370120: --exec jvm arguments missing spaces fix

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
This commit is contained in:
Thomas Becker 2012-01-30 14:37:33 +01:00 committed by Joakim Erdfelt
parent 40963a884e
commit 9f667257f1
2 changed files with 35 additions and 5 deletions

View File

@ -659,7 +659,7 @@ public class Main
throw new FileNotFoundException("Unable to find XML Config: " + xmlFilename);
}
private String buildCommandLine(Classpath classpath, List<String> xmls) throws IOException
String buildCommandLine(Classpath classpath, List<String> xmls) throws IOException
{
StringBuilder cmd = new StringBuilder();
cmd.append(findJavaBin());
@ -1090,4 +1090,9 @@ public class Main
return args;
}
void addJvmArgs(List<String> jvmArgs)
{
_jvmArgs.addAll(jvmArgs);
}
}

View File

@ -13,10 +13,12 @@
package org.eclipse.jetty.start;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
@ -53,18 +55,18 @@ public class MainTest
public void testExpandCommandLine() throws Exception
{
Main main = new Main();
List<String> args = main.expandCommandLine(new String[]{});
List<String> args = main.expandCommandLine(new String[] {});
assertEquals("start.ini OPTIONS","OPTIONS=Server,jsp,resources,websocket,ext",args.get(0));
assertEquals("start.d/jmx OPTIONS","OPTIONS=jmx",args.get(5));
assertEquals("start.d/jmx XML","--pre=etc/jetty-jmx.xml",args.get(6));
assertEquals("start.d/websocket OPTIONS","OPTIONS=websocket",args.get(7));
}
@Test
public void testProcessCommandLine() throws Exception
{
Main main = new Main();
List<String> args = main.expandCommandLine(new String[]{});
List<String> args = main.expandCommandLine(new String[] {});
List<String> xmls = main.processCommandLine(args);
assertEquals("jmx --pre","etc/jetty-jmx.xml",xmls.get(0));
@ -72,4 +74,27 @@ public class MainTest
assertEquals("start.d","etc/jetty-testrealm.xml",xmls.get(5));
}
@Test
public void testBuildCommandLine() throws IOException
{
List<String> jvmArgs = new ArrayList<String>();
jvmArgs.add("--exec");
jvmArgs.add("-Xms1024m");
jvmArgs.add("-Xmx1024m");
List<String> xmls = new ArrayList<String>();
xmls.add("jetty.xml");
xmls.add("jetty-jmx.xml");
xmls.add("jetty-logging.xml");
Main main = new Main();
main.addJvmArgs(jvmArgs);
String commandLine = main.buildCommandLine(new Classpath(""),xmls);
assertTrue("CommandLine shouldn't be null",commandLine != null);
assertTrue("CommandLine should contain jvmArgs",commandLine.contains("--exec -Xms1024m -Xmx1024m"));
assertTrue("CommandLine should contain xmls",commandLine.contains("jetty.xml jetty-jmx.xml jetty-logging.xml"));
}
}