Making --dry-run work with paths that have spaces

This commit is contained in:
Joakim Erdfelt 2012-01-20 11:27:38 -07:00
parent 6fc530f7c0
commit 3df95d45c2
2 changed files with 12 additions and 15 deletions

View File

@ -663,17 +663,19 @@ public class Main
{ {
StringBuilder cmd = new StringBuilder(); StringBuilder cmd = new StringBuilder();
cmd.append(findJavaBin()); cmd.append(findJavaBin());
for (String x : _jvmArgs) for (String x : _jvmArgs) {
cmd.append(' ').append(x); cmd.append(" \"").append(x).append("\"");
cmd.append(" -Djetty.home=").append(_jettyHome); }
cmd.append(" \"-Djetty.home=").append(_jettyHome).append("\"");
for (String p : _sysProps) for (String p : _sysProps)
{ {
cmd.append(" -D").append(p); cmd.append(" \"-D").append(p);
String v = System.getProperty(p); String v = System.getProperty(p);
if (v != null && v.length() > 0) if (v != null && v.length() > 0)
cmd.append('=').append(v); cmd.append('=').append(v);
cmd.append("\"");
} }
cmd.append(" -cp ").append(classpath.toString()); cmd.append(" -cp \"").append(classpath.toString()).append("\"");
cmd.append(" ").append(_config.getMainClassname()); cmd.append(" ").append(_config.getMainClassname());
// Check if we need to pass properties as a file // Check if we need to pass properties as a file
@ -681,15 +683,16 @@ public class Main
if (properties.size() > 0) if (properties.size() > 0)
{ {
File prop_file = File.createTempFile("start",".properties"); File prop_file = File.createTempFile("start",".properties");
if (!_dryRun) if (!_dryRun) {
prop_file.deleteOnExit(); prop_file.deleteOnExit();
}
properties.store(new FileOutputStream(prop_file),"start.jar properties"); properties.store(new FileOutputStream(prop_file),"start.jar properties");
cmd.append(" ").append(prop_file.getAbsolutePath()); cmd.append(" \"").append(prop_file.getAbsolutePath()).append("\"");
} }
for (String xml : xmls) for (String xml : xmls)
{ {
cmd.append(' ').append(xml); cmd.append(" \"").append(xml).append("\"");
} }
return cmd.toString(); return cmd.toString();

View File

@ -13,15 +13,11 @@
package org.eclipse.jetty.test.monitor; package org.eclipse.jetty.test.monitor;
import static org.junit.Assert.assertTrue;
import java.io.IOException; import java.io.IOException;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
import javax.management.MBeanServerConnection;
import org.eclipse.jetty.client.ContentExchange; import org.eclipse.jetty.client.ContentExchange;
import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.http.HttpMethods; import org.eclipse.jetty.http.HttpMethods;
@ -35,7 +31,6 @@ import org.eclipse.jetty.monitor.jmx.MonitorAction;
import org.eclipse.jetty.monitor.triggers.GreaterThanAttrEventTrigger; import org.eclipse.jetty.monitor.triggers.GreaterThanAttrEventTrigger;
import org.eclipse.jetty.monitor.triggers.LessThanOrEqualToAttrEventTrigger; import org.eclipse.jetty.monitor.triggers.LessThanOrEqualToAttrEventTrigger;
import org.eclipse.jetty.monitor.triggers.OrEventTrigger; import org.eclipse.jetty.monitor.triggers.OrEventTrigger;
import org.eclipse.jetty.toolchain.jmx.JmxServiceConnection;
import org.eclipse.jetty.toolchain.test.JettyDistro; import org.eclipse.jetty.toolchain.test.JettyDistro;
import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.util.log.Logger;
@ -98,7 +93,7 @@ public class ProgramConfigTest
@Override @Override
public void execute(EventTrigger trigger, EventState<?> state, long timestamp) public void execute(EventTrigger trigger, EventState<?> state, long timestamp)
{ {
System.out.println(counter.incrementAndGet()); counter.incrementAndGet();
} }
}; };
JMXMonitor.addMonitorActions(action); JMXMonitor.addMonitorActions(action);
@ -121,7 +116,6 @@ public class ProgramConfigTest
} }
gate.await(); gate.await();
JMXMonitor.removeMonitorActions(action); JMXMonitor.removeMonitorActions(action);
assertTrue(true);
} }
protected static void runTest(String requestUrl, long count) protected static void runTest(String requestUrl, long count)