db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject svn commit: r1702197 - /db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/manager/AbstractBaseManagerTest.java
Date Thu, 10 Sep 2015 09:35:40 GMT
Author: tv
Date: Thu Sep 10 09:35:40 2015
New Revision: 1702197

URL: http://svn.apache.org/r1702197
Log:
Some more tests.

Modified:
    db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/manager/AbstractBaseManagerTest.java

Modified: db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/manager/AbstractBaseManagerTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/manager/AbstractBaseManagerTest.java?rev=1702197&r1=1702196&r2=1702197&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/manager/AbstractBaseManagerTest.java
(original)
+++ db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/manager/AbstractBaseManagerTest.java
Thu Sep 10 09:35:40 2015
@@ -24,11 +24,12 @@ import junit.framework.TestCase;
 import org.apache.torque.BaseTestCase;
 import org.apache.torque.Torque;
 import org.apache.torque.TorqueException;
+import org.apache.torque.om.ObjectKey;
 import org.apache.torque.om.SimpleKey;
 
 public class AbstractBaseManagerTest extends TestCase
 {
-	private static final String TEST_PRIMARY_KEY = "testID";
+	private static final ObjectKey TEST_PRIMARY_KEY = SimpleKey.keyFor("testID");
 	private static final String CACHE_REGION = "testCache1";
 	private TestManager manager;
 
@@ -58,6 +59,16 @@ public class AbstractBaseManagerTest ext
 		this.manager.setRegion(CACHE_REGION);
 	}
 
+	/**
+	 * @see junit.framework.TestCase#tearDown()
+	 */
+	@Override
+	protected void tearDown() throws Exception
+	{
+		manager.cache.clear();
+		super.tearDown();
+	}
+
 	public void testGetOMInstance() throws TorqueException
 	{
 		TestPersistent test = manager.getOMInstance();
@@ -67,101 +78,68 @@ public class AbstractBaseManagerTest ext
 
 	public void testGetOMInstanceObjectKey() throws TorqueException
 	{
-		TestPersistent test = manager.getOMInstance(SimpleKey.keyFor(TEST_PRIMARY_KEY));
+		TestPersistent test = manager.getOMInstance(TEST_PRIMARY_KEY);
 		assertNotNull("Instance should not be null", test);
 		assertTrue("Instance should be a TestPersistent", test instanceof TestPersistent);
-		assertEquals("Instance should have id 'testID'", TEST_PRIMARY_KEY, test.getPrimaryKey().getValue());
+		assertEquals("Instance should have id 'testID'", TEST_PRIMARY_KEY, test.getPrimaryKey());
 	}
 
 	public void testGetOMInstanceObjectKeyBoolean() throws TorqueException
 	{
-		TestPersistent test1 = manager.getOMInstance(SimpleKey.keyFor(TEST_PRIMARY_KEY), false);
-		TestPersistent test2 = manager.getOMInstance(SimpleKey.keyFor(TEST_PRIMARY_KEY), false);
+		TestPersistent test1 = manager.getOMInstance(TEST_PRIMARY_KEY, false);
+		TestPersistent test2 = manager.getOMInstance(TEST_PRIMARY_KEY, false);
 		assertNotSame("Should be different instances", test1, test2);
 
-		TestPersistent test3 = manager.getOMInstance(SimpleKey.keyFor(TEST_PRIMARY_KEY), true);
-		TestPersistent test4 = manager.getOMInstance(SimpleKey.keyFor(TEST_PRIMARY_KEY), true);
+		TestPersistent test3 = manager.getOMInstance(TEST_PRIMARY_KEY, true);
+		TestPersistent test4 = manager.getOMInstance(TEST_PRIMARY_KEY, true);
 		assertSame("Should be same instances", test3, test4);
 	}
 
-/*
-	public void testCacheGet()
-	{
-		fail("Not yet implemented");
-	}
-
-	public void testClearImpl()
-	{
-		fail("Not yet implemented");
-	}
-
-	public void testDispose()
-	{
-		fail("Not yet implemented");
-	}
-
-	public void testRemoveInstanceImpl()
-	{
-		fail("Not yet implemented");
-	}
-
-	public void testPutInstanceImplT()
+	public void testCacheGet() throws TorqueException
 	{
-		fail("Not yet implemented");
+		TestPersistent test1 = manager.cacheGet(TEST_PRIMARY_KEY);
+		assertNull("Should not be in cache", test1);
+		test1 = manager.getOMInstance(TEST_PRIMARY_KEY, true);
+		TestPersistent test2 = manager.cacheGet(TEST_PRIMARY_KEY);
+		assertSame("Should be same instances", test1, test2);
 	}
 
-	public void testPutInstanceImplSerializableT()
+	public void testClearImpl() throws TorqueException
 	{
-		fail("Not yet implemented");
-
+		TestPersistent test1 = manager.getOMInstance(TEST_PRIMARY_KEY, true);
+		TestPersistent test2 = manager.cacheGet(TEST_PRIMARY_KEY);
+		assertNotNull("Should be in cache", test2);
+		manager.clearImpl();
+		TestPersistent test3 = manager.cacheGet(TEST_PRIMARY_KEY);
+		assertNull("Should not be in cache", test3);
 	}
 
-	public void testRetrieveStoredOM()
+	public void testRemoveInstanceImpl() throws TorqueException
 	{
-		fail("Not yet implemented");
+		TestPersistent test1 = manager.getOMInstance(TEST_PRIMARY_KEY, true);
+		TestPersistent test2 = manager.removeInstanceImpl(TEST_PRIMARY_KEY);
+		assertSame("Should be same instances", test1, test2);
+		TestPersistent test3 = manager.cacheGet(TEST_PRIMARY_KEY);
+		assertNull("Should not be in cache", test3);
 	}
 
-	public void testGetOMsObjectKeyArray()
+	public void testPutInstanceImplSerializableT() throws TorqueException
 	{
-		fail("Not yet implemented");
-	}
-
-	public void testGetOMsListOfQextendsObjectKey()
-	{
-		fail("Not yet implemented");
-	}
-
-	public void testGetOMsListOfQextendsObjectKeyBoolean()
-	{
-
-		fail("Not yet implemented");
-	}
-
-	public void testRetrieveStoredOMs()
-	{
-		fail("Not yet implemented");
-	}
-
-	public void testGetRegion()
-	{
-		fail("Not yet implemented");
-	}
-
-	public void testSetRegion()
-	{
-		fail("Not yet implemented");
+		TestPersistent test1 = manager.getOMInstance(TEST_PRIMARY_KEY, true);
+		TestPersistent test2 = manager.getOMInstance(TEST_PRIMARY_KEY, false);
+		TestPersistent test3 = manager.putInstanceImpl(TEST_PRIMARY_KEY, test2);
+		assertSame("Should be same instances", test1, test3);
+		TestPersistent test4 = manager.cacheGet(TEST_PRIMARY_KEY);
+		assertSame("Should be same instances", test2, test4);
 	}
 
 	public void testGetMethodResultCache()
 	{
-		fail("Not yet implemented");
-	}
-
-	public void testRegisterAsListener()
-	{
-		fail("Not yet implemented");
+		MethodResultCache mrc = manager.getMethodResultCache();
+		assertNotNull("Should have MethodResultCache", mrc);
 	}
 
+/*
 	public void testAddCacheListenerImpl()
 	{
 		fail("Not yet implemented");



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message