Author: tfischer Date: Fri Aug 30 01:07:07 2013 New Revision: 1518866 URL: http://svn.apache.org/r1518866 Log: Tests for TORQUE-300 and TORQUE-301
Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/ManagerTestConditional.java Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/ManagerTestConditional.java URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/ManagerTestConditional.java?rev=1518866&r1=1518865&r2=1518866&view=diff ============================================================================== --- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/ManagerTestConditional.java (original) +++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/ManagerTestConditional.java Fri Aug 30 01:07:07 2013 @@ -19,6 +19,10 @@ package org.apache.torque; * under the License. */ +import java.util.ArrayList; +import java.util.List; + +import org.apache.torque.om.ObjectKey; import org.apache.torque.test.dbobject.Author; import org.apache.torque.test.dbobject.Book; import org.apache.torque.test.dbobject.IfcTable; @@ -41,6 +45,8 @@ public class ManagerTestConditional exte public void testManagers() throws Exception { cleanBookstore(); + AuthorManager.clear(); + BookManager.clear(); AuthorManager.getManager().setRegion("om_Author"); BookManager.getManager().setRegion("om_Book"); @@ -67,6 +73,57 @@ public class ManagerTestConditional exte } /** + * Tests whether the getInstances method works. + * + * @throws Exception if the test fails + */ + public void testGetInstances() throws Exception + { + cleanBookstore(); + AuthorManager.clear(); + AuthorManager.getManager().setRegion("om_Author"); + + Author author1 = new Author(); + author1.setName("author1"); + author1.save(); + Author author2 = new Author(); + author2.setName("author2"); + author2.save(); + + List<ObjectKey> authorKeys = new ArrayList<ObjectKey>(); + authorKeys.add(author1.getPrimaryKey()); + authorKeys.add(author2.getPrimaryKey()); + List<Author> authors = AuthorManager.getInstances(authorKeys); + assertSame(author1, authors.get(0)); + assertSame(author2, authors.get(1)); + } + + /** + * Tests whether the getInstances method returns null + * if null is supplied as argument. + * + * @throws Exception if the test fails + */ + public void testGetInstancesNull() throws Exception + { + List<Author> authors = AuthorManager.getInstances(null); + assertNull(authors); + } + + /** + * Tests whether the getInstances method returns the empty list + * if the empty list is supplied as argument. + * + * @throws Exception if the test fails + */ + public void testGetInstancesEmpty() throws Exception + { + List<Author> authors + = AuthorManager.getInstances(new ArrayList<ObjectKey>()); + assertEquals(new ArrayList<Author>(), authors); + } + + /** * Tests whether managers return the right interface * @throws Exception if the test fails */ --------------------------------------------------------------------- To unsubscribe, e-mail: torque-dev-unsubscr...@db.apache.org For additional commands, e-mail: torque-dev-h...@db.apache.org