tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject [1/2] tomee git commit: making CdiParentBeanTest passing
Date Mon, 16 Mar 2015 21:45:39 GMT
Repository: tomee
Updated Branches:
  refs/heads/master a7a4ff7ec -> 352c0ce58


making CdiParentBeanTest passing


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

Branch: refs/heads/master
Commit: ec0e06686f1a5a9d13a62b68c8b375a8121b32f5
Parents: a7a4ff7
Author: Romain Manni-Bucau <rmannibucau@apache.org>
Authored: Mon Mar 16 22:45:09 2015 +0100
Committer: Romain Manni-Bucau <rmannibucau@apache.org>
Committed: Mon Mar 16 22:45:09 2015 +0100

----------------------------------------------------------------------
 .../arquillian/common/TestClassDiscoverer.java  | 34 +++++++++++++++++---
 .../arquillian/tests/ear/CdiParentBeanTest.java | 18 -----------
 2 files changed, 29 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/ec0e0668/arquillian/arquillian-tomee-common/src/main/java/org/apache/openejb/arquillian/common/TestClassDiscoverer.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-common/src/main/java/org/apache/openejb/arquillian/common/TestClassDiscoverer.java
b/arquillian/arquillian-tomee-common/src/main/java/org/apache/openejb/arquillian/common/TestClassDiscoverer.java
index 5fb3ef8..f8619aa 100644
--- a/arquillian/arquillian-tomee-common/src/main/java/org/apache/openejb/arquillian/common/TestClassDiscoverer.java
+++ b/arquillian/arquillian-tomee-common/src/main/java/org/apache/openejb/arquillian/common/TestClassDiscoverer.java
@@ -64,6 +64,19 @@ public class TestClassDiscoverer implements AdditionalBeanDiscoverer {
                 for (final Class<?> c : classes) {
                     webTestClasses.put(c, web);
                 }
+
+                // in case of an ear if we find the same test class in a webapp we don't
want it in lib part
+                // this case can happen in tomee-embedded mainly
+                final Iterator<Class<?>> c = testClasses.iterator();
+                while (c.hasNext()) {
+                    final String cl = c.next().getName();
+                    for (final Class<?> wc : classes) {
+                        if (cl.equals(wc.getName())) {
+                            c.remove();
+                            break;
+                        }
+                    }
+                }
                 testClasses.addAll(classes);
             }
         }
@@ -96,11 +109,22 @@ public class TestClassDiscoverer implements AdditionalBeanDiscoverer
{
             }
 
             if (name != null) {
-                try {
-                    // call some reflection methods to make it fail if some dep are missing...
-                    testClasses.add(module.getClassLoader().loadClass(name));
-                } catch (final Throwable e) {
-                    // no-op
+                boolean found = false;
+                for (final WebModule web : module.getWebModules()) {
+                    try {
+                        testClasses.add(web.getClassLoader().loadClass(name));
+                        found = true;
+                        break;
+                    } catch (final Throwable e) {
+                        // no-op
+                    }
+                }
+                if (!found) {
+                    try {
+                        testClasses.add(module.getClassLoader().loadClass(name));
+                    } catch (final Throwable e) {
+                        // no-op
+                    }
                 }
             }
         }

http://git-wip-us.apache.org/repos/asf/tomee/blob/ec0e0668/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/ear/CdiParentBeanTest.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/ear/CdiParentBeanTest.java
b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/ear/CdiParentBeanTest.java
index 02c893c..3400e04 100644
--- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/ear/CdiParentBeanTest.java
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/ear/CdiParentBeanTest.java
@@ -30,13 +30,6 @@ import org.jboss.shrinkwrap.api.spec.WebArchive;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
-import javax.inject.Inject;
-import javax.servlet.ServletException;
-import javax.servlet.annotation.WebServlet;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
 import java.net.URL;
 
 import static org.junit.Assert.assertFalse;
@@ -67,15 +60,4 @@ public class CdiParentBeanTest {
         final String slurp = IO.slurp(new URL(url, "/myear/web/classloader"));
         assertFalse(slurp + " should not contain WebappClassLoader", slurp.toLowerCase().contains("webappclassloader"));
     }
-
-    @WebServlet("/classloader")
-    public static class ClassLoaderServlet extends HttpServlet {
-        @Inject
-        private SimpleBean bean;
-
-        @Override
-        protected void service(final HttpServletRequest req, final HttpServletResponse resp)
throws ServletException, IOException {
-            resp.getWriter().print(bean.classloaderAsStr());
-        }
-    }
 }


Mime
View raw message