Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/map/DatabaseMapTest.java URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/map/DatabaseMapTest.java?rev=1870836&r1=1870835&r2=1870836&view=diff ============================================================================== --- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/map/DatabaseMapTest.java (original) +++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/map/DatabaseMapTest.java Wed Dec 4 15:51:06 2019 @@ -24,6 +24,13 @@ import java.util.List; import org.apache.torque.BaseDatabaseTestCase; import org.apache.torque.Torque; import org.apache.torque.TorqueException; +import org.junit.jupiter.api.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.junit.Assert.assertNotNull; /** * Test code for Database Map functions @@ -94,6 +101,7 @@ public class DatabaseMapTest extends Bas * * @throws Throwable if the test has failed. */ + @Test public void testDatabaseMapInitialize() throws Throwable { if (testDatabaseMapInitializeResult != null) @@ -113,6 +121,7 @@ public class DatabaseMapTest extends Bas * * @throws TorqueException */ + @Test public void testColumnOrder() throws TorqueException { DatabaseMap map = Torque.getDatabaseMap(DATABASE_NAME); @@ -146,6 +155,7 @@ public class DatabaseMapTest extends Bas * * @throws TorqueException */ + @Test public void testTableOrder() throws TorqueException { DatabaseMap map = Torque.getDatabaseMap(DATABASE_NAME); @@ -167,6 +177,7 @@ public class DatabaseMapTest extends Bas * <p> * @throws TorqueException */ + @Test public void testExternalSchemaTables() throws TorqueException { DatabaseMap map = Torque.getDatabaseMap(); @@ -184,6 +195,7 @@ public class DatabaseMapTest extends Bas /** * Test that various table properties get set correctly from the XML */ + @Test public void testTableAttributes() throws TorqueException { DatabaseMap map = Torque.getDatabaseMap(DATABASE_NAME); @@ -210,6 +222,7 @@ public class DatabaseMapTest extends Bas /** * Test that various column properties get set correctly from the XML */ + @Test public void testColumnAttributes() throws TorqueException { DatabaseMap map = Torque.getDatabaseMap(DATABASE_NAME); @@ -275,6 +288,7 @@ public class DatabaseMapTest extends Bas /** * Test that the foreign key properties get set correctly from the XML */ + @Test public void testForeignKeyAttributes() throws TorqueException { DatabaseMap map = Torque.getDatabaseMap(DATABASE_NAME); @@ -297,6 +311,7 @@ public class DatabaseMapTest extends Bas /** * Test that Inheritance info is stored correctly */ + @Test public void testInheritanceMapping() throws TorqueException { DatabaseMap map = Torque.getDatabaseMap(DATABASE_NAME); @@ -327,6 +342,7 @@ public class DatabaseMapTest extends Bas /** * Test for controlled error on getting invalid database */ + @Test public void testInvalidDatabaseName() throws TorqueException { DatabaseMap map = Torque.getDatabaseMap(INVALID_DATABASE_NAME); @@ -344,6 +360,7 @@ public class DatabaseMapTest extends Bas /** * Tests whether all options are present */ + @Test public void testOptions() throws TorqueException { DatabaseMap databaseMap = Torque.getDatabaseMap(DATABASE_NAME);
Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/oid/IDBrokerTest.java URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/oid/IDBrokerTest.java?rev=1870836&r1=1870835&r2=1870836&view=diff ============================================================================== --- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/oid/IDBrokerTest.java (original) +++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/oid/IDBrokerTest.java Wed Dec 4 15:51:06 2019 @@ -30,6 +30,15 @@ import org.apache.torque.BaseDatabaseTes import org.apache.torque.Torque; import org.apache.torque.test.peer.AuthorPeer; import org.apache.torque.util.Transaction; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.junit.Assert.assertNotNull; /** * Tests methods in the adapters @@ -44,10 +53,9 @@ public class IDBrokerTest extends BaseDa /** System under test. */ private IDBroker idBroker; - @Override + @BeforeEach public void setUp() throws Exception { - super.setUp(); idBroker = new IDBroker(Torque.getDatabase(Torque.getDefaultDB())); Connection connection = Transaction.begin(); idBroker.updateQuantity( @@ -57,10 +65,9 @@ public class IDBrokerTest extends BaseDa Transaction.commit(connection); } - @Override + @AfterEach public void tearDown() throws Exception { - super.setUp(); idBroker.stop(); } @@ -69,6 +76,7 @@ public class IDBrokerTest extends BaseDa * * @throws Exception if the test fails */ + @Test public void testRestartIdBroker() throws Exception { log.trace("testRestartIdBroker(): start"); @@ -91,6 +99,7 @@ public class IDBrokerTest extends BaseDa * * @throws Exception if the test fails */ + @Test public void testInitialQuantityValue() throws Exception { log.trace("testInitialQuantityValue(): start"); @@ -109,6 +118,7 @@ public class IDBrokerTest extends BaseDa * * @throws Exception if the test fails */ + @Test public void testCleverQuantityValue() throws Exception { log.trace("testCleverQuantityValue(): start"); @@ -132,6 +142,7 @@ public class IDBrokerTest extends BaseDa * * @throws Exception if the test fails */ + @Test public void testCleverQuantityValueMax() throws Exception { log.trace("testCleverQuantityValueMax(): start"); Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/om/OMByNameMethodsTest.java URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/om/OMByNameMethodsTest.java?rev=1870836&r1=1870835&r2=1870836&view=diff ============================================================================== --- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/om/OMByNameMethodsTest.java (original) +++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/om/OMByNameMethodsTest.java Wed Dec 4 15:51:06 2019 @@ -30,6 +30,13 @@ import org.apache.torque.test.dbobject.T import org.apache.torque.test.dbobject.TypesPrimitive; import org.apache.torque.test.peer.TypesObjectPeer; import org.apache.torque.test.peer.TypesPrimitivePeer; +import org.junit.jupiter.api.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.junit.Assert.assertNotNull; /** * Test the various setBy and getBy methods that can be used to access field @@ -239,6 +246,7 @@ public class OMByNameMethodsTest extends * Checks the setValue against the value returned by the get<FieldName>() * methods for all known object and primitive types. */ + @Test public void testSetByNameMethod() throws Exception { @@ -291,6 +299,7 @@ public class OMByNameMethodsTest extends * * @throws Exception */ + @Test public void testGetByNameMethod() throws Exception { // Testing GetByName method for Object Types @@ -347,6 +356,7 @@ public class OMByNameMethodsTest extends * Checks that getValue returns the value set with a setByPeerName call for all * known object and primitive types. */ + @Test public void testSetByFullyQualifiedPeerName() throws Exception { // Testing GetByName method for Object Types @@ -399,6 +409,7 @@ public class OMByNameMethodsTest extends * Checks that getValue returns the value set with a setByPeerName call for all * known object and primitive types. */ + @Test public void testSetUnqualifiedPeerName() throws Exception { // Testing GetByName method for Object Types @@ -451,6 +462,7 @@ public class OMByNameMethodsTest extends * * @throws Exception if the test fails */ + @Test public void testGetByFullyQualifiedPeerName() throws Exception { // Testing GetByName method for Object Types @@ -510,6 +522,7 @@ public class OMByNameMethodsTest extends * * @throws Exception if the test fails */ + @Test public void testGetByUnqualifiedPeerName() throws Exception { // Testing GetByName method for Object Types @@ -569,6 +582,7 @@ public class OMByNameMethodsTest extends * Checks that getByPosition returns the value set with a setByPosition call * for all known object and primitive types. */ + @Test public void testSetByPositionMethod() throws Exception { // Testing GetByName method for Object Types @@ -619,6 +633,7 @@ public class OMByNameMethodsTest extends * * @throws Exception if the test fails */ + @Test public void testGetByPositionMethod() throws Exception { // Testing GetByName method for Object Types @@ -675,6 +690,7 @@ public class OMByNameMethodsTest extends * Validate that various an IllegalArgumentException if thrown if the * Object type of the value is not correct. */ + @Test public void testInvalidObjectErrors() throws Exception { ColumnAccessByName objectTypes = new TypesObject(); @@ -710,6 +726,7 @@ public class OMByNameMethodsTest extends /* * Validate that a false rc is returned if non-column names passed to methods. */ + @Test public void testInvalidNameErrors() throws Exception { ColumnAccessByName objectTypes = new TypesObject(); @@ -730,6 +747,7 @@ public class OMByNameMethodsTest extends /** * Verify that null handling (can't use them for primitives) works. */ + @Test public void testNullHandling() throws Exception { ColumnAccessByName objectTypes = new TypesObject(); Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/sql/SkipSqlTest.java URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/sql/SkipSqlTest.java?rev=1870836&r1=1870835&r2=1870836&view=diff ============================================================================== --- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/sql/SkipSqlTest.java (original) +++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/sql/SkipSqlTest.java Wed Dec 4 15:51:06 2019 @@ -23,6 +23,13 @@ import java.sql.Connection; import org.apache.torque.BaseDatabaseTestCase; import org.apache.torque.Torque; +import org.junit.jupiter.api.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.junit.Assert.assertNotNull; /** * Checks whether the SkipSql flag works on a table. @@ -37,6 +44,7 @@ public class SkipSqlTest extends BaseDat * * @throws Exception if an error occurs. */ + @Test public void testSkipTableNotPresent() throws Exception { Connection connection = null; Added: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/BeanConditionalContainerTest.java URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/BeanConditionalContainerTest.java?rev=1870836&view=auto ============================================================================== --- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/BeanConditionalContainerTest.java (added) +++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/BeanConditionalContainerTest.java Wed Dec 4 15:51:06 2019 @@ -0,0 +1,9 @@ +package org.apache.torque.testcontainer; + +import org.apache.torque.BeanTestConditional; +import org.apache.torque.testcontainer.junit5.extension.DockerCallback; + +@DockerCallback +public class BeanConditionalContainerTest extends BeanTestConditional { + +} Propchange: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/BeanConditionalContainerTest.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/DataContainerTest.java URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/DataContainerTest.java?rev=1870836&r1=1870835&r2=1870836&view=diff ============================================================================== --- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/DataContainerTest.java (original) +++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/DataContainerTest.java Wed Dec 4 15:51:06 2019 @@ -1,1452 +1,16 @@ package org.apache.torque.testcontainer; -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import static org.junit.Assert.*; - -import java.sql.Connection; -import java.sql.ResultSet; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.apache.torque.ColumnImpl; -import org.apache.torque.ForeignKeySchemaData; -import org.apache.torque.TestInterface; -import org.apache.torque.TestPeerInterface; -import org.apache.torque.Torque; -import org.apache.torque.TorqueException; -import org.apache.torque.adapter.Adapter; -import org.apache.torque.adapter.DerbyAdapter; -import org.apache.torque.adapter.HsqldbAdapter; -import org.apache.torque.adapter.MssqlAdapter; -import org.apache.torque.adapter.MysqlAdapter; -import org.apache.torque.criteria.Criteria; -import org.apache.torque.criteria.Criterion; -import org.apache.torque.om.mapper.CompositeMapper; -import org.apache.torque.om.mapper.IntegerMapper; -import org.apache.torque.om.mapper.RecordMapper; -import org.apache.torque.test.InheritanceClassnameTestChild1; -import org.apache.torque.test.InheritanceClassnameTestChild2; -import org.apache.torque.test.dbobject.Author; -import org.apache.torque.test.dbobject.BigintType; -import org.apache.torque.test.dbobject.Book; -import org.apache.torque.test.dbobject.CompPkContainsFk; -import org.apache.torque.test.dbobject.IfcTable; -import org.apache.torque.test.dbobject.InheritanceChildB; -import org.apache.torque.test.dbobject.InheritanceChildC; -import org.apache.torque.test.dbobject.InheritanceChildD; -import org.apache.torque.test.dbobject.InheritanceClassnameTest; -import org.apache.torque.test.dbobject.InheritanceTest; -import org.apache.torque.test.dbobject.IntegerType; -import org.apache.torque.test.dbobject.LocalIfcTable; -import org.apache.torque.test.dbobject.LocalTestInterface; -import org.apache.torque.test.dbobject.MultiPk; -import org.apache.torque.test.dbobject.Nopk; -import org.apache.torque.test.dbobject.OIntegerPk; -import org.apache.torque.test.dbobject.VarcharType; -import org.apache.torque.test.peer.AuthorPeer; -import org.apache.torque.test.peer.BigintTypePeer; -import org.apache.torque.test.peer.BookPeer; -import org.apache.torque.test.peer.CompPkContainsFkPeer; -import org.apache.torque.test.peer.IfcTablePeer; -import org.apache.torque.test.peer.IfcTablePeerImpl; -import org.apache.torque.test.peer.InheritanceClassnameTestPeer; -import org.apache.torque.test.peer.InheritanceTestPeer; -import org.apache.torque.test.peer.IntegerTypePeer; -import org.apache.torque.test.peer.LocalIfcTablePeer; -import org.apache.torque.test.peer.LocalIfcTablePeerImpl; -import org.apache.torque.test.peer.LocalTestPeerInterface; -import org.apache.torque.test.peer.MultiPkPeer; -import org.apache.torque.test.peer.NopkPeer; -import org.apache.torque.test.peer.VarcharTypePeer; -import org.apache.torque.test.recordmapper.AuthorRecordMapper; -import org.apache.torque.test.recordmapper.BookRecordMapper; -import org.apache.torque.util.BasePeerImpl; -import org.apache.torque.util.CountHelper; -import org.apache.torque.util.Transaction; -import org.junit.jupiter.api.Tag; -import org.junit.jupiter.api.Test; -import org.testcontainers.junit.jupiter.Testcontainers; +import org.apache.torque.DataTest; +import org.apache.torque.testcontainer.junit5.extension.DockerCallback; /** - * Runtime tests. + * Docker adapter tests. * - * @author <a href="mailto:se...@backstagetech.com.au">Scott Eade</a> - * @author <a href="mailto:mpoes...@marmot.at">Martin Poeschl</a> - * @author <a href="mailto:fisc...@seitenbau.de">Thomas Fischer</a> - * @author <a href="mailto:patrick.c...@web.de">Patrick Carl</a> - * @author <a href="mailto:t...@apache.org">Thomas Vandahl</a> * @author <a href="mailto:g...@apache.org">Georg Kallidis</a> * @version $Id: DataTest.java 1869081 2019-10-28 16:17:11Z gk $ */ -@Tag("docker") -@Testcontainers -public class DataContainerTest extends BaseDatabaseContainerTestCase +@DockerCallback +public class DataContainerTest extends DataTest { - private static Logger log = LogManager.getLogger(); - - /** - * test whether we can connect to the database at all - * @throws Exception if no connection can be established - */ - @Test - @Tag("docker") - public void testConnect() throws Exception - { - Connection connection = null; - try - { - connection = Torque.getConnection(); - connection.close(); - connection = null; - } - finally - { - if (connection != null) - { - connection.close(); - } - } - } - - /** - * multiple pk test (TRQ12) - * @throws Exception if the test fails - */ - @Test - public void testMultiplePk() throws Exception - { - // clean table - Criteria criteria = new Criteria(); - criteria.where(MultiPkPeer.PK1, (Object) null, Criteria.NOT_EQUAL); - MultiPkPeer.doDelete(criteria); - - // do test - MultiPk mpk = new MultiPk(); - mpk.setPrimaryKey("Svarchar:N5:Schar:N3:N-42:N3:N4:N5:N6:D9999999999:"); - mpk.save(); - // TODO assert saved values - } - - private static final String[] validTitles = { - "Book 6 - Author 4", "Book 6 - Author 5", "Book 6 - Author 6", - "Book 6 - Author 7", "Book 6 - Author 8", - "Book 7 - Author 4", "Book 7 - Author 5", "Book 7 - Author 6", - "Book 7 - Author 7", "Book 7 - Author 8" - }; - - /** - * test limit/offset - * - * @throws Exception if the test fails - */ - @Test - public void testLimitOffset() throws Exception - { - cleanBookstore(); - insertBookstoreData(); - Set<String> titleSet = new HashSet<>(); - for (int j = 0; j < validTitles.length; j++) - { - titleSet.add(validTitles[j]); - } - - Criteria crit = new Criteria(); - Criterion c = new Criterion(BookPeer.TITLE, - "Book 6 - Author 1", Criteria.GREATER_EQUAL); - c.and(new Criterion(BookPeer.TITLE, - "Book 8 - Author 3", Criteria.LESS_EQUAL)); - crit.where(c); - crit.addDescendingOrderByColumn(BookPeer.BOOK_ID); - crit.setLimit(10); - crit.setOffset(5); - List<Book> books = BookPeer.doSelect(crit); - assertEquals("List should have 10 books", 10, books.size()); - for (Book book : books) - { - String title = book.getTitle(); - assertTrue("Incorrect title: " + title, - titleSet.contains(title)); - } - - - // Test limit of zero works - if (defaultAdapter instanceof DerbyAdapter || defaultAdapter instanceof HsqldbAdapter) - { - log.info("testLimitOffset(): " - + "A limit of 0 is not supported for Derby or Hsqldb"); - } - else - { - crit = new Criteria(); - crit.setLimit(0); - books = BookPeer.doSelect(crit); - assertEquals("List should have 0 books", 0, books.size()); - } - - // check that Offset also works without limit - crit = new Criteria(); - crit.setOffset(5); - books = BookPeer.doSelect(crit); - assertEquals("List should have 95 books", 95, books.size()); - - // Check that limiting also works if a table with an equal column name - // is joined. This is problematic for oracle, see TORQUE-10. - - crit = new Criteria(); - crit.setLimit(10); - crit.setOffset(5); - books = BookPeer.doSelectJoinAuthor(crit); - assertEquals("List should have 10 books", 10, books.size()); - } - - /** - * Checks whether the setSingleRecord() method in criteria works - */ - @Test - public void testSingleRecord() throws Exception - { - cleanBookstore(); - insertBookstoreData(); - Criteria criteria = new Criteria(); - criteria.setSingleRecord(true); - criteria.setLimit(1); - criteria.setOffset(5); - List<Book> books = BookPeer.doSelect(criteria); - assertTrue("List should have 1 books, not " + books.size(), - books.size() == 1); - - criteria = new Criteria(); - 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 selects work correctly if the value <code>null</code> - * is used. - * @throws Exception if the test fails - */ - @Test - public void testNullSelects() throws Exception - { - // clean table - VarcharTypePeer.doDelete(new Criteria()); - IntegerTypePeer.doDelete(new Criteria()); - - // add test data - VarcharType varcharType = new VarcharType(); - varcharType.setId("text2"); - varcharType.setVarcharValue("text2"); - varcharType.save(); - varcharType = new VarcharType(); - varcharType.setId("text"); - varcharType.save(); - - IntegerType integerTypeNotNull = new IntegerType(); - integerTypeNotNull.setIntegerObjectValue(1); - integerTypeNotNull.save(); - IntegerType integerTypeNull = new IntegerType(); - integerTypeNull.save(); - - // check for comparison NOT_EQUAL and value null - Criteria criteria = new Criteria(); - criteria.where(VarcharTypePeer.ID, null, Criteria.NOT_EQUAL) - .and(VarcharTypePeer.VARCHAR_VALUE, null, Criteria.NOT_EQUAL); - List<VarcharType> varcharResult = VarcharTypePeer.doSelect(criteria); - assertEquals(1, varcharResult.size()); - assertEquals("text2", varcharResult.get(0).getId()); - - criteria = new Criteria(); - criteria.where(IntegerTypePeer.ID, null, Criteria.NOT_EQUAL) - .and(IntegerTypePeer.INTEGER_OBJECT_VALUE, null, Criteria.NOT_EQUAL); - List<IntegerType> integerResult = IntegerTypePeer.doSelect(criteria); - assertEquals(1, integerResult.size()); - assertEquals(integerTypeNotNull.getId(), integerResult.get(0).getId()); - - // check for comparison EQUAL and value null - criteria = new Criteria(); - criteria.where(VarcharTypePeer.VARCHAR_VALUE, null, Criteria.EQUAL); - varcharResult = VarcharTypePeer.doSelect(criteria); - assertEquals(1, varcharResult.size()); - assertEquals("text", varcharResult.get(0).getId()); - - criteria = new Criteria(); - criteria.where(IntegerTypePeer.INTEGER_OBJECT_VALUE, null, Criteria.EQUAL); - integerResult = IntegerTypePeer.doSelect(criteria); - assertEquals(1, integerResult.size()); - assertEquals(integerTypeNull.getId(), integerResult.get(0).getId()); - } - - /** - * Test whether an update works and whether it only affects the - * specified record. - * @throws Exception if anything in the test goes wrong. - */ - @Test - public void testUpdate() throws Exception - { - cleanBookstore(); - - Author otherAuthor = new Author(); - otherAuthor.setName("OtherName"); - otherAuthor.save(); - - Author author = new Author(); - author.setName("Name"); - author.save(); - - - // Test doUpdate methods in Peer explicitly - Connection connection = Transaction.begin(AuthorPeer.DATABASE_NAME); - author.setName("NewName2"); - AuthorPeer.doUpdate(author); - Transaction.commit(connection); - - Criteria criteria = new Criteria(); - criteria.addAscendingOrderByColumn(AuthorPeer.NAME); - - List<Author> authors = AuthorPeer.doSelect(criteria); - assertEquals("List should contain 2 authors", 2, authors.size()); - assertEquals("First Author's name should be \"NewName2\"", - "NewName2", - authors.get(0).getName()); - assertEquals("Second Author's name should be \"OtherName\"", - "OtherName", - authors.get(1).getName()); - - author.setName("NewName3"); - AuthorPeer.doUpdate(author); - - criteria = new Criteria(); - criteria.addAscendingOrderByColumn(AuthorPeer.NAME); - - authors = AuthorPeer.doSelect(criteria); - assertEquals("List should contain 2 authors", 2, authors.size()); - assertEquals("First Author's name should be \"NewName3\"", - "NewName3", - authors.get(0).getName()); - assertEquals("Second Author's name should be \"OtherName\"", - "OtherName", - authors.get(1).getName()); - - Nopk nopk = new Nopk(); - nopk.setName("name"); - nopk.save(); - - // check the doPupdate Peer methods throw exceptions on a modified - // object without primary keys - try - { - NopkPeer.doUpdate(new Nopk()); - fail("A Torque exception should be thrown (2)"); - } - catch (TorqueException e) - { - } - - connection = Transaction.begin(NopkPeer.DATABASE_NAME); - try - { - NopkPeer.doUpdate(new Nopk(),connection); - fail("A Torque exception should be thrown (3)"); - } - catch (TorqueException e) - { - } - Transaction.safeRollback(connection); - - } - - /** - * test special cases in the select clause - * @throws Exception if the test fails - */ - @Test - public void testSelectClause() throws Exception - { - // test double functions in select columns - Criteria criteria = new Criteria(); - criteria.addSelectColumn( - new ColumnImpl("count(distinct(" + BookPeer.BOOK_ID + "))")); - new BasePeerImpl<>().doSelect(criteria, new IntegerMapper()); - - // test qualifiers in function in select columns - criteria = new Criteria(); - criteria.addSelectColumn( - new ColumnImpl("count(distinct " + BookPeer.BOOK_ID + ")")); - new BasePeerImpl<>().doSelect(criteria, new IntegerMapper()); - } - - /** - * test if a select from the "default" database works - * @throws Exception (NPE) if the test fails - */ - @Test - public void testSelectFromDefault() throws Exception - { - Criteria criteria = new Criteria("default"); - - criteria.addSelectColumn(BookPeer.BOOK_ID); - - new BasePeerImpl<>().doSelect(criteria, new IntegerMapper()); - } - - /** - * Test the behaviour if a connection is supplied to access the database, - * but it is null. All methods on the user level should be fail - * because these methods will be only needed if a method should be executed - * in a transaction context. If one assumes that a transaction is open - * (connection is not null), but it is not (connection == null), - * it is a bad idea to silently start one as this behaviour is very - * difficult to tell from the correct one. A clean failure is much easier - * to test for. - */ - @Test - public void testNullConnection() throws Exception - { - try - { - Criteria criteria = new Criteria(); - AuthorPeer.doSelect(criteria, new IntegerMapper(), null); - fail("NullPointerException expected"); - } - catch (NullPointerException e) - { - //expected - } - - try - { - Criteria criteria = new Criteria(); - criteria.where(BookPeer.BOOK_ID, (Long) null, Criteria.NOT_EQUAL); - BookPeer.doDelete(criteria, (Connection) null); - fail("NullPointerException expected"); - } - catch (NullPointerException e) - { - //expected - } - - try - { - Author author = new Author(); - author.setName("name"); - author.save((Connection) null); - fail("TorqueException expected"); - } - catch (TorqueException e) - { - //expected - assertEquals("connection is null", e.getMessage()); - } - } - - /** - * test the order by, especially in joins and with aliases - * @throws Exception if the test fails - */ - @Test - public void testOrderBy() throws Exception - { - cleanBookstore(); - - // insert test data - Author firstAuthor = new Author(); - firstAuthor.setName("Author 1"); - firstAuthor.save(); - Book book = new Book(); - book.setAuthor(firstAuthor); - 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++) - { - book = new Book(); - book.setAuthor(secondAuthor); - book.setTitle("Book " + bookNr); - book.setIsbn("unknown"); - book.save(); - } - - // test simple ascending order by - Criteria criteria = new Criteria(); - criteria.addAscendingOrderByColumn(BookPeer.TITLE); - List<Book> bookList = BookPeer.doSelect(criteria); - if (bookList.size() != 4) - { - fail("Ascending Order By: " - + "incorrect numbers of books found : " - + bookList.size() - + ", should be 4"); - } - if (! "Book 1".equals(bookList.get(0).getTitle())) - { - fail("Ascending Order By: " - + "Title of first Book is " - + bookList.get(0).getTitle() - + ", should be \"Book 1\""); - } - if (! "Book 4".equals(bookList.get(3).getTitle())) - { - fail("Ascending Order By: " - + "Title of fourth Book is " - + 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) - { - fail("Descending Order By: " - + "incorrect numbers of books found : " - + bookList.size() - + ", should be 4"); - } - if (! "Book 1".equals(bookList.get(3).getTitle())) - { - fail("Descending Order By: " - + "Title of fourth Book is " - + bookList.get(3).getTitle() - + ", should be \"Book 1\""); - } - if (! "Book 4".equals((bookList.get(0)).getTitle())) - { - fail("Descending Order By: " - + "Title of first Book is " - + bookList.get(0).getTitle() - + ", should be \"Book 4\""); - } - - criteria = new Criteria(); - criteria.addAlias("b", BookPeer.TABLE_NAME); - criteria.addJoin(BookPeer.AUTHOR_ID, AuthorPeer.AUTHOR_ID); - criteria.addJoin( - AuthorPeer.AUTHOR_ID, - new ColumnImpl("b." + BookPeer.AUTHOR_ID.getColumnName())); - criteria.addAscendingOrderByColumn( - new ColumnImpl("b." + BookPeer.TITLE.getColumnName())); - criteria.addDescendingOrderByColumn(BookPeer.TITLE); - // the retrieved columns are - // author book b - // author1 book1 book1 - // author2 book4 book2 - // author2 book3 book2 - // author2 book2 book2 - // author2 book4 book3 - // ... - bookList = BookPeer.doSelect(criteria); - if (bookList.size() != 10) - { - fail("ordering by Aliases: " - + "incorrect numbers of books found : " - + bookList.size() - + ", should be 10"); - } - if (!"Book 4".equals(bookList.get(1).getTitle())) - { - fail("ordering by Aliases: " - + "Title of second Book is " - + bookList.get(1).getTitle() - + ", should be \"Book 4\""); - } - if (!"Book 3".equals(bookList.get(2).getTitle())) - { - fail("ordering by Aliases: " - + "Title of third Book is " - + 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, - new ColumnImpl("b." + BookPeer.AUTHOR_ID.getColumnName())); - criteria.addAscendingOrderByColumn(BookPeer.TITLE); - criteria.addDescendingOrderByColumn( - new ColumnImpl("b." + BookPeer.TITLE.getColumnName())); - // the retrieved columns are - // author book b - // author1 book1 book1 - // author2 book2 book4 - // author2 book2 book3 - // author2 book2 book2 - // author2 book3 book4 - // ... - bookList = BookPeer.doSelect(criteria); - if (bookList.size() != 10) - { - fail("ordering by Aliases (2): " - + "incorrect numbers of books found : " - + bookList.size() - + ", should be 10"); - } - if (!"Book 2".equals(bookList.get(1).getTitle())) - { - fail("ordering by Aliases (2, PS): " - + "Title of second Book is " - + bookList.get(1).getTitle() - + ", should be \"Book 2\""); - } - if (!"Book 2".equals(bookList.get(2).getTitle())) - { - fail("ordering by Aliases (2, PS): " - + "Title of third Book is " - + bookList.get(2).getTitle() - + ", should be \"Book 2\""); - } - - // test usage of Expressions in order by - criteria = new Criteria(); - criteria.addAscendingOrderByColumn( - new ColumnImpl("UPPER(" + BookPeer.TITLE + ")")); - criteria.setIgnoreCase(true); - BookPeer.doSelect(criteria); - } - - - /** - * Tests whether ignoreCase works correctly - * @throws Exception if the test fails - */ - @Test - public void testIgnoreCase() throws Exception - { - cleanBookstore(); - - // check ignore case in selects - Author author = new Author(); - author.setName("AuTHor"); - author.save(); - - Criteria criteria = new Criteria(); - criteria.where(AuthorPeer.NAME, author.getName().toLowerCase()); - criteria.setIgnoreCase(true); - List<Author> result = AuthorPeer.doSelect(criteria); - assertTrue("Size of result is not 1, but " + result.size(), - result.size() == 1); - - // LIKE treatment might be different (e.g. postgres), so check extra - criteria = new Criteria(); - criteria.where( - AuthorPeer.NAME, - author.getName().toLowerCase().replace('r', '%'), - Criteria.LIKE); - criteria.setIgnoreCase(true); - result = AuthorPeer.doSelect(criteria); - assertTrue("Size of result is not 1, but " + result.size(), - result.size() == 1); - - // Test ignore case in criterion - criteria = new Criteria(); - Criterion criterion1 = new Criterion( - AuthorPeer.NAME, - author.getName().toLowerCase(), - Criteria.EQUAL); - criterion1.setIgnoreCase(true); - Criterion criterion2 = new Criterion( - AuthorPeer.AUTHOR_ID, null, Criteria.NOT_EQUAL); - criterion1.and(criterion2); - - result = AuthorPeer.doSelect(criteria); - - // ignore case should not be set either in Criteria - // nor in other criterions - assertFalse(criteria.isIgnoreCase()); - assertFalse(criterion2.isIgnoreCase()); - assertTrue("Size of result is not 1, but " + result.size(), - result.size() == 1); - - - // Test ignore case in attached criterion - criteria = new Criteria(); - criterion1 = new Criterion( - AuthorPeer.AUTHOR_ID, null, Criteria.NOT_EQUAL); - criterion2 = new Criterion( - AuthorPeer.NAME, - author.getName().toLowerCase(), - Criteria.EQUAL); - criterion2.setIgnoreCase(true); - criterion1.and(criterion2); - - result = AuthorPeer.doSelect(criteria); - - // ignore case should not be set either in Criteria - // nor in other criterions - assertFalse(criteria.isIgnoreCase()); - assertFalse(criterion1.isIgnoreCase()); - - assertTrue("Size of result is not 1, but " + result.size(), - result.size() == 1); - - // ignore case in "in" query - { - criteria = new Criteria(); - Set<String> names = new HashSet<>(); - names.add(author.getName().toLowerCase()); - criteria.where(AuthorPeer.NAME, names, Criteria.IN); - criteria.setIgnoreCase(true); - - result = AuthorPeer.doSelect(criteria); - assertEquals("Expected result of size 1 but got " + result.size(), - result.size(), - 1); - } - - // Check that case is not ignored if ignoreCase is not set - // This is known not to work for mysql - author = new Author(); - author.setName("author"); - author.save(); - - Adapter adapter = Torque.getAdapter(Torque.getDefaultDB()); - if (adapter instanceof MysqlAdapter - || adapter instanceof MssqlAdapter) - { - log.error("testIgnoreCase(): " - + "Case sensitive comparisons are known not to work" - + " with Mysql and MSSQL"); - // failing is "expected", so bypass without error - } - else - { - criteria = new Criteria(); - criteria.where(AuthorPeer.NAME, author.getName()); - result = AuthorPeer.doSelect(criteria); - assertTrue("Size of result is not 1, but " + result.size(), - result.size() == 1); - - // again check LIKE treatment - criteria = new Criteria(); - criteria.where( - AuthorPeer.NAME, - author.getName().replace('r', '%'), - Criteria.LIKE); - result = AuthorPeer.doSelect(criteria); - assertTrue("Size of result is not 1, but " + result.size(), - result.size() == 1); - - // Test different ignore cases in criterions - criteria = new Criteria(); - criterion1 = new Criterion( - AuthorPeer.NAME, - author.getName().toLowerCase(), - Criteria.NOT_EQUAL); - criterion2 = new Criterion( - AuthorPeer.NAME, - author.getName().toLowerCase(), - Criteria.EQUAL); - criterion2.setIgnoreCase(true); - criterion1.and(criterion2); - criteria.where(criterion1); - - result = AuthorPeer.doSelect(criteria); - assertTrue("Size of result is not 1, but " + result.size(), - result.size() == 1); - - // ignore case in "in" query - { - criteria = new Criteria(); - Set<String> names = new HashSet<>(); - names.add(author.getName()); - criteria.where(AuthorPeer.NAME, names, Criteria.IN); - - result = AuthorPeer.doSelect(criteria); - assertEquals("Expected result of size 1 but got " + result.size(), - result.size(), - 1); - } - } - - cleanBookstore(); - author = new Author(); - author.setName("AA"); - author.save(); - author = new Author(); - author.setName("BB"); - author.save(); - author = new Author(); - author.setName("ba"); - author.save(); - author = new Author(); - author.setName("ab"); - author.save(); - - // check ignoreCase in Criteria - criteria = new Criteria(); - criteria.setIgnoreCase(true); - criteria.addAscendingOrderByColumn(AuthorPeer.NAME); - result = AuthorPeer.doSelect(criteria); - assertTrue("Size of result is not 4, but " + result.size(), - result.size() == 4); - assertEquals("AA", result.get(0).getName()); - assertEquals("ab", result.get(1).getName()); - assertEquals("ba", result.get(2).getName()); - assertEquals("BB", result.get(3).getName()); - - // check ignoreCase in orderBy - criteria = new Criteria(); - criteria.addAscendingOrderByColumn(AuthorPeer.NAME, true); - result = AuthorPeer.doSelect(criteria); - assertTrue("Size of result is not 4, but " + result.size(), - result.size() == 4); - assertEquals(result.get(0).getName(), "AA"); - assertEquals(result.get(1).getName(), "ab"); - assertEquals(result.get(2).getName(), "ba"); - assertEquals(result.get(3).getName(), "BB"); - } - - /** - * tests whether AsColumns produce valid SQL code - * @throws Exception if the test fails - */ - @Test - public void testAsColumn() throws Exception - { - Criteria criteria = new Criteria(); - criteria.addAsColumn("ALIASNAME", AuthorPeer.NAME); - // we need an additional column to select from, - // to indicate the table we want use - criteria.addSelectColumn(AuthorPeer.AUTHOR_ID); - new BasePeerImpl<>().doSelect(criteria, new DoNothingMapper()); - } - - /** - * Test whether same column name in different tables - * are handled correctly - * @throws Exception if the test fails - */ - @Test - public void testSameColumnName() throws Exception - { - cleanBookstore(); - 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); - AuthorPeer.addSelectColumns(criteria); - // basically a BaseBookPeer.setDbName(criteria); - // and BasePeer.doSelect(criteria); - CompositeMapper mapper = new CompositeMapper(); - mapper.addMapper(new BookRecordMapper(), 0); - mapper.addMapper( - new AuthorRecordMapper(), - BookPeer.numColumns); - - List<List<Object>> queryResult - = BookPeer.doSelect(criteria, mapper); - List<Object> mappedRow = queryResult.get(0); - book = (Book) mappedRow.get(0); - author = (Author) mappedRow.get(1); - - if (book.getAuthorId() == author.getAuthorId()) - { - fail("wrong Ids read"); - } - } - - /** - * tests whether large primary keys are inserted and read correctly - * @throws Exception if the test fails - */ - @Test - public void testLargePk() throws Exception - { - if (defaultAdapter instanceof MssqlAdapter) { - log.error("testLargePk(): " - + "MSSQL does not support inserting defined PK values"); - return; - } - BigintTypePeer.doDelete(new Criteria()); - - long longId = 8771507845873286l; - BigintType bigintType = new BigintType(); - bigintType.setId(longId); - bigintType.save(); - - List<BigintType> bigintTypeList = BigintTypePeer.doSelect(new Criteria()); - BigintType readBigintType = bigintTypeList.get(0); - assertEquals(bigintType.getId(), readBigintType.getId()); - assertEquals(longId, readBigintType.getId()); - } - - /** - * tests whether large bigint values are inserted and read correctly - * @throws Exception if the test fails - */ - @Test - public void testLargeValue() throws Exception - { - BigintTypePeer.doDelete(new Criteria()); - - long longValue = 8771507845873286l; - BigintType bigintType = new BigintType(); - bigintType.setBigintValue(longValue); - bigintType.save(); - - List<BigintType> bigintTypeList = BigintTypePeer.doSelect(new Criteria()); - BigintType readBigintType = bigintTypeList.get(0); - assertEquals(bigintType.getId(), readBigintType.getId()); - assertEquals(longValue, readBigintType.getBigintValue()); - } - - /** - * Tests the CountHelper class - * @throws Exception if the test fails - */ - @Test - public void testCountHelper() throws Exception - { - 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.where(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 - * also foreign keys - * @throws Exception if the test fails - */ - @Test - public void testMultiplePrimaryForeignKey() throws Exception - { - ForeignKeySchemaData.clearTablesInDatabase(); - - OIntegerPk oIntegerPk = new OIntegerPk(); - oIntegerPk.save(); - CompPkContainsFk compPkContainsFk = new CompPkContainsFk(); - compPkContainsFk.setId1(oIntegerPk.getId()); - compPkContainsFk.setId2("test"); - compPkContainsFk.save(); - - List<CompPkContainsFk> selectedList - = CompPkContainsFkPeer.doSelect(new Criteria()); - assertEquals(1, selectedList.size()); - CompPkContainsFk selected = selectedList.get(0); - assertEquals(oIntegerPk.getId(), selected.getId1()); - assertEquals("test", selected.getId2()); - } - - /** - * 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. - * @throws Exception if inserting the test data fails - */ - @Test - public void testSingleQuotes() throws Exception - { - cleanBookstore(); - - Author author = new Author(); - author.setName("has Single ' Quote"); - author.save(); - } - - /** - * Test whether equals() is working correctly - * @throws Exception - */ - @Test - public void testEquals() throws Exception - { - Author author = new Author(); - author.setAuthorId(1000); - - Book book = new Book(); - book.setBookId(1000); - - Book bookNotEqual = new Book(); - bookNotEqual.setBookId(2000); - - Book bookEqual = new Book(); - bookEqual.setBookId(1000); - - assertFalse("Author and Book should not be equal", - author.equals(book)); - assertTrue("Book compared with itself should be equal", - book.equals(book)); - assertTrue("Book compared with book with same id should be equal", - book.equals(bookEqual)); - assertFalse("Book compared with book with different id " - + "should not be equal", - book.equals(bookNotEqual)); - } - - /** - * Tests whether a table implementing an interface actually - * returns an instance of this interface - * @throws Exception if the test fails - */ - @Test - public void testInterface() throws Exception - { - Criteria criteria = new Criteria(); - criteria.where(IfcTablePeer.ID, -1, Criteria.NOT_EQUAL); - IfcTablePeer.doDelete(criteria); - - IfcTable ifc = new IfcTable(); - - assertTrue("IfcTable should be an instance of TestInterface", - ifc instanceof TestInterface); - - ifc.setID(1); - ifc.setName("John Doe"); - ifc.save(); - - List<IfcTable> results = IfcTablePeer.doSelect(new Criteria()); - - for (IfcTable ifcTable : results) - { - assertTrue("IfcTablePeer.doSelect should return" - + " instances of TestInterface", - ifcTable instanceof TestInterface); - } - - IfcTablePeerImpl peerImpl = IfcTablePeer.getIfcTablePeerImpl(); - assertTrue("IfcTablePeerImpl should be an instance of " - + "TestPeerInterface", - peerImpl instanceof TestPeerInterface); - - LocalIfcTable localIfc = new LocalIfcTable(); - - assertTrue("LocalIfcTable should be an instance of LocalTestInterface", - localIfc instanceof LocalTestInterface); - - List<LocalIfcTable> results2 = LocalIfcTablePeer.doSelect(new Criteria()); - - for (LocalIfcTable readLocalIfcTable : results2) - { - assertTrue("IfcTable2Peer.doSelect should return" - + " instances of LocalTestInterface", - readLocalIfcTable instanceof LocalTestInterface); - } - - LocalIfcTablePeerImpl localPeerImpl = LocalIfcTablePeer.getLocalIfcTablePeerImpl(); - assertTrue("LocalIfcTablePeerImpl should be an instance of " - + "LocalTestPeerInterface", - localPeerImpl instanceof LocalTestPeerInterface); - } - - @Test - public void testInheritanceWithKeys() throws Exception - { - // make sure that the InheritanceTest table is empty before the test - Criteria criteria = new Criteria(); - criteria.where( - InheritanceTestPeer.INHERITANCE_TEST, - (Object) null, - Criteria.ISNOTNULL); - InheritanceTestPeer.doDelete(criteria); - criteria = new Criteria(); - criteria.where( - InheritanceTestPeer.INHERITANCE_TEST, - (Object) null, - Criteria.ISNOTNULL); - assertEquals(0, - new CountHelper().count(criteria)); - - // create & save test data - InheritanceTest inheritanceTest = new InheritanceTest(); - inheritanceTest.setPayload("payload1"); - inheritanceTest.save(); - InheritanceChildB inheritanceChildB = new InheritanceChildB(); - inheritanceChildB.setPayload("payload 2"); - inheritanceChildB.save(); - InheritanceChildC inheritanceChildC = new InheritanceChildC(); - inheritanceChildC.setPayload("payload 3"); - inheritanceChildC.save(); - InheritanceChildD inheritanceChildD = new InheritanceChildD(); - inheritanceChildD.setPayload("payload 4"); - inheritanceChildD.save(); - - // Check that all objects are saved into the InheritanceTest table - criteria = new Criteria(); - criteria.where( - InheritanceTestPeer.INHERITANCE_TEST, - null, - Criteria.ISNOTNULL); - assertEquals("InheritanceTestTable should contain 4 rows", - 4, - new CountHelper().count(criteria)); - criteria = new Criteria(); - criteria.addAscendingOrderByColumn( - InheritanceTestPeer.INHERITANCE_TEST); - - // Check that the class of the object is retained when loading - List<InheritanceTest> inheritanceObjects - = InheritanceTestPeer.doSelect(criteria); - assertEquals( - InheritanceTest.class, - inheritanceObjects.get(0).getClass()); - assertEquals( - InheritanceChildB.class, - inheritanceObjects.get(1).getClass()); - assertEquals( - InheritanceChildC.class, - inheritanceObjects.get(2).getClass()); - assertEquals( - InheritanceChildD.class, - inheritanceObjects.get(3).getClass()); - } - - @Test - public void testInheritanceWithClassname() throws Exception - { - // make sure that the InheritanceTest table is empty before the test - Criteria criteria = new Criteria(); - InheritanceClassnameTestPeer.doDelete(criteria); - criteria = new Criteria(); - criteria.where( - InheritanceClassnameTestPeer.INHERITANCE_TEST, - null, - Criteria.ISNOTNULL); - assertEquals(0, - new CountHelper().count(criteria)); - - // create & save test data - InheritanceClassnameTest inheritanceClassnameTest - = new InheritanceClassnameTest(); - inheritanceClassnameTest.setPayload("0 parent"); - inheritanceClassnameTest.save(); - InheritanceClassnameTestChild1 inheritanceClassnameChild1 - = new InheritanceClassnameTestChild1(); - inheritanceClassnameChild1.setPayload("1 child"); - inheritanceClassnameChild1.save(); - InheritanceClassnameTestChild2 inheritanceClassnameChild2 - = new InheritanceClassnameTestChild2(); - inheritanceClassnameChild2.setPayload("2 child"); - inheritanceClassnameChild2.save(); - - // Check that all objects are saved into the InheritanceTest table - criteria = new Criteria(); - criteria.where( - InheritanceClassnameTestPeer.INHERITANCE_TEST, - null, - Criteria.ISNOTNULL); - assertEquals("InheritanceClassnameTest table should contain 3 rows", - 3, - new CountHelper().count(criteria)); - criteria = new Criteria(); - criteria.addAscendingOrderByColumn( - InheritanceClassnameTestPeer.PAYLOAD); - - // Check that the class of the object is retained when loading - List<InheritanceClassnameTest> inheritanceObjects - = InheritanceClassnameTestPeer.doSelect(criteria); - assertEquals( - InheritanceClassnameTest.class, - inheritanceObjects.get(0).getClass()); - assertEquals("0 parent", inheritanceObjects.get(0).getPayload()); - assertEquals( - InheritanceClassnameTestChild1.class, - inheritanceObjects.get(1).getClass()); - assertEquals("1 child", inheritanceObjects.get(1).getPayload()); - assertEquals( - InheritanceClassnameTestChild2.class, - inheritanceObjects.get(2).getClass()); - assertEquals("2 child", inheritanceObjects.get(2).getPayload()); - } - - /** - * Checks whether selects with unqualified column names work. - * - * @throws Exception if a problem occurs. - */ - @Test - public void testUnqualifiedColumnNames() throws Exception - { - cleanBookstore(); - Author author = new Author(); - author.setName("Joshua Bloch"); - author.save(); - - Criteria criteria = new Criteria(); - criteria.where(AuthorPeer.AUTHOR_ID, (Object) null, Criteria.NOT_EQUAL); - criteria.and(new ColumnImpl("name"), "Joshua Bloch", Criteria.EQUAL); - List<Author> authors = AuthorPeer.doSelect(criteria); - assertEquals(1, authors.size()); - } - - @Test - public void testLikeClauseEscaping() throws Exception - { - String[] authorNames - = {"abc", "bbc", "a_c", "a%c", "a\\c", - "a\"c", "a'c", "a?c", "a*c" }; - - Map<String, String> likeResults = new LinkedHashMap<>(); - - likeResults.put("a\\_c", "a_c"); - likeResults.put("a\\_%", "a_c"); - likeResults.put("%\\_c", "a_c"); - - likeResults.put("a\\%c", "a%c"); - likeResults.put("a\\%%", "a%c"); - likeResults.put("%\\%c", "a%c"); // escaped second % - - likeResults.put("a\\\\c", "a\\c"); // escaped \ three times - likeResults.put("a\\\\%", "a\\c"); - - // mysql: like '%\\c' ESCAPE '|' succeeds, but - // %\\\\c fails, see https://dev.mysql.com/doc/refman/8.0/en/string-comparison-functions.html, - // MySQL uses C escape syntax in strings.. you must double any \ that you use in LIKE strings. - // That is platform specific mysql: - // likeResults.put("%\\\\\\\\c", "a\\c"); // succeeds in mysql - // other platforms ? - //likeResults.put("%\\\\c", "a\\c"); // fails in mysql - - likeResults.put("a\\*c", "a*c"); - likeResults.put("a\\*%", "a*c"); - //likeResults.put("%\\*c", "a*c"); // mysql: %\\*c fails, only underscore (_) is wild card - // this matches multiple users - //likeResults.put("%*c", "a%c"); - likeResults.put("_\\*c", "a*c"); - - likeResults.put("a\\?c", "a?c"); - likeResults.put("a\\?%", "a?c"); - likeResults.put("%\\?c", "a?c"); - - likeResults.put("a\"c", "a\"c"); - likeResults.put("a\"%", "a\"c"); - likeResults.put("%\"c", "a\"c"); - - likeResults.put("a'c", "a'c"); - likeResults.put("a'%", "a'c"); - likeResults.put("%'c", "a'c"); - cleanBookstore(); - - // Save authors - for (int i = 0; i < authorNames.length; ++i) - { - Author author = new Author(); - author.setName(authorNames[i]); - author.save(); - } - - // Check authors are in the database - for (int i = 0; i < authorNames.length; ++i) - { - Criteria criteria = new Criteria(); - criteria.where(AuthorPeer.NAME, authorNames[i]); - List<Author> authorList = AuthorPeer.doSelect(criteria); - assertEquals( - "AuthorList should contain one author" - + " when querying for " + authorNames[i], - 1, - authorList.size()); - Author author = authorList.get(0); - assertEquals("Name of author should be " + authorNames[i], - authorNames[i], - author.getName()); - } - - for (Map.Entry<String, String> likeResult : likeResults.entrySet()) - { - // System.out.println("Key: " + likeResult.getKey() + " - Value: " + likeResult.getValue()); - Criteria criteria = new Criteria(); - criteria.where( - AuthorPeer.NAME, - likeResult.getKey(), - Criteria.LIKE); - List<Author> authorList; - try - { - authorList = AuthorPeer.doSelect(criteria); - } - catch (Exception e) - { - throw new Exception( - "error executing select using like content " - + likeResult.getKey(), - e); - } - assertEquals( - "AuthorList contained " + authorList.size() + ", but should contain one author" - + " when querying for " + likeResult.getKey(), - 1, - authorList.size()); - Author author = authorList.get(0); - assertEquals("Name of author should be " - + likeResult.getValue() - + " when querying for " - + likeResult.getKey(), - likeResult.getValue(), - author.getName()); - } - - // check that case insensitivity is maintained if - // a like is replaced with an equals (no wildcard present) - // This might be a problem for databases which use ILIKE - Criteria criteria = new Criteria(); - criteria.where(AuthorPeer.NAME, "AbC", Criteria.LIKE); - criteria.setIgnoreCase(true); - List<Author> authorList = AuthorPeer.doSelect(criteria); - assertEquals( - "AuthorList should contain one author", - 1, - authorList.size()); - Author author = authorList.get(0); - assertEquals("Name of author should be abc", - "abc", - author.getName()); - - // check that the escape clause (where needed) also works - // with limit, offset and order by - criteria = new Criteria(); - Criterion criterion1 = new Criterion( - AuthorPeer.NAME, - "b%", - Criteria.LIKE); - Criterion criterion2 = new Criterion( - AuthorPeer.NAME, - "a\\%%", - Criteria.LIKE); - Criterion criterion3 = new Criterion( - AuthorPeer.NAME, - "cbc", - Criteria.LIKE); - criteria.where(criterion1.or(criterion2).or(criterion3)); - criteria.addAscendingOrderByColumn(AuthorPeer.NAME); - criteria.setOffset(1); - criteria.setLimit(1); - authorList = AuthorPeer.doSelect(criteria); - assertEquals( - "AuthorList should contain one author", - 1, - authorList.size()); - author = authorList.get(0); - assertEquals("Name of author should be bbc", - "bbc", - author.getName()); - } - - - /** - * Strips the schema and table name from a fully qualified colum name - * This is useful for creating Query with aliases, as the constants - * for the colum names in the data objects are fully qualified. - * @param fullyQualifiedColumnName the fully qualified column name, not null - * @return the column name stripped from the table (and schema) prefixes - */ - public static String getRawColumnName(final String fullyQualifiedColumnName) - { - int dotPosition = fullyQualifiedColumnName.lastIndexOf("."); - if (dotPosition == -1) - { - return fullyQualifiedColumnName; - } - String result = fullyQualifiedColumnName.substring( - dotPosition + 1, - fullyQualifiedColumnName.length()); - return result; - } - - static class DoNothingMapper implements RecordMapper<Object> - { - - /** Serial version */ - private static final long serialVersionUID = 1L; - - @Override - public Object processRow( - final ResultSet resultSet, - final int rowOffset, - final Criteria criteria) - throws TorqueException - { - return null; - } - } + } Added: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/ManagerConditionalContainerTest.java URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/ManagerConditionalContainerTest.java?rev=1870836&view=auto ============================================================================== --- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/ManagerConditionalContainerTest.java (added) +++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/ManagerConditionalContainerTest.java Wed Dec 4 15:51:06 2019 @@ -0,0 +1,9 @@ +package org.apache.torque.testcontainer; + +import org.apache.torque.ManagerTestConditional; +import org.apache.torque.testcontainer.junit5.extension.DockerCallback; + +@DockerCallback +public class ManagerConditionalContainerTest extends ManagerTestConditional { + +} Propchange: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/ManagerConditionalContainerTest.java ------------------------------------------------------------------------------ svn:eol-style = native Added: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerCallback.java URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerCallback.java?rev=1870836&view=auto ============================================================================== --- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerCallback.java (added) +++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerCallback.java Wed Dec 4 15:51:06 2019 @@ -0,0 +1,34 @@ +package org.apache.torque.testcontainer.junit5.extension; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import org.apache.torque.junit5.extension.AdapterParameterResolver; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; +import org.junit.jupiter.api.extension.ExtendWith; +import org.testcontainers.junit.jupiter.Testcontainers; + +/** + * {@code @DockerCallback} is used to signal that the annotated test class or + * test method is using Docker {@link Testcontainers} and Torque initialized accordingly. + * + * It is currently enabled by overridign the default + * + * @author gkallidis + * + */ +// may have ParameterizedTest in test class -> Possible configuration error +@Tag("DockerCallback") +@Inherited +@Target( { ElementType.TYPE, ElementType.METHOD } ) +@Retention(RetentionPolicy.RUNTIME) +@ExtendWith(DockerCallbackExtension.class) +@ExtendWith(AdapterParameterResolver.class) +//@EnabledIfEnvironmentVariable(named = "torque.callback", matches = "docker") +public @interface DockerCallback { + String value() default ""; +} Propchange: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerCallback.java ------------------------------------------------------------------------------ svn:eol-style = native Added: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerCallbackExtension.java URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerCallbackExtension.java?rev=1870836&view=auto ============================================================================== --- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerCallbackExtension.java (added) +++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerCallbackExtension.java Wed Dec 4 15:51:06 2019 @@ -0,0 +1,144 @@ +package org.apache.torque.testcontainer.junit5.extension; + + +import static org.junit.Assert.fail; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.adapter.Adapter; +import org.junit.jupiter.api.extension.BeforeAllCallback; +import org.junit.jupiter.api.extension.BeforeTestExecutionCallback; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.api.extension.ExtensionContext.Namespace; +import org.testcontainers.containers.GenericContainer; +import org.testcontainers.containers.wait.strategy.Wait; +import org.testcontainers.images.builder.ImageFromDockerfile; +import org.testcontainers.junit.jupiter.Container; +import org.testcontainers.junit.jupiter.Testcontainers; + +/** + * + * @author gk + * + */ +@Testcontainers +public class DockerCallbackExtension implements BeforeAllCallback, BeforeTestExecutionCallback { + + private static final String TORQUE_WRAPPER_CONFIG_SYSTEM_PROPERTY = "torque.wrapper.configuration.file"; + + // copied from src/test/profile/mysql/docker-resources/db/ + private static final String DOCKERFILE = "./target/Dockerfile"; + + private static Logger log = LogManager.getLogger(); + + private static int SERVICE_PORT = 3306; + + private static String DATABASE_NAME = "bookstore"; + + protected static Adapter defaultAdapter; + + public static Namespace NS = Namespace.create(DockerCallbackExtension.class); + + @Container + public static GenericContainer MY_SQL_CONTAINER = new GenericContainer<>( + new ImageFromDockerfile() + .withDockerfile(new File(DOCKERFILE).toPath()) + ).withExposedPorts( SERVICE_PORT ) //.withStartupAttempts( 2 ) + .withEnv( "MYSQL_DATABASE", DATABASE_NAME ) + .withEnv( "MYSQL_USER", "torque" ) + .withEnv( "MYSQL_PASSWORD", "torque" ) + .withEnv( "MYSQL_ROOT_PASSWORD","torque" ); + + @Override + public void beforeAll(ExtensionContext context) throws Exception { + //log.info("starting call context "+ context); + init(); + context.getStore(NS).put("container", MY_SQL_CONTAINER); + context.getStore(Namespace.GLOBAL).put("adapter", defaultAdapter); + } + + @Override + public void beforeTestExecution(ExtensionContext context) throws Exception { + //log.info("starting call test context "+ context); + } + + private void init() throws TorqueException, UnsupportedOperationException, IOException, InterruptedException { + log.info("Starting from dockerfile: {}", DOCKERFILE); + //before torque init + MY_SQL_CONTAINER.setStartupAttempts( 3 ); + startDatabaseContainer(); + // TODO do resource filtering and read from properties + File targetFile = new File(System.getProperty( + TORQUE_WRAPPER_CONFIG_SYSTEM_PROPERTY) + ); + Path torqueConfBase = Paths.get(targetFile.toURI()).getParent(); + updateTorque(torqueConfBase); + + synchronized (DockerCallbackExtension.class) + { + if (!Torque.isInit()) + { + Torque.init( + System.getProperty( + TORQUE_WRAPPER_CONFIG_SYSTEM_PROPERTY)); + } + } + defaultAdapter = Torque.getDatabase(Torque.getDefaultDB()).getAdapter(); + log.info("using adapter: {}", defaultAdapter); + + } + + private static void updateTorque(Path torqueConfBase) { + try { + String jdbcConnectionString = generateJdbcUrl(); + String customUrl = "torque.dsfactory.bookstore.connection.url="+ jdbcConnectionString; + // override and set mapped port in url, which is known only at runtime. + File file = torqueConfBase.resolve("torque.usersettings.properties").toFile(); + try (FileOutputStream fop = new FileOutputStream(file )) { + if (!file.exists()) { + file.createNewFile(); + } + fop.write( customUrl.getBytes() ); + fop.flush(); + } + } catch (Exception e) { + fail(); + } + } + + private static void startDatabaseContainer() { + if (!MY_SQL_CONTAINER.isRunning()) { + MY_SQL_CONTAINER.waitingFor(Wait.forListeningPort()); + MY_SQL_CONTAINER.start(); + } + } + + /** + * + * @returns the JDBC string with mapped port binding + */ + private static String generateJdbcUrl() { + startDatabaseContainer(); + if (!MY_SQL_CONTAINER.isRunning()) { throw new RuntimeException("Could not find RUNNING database container"); } + + //MY_SQL_CONTAINER.withCreateContainerCmdModifier(modifier) // + String serviceHost = MY_SQL_CONTAINER.getContainerIpAddress(); + Integer mappedPort = MY_SQL_CONTAINER.getMappedPort(SERVICE_PORT);// e.g. 32811 + log.info("generate jdbc url from {}, mapped Port: {}, bounded port: {}", serviceHost, mappedPort, MY_SQL_CONTAINER.getBoundPortNumbers()); + + String targetJDBC = //genJDBC; + String.format("jdbc:mysql://%s:%d/%s?loggerLevel=OFF", serviceHost, + mappedPort, DATABASE_NAME); + log.info( "used connect url: {}", targetJDBC); + return targetJDBC; + } + +} Propchange: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerCallbackExtension.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/BasePeerTest.java URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/BasePeerTest.java?rev=1870836&r1=1870835&r2=1870836&view=diff ============================================================================== --- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/BasePeerTest.java (original) +++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/BasePeerTest.java Wed Dec 4 15:51:06 2019 @@ -28,6 +28,12 @@ import org.apache.torque.criteria.Criter import org.apache.torque.test.dbobject.Author; import org.apache.torque.test.peer.BookPeer; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.junit.Assert.assertNull; + /** * Tests the methods in BasePeer directly, without any generated classes. * Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/CopyTestConditional.java URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/CopyTestConditional.java?rev=1870836&r1=1870835&r2=1870836&view=diff ============================================================================== --- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/CopyTestConditional.java (original) +++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/CopyTestConditional.java Wed Dec 4 15:51:06 2019 @@ -24,6 +24,12 @@ import org.apache.torque.test.dbobject.A import org.apache.torque.test.dbobject.Book; import org.apache.torque.test.peer.AuthorPeer; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.junit.Assert.assertNotNull; + /** * Test code for TorqueObject.copy(). * Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/ExceptionMapperTest.java URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/ExceptionMapperTest.java?rev=1870836&r1=1870835&r2=1870836&view=diff ============================================================================== --- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/ExceptionMapperTest.java (original) +++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/ExceptionMapperTest.java Wed Dec 4 15:51:06 2019 @@ -38,6 +38,12 @@ import org.apache.torque.test.dbobject.B import org.apache.torque.test.dbobject.SingleNamedUnique; import org.apache.torque.test.peer.SingleNamedUniquePeer; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.junit.Assert.assertNotNull; + public class ExceptionMapperTest extends BaseDatabaseTestCase { /** Sleep time for thread polling, in miliseconds. */ Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/LargeSelectTest.java URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/LargeSelectTest.java?rev=1870836&r1=1870835&r2=1870836&view=diff ============================================================================== --- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/LargeSelectTest.java (original) +++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/LargeSelectTest.java Wed Dec 4 15:51:06 2019 @@ -27,6 +27,15 @@ import org.apache.torque.criteria.Criter import org.apache.torque.om.mapper.IntegerMapper; import org.apache.torque.test.dbobject.Author; import org.apache.torque.test.peer.AuthorPeer; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertSame; /** * Test code for LargeSelect. @@ -44,11 +53,9 @@ public class LargeSelectTest extends Bas private Criteria criteria; - @Override + @BeforeEach public void setUp() throws Exception { - super.setUp(); - // Clean up any previous failures tearDown(); @@ -68,7 +75,8 @@ public class LargeSelectTest extends Bas criteria.where(AuthorPeer.NAME, LARGE_SELECT_AUTHOR); } - @Override + + @AfterEach public void tearDown() throws Exception { // Delete the test data Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/SummaryHelperTest.java URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/SummaryHelperTest.java?rev=1870836&r1=1870835&r2=1870836&view=diff ============================================================================== --- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/SummaryHelperTest.java (original) +++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/SummaryHelperTest.java Wed Dec 4 15:51:06 2019 @@ -34,6 +34,13 @@ import org.apache.torque.util.functions. import org.apache.torque.util.functions.Max; import org.apache.torque.util.functions.Min; import org.apache.torque.util.functions.Sum; +import org.junit.jupiter.api.BeforeEach; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.junit.Assert.assertNotNull; /** * Test code for SummaryHelper. @@ -55,10 +62,10 @@ public class SummaryHelperTest extends B "A2","B2","C2","D2" }; - @Override + + @BeforeEach public void setUp() throws Exception { - super.setUp(); // Clean up any previous failures Summarize1Peer.doDelete(new Criteria()); Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/TorqueConnectionImplTest.java URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/TorqueConnectionImplTest.java?rev=1870836&r1=1870835&r2=1870836&view=diff ============================================================================== --- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/TorqueConnectionImplTest.java (original) +++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/TorqueConnectionImplTest.java Wed Dec 4 15:51:06 2019 @@ -28,6 +28,12 @@ import org.apache.torque.test.dbobject.A import org.apache.torque.test.peer.AuthorPeer; import org.apache.torque.test.peer.BookPeer; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.junit.Assert.assertNotNull; + /** * Test correct behavior if Transaction is used with the try-with-resources pattern * @@ -35,6 +41,7 @@ import org.apache.torque.test.peer.BookP */ public class TorqueConnectionImplTest extends BaseDatabaseTestCase { + public void testTryWithResources() throws TorqueException { // prepare Modified: db/torque/torque4/trunk/torque-test/src/test/profile/mysql/docker-resources/testcontainers.properties URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/profile/mysql/docker-resources/testcontainers.properties?rev=1870836&r1=1870835&r2=1870836&view=diff ============================================================================== --- db/torque/torque4/trunk/torque-test/src/test/profile/mysql/docker-resources/testcontainers.properties (original) +++ db/torque/torque4/trunk/torque-test/src/test/profile/mysql/docker-resources/testcontainers.properties Wed Dec 4 15:51:06 2019 @@ -14,4 +14,6 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. + +# windows workaround, should have more than 2GB free disk space checks.disable = true \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: torque-dev-unsubscr...@db.apache.org For additional commands, e-mail: torque-dev-h...@db.apache.org