diff --git a/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/GoogleDevServer.java b/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/GoogleDevServer.java index a261dcf459..47a73f0581 100644 --- a/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/GoogleDevServer.java +++ b/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/GoogleDevServer.java @@ -18,12 +18,17 @@ */ package org.jclouds.demo.tweetstore.integration; -import com.google.appengine.tools.KickStart; +import static com.google.common.base.Preconditions.checkNotNull; +import static java.lang.String.format; +import java.io.File; import java.io.FileOutputStream; import java.io.IOException; -import java.io.File; import java.util.Properties; +import java.util.concurrent.TimeUnit; + +import com.google.appengine.tools.KickStart; +import com.google.appengine.tools.info.SdkInfo; /** * Basic functionality to start a local google app engine instance. @@ -44,22 +49,29 @@ public class GoogleDevServer { assert new File(filename).exists(); this.server = new Thread(new Runnable() { public void run() { - KickStart - .main(new String[]{ - "com.google.appengine.tools.development.DevAppServerMain", - "--disable_update_check", "-a", address, "-p", - port, warfile}); - + String sdkRoot = checkNotNull(System.getProperty(SdkInfo.SDK_ROOT_PROPERTY), SdkInfo.SDK_ROOT_PROPERTY); + KickStart.main(new String[] { + KickStarter.systemProperty("java.util.logging.config.file", + format("%s/WEB-INF/logging.properties", warfile)), + KickStarter.systemProperty(SdkInfo.SDK_ROOT_PROPERTY, sdkRoot), + "com.google.appengine.tools.development.DevAppServerMain", + "--disable_update_check", + format("--sdk_root=%s", sdkRoot), + "-a", address, "-p", port, warfile }); } - }); server.start(); - Thread.sleep(30 * 1000); + TimeUnit.SECONDS.sleep(30); } - @SuppressWarnings("deprecation") public void stop() throws Exception { - server.stop(); + // KickStart.main opens a process and calls process.waitFor(), which is interruptable + server.interrupt(); + } + + private static class KickStarter { + private static String systemProperty(String key, String value) { + return format("--jvm_flag=-D%s=%s", key, value); + } } - } \ No newline at end of file diff --git a/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/GoogleDevServer.java b/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/GoogleDevServer.java index a261dcf459..47a73f0581 100755 --- a/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/GoogleDevServer.java +++ b/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/GoogleDevServer.java @@ -18,12 +18,17 @@ */ package org.jclouds.demo.tweetstore.integration; -import com.google.appengine.tools.KickStart; +import static com.google.common.base.Preconditions.checkNotNull; +import static java.lang.String.format; +import java.io.File; import java.io.FileOutputStream; import java.io.IOException; -import java.io.File; import java.util.Properties; +import java.util.concurrent.TimeUnit; + +import com.google.appengine.tools.KickStart; +import com.google.appengine.tools.info.SdkInfo; /** * Basic functionality to start a local google app engine instance. @@ -44,22 +49,29 @@ public class GoogleDevServer { assert new File(filename).exists(); this.server = new Thread(new Runnable() { public void run() { - KickStart - .main(new String[]{ - "com.google.appengine.tools.development.DevAppServerMain", - "--disable_update_check", "-a", address, "-p", - port, warfile}); - + String sdkRoot = checkNotNull(System.getProperty(SdkInfo.SDK_ROOT_PROPERTY), SdkInfo.SDK_ROOT_PROPERTY); + KickStart.main(new String[] { + KickStarter.systemProperty("java.util.logging.config.file", + format("%s/WEB-INF/logging.properties", warfile)), + KickStarter.systemProperty(SdkInfo.SDK_ROOT_PROPERTY, sdkRoot), + "com.google.appengine.tools.development.DevAppServerMain", + "--disable_update_check", + format("--sdk_root=%s", sdkRoot), + "-a", address, "-p", port, warfile }); } - }); server.start(); - Thread.sleep(30 * 1000); + TimeUnit.SECONDS.sleep(30); } - @SuppressWarnings("deprecation") public void stop() throws Exception { - server.stop(); + // KickStart.main opens a process and calls process.waitFor(), which is interruptable + server.interrupt(); + } + + private static class KickStarter { + private static String systemProperty(String key, String value) { + return format("--jvm_flag=-D%s=%s", key, value); + } } - } \ No newline at end of file