tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1405757 - /openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/junit/ApplicationComposer.java
Date Mon, 05 Nov 2012 11:56:08 GMT
Author: rmannibucau
Date: Mon Nov  5 11:56:08 2012
New Revision: 1405757

URL: http://svn.apache.org/viewvc?rev=1405757&view=rev
Log:
setting up the LightweightWebAppBuilder if some webmodule are tested and no webappbuilder
are registered

Modified:
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/junit/ApplicationComposer.java

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/junit/ApplicationComposer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/junit/ApplicationComposer.java?rev=1405757&r1=1405756&r2=1405757&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/junit/ApplicationComposer.java
(original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/junit/ApplicationComposer.java
Mon Nov  5 11:56:08 2012
@@ -24,6 +24,7 @@ import org.apache.openejb.OpenEJBRuntime
 import org.apache.openejb.OpenEjbContainer;
 import org.apache.openejb.assembler.classic.AppInfo;
 import org.apache.openejb.assembler.classic.Assembler;
+import org.apache.openejb.assembler.classic.WebAppBuilder;
 import org.apache.openejb.cdi.ScopeHelper;
 import org.apache.openejb.config.AppModule;
 import org.apache.openejb.config.ConfigurationFactory;
@@ -53,6 +54,7 @@ import org.apache.openejb.loader.SystemI
 import org.apache.openejb.spi.ContainerSystem;
 import org.apache.openejb.util.Join;
 import org.apache.openejb.util.ServiceManagerProxy;
+import org.apache.openejb.web.LightweightWebAppBuilder;
 import org.apache.webbeans.inject.AbstractInjectable;
 import org.apache.webbeans.inject.OWBInjector;
 import org.apache.webbeans.web.lifecycle.test.MockHttpSession;
@@ -290,6 +292,8 @@ public class ApplicationComposer extends
 
             Application application = null;
 
+            int webModulesNb = 0;
+
             // Invoke the @Module producer methods to build out the AppModule
             for (FrameworkMethod method : testClass.getAnnotatedMethods(Module.class)) {
 
@@ -297,6 +301,8 @@ public class ApplicationComposer extends
                 final Classes classesAnnotation = method.getAnnotation(Classes.class);
 
                 if (obj instanceof WebApp) { // will add the ejbmodule too
+                    webModulesNb++;
+
                     final WebApp webapp = (WebApp) obj;
                     String root = webapp.getContextRoot();
                     if (root == null) {
@@ -309,6 +315,8 @@ public class ApplicationComposer extends
                     }
                     DeploymentLoader.addWebModule(webModule, appModule);
                 } else if (obj instanceof WebModule) { // will add the ejbmodule too
+                    webModulesNb++;
+
                     final WebModule webModule = (WebModule) obj;
                     if (classesAnnotation != null) {
                         webModule.setFinder(finderFromClasses(classesAnnotation.value()));
@@ -399,9 +407,13 @@ public class ApplicationComposer extends
                     ejbModule.setBeans(new Beans());
                     appModule.getEjbModules().add(ejbModule);
                 } else if (obj instanceof AppModule) {
-
                     // we can probably go further here
                     final AppModule module = (AppModule) obj;
+
+                    if (module.getWebModules().size() > 0) {
+                        webModulesNb++;
+                    }
+
                     appModule.getEjbModules().addAll(module.getEjbModules());
                     appModule.getPersistenceModules().addAll(module.getPersistenceModules());
                     appModule.getAdditionalLibMbeans().addAll(module.getAdditionalLibMbeans());
@@ -426,6 +438,10 @@ public class ApplicationComposer extends
                 appModule = newModule;
             }
 
+            if (webModulesNb > 0 && SystemInstance.get().getComponent(WebAppBuilder.class)
== null) {
+                SystemInstance.get().setComponent(WebAppBuilder.class, new LightweightWebAppBuilder());
+            }
+
             try {
                 ConfigurationFactory config = new ConfigurationFactory();
                 config.init(SystemInstance.get().getProperties());



Mime
View raw message