deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject [2/2] git commit: DELTASPIKE-466 improved external-container handling
Date Sun, 15 Dec 2013 19:46:32 GMT
DELTASPIKE-466 improved external-container handling


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

Branch: refs/heads/master
Commit: 7ec889fe2e6085fc03b96ec491da3a89376dc6c4
Parents: 7f14a66
Author: gpetracek <gpetracek@apache.org>
Authored: Sun Dec 15 20:25:15 2013 +0100
Committer: gpetracek <gpetracek@apache.org>
Committed: Sun Dec 15 20:44:09 2013 +0100

----------------------------------------------------------------------
 .../deltaspike/testcontrol/api/TestControl.java |  1 +
 .../testcontrol/api/junit/CdiTestRunner.java    | 34 ++++++++++++++------
 2 files changed, 25 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/7ec889fe/deltaspike/modules/test-control/api/src/main/java/org/apache/deltaspike/testcontrol/api/TestControl.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/test-control/api/src/main/java/org/apache/deltaspike/testcontrol/api/TestControl.java
b/deltaspike/modules/test-control/api/src/main/java/org/apache/deltaspike/testcontrol/api/TestControl.java
index c492c97..baba3cb 100644
--- a/deltaspike/modules/test-control/api/src/main/java/org/apache/deltaspike/testcontrol/api/TestControl.java
+++ b/deltaspike/modules/test-control/api/src/main/java/org/apache/deltaspike/testcontrol/api/TestControl.java
@@ -55,6 +55,7 @@ public @interface TestControl
 
     /**
      * Requires additional service-loader config
+     * Currently only supported on class-level
      */
     boolean startExternalContainers() default true;
 }

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/7ec889fe/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 9b331a9..af9d560 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
@@ -632,24 +632,38 @@ public class CdiTestRunner extends BlockJUnit4ClassRunner
 
         private void onScopeStarted(Class<? extends Annotation> scopeClass)
         {
-            if (this.externalContainers != null)
+            List<ExternalContainer> externalContainerList = collectExternalContainers(this);
+
+            for (ExternalContainer externalContainer : externalContainerList)
             {
-                for (ExternalContainer externalContainer : this.externalContainers)
-                {
-                    externalContainer.startScope(scopeClass);
-                }
+                externalContainer.startScope(scopeClass);
             }
         }
 
         private void onScopeStopped(Class<? extends Annotation> scopeClass)
         {
-            if (this.externalContainers != null)
+            List<ExternalContainer> externalContainerList = collectExternalContainers(this);
+
+            for (ExternalContainer externalContainer : externalContainerList)
             {
-                for (ExternalContainer externalContainer : this.externalContainers)
-                {
-                    externalContainer.stopScope(scopeClass);
-                }
+                externalContainer.stopScope(scopeClass);
+            }
+        }
+
+        private static List<ExternalContainer> collectExternalContainers(ContainerAwareTestContext
testContext)
+        {
+            List<ExternalContainer> result = new ArrayList<ExternalContainer>();
+
+            if (testContext.externalContainers != null)
+            {
+                result.addAll(testContext.externalContainers);
+            }
+
+            if (testContext.parent != null)
+            {
+                result.addAll(collectExternalContainers(testContext.parent));
             }
+            return result;
         }
     }
 }


Mime
View raw message