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 c2f4bcfff08..44cb5d92bc2 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 5f4fc13944c..3f5c0f06afe 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 3a2ae781938..f84c8eaa185 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 jvmArgs = new ArrayList(); 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 elements = new Vector(); + elements.add(file); + elements.add(file2); + classpathElements.set(classpath,elements); + return classpath; + } + }