You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2016/02/08 11:24:54 UTC
[2/4] brooklyn-server git commit: fix failing test searching for jsgui
fix failing test searching for jsgui
was assuming all dirs are checked out; now looks in classpath
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/c91ecf27
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/c91ecf27
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/c91ecf27
Branch: refs/heads/master
Commit: c91ecf27da46cebe5fe59d569853e3d7ead3aeea
Parents: 1298d37
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Sat Feb 6 11:48:51 2016 +0000
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Sat Feb 6 11:48:51 2016 +0000
----------------------------------------------------------------------
.../rest/jsgui/BrooklynJavascriptGuiLauncher.java | 15 ++++++++++++---
.../brooklyn/rest/BrooklynRestApiLauncher.java | 11 ++++++++---
2 files changed, 20 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/c91ecf27/launcher/src/test/java/org/apache/brooklyn/rest/jsgui/BrooklynJavascriptGuiLauncher.java
----------------------------------------------------------------------
diff --git a/launcher/src/test/java/org/apache/brooklyn/rest/jsgui/BrooklynJavascriptGuiLauncher.java b/launcher/src/test/java/org/apache/brooklyn/rest/jsgui/BrooklynJavascriptGuiLauncher.java
index f6329b0..02387c8 100644
--- a/launcher/src/test/java/org/apache/brooklyn/rest/jsgui/BrooklynJavascriptGuiLauncher.java
+++ b/launcher/src/test/java/org/apache/brooklyn/rest/jsgui/BrooklynJavascriptGuiLauncher.java
@@ -25,7 +25,9 @@ import org.eclipse.jetty.webapp.WebAppContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.brooklyn.rest.BrooklynRestApiLauncher;
+import org.apache.brooklyn.util.core.ResourceUtils;
import org.apache.brooklyn.util.net.Networking;
+import org.apache.brooklyn.util.os.Os;
import org.eclipse.jetty.server.NetworkConnector;
/** launches Javascript GUI programmatically. and used for tests.
@@ -73,9 +75,12 @@ public class BrooklynJavascriptGuiLauncher {
* see {@link BrooklynRestApiLauncher#findJsguiWebappInSource()} */
public static Server startJavascriptWithoutRest() throws Exception {
WebAppContext context = new WebAppContext(
- BrooklynRestApiLauncher.findJsguiWebappInSource()
- .or("../../brooklyn-ui/src/main/webapp"),
- "/");
+ BrooklynRestApiLauncher.findJsguiWebappInSource().isPresent()
+ ? BrooklynRestApiLauncher.findJsguiWebappInSource().get()
+ : ResourceUtils.create(BrooklynJavascriptGuiLauncher.class).doesUrlExist("classpath://brooklyn.war")
+ ? Os.writeToTempFile(ResourceUtils.create(BrooklynJavascriptGuiLauncher.class).getResourceFromUrl("classpath://brooklyn.war"), "brooklyn", "war").getAbsolutePath()
+ : throwingReturning("could not find jsgui war or source", "missing-brooklyn.war"),
+ "/");
Server server = new Server(new InetSocketAddress(Networking.LOOPBACK, Networking.nextAvailablePort(FAVOURITE_PORT)));
server.setHandler(context);
@@ -85,4 +90,8 @@ public class BrooklynJavascriptGuiLauncher {
return server;
}
+ private static <T> T throwingReturning(String error, T result) {
+ throw new IllegalStateException(error);
+ }
+
}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/c91ecf27/rest/rest-server/src/test/java/org/apache/brooklyn/rest/BrooklynRestApiLauncher.java
----------------------------------------------------------------------
diff --git a/rest/rest-server/src/test/java/org/apache/brooklyn/rest/BrooklynRestApiLauncher.java b/rest/rest-server/src/test/java/org/apache/brooklyn/rest/BrooklynRestApiLauncher.java
index 92ac8f7..becb882 100644
--- a/rest/rest-server/src/test/java/org/apache/brooklyn/rest/BrooklynRestApiLauncher.java
+++ b/rest/rest-server/src/test/java/org/apache/brooklyn/rest/BrooklynRestApiLauncher.java
@@ -50,9 +50,11 @@ import org.apache.brooklyn.rest.util.ManagementContextProvider;
import org.apache.brooklyn.rest.util.OsgiCompat;
import org.apache.brooklyn.rest.util.ServerStoppingShutdownHandler;
import org.apache.brooklyn.rest.util.ShutdownHandlerProvider;
+import org.apache.brooklyn.util.core.ResourceUtils;
import org.apache.brooklyn.util.exceptions.Exceptions;
import org.apache.brooklyn.util.guava.Maybe;
import org.apache.brooklyn.util.net.Networking;
+import org.apache.brooklyn.util.os.Os;
import org.apache.brooklyn.util.text.WildcardGlobs;
import org.eclipse.jetty.server.NetworkConnector;
import org.eclipse.jetty.server.Server;
@@ -235,9 +237,12 @@ public class BrooklynRestApiLauncher {
// For Eclipse, use the default option of ${workspace_loc:brooklyn-launcher}.
// If the working directory is not set correctly, Brooklyn will be unable to find the jsgui .war
// file and the 'gui not available' message will be shown.
- context.setWar(this.deployJsgui && findJsguiWebappInSource().isPresent()
- ? findJsguiWebappInSource().get()
- : createTempWebDirWithIndexHtml("Brooklyn REST API <p> (gui not available)"));
+ context.setWar(this.deployJsgui &&
+ findJsguiWebappInSource().isPresent()
+ ? findJsguiWebappInSource().get()
+ : ResourceUtils.create(this).doesUrlExist("classpath://brooklyn.war")
+ ? Os.writeToTempFile(ResourceUtils.create(this).getResourceFromUrl("classpath://brooklyn.war"), "brooklyn", "war").getAbsolutePath()
+ : createTempWebDirWithIndexHtml("Brooklyn REST API <p> (gui not available)"));
installAsServletFilter(context, this.filters);
return context;
}