summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorThomas Becker2012-01-31 16:38:06 (EST)
committer Greg Wilkins2012-02-01 03:04:09 (EST)
commit449302bcde504acf6d5ca70ca73822dc2fcd57dd (patch)
treecb6f97ec22c7bbe34e46dda24d42290c7a10c2dc
parente26cb287606461bea77d7dcf73b706fb7d9b7e5a (diff)
downloadorg.eclipse.jetty.project-449302bcde504acf6d5ca70ca73822dc2fcd57dd.zip
org.eclipse.jetty.project-449302bcde504acf6d5ca70ca73822dc2fcd57dd.tar.gz
org.eclipse.jetty.project-449302bcde504acf6d5ca70ca73822dc2fcd57dd.tar.bz2
369349: fix --exec classpath issue, spaces in directory names fix
Signed-off-by: Greg Wilkins <gregw@webtide.com>
-rw-r--r--jetty-servlets/src/test/java/org/eclipse/jetty/servlets/AbstractDoSFilterTest.java2
-rw-r--r--jetty-start/src/main/java/org/eclipse/jetty/start/Main.java7
-rw-r--r--jetty-start/src/test/java/org/eclipse/jetty/start/MainTest.java36
3 files changed, 32 insertions, 13 deletions
diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/AbstractDoSFilterTest.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/AbstractDoSFilterTest.java
index c2f4bcf..44cb5d9 100644
--- a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/AbstractDoSFilterTest.java
+++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/AbstractDoSFilterTest.java
@@ -282,7 +282,7 @@ public abstract class AbstractDoSFilterTest
assertEquals(0,count(responses,"DoSFilter: delayed"));
// alternate between sessions
- responses = doRequests(request1+request2+request1+request2+request1,2,550,550,last);
+ responses = doRequests(request1+request2+request1+request2+request1,2,350,550,last);
assertEquals(11,count(responses,"HTTP/1.1 200 OK"));
int delayedRequests = count(responses,"DoSFilter: delayed");
diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java b/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java
index 5f4fc13..3f5c0f0 100644
--- a/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java
+++ b/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java
@@ -669,14 +669,14 @@ public class Main
{
cmd.addArg(x);
}
- cmd.addEqualsArg("-Djetty.home",_jettyHome);
+ cmd.addRawArg("-Djetty.home=" + _jettyHome);
for (String p : _sysProps)
{
String v = System.getProperty(p);
cmd.addEqualsArg("-D" + p,v);
}
cmd.addArg("-cp");
- cmd.addArg(classpath.toString());
+ cmd.addRawArg(classpath.toString());
cmd.addRawArg(_config.getMainClassname());
// Check if we need to pass properties as a file
@@ -692,9 +692,8 @@ public class Main
for (String xml : xmls)
{
- cmd.addArg(xml);
+ cmd.addRawArg(xml);
}
-
return cmd;
}
diff --git a/jetty-start/src/test/java/org/eclipse/jetty/start/MainTest.java b/jetty-start/src/test/java/org/eclipse/jetty/start/MainTest.java
index 3a2ae78..f84c8ea 100644
--- a/jetty-start/src/test/java/org/eclipse/jetty/start/MainTest.java
+++ b/jetty-start/src/test/java/org/eclipse/jetty/start/MainTest.java
@@ -13,13 +13,16 @@
package org.eclipse.jetty.start;
-import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.*;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.junit.Assert.assertEquals;
import java.io.File;
import java.io.IOException;
+import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
+import java.util.Vector;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
import org.junit.Assert;
@@ -76,7 +79,7 @@ public class MainTest
}
@Test
- public void testBuildCommandLine() throws IOException
+ public void testBuildCommandLine() throws IOException, NoSuchFieldException, IllegalAccessException
{
List<String> jvmArgs = new ArrayList<String>();
jvmArgs.add("--exec");
@@ -91,13 +94,30 @@ public class MainTest
Main main = new Main();
main.addJvmArgs(jvmArgs);
- CommandLineBuilder cmd = main.buildCommandLine(new Classpath(""),xmls);
- Assert.assertThat("CommandLineBuilder shouldn't be null", cmd, notNullValue());
+ Classpath classpath = nastyWayToCreateAClasspathObject("/jetty/home with spaces/");
+ CommandLineBuilder cmd = main.buildCommandLine(classpath,xmls);
+ Assert.assertThat("CommandLineBuilder shouldn't be null",cmd,notNullValue());
String commandLine = cmd.toString();
- Assert.assertThat("CommandLine shouldn't be null", commandLine, notNullValue());
- Assert.assertThat("CommandLine should contain jvmArgs",commandLine, containsString("--exec -Xms1024m -Xmx1024m"));
- Assert.assertThat("CommandLine should contain xmls",commandLine, containsString("jetty.xml jetty-jmx.xml jetty-logging.xml"));
+ Assert.assertThat("CommandLine shouldn't be null",commandLine,notNullValue());
+ Assert.assertThat("Classpath should be correctly quoted and match expected value",commandLine,
+ containsString("-cp /jetty/home with spaces/somejar.jar:/jetty/home with spaces/someotherjar.jar"));
+ Assert.assertThat("CommandLine should contain jvmArgs",commandLine,containsString("--exec -Xms1024m -Xmx1024m"));
+ Assert.assertThat("CommandLine should contain xmls",commandLine,containsString("jetty.xml jetty-jmx.xml jetty-logging.xml"));
}
+ private Classpath nastyWayToCreateAClasspathObject(String jettyHome) throws NoSuchFieldException, IllegalAccessException
+ {
+ Classpath classpath = new Classpath();
+ Field classpathElements = Classpath.class.getDeclaredField("_elements");
+ classpathElements.setAccessible(true);
+ File file = new File(jettyHome + "somejar.jar");
+ File file2 = new File(jettyHome + "someotherjar.jar");
+ Vector<File> elements = new Vector<File>();
+ elements.add(file);
+ elements.add(file2);
+ classpathElements.set(classpath,elements);
+ return classpath;
+ }
+
}