Return-Path: Delivered-To: apmail-db-torque-dev-archive@www.apache.org Received: (qmail 13039 invoked from network); 24 Aug 2005 12:39:16 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 24 Aug 2005 12:39:16 -0000 Received: (qmail 21475 invoked by uid 500); 24 Aug 2005 12:39:15 -0000 Delivered-To: apmail-db-torque-dev-archive@db.apache.org Received: (qmail 21444 invoked by uid 500); 24 Aug 2005 12:39:15 -0000 Mailing-List: contact torque-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Apache Torque Developers List" Reply-To: "Apache Torque Developers List" Delivered-To: mailing list torque-dev@db.apache.org Received: (qmail 21419 invoked by uid 500); 24 Aug 2005 12:39:15 -0000 Received: (qmail 21406 invoked by uid 99); 24 Aug 2005 12:39:14 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Wed, 24 Aug 2005 05:39:09 -0700 Received: (qmail 13014 invoked by uid 65534); 24 Aug 2005 12:39:09 -0000 Message-ID: <20050824123909.13012.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r239636 [2/4] - in /db/torque/runtime/trunk: ./ conf/ src/conf/ src/java/org/apache/torque/ src/java/org/apache/torque/adapter/ src/java/org/apache/torque/avalon/ src/java/org/apache/torque/dsfactory/ src/java/org/apache/torque/manager/ src... Date: Wed, 24 Aug 2005 12:38:54 -0000 To: torque-commits@db.apache.org From: henning@apache.org X-Mailer: svnmailer-1.0.3 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Modified: db/torque/runtime/trunk/src/rttest/bookstore-schema.xml URL: http://svn.apache.org/viewcvs/db/torque/runtime/trunk/src/rttest/bookstore-schema.xml?rev=239636&r1=239635&r2=239636&view=diff ============================================================================== --- db/torque/runtime/trunk/src/rttest/bookstore-schema.xml (original) +++ db/torque/runtime/trunk/src/rttest/bookstore-schema.xml Wed Aug 24 05:38:09 2005 @@ -17,8 +17,8 @@ - @@ -87,7 +87,7 @@ - @@ -97,7 +97,7 @@ - +
@@ -255,14 +255,14 @@ - + - +
- +
Modified: db/torque/runtime/trunk/src/rttest/id-table-schema.xml URL: http://svn.apache.org/viewcvs/db/torque/runtime/trunk/src/rttest/id-table-schema.xml?rev=239636&r1=239635&r2=239636&view=diff ============================================================================== --- db/torque/runtime/trunk/src/rttest/id-table-schema.xml (original) +++ db/torque/runtime/trunk/src/rttest/id-table-schema.xml Wed Aug 24 05:38:09 2005 @@ -34,10 +34,10 @@ - + - - + + - + Modified: db/torque/runtime/trunk/src/rttest/org/apache/torque/BeanTest.java URL: http://svn.apache.org/viewcvs/db/torque/runtime/trunk/src/rttest/org/apache/torque/BeanTest.java?rev=239636&r1=239635&r2=239636&view=diff ============================================================================== --- db/torque/runtime/trunk/src/rttest/org/apache/torque/BeanTest.java (original) +++ db/torque/runtime/trunk/src/rttest/org/apache/torque/BeanTest.java Wed Aug 24 05:38:09 2005 @@ -36,17 +36,17 @@ public class BeanTest extends BaseRuntimeTestCase { public static final String AUTHOR_1_NAME = "Joshua Bloch"; - + public static final int AUTHOR_1_ID = 123; - + public static final String BOOK_1_TITLE = "Effective Java"; - + public static final String BOOK_1_ISBN = "0-618-12902-2"; - + public static final int BOOK_1_ID = 456; public static final String AUTHOR_2_NAME = "W. Stevens"; - + /** * Creates a new instance. */ @@ -68,15 +68,15 @@ Author author = new Author(); author.setName(AUTHOR_1_NAME); author.setAuthorId(AUTHOR_1_ID); - + AuthorBean authorBean = author.getBean(); - assertTrue("bean.getName() is " + authorBean.getName() + assertTrue("bean.getName() is " + authorBean.getName() + " should be " + author.getName(), author.getName().equals(authorBean.getName())); - assertTrue("bean.getId() is " + authorBean.getAuthorId() + assertTrue("bean.getId() is " + authorBean.getAuthorId() + " should be " + AUTHOR_1_ID, author.getAuthorId() == authorBean.getAuthorId()); - + Author authorFromBean = Author.createAuthor(authorBean); assertTrue("author from bean has name " + authorFromBean.getName() + " should be " + author.getName(), @@ -85,7 +85,7 @@ + " should be " + author.getAuthorId(), author.getAuthorId() == authorBean.getAuthorId()); } - + /** * tests whether object relations are transferred correctly, * if two objects refer to each other @@ -94,30 +94,30 @@ { Author author = new Author(); author.setAuthorId(AUTHOR_1_ID); - + Book book = new Book(); book.setBookId(BOOK_1_ID); - + author.addBook(book); book.setAuthor(author); - + // check one roundtrip from author assertTrue("author from book should be the same object as author", author == book.getAuthor()); - + AuthorBean authorBean = author.getBean(); BookBean bookBean = (BookBean) authorBean.getBookBeans().get(0); assertTrue("authorBean from BookBean should be the same " + "object as authorBean", bookBean.getAuthorBean() == authorBean); - + author = Author.createAuthor(authorBean); book = (Book) author.getBooks().get(0); - + assertTrue("author from book should be the same object as author " + "after creating from bean", author == book.getAuthor()); - + // check one roundtrip from book assertTrue("book from author should be the same object as book", book == author.getBooks().get(0)); @@ -135,34 +135,34 @@ + "after creating from bean", author.getBooks().get(0) == book); } - + /** * tests whether object relations are transferred correctly, * if there is no mutual reference between objects * @throws Exception */ - public void testDifferentObjectRelations() throws Exception + public void testDifferentObjectRelations() throws Exception { // create a relation chain: // // getBooks() getAuthor() getBooks() - // | | | + // | | | // author ----> book -----> differentAuthor ---> differentBook Author author = new Author(); author.setAuthorId(AUTHOR_1_ID); Book book = new Book(); book.setBookId(BOOK_1_ID); - + Author differentAuthor = new Author(); author.setAuthorId(AUTHOR_1_ID); author.addBook(book); book.setAuthor(differentAuthor); - + Book differentBook = new Book(); book.setBookId(BOOK_1_ID); - + differentAuthor.addBook(differentBook); // check one roundtrip from author @@ -183,7 +183,7 @@ author != book.getAuthor()); // check one roundtrip from book - assertTrue("book from differentAuthor should not be " + assertTrue("book from differentAuthor should not be " + "the same object as book", book != differentAuthor.getBooks().get(0)); @@ -207,63 +207,63 @@ Criteria criteria = new Criteria(); criteria.add(BookPeer.BOOK_ID, (Long) null, Criteria.NOT_EQUAL); BookPeer.doDelete(criteria); - + criteria = new Criteria(); criteria.add(AuthorPeer.AUTHOR_ID, (Long) null, Criteria.NOT_EQUAL); AuthorPeer.doDelete(criteria); - + Author author = new Author(); author.setName(AUTHOR_1_NAME); author.save(); - + assertFalse("isModified() should return false after save", author.isModified()); assertFalse("isNew() should return false after save", author.isNew()); - + AuthorBean authorBean = author.getBean(); - + assertFalse("bean.isModified() should return false after save " + "and bean creation", authorBean.isModified()); assertFalse("bean.isNew() should return false after save " + "and bean creation", authorBean.isNew()); - + author = Author.createAuthor(authorBean); - + assertFalse("isModified() should return false after save " + "and bean roundtrip", author.isModified()); assertFalse("isNew() should return false after save " + "and bean rounddtrip", author.isNew()); - + authorBean.setName(AUTHOR_2_NAME); assertTrue("bean.isModified() should return true after it was modified", authorBean.isModified()); - assertFalse("bean.isNew() should still return false " + assertFalse("bean.isNew() should still return false " + "after bean creation and modification", authorBean.isNew()); - + author = Author.createAuthor(authorBean); assertTrue("isModified() should return true after creation of object " + "from modified bean", author.isModified()); - + author.save(); - + List authorList = AuthorPeer.doSelect(new Criteria()); Author readAuthor = (Author) authorList.get(0); - assertEquals("name from read Author is " + readAuthor.getName() + assertEquals("name from read Author is " + readAuthor.getName() +" but should be " + authorBean.getName(), readAuthor.getName(), authorBean.getName()); - + BookBean bookBean = new BookBean(); bookBean.setTitle(BOOK_1_TITLE); bookBean.setIsbn(BOOK_1_ISBN); - + Book book = Book.createBook(bookBean); assertTrue("isModified() should return true after creation of object " + " from new bean", @@ -273,9 +273,9 @@ book.isNew()); book.setAuthor(author); book.save(); - + List bookList = BookPeer.doSelect(new Criteria()); - assertTrue("Ther should be one book in DB but there are " + assertTrue("Ther should be one book in DB but there are " + bookList.size(), bookList.size() == 1); } Modified: db/torque/runtime/trunk/src/rttest/org/apache/torque/DataTest.java URL: http://svn.apache.org/viewcvs/db/torque/runtime/trunk/src/rttest/org/apache/torque/DataTest.java?rev=239636&r1=239635&r2=239636&view=diff ============================================================================== --- db/torque/runtime/trunk/src/rttest/org/apache/torque/DataTest.java (original) +++ db/torque/runtime/trunk/src/rttest/org/apache/torque/DataTest.java Wed Aug 24 05:38:09 2005 @@ -71,7 +71,7 @@ public class DataTest extends BaseRuntimeTestCase { private static Log log = LogFactory.getLog(DataTest.class);; - + /** * Creates a new instance. */ @@ -92,13 +92,13 @@ public void testConnect() throws Exception { Connection connection = null; - try + try { connection = Torque.getConnection(); connection.close(); connection = null; } - finally + finally { if (connection != null) { @@ -106,7 +106,7 @@ } } } - + /** * does some inserts. * @throws Exception if the test fails @@ -135,7 +135,7 @@ Criteria criteria = new Criteria(); criteria.add(BooleanCheckPeer.TEST_KEY, (Object) null, Criteria.NOT_EQUAL); BooleanCheckPeer.doDelete(criteria); - + BooleanCheck bc = new BooleanCheck(); bc.setTestKey("t1"); bc.setBintValue(true); @@ -158,7 +158,7 @@ Criteria criteria = new Criteria(); criteria.add(MultiPkPeer.PK1, (Object) null, Criteria.NOT_EQUAL); MultiPkPeer.doDelete(criteria); - + // do test MultiPk mpk = new MultiPk(); mpk.setPrimaryKey("Svarchar:N5:Schar:"); @@ -166,7 +166,7 @@ } private static final String[] validTitles = { - "Book 7 - Author 8", "Book 6 - Author 8", "Book 7 - Author 7", + "Book 7 - Author 8", "Book 6 - Author 8", "Book 7 - Author 7", "Book 6 - Author 7", "Book 7 - Author 6", "Book 6 - Author 6", "Book 7 - Author 5", "Book 6 - Author 5", "Book 7 - Author 4", "Book 6 - Author 4"}; @@ -178,31 +178,31 @@ public void testLimitOffset() throws Exception { Map titleMap = new HashMap(); - for (int j = 0; j < validTitles.length; j++) + for (int j = 0; j < validTitles.length; j++) { titleMap.put(validTitles[j], null); } Criteria crit = new Criteria(); - Criteria.Criterion c = crit.getNewCriterion(BookPeer.TITLE, + Criteria.Criterion c = crit.getNewCriterion(BookPeer.TITLE, (Object) "Book 6 - Author 1", Criteria.GREATER_EQUAL); - c.and(crit.getNewCriterion(BookPeer.TITLE, + c.and(crit.getNewCriterion(BookPeer.TITLE, (Object) "Book 8 - Author 3", Criteria.LESS_EQUAL)); crit.add(c); crit.addDescendingOrderByColumn(BookPeer.BOOK_ID); crit.setLimit(10); crit.setOffset(5); List books = BookPeer.doSelect(crit); - assertTrue("List should have 10 books, not " + books.size(), + assertTrue("List should have 10 books, not " + books.size(), books.size() == 10); - for (Iterator i = books.iterator(); i.hasNext();) + for (Iterator i = books.iterator(); i.hasNext();) { String title = ((Book) i.next()).getTitle(); - assertTrue("Incorrect title: " + title, + assertTrue("Incorrect title: " + title, titleMap.containsKey(title)); } } - + /** * Checks whether the setSingleRecord() method in criteria works */ @@ -213,9 +213,9 @@ criteria.setLimit(1); criteria.setOffset(5); List books = BookPeer.doSelect(criteria); - assertTrue("List should have 1 books, not " + books.size(), + assertTrue("List should have 1 books, not " + books.size(), books.size() == 1); - + criteria.clear(); criteria.setSingleRecord(true); criteria.setLimit(2); @@ -227,14 +227,14 @@ + " and one was expected"); } catch (TorqueException e) - { + { } } - + /** * tests whether null values can be processed successfully by datadump * For this, a row containing null values is inserted here, - * the actual test is done later + * the actual test is done later * @throws Exception if inserting the test data fails */ public void testDataDump() throws Exception @@ -246,7 +246,7 @@ nvt.setNumberObj1(new Integer(1)); nvt.save(); } - + /** * test boolean values * @throws Exception if the test fails @@ -254,17 +254,17 @@ public void testBooleanValues() throws Exception { BooleanCheck bc = BooleanCheckPeer.retrieveByPK(new StringKey("t1")); - assertTrue("BOOLEANINT should be true but is: " + assertTrue("BOOLEANINT should be true but is: " + bc.getBintValue(), bc.getBintValue()); - assertTrue("BOOLEANCHAR should be true but is: " + assertTrue("BOOLEANCHAR should be true but is: " + bc.getBcharValue(), bc.getBcharValue()); bc = BooleanCheckPeer.retrieveByPK(new StringKey("f1")); - assertFalse("BOOLEANINT should be false but is: " + assertFalse("BOOLEANINT should be false but is: " + bc.getBintValue(), bc.getBintValue()); - assertFalse("BOOLEANCHAR should be false but is: " + assertFalse("BOOLEANCHAR should be false but is: " + bc.getBcharValue(), bc.getBcharValue()); } - + /** * Tests whether column type BIT can be written and read correctly * and works in criteria as expected @@ -278,12 +278,12 @@ // failing is "expected", so exit without error return; } - + // clean table Criteria criteria = new Criteria(); criteria.add(BitTestPeer.ID, (Object) null, Criteria.NOT_EQUAL); BitTestPeer.doDelete(criteria); - + // insert Data BitTest bitTest = new BitTest(); bitTest.setId("t1"); @@ -296,19 +296,19 @@ // read data bitTest = BitTestPeer.retrieveByPK(new StringKey("t1")); - assertTrue("BIT should be true but is: " + assertTrue("BIT should be true but is: " + bitTest.getBitValue(), bitTest.getBitValue()); - + bitTest = BitTestPeer.retrieveByPK(new StringKey("f1")); - assertFalse("BIT should be false but is: " + assertFalse("BIT should be false but is: " + bitTest.getBitValue(), bitTest.getBitValue()); - + // query data criteria.clear(); criteria.add(BitTestPeer.BIT_VALUE, new Boolean(true)); List bitTestList = BitTestPeer.doSelect(criteria); assertTrue("Should have read 1 dataset " - + "but read " + bitTestList.size(), + + "but read " + bitTestList.size(), bitTestList.size() == 1); bitTest = (BitTest) bitTestList.get(0); // use trim() for testkey because some databases will return the @@ -321,7 +321,7 @@ criteria.add(BitTestPeer.BIT_VALUE, new Boolean(false)); bitTestList = BitTestPeer.doSelect(criteria); assertTrue("Should have read 1 dataset " - + "but read " + bitTestList.size(), + + "but read " + bitTestList.size(), bitTestList.size() == 1); bitTest = (BitTest) bitTestList.get(0); assertTrue("Primary key of data set should be f1 but is " @@ -329,9 +329,9 @@ "f1".equals(bitTest.getId().trim())); } - + /** - * check whether we can select from boolean columns + * check whether we can select from boolean columns * @throws Exception if the test fails */ public void testBooleanSelects() throws Exception @@ -341,7 +341,7 @@ criteria.add(BooleanCheckPeer.BINT_VALUE, new Boolean(true)); List booleanCheckList = BooleanCheckPeer.doSelect(criteria); assertTrue("Should have read 1 dataset with both values true " - + "but read " + booleanCheckList.size(), + + "but read " + booleanCheckList.size(), booleanCheckList.size() == 1); BooleanCheck booleanCheck = (BooleanCheck) booleanCheckList.get(0); // use trim() for testkey because some databases will return the @@ -349,13 +349,13 @@ assertTrue("Primary key of data set should be t1 but is " + booleanCheck.getTestKey().trim(), "t1".equals(booleanCheck.getTestKey().trim())); - + criteria.clear(); criteria.add(BooleanCheckPeer.BCHAR_VALUE, new Boolean(false)); criteria.add(BooleanCheckPeer.BINT_VALUE, new Boolean(false)); booleanCheckList = BooleanCheckPeer.doSelect(criteria); assertTrue("Should have read 1 dataset with both values false " - + "but read " + booleanCheckList.size(), + + "but read " + booleanCheckList.size(), booleanCheckList.size() == 1); booleanCheck = (BooleanCheck) booleanCheckList.get(0); assertTrue("Primary key of data set should be f1 but is " @@ -370,7 +370,7 @@ public void testDelete() throws Exception { cleanBookstore(); - + Author author = new Author(); author.setName("Name"); author.save(); @@ -384,8 +384,8 @@ // delete without matching data Criteria criteria = new Criteria(); criteria.add( - AuthorPeer.AUTHOR_ID, - author.getAuthorId(), + AuthorPeer.AUTHOR_ID, + author.getAuthorId(), Criteria.NOT_EQUAL); AuthorPeer.doDelete(criteria); List authorResult = AuthorPeer.doSelect(new Criteria()); @@ -395,10 +395,10 @@ List bookResult = BookPeer.doSelect(new Criteria()); authorResult = AuthorPeer.doSelect(new Criteria()); // check that the book has disappeared - assertTrue("delete by object failed", + assertTrue("delete by object failed", bookResult.size() == 0); // check that the underlying author has not been deleted - assertTrue("delete by object deleted in cascade", + assertTrue("delete by object deleted in cascade", authorResult.size() == 1); // delete with matching data @@ -406,46 +406,46 @@ criteria.add(AuthorPeer.AUTHOR_ID, author.getAuthorId()); AuthorPeer.doDelete(criteria); authorResult = AuthorPeer.doSelect(new Criteria()); - assertTrue("deleted not enough records", + assertTrue("deleted not enough records", authorResult.size() == 0); } - + /** * test special cases in the select clause * @throws Exception if the test fails */ public void testSelectClause() throws Exception - { + { // test double functions in select columns Criteria criteria = new Criteria(); criteria.addSelectColumn("count(distinct(" + BookPeer.BOOK_ID + "))"); List result = BookPeer.doSelectVillageRecords(criteria); - + // test qualifiers in function in select columns criteria = new Criteria(); criteria.addSelectColumn("count(distinct " + BookPeer.BOOK_ID + ")"); result = BookPeer.doSelectVillageRecords(criteria); } - + /** * test the behaviour if a connection is supplied to access the database, - * but it is null. All methods on the user level should be able to + * but it is null. All methods on the user level should be able to * handle this. */ public void testNullConnection() throws Exception { Criteria criteria = new Criteria(); List result = BookPeer.doSelectVillageRecords(criteria, null); - + criteria = new Criteria(); criteria.add(BookPeer.BOOK_ID, (Long) null, Criteria.NOT_EQUAL); BookPeer.doDelete(criteria, null); - + Author author = new Author(); author.setName("name"); author.save((Connection) null); } - + /** * test joins * @throws Exception if the test fails @@ -463,7 +463,7 @@ book.setTitle("Book 1"); book.setIsbn("unknown"); book.save(); - + author = new Author(); author.setName("Author without book"); author.save(); @@ -471,7 +471,7 @@ author = new Author(); author.setName("Author with three books"); author.save(); - for (int bookNr = 2; bookNr <=4; bookNr++) + for (int bookNr = 2; bookNr <=4; bookNr++) { book = new Book(); book.setAuthor(author); @@ -488,14 +488,14 @@ // Here we get 5 authors: // the author with one book, the author without books, // and three times the author with three books - if (authorList.size() != 5) + if (authorList.size() != 5) { fail("author left join book : " - + "incorrect numbers of authors found : " + + "incorrect numbers of authors found : " + authorList.size() + ", should be 5"); } - + // test inner join criteria = new Criteria(); criteria.addJoin( @@ -503,12 +503,12 @@ Criteria.INNER_JOIN); authorList = AuthorPeer.doSelect(criteria); // Here we get 4 authors: - // the author with one book, + // the author with one book, // and three times the author with three books - if (authorList.size() != 4) + if (authorList.size() != 4) { fail("author left join book : " - + "incorrect numbers of authors found : " + + "incorrect numbers of authors found : " + authorList.size() + ", should be 4"); } @@ -529,14 +529,14 @@ // Here we get 4 authors: // the author with one book, the author without books, // and three times the author with three books - if (authorList.size() != 5) + if (authorList.size() != 5) { fail("book right join author " - + "incorrect numbers of authors found : " + + "incorrect numbers of authors found : " + authorList.size() + ", should be 5"); } - + // test double join with aliases criteria = new Criteria(); criteria.addAlias("b", BookPeer.TABLE_NAME); @@ -544,21 +544,21 @@ BookPeer.AUTHOR_ID, AuthorPeer.AUTHOR_ID, Criteria.RIGHT_JOIN); criteria.addJoin( - AuthorPeer.AUTHOR_ID, + AuthorPeer.AUTHOR_ID, "b." + getRawColumnName(BookPeer.AUTHOR_ID), Criteria.LEFT_JOIN); authorList = AuthorPeer.doSelect(criteria); // Here we get 11 authors: // the author with one book, the author without books, // and nine times the author with three books - if (authorList.size() != 11) + if (authorList.size() != 11) { fail("book right join author left join book b: " - + "incorrect numbers of authors found : " + + "incorrect numbers of authors found : " + authorList.size() + ", should be 11"); } - + // test double join with aliases and "reversed" second join criteria = new Criteria(); criteria.addAlias("b", BookPeer.TABLE_NAME); @@ -572,16 +572,16 @@ // Here we get 11 authors: // the author with one book, the author without books, // and nine times the author with three books - if (authorList.size() != 11) + if (authorList.size() != 11) { fail("book right join author left join book b (reversed): " - + "incorrect numbers of authors found : " + + "incorrect numbers of authors found : " + authorList.size() + ", should be 11"); } } - - + + /** * Test joins using the XPeer.DoSelectJoinYYY methods * @throws Exception if the Test fails @@ -592,7 +592,7 @@ Criteria criteria = new Criteria(); criteria.addAscendingOrderByColumn(BookPeer.TITLE); List books = MyBookPeer.doSelectJoinAuthor(criteria); - assertTrue("books should contain 4 books but contains " + assertTrue("books should contain 4 books but contains " + books.size(), books.size() == 4); Book bookTwo = (Book) books.get(1); Book bookThree = (Book) books.get(2); @@ -618,11 +618,11 @@ book.setTitle("Book 1"); book.setIsbn("unknown"); book.save(); - + Author secondAuthor = new Author(); secondAuthor.setName("Author 2"); secondAuthor.save(); - for (int bookNr = 2; bookNr <=4; bookNr++) + for (int bookNr = 2; bookNr <=4; bookNr++) { book = new Book(); book.setAuthor(secondAuthor); @@ -630,65 +630,65 @@ book.setIsbn("unknown"); book.save(); } - + // test simple ascending order by Criteria criteria = new Criteria(); criteria.addAscendingOrderByColumn(BookPeer.TITLE); List bookList = BookPeer.doSelect(criteria); - if (bookList.size() != 4) + if (bookList.size() != 4) { fail("Ascending Order By: " - + "incorrect numbers of books found : " + + "incorrect numbers of books found : " + bookList.size() + ", should be 4"); } - if (! "Book 1".equals(((Book) bookList.get(0)).getTitle())) + if (! "Book 1".equals(((Book) bookList.get(0)).getTitle())) { fail("Ascending Order By: " - + "Title of first Book is " + + "Title of first Book is " + ((Book) bookList.get(0)).getTitle() + ", should be \"Book 1\""); } - if (! "Book 4".equals(((Book) bookList.get(3)).getTitle())) + if (! "Book 4".equals(((Book) bookList.get(3)).getTitle())) { fail("Ascending Order By: " - + "Title of fourth Book is " + + "Title of fourth Book is " + ((Book) bookList.get(3)).getTitle() + ", should be \"Book 4\""); } - + // test simple descending order by criteria = new Criteria(); criteria.addDescendingOrderByColumn(BookPeer.TITLE); bookList = BookPeer.doSelect(criteria); - if (bookList.size() != 4) + if (bookList.size() != 4) { fail("Descending Order By: " - + "incorrect numbers of books found : " + + "incorrect numbers of books found : " + bookList.size() + ", should be 4"); } - if (! "Book 1".equals(((Book) bookList.get(3)).getTitle())) + if (! "Book 1".equals(((Book) bookList.get(3)).getTitle())) { fail("Descending Order By: " - + "Title of fourth Book is " + + "Title of fourth Book is " + ((Book) bookList.get(3)).getTitle() + ", should be \"Book 1\""); } - if (! "Book 4".equals(((Book) bookList.get(0)).getTitle())) + if (! "Book 4".equals(((Book) bookList.get(0)).getTitle())) { fail("Descending Order By: " - + "Title of first Book is " + + "Title of first Book is " + ((Book) bookList.get(0)).getTitle() + ", should be \"Book 4\""); } - + // test ordering by Aliases and in joins criteria = new Criteria(); criteria.addAlias("b", BookPeer.TABLE_NAME); criteria.addJoin(BookPeer.AUTHOR_ID, AuthorPeer.AUTHOR_ID); criteria.addJoin( - AuthorPeer.AUTHOR_ID, + AuthorPeer.AUTHOR_ID, "b." + getRawColumnName(BookPeer.AUTHOR_ID)); criteria.addAscendingOrderByColumn( "b." + getRawColumnName(BookPeer.TITLE)); @@ -702,33 +702,33 @@ // author2 book4 book3 // ... bookList = BookPeer.doSelect(criteria); - if (bookList.size() != 10) + if (bookList.size() != 10) { fail("ordering by Aliases: " - + "incorrect numbers of books found : " + + "incorrect numbers of books found : " + bookList.size() + ", should be 10"); } - if (!"Book 4".equals(((Book)bookList.get(1)).getTitle())) + if (!"Book 4".equals(((Book)bookList.get(1)).getTitle())) { fail("ordering by Aliases: " - + "Title of second Book is " + + "Title of second Book is " + ((Book) bookList.get(1)).getTitle() + ", should be \"Book 4\""); } - if (!"Book 3".equals(((Book)bookList.get(2)).getTitle())) + if (!"Book 3".equals(((Book)bookList.get(2)).getTitle())) { fail("ordering by Aliases: " - + "Title of third Book is " + + "Title of third Book is " + ((Book) bookList.get(2)).getTitle() + ", should be \"Book 3\""); } - + criteria = new Criteria(); criteria.addAlias("b", BookPeer.TABLE_NAME); criteria.addJoin(BookPeer.AUTHOR_ID, AuthorPeer.AUTHOR_ID); criteria.addJoin( - AuthorPeer.AUTHOR_ID, + AuthorPeer.AUTHOR_ID, "b." + getRawColumnName(BookPeer.AUTHOR_ID)); criteria.addAscendingOrderByColumn(BookPeer.TITLE); criteria.addDescendingOrderByColumn( @@ -742,36 +742,36 @@ // author2 book3 book4 // ... bookList = BookPeer.doSelect(criteria); - if (bookList.size() != 10) + if (bookList.size() != 10) { fail("ordering by Aliases (2): " - + "incorrect numbers of books found : " + + "incorrect numbers of books found : " + bookList.size() + ", should be 10"); } - if (!"Book 2".equals(((Book)bookList.get(1)).getTitle())) + if (!"Book 2".equals(((Book)bookList.get(1)).getTitle())) { fail("ordering by Aliases (2, PS): " - + "Title of second Book is " + + "Title of second Book is " + ((Book) bookList.get(1)).getTitle() + ", should be \"Book 2\""); } - if (!"Book 2".equals(((Book)bookList.get(2)).getTitle())) + if (!"Book 2".equals(((Book)bookList.get(2)).getTitle())) { fail("ordering by Aliases (2, PS): " - + "Title of third Book is " + + "Title of third Book is " + ((Book) bookList.get(2)).getTitle() + ", should be \"Book 2\""); } - + // test usage of Expressions in order by criteria = new Criteria(); criteria.addAscendingOrderByColumn("UPPER(" + BookPeer.TITLE + ")"); criteria.setIgnoreCase(true); BookPeer.doSelect(criteria); } - - + + /** * Tests whether ignoreCase works correctly * @throws Exception if the test fails @@ -783,17 +783,17 @@ Author author = new Author(); author.setName("AuTHor"); author.save(); - + Criteria criteria = new Criteria(); criteria.add(AuthorPeer.NAME, author.getName().toLowerCase()); criteria.setIgnoreCase(true); List result = AuthorPeer.doSelect(criteria); - if (result.size() != 1) + if (result.size() != 1) { fail("Size of result is not 1, but " + result.size()); } } - + /** * tests whether AsColumns produce valid SQL code * @throws Exception if the test fails @@ -807,7 +807,7 @@ criteria.addSelectColumn(AuthorPeer.AUTHOR_ID); BasePeer.doSelect(criteria); } - + /** * Test whether same column name in different tables * are handled correctly @@ -819,17 +819,17 @@ Author author = new Author(); author.setName("Name"); author.save(); - + author = new Author(); author.setName("NotCorrespondingName"); author.save(); - + Book book = new Book(); book.setTitle("Name"); book.setAuthor(author); book.setIsbn("unknown"); book.save(); - + Criteria criteria = new Criteria(); criteria.addJoin(BookPeer.TITLE, AuthorPeer.NAME); BookPeer.addSelectColumns(criteria); @@ -847,7 +847,7 @@ fail("wrong Ids read"); } } - + /** * Tests the date, time and datetime accuracy. * At the moment, no upper limit for the accuracy is checked, @@ -859,11 +859,11 @@ // clean Date table Criteria criteria = new Criteria(); criteria.add( - DateTestPeer.DATE_TEST_ID, - (Long) null, + DateTestPeer.DATE_TEST_ID, + (Long) null, Criteria.NOT_EQUAL); DateTestPeer.doDelete(criteria); - + // insert new DateTest object to db DateTest dateTest = new DateTest(); Date now = new Date(); @@ -873,47 +873,47 @@ dateTest.save(); DateFormat dateFormat = new SimpleDateFormat(); System.out.println( - "testDateTime() : set date to : " + "testDateTime() : set date to : " + dateFormat.format(now)); - + // reload dateTest from db - DateTest loadedDateTest + DateTest loadedDateTest = DateTestPeer.retrieveByPK(dateTest.getPrimaryKey()); - + System.out.println( - "testDateTime() : retrieved date : " + "testDateTime() : retrieved date : " + dateFormat.format(loadedDateTest.getDateValue())); System.out.println( - "testDateTime() : retrieved time : " + "testDateTime() : retrieved time : " + dateFormat.format(loadedDateTest.getTimeValue())); System.out.println( - "testDateTime() : retrieved timestamp : " + "testDateTime() : retrieved timestamp : " + dateFormat.format(loadedDateTest.getTimestampValue())); // compute time differences between reloaded and original object - long dateDifference + long dateDifference = dateTest.getDateValue().getTime() - loadedDateTest.getDateValue().getTime(); - long timeDifference + long timeDifference = dateTest.getTimeValue().getTime() - loadedDateTest.getTimeValue().getTime(); - long timestampDifference + long timestampDifference = dateTest.getTimestampValue().getTime() - loadedDateTest.getTimestampValue().getTime(); - + System.out.println( - "testDateTime() : Date difference (ms): " + "testDateTime() : Date difference (ms): " + dateDifference); System.out.println( - "testDateTime() : Time difference (ms): " + "testDateTime() : Time difference (ms): " + timeDifference); System.out.println( - "testDateTime() : Timestamp difference (ms): " + "testDateTime() : Timestamp difference (ms): " + timestampDifference); } - + /** - * tests whether large primary keys are inserted and read correctly + * tests whether large primary keys are inserted and read correctly * @throws Exception if the test fails */ public void testLargePk() throws Exception @@ -921,8 +921,8 @@ // clean LargePk table Criteria criteria = new Criteria(); criteria.add( - LargePkPeer.LARGE_PK_ID, - (Long) null, + LargePkPeer.LARGE_PK_ID, + (Long) null, Criteria.NOT_EQUAL); LargePkPeer.doDelete(criteria); @@ -931,7 +931,7 @@ largePk.setLargePkId(longId); largePk.setName("testLargePk"); largePk.save(); - + List largePkList = LargePkPeer.doSelect(new Criteria()); LargePk readLargePk = (LargePk) largePkList.get(0); assertTrue("the inserted Id, " + largePk.getLargePkId() @@ -942,7 +942,7 @@ + " , should be equal to " + longId, longId == largePk.getLargePkId()); } - + /** * Tests the CountHelper class * @throws Exception if the test fails @@ -953,29 +953,29 @@ Author author = new Author(); author.setName("Name"); author.save(); - + author = new Author(); author.setName("Name2"); author.save(); - + author = new Author(); author.setName("Name"); author.save(); - + Criteria criteria = new Criteria(); int count = new CountHelper().count( - criteria, - null, + criteria, + null, AuthorPeer.AUTHOR_ID); - + if (count != 3) { fail("counted " + count + " datasets, should be 3 "); } - + criteria = new Criteria(); criteria.setDistinct(); count = new CountHelper().count(criteria, null, AuthorPeer.NAME); - + if (count != 2) { fail("counted " + count + " distinct datasets, should be 2 "); } @@ -983,16 +983,16 @@ criteria = new Criteria(); criteria.add(AuthorPeer.NAME, "Name2"); count = new CountHelper().count(criteria); - + if (count != 1) { fail("counted " + count + " datasets with name Name2," + " should be 1 "); } } - - + + /** - * Tests whether we can handle multiple primary keys some of which are + * Tests whether we can handle multiple primary keys some of which are * also foreign keys * @throws Exception if the test fails */ @@ -1006,10 +1006,10 @@ multiPkForeignKey.save(); integerPk.save(); } - + /** * Tests inserting single quotes in Strings. - * This may not crash now, but in a later task like datasql, + * This may not crash now, but in a later task like datasql, * so the data has to be inserted in a table which does not get cleaned * during the runtime test. * @throws Exception if inserting the test data fails @@ -1020,13 +1020,13 @@ Criteria criteria = new Criteria(); criteria.add(APeer.A_ID, (Long) null, Criteria.NOT_EQUAL); APeer.doDelete(criteria); - + A a = new A(); a.setName("has Single ' Quote"); a.save(); } - - + + /** * check that blob cloumns can be read and written correctly * @throws Exception if the test fails @@ -1037,8 +1037,8 @@ { Criteria criteria = new Criteria(); criteria.add( - BlobTestPeer.ID, - (Long) null, + BlobTestPeer.ID, + (Long) null, Criteria.NOT_EQUAL); BlobTestPeer.doDelete(criteria); } @@ -1059,26 +1059,26 @@ blobTest.setBlobValue(bytes); } blobTest.save(); - + // read the BlobTests from the database // and check the values against the original values List blobTestList = BlobTestPeer.doSelect(new Criteria()); - assertTrue("blobTestList should contain 1 object but contains " + assertTrue("blobTestList should contain 1 object but contains " + blobTestList.size(), blobTestList.size() == 1); - - BlobTest readBlobTest = (BlobTest) blobTestList.get(0); + + BlobTest readBlobTest = (BlobTest) blobTestList.get(0); assertTrue("read and written blobs should be equal. " + "Size of read blob is" + readBlobTest.getBlobValue().length + " size of written blob is " - + blobTest.getBlobValue().length, + + blobTest.getBlobValue().length, Arrays.equals( blobTest.getBlobValue(), readBlobTest.getBlobValue())); } - - + + /** * check that clob cloumns can be read and written correctly * @throws Exception if the test fails @@ -1089,8 +1089,8 @@ { Criteria criteria = new Criteria(); criteria.add( - ClobTestPeer.ID, - (Long) null, + ClobTestPeer.ID, + (Long) null, Criteria.NOT_EQUAL); ClobTestPeer.doDelete(criteria); } @@ -1109,19 +1109,19 @@ clobTest.setClobValue(chars.toString()); } clobTest.save(); - + // read the ClobTests from the database // and check the values against the original values List clobTestList = ClobTestPeer.doSelect(new Criteria()); - assertTrue("clobTestList should contain 1 object but contains " + assertTrue("clobTestList should contain 1 object but contains " + clobTestList.size(), clobTestList.size() == 1); - + ClobTest readClobTest = (ClobTest) clobTestList.get(0); - assertTrue("read and written clobs should be equal", + assertTrue("read and written clobs should be equal", clobTest.getClobValue().equals(readClobTest.getClobValue())); } - + /** * Test whether we can execute queries as prepared statements * @throws Exception @@ -1131,8 +1131,8 @@ // clean LargePk table Criteria criteria = new Criteria(); criteria.add( - LargePkPeer.LARGE_PK_ID, - (Long) null, + LargePkPeer.LARGE_PK_ID, + (Long) null, Criteria.NOT_EQUAL); LargePkPeer.doDelete(criteria); @@ -1140,21 +1140,21 @@ largePk.setLargePkId(1); largePk.setName("testLargePk"); largePk.save(); - + largePk = new LargePk(); largePk.setLargePkId(2); largePk.setName("testLargePk"); largePk.save(); - + criteria = new Criteria(); criteria.add(LargePkPeer.LARGE_PK_ID, 2, Criteria.LESS_THAN); LargePkPeer.addSelectColumns(criteria); List result = BasePeer.doPSSelect(criteria); - assertTrue("Size of largePk list should be 1 but is " + assertTrue("Size of largePk list should be 1 but is " + result.size(), result.size() == 1); } - + /** * Tests whether shutdown complains about anything * @throws TorqueException if shutdown does not exit cleanly @@ -1176,12 +1176,12 @@ criteria.clear(); criteria.add( - AuthorPeer.AUTHOR_ID, + AuthorPeer.AUTHOR_ID, (Long) null, Criteria.NOT_EQUAL); AuthorPeer.doDelete(criteria); } - + /** * Strips the schema and table name from a fully qualified colum name * This is useful for creating Query with aliases, as the constants @@ -1189,24 +1189,24 @@ * @param fullyQualifiedColumnName the fully qualified column name, not null * @return the column name stripped from the table (and schema) prefixes */ - public static String getRawColumnName(String fullyQualifiedColumnName) + public static String getRawColumnName(String fullyQualifiedColumnName) { int dotPosition = fullyQualifiedColumnName.lastIndexOf("."); - if (dotPosition == -1) + if (dotPosition == -1) { return fullyQualifiedColumnName; } String result = fullyQualifiedColumnName.substring( - dotPosition + 1, + dotPosition + 1, fullyQualifiedColumnName.length()); return result; } - - + + /** * Subclass of BookPeer to make the doSelectJoinAuthors() visible */ - static class MyBookPeer extends BookPeer + static class MyBookPeer extends BookPeer { public static List doSelectJoinAuthor(Criteria criteria) throws TorqueException Modified: db/torque/runtime/trunk/src/rttest/org/apache/torque/DocsTest.java URL: http://svn.apache.org/viewcvs/db/torque/runtime/trunk/src/rttest/org/apache/torque/DocsTest.java?rev=239636&r1=239635&r2=239636&view=diff ============================================================================== --- db/torque/runtime/trunk/src/rttest/org/apache/torque/DocsTest.java (original) +++ db/torque/runtime/trunk/src/rttest/org/apache/torque/DocsTest.java Wed Aug 24 05:38:09 2005 @@ -35,23 +35,23 @@ public class DocsTest extends BaseRuntimeTestCase { public static final String AUTHOR_1_NAME = "Joshua Bloch"; - + public static final String AUTHOR_2_NAME = "W. Stevens"; public static final String AUTHOR_3_NAME = "Author without book"; - + public static final String BOOK_1_TITLE = "Effective Java"; - + public static final String BOOK_1_ISBN = "0-618-12902-2"; - + public static final String BOOK_2_TITLE = "TCP/IP Illustrated"; - + public static final String BOOK_2_ISBN = "0-201-63346-9"; - + public static final String BOOK_3_TITLE = "TCP/IP Illustrated"; - + public static final String BOOK_3_ISBN = "0-201-63354-X"; - + /** * Creates a new instance. */ @@ -67,38 +67,38 @@ // clean the books database Criteria criteria = new Criteria(); criteria.add(BookPeer.BOOK_ID, (Long) null, Criteria.NOT_EQUAL); - try + try { BookPeer.doDelete(criteria); } - catch(Exception e) + catch(Exception e) { e.printStackTrace(); - fail("cleaning books : Exception caught : " - + e.getClass().getName() + fail("cleaning books : Exception caught : " + + e.getClass().getName() + " : " + e.getMessage()); } criteria.clear(); criteria.add( - AuthorPeer.AUTHOR_ID, + AuthorPeer.AUTHOR_ID, (Long) null, Criteria.NOT_EQUAL); - try + try { AuthorPeer.doDelete(criteria); } - catch(Exception e) + catch(Exception e) { e.printStackTrace(); - fail("cleaning authors : Exception caught : " - + e.getClass().getName() + fail("cleaning authors : Exception caught : " + + e.getClass().getName() + " : " + e.getMessage()); } - - + + // insert some data into the database // taken from tutorial step 4 with some changes - try - { + try + { Author bloch = new Author(); bloch.setName(AUTHOR_1_NAME); bloch.save(); @@ -132,8 +132,8 @@ } catch (Exception e) { e.printStackTrace(); - fail("Exception caught : " - + e.getClass().getName() + fail("Exception caught : " + + e.getClass().getName() + " : " + e.getMessage()); } } @@ -141,25 +141,25 @@ /** * Criteria howto, section "Order by". */ - public void testCriteriaOrderBy() + public void testCriteriaOrderBy() { List books = null; - try + try { Criteria criteria = new Criteria(); criteria.addAscendingOrderByColumn(BookPeer.TITLE); criteria.addAscendingOrderByColumn(BookPeer.ISBN); - - books = BookPeer.doSelect(criteria); + + books = BookPeer.doSelect(criteria); } - catch (Exception e) - { + catch (Exception e) + { e.printStackTrace(); - fail("Exception caught : " - + e.getClass().getName() + fail("Exception caught : " + + e.getClass().getName() + " : " + e.getMessage()); } - + Book book = (Book) books.get(0); assertTrue( "title of first book is not" @@ -177,99 +177,99 @@ + book.getIsbn(), BOOK_3_ISBN.equals(book.getIsbn())); } - + /** * Criteria howto, section "Order by". */ - public void testCriteriaJoins() + public void testCriteriaJoins() { // inner joins List bookAuthors = null; - try + try { Criteria criteria = new Criteria(); criteria.addJoin( - AuthorPeer.AUTHOR_ID, - BookPeer.AUTHOR_ID, + AuthorPeer.AUTHOR_ID, + BookPeer.AUTHOR_ID, Criteria.INNER_JOIN); - + bookAuthors = AuthorPeer.doSelect(criteria); - + // from Details section Author author = (Author) bookAuthors.get(0); List books = author.getBooks(); } - catch (Exception e) - { + catch (Exception e) + { e.printStackTrace(); - fail("inner join : Exception caught : " - + e.getClass().getName() + fail("inner join : Exception caught : " + + e.getClass().getName() + " : " + e.getMessage()); } - + assertTrue( "inner join : size of bookAuthors is not 3, but" + bookAuthors.size(), bookAuthors.size() == 3); - + // test explicit sql statements from details section List result = null; - try + try { result = BasePeer.executeQuery( "SELECT book.* FROM book " + "INNER JOIN author " + "ON book.AUTHOR_ID=author.AUTHOR_ID"); } - catch (Exception e) - { + catch (Exception e) + { e.printStackTrace(); - fail("Explicit SQL query 1 : Exception caught : " - + e.getClass().getName() + fail("Explicit SQL query 1 : Exception caught : " + + e.getClass().getName() + " : " + e.getMessage()); } - + assertTrue( "Explicit SQL query 1 : size of result is not 3, but" + result.size(), result.size() == 3); result = null; - try + try { result = BasePeer.executeQuery( "SELECT book.* FROM book,author " + "WHERE book.AUTHOR_ID=author.AUTHOR_ID"); } - catch (Exception e) - { + catch (Exception e) + { e.printStackTrace(); - fail("Explicit SQL query 2 : Exception caught : " - + e.getClass().getName() + fail("Explicit SQL query 2 : Exception caught : " + + e.getClass().getName() + " : " + e.getMessage()); } - + assertTrue( "Explicit SQL query 2 : size of result is not 3, but" + result.size(), result.size() == 3); - + // test left outer join bookAuthors = null; - try + try { Criteria criteria = new Criteria(); criteria.addJoin( - AuthorPeer.AUTHOR_ID, - BookPeer.AUTHOR_ID, + AuthorPeer.AUTHOR_ID, + BookPeer.AUTHOR_ID, Criteria.LEFT_JOIN); bookAuthors = AuthorPeer.doSelect(criteria); } - catch (Exception e) - { + catch (Exception e) + { e.printStackTrace(); - fail("left join : Exception caught : " - + e.getClass().getName() + fail("left join : Exception caught : " + + e.getClass().getName() + " : " + e.getMessage()); } @@ -279,29 +279,29 @@ bookAuthors.size() == 4); } - + /** * Criteria Howto, section "Distinct". */ - public void testDistinct() + public void testDistinct() { List bookAuthors = null; - try + try { Criteria criteria = new Criteria(); criteria.addJoin( - AuthorPeer.AUTHOR_ID, - BookPeer.AUTHOR_ID, + AuthorPeer.AUTHOR_ID, + BookPeer.AUTHOR_ID, Criteria.INNER_JOIN); criteria.setDistinct(); - + bookAuthors = AuthorPeer.doSelect(criteria); } - catch (Exception e) - { + catch (Exception e) + { e.printStackTrace(); - fail("Exception caught : " - + e.getClass().getName() + fail("Exception caught : " + + e.getClass().getName() + " : " + e.getMessage()); } assertTrue( @@ -309,37 +309,37 @@ + bookAuthors.size(), bookAuthors.size() == 2); } - + /** * Criteria Howto, section "Join & Order & Distinct". */ - public void testJoinOrderDistinct() + public void testJoinOrderDistinct() { List bookAuthors = null; - try + try { Criteria criteria = new Criteria(); criteria.addJoin( - AuthorPeer.AUTHOR_ID, - BookPeer.AUTHOR_ID, + AuthorPeer.AUTHOR_ID, + BookPeer.AUTHOR_ID, Criteria.INNER_JOIN); criteria.setDistinct(); criteria.addAscendingOrderByColumn(AuthorPeer.NAME); - + bookAuthors = AuthorPeer.doSelect(criteria); } - catch (Exception e) - { + catch (Exception e) + { e.printStackTrace(); - fail("Exception caught : " - + e.getClass().getName() + fail("Exception caught : " + + e.getClass().getName() + " : " + e.getMessage()); } assertTrue( "size of bookAuthors is not 2, but" + bookAuthors.size(), bookAuthors.size() == 2); - + Author author = (Author) bookAuthors.get(0); assertTrue( "Author of first book is not" @@ -347,7 +347,7 @@ + " but " + author.getName(), AUTHOR_1_NAME.equals(author.getName())); - + author = (Author) bookAuthors.get(1); assertTrue( "Author of second book is not" Modified: db/torque/runtime/trunk/src/rttest/org/apache/torque/util/CopyTest.java URL: http://svn.apache.org/viewcvs/db/torque/runtime/trunk/src/rttest/org/apache/torque/util/CopyTest.java?rev=239636&r1=239635&r2=239636&view=diff ============================================================================== --- db/torque/runtime/trunk/src/rttest/org/apache/torque/util/CopyTest.java (original) +++ db/torque/runtime/trunk/src/rttest/org/apache/torque/util/CopyTest.java Wed Aug 24 05:38:09 2005 @@ -60,18 +60,18 @@ book.save(); } assertTrue("Number of books before copy should be 10, was " - + author.getBooks().size(), + + author.getBooks().size(), author.getBooks().size() == 10); Author authorCopy = author.copy(); authorCopy.save(); author = AuthorPeer.retrieveByPK(author.getPrimaryKey()); assertTrue("Number of books in original object should be 10, was " - + author.getBooks().size(), + + author.getBooks().size(), author.getBooks().size() == 10); assertTrue("Number of books after copy should be 10, was " - + authorCopy.getBooks().size(), + + authorCopy.getBooks().size(), authorCopy.getBooks().size() == 10); } } Modified: db/torque/runtime/trunk/src/rttest/schema.sql URL: http://svn.apache.org/viewcvs/db/torque/runtime/trunk/src/rttest/schema.sql?rev=239636&r1=239635&r2=239636&view=diff ============================================================================== Binary files - no diff available. Modified: db/torque/runtime/trunk/src/rttest/test-schema.xml URL: http://svn.apache.org/viewcvs/db/torque/runtime/trunk/src/rttest/test-schema.xml?rev=239636&r1=239635&r2=239636&view=diff ============================================================================== --- db/torque/runtime/trunk/src/rttest/test-schema.xml (original) +++ db/torque/runtime/trunk/src/rttest/test-schema.xml Wed Aug 24 05:38:09 2005 @@ -98,7 +98,7 @@ - + @@ -115,7 +115,7 @@
- + @@ -126,13 +126,13 @@
- + - - + @@ -152,7 +152,7 @@
- + @@ -183,7 +183,7 @@
- + @@ -197,7 +197,7 @@
- +
@@ -208,12 +208,12 @@
-
+ -
+ @@ -248,24 +248,24 @@ primaryKey="true" type="INTEGER" /> - - - - @@ -285,15 +285,15 @@
- + - @@ -33,9 +33,9 @@ - + - + - +
Modified: db/torque/runtime/trunk/src/test/TurbineResources.properties URL: http://svn.apache.org/viewcvs/db/torque/runtime/trunk/src/test/TurbineResources.properties?rev=239636&r1=239635&r2=239636&view=diff ============================================================================== --- db/torque/runtime/trunk/src/test/TurbineResources.properties (original) +++ db/torque/runtime/trunk/src/test/TurbineResources.properties Wed Aug 24 05:38:09 2005 @@ -16,14 +16,14 @@ # # This is the configuration file for Turbine. # -# Note that strings containing "," (comma) characters must backslash +# Note that strings containing "," (comma) characters must backslash # escape the comma (i.e. '\,') # # ------------------------------------------------------------------- # ------------------------------------------------------------------- -# +# # L O G G I N G # # ------------------------------------------------------------------- @@ -64,7 +64,7 @@ # ------------------------------------------------------------------- -# +# # T O R Q U E # # ------------------------------------------------------------------- Modified: db/torque/runtime/trunk/src/test/org/apache/torque/BaseTestCase.java URL: http://svn.apache.org/viewcvs/db/torque/runtime/trunk/src/test/org/apache/torque/BaseTestCase.java?rev=239636&r1=239635&r2=239636&view=diff ============================================================================== --- db/torque/runtime/trunk/src/test/org/apache/torque/BaseTestCase.java (original) +++ db/torque/runtime/trunk/src/test/org/apache/torque/BaseTestCase.java Wed Aug 24 05:38:09 2005 @@ -29,7 +29,7 @@ public abstract class BaseTestCase extends TestCase { /** The path to the configuration file. */ - private static final String CONFIG_FILE + private static final String CONFIG_FILE = "src/test/TurbineResources.properties"; /** Whether torque has been initialized. */ @@ -37,7 +37,7 @@ /** * Creates a new instance. - * + * * @param name the name of the test case to run */ public BaseTestCase(String name) Modified: db/torque/runtime/trunk/src/test/org/apache/torque/om/ComboKeyTest.java URL: http://svn.apache.org/viewcvs/db/torque/runtime/trunk/src/test/org/apache/torque/om/ComboKeyTest.java?rev=239636&r1=239635&r2=239636&view=diff ============================================================================== --- db/torque/runtime/trunk/src/test/org/apache/torque/om/ComboKeyTest.java (original) +++ db/torque/runtime/trunk/src/test/org/apache/torque/om/ComboKeyTest.java Wed Aug 24 05:38:09 2005 @@ -53,7 +53,7 @@ } /** - * + * * @param args */ public static void main(java.lang.String[] args) @@ -62,7 +62,7 @@ } /** - * + * * @return Test */ public static Test suite() @@ -73,7 +73,7 @@ } /** - * + * * */ public void testReflexive() @@ -86,7 +86,7 @@ } /** - * + * * */ public void testSymmetric() @@ -96,7 +96,7 @@ } /** - * + * * */ public void testNull() @@ -105,7 +105,7 @@ } /** - * + * * */ public void testNotEqual() @@ -114,7 +114,7 @@ } /** - * + * * */ public void testRoundTripWithStringKeys() @@ -138,7 +138,7 @@ } /** - * + * * */ public void testRoundTripWithComplexKey() @@ -155,7 +155,7 @@ } catch (Exception e) { - fail("Exception " + e.getClass().getName() + fail("Exception " + e.getClass().getName() + " thrown on new ComboKey(" + stringValue + "):" + e.getMessage()); } @@ -163,7 +163,7 @@ } /** - * + * * */ public void testRoundTripWithNullKey() @@ -179,7 +179,7 @@ } catch (Exception e) { - fail("Exception " + e.getClass().getName() + fail("Exception " + e.getClass().getName() + " thrown on new ComboKey(" + stringValue + "):" + e.getMessage()); } @@ -189,8 +189,8 @@ } - /** - * Test of appendTo method, of class org.apache.torque.om.ComboKey. + /** + * Test of appendTo method, of class org.apache.torque.om.ComboKey. */ public void testAppendTo() { @@ -199,8 +199,8 @@ Assert.assertEquals("Skey1:Skey2:", sb.toString()); } - /** - * Test of toString method, of class org.apache.torque.om.ComboKey. + /** + * Test of toString method, of class org.apache.torque.om.ComboKey. */ public void testToString() { Modified: db/torque/runtime/trunk/src/test/org/apache/torque/om/NumberKeyTest.java URL: http://svn.apache.org/viewcvs/db/torque/runtime/trunk/src/test/org/apache/torque/om/NumberKeyTest.java?rev=239636&r1=239635&r2=239636&view=diff ============================================================================== --- db/torque/runtime/trunk/src/test/org/apache/torque/om/NumberKeyTest.java (original) +++ db/torque/runtime/trunk/src/test/org/apache/torque/om/NumberKeyTest.java Wed Aug 24 05:38:09 2005 @@ -23,13 +23,13 @@ /** * Currently just tests the equality of NumberKey. - * + * * @author Stephen Haberman * @version $Id$ */ public class NumberKeyTest extends TestCase { - + /** Test value. */ private NumberKey n1a = new NumberKey(1); /** Test value. */ @@ -38,17 +38,17 @@ private NumberKey n1c = new NumberKey(1); /** Test value. */ private NumberKey n2a = new NumberKey(2); - + /** * Simple constructor. - * + * * @param name the name of the test to execute */ public NumberKeyTest(String name) { super(name); } - + /** * Test a.equals(a) */ @@ -56,7 +56,7 @@ { Assert.assertTrue(n1a.equals(n1a)); } - + /** * Test a.equals(b) = b.equals(a) */ @@ -64,7 +64,7 @@ { Assert.assertTrue(n1a.equals(n1b)); Assert.assertTrue(n1b.equals(n1a)); - + Assert.assertTrue(!"1".equals(n1a)); // As this used to give false, i.e. n1a was considered equal to "1" // it can lead to difficult to find bugs if it is immediately @@ -81,7 +81,7 @@ Assert.assertTrue(!n1a.equals(new Integer(1))); Assert.assertTrue(!new Integer(1).equals(n1a)); } - + /** * Test a.equals(b) = b.equals(c) = c.equals(a) */ @@ -91,7 +91,7 @@ Assert.assertTrue(n1b.equals(n1c)); Assert.assertTrue(n1c.equals(n1a)); } - + /** * Test !a.equals(null) */ @@ -99,7 +99,7 @@ { Assert.assertTrue(!n1a.equals(null)); } - + /** * Test sorting. */ @@ -120,5 +120,5 @@ { NumberKey key = new NumberKey(9900000000000001L); assertEquals("9900000000000001", key.toString()); - } + } } Modified: db/torque/runtime/trunk/src/test/org/apache/torque/util/SqlExpressionTest.java URL: http://svn.apache.org/viewcvs/db/torque/runtime/trunk/src/test/org/apache/torque/util/SqlExpressionTest.java?rev=239636&r1=239635&r2=239636&view=diff ============================================================================== --- db/torque/runtime/trunk/src/test/org/apache/torque/util/SqlExpressionTest.java (original) +++ db/torque/runtime/trunk/src/test/org/apache/torque/util/SqlExpressionTest.java Wed Aug 24 05:38:09 2005 @@ -25,7 +25,7 @@ /** * Tests for SqlExpression - * + * * @author Martin Poeschl * @author Scott Eade * @version $Id$ @@ -33,7 +33,7 @@ public class SqlExpressionTest extends TestCase { private DB db = null; - + /** * Constructor for SqlExpressionTest. @@ -73,7 +73,7 @@ */ public void testBuildInnerJoinStringStringbooleanDB() { - String result = SqlExpression.buildInnerJoin("TA.COLA", "TB.COLB", + String result = SqlExpression.buildInnerJoin("TA.COLA", "TB.COLB", true, db); assertEquals(result, "TA.COLA=TB.COLB"); } @@ -84,7 +84,7 @@ public void testBuildInStringObjectSqlEnumbooleanDB() { String[] values = new String[] { "42", "43", "44" }; - String result = SqlExpression.buildIn("COL", values, SqlEnum.IN, + String result = SqlExpression.buildIn("COL", values, SqlEnum.IN, true, db); // It seems the order of the values is different for jdk1.3 vs 1.4 // In any case, the order is not significant. @@ -99,7 +99,7 @@ assertEquals(result, "COL IN ('43','44','42')"); } } - + public void testLargeBuildInStringObjectSqlEnumbooleanDB() { int size = 10000; @@ -109,10 +109,10 @@ Array.set(values, i, String.valueOf(i)); } long start = System.currentTimeMillis(); - String result = SqlExpression.buildIn("COL", values, SqlEnum.IN, + String result = SqlExpression.buildIn("COL", values, SqlEnum.IN, true, db); long end = System.currentTimeMillis(); System.out.println("large buildIn took " + (end - start) + " milliseconds"); } - + } Modified: db/torque/runtime/trunk/xdocs/beans-howto.xml URL: http://svn.apache.org/viewcvs/db/torque/runtime/trunk/xdocs/beans-howto.xml?rev=239636&r1=239635&r2=239636&view=diff ============================================================================== --- db/torque/runtime/trunk/xdocs/beans-howto.xml (original) +++ db/torque/runtime/trunk/xdocs/beans-howto.xml Wed Aug 24 05:38:09 2005 @@ -24,24 +24,24 @@
- +

Creating beans from Torque objects creates a bridge between an environment which knows Torque and has access to a database, and another environment which dies not know anything about Torque and databases.

- +

For example, you might have a server using Torque, and a java client without database access where you want to use data supplied by - Torque, but do not want to include Torque in any way. + Torque, but do not want to include Torque in any way.

- +

If this is the case, you can create simple beans from Torque objects - in the server, send them over the network to your client, - manipulate them there, send them back over the network, + in the server, send them over the network to your client, + manipulate them there, send them back over the network, create Torque objects from the beans, and save the objects generated from the beans.

@@ -58,7 +58,7 @@ torque.generateBeans = true

- Then you just need to regenerate your object model to obtain an object model + Then you just need to regenerate your object model to obtain an object model with bean creation support enabled.

@@ -70,15 +70,15 @@ in the bean subpackage of your target package. E.g. in the bookstore example in the tutorial, the classes are generated in the com.kazmier.om package, so the beans will generated in the package com.kazmier.om.bean. - Each bean has getters and setters for all the properties defined - in the schema.xml. + Each bean has getters and setters for all the properties defined + in the schema.xml.

- Also, getters and setters for two boolean values, namely + Also, getters and setters for two boolean values, namely isNew(), setNew(), isModified() and setModified() are generated, which keep track of which changes have already made it into the - database. You should not normally need to use these. + database. You should not normally need to use these.

@@ -86,7 +86,7 @@

- If bean creation is enabled, every Torque object gets some + If bean creation is enabled, every Torque object gets some additional methods. E.g, the author class from the bookstore example in the tutorial gets the additional methods

@@ -103,13 +103,13 @@
- +

- If a bean is created from an object, the beans gets knowledge about + If a bean is created from an object, the beans gets knowledge about whether the object it was created from already exists in the database, - or whether it was changed after redaing it from the database + or whether it was changed after redaing it from the database (that is what the isNew() and isModified() methods are for). - So assuming we have at least one author stored in the database, + So assuming we have at least one author stored in the database, the following code works as expected

@@ -134,16 +134,16 @@

- + - +

- The bean creation process preserves object relations. + The bean creation process preserves object relations. Consider again the bookstore example from the tutorial: Each book has an author, and an author can have serveral books. - So if you have created an author-book relation, e.g. by + So if you have created an author-book relation, e.g. by

- + Author author = new Author(); // fill author data here @@ -154,19 +154,19 @@ AuthorBean authorBean = author.getBean();

- then the related bookBean is automatically created, + then the related bookBean is automatically created, and can be retrieved by

- + BookBean bookBean = (BookBean) authorBean.getBookBeans().get(0); - +

This is also true in the reverse direction. If you create an - author from this authorBean, the corresponding book can also + author from this authorBean, the corresponding book can also be retrieved:

- + Author authorFromBean = Author.createAuthor(authorBean); Book bookFromBean = (Book) author.getBooks().get(0); @@ -174,14 +174,14 @@

Note that only newly created or cached related objects are cosnidered in bean creation. - To elaborate that, consider the case where one author which is related + To elaborate that, consider the case where one author which is related to several books is stored in the database.

- +

The following code will NOT transfer the related books into the bean:

- + List authorList = AuthorPeer.doSelect(new Criteria()); Author author = (Author) authorList.get(0); @@ -189,11 +189,11 @@

This is because the related books are never read from the database, - and thus are not included in bean conversion. To include the - related books into the author bean, you have to assure that the + and thus are not included in bean conversion. To include the + related books into the author bean, you have to assure that the related books are read into memory. This can be done as follows:

- + List authorList = AuthorPeer.doSelect(new Criteria()); Author author = (Author) authorList.get(0); --------------------------------------------------------------------- To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org For additional commands, e-mail: torque-dev-help@db.apache.org