geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r516297 - in /geronimo/server/trunk/modules/geronimo-jetty6-builder/src: main/java/org/apache/geronimo/jetty6/deployment/JettyModuleBuilder.java test/java/org/apache/geronimo/jetty6/deployment/PlanParsingTest.java
Date Fri, 09 Mar 2007 04:41:57 GMT
Author: djencks
Date: Thu Mar  8 20:41:56 2007
New Revision: 516297

URL: http://svn.apache.org/viewvc?view=rev&rev=516297
Log:
port rev 514224 to jetty

Modified:
    geronimo/server/trunk/modules/geronimo-jetty6-builder/src/main/java/org/apache/geronimo/jetty6/deployment/JettyModuleBuilder.java
    geronimo/server/trunk/modules/geronimo-jetty6-builder/src/test/java/org/apache/geronimo/jetty6/deployment/PlanParsingTest.java

Modified: geronimo/server/trunk/modules/geronimo-jetty6-builder/src/main/java/org/apache/geronimo/jetty6/deployment/JettyModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty6-builder/src/main/java/org/apache/geronimo/jetty6/deployment/JettyModuleBuilder.java?view=diff&rev=516297&r1=516296&r2=516297
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty6-builder/src/main/java/org/apache/geronimo/jetty6/deployment/JettyModuleBuilder.java
(original)
+++ geronimo/server/trunk/modules/geronimo-jetty6-builder/src/main/java/org/apache/geronimo/jetty6/deployment/JettyModuleBuilder.java
Thu Mar  8 20:41:56 2007
@@ -37,7 +37,9 @@
 import java.util.Map;
 import java.util.Set;
 import java.util.TreeSet;
+import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.jar.JarFile;
+import static java.lang.Boolean.*;
 
 import javax.management.ObjectName;
 import javax.servlet.Servlet;
@@ -57,16 +59,16 @@
 import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
-import org.apache.geronimo.j2ee.deployment.annotation.AnnotatedWebApp;
+import org.apache.geronimo.j2ee.annotation.Holder;
 import org.apache.geronimo.j2ee.deployment.EARContext;
 import org.apache.geronimo.j2ee.deployment.Module;
 import org.apache.geronimo.j2ee.deployment.ModuleBuilder;
+import org.apache.geronimo.j2ee.deployment.ModuleBuilderExtension;
 import org.apache.geronimo.j2ee.deployment.NamingBuilder;
 import org.apache.geronimo.j2ee.deployment.WebModule;
 import org.apache.geronimo.j2ee.deployment.WebServiceBuilder;
-import org.apache.geronimo.j2ee.deployment.ModuleBuilderExtension;
+import org.apache.geronimo.j2ee.deployment.annotation.AnnotatedWebApp;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
-import org.apache.geronimo.j2ee.annotation.Holder;
 import org.apache.geronimo.jetty6.Host;
 import org.apache.geronimo.jetty6.JettyDefaultServletHolder;
 import org.apache.geronimo.jetty6.JettyFilterHolder;
@@ -181,9 +183,9 @@
     }
 
     protected Module createModule(Object plan, JarFile moduleFile, String targetPath, URL
specDDUrl, boolean standAlone, String contextRoot, AbstractName earName, Naming naming, ModuleIDBuilder
idBuilder) throws DeploymentException {
-        assert moduleFile != null: "moduleFile is null";
-        assert targetPath != null: "targetPath is null";
-        assert !targetPath.endsWith("/"): "targetPath must not end with a '/'";
+        assert moduleFile != null : "moduleFile is null";
+        assert targetPath != null : "targetPath is null";
+        assert !targetPath.endsWith("/") : "targetPath must not end with a '/'";
 
         // parse the spec dd
         String specDD = null;
@@ -208,7 +210,7 @@
             // value such as C:\geronimo-1.1\var\temp\geronimo-deploymentUtil22826.tmpdir
             throw new DeploymentException("Error parsing web.xml for " + targetPath, e);
         } catch (Exception e) {
-            if(!moduleFile.getName().endsWith(".war")) {
+            if (!moduleFile.getName().endsWith(".war")) {
                 //not for us
                 return null;
             }
@@ -218,15 +220,14 @@
         if (webApp == null) {
             webApp = WebAppType.Factory.newInstance();
         }
-        
+
         // parse vendor dd
-        JettyWebAppType jettyWebApp = getJettyWebApp(plan, moduleFile, standAlone, targetPath,
webApp);
-        if (contextRoot == null || contextRoot.trim().equals("")) {
-            if (jettyWebApp.isSetContextRoot()) {
-                contextRoot = jettyWebApp.getContextRoot();
-            } else {
-                contextRoot = determineDefaultContextRoot(webApp, standAlone, moduleFile,
targetPath);
-            }
+        AtomicBoolean isDefault = new AtomicBoolean(false);
+        JettyWebAppType jettyWebApp = getJettyWebApp(plan, moduleFile, standAlone, targetPath,
webApp, isDefault);
+        if (jettyWebApp.isSetContextRoot() && !isDefault.get()) {
+            contextRoot = jettyWebApp.getContextRoot();
+        } else if (contextRoot == null || contextRoot.trim().equals("")) {
+            contextRoot = determineDefaultContextRoot(webApp, standAlone, moduleFile, targetPath);
         }
 
         contextRoot = contextRoot.trim();
@@ -234,8 +235,8 @@
         EnvironmentType environmentType = jettyWebApp.getEnvironment();
         Environment environment = EnvironmentBuilder.buildEnvironment(environmentType, defaultEnvironment);
 
-        Boolean distributable = webApp.getDistributableArray().length == 1 ? Boolean.TRUE
: Boolean.FALSE;
-        if (Boolean.TRUE == distributable) {
+        Boolean distributable = webApp.getDistributableArray().length == 1 ? TRUE : FALSE;
+        if (TRUE == distributable) {
             clusteringBuilders.buildEnvironment(jettyWebApp, environment);
         }
 
@@ -259,13 +260,13 @@
 
         WebModule module = new WebModule(standAlone, moduleName, environment, moduleFile,
targetPath, webApp, jettyWebApp, specDD, contextRoot, new HashMap(), JETTY_NAMESPACE, annotatedWebApp);
 
-        for (ModuleBuilderExtension mbe: moduleBuilderExtensions) {
+        for (ModuleBuilderExtension mbe : moduleBuilderExtensions) {
             mbe.createModule(module, plan, moduleFile, targetPath, specDDUrl, environment,
contextRoot, earName, naming, idBuilder);
         }
         return module;
     }
 
-    JettyWebAppType getJettyWebApp(Object plan, JarFile moduleFile, boolean standAlone, String
targetPath, WebAppType webApp) throws DeploymentException {
+    JettyWebAppType getJettyWebApp(Object plan, JarFile moduleFile, boolean standAlone, String
targetPath, WebAppType webApp, AtomicBoolean isDefault) throws DeploymentException {
         XmlObject rawPlan = null;
         try {
             // load the geronimo-web.xml from either the supplied plan or from the earFile
@@ -300,6 +301,7 @@
                 jettyWebApp = (JettyWebAppType) webPlan.changeType(JettyWebAppType.type);
                 XmlBeansUtil.validateDD(jettyWebApp);
             } else {
+                isDefault.set(true);
                 String defaultContextRoot = determineDefaultContextRoot(webApp, standAlone,
moduleFile, targetPath);
                 jettyWebApp = createDefaultPlan(defaultContextRoot);
             }
@@ -319,7 +321,7 @@
         JettyWebAppType gerWebApp = (JettyWebAppType) module.getVendorDD();
         boolean hasSecurityRealmName = gerWebApp.isSetSecurityRealmName();
         buildSubstitutionGroups(gerWebApp, hasSecurityRealmName, module, earContext);
-        for (ModuleBuilderExtension mbe: moduleBuilderExtensions) {
+        for (ModuleBuilderExtension mbe : moduleBuilderExtensions) {
             mbe.initContext(earContext, module, cl);
         }
     }
@@ -344,7 +346,7 @@
             webModule.setClassFinder(createWebAppClassFinder(webApp, webModule));
         }
 
-        getNamingBuilders().buildNaming(webApp, jettyWebApp, earConfiguration, earConfiguration,
(Module) webModule, buildingContext);
+        getNamingBuilders().buildNaming(webApp, jettyWebApp, earConfiguration, earConfiguration,
webModule, buildingContext);
 
         if (!webApp.getMetadataComplete()) {
             webApp.setMetadataComplete(true);
@@ -418,15 +420,14 @@
 
             webModuleData.setAttribute(JettyWebAppContext.GBEAN_ATTR_SESSION_TIMEOUT,
                     (webApp.getSessionConfigArray().length == 1 && webApp.getSessionConfigArray(0).getSessionTimeout()
!= null) ?
-                            new Integer(webApp.getSessionConfigArray(0).getSessionTimeout().getBigIntegerValue().intValue()
* 60) :
+                            webApp.getSessionConfigArray(0).getSessionTimeout().getBigIntegerValue().intValue()
* 60 :
                             defaultSessionTimeoutSeconds);
 
-            Boolean distributable = webApp.getDistributableArray().length == 1 ? Boolean.TRUE
: Boolean.FALSE;
+            Boolean distributable = webApp.getDistributableArray().length == 1 ? TRUE : FALSE;
             webModuleData.setAttribute("distributable", distributable);
-            if (Boolean.TRUE == distributable) {
+            if (TRUE == distributable) {
                 clusteringBuilders.build(jettyWebApp, earContext, moduleContext);
-                if (webModuleData.getReferencePatterns(JettyWebAppContext.GBEAN_REF_SESSION_HANDLER_FACTORY)
== null)
-                {
+                if (webModuleData.getReferencePatterns(JettyWebAppContext.GBEAN_REF_SESSION_HANDLER_FACTORY)
== null) {
                     log.warn("No clustering builders configured: app will not be clustered");
                     configureNoClustering(moduleContext, webModuleData);
                 }
@@ -521,7 +522,7 @@
         }
 
         //TODO this may definitely not be the best place for this!
-        for (ModuleBuilderExtension mbe: moduleBuilderExtensions) {
+        for (ModuleBuilderExtension mbe : moduleBuilderExtensions) {
             mbe.addGBeans(earContext, module, cl, repository);
         }
     }
@@ -568,8 +569,7 @@
     }
 
     private void addDefaultServletsGBeans(EARContext earContext, EARContext moduleContext,
AbstractName moduleName, Set knownServletMappings) throws GBeanNotFoundException, GBeanAlreadyExistsException
{
-        for (Iterator iterator = defaultServlets.iterator(); iterator.hasNext();) {
-            Object defaultServlet = iterator.next();
+        for (Object defaultServlet : defaultServlets) {
             GBeanData servletGBeanData = getGBeanData(kernel, defaultServlet);
             AbstractName defaultServletObjectName = earContext.getNaming().createChildName(moduleName,
(String) servletGBeanData.getAttribute("servletName"), NameFactory.SERVLET);
             servletGBeanData.setAbstractName(defaultServletObjectName);
@@ -583,8 +583,7 @@
 
     private void addFiltersGBeans(EARContext earContext, EARContext moduleContext, AbstractName
moduleName, WebAppType webApp) throws GBeanAlreadyExistsException {
         FilterType[] filterArray = webApp.getFilterArray();
-        for (int i = 0; i < filterArray.length; i++) {
-            FilterType filterType = filterArray[i];
+        for (FilterType filterType : filterArray) {
             String filterName = filterType.getFilterName().getStringValue().trim();
             AbstractName filterAbstractName = earContext.getNaming().createChildName(moduleName,
filterName, NameFactory.WEB_FILTER);
             GBeanData filterData = new GBeanData(filterAbstractName, JettyFilterHolder.GBEAN_INFO);
@@ -592,8 +591,7 @@
             filterData.setAttribute("filterClass", filterType.getFilterClass().getStringValue().trim());
             Map initParams = new HashMap();
             ParamValueType[] initParamArray = filterType.getInitParamArray();
-            for (int j = 0; j < initParamArray.length; j++) {
-                ParamValueType paramValueType = initParamArray[j];
+            for (ParamValueType paramValueType : initParamArray) {
                 initParams.put(paramValueType.getParamName().getStringValue().trim(), paramValueType.getParamValue().getStringValue().trim());
             }
             filterData.setAttribute("initParams", initParams);
@@ -604,8 +602,7 @@
 
     private void addFilterMappingsGBeans(EARContext earContext, EARContext moduleContext,
AbstractName moduleName, WebAppType webApp, AbstractName previous) throws GBeanAlreadyExistsException
{
         FilterMappingType[] filterMappingArray = webApp.getFilterMappingArray();
-        for (int i = 0; i < filterMappingArray.length; i++) {
-            FilterMappingType filterMappingType = filterMappingArray[i];
+        for (FilterMappingType filterMappingType : filterMappingArray) {
             String filterName = filterMappingType.getFilterName().getStringValue().trim();
             GBeanData filterMappingData = new GBeanData(JettyFilterMapping.GBEAN_INFO);
             if (previous != null) {
@@ -656,18 +653,17 @@
                     error = true;
                 }
             }
-            filterMappingData.setAttribute("requestDispatch", Boolean.valueOf(request));
-            filterMappingData.setAttribute("forwardDispatch", Boolean.valueOf(forward));
-            filterMappingData.setAttribute("includeDispatch", Boolean.valueOf(include));
-            filterMappingData.setAttribute("errorDispatch", Boolean.valueOf(error));
+            filterMappingData.setAttribute("requestDispatch", request);
+            filterMappingData.setAttribute("forwardDispatch", forward);
+            filterMappingData.setAttribute("includeDispatch", include);
+            filterMappingData.setAttribute("errorDispatch", error);
             filterMappingData.setReferencePattern("Filter", filterAbstractName);
             moduleContext.addGBean(filterMappingData);
         }
     }
 
     private AbstractName addDefaultFiltersGBeans(EARContext earContext, EARContext moduleContext,
AbstractName moduleName, AbstractName previous) throws GBeanNotFoundException, GBeanAlreadyExistsException
{
-        for (Iterator iterator = defaultFilters.iterator(); iterator.hasNext();) {
-            Object defaultFilter = iterator.next();
+        for (Object defaultFilter : defaultFilters) {
             GBeanData filterGBeanData = getGBeanData(kernel, defaultFilter);
             String filterName = (String) filterGBeanData.getAttribute("filterName");
             AbstractName defaultFilterAbstractName = earContext.getNaming().createChildName(moduleName,
filterName, NameFactory.WEB_FILTER);
@@ -688,10 +684,10 @@
             previous = filterMappingName;
 
 
-            filterMappingGBeanData.setAttribute("requestDispatch", Boolean.TRUE);
-            filterMappingGBeanData.setAttribute("forwardDispatch", Boolean.TRUE);
-            filterMappingGBeanData.setAttribute("includeDispatch", Boolean.TRUE);
-            filterMappingGBeanData.setAttribute("errorDispatch", Boolean.FALSE);
+            filterMappingGBeanData.setAttribute("requestDispatch", TRUE);
+            filterMappingGBeanData.setAttribute("forwardDispatch", TRUE);
+            filterMappingGBeanData.setAttribute("includeDispatch", TRUE);
+            filterMappingGBeanData.setAttribute("errorDispatch", FALSE);
             filterMappingGBeanData.setReferencePattern("Filter", defaultFilterAbstractName);
             moduleContext.addGBean(filterMappingGBeanData);
         }
@@ -701,14 +697,12 @@
     private Map buildServletMappings(Module module, WebAppType webApp, Map servletMappings,
Set knownServletMappings) throws DeploymentException {
         ServletType[] servletTypes = webApp.getServletArray();
         Set knownServlets = new HashSet();
-        for (int i = 0; i < servletTypes.length; i++) {
-            ServletType type = servletTypes[i];
+        for (ServletType type : servletTypes) {
             knownServlets.add(type.getServletName().getStringValue().trim());
         }
 
         ServletMappingType[] servletMappingArray = webApp.getServletMappingArray();
-        for (int i = 0; i < servletMappingArray.length; i++) {
-            ServletMappingType servletMappingType = servletMappingArray[i];
+        for (ServletMappingType servletMappingType : servletMappingArray) {
             String servletName = servletMappingType.getServletName().getStringValue().trim();
             if (!knownServlets.contains(servletName)) {
                 throw new DeploymentException("Web app " + module.getName() +
@@ -716,8 +710,8 @@
                         "' but no such servlet was found!");
             }
             UrlPatternType[] urlPatterns = servletMappingType.getUrlPatternArray();
-            for (int j = 0; j < urlPatterns.length; j++) {
-                String urlPattern = urlPatterns[j].getStringValue().trim();
+            for (UrlPatternType urlPattern1 : urlPatterns) {
+                String urlPattern = urlPattern1.getStringValue().trim();
                 if (!knownServletMappings.contains(urlPattern)) {
                     knownServletMappings.add(urlPattern);
                     checkString(urlPattern);
@@ -775,10 +769,9 @@
             throw new DeploymentException("Web app " + module.getName() + " cannot have more
than one jsp-config element.  Currently has " + jspConfigArray.length + " jsp-config elements.");
         }
         Map tagLibMap = new HashMap();
-        for (int i = 0; i < jspConfigArray.length; i++) {
-            TaglibType[] tagLibArray = jspConfigArray[i].getTaglibArray();
-            for (int j = 0; j < tagLibArray.length; j++) {
-                TaglibType taglib = tagLibArray[j];
+        for (JspConfigType aJspConfigArray : jspConfigArray) {
+            TaglibType[] tagLibArray = aJspConfigArray.getTaglibArray();
+            for (TaglibType taglib : tagLibArray) {
                 tagLibMap.put(taglib.getTaglibUri().getStringValue().trim(), taglib.getTaglibLocation().getStringValue().trim());
             }
         }
@@ -788,8 +781,7 @@
     private void configureErrorPages(WebAppType webApp, GBeanData webModuleData) {
         ErrorPageType[] errorPageArray = webApp.getErrorPageArray();
         Map errorPageMap = new HashMap();
-        for (int i = 0; i < errorPageArray.length; i++) {
-            ErrorPageType errorPageType = errorPageArray[i];
+        for (ErrorPageType errorPageType : errorPageArray) {
             if (errorPageType.isSetErrorCode()) {
                 errorPageMap.put(errorPageType.getErrorCode().getStringValue(), errorPageType.getLocation().getStringValue());
             } else {
@@ -802,10 +794,9 @@
     private void configureLocalEncodingMappingLists(WebAppType webApp, GBeanData webModuleData)
{
         LocaleEncodingMappingListType[] localeEncodingMappingListArray = webApp.getLocaleEncodingMappingListArray();
         Map localeEncodingMappingMap = new HashMap();
-        for (int i = 0; i < localeEncodingMappingListArray.length; i++) {
-            LocaleEncodingMappingType[] localeEncodingMappingArray = localeEncodingMappingListArray[i].getLocaleEncodingMappingArray();
-            for (int j = 0; j < localeEncodingMappingArray.length; j++) {
-                LocaleEncodingMappingType localeEncodingMapping = localeEncodingMappingArray[j];
+        for (LocaleEncodingMappingListType aLocaleEncodingMappingListArray : localeEncodingMappingListArray)
{
+            LocaleEncodingMappingType[] localeEncodingMappingArray = aLocaleEncodingMappingListArray.getLocaleEncodingMappingArray();
+            for (LocaleEncodingMappingType localeEncodingMapping : localeEncodingMappingArray)
{
                 localeEncodingMappingMap.put(localeEncodingMapping.getLocale(), localeEncodingMapping.getEncoding());
             }
         }
@@ -817,10 +808,10 @@
         List welcomeFiles;
         if (welcomeFileArray.length > 0) {
             welcomeFiles = new ArrayList();
-            for (int i = 0; i < welcomeFileArray.length; i++) {
-                String[] welcomeFileListType = welcomeFileArray[i].getWelcomeFileArray();
-                for (int j = 0; j < welcomeFileListType.length; j++) {
-                    String welcomeFile = welcomeFileListType[j].trim();
+            for (WelcomeFileListType aWelcomeFileArray : welcomeFileArray) {
+                String[] welcomeFileListType = aWelcomeFileArray.getWelcomeFileArray();
+                for (String aWelcomeFileListType : welcomeFileListType) {
+                    String welcomeFile = aWelcomeFileListType.trim();
                     welcomeFiles.add(welcomeFile);
                 }
             }
@@ -833,8 +824,7 @@
     private void configureMimeMappings(WebAppType webApp, GBeanData webModuleData) {
         MimeMappingType[] mimeMappingArray = webApp.getMimeMappingArray();
         Map mimeMappingMap = new HashMap();
-        for (int i = 0; i < mimeMappingArray.length; i++) {
-            MimeMappingType mimeMappingType = mimeMappingArray[i];
+        for (MimeMappingType mimeMappingType : mimeMappingArray) {
             mimeMappingMap.put(mimeMappingType.getExtension().getStringValue(), mimeMappingType.getMimeType().getStringValue());
         }
         webModuleData.setAttribute("mimeMap", mimeMappingMap);
@@ -843,8 +833,7 @@
     private void configureListeners(WebAppType webApp, GBeanData webModuleData) {
         ListenerType[] listenerArray = webApp.getListenerArray();
         Collection listeners = new ArrayList();
-        for (int i = 0; i < listenerArray.length; i++) {
-            ListenerType listenerType = listenerArray[i];
+        for (ListenerType listenerType : listenerArray) {
             listeners.add(listenerType.getListenerClass().getStringValue());
         }
         webModuleData.setAttribute("listenerClassNames", listeners);
@@ -853,8 +842,7 @@
     private void configureContextParams(WebAppType webApp, GBeanData webModuleData) {
         ParamValueType[] contextParamArray = webApp.getContextParamArray();
         Map contextParams = new HashMap();
-        for (int i = 0; i < contextParamArray.length; i++) {
-            ParamValueType contextParam = contextParamArray[i];
+        for (ParamValueType contextParam : contextParamArray) {
             contextParams.put(contextParam.getParamName().getStringValue().trim(), contextParam.getParamValue().getStringValue().trim());
         }
         webModuleData.setAttribute("contextParamMap", contextParams);
@@ -893,7 +881,7 @@
      * @param servletMappings a <code>Map</code> value
      * @param securityRoles   a <code>Set</code> value
      * @param rolePermissions a <code>Map</code> value
-     * @param moduleContext      an <code>EARContext</code> value
+     * @param moduleContext   an <code>EARContext</code> value
      * @throws DeploymentException if an error occurs
      */
     private void addServlets(AbstractName webModuleName,
@@ -909,8 +897,8 @@
         TreeSet loadOrder = new TreeSet(new StartupOrderComparator());
 
         // add all of the servlets to the sorted set
-        for (int i = 0; i < servletTypes.length; i++) {
-            loadOrder.add(servletTypes[i]);
+        for (ServletType servletType1 : servletTypes) {
+            loadOrder.add(servletType1);
         }
 
         // now that they're sorted, read them in order and add them to
@@ -923,8 +911,8 @@
         // of how to do this.
         // http://issues.apache.org/jira/browse/GERONIMO-645
         AbstractName previousServlet = null;
-        for (Iterator servlets = loadOrder.iterator(); servlets.hasNext();) {
-            ServletType servletType = (ServletType) servlets.next();
+        for (Object aLoadOrder : loadOrder) {
+            ServletType servletType = (ServletType) aLoadOrder;
             previousServlet = addServlet(webModuleName, module, previousServlet, servletType,
servletMappings, securityRoles, rolePermissions, moduleContext);
         }
 
@@ -1015,8 +1003,7 @@
         servletData.setReferencePattern("JettyServletRegistration", webModuleName);
         servletData.setAttribute("servletName", servletName);
         ParamValueType[] initParamArray = servletType.getInitParamArray();
-        for (int j = 0; j < initParamArray.length; j++) {
-            ParamValueType paramValueType = initParamArray[j];
+        for (ParamValueType paramValueType : initParamArray) {
             initParams.put(paramValueType.getParamName().getStringValue().trim(), paramValueType.getParamValue().getStringValue().trim());
         }
         servletData.setAttribute("initParams", initParams);

Modified: geronimo/server/trunk/modules/geronimo-jetty6-builder/src/test/java/org/apache/geronimo/jetty6/deployment/PlanParsingTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty6-builder/src/test/java/org/apache/geronimo/jetty6/deployment/PlanParsingTest.java?view=diff&rev=516297&r1=516296&r2=516297
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty6-builder/src/test/java/org/apache/geronimo/jetty6/deployment/PlanParsingTest.java
(original)
+++ geronimo/server/trunk/modules/geronimo-jetty6-builder/src/test/java/org/apache/geronimo/jetty6/deployment/PlanParsingTest.java
Thu Mar  8 20:41:56 2007
@@ -21,6 +21,7 @@
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashSet;
+import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.jar.JarFile;
 
 import org.apache.geronimo.deployment.util.UnpackedJarFile;
@@ -64,6 +65,7 @@
     private WebServiceBuilder webServiceBuilder = null;
     private Environment defaultEnvironment = new Environment();
     private JettyModuleBuilder builder;
+    private AtomicBoolean isDefault = new AtomicBoolean(false);
 
     public PlanParsingTest() throws Exception {
         builder = new JettyModuleBuilder(defaultEnvironment,
@@ -87,7 +89,7 @@
     public void testContents() throws Exception {
         URL resourcePlan = classLoader.getResource("plans/plan1.xml");
         assertTrue(resourcePlan != null);
-        JettyWebAppType jettyWebApp = builder.getJettyWebApp(new File(resourcePlan.getFile()),
null, true, null, null);
+        JettyWebAppType jettyWebApp = builder.getJettyWebApp(new File(resourcePlan.getFile()),
null, true, null, null, isDefault);
         assertEquals(1, jettyWebApp.getResourceRefArray().length);
 //        assertEquals(4, jettyWebApp.getSecurity().getRoleMappings().getRoleArray().length);
     }
@@ -95,7 +97,7 @@
     public void testMoveSecurity1() throws Exception {
         URL resourcePlan = classLoader.getResource("plans/plan1A.xml");
         assertTrue(resourcePlan != null);
-        JettyWebAppType jettyWebApp = builder.getJettyWebApp(new File(resourcePlan.getFile()),
null, true, null, null);
+        JettyWebAppType jettyWebApp = builder.getJettyWebApp(new File(resourcePlan.getFile()),
null, true, null, null, isDefault);
         assertEquals(1, jettyWebApp.getResourceRefArray().length);
 //        assertEquals(4, jettyWebApp.getSecurity().getRoleMappings().getRoleArray().length);
     }
@@ -103,7 +105,7 @@
     public void testMoveSecurity2() throws Exception {
         URL resourcePlan = classLoader.getResource("plans/plan1B.xml");
         assertTrue(resourcePlan != null);
-        JettyWebAppType jettyWebApp = builder.getJettyWebApp(new File(resourcePlan.getFile()),
null, true, null, null);
+        JettyWebAppType jettyWebApp = builder.getJettyWebApp(new File(resourcePlan.getFile()),
null, true, null, null, isDefault);
         assertEquals(1, jettyWebApp.getResourceRefArray().length);
 //        assertEquals(4, jettyWebApp.getSecurity().getRoleMappings().getRoleArray().length);
     }
@@ -111,7 +113,7 @@
     public void testMoveSecurity3() throws Exception {
         URL resourcePlan = classLoader.getResource("plans/plan1C.xml");
         assertTrue(resourcePlan != null);
-        JettyWebAppType jettyWebApp = builder.getJettyWebApp(new File(resourcePlan.getFile()),
null, true, null, null);
+        JettyWebAppType jettyWebApp = builder.getJettyWebApp(new File(resourcePlan.getFile()),
null, true, null, null, isDefault);
 //        assertEquals(4, jettyWebApp.getSecurity().getRoleMappings().getRoleArray().length);
 //        log.debug(jettyWebApp.xmlText());
     }
@@ -119,7 +121,7 @@
     public void testOldFormat() throws Exception {
         URL resourcePlan = classLoader.getResource("plans/plan2.xml");
         assertTrue(resourcePlan != null);
-        JettyWebAppType jettyWebApp = builder.getJettyWebApp(new File(resourcePlan.getFile()),
null, true, null, null);
+        JettyWebAppType jettyWebApp = builder.getJettyWebApp(new File(resourcePlan.getFile()),
null, true, null, null, isDefault);
         assertEquals(1, jettyWebApp.getResourceRefArray().length);
 //        assertEquals(4, jettyWebApp.getSecurity().getRoleMappings().getRoleArray().length);
     }
@@ -128,7 +130,7 @@
         URL war = classLoader.getResource("deployables/war5");
         assertTrue(war != null);
         UnpackedJarFile moduleFile = new UnpackedJarFile(new File(war.getFile()));
-        JettyWebAppType jettyWebApp = builder.getJettyWebApp(null, moduleFile, true, null,
null);
+        JettyWebAppType jettyWebApp = builder.getJettyWebApp(null, moduleFile, true, null,
null, isDefault);
         moduleFile.close();
         assertEquals(1, jettyWebApp.getResourceRefArray().length);
     }
@@ -137,7 +139,7 @@
         URL war = classLoader.getResource("deployables/war6.war");
         assertTrue(war != null);
         JarFile moduleFile = new JarFile(new File(war.getFile()));
-        JettyWebAppType jettyWebApp = builder.getJettyWebApp(null, moduleFile, true, null,
null);
+        JettyWebAppType jettyWebApp = builder.getJettyWebApp(null, moduleFile, true, null,
null, isDefault);
         moduleFile.close();
         assertEquals(1, jettyWebApp.getResourceRefArray().length);
     }
@@ -181,7 +183,7 @@
         assertTrue(war != null);
         JarFile dummyFile = new JarFile(new File(war.getFile()));
 
-        webApp = builder.getJettyWebApp(webApp, dummyFile, true, null, null);
+        webApp = builder.getJettyWebApp(webApp, dummyFile, true, null, null, isDefault);
 
         assertEquals("myContextRoot", webApp.getContextRoot());
 
@@ -192,7 +194,7 @@
         URL war = classLoader.getResource("deployables/war2.war");
         assertTrue(war != null);
         JarFile dummyFile = new JarFile(new File(war.getFile()));
-        JettyWebAppType GerWebAppType = builder.getJettyWebApp(null, dummyFile, true, null,
null);
+        JettyWebAppType GerWebAppType = builder.getJettyWebApp(null, dummyFile, true, null,
null, isDefault);
 
         assertEquals("/war2", GerWebAppType.getContextRoot());
 
@@ -203,7 +205,7 @@
         URL war = classLoader.getResource("deployables/war2.war");
         assertTrue(war != null);
         JarFile dummyFile = new JarFile(new File(war.getFile()));
-        JettyWebAppType GerWebAppType = builder.getJettyWebApp(null, dummyFile, false, "myTargetPath",
null);
+        JettyWebAppType GerWebAppType = builder.getJettyWebApp(null, dummyFile, false, "myTargetPath",
null, isDefault);
 
         assertEquals("myTargetPath", GerWebAppType.getContextRoot());
 
@@ -218,7 +220,7 @@
         URL war = classLoader.getResource("deployables/war2.war");
         assertTrue(war != null);
         JarFile dummyFile = new JarFile(new File(war.getFile()));
-        JettyWebAppType GerWebAppType = builder.getJettyWebApp(null, dummyFile, false, "myTargetPath",
webAppType);
+        JettyWebAppType GerWebAppType = builder.getJettyWebApp(null, dummyFile, false, "myTargetPath",
webAppType, isDefault);
 
         assertEquals("myId", GerWebAppType.getContextRoot());
 



Mime
View raw message