You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltaspike.apache.org by st...@apache.org on 2013/08/11 21:14:16 UTC

git commit: DELTASPIKE-402 introduce a way to conditionally skip test based on cdi-container versions

Updated Branches:
  refs/heads/master 170647869 -> ea413ab4a


DELTASPIKE-402 introduce a way to conditionally skip test based on cdi-container versions


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

Branch: refs/heads/master
Commit: ea413ab4a18b4fdeb7e1166ee2e6edbdacf2b49c
Parents: 1706478
Author: Mark Struberg <st...@apache.org>
Authored: Sun Aug 11 21:12:55 2013 +0200
Committer: Mark Struberg <st...@apache.org>
Committed: Sun Aug 11 21:12:55 2013 +0200

----------------------------------------------------------------------
 ...lBeanAsAbstractClassWithInterceptorTest.java | 21 ++++++--
 deltaspike/parent/code/pom.xml                  | 50 +++++++++++++++++
 .../test/utils/CdiContainerUnderTest.java       | 56 ++++++++++++++++++++
 3 files changed, 124 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ea413ab4/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc003/PartialBeanAsAbstractClassWithInterceptorTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc003/PartialBeanAsAbstractClassWithInterceptorTest.java b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc003/PartialBeanAsAbstractClassWithInterceptorTest.java
index 40fadde..eca1799 100644
--- a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc003/PartialBeanAsAbstractClassWithInterceptorTest.java
+++ b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc003/PartialBeanAsAbstractClassWithInterceptorTest.java
@@ -22,6 +22,7 @@ import org.apache.deltaspike.test.category.SeCategory;
 import org.apache.deltaspike.test.core.api.partialbean.shared.CustomInterceptorImpl;
 import org.apache.deltaspike.test.core.api.partialbean.shared.TestPartialBeanBinding;
 import org.apache.deltaspike.test.core.api.partialbean.util.ArchiveUtils;
+import org.apache.deltaspike.test.utils.CdiContainerUnderTest;
 import org.jboss.arquillian.container.test.api.Deployment;
 import org.jboss.arquillian.junit.Arquillian;
 import org.jboss.shrinkwrap.api.ShrinkWrap;
@@ -31,22 +32,33 @@ import org.jboss.shrinkwrap.api.asset.StringAsset;
 import org.jboss.shrinkwrap.api.spec.JavaArchive;
 import org.jboss.shrinkwrap.api.spec.WebArchive;
 import org.junit.Assert;
+import org.junit.Assume;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 import org.junit.runner.RunWith;
 
+import javax.enterprise.inject.Instance;
 import javax.inject.Inject;
 
 @RunWith(Arquillian.class)
 @Category(SeCategory.class) //TODO use different category (only new versions of weld)
 public class PartialBeanAsAbstractClassWithInterceptorTest
 {
+    public static final String CONTAINER_WELD_2_0_0 = "weld-2\\.0\\.0\\..*";
+
+    // we only inject an Instance as the proxy creation for the Bean itself
+    // would trigger a nasty bug in Weld-2.0.0
     @Inject
-    private PartialBean partialBean;
+    private Instance<PartialBean> partialBean;
 
     @Deployment
     public static WebArchive war()
     {
+        if (CdiContainerUnderTest.is(CONTAINER_WELD_2_0_0))
+        {
+            return ShrinkWrap.create(WebArchive.class, "empty.war");
+        }
+
         Asset beansXml = new StringAsset(
             "<beans><interceptors><class>" +
                     CustomInterceptorImpl.class.getName() +
@@ -70,11 +82,14 @@ public class PartialBeanAsAbstractClassWithInterceptorTest
     @Test
     public void testPartialBeanAsAbstractClassWithInterceptor() throws Exception
     {
-        String result = this.partialBean.getResult();
+        // this test is known to not work under weld-2.0.0.Final and weld-2.0.0.SP1
+        Assume.assumeTrue(!CdiContainerUnderTest.is(CONTAINER_WELD_2_0_0));
+
+        String result = this.partialBean.get().getResult();
 
         Assert.assertEquals("partial-test-true", result);
 
-        result = this.partialBean.getManualResult();
+        result = this.partialBean.get().getManualResult();
 
         //"manual-test-true" would be the goal, but it isn't supported (for now)
         Assert.assertEquals("manual-test-false", result);

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ea413ab4/deltaspike/parent/code/pom.xml
----------------------------------------------------------------------
diff --git a/deltaspike/parent/code/pom.xml b/deltaspike/parent/code/pom.xml
index e6a3245..97ecb03 100644
--- a/deltaspike/parent/code/pom.xml
+++ b/deltaspike/parent/code/pom.xml
@@ -71,6 +71,7 @@
                     <configuration>
                         <systemProperties>
                             <org.apache.deltaspike.ProjectStage>UnitTest</org.apache.deltaspike.ProjectStage>
+                            <cdicontainer.version>${cdicontainer.version}</cdicontainer.version>
                         </systemProperties>
                     </configuration>
                 </plugin>
@@ -140,12 +141,20 @@
                 <activeByDefault>true</activeByDefault>
             </activation>
 
+            <properties>
+                <cdicontainer.version>owb-${owb.version}</cdicontainer.version>
+            </properties>
+
             <build>
                 <plugins>
                     <plugin>
                         <groupId>org.apache.maven.plugins</groupId>
                         <artifactId>maven-surefire-plugin</artifactId>
                         <configuration>
+                            <systemProperties>
+                                <cdicontainer.version>${cdicontainer.version}</cdicontainer.version>
+                            </systemProperties>
+
                             <!-- Ignore these groups because they don't work with embedded OWB -->
                             <excludedGroups>
                                 org.apache.deltaspike.test.category.WebProfileCategory,
@@ -202,11 +211,19 @@
             <!-- use this profile to compile and test DeltaSpike with JBoss Weld -->
             <id>Weld</id>
 
+            <properties>
+                <cdicontainer.version>weld-${weld.version}</cdicontainer.version>
+            </properties>
+
+
             <build>
                 <plugins>
                     <plugin>
                         <artifactId>maven-surefire-plugin</artifactId>
                         <configuration>
+                            <systemProperties>
+                                <cdicontainer.version>${cdicontainer.version}</cdicontainer.version>
+                            </systemProperties>
                             <!-- Ignore these groups because they don't work with embedded Weld -->
                             <excludedGroups>
                                 org.apache.deltaspike.test.category.WebProfileCategory,
@@ -312,6 +329,10 @@
             -->
             <id>tomee-build-managed</id>
 
+            <properties>
+                <cdicontainer.version>owb-${owb.version}</cdicontainer.version>
+            </properties>
+
             <dependencies>
                 <dependency>
                     <groupId>org.apache.openejb</groupId>
@@ -345,6 +366,7 @@
                             <systemProperties>
                                 <arquillian.launch>tomee</arquillian.launch>
                                 <org.apache.deltaspike.ProjectStage>UnitTest</org.apache.deltaspike.ProjectStage>
+                                <cdicontainer.version>${cdicontainer.version}</cdicontainer.version>
                             </systemProperties>
 
                             <!-- we just use groups to mark that a test should be executed only
@@ -372,6 +394,9 @@
              *
              -->
             <id>jbossas-managed-7</id>
+            <properties>
+                <cdicontainer.version>weld-${weld.version}</cdicontainer.version>
+            </properties>
 
             <dependencies>
                 <dependency>
@@ -419,6 +444,7 @@
                             <systemProperties>
                                 <arquillian.launch>jbossas-managed-7</arquillian.launch>
                                 <org.apache.deltaspike.ProjectStage>UnitTest</org.apache.deltaspike.ProjectStage>
+                                <cdicontainer.version>${cdicontainer.version}</cdicontainer.version>
                             </systemProperties>
                             <!-- we just use groups to mark that a test should be executed only
                             with specific environments. even though a java-ee6 application server has to be able to run
@@ -446,6 +472,11 @@
              *
              -->
             <id>jbossas-build-managed-7</id>
+
+            <properties>
+                <cdicontainer.version>weld-${weld.version}</cdicontainer.version>
+            </properties>
+
             <dependencies>
                 <dependency>
                     <groupId>javax.enterprise</groupId>
@@ -485,6 +516,7 @@
                                     ${project.build.directory}/jboss-as-${jboss.as.version}
                                 </arquillian.jboss_home>
                                 <org.apache.deltaspike.ProjectStage>UnitTest</org.apache.deltaspike.ProjectStage>
+                                <cdicontainer.version>${cdicontainer.version}</cdicontainer.version>
                             </systemProperties>
                             <!-- we just use groups to mark that a test should be executed only
                             with specific environments. even though a java-ee6 application server has to be able to run
@@ -531,6 +563,11 @@
         <profile>
             <id>jbossas-remote-7</id>
             <!-- AS7 must be started manually for this work correctly - debug hints see arquillian.xml -->
+
+            <properties>
+                <cdicontainer.version>weld-${weld.version}</cdicontainer.version>
+            </properties>
+
             <dependencies>
 
                 <dependency>
@@ -568,6 +605,7 @@
                             <systemProperties>
                                 <arquillian.launch>jbossas-remote-7</arquillian.launch>
                                 <org.apache.deltaspike.ProjectStage>UnitTest</org.apache.deltaspike.ProjectStage>
+                                <cdicontainer.version>${cdicontainer.version}</cdicontainer.version>
                             </systemProperties>
                             <!-- we just use groups to mark that a test should be executed only
                             with specific environments. even though a java-ee6 application server has to be able to run
@@ -586,6 +624,11 @@
 
         <profile>
             <id>glassfish-remote-3.1</id>
+
+            <properties>
+                <cdicontainer.version>weld-${weld.version}</cdicontainer.version>
+            </properties>
+
             <dependencies>
                 <dependency>
                     <groupId>javax.enterprise</groupId>
@@ -628,6 +671,7 @@
                             <systemProperties>
                                 <arquillian.launch>glassfish-remote-3.1</arquillian.launch>
                                 <org.apache.deltaspike.ProjectStage>UnitTest</org.apache.deltaspike.ProjectStage>
+                                <cdicontainer.version>${cdicontainer.version}</cdicontainer.version>
                             </systemProperties>
                             <!-- we just use groups to mark that a test should be executed only
                             with specific environments. even though a java-ee6 application server has to be able to run
@@ -646,6 +690,11 @@
 
         <profile>
             <id>wls-remote-12c</id>
+
+            <properties>
+                <cdicontainer.version>weld-${weld.version}</cdicontainer.version>
+            </properties>
+
             <dependencies>
 
                 <dependency>
@@ -673,6 +722,7 @@
                             <systemProperties>
                                 <arquillian.launch>wls-remote-12c</arquillian.launch>
                                 <org.apache.deltaspike.ProjectStage>UnitTest</org.apache.deltaspike.ProjectStage>
+                                <cdicontainer.version>${cdicontainer.version}</cdicontainer.version>
                             </systemProperties>
                             <systemPropertyVariables>
                                 <WLS_HOME>${env.WLS_HOME}</WLS_HOME>

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ea413ab4/deltaspike/test-utils/src/main/java/org/apache/deltaspike/test/utils/CdiContainerUnderTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/test-utils/src/main/java/org/apache/deltaspike/test/utils/CdiContainerUnderTest.java b/deltaspike/test-utils/src/main/java/org/apache/deltaspike/test/utils/CdiContainerUnderTest.java
new file mode 100644
index 0000000..ddbf711
--- /dev/null
+++ b/deltaspike/test-utils/src/main/java/org/apache/deltaspike/test/utils/CdiContainerUnderTest.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.deltaspike.test.utils;
+
+/**
+ * A small helper class which checks if the container
+ * which is currently being tested matches the given version RegExp
+ */
+public class CdiContainerUnderTest
+{
+    private CdiContainerUnderTest()
+    {
+        // utility class ct
+    }
+
+    /**
+     * Checks whether the current container matches the given version regexps.
+     * @param containerRegExps container versions to test against.
+     *                         e.g. 'owb-1\\.0\\..*' or 'weld-2\\.0\\.0\\..*'
+     */
+    public static boolean is(String... containerRegExps)
+    {
+        String containerVersion = System.getProperty("cdicontainer.version");
+
+        if (containerVersion == null)
+        {
+            return false;
+        }
+
+        for (String containerRe : containerRegExps)
+        {
+            if (containerVersion.matches(containerRe))
+            {
+                return true;
+            }
+        }
+
+        return false;
+    }
+}