cvs commit: db-torque/src/rttest/org/apache/torque DataTest.java
tfischer2005/07/13 13:34:29 Modified:src/rttest/org/apache/torque DataTest.java Log: Corrected typos in testcase BlobTest Revision ChangesPath 1.27 +7 -7 db-torque/src/rttest/org/apache/torque/DataTest.java Index: DataTest.java === RCS file: /home/cvs/db-torque/src/rttest/org/apache/torque/DataTest.java,v retrieving revision 1.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- DataTest.java 26 Jun 2005 10:46:48 - 1.26 +++ DataTest.java 13 Jul 2005 20:34:29 - 1.27 @@ -1031,9 +1031,9 @@ * check that blob cloumns can be read and written correctly * @throws Exception if the test fails */ -public void testLobs() throws Exception +public void testBlobs() throws Exception { -// clean LobTest table +// clean BlobTest table { Criteria criteria = new Criteria(); criteria.add( @@ -1062,12 +1062,12 @@ // read the BlobTests from the database // and check the values against the original values -List lobTestList = BlobTestPeer.doSelect(new Criteria()); +List blobTestList = BlobTestPeer.doSelect(new Criteria()); assertTrue(blobTestList should contain 1 object but contains -+ lobTestList.size(), -lobTestList.size() == 1); ++ blobTestList.size(), +blobTestList.size() == 1); -BlobTest readBlobTest = (BlobTest) lobTestList.get(0); +BlobTest readBlobTest = (BlobTest) blobTestList.get(0); assertTrue(read and written blobs should be equal. + Size of read blob is + readBlobTest.getBlobValue().length - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: db-torque/src/rttest/org/apache/torque DataTest.java
tfischer2005/07/13 14:12:07 Modified:src/rttest/org/apache/torque DataTest.java Log: added a testcase which does a select for prepared statements Revision ChangesPath 1.28 +35 -2 db-torque/src/rttest/org/apache/torque/DataTest.java Index: DataTest.java === RCS file: /home/cvs/db-torque/src/rttest/org/apache/torque/DataTest.java,v retrieving revision 1.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- DataTest.java 13 Jul 2005 20:34:29 - 1.27 +++ DataTest.java 13 Jul 2005 21:12:07 - 1.28 @@ -918,7 +918,7 @@ */ public void testLargePk() throws Exception { -// clean Date table +// clean LargePk table Criteria criteria = new Criteria(); criteria.add( LargePkPeer.LARGE_PK_ID, @@ -1123,6 +1123,39 @@ } /** + * Test whether we can execute queries as prepared statements + * @throws Exception + */ +public void testPreparedStatements() throws Exception +{ +// clean LargePk table +Criteria criteria = new Criteria(); +criteria.add( +LargePkPeer.LARGE_PK_ID, +(Long) null, +Criteria.NOT_EQUAL); +LargePkPeer.doDelete(criteria); + +LargePk largePk = new LargePk(); +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 ++ result.size(), +result.size() == 1); +} + +/** * Tests whether shutdown complains about anything * @throws TorqueException if shutdown does not exit cleanly */ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: db-torque/src/rttest/org/apache/torque DataTest.java
tfischer2005/06/26 03:46:48 Modified:src/rttest/org/apache/torque DataTest.java Log: Added a Testcase for XPeer.DoSelectJoinY and another one for invoking Torque.shutdown() Revision ChangesPath 1.26 +44 -3 db-torque/src/rttest/org/apache/torque/DataTest.java Index: DataTest.java === RCS file: /home/cvs/db-torque/src/rttest/org/apache/torque/DataTest.java,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- DataTest.java 11 Jun 2005 06:31:27 - 1.25 +++ DataTest.java 26 Jun 2005 10:46:48 - 1.26 @@ -580,6 +580,26 @@ + , should be 11); } } + + +/** + * Test joins using the XPeer.DoSelectJoinYYY methods + * @throws Exception if the Test fails + */ +public void testDoSelectJoinY() throws Exception +{ +// using the test data from testJoins() +Criteria criteria = new Criteria(); +criteria.addAscendingOrderByColumn(BookPeer.TITLE); +List books = MyBookPeer.doSelectJoinAuthor(criteria); +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); +assertTrue (the authors of BookTwo and BookThree ++ should point to the same instance, +bookTwo.getAuthor() == bookThree.getAuthor()); +} /** * test the order by, especially in joins and with aliases @@ -1101,8 +1121,16 @@ assertTrue(read and written clobs should be equal, clobTest.getClobValue().equals(readClobTest.getClobValue())); } - - + +/** + * Tests whether shutdown complains about anything + * @throws TorqueException if shutdown does not exit cleanly + */ +public void testShutdown() throws TorqueException +{ +Torque.shutdown(); +} + /** * Deletes all authors and books in the bookstore tables * @throws Exception if the bookstore could not be cleaned @@ -1140,4 +1168,17 @@ fullyQualifiedColumnName.length()); return result; } + + +/** + * Subclass of BookPeer to make the doSelectJoinAuthors() visible + */ +static class MyBookPeer extends BookPeer +{ +public static List doSelectJoinAuthor(Criteria criteria) +throws TorqueException +{ +return BookPeer.doSelectJoinAuthor(criteria); +} +} } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: db-torque/src/rttest/org/apache/torque DataTest.java
tfischer2005/06/10 23:31:27 Modified:src/rttest/org/apache/torque DataTest.java Log: added the testcase testSingleRecords changed the position of the exit point in testJoins for HSQLDB just before the first right join Revision ChangesPath 1.25 +37 -9 db-torque/src/rttest/org/apache/torque/DataTest.java Index: DataTest.java === RCS file: /home/cvs/db-torque/src/rttest/org/apache/torque/DataTest.java,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- DataTest.java 10 Jun 2005 06:02:07 - 1.24 +++ DataTest.java 11 Jun 2005 06:31:27 - 1.25 @@ -204,6 +204,34 @@ } /** + * Checks whether the setSingleRecord() method in criteria works + */ +public void testSingleRecord() throws Exception +{ +Criteria criteria = new Criteria(); +criteria.setSingleRecord(true); +criteria.setLimit(1); +criteria.setOffset(5); +List books = BookPeer.doSelect(criteria); +assertTrue(List should have 1 books, not + books.size(), +books.size() == 1); + +criteria.clear(); +criteria.setSingleRecord(true); +criteria.setLimit(2); +try +{ +books = BookPeer.doSelect(criteria); +fail(doSelect should have failed ++ because two records were selected ++ 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 @@ -424,13 +452,6 @@ */ public void testJoins() throws Exception { -if (Torque.getDB(Torque.getDefaultDB()) instanceof DBHypersonicSQL) -{ -log.error(testJoins(): Right joins are not supported by HSQLDB); -// failing is expected, so exit without error -return; -} - cleanBookstore(); // insert test data @@ -491,7 +512,14 @@ + authorList.size() + , should be 4); } - + +if (Torque.getDB(Torque.getDefaultDB()) instanceof DBHypersonicSQL) +{ +log.error(testJoins(): Right joins are not supported by HSQLDB); +// failing is expected, so exit without error +return; +} + // test right join criteria = new Criteria(); criteria.addJoin( - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: db-torque/src/rttest/org/apache/torque DataTest.java
tfischer2005/06/09 14:22:15 Modified:src/rttest/org/apache/torque DataTest.java Log: Get runtimetest working for HSQLDB: - skip Join Test becauseHSQLDB does not support right joins - clean A table each time before saving Revision ChangesPath 1.23 +15 -1 db-torque/src/rttest/org/apache/torque/DataTest.java Index: DataTest.java === RCS file: /home/cvs/db-torque/src/rttest/org/apache/torque/DataTest.java,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- DataTest.java 8 Jun 2005 06:08:47 - 1.22 +++ DataTest.java 9 Jun 2005 21:22:14 - 1.23 @@ -28,9 +28,11 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.torque.adapter.DBHypersonicSQL; import org.apache.torque.adapter.DBOracle; import org.apache.torque.om.StringKey; import org.apache.torque.test.A; +import org.apache.torque.test.APeer; import org.apache.torque.test.Author; import org.apache.torque.test.AuthorPeer; import org.apache.torque.test.BitTest; @@ -403,6 +405,13 @@ */ public void testJoins() throws Exception { +if (Torque.getDB(Torque.getDefaultDB()) instanceof DBHypersonicSQL) +{ +log.error(testJoins(): Right joins are not supported by HSQLDB); +// failing is expected, so exit without error +return; +} + cleanBookstore(); // insert test data @@ -940,6 +949,11 @@ */ public void testSingleQuotes() throws Exception { +// clean A table +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(); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: db-torque/src/rttest/org/apache/torque DataTest.java
tfischer2005/06/07 23:08:47 Modified:src/rttest/org/apache/torque DataTest.java Log: corrected Bug: the wrong Peer class was used in the BitType test Revision ChangesPath 1.22 +3 -3 db-torque/src/rttest/org/apache/torque/DataTest.java Index: DataTest.java === RCS file: /home/cvs/db-torque/src/rttest/org/apache/torque/DataTest.java,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- DataTest.java 22 May 2005 15:05:12 - 1.21 +++ DataTest.java 8 Jun 2005 06:08:47 - 1.22 @@ -276,7 +276,7 @@ // query data criteria.clear(); criteria.add(BitTestPeer.BIT_VALUE, new Boolean(true)); -List bitTestList = BooleanCheckPeer.doSelect(criteria); +List bitTestList = BitTestPeer.doSelect(criteria); assertTrue(Should have read 1 dataset + but read + bitTestList.size(), bitTestList.size() == 1); @@ -289,7 +289,7 @@ criteria.clear(); criteria.add(BitTestPeer.BIT_VALUE, new Boolean(false)); -bitTestList = BooleanCheckPeer.doSelect(criteria); +bitTestList = BitTestPeer.doSelect(criteria); assertTrue(Should have read 1 dataset + but read + bitTestList.size(), bitTestList.size() == 1); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: db-torque/src/rttest/org/apache/torque DataTest.java
tfischer2005/05/22 03:03:00 Modified:src/rttest/org/apache/torque DataTest.java Log: Added a new testcase testConnection This test is useful if one is trying to get the runtimetest running for a new database type Revision ChangesPath 1.20 +24 -1 db-torque/src/rttest/org/apache/torque/DataTest.java Index: DataTest.java === RCS file: /home/cvs/db-torque/src/rttest/org/apache/torque/DataTest.java,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- DataTest.java 10 May 2005 19:18:08 - 1.19 +++ DataTest.java 22 May 2005 10:02:59 - 1.20 @@ -16,6 +16,7 @@ * limitations under the License. */ +import java.sql.Connection; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Arrays; @@ -74,6 +75,28 @@ } /** + * test whether we can connect to the database at all + * @throws Exception if no connection can be established + */ +public void testConnect() throws Exception +{ +Connection connection = null; +try +{ + connection = Torque.getConnection(); +connection.close(); +connection = null; +} +finally +{ + if (connection != null) +{ + connection.close(); +} +} +} + +/** * does some inserts. * @throws Exception if the test fails */ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: db-torque/src/rttest/org/apache/torque DataTest.java
tfischer2005/05/10 12:18:08 Modified:src/rttest/org/apache/torque DataTest.java Log: Added a simple testcase for reading and writing LOBS Appended a check to a testcase that newly generated objects are filled with autogenerated ids Revision ChangesPath 1.19 +58 -1 db-torque/src/rttest/org/apache/torque/DataTest.java Index: DataTest.java === RCS file: /home/cvs/db-torque/src/rttest/org/apache/torque/DataTest.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- DataTest.java 8 May 2005 17:27:25 - 1.18 +++ DataTest.java 10 May 2005 19:18:08 - 1.19 @@ -18,6 +18,7 @@ import java.text.DateFormat; import java.text.SimpleDateFormat; +import java.util.Arrays; import java.util.Date; import java.util.HashMap; import java.util.Iterator; @@ -37,6 +38,8 @@ import org.apache.torque.test.IntegerPk; import org.apache.torque.test.LargePk; import org.apache.torque.test.LargePkPeer; +import org.apache.torque.test.LobTest; +import org.apache.torque.test.LobTestPeer; import org.apache.torque.test.MultiPk; import org.apache.torque.test.MultiPkForeignKey; import org.apache.torque.test.MultiPkPeer; @@ -87,6 +90,8 @@ Author author = new Author(); author.setName(Author + i); author.save(); +assertTrue(authorId should not be 0 after insert, +author.getAuthorId() != 0); for (int j = 1; j = 10; j++) { @@ -850,6 +855,58 @@ a.setName(has Single ' Quote); a.save(); } + +public void testLobs() throws Exception +{ +// clean LobTest table +{ +Criteria criteria = new Criteria(); +criteria.add( +LobTestPeer.ID, +(Long) null, +Criteria.NOT_EQUAL); +LobTestPeer.doDelete(criteria); +} + +// create a new LobTest Object with large blob and clob values +// and save it +LobTest lobTest = new LobTest(); +{ +int length = 10; +byte[] bytes = new byte[length]; +StringBuffer chars = new StringBuffer(); +String charTemplate = 1234567890abcdefghijklmnopqrstuvwxyz; +for (int i = 0; i length; ++i) +{ + bytes[i] = new Integer(i % 256).byteValue(); +chars.append(charTemplate.charAt(i % charTemplate.length())); +} +lobTest.setBlobValue(bytes); +lobTest.setClobValue(chars.toString()); +} +lobTest.save(); + +// read the LobTests from the database +// and check the values against the original values +List lobTestList = LobTestPeer.doSelect(new Criteria()); +assertTrue(lobTests should contain 1 object but contains ++ lobTestList.size(), +lobTestList.size() == 1); + +LobTest readLobTest = (LobTest) lobTestList.get(0); +boolean bytesDiffer = false; + +assertTrue(read and written blobs should be equal. ++ Size of read blob is ++ readLobTest.getBlobValue().length ++ size of written blob is ++ lobTest.getBlobValue().length, +Arrays.equals( +lobTest.getBlobValue(), +readLobTest.getBlobValue())); +assertTrue(read and written clobs should be equal, +lobTest.getClobValue().equals(readLobTest.getClobValue())); +} /** - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: db-torque/src/rttest/org/apache/torque DataTest.java
tfischer2005/05/05 01:17:11 Modified:src/rttest/org/apache/torque DataTest.java Log: added a test case to test primary keys which are also foreign keys added a test to the orderByTest to check usage of sql functions in the order by clause Revision ChangesPath 1.16 +27 -1 db-torque/src/rttest/org/apache/torque/DataTest.java Index: DataTest.java === RCS file: /home/cvs/db-torque/src/rttest/org/apache/torque/DataTest.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- DataTest.java 23 Apr 2005 14:58:14 - 1.15 +++ DataTest.java 5 May 2005 08:17:11 - 1.16 @@ -34,9 +34,12 @@ import org.apache.torque.test.BooleanCheckPeer; import org.apache.torque.test.DateTest; import org.apache.torque.test.DateTestPeer; +import org.apache.torque.test.IntegerPk; +import org.apache.torque.test.IntegerPkPeer; import org.apache.torque.test.LargePk; import org.apache.torque.test.LargePkPeer; import org.apache.torque.test.MultiPk; +import org.apache.torque.test.MultiPkForeignKey; import org.apache.torque.test.MultiPkPeer; import org.apache.torque.test.NullValueTable; import org.apache.torque.util.BasePeer; @@ -726,6 +729,12 @@ + , 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); + } catch( Exception e) { @@ -1034,6 +1043,23 @@ + : + e.getMessage()); } } + + +/** + * Tests whether we can handle multiple primary keys some of which are + * also foreign keys + * @throws Exception if the testfails + */ +public void testMultiplePrimaryForeignKey() throws Exception +{ +IntegerPk integerPk = new IntegerPk(); +integerPk.save(); +MultiPkForeignKey multiPkForeignKey = new MultiPkForeignKey(); +multiPkForeignKey.setId(10); +multiPkForeignKey.setIntegerPk(integerPk); +multiPkForeignKey.save(); +integerPk.save(); +} /** * Tests inserting single quotes in Strings. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: db-torque/src/rttest/org/apache/torque DataTest.java
tfischer2005/03/26 09:38:40 Modified:src/rttest bookstore-schema.xml src/rttest/org/apache/torque DataTest.java Log: Added a test case to chekct whether large primary keys are inserted and read correctly. This check is related to TQRS245 Revision ChangesPath 1.17 +21 -1 db-torque/src/rttest/bookstore-schema.xml Index: bookstore-schema.xml === RCS file: /home/cvs/db-torque/src/rttest/bookstore-schema.xml,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- bookstore-schema.xml 31 Jan 2005 19:43:59 - 1.16 +++ bookstore-schema.xml 26 Mar 2005 17:38:39 - 1.17 @@ -255,7 +255,7 @@ name=DATE_TEST_ID required=true primaryKey=true - type=INTEGER + type=BIGINT / column name=DATE_VALUE @@ -275,4 +275,24 @@ /table + !-- === -- + !-- L A R G E _ P K T A B L E -- + !-- === -- + + table name=LARGE_PK idMethod=none description=Table to test large Primary keys +column + name=LARGE_PK_ID + required=true + primaryKey=true + type=BIGINT +/ +column + name=NAME + type=VARCHAR + size=100 + required=false +/ + /table + + /database 1.14 +34 -3 db-torque/src/rttest/org/apache/torque/DataTest.java Index: DataTest.java === RCS file: /home/cvs/db-torque/src/rttest/org/apache/torque/DataTest.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- DataTest.java 19 Mar 2005 06:25:27 - 1.13 +++ DataTest.java 26 Mar 2005 17:38:39 - 1.14 @@ -25,15 +25,17 @@ import java.util.Map; import org.apache.torque.om.StringKey; +import org.apache.torque.test.A; import org.apache.torque.test.Author; import org.apache.torque.test.AuthorPeer; import org.apache.torque.test.Book; import org.apache.torque.test.BookPeer; import org.apache.torque.test.BooleanCheck; import org.apache.torque.test.BooleanCheckPeer; -import org.apache.torque.test.A; import org.apache.torque.test.DateTest; import org.apache.torque.test.DateTestPeer; +import org.apache.torque.test.LargePk; +import org.apache.torque.test.LargePkPeer; import org.apache.torque.test.MultiPk; import org.apache.torque.test.MultiPkPeer; import org.apache.torque.test.NullValueTable; @@ -870,6 +872,36 @@ } /** + * tests whether large primary keys are inserted and read correctly + */ +public void testLargePk() throws Exception +{ +// clean Date table +Criteria criteria = new Criteria(); +criteria.add( + LargePkPeer.LARGE_PK_ID, +(Long) null, +Criteria.NOT_EQUAL); +LargePkPeer.doDelete(criteria); + +long longId = 8771507845873286l; +LargePk largePk = new LargePk(); +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() + + , and the read id, + readLargePk.getLargePkId() + + , should be equal, + readLargePk.getLargePkId() == largePk.getLargePkId()); +assertTrue(the inserted Id, + largePk.getLargePkId() + + , should be equal to + longId, + longId == largePk.getLargePkId()); +} + +/** * Deletes all authors and books in the bookstore tables */ protected void cleanBookstore() @@ -1005,5 +1037,4 @@ fullyQualifiedColumnName.length()); return result; } - } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: db-torque/src/rttest/org/apache/torque DataTest.java
tfischer2005/03/03 22:38:54 Modified:src/rttest/org/apache/torque DataTest.java Log: added test for TRQS267 Revision ChangesPath 1.12 +25 -1 db-torque/src/rttest/org/apache/torque/DataTest.java Index: DataTest.java === RCS file: /home/cvs/db-torque/src/rttest/org/apache/torque/DataTest.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- DataTest.java 18 Feb 2005 09:26:03 - 1.11 +++ DataTest.java 4 Mar 2005 06:38:54 - 1.12 @@ -31,6 +31,7 @@ import org.apache.torque.test.BookPeer; import org.apache.torque.test.BooleanCheck; import org.apache.torque.test.BooleanCheckPeer; +import org.apache.torque.test.A; import org.apache.torque.test.DateTest; import org.apache.torque.test.DateTestPeer; import org.apache.torque.test.MultiPk; @@ -961,6 +962,29 @@ } } +/** + * Tests inserting single quotes in Strings. + * 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. + */ +public void testSingleQuotes() +{ +try +{ +A a = new A(); +a.setName(has Single ' Quote); +a.save(); +} +catch( Exception e) +{ +e.printStackTrace(); +fail(Exception caught : + + e.getClass().getName() + + : + e.getMessage()); +} +} + /** * Strips the schema and table name from a fully qualified colum name - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: db-torque/src/rttest/org/apache/torque DataTest.java
tfischer2005/02/18 01:26:03 Modified:src/rttest/org/apache/torque DataTest.java Log: corrected error message Revision ChangesPath 1.11 +2 -2 db-torque/src/rttest/org/apache/torque/DataTest.java Index: DataTest.java === RCS file: /home/cvs/db-torque/src/rttest/org/apache/torque/DataTest.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- DataTest.java 31 Jan 2005 19:43:58 - 1.10 +++ DataTest.java 18 Feb 2005 09:26:03 - 1.11 @@ -117,7 +117,7 @@ catch (Exception ex) { ex.printStackTrace(); -fail(cleaning table : Exception caught : +fail(Exception caught : + ex.getClass().getName() + : + ex.getMessage()); } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: db-torque/src/rttest/org/apache/torque DataTest.java
tfischer2005/01/11 09:13:00 Modified:src/rttest/org/apache/torque Tag: TORQUE_3_1_BRANCH DataTest.java Added: src/java/org/apache/torque/util Tag: TORQUE_3_1_BRANCH CountHelper.java Log: Added a helper class which eases counting of datasets in a table. The CountHelper class has been submitted by Martin Goulet, and I have introduced some changes which are approved by Martin. See TRQS265 in scarab for Martin's last version. Also added a test case for the class. Submitted by: (CountHelper.java) [EMAIL PROTECTED] Revision ChangesPath No revision No revision 1.1.2.1 +141 -0 db-torque/src/java/org/apache/torque/util/Attic/CountHelper.java No revision No revision 1.8.2.8 +61 -2 db-torque/src/rttest/org/apache/torque/DataTest.java Index: DataTest.java === RCS file: /home/cvs/db-torque/src/rttest/org/apache/torque/DataTest.java,v retrieving revision 1.8.2.7 retrieving revision 1.8.2.8 diff -u -r1.8.2.7 -r1.8.2.8 --- DataTest.java 29 Dec 2004 20:45:01 - 1.8.2.7 +++ DataTest.java 11 Jan 2005 17:13:00 - 1.8.2.8 @@ -37,6 +37,7 @@ import org.apache.torque.test.MultiPkPeer; import org.apache.torque.test.NullValueTable; import org.apache.torque.util.BasePeer; +import org.apache.torque.util.CountHelper; import org.apache.torque.util.Criteria; import com.workingdogs.village.Record; @@ -901,8 +902,66 @@ + : + e.getMessage()); } } + - +/** + * Tests the CountHelper class + */ +public void testCountHelper() +{ +try +{ +cleanBookstore(); +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, +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 ); +} + +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 ); +} + +} +catch( Exception e) +{ +e.printStackTrace(); +fail(Exception caught : + + e.getClass().getName() + + : + e.getMessage()); +} +} + + /** * Strips the schema and table name from a fully qualified colum name * This is useful for creating Query with aliases, as the constants - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: db-torque/src/rttest/org/apache/torque DataTest.java
tfischer2004/12/27 11:52:48 Modified:src/rttest Tag: TORQUE_3_1_BRANCH bookstore-schema.xml src/rttest/org/apache/torque Tag: TORQUE_3_1_BRANCH DataTest.java Log: added a test case where the accuracy of date/time/timestamp values are checked. For this, a new table was added to the bookstore schema. Revision ChangesPath No revision No revision 1.13.2.1 +29 -0 db-torque/src/rttest/bookstore-schema.xml Index: bookstore-schema.xml === RCS file: /home/cvs/db-torque/src/rttest/bookstore-schema.xml,v retrieving revision 1.13 retrieving revision 1.13.2.1 diff -u -r1.13 -r1.13.2.1 --- bookstore-schema.xml 3 Aug 2003 13:42:40 - 1.13 +++ bookstore-schema.xml 27 Dec 2004 19:52:47 - 1.13.2.1 @@ -245,5 +245,34 @@ reference foreign=COL2 local=PARENT_COL2/ /foreign-key /table + + !-- === -- + !-- D A T E _ T E S T T A B L E-- + !-- === -- + + table name=DATE_TEST description=Table to test Date formats +column + name=DATE_TEST_ID + required=true + primaryKey=true + type=INTEGER +/ +column + name=DATE_VALUE + required=true + type=DATE +/ +column + name=TIME_VALUE + required=true + type=TIME +/ +column + name=TIMESTAMP_VALUE + required=true + type=TIMESTAMP +/ + + /table /database No revision No revision 1.8.2.6 +79 -1 db-torque/src/rttest/org/apache/torque/DataTest.java Index: DataTest.java === RCS file: /home/cvs/db-torque/src/rttest/org/apache/torque/DataTest.java,v retrieving revision 1.8.2.5 retrieving revision 1.8.2.6 diff -u -r1.8.2.5 -r1.8.2.6 --- DataTest.java 16 Dec 2004 08:04:36 - 1.8.2.5 +++ DataTest.java 27 Dec 2004 19:52:47 - 1.8.2.6 @@ -16,6 +16,9 @@ * limitations under the License. */ +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -28,6 +31,8 @@ import org.apache.torque.test.BookPeer; import org.apache.torque.test.BooleanCheck; import org.apache.torque.test.BooleanCheckPeer; +import org.apache.torque.test.DateTest; +import org.apache.torque.test.DateTestPeer; import org.apache.torque.test.MultiPk; import org.apache.torque.test.MultiPkPeer; import org.apache.torque.test.NullValueTable; @@ -764,6 +769,79 @@ } } catch( Exception e) +{ +e.printStackTrace(); +fail(Exception caught : + + e.getClass().getName() + + : + e.getMessage()); +} +} + +/** + * Tests the date, time and datetime accuracy. + * At the moment, no upper limit for the accuracy is checked, + * the differences are printed to stdout. + */ +public void testDateTime() +{ +try +{ +// clean Date table +Criteria criteria = new Criteria(); +criteria.add( +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(); +dateTest.setDateValue(now); +dateTest.setTimeValue(now); +dateTest.setTimestampValue(now); +dateTest.save(); +DateFormat dateFormat = new SimpleDateFormat(); +System.out.println( +testDateTime() : set date to : ++ dateFormat.format(now)); + +// reload dateTest from db +DateTest loadedDateTest += DateTestPeer.retrieveByPK(dateTest.getPrimaryKey()); + +System.out.println( +testDateTime() : retrieved date : ++ dateFormat.format(loadedDateTest.getDateValue())); +System.out.println( +testDateTime() : retrieved time : ++ dateFormat.format(loadedDateTest.getTimeValue())); +System.out.println( +testDateTime() : retrieved timestamp : ++ dateFormat.format(loadedDateTest.getTimestampValue()));
cvs commit: db-torque/src/rttest/org/apache/torque DataTest.java
seade 2003/08/24 07:38:50 Modified:src/rttest test-schema.xml src/rttest/org/apache/torque DataTest.java Log: New runtime test case that shows booleanchar is not currently working. Revision ChangesPath 1.16 +9 -1 db-torque/src/rttest/test-schema.xml Index: test-schema.xml === RCS file: /home/cvs/db-torque/src/rttest/test-schema.xml,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- test-schema.xml 7 Aug 2003 21:27:46 - 1.15 +++ test-schema.xml 24 Aug 2003 14:38:50 - 1.16 @@ -145,5 +145,13 @@ column name=class javaName=JavaClass required=false type=VARCHAR/ column name=package javaName=JavaPackage required=false type=VARCHAR/ /table --- +-- + + !-- BOOLEANCHAR not working? -- + table name=boolean_check idMethod=none +column name=test_key required=true primaryKey=true type=CHAR size=10 / +column name=bint_value required=true type=BOOLEANINT / +column name=bchar_value required=true type=BOOLEANCHAR / + /table + /database 1.8 +39 -1 db-torque/src/rttest/org/apache/torque/DataTest.java Index: DataTest.java === RCS file: /home/cvs/db-torque/src/rttest/org/apache/torque/DataTest.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- DataTest.java 3 Aug 2003 13:42:40 - 1.7 +++ DataTest.java 24 Aug 2003 14:38:50 - 1.8 @@ -58,9 +58,12 @@ import java.util.HashMap; import java.util.List; import java.util.Iterator; +import org.apache.torque.om.StringKey; import org.apache.torque.test.Author; import org.apache.torque.test.Book; import org.apache.torque.test.BookPeer; +import org.apache.torque.test.BooleanCheck; +import org.apache.torque.test.BooleanCheckPeer; import org.apache.torque.test.NullValueTable; import org.apache.torque.util.Criteria; import org.apache.torque.test.MultiPk; @@ -109,6 +112,16 @@ book.save(); } } +BooleanCheck bc = new BooleanCheck(); +bc.setTestKey(t1); +bc.setBintValue(true); +bc.setBcharValue(true); +bc.save(); +bc = new BooleanCheck(); +bc.setTestKey(f1); +bc.setBintValue(false); +bc.setBcharValue(false); +bc.save(); } catch (Exception ex) { @@ -193,4 +206,29 @@ ex.printStackTrace(); } } + +/** + * test boolean values + */ +public void testBooleanValues() +{ +try +{ +BooleanCheck bc = BooleanCheckPeer.retrieveByPK(new StringKey(t1)); +assertTrue(BOOLEANINT should be true but is: ++ bc.getBintValue(), bc.getBintValue()); +assertTrue(BOOLEANCHAR should be true but is: ++ bc.getBcharValue(), bc.getBcharValue()); +bc = BooleanCheckPeer.retrieveByPK(new StringKey(f1)); +assertFalse(BOOLEANINT should be false but is: ++ bc.getBintValue(), bc.getBintValue()); +assertFalse(BOOLEANCHAR should be false but is: ++ bc.getBcharValue(), bc.getBcharValue()); +} +catch (Exception ex) +{ +ex.printStackTrace(); +} +} + } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]