Merge branch 'master' of ssh://git.eclipse.org/gitroot/jetty/org.eclipse.jetty.project

This commit is contained in:
Greg Wilkins 2012-01-31 11:08:11 +11:00
commit cafdf291ee
2 changed files with 29 additions and 24 deletions

View File

@ -541,29 +541,31 @@ public class Main
// Show Command Line to execute Jetty
if (_dryRun)
{
System.out.println(buildCommandLine(classpath,configuredXmls));
CommandLineBuilder cmd = buildCommandLine(classpath,configuredXmls);
System.out.println(cmd.toString());
return;
}
// execute Jetty in another JVM
if (_exec)
{
String cmd = buildCommandLine(classpath,configuredXmls);
final Process process = Runtime.getRuntime().exec(cmd);
Runtime.getRuntime().addShutdownHook(new Thread()
CommandLineBuilder cmd = buildCommandLine(classpath,configuredXmls);
ProcessBuilder pbuilder = new ProcessBuilder(cmd.getArgs());
final Process process = pbuilder.start();
try
{
@Override
public void run()
{
Config.debug("Destroying " + process);
process.destroy();
}
});
copyInThread(process.getErrorStream(),System.err);
copyInThread(process.getInputStream(),System.out);
copyInThread(System.in,process.getOutputStream());
monitor.setProcess(process);
process.waitFor();
}
finally
{
Config.debug("Destroying " + process);
process.destroy();
}
return;
}
@ -659,7 +661,7 @@ public class Main
throw new FileNotFoundException("Unable to find XML Config: " + xmlFilename);
}
String buildCommandLine(Classpath classpath, List<String> xmls) throws IOException
CommandLineBuilder buildCommandLine(Classpath classpath, List<String> xmls) throws IOException
{
CommandLineBuilder cmd = new CommandLineBuilder(findJavaBin());
@ -693,7 +695,7 @@ public class Main
cmd.addArg(xml);
}
return cmd.toString();
return cmd;
}
private String findJavaBin()

View File

@ -13,8 +13,8 @@
package org.eclipse.jetty.start;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import java.io.File;
import java.io.IOException;
@ -22,6 +22,7 @@ import java.util.ArrayList;
import java.util.List;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@ -90,10 +91,12 @@ public class MainTest
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"));
CommandLineBuilder cmd = main.buildCommandLine(new 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"));
}