deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject git commit: DELTASPIKE-459 optional global container bootstrapping added
Date Thu, 05 Dec 2013 12:16:21 GMT
Updated Branches:
  refs/heads/master b1cdf8765 -> e1aeb3acb


DELTASPIKE-459 optional global container bootstrapping added


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

Branch: refs/heads/master
Commit: e1aeb3acb640d25a639bc4e3d6de7c111cf0af38
Parents: b1cdf87
Author: gpetracek <gpetracek@apache.org>
Authored: Thu Dec 5 13:10:49 2013 +0100
Committer: gpetracek <gpetracek@apache.org>
Committed: Thu Dec 5 13:16:03 2013 +0100

----------------------------------------------------------------------
 .../testcontrol/api/junit/CdiTestRunner.java    | 14 +++++++--
 .../api/junit/CdiTestSuiteRunner.java           | 32 +++++++++++++++++---
 2 files changed, 39 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/e1aeb3ac/deltaspike/modules/test-control/api/src/main/java/org/apache/deltaspike/testcontrol/api/junit/CdiTestRunner.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/test-control/api/src/main/java/org/apache/deltaspike/testcontrol/api/junit/CdiTestRunner.java
b/deltaspike/modules/test-control/api/src/main/java/org/apache/deltaspike/testcontrol/api/junit/CdiTestRunner.java
index 19698d9..fcd85c8 100644
--- a/deltaspike/modules/test-control/api/src/main/java/org/apache/deltaspike/testcontrol/api/junit/CdiTestRunner.java
+++ b/deltaspike/modules/test-control/api/src/main/java/org/apache/deltaspike/testcontrol/api/junit/CdiTestRunner.java
@@ -400,8 +400,11 @@ public class CdiTestRunner extends BlockJUnit4ClassRunner
 
             if (!isContainerStarted())
             {
-                container.boot();
-                setContainerStarted();
+                if (!CdiTestSuiteRunner.isContainerStarted())
+                {
+                    container.boot();
+                    setContainerStarted();
+                }
             }
 
             List<Class<? extends Annotation>> restrictedScopes = new ArrayList<Class<?
extends Annotation>>();
@@ -428,7 +431,11 @@ public class CdiTestRunner extends BlockJUnit4ClassRunner
 
             if (this.containerStarted)
             {
-                container.shutdown(); //stop the container on the same level which started
it
+                if (CdiTestSuiteRunner.isStopContainerAllowed())
+                {
+                    container.shutdown(); //stop the container on the same level which started
it
+                    CdiTestSuiteRunner.setContainerStarted(false);
+                }
             }
         }
 
@@ -456,6 +463,7 @@ public class CdiTestRunner extends BlockJUnit4ClassRunner
         void setContainerStarted()
         {
             this.containerStarted = true;
+            CdiTestSuiteRunner.setContainerStarted(true);
         }
 
         private void startContexts(CdiContainer container, Class<? extends Annotation>...
restrictedScopes)

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/e1aeb3ac/deltaspike/modules/test-control/api/src/main/java/org/apache/deltaspike/testcontrol/api/junit/CdiTestSuiteRunner.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/test-control/api/src/main/java/org/apache/deltaspike/testcontrol/api/junit/CdiTestSuiteRunner.java
b/deltaspike/modules/test-control/api/src/main/java/org/apache/deltaspike/testcontrol/api/junit/CdiTestSuiteRunner.java
index 1d795c5..7b25a72 100644
--- a/deltaspike/modules/test-control/api/src/main/java/org/apache/deltaspike/testcontrol/api/junit/CdiTestSuiteRunner.java
+++ b/deltaspike/modules/test-control/api/src/main/java/org/apache/deltaspike/testcontrol/api/junit/CdiTestSuiteRunner.java
@@ -20,6 +20,7 @@ package org.apache.deltaspike.testcontrol.api.junit;
 
 import org.apache.deltaspike.cdise.api.CdiContainer;
 import org.apache.deltaspike.cdise.api.CdiContainerLoader;
+import org.apache.deltaspike.core.api.config.ConfigResolver;
 import org.junit.runner.Description;
 import org.junit.runner.Runner;
 import org.junit.runner.notification.Failure;
@@ -36,10 +37,17 @@ import java.util.logging.Logger;
 @SuppressWarnings("UnusedDeclaration")
 public class CdiTestSuiteRunner extends Suite
 {
+    private static final boolean STOP_CONTAINER;
     private static boolean containerStarted; //TODO
 
     private final Class<?> testSuiteClass;
 
+    static
+    {
+        String stopContainerConfigValue = ConfigResolver.getPropertyValue("testcontrol.stop_container",
"true");
+        STOP_CONTAINER = Boolean.parseBoolean(stopContainerConfigValue.trim());
+    }
+
     public CdiTestSuiteRunner(Class<?> klass, RunnerBuilder builder) throws InitializationError
     {
         super(klass, builder);
@@ -75,8 +83,11 @@ public class CdiTestSuiteRunner extends Suite
 
         CdiContainer container = CdiContainerLoader.getCdiContainer();
 
-        container.boot();
-        containerStarted = true;
+        if (!containerStarted)
+        {
+            container.boot();
+            containerStarted = true;
+        }
 
         notifier.addListener(new LogRunListener());
 
@@ -86,8 +97,11 @@ public class CdiTestSuiteRunner extends Suite
         }
         finally
         {
-            container.shutdown();
-            containerStarted = false;
+            if (STOP_CONTAINER)
+            {
+                container.shutdown();
+                containerStarted = false;
+            }
         }
     }
 
@@ -96,6 +110,16 @@ public class CdiTestSuiteRunner extends Suite
         return containerStarted;
     }
 
+    static Boolean isStopContainerAllowed()
+    {
+        return STOP_CONTAINER;
+    }
+
+    static void setContainerStarted(boolean containerStarted)
+    {
+        CdiTestSuiteRunner.containerStarted = containerStarted;
+    }
+
     static class LogRunListener extends RunListener
     {
         private final Logger logger = Logger.getLogger(LogRunListener.class.getName());


Mime
View raw message