incubator-isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ke...@apache.org
Subject svn commit: r1385036 - in /incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql: sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/ sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/auto/ sql-impl/src/ma...
Date Sat, 15 Sep 2012 10:09:11 GMT
Author: kevin
Date: Sat Sep 15 10:09:10 2012
New Revision: 1385036

URL: http://svn.apache.org/viewvc?rev=1385036&view=rev
Log:
ISIS-268: Breaking apart Polymorphism test to address exception in Hudson. Commenting tests
to describes what they are doing and explain test philosophy. Minor code cleanups (unused
imports). 

Modified:
    incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/IdMappingAbstract.java
    incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/auto/AutoMapper.java
    incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/JdbcDateMapper.java
    incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/JdbcObjectReferenceFieldMapping.java
    incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/common/SqlIntegrationTestCommonBase.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/test/java/org/apache/isis/runtimes/dflt/objectstores/sql/HsqlTest.java
    incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/test/java/org/apache/isis/runtimes/dflt/objectstores/sql/PolymorphismTest.java

Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/IdMappingAbstract.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/IdMappingAbstract.java?rev=1385036&r1=1385035&r2=1385036&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/IdMappingAbstract.java
(original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/IdMappingAbstract.java
Sat Sep 15 10:09:10 2012
@@ -27,7 +27,6 @@ import org.apache.isis.core.metamodel.ad
 import org.apache.isis.core.metamodel.adapter.oid.TypedOid;
 import org.apache.isis.core.metamodel.spec.ObjectSpecification;
 import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
-import org.apache.isis.runtimes.dflt.runtime.system.persistence.AdapterManagerSpi;
 import org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceSession;
 
 public class IdMappingAbstract {
@@ -72,7 +71,7 @@ public class IdMappingAbstract {
         if (object == null) {
             sql.append("NULL");
         } else {
-            appendObjectId(connector, sql, (RootOid)object.getOid());
+            appendObjectId(connector, sql, (RootOid) object.getOid());
             // sql.append(connector.addToQueryValues(primaryKeyAsObject(object.getOid())));
         }
     }
@@ -85,23 +84,23 @@ public class IdMappingAbstract {
         final Object object = rs.getObject(column);
         if (object == null) {
             return null;
-        } 
+        }
         final int id = ((Integer) object).intValue();
-        return new RootOidDefault(specification.getSpecId(), ""+id, Oid.State.PERSISTENT);
+        return new RootOidDefault(specification.getSpecId(), "" + id, Oid.State.PERSISTENT);
     }
 
     protected ObjectAdapter getAdapter(final ObjectSpecification spec, final Oid oid) {
         final ObjectAdapter adapter = getAdapterManager().getAdapterFor(oid);
         if (adapter != null) {
             return adapter;
-        } 
-        // REVIEW: where the oid is a TypedOid, the following two lines could be replaced
by getPersistenceSession().recreatePersistentAdapter(oid)
+        }
+        // REVIEW: where the oid is a TypedOid, the following two lines could be replaced
by
+        // getPersistenceSession().recreatePersistentAdapter(oid)
         // is preferable, since then reuses the PojoRecreator impl defined within SqlPersistorInstaller
         final Object recreatedPojo = spec.createObject();
         return getPersistenceSession().mapRecreatedPojo(oid, recreatedPojo);
     }
 
-    
     protected AdapterManager getAdapterManager() {
         return getPersistenceSession().getAdapterManager();
     }

Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/auto/AutoMapper.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/auto/AutoMapper.java?rev=1385036&r1=1385035&r2=1385036&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/auto/AutoMapper.java
(original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/auto/AutoMapper.java
Sat Sep 15 10:09:10 2012
@@ -23,6 +23,8 @@ import java.lang.reflect.Method;
 import java.util.List;
 import java.util.Vector;
 
+import org.apache.log4j.Logger;
+
 import org.apache.isis.applib.Identifier;
 import org.apache.isis.core.commons.debug.DebugBuilder;
 import org.apache.isis.core.commons.debug.DebuggableWithTitle;
@@ -33,7 +35,6 @@ import org.apache.isis.core.metamodel.ad
 import org.apache.isis.core.metamodel.adapter.oid.TypedOid;
 import org.apache.isis.core.metamodel.adapter.util.InvokeUtils;
 import org.apache.isis.core.metamodel.adapter.version.ConcurrencyException;
-import org.apache.isis.core.metamodel.adapter.version.SerialNumberVersion;
 import org.apache.isis.core.metamodel.adapter.version.Version;
 import org.apache.isis.core.metamodel.facets.notpersisted.NotPersistedFacet;
 import org.apache.isis.core.metamodel.spec.ObjectSpecification;
@@ -56,18 +57,17 @@ import org.apache.isis.runtimes.dflt.run
 import org.apache.isis.runtimes.dflt.runtime.persistence.PersistorUtil;
 import org.apache.isis.runtimes.dflt.runtime.persistence.query.PersistenceQueryFindByPattern;
 import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
-import org.apache.log4j.Logger;
 
 public class AutoMapper extends AbstractAutoMapper implements ObjectMapping, DebuggableWithTitle
{
-	
+
     private static final Logger LOG = Logger.getLogger(AutoMapper.class);
     private final IdMapping idMapping;
     private final VersionMapping versionMapping;
     private final TitleMapping titleMapping;
     private final boolean useVersioning;
-    
-    
-    public AutoMapper(final String className, final String parameterBase, final FieldMappingLookup
lookup, final ObjectMappingLookup objectMapperLookup) {
+
+    public AutoMapper(final String className, final String parameterBase, final FieldMappingLookup
lookup,
+        final ObjectMappingLookup objectMapperLookup) {
         super(className, parameterBase, lookup, objectMapperLookup);
         idMapping = lookup.createIdMapping();
         versionMapping = lookup.createVersionMapping();
@@ -170,7 +170,8 @@ public class AutoMapper extends Abstract
     }
 
     @Override
-    public Vector<ObjectAdapter> getInstances(final DatabaseConnector connector, final
ObjectSpecification spec, final PersistenceQueryFindByPattern query) {
+    public Vector<ObjectAdapter> getInstances(final DatabaseConnector connector, final
ObjectSpecification spec,
+        final PersistenceQueryFindByPattern query) {
         final Vector<ObjectAdapter> instances = new Vector<ObjectAdapter>();
 
         final StringBuffer sql = createSelectStatement();
@@ -252,7 +253,8 @@ public class AutoMapper extends Abstract
     }
 
     @Override
-    public Vector<ObjectAdapter> getInstances(final DatabaseConnector connector, final
ObjectSpecification spec, final String title) {
+    public Vector<ObjectAdapter> getInstances(final DatabaseConnector connector, final
ObjectSpecification spec,
+        final String title) {
         final Vector<ObjectAdapter> instances = new Vector<ObjectAdapter>();
 
         final StringBuffer sql = createSelectStatement();
@@ -297,8 +299,7 @@ public class AutoMapper extends Abstract
         sql.append(" from " + table);
         return sql;
     } /*
-       * if (whereClause != null) { sql.append(" WHERE ");
-       * sql.append(whereClause); } else if (whereClause != null) {
+       * if (whereClause != null) { sql.append(" WHERE "); sql.append(whereClause); } else
if (whereClause != null) {
        * sql.append(" WHERE "); idMapping.appendWhereClause(sql, oid); }
        */
 
@@ -315,8 +316,8 @@ public class AutoMapper extends Abstract
                 mapping.initializeField(adapter, rs);
             }
             /*
-             * for (int i = 0; i < oneToManyProperties.length; i++) { /* Need to set
-             * up collection to be a ghost before we access as below
+             * for (int i = 0; i < oneToManyProperties.length; i++) { /* Need to set up
collection to be a ghost before
+             * we access as below
              */
             // CollectionAdapter collection = (CollectionAdapter)
             /*
@@ -336,7 +337,8 @@ public class AutoMapper extends Abstract
         }
     }
 
-    private void loadInstancesToVector(final DatabaseConnector connector, final ObjectSpecification
cls, final String selectStatment, final Vector<ObjectAdapter> instances) {
+    private void loadInstancesToVector(final DatabaseConnector connector, final ObjectSpecification
cls,
+        final String selectStatment, final Vector<ObjectAdapter> instances) {
         LOG.debug("loading instances from SQL " + table);
 
         try {
@@ -354,7 +356,8 @@ public class AutoMapper extends Abstract
         }
     }
 
-    private ObjectAdapter loadMappedObject(final DatabaseConnector connector, final ObjectSpecification
cls, final Results rs) {
+    private ObjectAdapter loadMappedObject(final DatabaseConnector connector, final ObjectSpecification
cls,
+        final Results rs) {
         final Oid oid = idMapping.recreateOid(rs, specification);
         final ObjectAdapter adapter = getAdapter(cls, oid);
 
@@ -387,12 +390,14 @@ public class AutoMapper extends Abstract
             }
         } else {
             rs.close();
-            throw new SqlObjectStoreException("Unable to load data from " + table + " with
id " + object.getOid().enString(getOidMarshaller()));
+            throw new SqlObjectStoreException("Unable to load data from " + table + " with
id "
+                + object.getOid().enString(getOidMarshaller()));
         }
     }
 
     @Override
-    public void resolveCollection(final DatabaseConnector connector, final ObjectAdapter
object, final ObjectAssociation field) {
+    public void resolveCollection(final DatabaseConnector connector, final ObjectAdapter
object,
+        final ObjectAssociation field) {
         if (collectionMappers.length > 0) {
             final DatabaseConnector secondConnector = connector.getConnectionPool().acquire();
             for (final CollectionMapper collectionMapper : collectionMappers) {
@@ -465,11 +470,10 @@ public class AutoMapper extends Abstract
         return false;
     }
 
-
-    ////////////////////////////////////////////////////////////////
+    // //////////////////////////////////////////////////////////////
     // debugging, toString
-    ////////////////////////////////////////////////////////////////
-    
+    // //////////////////////////////////////////////////////////////
+
     @Override
     public void debugData(final DebugBuilder debug) {
         debug.appendln("ID mapping", idMapping);
@@ -489,20 +493,18 @@ public class AutoMapper extends Abstract
         return toString();
     }
 
-    
     @Override
     public String toString() {
-        return "AutoMapper [table=" + table + ",id=" + idMapping + ",noColumns=" + fieldMappingByField.size()
+ ",specification=" + specification.getFullIdentifier() + "]";
+        return "AutoMapper [table=" + table + ",id=" + idMapping + ",noColumns=" + fieldMappingByField.size()
+            + ",specification=" + specification.getFullIdentifier() + "]";
     }
 
-    
-
-    ////////////////////////////////////////////////////////////////
+    // //////////////////////////////////////////////////////////////
     // dependencies (from context)
-    ////////////////////////////////////////////////////////////////
+    // //////////////////////////////////////////////////////////////
 
     protected OidMarshaller getOidMarshaller() {
-		return IsisContext.getOidMarshaller();
-	}
+        return IsisContext.getOidMarshaller();
+    }
 
 }

Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/JdbcDateMapper.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/JdbcDateMapper.java?rev=1385036&r1=1385035&r2=1385036&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/JdbcDateMapper.java
(original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/JdbcDateMapper.java
Sat Sep 15 10:09:10 2012
@@ -33,12 +33,10 @@ import org.apache.isis.runtimes.dflt.obj
 import org.apache.isis.runtimes.dflt.objectstores.sql.Results;
 import org.apache.isis.runtimes.dflt.objectstores.sql.mapping.FieldMapping;
 import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
-import org.apache.isis.runtimes.dflt.runtime.system.persistence.AdapterManagerSpi;
 import org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceSession;
 
 /**
- * Handles reading and writing java.sql.Date and
- * org.apache.isis.applib.value.Date values to and from the data store.
+ * Handles reading and writing java.sql.Date and org.apache.isis.applib.value.Date values
to and from the data store.
  * 
  * 
  * @version $Rev$ $Date$
@@ -71,7 +69,8 @@ public class JdbcDateMapper extends Abst
             final Date asDate = (Date) value.getObject();
             return new LocalDate(asDate.getMillisSinceEpoch());
         } else {
-            throw new IsisApplicationException("Unimplemented JdbcDateMapper instance type:
" + value.getClass().toString());
+            throw new IsisApplicationException("Unimplemented JdbcDateMapper instance type:
"
+                + value.getClass().toString());
         }
     }
 
@@ -102,10 +101,8 @@ public class JdbcDateMapper extends Abst
     protected PersistenceSession getPersistenceSession() {
         return IsisContext.getPersistenceSession();
     }
-    
+
     protected AdapterManager getAdapterManager() {
         return getPersistenceSession().getAdapterManager();
     }
 }
-
-

Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/JdbcObjectReferenceFieldMapping.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/JdbcObjectReferenceFieldMapping.java?rev=1385036&r1=1385035&r2=1385036&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/JdbcObjectReferenceFieldMapping.java
(original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/JdbcObjectReferenceFieldMapping.java
Sat Sep 15 10:09:10 2012
@@ -21,7 +21,6 @@ package org.apache.isis.runtimes.dflt.ob
 
 import org.apache.isis.core.commons.debug.DebugBuilder;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.adapter.oid.Oid;
 import org.apache.isis.core.metamodel.adapter.oid.RootOid;
 import org.apache.isis.core.metamodel.spec.ObjectSpecification;
 import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
@@ -50,9 +49,9 @@ public class JdbcObjectReferenceFieldMap
 
     @Override
     public ObjectAssociation getField() {
-		return field;
-	}
-    
+        return field;
+    }
+
     @Override
     public void appendWhereClause(final DatabaseConnector connector, final StringBuffer sql,
final ObjectAdapter object) {
         final ObjectAdapter fieldValue = field.get(object);

Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/common/SqlIntegrationTestCommonBase.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/SqlIntegrationTestCommonBase.java?rev=1385036&r1=1385035&r2=1385036&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/common/SqlIntegrationTestCommonBase.java
(original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/common/SqlIntegrationTestCommonBase.java
Sat Sep 15 10:09:10 2012
@@ -37,6 +37,13 @@ import org.apache.isis.tck.dom.poly.Refe
 import org.apache.isis.tck.dom.sqlos.SqlDomainObjectRepository;
 import org.apache.isis.tck.dom.sqlos.data.SqlDataClass;
 
+/**
+ * @author Kevin kevin@kmz.co.za
+ * 
+ *         This common test class is used by all sql objectstore tests to manage the Isis
framework.
+ * 
+ * @version $Rev$ $Date$
+ */
 public abstract class SqlIntegrationTestCommonBase {
 
     @Rule
@@ -93,6 +100,11 @@ public abstract class SqlIntegrationTest
     public void resetPersistenceStoreDirectlyIfRequired() {
     }
 
+    protected void testSetup() {
+        resetPersistenceStoreDirectlyIfRequired();
+        getSqlIntegrationTestFixtures().setState(State.INITIALIZE);
+    }
+
     // //////////////////////////////////////////////////////////////////////////////
     // before, after
     // //////////////////////////////////////////////////////////////////////////////

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=1385036&r1=1385035&r2=1385036&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
Sat Sep 15 10:09:10 2012
@@ -49,8 +49,15 @@ import org.apache.isis.tck.dom.sqlos.dat
 /**
  * @author Kevin kevin@kmz.co.za
  * 
+ *         This common class is used by the datatype tests (values, objects, collections)
to ensure proper creation and
+ *         reloading of domain objects.
+ * 
+ *         There are two "tests", with the framework re-initialised each time (to flush any
objectstore memory of any
+ *         created domain objects).
+ * 
  *         The Singleton class {@link SqlIntegrationTestFixtures} is used to preserve values
between tests.
  * 
+ * @version $Rev$ $Date$
  */
 public abstract class SqlIntegrationTestData extends SqlIntegrationTestCommonBase {
 
@@ -66,15 +73,34 @@ public abstract class SqlIntegrationTest
     private static PrimitiveValuedEntity pve2;
 
     @Test
+    /**
+     * Uses factory methods within the Isis framework to create the test data,
+     * thus exercising the "create data" portion of the object store.
+     * 
+     * The Isis framework will be again be re-created in the next test unless the 
+     * object store is "in-memory" (this is required since "in-memory" has to be
+     * left alone for created data to still be present in the next test).
+     */
     public void testSetupStore() throws Exception {
         testSetup();
         setUpFactory();
-
         testCreate();
     }
 
     @Test
-    public void testAll() throws Exception {
+    /**
+     * The actual "tests". Unless the test is using the "in-memory" object store 
+     * the Isis framework is re-created, thus ensuring that no domain objects are
+     * left over from the previous "create" step, forcing the objects to be created
+     * via the object store.
+     * 
+     * Exercises the "restore data" portion of the object store.
+     * 
+     * Confirms that values and objects (single and collections) are loaded as expected.
+     * Especially, it confirms that dates, times, etc, do not suffer from differences in
+     * time zones between the database and the Isis framework.
+     */
+    public void testTestAll() throws Exception {
         testLoad();
 
         setUpFactory();
@@ -90,7 +116,6 @@ public abstract class SqlIntegrationTest
         testStandardValueTypesMaxima();
         testStandardValueTypesMinima();
 
-        // broken it...
         testSingleReferenceLazy();
         testSimpleClassTwoReferenceLazy();
 
@@ -110,18 +135,8 @@ public abstract class SqlIntegrationTest
         testSqlDate();
         testTime();
         testTimeStamp();
-
         testDateTimezoneIssue();
-
         testDateTime();
-
-        // reinitializeFixtures();
-
-    }
-
-    protected void testSetup() {
-        resetPersistenceStoreDirectlyIfRequired();
-        getSqlIntegrationTestFixtures().setState(State.INITIALIZE);
     }
 
     protected void testCreate() throws Exception {

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=1385036&r1=1385035&r2=1385036&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
Sat Sep 15 10:09:10 2012
@@ -23,6 +23,15 @@ import org.apache.isis.core.testsupport.
 import org.apache.isis.runtimes.dflt.objectstores.sql.common.Data;
 import org.apache.isis.runtimes.dflt.objectstores.sql.common.SqlIntegrationTestData;
 
+/**
+ * @author Kevin kevin@kmz.co.za
+ * 
+ *         This test implementation uses the HyperSQL database engine to perform "serverless"
tests of data creation and
+ *         reloading.
+ * 
+ * 
+ * @version $Rev$ $Date$
+ */
 public class HsqlTest extends SqlIntegrationTestData {
 
     @Override

Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/test/java/org/apache/isis/runtimes/dflt/objectstores/sql/PolymorphismTest.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/PolymorphismTest.java?rev=1385036&r1=1385035&r2=1385036&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/test/java/org/apache/isis/runtimes/dflt/objectstores/sql/PolymorphismTest.java
(original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/test/java/org/apache/isis/runtimes/dflt/objectstores/sql/PolymorphismTest.java
Sat Sep 15 10:09:10 2012
@@ -44,11 +44,23 @@ import org.apache.isis.tck.dom.poly.Stri
 import org.apache.isis.tck.dom.poly.StringableEntityWithOwnProperties;
 import org.apache.isis.tck.dom.poly.StringableEntityWithOwnProperty;
 
-public class PolymorphismTest extends SqlIntegrationTestCommonBase {
+/**
+ * @author Kevin kevin@kmz.co.za
+ * 
+ *         This test implementation uses the HyperSQL database engine to perform "serverless"
tests of polymorphic class
+ *         object creation and reloading.
+ * 
+ *         The sql object store thus allows your domain objects to have properties referenced
via interface or
+ *         superclass. Both single reference properties and property collections are supported.
+ * 
+ * 
+ * @version $Rev$ $Date$
+ */
 
-    private static final String IMPL_B_STRING = "Impl B String";
+public class PolymorphismTest extends SqlIntegrationTestCommonBase {
 
     private static final String IMPL_A_STRING = "Impl A String";
+    private static final String IMPL_B_STRING = "Impl B String";
     private static final String CHILD_1 = "Child 1";
 
     private static StringableEntityWithOwnProperty polyIntImpA;
@@ -69,50 +81,38 @@ public class PolymorphismTest extends Sq
         return "SHUTDOWN;";
     }
 
+    // Order is important. The next three "tests" must be executed in the correct sequential
order.
     @Test
-    public void testSetupStore() throws Exception {
-        setupFixtures();
-
-        setUpFactory();
-
-        create();
+    /**
+     * Sets up the database connection and tells the test framework to create an instance
of the 
+     * Isis framework for the next "test".
+     */
+    public void test1SetupStoreAndDatabaseConnection() throws Exception {
+        testSetup();
     }
 
     @Test
-    public void testAll() throws Exception {
-        load();
-
-        setUpFactory();
-
-        polymorphicLoad();
-        interfaceLoad();
-        loadSelfReferencingCollection();
-        interfaceLoadProperty();
-        interfaceLoadCollection();
-        interfaceEditSave();
-        interfaceEditLoad();
-        allInterfacesInstancesLoaded();
-        interfacesLoadedByQuery();
-        interfacesLoadedByQuerySpecial();
-        findByMatchPartialEntity();
-        cannotFindByMatchWithWrongValue();
-        reinitializeFixtures();
-    }
-
-    private void setupFixtures() {
-        resetPersistenceStoreDirectlyIfRequired();
-        setFixtureInitializationState(State.INITIALIZE);
-    }
-
-    private void create() throws Exception {
-        getSqlIntegrationTestFixtures().dropTable("ISIS_SELFREFERENCINGENTITY");
-        getSqlIntegrationTestFixtures().dropTable("ISIS_STRINGABLEENTITYWITHOWNPROPERTY");
-        getSqlIntegrationTestFixtures().dropTable("ISIS_STRINGBASEENTITYSUB");
-        getSqlIntegrationTestFixtures().dropTable("ISIS_STRINGBASEENTITYSUBTWO");
-        getSqlIntegrationTestFixtures().dropTable("ISIS_STRINGBASEENTITYSUBTHREE");
-        getSqlIntegrationTestFixtures().dropTable("ISIS_REFERENCINGPOLYTYPESENTITY");
-        getSqlIntegrationTestFixtures().dropTable("ISIS_STRINGBASEENTITY");
-        getSqlIntegrationTestFixtures().dropTable("ISIS_STRINGABLE");
+    /**
+     * Uses the database connection to drop database tables related to these tests.
+     * This forces (and exercises the ability of) the object store to re-create the tables.
+     *  
+     * Also uses factory methods within the Isis framework to create the test data,
+     * thus exercising the "create data" portion of the object store.
+     * 
+     * The Isis framework will be again be re-created in the next test unless the 
+     * object store is "in-memory" (this is required since "in-memory" has to be
+     * left alone for created data to still be present in the next test).
+     */
+    public void test2SetupDataWithDatabaseConnection() throws Exception {
+        final SqlIntegrationTestFixtures sqlIntegrationTestFixtures = getSqlIntegrationTestFixtures();
+        sqlIntegrationTestFixtures.dropTable("ISIS_SELFREFERENCINGENTITY");
+        sqlIntegrationTestFixtures.dropTable("ISIS_STRINGABLEENTITYWITHOWNPROPERTY");
+        sqlIntegrationTestFixtures.dropTable("ISIS_STRINGBASEENTITYSUB");
+        sqlIntegrationTestFixtures.dropTable("ISIS_STRINGBASEENTITYSUBTWO");
+        sqlIntegrationTestFixtures.dropTable("ISIS_STRINGBASEENTITYSUBTHREE");
+        sqlIntegrationTestFixtures.dropTable("ISIS_REFERENCINGPOLYTYPESENTITY");
+        sqlIntegrationTestFixtures.dropTable("ISIS_STRINGBASEENTITY");
+        sqlIntegrationTestFixtures.dropTable("ISIS_STRINGABLE");
 
         final ReferencingPolyTypesEntity referencingPolyTypesEntity = factory.newPolyTestClass();
         referencingPolyTypesEntity.setString("polyTestClassString");
@@ -178,6 +178,37 @@ public class PolymorphismTest extends Sq
         setFixtureInitializationState(State.DONT_INITIALIZE, "in-memory");
     }
 
+    @Test
+    /**
+     * The actual "tests". Unless the test is using the "in-memory" object store 
+     * the Isis framework is re-created, thus ensuring that no domain objects are
+     * left over from the previous "create" step, forcing the objects to be created
+     * via the object store.
+     * 
+     * Exercises the "restore data" portion of the object store.
+     * 
+     * Confirms that polymorphic classes are loaded as expected (via interface, 
+     * via super-class, etc.)
+     */
+    public void test3All() throws Exception {
+        load();
+
+        setUpFactory();
+
+        polymorphicLoad();
+        interfaceLoad();
+        loadSelfReferencingCollection();
+        interfaceLoadProperty();
+        interfaceLoadCollection();
+        interfaceEditSave();
+        interfaceEditLoad();
+        allInterfacesInstancesLoaded();
+        interfacesLoadedByQuery();
+        interfacesLoadedByQuerySpecial();
+        findByMatchPartialEntity();
+        cannotFindByMatchWithWrongValue();
+    }
+
     private void load() {
         final List<ReferencingPolyTypesEntity> dataClasses = factory.allPolyTestClasses();
         assertEquals(1, dataClasses.size());
@@ -310,10 +341,4 @@ public class PolymorphismTest extends Sq
         final List<Empty> matches = factory.allEmptyInterfacesThatMatch(match);
         assertEquals(0, matches.size());
     }
-
-    private void reinitializeFixtures() {
-        setFixtureInitializationState(State.INITIALIZE);
-        SqlIntegrationTestFixtures.recreate();
-    }
-
 }



Mime
View raw message