You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by am...@apache.org on 2006/05/04 06:40:45 UTC
svn commit: r399544 - in /geronimo/branches/1.1/modules:
jetty-builder/src/java/org/apache/geronimo/jetty/deployment/
jetty-builder/src/test-resources/deployables/war-spaces-in-context/
jetty-builder/src/test-resources/deployables/war-spaces-in-context...
Author: ammulder
Date: Wed May 3 21:40:42 2006
New Revision: 399544
URL: http://svn.apache.org/viewcvs?rev=399544&view=rev
Log:
Strip spaces from the context root (GERONIMO-1683), thanks Erin for
the patch!
Added:
geronimo/branches/1.1/modules/jetty-builder/src/test-resources/deployables/war-spaces-in-context/
geronimo/branches/1.1/modules/jetty-builder/src/test-resources/deployables/war-spaces-in-context/META-INF/
geronimo/branches/1.1/modules/jetty-builder/src/test-resources/deployables/war-spaces-in-context/META-INF/MANIFEST.MF
geronimo/branches/1.1/modules/jetty-builder/src/test-resources/deployables/war-spaces-in-context/WEB-INF/
geronimo/branches/1.1/modules/jetty-builder/src/test-resources/deployables/war-spaces-in-context/WEB-INF/geronimo-web.xml (with props)
geronimo/branches/1.1/modules/jetty-builder/src/test-resources/deployables/war-spaces-in-context/WEB-INF/web.xml (with props)
geronimo/branches/1.1/modules/jetty-builder/src/test-resources/deployables/war-spaces-in-context/index.jsp (with props)
geronimo/branches/1.1/modules/tomcat-builder/src/test-resources/deployables/war-spaces-in-context/
geronimo/branches/1.1/modules/tomcat-builder/src/test-resources/deployables/war-spaces-in-context/META-INF/
geronimo/branches/1.1/modules/tomcat-builder/src/test-resources/deployables/war-spaces-in-context/META-INF/MANIFEST.MF
geronimo/branches/1.1/modules/tomcat-builder/src/test-resources/deployables/war-spaces-in-context/WEB-INF/
geronimo/branches/1.1/modules/tomcat-builder/src/test-resources/deployables/war-spaces-in-context/WEB-INF/geronimo-web.xml (with props)
geronimo/branches/1.1/modules/tomcat-builder/src/test-resources/deployables/war-spaces-in-context/WEB-INF/web.xml (with props)
geronimo/branches/1.1/modules/tomcat-builder/src/test-resources/deployables/war-spaces-in-context/index.jsp (with props)
Modified:
geronimo/branches/1.1/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
geronimo/branches/1.1/modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/JettyModuleBuilderTest.java
geronimo/branches/1.1/modules/tomcat-builder/src/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
geronimo/branches/1.1/modules/tomcat-builder/src/test/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java
Modified: geronimo/branches/1.1/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java?rev=399544&r1=399543&r2=399544&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java (original)
+++ geronimo/branches/1.1/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java Wed May 3 21:40:42 2006
@@ -215,13 +215,15 @@
// parse vendor dd
JettyWebAppType jettyWebApp = getJettyWebApp(plan, moduleFile, standAlone, targetPath, webApp);
- if (contextRoot == null) {
+ if (contextRoot == null || contextRoot.trim().equals("")) {
if (jettyWebApp.isSetContextRoot()) {
contextRoot = jettyWebApp.getContextRoot();
} else {
contextRoot = determineDefaultContextRoot(webApp, standAlone, moduleFile, targetPath);
}
}
+
+ contextRoot = contextRoot.trim();
EnvironmentType environmentType = jettyWebApp.getEnvironment();
Environment environment = EnvironmentBuilder.buildEnvironment(environmentType, defaultEnvironment);
Added: geronimo/branches/1.1/modules/jetty-builder/src/test-resources/deployables/war-spaces-in-context/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/jetty-builder/src/test-resources/deployables/war-spaces-in-context/META-INF/MANIFEST.MF?rev=399544&view=auto
==============================================================================
--- geronimo/branches/1.1/modules/jetty-builder/src/test-resources/deployables/war-spaces-in-context/META-INF/MANIFEST.MF (added)
+++ geronimo/branches/1.1/modules/jetty-builder/src/test-resources/deployables/war-spaces-in-context/META-INF/MANIFEST.MF Wed May 3 21:40:42 2006
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Created-By: 1.5.0_06 (Sun Microsystems Inc.)
+
Added: geronimo/branches/1.1/modules/jetty-builder/src/test-resources/deployables/war-spaces-in-context/WEB-INF/geronimo-web.xml
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/jetty-builder/src/test-resources/deployables/war-spaces-in-context/WEB-INF/geronimo-web.xml?rev=399544&view=auto
==============================================================================
--- geronimo/branches/1.1/modules/jetty-builder/src/test-resources/deployables/war-spaces-in-context/WEB-INF/geronimo-web.xml (added)
+++ geronimo/branches/1.1/modules/jetty-builder/src/test-resources/deployables/war-spaces-in-context/WEB-INF/geronimo-web.xml Wed May 3 21:40:42 2006
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app
+ xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-1.1"
+ xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.1"
+ xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.1"
+ xmlns:security="http://geronimo.apache.org/xml/ns/security-1.1"
+ >
+ <environment>
+ <configId>
+ <groupId>contextRootTest</groupId>
+ <artifactId>spacesInContext</artifactId>
+ </configId>
+ </environment>
+
+ <context-root>
+ test-spaces
+ </context-root>
+</web-app>
\ No newline at end of file
Propchange: geronimo/branches/1.1/modules/jetty-builder/src/test-resources/deployables/war-spaces-in-context/WEB-INF/geronimo-web.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: geronimo/branches/1.1/modules/jetty-builder/src/test-resources/deployables/war-spaces-in-context/WEB-INF/web.xml
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/jetty-builder/src/test-resources/deployables/war-spaces-in-context/WEB-INF/web.xml?rev=399544&view=auto
==============================================================================
--- geronimo/branches/1.1/modules/jetty-builder/src/test-resources/deployables/war-spaces-in-context/WEB-INF/web.xml (added)
+++ geronimo/branches/1.1/modules/jetty-builder/src/test-resources/deployables/war-spaces-in-context/WEB-INF/web.xml Wed May 3 21:40:42 2006
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+ http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+ version="2.4">
+
+</web-app>
\ No newline at end of file
Propchange: geronimo/branches/1.1/modules/jetty-builder/src/test-resources/deployables/war-spaces-in-context/WEB-INF/web.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: geronimo/branches/1.1/modules/jetty-builder/src/test-resources/deployables/war-spaces-in-context/index.jsp
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/jetty-builder/src/test-resources/deployables/war-spaces-in-context/index.jsp?rev=399544&view=auto
==============================================================================
--- geronimo/branches/1.1/modules/jetty-builder/src/test-resources/deployables/war-spaces-in-context/index.jsp (added)
+++ geronimo/branches/1.1/modules/jetty-builder/src/test-resources/deployables/war-spaces-in-context/index.jsp Wed May 3 21:40:42 2006
@@ -0,0 +1,6 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+ <head><title>WAR Test - Spaces in Context Root</title></head>
+ <body><p>Testing WAR with spaces in its context root.</p></body>
+</html>
Propchange: geronimo/branches/1.1/modules/jetty-builder/src/test-resources/deployables/war-spaces-in-context/index.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Modified: geronimo/branches/1.1/modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/JettyModuleBuilderTest.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/JettyModuleBuilderTest.java?rev=399544&r1=399543&r2=399544&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/JettyModuleBuilderTest.java (original)
+++ geronimo/branches/1.1/modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/JettyModuleBuilderTest.java Wed May 3 21:40:42 2006
@@ -140,6 +140,39 @@
}
+ public void testContextRootWithSpaces() throws Exception {
+ File outputPath = new File(basedir, "target/test-resources/deployables/war-spaces-in-context");
+ recursiveDelete(outputPath);
+ outputPath.mkdirs();
+ new File(outputPath, "war").mkdir();
+ File path = new File(basedir, "src/test-resources/deployables/war-spaces-in-context");
+ UnpackedJarFile jarFile = new UnpackedJarFile(path);
+ Module module = builder.createModule(null, jarFile, kernel.getNaming(), new ModuleIDBuilder());
+ Repository repository = null;
+
+ AbstractName moduleName = module.getModuleName();
+ EARContext earContext = createEARContext(outputPath, defaultEnvironment, repository, configStore, moduleName);
+ module.setEarContext(earContext);
+ builder.initContext(earContext, module, cl);
+ builder.addGBeans(earContext, module, cl, Collections.EMPTY_SET);
+ ConfigurationData configurationData = earContext.getConfigurationData();
+ earContext.close();
+ module.close();
+
+ Artifact configurationId = configurationData.getId();
+ configurationManager.loadConfiguration(configurationData);
+ Configuration configuration = configurationManager.getConfiguration(configurationId);
+ configurationManager.startConfiguration(configurationId);
+
+ String contextRoot = (String) kernel.getAttribute(moduleName, "contextPath");
+ assertNotNull(contextRoot);
+ assertEquals(contextRoot, contextRoot.trim());
+
+ configurationManager.stopConfiguration(configurationId);
+ configurationManager.unloadConfiguration(configurationId);
+
+ }
+
private EARContext createEARContext(File outputPath, Environment environment, Repository repository, ConfigurationStore configStore, AbstractName moduleName) throws DeploymentException {
Set repositories = repository == null ? Collections.EMPTY_SET : Collections.singleton(repository);
ArtifactManager artifactManager = new DefaultArtifactManager();
Modified: geronimo/branches/1.1/modules/tomcat-builder/src/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/tomcat-builder/src/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java?rev=399544&r1=399543&r2=399544&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/tomcat-builder/src/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java (original)
+++ geronimo/branches/1.1/modules/tomcat-builder/src/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java Wed May 3 21:40:42 2006
@@ -161,13 +161,15 @@
// parse vendor dd
TomcatWebAppType tomcatWebApp = getTomcatWebApp(plan, moduleFile, standAlone, targetPath, webApp);
- if (contextRoot == null) {
+ if (contextRoot == null || contextRoot.trim().equals("")) {
if (tomcatWebApp.isSetContextRoot()) {
contextRoot = tomcatWebApp.getContextRoot();
} else {
contextRoot = determineDefaultContextRoot(webApp, standAlone, moduleFile, targetPath);
}
}
+
+ contextRoot = contextRoot.trim();
EnvironmentType environmentType = tomcatWebApp.getEnvironment();
Environment environment = EnvironmentBuilder.buildEnvironment(environmentType, defaultEnvironment);
Added: geronimo/branches/1.1/modules/tomcat-builder/src/test-resources/deployables/war-spaces-in-context/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/tomcat-builder/src/test-resources/deployables/war-spaces-in-context/META-INF/MANIFEST.MF?rev=399544&view=auto
==============================================================================
--- geronimo/branches/1.1/modules/tomcat-builder/src/test-resources/deployables/war-spaces-in-context/META-INF/MANIFEST.MF (added)
+++ geronimo/branches/1.1/modules/tomcat-builder/src/test-resources/deployables/war-spaces-in-context/META-INF/MANIFEST.MF Wed May 3 21:40:42 2006
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Created-By: 1.5.0_06 (Sun Microsystems Inc.)
+
Added: geronimo/branches/1.1/modules/tomcat-builder/src/test-resources/deployables/war-spaces-in-context/WEB-INF/geronimo-web.xml
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/tomcat-builder/src/test-resources/deployables/war-spaces-in-context/WEB-INF/geronimo-web.xml?rev=399544&view=auto
==============================================================================
--- geronimo/branches/1.1/modules/tomcat-builder/src/test-resources/deployables/war-spaces-in-context/WEB-INF/geronimo-web.xml (added)
+++ geronimo/branches/1.1/modules/tomcat-builder/src/test-resources/deployables/war-spaces-in-context/WEB-INF/geronimo-web.xml Wed May 3 21:40:42 2006
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app
+ xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-1.1"
+ xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.1"
+ xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.1"
+ xmlns:security="http://geronimo.apache.org/xml/ns/security-1.1"
+ >
+ <environment>
+ <configId>
+ <groupId>contextRootTest</groupId>
+ <artifactId>spacesInContext</artifactId>
+ </configId>
+ </environment>
+
+ <context-root>
+ test-spaces
+ </context-root>
+</web-app>
\ No newline at end of file
Propchange: geronimo/branches/1.1/modules/tomcat-builder/src/test-resources/deployables/war-spaces-in-context/WEB-INF/geronimo-web.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: geronimo/branches/1.1/modules/tomcat-builder/src/test-resources/deployables/war-spaces-in-context/WEB-INF/web.xml
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/tomcat-builder/src/test-resources/deployables/war-spaces-in-context/WEB-INF/web.xml?rev=399544&view=auto
==============================================================================
--- geronimo/branches/1.1/modules/tomcat-builder/src/test-resources/deployables/war-spaces-in-context/WEB-INF/web.xml (added)
+++ geronimo/branches/1.1/modules/tomcat-builder/src/test-resources/deployables/war-spaces-in-context/WEB-INF/web.xml Wed May 3 21:40:42 2006
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+ http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+ version="2.4">
+
+</web-app>
\ No newline at end of file
Propchange: geronimo/branches/1.1/modules/tomcat-builder/src/test-resources/deployables/war-spaces-in-context/WEB-INF/web.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: geronimo/branches/1.1/modules/tomcat-builder/src/test-resources/deployables/war-spaces-in-context/index.jsp
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/tomcat-builder/src/test-resources/deployables/war-spaces-in-context/index.jsp?rev=399544&view=auto
==============================================================================
--- geronimo/branches/1.1/modules/tomcat-builder/src/test-resources/deployables/war-spaces-in-context/index.jsp (added)
+++ geronimo/branches/1.1/modules/tomcat-builder/src/test-resources/deployables/war-spaces-in-context/index.jsp Wed May 3 21:40:42 2006
@@ -0,0 +1,6 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+ <head><title>WAR Test - Spaces in Context Root</title></head>
+ <body><p>Testing WAR with spaces in its context root.</p></body>
+</html>
Propchange: geronimo/branches/1.1/modules/tomcat-builder/src/test-resources/deployables/war-spaces-in-context/index.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Modified: geronimo/branches/1.1/modules/tomcat-builder/src/test/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/tomcat-builder/src/test/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java?rev=399544&r1=399543&r2=399544&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/tomcat-builder/src/test/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java (original)
+++ geronimo/branches/1.1/modules/tomcat-builder/src/test/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java Wed May 3 21:40:42 2006
@@ -110,16 +110,36 @@
private ConfigurationManager configurationManager;
private ConfigurationStore configStore;
+
public void testDeployWar4() throws Exception {
- deployWar("war4", "foo/bar/1/car");
+ verifyStartable("war4");
}
public void testDeployWar5() throws Exception {
- deployWar("war5", "test/foo/1/car");
+ verifyStartable("war5");
+ }
+
+ public void testContextRootWithSpaces() throws Exception {
+ WebModuleInfo info = deployWar("war-spaces-in-context");
+ String contextRoot = (String) kernel.getAttribute(info.moduleName, "contextPath");
+ assertNotNull(contextRoot);
+ assertEquals(contextRoot, contextRoot.trim());
+ undeployWar(info.configuration);
}
- public void deployWar(String warName, String name) throws Exception {
+ private void verifyStartable(String warName) throws Exception {
+ WebModuleInfo info = deployWar(warName);
+ assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(info.moduleName));
+ Set names = info.configuration.findGBeans(new AbstractNameQuery(info.moduleName.getArtifact(), Collections.EMPTY_MAP));
+ System.out.println("names: " + names);
+ for (Iterator iterator = names.iterator(); iterator.hasNext();) {
+ AbstractName objectName = (AbstractName) iterator.next();
+ assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(objectName));
+ }
+ undeployWar(info.configuration);
+ }
+ private WebModuleInfo deployWar(String warName) throws Exception {
File outputPath = new File(basedir,
"target/test-resources/deployables/" + warName);
recursiveDelete(outputPath);
@@ -157,16 +177,12 @@
Configuration configuration = configurationManager.getConfiguration(configurationId);
configurationManager.startConfiguration(configurationId);
- assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(moduleName));
- Set names = configuration.findGBeans(new AbstractNameQuery(moduleName.getArtifact(), Collections.EMPTY_MAP));
- System.out.println("names: " + names);
- for (Iterator iterator = names.iterator(); iterator.hasNext();) {
- AbstractName objectName = (AbstractName) iterator.next();
- assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(objectName));
- }
+ return new WebModuleInfo(moduleName, configuration);
+ }
- configurationManager.stopConfiguration(configurationId);
- configurationManager.unloadConfiguration(configurationId);
+ private void undeployWar(Configuration configuration) throws Exception{
+ configurationManager.stopConfiguration(configuration.getId());
+ configurationManager.unloadConfiguration(configuration.getId());
}
private EARContext createEARContext(File outputPath, Environment environment, Repository repository, ConfigurationStore configStore, AbstractName moduleName) throws DeploymentException {
@@ -416,4 +432,15 @@
GBEAN_INFO = infoBuilder.getBeanInfo();
}
}
+
+ private static class WebModuleInfo {
+ AbstractName moduleName;
+ Configuration configuration;
+
+ public WebModuleInfo (AbstractName moduleName, Configuration configuration){
+ this.moduleName = moduleName;
+ this.configuration = configuration;
+ }
+ }
+
}