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 69112f8f319..f734d642562 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 @@ -659,7 +659,7 @@ public class Main throw new FileNotFoundException("Unable to find XML Config: " + xmlFilename); } - private String buildCommandLine(Classpath classpath, List xmls) throws IOException + String buildCommandLine(Classpath classpath, List xmls) throws IOException { StringBuilder cmd = new StringBuilder(); cmd.append(findJavaBin()); @@ -1090,4 +1090,9 @@ public class Main return args; } + + void addJvmArgs(List jvmArgs) + { + _jvmArgs.addAll(jvmArgs); + } } 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 63143c7c377..9ebcaf4f18e 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,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 args = main.expandCommandLine(new String[]{}); + List 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 args = main.expandCommandLine(new String[]{}); + List args = main.expandCommandLine(new String[] {}); List 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 jvmArgs = new ArrayList(); + jvmArgs.add("--exec"); + jvmArgs.add("-Xms1024m"); + jvmArgs.add("-Xmx1024m"); + + List xmls = new ArrayList(); + 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")); + + } + }