You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ke...@apache.org on 2012/09/12 08:31:28 UTC
svn commit: r1383802 - in
/incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src:
main/java/org/apache/isis/runtimes/dflt/objectstores/sql/common/
main/resources/ test/java/org/apache/isis/runtimes/dflt/objectstores/sql/
Author: kevin
Date: Wed Sep 12 06:31:28 2012
New Revision: 1383802
URL: http://svn.apache.org/viewvc?rev=1383802&view=rev
Log:
ISIS-268: The common test needs to be split into 2 seperate tests - test framework must be restarted to test ability of framework to recreate domain objects
Modified:
incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/common/Data.java
incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/common/SqlIntegrationTestData.java
incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/main/resources/log4j.properties
incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/test/java/org/apache/isis/runtimes/dflt/objectstores/sql/HsqlTest.java
Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/common/Data.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/common/Data.java?rev=1383802&r1=1383801&r2=1383802&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/common/Data.java (original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/common/Data.java Wed Sep 12 06:31:28 2012
@@ -19,35 +19,34 @@ public class Data {
// Helper values
static final java.sql.Date sqlDate;
+ static final java.sql.Date sqlDate20100305;
static {
/*
*
- * // For testing -ve offset timezone local regions. GMTm2_TIME_ZONE =
- * TimeZone.getTimeZone("GMT-0200"); //GMTm2_TIME_ZONE =
- * TimeZone.getTimeZone("UTC"); TimeZone.setDefault(GMTm2_TIME_ZONE);
+ * // For testing -ve offset timezone local regions. GMTm2_TIME_ZONE = TimeZone.getTimeZone("GMT-0200");
+ * //GMTm2_TIME_ZONE = TimeZone.getTimeZone("UTC"); TimeZone.setDefault(GMTm2_TIME_ZONE);
*/
/*
- * TimeZone timeZone = TimeZone.getTimeZone("Etc/UTC"); if (timeZone ==
- * null) { timeZone = TimeZone.getTimeZone("UTC"); } UTC_TIME_ZONE =
- * timeZone;
+ * TimeZone timeZone = TimeZone.getTimeZone("Etc/UTC"); if (timeZone == null) { timeZone =
+ * TimeZone.getTimeZone("UTC"); } UTC_TIME_ZONE = timeZone;
*/
/*
- * There is still an issue assigning a java.sql.Date variable from a
- * calendar. final Calendar cal = Calendar.getInstance();
- * cal.setTimeZone(UTC_TIME_ZONE); cal.clear(); cal.set(Calendar.YEAR,
- * 2011); cal.set(Calendar.MONTH, 4-1); cal.set(Calendar.DAY_OF_MONTH,
- * 8);
+ * There is still an issue assigning a java.sql.Date variable from a calendar. final Calendar cal =
+ * Calendar.getInstance(); cal.setTimeZone(UTC_TIME_ZONE); cal.clear(); cal.set(Calendar.YEAR, 2011);
+ * cal.set(Calendar.MONTH, 4-1); cal.set(Calendar.DAY_OF_MONTH, 8);
*/
// 2011-4-8 = 1270684800000
final Date date20100308 = new Date(2010, 4, 8);
sqlDate = new java.sql.Date(date20100308.getMillisSinceEpoch());
+
+ sqlDate20100305 = new java.sql.Date(new Date(2010, 3, 5).getMillisSinceEpoch());
}
static final Date applibDate = new Date(2010, 3, 5); // 2010-03-05 =
- // 1267747200000
+ // 1267747200000
static final DateTime dateTime = new DateTime(2010, 3, 5, 1, 23);
static final TimeStamp timeStamp = new TimeStamp(dateTime.millisSinceEpoch());
static final Time time = new Time(14, 56);
@@ -73,8 +72,9 @@ public class Data {
// Collection mapper tests
static final List<String> stringList1 = Arrays.asList("Baking", "Bakery", "Canned", "Dairy");
- static final List<String> stringList2 = Arrays.asList("Fridge", "Deli", "Fresh Produce", "Frozen", "Household", "Other..");
-
+ static final List<String> stringList2 = Arrays.asList("Fridge", "Deli", "Fresh Produce", "Frozen", "Household",
+ "Other..");
+
static List<String> getTableNames() {
return Arrays.asList("sqldataclass", "simpleclass", "simpleclasstwo", "primitivevaluedentity");
}
Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/common/SqlIntegrationTestData.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/common/SqlIntegrationTestData.java?rev=1383802&r1=1383801&r2=1383802&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/common/SqlIntegrationTestData.java (original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/common/SqlIntegrationTestData.java Wed Sep 12 06:31:28 2012
@@ -50,12 +50,11 @@ import org.apache.isis.tck.dom.sqlos.dat
/**
* @author Kevin kevin@kmz.co.za
*
- * The Singleton class {@link SqlIntegrationTestFixtures} is used to
- * preserve values between tests.
- *
+ * The Singleton class {@link SqlIntegrationTestFixtures} is used to preserve values between tests.
+ *
*/
public abstract class SqlIntegrationTestData extends SqlIntegrationTestCommonBase {
-
+
private static final Logger LOG = Logger.getLogger(SqlIntegrationTestData.class);
private static List<SimpleClass> simpleClassList1 = new ArrayList<SimpleClass>();
@@ -68,38 +67,37 @@ public abstract class SqlIntegrationTest
private static PrimitiveValuedEntity pve2;
@Test
- public void testAll() throws Exception {
+ public void testSetupStore() throws Exception {
testSetup();
setUpFactory();
testCreate();
+ }
+
+ @Test
+ public void testAll() throws Exception {
testLoad();
-
+
setUpFactory();
testString();
setStringToDifferentValue();
testSimpleClassCollection1Lazy();
- testApplibDate();
- testSqlDate();
- //testDateTimezoneIssue();
+
testMoney();
- testDateTime();
- testTimeStamp();
- testTime();
testColor();
testPassword();
testPercentage();
testStandardValueTypesMaxima();
testStandardValueTypesMinima();
-
+
// broken it...
- //testSingleReferenceLazy();
- //testSimpleClassTwoReferenceLazy();
-
+ testSingleReferenceLazy();
+ testSimpleClassTwoReferenceLazy();
+
testSimpleClassCollection1();
testSimpleClassCollection2();
-
+
testSingleReferenceResolve();
testSimpleClassTwoReferenceResolve();
testSimpleClassTwo();
@@ -108,10 +106,18 @@ public abstract class SqlIntegrationTest
testUpdateCollectionIsDirty();
testFindByMatchString();
testFindByMatchEntity();
- reinitializeFixtures();
-
+
+ testApplibDate();
+ testSqlDate();
+ testTime();
+ testDateTimezoneIssue();
+
+ testTimeStamp();
+ testDateTime();
+
+ // reinitializeFixtures();
+
}
-
private void testSetup() {
resetPersistenceStoreDirectlyIfRequired();
@@ -122,9 +128,9 @@ public abstract class SqlIntegrationTest
for (final String tableName : Data.getTableNames()) {
getSqlIntegrationTestFixtures().dropTable(tableName);
}
-
+
sqlDataClass = factory.newDataClass();
-
+
sqlDataClass.setString("Test String");
sqlDataClass.setDate(Data.applibDate);
sqlDataClass.setSqlDate(Data.sqlDate);
@@ -205,7 +211,7 @@ public abstract class SqlIntegrationTest
assertEquals(1, dataClasses.size());
final SqlDataClass sqlDataClass = dataClasses.get(0);
getSqlIntegrationTestFixtures().setSqlDataClass(sqlDataClass);
-
+
setFixtureInitializationState(State.DONT_INITIALIZE);
}
@@ -241,7 +247,8 @@ public abstract class SqlIntegrationTest
LOG.log(Level.INFO, "sqlDataClass.getDate().getTime() as Long: " + sqlDataClass.getDate().getMillisSinceEpoch());
if (!Data.applibDate.isEqualTo(sqlDataClass.getDate())) {
- fail("Applib date: Test '2010-3-5', expected " + Data.applibDate.toString() + ", but got " + sqlDataClass.getDate().toString() + ". Check log for more info.");
+ fail("Applib date: Test '2010-3-5', expected " + Data.applibDate.toString() + ", but got "
+ + sqlDataClass.getDate().toString() + ". Check log for more info.");
// LOG.log(Level.INFO, "Applib date: Test '2011-3-5', expected " +
// applibDate.toString() + ", but got "
// +
@@ -264,8 +271,8 @@ public abstract class SqlIntegrationTest
// 2011-4-8 = 1302220800000
LOG.log(Level.INFO, "sqlDate.toString() as String:" + Data.sqlDate); // shows
- // as
- // 2011-04-07
+ // as
+ // 2011-04-07
LOG.log(Level.INFO, "sqlDate.getTime() as Long:" + Data.sqlDate.getTime());
// 2011-4-8 = 1302220800000
@@ -275,7 +282,8 @@ public abstract class SqlIntegrationTest
LOG.log(Level.INFO, "sqlDataClass.getSqlDate().getTime() as Long:" + sqlDataClass.getSqlDate().getTime());
if (Data.sqlDate.compareTo(sqlDataClass.getSqlDate()) != 0) {
- fail("SQL date: Test '2011-4-8', expected " + Data.sqlDate.toString() + ", but got " + sqlDataClass.getSqlDate().toString() + ". Check log for more info.");
+ fail("SQL date: Test '2011-4-8', expected " + Data.sqlDate.toString() + ", but got "
+ + sqlDataClass.getSqlDate().toString() + ". Check log for more info.");
// LOG.log(Level.INFO, "SQL date: Test '2011-4-8', expected " +
// sqlDate.toString() + ", and got "
// + sqlDataClass.getSqlDate().toString()
@@ -289,33 +297,25 @@ public abstract class SqlIntegrationTest
@Ignore
private void testDateTimezoneIssue() {
/*
- * At the moment, applib Date and java.sql.Date are restored from
- * ValueSemanticsProviderAbstractTemporal with an explicit hourly offset
- * that comes from the timezone. I.e. in South Africa, with TZ +2h00,
- * they have an implicit time of 02h00 (2AM). This can potentially
- * seriously screw up GMT-X dates, which, I suspect, will actually be
- * set to the dat BEFORE.
+ * At the moment, applib Date and java.sql.Date are restored from ValueSemanticsProviderAbstractTemporal with an
+ * explicit hourly offset that comes from the timezone. I.e. in South Africa, with TZ +2h00, they have an
+ * implicit time of 02h00 (2AM). This can potentially seriously screw up GMT-X dates, which, I suspect, will
+ * actually be set to the dat BEFORE.
*
- * This test is a simple test to confirm that date/time before and after
- * checks work as expected.
- */
- /*
- * *
- * SqlDataClass sqlDataClass = SqlIntegrationTestSingleton.getPerson();
- *
- * DateTime dateTime = sqlDataClass.getDateTime(); // new DateTime(2010,
- * 3, 5, 1, 23); Date date = sqlDataClass.getDate(); // new Date(2010,
- * 3, 5);
- *
- * //java.sql.Date sqlDate = sqlDataClass.getSqlDate(); // "2010-03-05"
- * //assertTrue("dateTime's value ("+dateTime.dateValue()+ //
- * ") should be after java.sql.date's ("+ sqlDate +")",
- * dateTime.dateValue().after(sqlDate));
- *
- * assertTrue("dateTime's value ("+dateTime.dateValue()+
- * ") should be after date's ("+ date +")",
- * dateTime.dateValue().after(date.dateValue()));
+ * This test is a simple test to confirm that date/time before and after checks work as expected.
*/
+
+ DateTime dateTime = sqlDataClass.getDateTime(); // new DateTime(2010, 3, 5, 1, 23);
+ Date date = sqlDataClass.getDate(); // new Date(2010, 3, 5);
+
+ // java.sql.Date sqlDate = sqlDataClass.getSqlDate(); // "2010-03-05"
+ // assertTrue("dateTime's value (" + dateTime.dateValue() + ") should be after java.sql.date's (" + sqlDate +
+ // ")",
+ // dateTime.dateValue().after(sqlDate));
+
+ assertTrue("dateTime's value (" + dateTime.dateValue() + ") should be after date's (" + date + ")", dateTime
+ .dateValue().after(date.dateValue()));
+
}
/**
@@ -323,9 +323,6 @@ public abstract class SqlIntegrationTest
*/
private void testMoney() {
assertEquals(Data.money, sqlDataClass.getMoney());
- // assertTrue("Money " + money.toString() + " is not equal to " +
- // sqlDataClass.getMoney().toString(),
- // money.equals(sqlDataClass.getMoney()));
}
/**
@@ -337,7 +334,8 @@ public abstract class SqlIntegrationTest
LOG.log(Level.INFO, "sqlDataClass.getDateTime() as String:" + sqlDataClass.getDateTime());
LOG.log(Level.INFO, "dateTime.toString() as String:" + Data.dateTime);
- LOG.log(Level.INFO, "sqlDataClass.getDateTime().getTime() as Long:" + sqlDataClass.getDateTime().millisSinceEpoch());
+ LOG.log(Level.INFO, "sqlDataClass.getDateTime().getTime() as Long:"
+ + sqlDataClass.getDateTime().millisSinceEpoch());
LOG.log(Level.INFO, "dateTime.getTime() as Long:" + Data.dateTime.millisSinceEpoch());
if (!Data.dateTime.equals(sqlDataClass.getDateTime())) {
@@ -349,7 +347,9 @@ public abstract class SqlIntegrationTest
* Test {@link TimeStamp} type.
*/
private void testTimeStamp() {
- assertTrue("TimeStamp " + Data.timeStamp.toString() + " is not equal to " + sqlDataClass.getTimeStamp().toString(), Data.timeStamp.isEqualTo(sqlDataClass.getTimeStamp()));
+ assertTrue(
+ "TimeStamp " + sqlDataClass.getTimeStamp().toString() + " does not equal expected "
+ + Data.timeStamp.toString(), Data.timeStamp.isEqualTo(sqlDataClass.getTimeStamp()));
}
/**
@@ -359,7 +359,8 @@ public abstract class SqlIntegrationTest
private void testTime() {
assertNotNull("sqlDataClass is null", sqlDataClass);
assertNotNull("getTime() is null", sqlDataClass.getTime());
- assertTrue("Time 14h56: expected " + Data.time.toString() + ", but got " + sqlDataClass.getTime().toString(), Data.time.isEqualTo(sqlDataClass.getTime()));
+ assertTrue("Time 14h56: expected " + Data.time.toString() + ", but got " + sqlDataClass.getTime().toString(),
+ Data.time.isEqualTo(sqlDataClass.getTime()));
}
/**
@@ -367,9 +368,6 @@ public abstract class SqlIntegrationTest
*/
private void testColor() {
assertEquals(Data.color, sqlDataClass.getColor());
- // assertTrue("Color Black, expected " + color.toString() + " but got "
- // + sqlDataClass.getColor().toString(),
- // color.isEqualTo(sqlDataClass.getColor()));
}
/**
@@ -377,20 +375,15 @@ public abstract class SqlIntegrationTest
*/
// TODO: Images are not equal...
/*
- * public void testImage(){ SqlDataClass sqlDataClass =
- * SqlIntegrationTestSingleton.getPerson(); Image image2 =
+ * public void testImage(){ SqlDataClass sqlDataClass = SqlIntegrationTestSingleton.getPerson(); Image image2 =
* sqlDataClass.getImage(); assertEqual(image, image2); }
*
- * private void assertEqual(Image image2, Image image3) {
- * assertEquals(image2.getHeight(), image3.getHeight());
- * assertEquals(image2.getWidth(), image3.getWidth()); boolean same = true;
- * int i=0,j=0; int p1=0, p2=0; String error = ""; int [][] i1 =
- * image2.getImage(), i2 = image3.getImage(); for(i = 0; same &&
- * i<image2.getHeight();i++){ int [] r1 = i1[i], r2 = i2[i]; for (j = 0;
- * same && j < image2.getWidth(); j++){ if (r1[j] != r2[j]){ same = false;
- * p1 = r1[j]; p2 = r2[j]; error =
- * "Images differ at i = "+i+", j = "+j+", "+p1+ " is not "+p2+"!"; break; }
- * } } assertTrue(error, same); }
+ * private void assertEqual(Image image2, Image image3) { assertEquals(image2.getHeight(), image3.getHeight());
+ * assertEquals(image2.getWidth(), image3.getWidth()); boolean same = true; int i=0,j=0; int p1=0, p2=0; String
+ * error = ""; int [][] i1 = image2.getImage(), i2 = image3.getImage(); for(i = 0; same &&
+ * i<image2.getHeight();i++){ int [] r1 = i1[i], r2 = i2[i]; for (j = 0; same && j < image2.getWidth(); j++){ if
+ * (r1[j] != r2[j]){ same = false; p1 = r1[j]; p2 = r2[j]; error = "Images differ at i = "+i+", j = "+j+", "+p1+
+ * " is not "+p2+"!"; break; } } } assertTrue(error, same); }
*/
/**
@@ -414,7 +407,7 @@ public abstract class SqlIntegrationTest
assertEquals(Data.intMaxValue, pveMax.getIntProperty());
assertEquals(Data.longMaxValue, pveMax.getLongProperty());
assertEquals(Data.doubleMaxValue, pveMax.getDoubleProperty(), 0.00001f); // fails
- // in
+ // in
assertEquals(Data.floatMaxValue, pveMax.getFloatProperty(), 0.00001f);
}
@@ -425,10 +418,10 @@ public abstract class SqlIntegrationTest
assertEquals(Data.intMinValue, pveMin.getIntProperty());
assertEquals(Data.longMinValue, pveMin.getLongProperty());
assertEquals(Data.doubleMinValue, pveMin.getDoubleProperty(), 0.00001f); // fails
- // in
- // MySQL
- // =
- // infinity
+ // in
+ // MySQL
+ // =
+ // infinity
assertEquals(Data.floatMinValue, pveMin.getFloatProperty(), 0.00001f);
}
@@ -436,11 +429,9 @@ public abstract class SqlIntegrationTest
* Test {@link StringCollection} type.
*/
/*
- * public void testStringCollection(){ SqlDataClass sqlDataClass =
- * SqlIntegrationTestSingleton.getPerson(); List<String> collection =
- * sqlDataClass.getStringCollection(); int i = 0; for (String string :
- * collection) { assertEquals(SqlIntegrationTestCommon.stringList.get(i++),
- * string); } }
+ * public void testStringCollection(){ SqlDataClass sqlDataClass = SqlIntegrationTestSingleton.getPerson();
+ * List<String> collection = sqlDataClass.getStringCollection(); int i = 0; for (String string : collection) {
+ * assertEquals(SqlIntegrationTestCommon.stringList.get(i++), string); } }
*/
private void testSingleReferenceLazy() {
@@ -526,7 +517,7 @@ public abstract class SqlIntegrationTest
simpleClass.setText("XXX");
simpleClass.setBooleanValue(false);
simpleClassTwoA.setBooleanValue(false);
-
+
setFixtureInitializationStateIfNot(State.INITIALIZE, "in-memory");
}
@@ -551,13 +542,13 @@ public abstract class SqlIntegrationTest
// simpleClass1.setString(stringList1.get(3));
collection.remove(simpleClass1);
-
+
// REVIEW: I'm very doubtful about this...
// what exactly is meant by updating an internal collection?
- if (!persistenceMechanismIs("xml") ) {
+ if (!persistenceMechanismIs("xml")) {
factory.update(collection);
}
-
+
factory.update(sqlDataClass);
}
@@ -577,7 +568,7 @@ public abstract class SqlIntegrationTest
simpleClassMatch.setSimpleClassTwoA(classTwos.get(0));
final List<SimpleClass> classes = factory.allSimpleClassesThatMatch(simpleClassMatch);
-
+
// TODO: Why is this hack required?
if (!getProperties().getProperty("isis.persistor").equals("in-memory")) {
assertEquals(Data.stringList1.size(), classes.size());
Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/main/resources/log4j.properties
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/main/resources/log4j.properties?rev=1383802&r1=1383801&r2=1383802&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/main/resources/log4j.properties (original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/main/resources/log4j.properties Wed Sep 12 06:31:28 2012
@@ -16,7 +16,7 @@
# under the License.
# apache's log4j is used to provide system logging.
log4j.rootCategory=DEBUG, Console, File
-#log4j.rootCategory=INFO, Console, File
+log4j.rootCategory=INFO, Console
# The console appender
Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/test/java/org/apache/isis/runtimes/dflt/objectstores/sql/HsqlTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/test/java/org/apache/isis/runtimes/dflt/objectstores/sql/HsqlTest.java?rev=1383802&r1=1383801&r2=1383802&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/test/java/org/apache/isis/runtimes/dflt/objectstores/sql/HsqlTest.java (original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/test/java/org/apache/isis/runtimes/dflt/objectstores/sql/HsqlTest.java Wed Sep 12 06:31:28 2012
@@ -26,7 +26,7 @@ public class HsqlTest extends SqlIntegra
@Override
public void resetPersistenceStoreDirectlyIfRequired() {
- Files.deleteFiles("hsql-db", ".xml", Recursion.DONT_RECURSE);
+ Files.deleteFiles("hsql-db", "", Recursion.DONT_RECURSE);
}
@Override