You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by ha...@apache.org on 2015/08/04 21:11:51 UTC
[2/4] incubator-brooklyn git commit: brooklyn-jsgui: add org.apache
package prefix
brooklyn-jsgui: add org.apache package prefix
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/85b1fcf6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/85b1fcf6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/85b1fcf6
Branch: refs/heads/master
Commit: 85b1fcf62f27158a602cd7be44e4cc82c37a2f8d
Parents: c5256b1
Author: Ciprian Ciubotariu <ch...@gmx.net>
Authored: Thu Jul 16 15:48:59 2015 +0300
Committer: Ciprian Ciubotariu <ch...@gmx.net>
Committed: Tue Aug 4 17:19:12 2015 +0300
----------------------------------------------------------------------
.../jsgui/BrooklynJavascriptGuiLauncher.java | 80 -------------------
.../BrooklynJavascriptGuiLauncherTest.java | 82 --------------------
.../jsgui/BrooklynJavascriptGuiLauncher.java | 80 +++++++++++++++++++
.../BrooklynJavascriptGuiLauncherTest.java | 82 ++++++++++++++++++++
4 files changed, 162 insertions(+), 162 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/85b1fcf6/usage/jsgui/src/test/java/brooklyn/rest/jsgui/BrooklynJavascriptGuiLauncher.java
----------------------------------------------------------------------
diff --git a/usage/jsgui/src/test/java/brooklyn/rest/jsgui/BrooklynJavascriptGuiLauncher.java b/usage/jsgui/src/test/java/brooklyn/rest/jsgui/BrooklynJavascriptGuiLauncher.java
deleted file mode 100644
index 2e9dd13..0000000
--- a/usage/jsgui/src/test/java/brooklyn/rest/jsgui/BrooklynJavascriptGuiLauncher.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package brooklyn.rest.jsgui;
-
-import java.net.InetSocketAddress;
-
-import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.webapp.WebAppContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import brooklyn.rest.BrooklynRestApiLauncher;
-import brooklyn.util.net.Networking;
-
-/** launches Javascript GUI programmatically. and used for tests.
- * see {@link BrooklynRestApiLauncher} for more information.
- *
- * WINDOWS tips:
- * On Windows Jetty will lock all static files preventing any changes on them.
- * To work around the problem and tell Jetty not to lock files:
- * <ul>
- * <li>find jetty-webapp-<ver>.jar from your classpath
- * <li>extract the file webdefault.xml from folder org/eclipse/jetty/webapp (On Eclipse
- * just expanding the jar from the dependencies, right click/copy on the file.)
- * <li>in this project create a java package org.eclipse.jetty.webapp and put the webdefault.html file in it
- * <li>edit the file and change the property useFileMappedBuffer to false
- * </ul>
- **/
-public class BrooklynJavascriptGuiLauncher {
-
- private static final Logger log = LoggerFactory.getLogger(BrooklynJavascriptGuiLauncher.class);
-
- public static void main(String[] args) throws Exception {
- // NOTE: When running Brooklyn from an IDE (i.e. by launching BrooklynJavascriptGuiLauncher.main())
- // you will need to ensure that the working directory is set to the jsgui folder. For IntelliJ,
- // set the 'Working directory' of the Run/Debug Configuration to $MODULE_DIR/../jsgui.
- // For Eclipse, use the default option of ${workspace_loc:brooklyn-jsgui}.
- // 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.
- startJavascriptAndRest();
-
- log.info("Press Ctrl-C to quit.");
- }
-
- final static int FAVOURITE_PORT = 8080;
-
- /** due to the ../jsgui trick in {@link BrooklynRestApiLauncher} we can just call that method */
- public static Server startJavascriptAndRest() throws Exception {
- return BrooklynRestApiLauncher.startRestResourcesViaFilter();
- }
-
- /** not much fun without a REST client. but TODO we should make it so the REST endpoint can be configured. */
- public static Server startJavascriptWithoutRest() throws Exception {
- WebAppContext context = new WebAppContext("./src/main/webapp", "/");
-
- Server server = new Server(new InetSocketAddress(Networking.LOOPBACK, Networking.nextAvailablePort(FAVOURITE_PORT)));
- server.setHandler(context);
- server.start();
- log.info("JS GUI server started (no REST) at http://localhost:"+server.getConnectors()[0].getLocalPort()+"/");
-
- return server;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/85b1fcf6/usage/jsgui/src/test/java/brooklyn/rest/jsgui/BrooklynJavascriptGuiLauncherTest.java
----------------------------------------------------------------------
diff --git a/usage/jsgui/src/test/java/brooklyn/rest/jsgui/BrooklynJavascriptGuiLauncherTest.java b/usage/jsgui/src/test/java/brooklyn/rest/jsgui/BrooklynJavascriptGuiLauncherTest.java
deleted file mode 100644
index 9ebb40b..0000000
--- a/usage/jsgui/src/test/java/brooklyn/rest/jsgui/BrooklynJavascriptGuiLauncherTest.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package brooklyn.rest.jsgui;
-
-import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.server.handler.ContextHandler;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.Test;
-
-import brooklyn.config.BrooklynServiceAttributes;
-import brooklyn.entity.basic.Entities;
-import brooklyn.management.ManagementContext;
-import brooklyn.rest.BrooklynRestApiLauncherTestFixture;
-import brooklyn.test.Asserts;
-import brooklyn.test.HttpTestUtils;
-
-/** Convenience and demo for launching programmatically. */
-public class BrooklynJavascriptGuiLauncherTest {
-
- Server server = null;
-
- @AfterMethod(alwaysRun=true)
- public void stopServer() throws Exception {
- if (server!=null) {
- ManagementContext mgmt = getManagementContextFromJettyServerAttributes(server);
- server.stop();
- if (mgmt!=null) Entities.destroyAll(mgmt);
- server = null;
- }
- }
-
- @Test
- public void testJavascriptWithoutRest() throws Exception {
- server = BrooklynJavascriptGuiLauncher.startJavascriptWithoutRest();
- checkUrlContains("/index.html", "Brooklyn");
- }
-
- @Test
- public void testJavascriptWithRest() throws Exception {
- server = BrooklynJavascriptGuiLauncher.startJavascriptAndRest();
- BrooklynRestApiLauncherTestFixture.forceUseOfDefaultCatalogWithJavaClassPath(server);
- BrooklynRestApiLauncherTestFixture.enableAnyoneLogin(server);
- checkEventuallyHealthy();
- checkUrlContains("/index.html", "Brooklyn");
- checkUrlContains("/v1/catalog/entities", "Tomcat");
- }
-
- protected void checkUrlContains(final String path, final String text) {
- //Server may return 403 until it loads completely, wait a bit
- //until it stabilizes.
- HttpTestUtils.assertContentEventuallyContainsText(rootUrl()+path, text);
- }
-
- protected void checkEventuallyHealthy() {
- HttpTestUtils.assertHttpStatusCodeEventuallyEquals(rootUrl(), 200);
- }
-
- protected String rootUrl() {
- return "http://localhost:"+server.getConnectors()[0].getLocalPort();
- }
-
- private ManagementContext getManagementContextFromJettyServerAttributes(Server server) {
- return (ManagementContext) ((ContextHandler)server.getHandler()).getAttribute(BrooklynServiceAttributes.BROOKLYN_MANAGEMENT_CONTEXT);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/85b1fcf6/usage/jsgui/src/test/java/org/apache/brooklyn/rest/jsgui/BrooklynJavascriptGuiLauncher.java
----------------------------------------------------------------------
diff --git a/usage/jsgui/src/test/java/org/apache/brooklyn/rest/jsgui/BrooklynJavascriptGuiLauncher.java b/usage/jsgui/src/test/java/org/apache/brooklyn/rest/jsgui/BrooklynJavascriptGuiLauncher.java
new file mode 100644
index 0000000..72897d9
--- /dev/null
+++ b/usage/jsgui/src/test/java/org/apache/brooklyn/rest/jsgui/BrooklynJavascriptGuiLauncher.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.brooklyn.rest.jsgui;
+
+import java.net.InetSocketAddress;
+
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.webapp.WebAppContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import brooklyn.rest.BrooklynRestApiLauncher;
+import brooklyn.util.net.Networking;
+
+/** launches Javascript GUI programmatically. and used for tests.
+ * see {@link BrooklynRestApiLauncher} for more information.
+ *
+ * WINDOWS tips:
+ * On Windows Jetty will lock all static files preventing any changes on them.
+ * To work around the problem and tell Jetty not to lock files:
+ * <ul>
+ * <li>find jetty-webapp-<ver>.jar from your classpath
+ * <li>extract the file webdefault.xml from folder org/eclipse/jetty/webapp (On Eclipse
+ * just expanding the jar from the dependencies, right click/copy on the file.)
+ * <li>in this project create a java package org.eclipse.jetty.webapp and put the webdefault.html file in it
+ * <li>edit the file and change the property useFileMappedBuffer to false
+ * </ul>
+ **/
+public class BrooklynJavascriptGuiLauncher {
+
+ private static final Logger log = LoggerFactory.getLogger(BrooklynJavascriptGuiLauncher.class);
+
+ public static void main(String[] args) throws Exception {
+ // NOTE: When running Brooklyn from an IDE (i.e. by launching BrooklynJavascriptGuiLauncher.main())
+ // you will need to ensure that the working directory is set to the jsgui folder. For IntelliJ,
+ // set the 'Working directory' of the Run/Debug Configuration to $MODULE_DIR/../jsgui.
+ // For Eclipse, use the default option of ${workspace_loc:brooklyn-jsgui}.
+ // 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.
+ startJavascriptAndRest();
+
+ log.info("Press Ctrl-C to quit.");
+ }
+
+ final static int FAVOURITE_PORT = 8080;
+
+ /** due to the ../jsgui trick in {@link BrooklynRestApiLauncher} we can just call that method */
+ public static Server startJavascriptAndRest() throws Exception {
+ return BrooklynRestApiLauncher.startRestResourcesViaFilter();
+ }
+
+ /** not much fun without a REST client. but TODO we should make it so the REST endpoint can be configured. */
+ public static Server startJavascriptWithoutRest() throws Exception {
+ WebAppContext context = new WebAppContext("./src/main/webapp", "/");
+
+ Server server = new Server(new InetSocketAddress(Networking.LOOPBACK, Networking.nextAvailablePort(FAVOURITE_PORT)));
+ server.setHandler(context);
+ server.start();
+ log.info("JS GUI server started (no REST) at http://localhost:"+server.getConnectors()[0].getLocalPort()+"/");
+
+ return server;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/85b1fcf6/usage/jsgui/src/test/java/org/apache/brooklyn/rest/jsgui/BrooklynJavascriptGuiLauncherTest.java
----------------------------------------------------------------------
diff --git a/usage/jsgui/src/test/java/org/apache/brooklyn/rest/jsgui/BrooklynJavascriptGuiLauncherTest.java b/usage/jsgui/src/test/java/org/apache/brooklyn/rest/jsgui/BrooklynJavascriptGuiLauncherTest.java
new file mode 100644
index 0000000..cd538cc
--- /dev/null
+++ b/usage/jsgui/src/test/java/org/apache/brooklyn/rest/jsgui/BrooklynJavascriptGuiLauncherTest.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.brooklyn.rest.jsgui;
+
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.handler.ContextHandler;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.Test;
+
+import brooklyn.config.BrooklynServiceAttributes;
+import brooklyn.entity.basic.Entities;
+import brooklyn.management.ManagementContext;
+import brooklyn.rest.BrooklynRestApiLauncherTestFixture;
+import brooklyn.test.Asserts;
+import brooklyn.test.HttpTestUtils;
+
+/** Convenience and demo for launching programmatically. */
+public class BrooklynJavascriptGuiLauncherTest {
+
+ Server server = null;
+
+ @AfterMethod(alwaysRun=true)
+ public void stopServer() throws Exception {
+ if (server!=null) {
+ ManagementContext mgmt = getManagementContextFromJettyServerAttributes(server);
+ server.stop();
+ if (mgmt!=null) Entities.destroyAll(mgmt);
+ server = null;
+ }
+ }
+
+ @Test
+ public void testJavascriptWithoutRest() throws Exception {
+ server = BrooklynJavascriptGuiLauncher.startJavascriptWithoutRest();
+ checkUrlContains("/index.html", "Brooklyn");
+ }
+
+ @Test
+ public void testJavascriptWithRest() throws Exception {
+ server = BrooklynJavascriptGuiLauncher.startJavascriptAndRest();
+ BrooklynRestApiLauncherTestFixture.forceUseOfDefaultCatalogWithJavaClassPath(server);
+ BrooklynRestApiLauncherTestFixture.enableAnyoneLogin(server);
+ checkEventuallyHealthy();
+ checkUrlContains("/index.html", "Brooklyn");
+ checkUrlContains("/v1/catalog/entities", "Tomcat");
+ }
+
+ protected void checkUrlContains(final String path, final String text) {
+ //Server may return 403 until it loads completely, wait a bit
+ //until it stabilizes.
+ HttpTestUtils.assertContentEventuallyContainsText(rootUrl()+path, text);
+ }
+
+ protected void checkEventuallyHealthy() {
+ HttpTestUtils.assertHttpStatusCodeEventuallyEquals(rootUrl(), 200);
+ }
+
+ protected String rootUrl() {
+ return "http://localhost:"+server.getConnectors()[0].getLocalPort();
+ }
+
+ private ManagementContext getManagementContextFromJettyServerAttributes(Server server) {
+ return (ManagementContext) ((ContextHandler)server.getHandler()).getAttribute(BrooklynServiceAttributes.BROOKLYN_MANAGEMENT_CONTEXT);
+ }
+
+}