You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2016/06/12 10:19:58 UTC

[1/2] isis git commit: ISIS-1427: reinstating IsisSystemForTest#setUpSystem to avoid too many unnecessary breakages.

Repository: isis
Updated Branches:
  refs/heads/ISIS-1427 95c3ecc11 -> b6b1bca60


ISIS-1427: reinstating IsisSystemForTest#setUpSystem to avoid too many unnecessary breakages.


Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/c88f44ff
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/c88f44ff
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/c88f44ff

Branch: refs/heads/ISIS-1427
Commit: c88f44ffd33c7c38917969a198b26c02224be13f
Parents: 95c3ecc
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Fri Jun 10 17:42:16 2016 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Fri Jun 10 17:42:16 2016 +0100

----------------------------------------------------------------------
 .../org/apache/isis/core/integtestsupport/IsisSystemForTest.java | 4 ++++
 1 file changed, 4 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/isis/blob/c88f44ff/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/IsisSystemForTest.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/IsisSystemForTest.java b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/IsisSystemForTest.java
index 6df861a..b6a677e 100644
--- a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/IsisSystemForTest.java
+++ b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/IsisSystemForTest.java
@@ -269,6 +269,10 @@ public class IsisSystemForTest implements org.junit.rules.TestRule, DomainServic
     // populated at #setupSystem
     private IsisComponentProvider componentProvider;
 
+    public IsisSystemForTest setUpSystem() throws RuntimeException {
+        return initIfRequiredThenOpenSession();
+    }
+
     /**
      * Intended to be called from a test's {@link Before} method.
      */


[2/2] isis git commit: ISIS-1427: minor refactoring of IsisConfigurationForJdoIntegTests to allow reuse within custom AppManifests in integration tests

Posted by da...@apache.org.
ISIS-1427: minor refactoring of IsisConfigurationForJdoIntegTests to allow reuse within custom AppManifests in integration tests


Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/b6b1bca6
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/b6b1bca6
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/b6b1bca6

Branch: refs/heads/ISIS-1427
Commit: b6b1bca602c1cd9baf51fc74d7477907ac77d4e1
Parents: c88f44f
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Sun Jun 12 11:19:49 2016 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Sun Jun 12 11:19:49 2016 +0100

----------------------------------------------------------------------
 .../integtestsupport/IsisSystemForTest.java     | 12 +--
 .../IsisConfigurationForJdoIntegTests.java      | 79 ++++++++++++++------
 .../bootstrap/DomainAppSystemInitializer.java   | 18 ++++-
 3 files changed, 74 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/isis/blob/b6b1bca6/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/IsisSystemForTest.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/IsisSystemForTest.java b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/IsisSystemForTest.java
index b6a677e..4aab64a 100644
--- a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/IsisSystemForTest.java
+++ b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/IsisSystemForTest.java
@@ -269,14 +269,10 @@ public class IsisSystemForTest implements org.junit.rules.TestRule, DomainServic
     // populated at #setupSystem
     private IsisComponentProvider componentProvider;
 
-    public IsisSystemForTest setUpSystem() throws RuntimeException {
-        return initIfRequiredThenOpenSession();
-    }
-
     /**
      * Intended to be called from a test's {@link Before} method.
      */
-    public IsisSystemForTest initIfRequiredThenOpenSession() throws RuntimeException {
+    public IsisSystemForTest setUpSystem() throws RuntimeException {
         try {
             initIfRequiredThenOpenSession(FireListeners.FIRE);
         } catch (Exception e) {
@@ -354,14 +350,14 @@ public class IsisSystemForTest implements org.junit.rules.TestRule, DomainServic
     private IsisSessionFactory isisSessionFactory;
 
     /**
-     * The {@link IsisSessionFactory} created during {@link #initIfRequiredThenOpenSession()}.
+     * The {@link IsisSessionFactory} created during {@link #setUpSystem()}.
      */
     public IsisSessionFactory getIsisSessionFactory() {
         return isisSessionFactory;
     }
 
     /**
-     * The {@link AuthenticationSession} created during {@link #initIfRequiredThenOpenSession()}.
+     * The {@link AuthenticationSession} created during {@link #setUpSystem()}.
      */
     public AuthenticationSession getAuthenticationSession() {
         return authenticationSession;
@@ -470,7 +466,7 @@ public class IsisSystemForTest implements org.junit.rules.TestRule, DomainServic
         return new Statement() {
             @Override
             public void evaluate() throws Throwable {
-                initIfRequiredThenOpenSession();
+                setUpSystem();
                 try {
                     base.evaluate();
                     closeSession();

http://git-wip-us.apache.org/repos/asf/isis/blob/b6b1bca6/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/IsisConfigurationForJdoIntegTests.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/IsisConfigurationForJdoIntegTests.java b/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/IsisConfigurationForJdoIntegTests.java
index 38e478d..ab8224f 100644
--- a/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/IsisConfigurationForJdoIntegTests.java
+++ b/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/IsisConfigurationForJdoIntegTests.java
@@ -21,6 +21,7 @@ package org.apache.isis.objectstore.jdo.datanucleus;
 
 import com.google.common.base.Joiner;
 
+import com.google.common.collect.Maps;
 import org.datanucleus.PropertyNames;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -34,6 +35,9 @@ import org.apache.isis.core.runtime.persistence.PersistenceConstants;
 import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
 import org.apache.isis.objectstore.jdo.service.RegisterEntities;
 
+import java.util.Map;
+import java.util.Properties;
+
 /**
  * If instantiated by the integration testing framework, this object will be registered as the implementation of
  * the {@link ConfigurationServiceInternal} (internal) domain service, using
@@ -70,31 +74,15 @@ public class IsisConfigurationForJdoIntegTests extends IsisConfigurationDefault
     }
 
     private void addStandardProperties() {
+        final Map<String, String> map = Maps.newHashMap();
+        withStandardProperties(map);
+        add(asProperties(map), ContainsPolicy.IGNORE);
+    }
 
-        // run-in memory
-        addDataNucleusProperty("javax.jdo.option.ConnectionURL", "jdbc:hsqldb:mem:test");
-        addDataNucleusProperty("javax.jdo.option.ConnectionDriverName", "org.hsqldb.jdbcDriver");
-        addDataNucleusProperty("javax.jdo.option.ConnectionUserName", "sa");
-        addDataNucleusProperty("javax.jdo.option.ConnectionPassword", "");
-
-        // Don't do validations that consume setup time.
-        addDataNucleusProperty(PropertyNames.PROPERTY_SCHEMA_AUTOCREATE_ALL, "true");
-        addDataNucleusProperty(PropertyNames.PROPERTY_SCHEMA_VALIDATE_ALL, "false");
-
-        // other properties as per WEB-INF/persistor_datanucleus.properties
-        addDataNucleusProperty("datanucleus.persistenceByReachabilityAtCommit", "false");
-        addDataNucleusProperty("datanucleus.identifier.case", "MixedCase");
-        addDataNucleusProperty("datanucleus.cache.level2.type","none");
-        addDataNucleusProperty("datanucleus.cache.level2.mode","ENABLE_SELECTIVE");
-
-        // automatically install any fixtures that might have been registered
-        add(PersistenceSession.INSTALL_FIXTURES_KEY , "true");
-
-        add(PersistenceConstants.ENFORCE_SAFE_SEMANTICS, ""+PersistenceConstants.ENFORCE_SAFE_SEMANTICS_DEFAULT);
-
-        add("isis.deploymentType", "server_prototype");
-
-        add("isis.services.eventbus.allowLateRegistration", "true");
+    private static Properties asProperties(Map<String, String> map) {
+        Properties properties = new Properties();
+        properties.putAll(map);
+        return properties;
     }
 
     @Programmatic
@@ -132,4 +120,47 @@ public class IsisConfigurationForJdoIntegTests extends IsisConfigurationDefault
     }
 
 
+    private static void withStandardProperties(Map<String, String> map) {
+        withJavaxJdoRunInMemoryProperties(map);
+        withDatanucleusProperties(map);
+        withIsisIntegTestProperties(map);
+    }
+
+    public static Map<String,String> withJavaxJdoRunInMemoryProperties(final Map<String, String> map) {
+
+        map.put(PersistenceSession.DATANUCLEUS_PROPERTIES_ROOT + "javax.jdo.option.ConnectionURL", "jdbc:hsqldb:mem:test");
+        map.put(PersistenceSession.DATANUCLEUS_PROPERTIES_ROOT + "javax.jdo.option.ConnectionDriverName", "org.hsqldb.jdbcDriver");
+        map.put(PersistenceSession.DATANUCLEUS_PROPERTIES_ROOT + "javax.jdo.option.ConnectionUserName", "sa");
+        map.put(PersistenceSession.DATANUCLEUS_PROPERTIES_ROOT + "javax.jdo.option.ConnectionPassword", "");
+
+        return map;
+    }
+
+    public static Map<String,String> withDatanucleusProperties(final Map<String, String> map) {
+
+        // Don't do validations that consume setup time.
+        map.put(PersistenceSession.DATANUCLEUS_PROPERTIES_ROOT + PropertyNames.PROPERTY_SCHEMA_AUTOCREATE_ALL, "true");
+        map.put(PersistenceSession.DATANUCLEUS_PROPERTIES_ROOT + PropertyNames.PROPERTY_SCHEMA_VALIDATE_ALL, "false");
+
+        // other properties as per WEB-INF/persistor_datanucleus.properties
+        map.put(PersistenceSession.DATANUCLEUS_PROPERTIES_ROOT + "datanucleus.persistenceByReachabilityAtCommit", "false");
+        map.put(PersistenceSession.DATANUCLEUS_PROPERTIES_ROOT + "datanucleus.identifier.case", "MixedCase");
+        map.put(PersistenceSession.DATANUCLEUS_PROPERTIES_ROOT + "datanucleus.cache.level2.type","none");
+        map.put(PersistenceSession.DATANUCLEUS_PROPERTIES_ROOT + "datanucleus.cache.level2.mode","ENABLE_SELECTIVE");
+
+        return map;
+    }
+
+    public static Map<String,String> withIsisIntegTestProperties(final Map<String, String> map) {
+
+        // automatically install any fixtures that might have been registered
+        map.put(PersistenceSession.INSTALL_FIXTURES_KEY , "true");
+        map.put(PersistenceConstants.ENFORCE_SAFE_SEMANTICS, ""+PersistenceConstants.ENFORCE_SAFE_SEMANTICS_DEFAULT);
+        map.put("isis.deploymentType", "server_prototype");
+        map.put("isis.services.eventbus.allowLateRegistration", "true");
+
+        return map;
+    }
+
+
 }

http://git-wip-us.apache.org/repos/asf/isis/blob/b6b1bca6/example/application/simpleapp/integtests/src/test/java/domainapp/integtests/bootstrap/DomainAppSystemInitializer.java
----------------------------------------------------------------------
diff --git a/example/application/simpleapp/integtests/src/test/java/domainapp/integtests/bootstrap/DomainAppSystemInitializer.java b/example/application/simpleapp/integtests/src/test/java/domainapp/integtests/bootstrap/DomainAppSystemInitializer.java
index dec906b..474c12d 100644
--- a/example/application/simpleapp/integtests/src/test/java/domainapp/integtests/bootstrap/DomainAppSystemInitializer.java
+++ b/example/application/simpleapp/integtests/src/test/java/domainapp/integtests/bootstrap/DomainAppSystemInitializer.java
@@ -18,11 +18,15 @@
  */
 package domainapp.integtests.bootstrap;
 
+import com.google.common.collect.Maps;
 import org.apache.isis.core.integtestsupport.IsisSystemForTest;
 import org.apache.isis.objectstore.jdo.datanucleus.IsisConfigurationForJdoIntegTests;
 
 import domainapp.app.DomainAppAppManifest;
 
+import java.util.HashMap;
+import java.util.Map;
+
 public class DomainAppSystemInitializer {
 
     public static void initIsft() {
@@ -30,10 +34,18 @@ public class DomainAppSystemInitializer {
         if(isft == null) {
             isft = new IsisSystemForTest.Builder()
                     .withLoggingAt(org.apache.log4j.Level.INFO)
-                    .with(new DomainAppAppManifest())
-                    .with(new IsisConfigurationForJdoIntegTests())
+                    .with(new DomainAppAppManifest() {
+                        @Override
+                        public Map<String, String> getConfigurationProperties() {
+                            final Map<String, String> map = Maps.newHashMap();
+                            IsisConfigurationForJdoIntegTests.withJavaxJdoRunInMemoryProperties(map);
+                            IsisConfigurationForJdoIntegTests.withDatanucleusProperties(map);
+                            IsisConfigurationForJdoIntegTests.withIsisIntegTestProperties(map);
+                            return map;
+                        }
+                    })
                     .build();
-            isft.initIfRequiredThenOpenSession();
+            isft.setUpSystem();
             IsisSystemForTest.set(isft);
         }
     }