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 12:59:18 UTC

git commit: DELTASPIKE-401 change GlobalAlternativeTest to work w Weld and OWB

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


DELTASPIKE-401 change GlobalAlternativeTest to work w Weld and OWB


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

Branch: refs/heads/master
Commit: 170647869b279e735cefa4541d45510071989ac4
Parents: a421be8
Author: Mark Struberg <st...@apache.org>
Authored: Sun Aug 11 12:49:35 2013 +0200
Committer: Mark Struberg <st...@apache.org>
Committed: Sun Aug 11 12:49:35 2013 +0200

----------------------------------------------------------------------
 .../global/GlobalAlternativeTest.java           | 32 +++++++++++++++-----
 1 file changed, 25 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/17064786/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/alternative/global/GlobalAlternativeTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/alternative/global/GlobalAlternativeTest.java b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/alternative/global/GlobalAlternativeTest.java
index 60ca097..044484e 100644
--- a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/alternative/global/GlobalAlternativeTest.java
+++ b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/alternative/global/GlobalAlternativeTest.java
@@ -68,13 +68,31 @@ public class GlobalAlternativeTest
     @Deployment
     public static WebArchive deploy()
     {
-        Asset beansXml = new StringAsset(
-                "<beans><alternatives>" +
-                        "<class>" + BaseInterface1AlternativeImplementation.class.getName() + "</class>" +
-                        "<class>" + SubBaseBean2.class.getName() + "</class>" +
-                        "<class>" + AlternativeBaseBeanB.class.getName() + "</class>" +
-                        "</alternatives></beans>"
-        );
+
+        Asset beansXml = EmptyAsset.INSTANCE;
+
+        try
+        {
+            // if this doesn't throw a ClassNotFoundException, then we have OpenWebBeans on the ClassPath.
+            Class.forName("org.apache.webbeans.spi.ContainerLifecycle");
+
+            // Older OWB versions had an error with @Alternatives pickup from AnnotatedType.
+            // But as OWB has global-alternatives behaviour by default, we can simply add them
+            // via beans.xml. From OWB-1.2.1 on we would not need this anymore, but it's still needed
+            // for 1.0.x, 1.1.x and 1.2.0 series
+            beansXml = new StringAsset(
+                    "<beans><alternatives>" +
+                            "<class>" + BaseInterface1AlternativeImplementation.class.getName() + "</class>" +
+                            "<class>" + SubBaseBean2.class.getName() + "</class>" +
+                            "<class>" + AlternativeBaseBeanB.class.getName() + "</class>" +
+                            "</alternatives></beans>"
+            );
+        }
+        catch (ClassNotFoundException cnfe)
+        {
+            // all fine, no OWB here -> Weld handling
+        }
+
 
         JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, "excludeIntegrationTest.jar")
                 .addPackage(GlobalAlternativeTest.class.getPackage())