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/11/10 03:01:23 UTC

[1/2] incubator-brooklyn git commit: [BROOKLYN-190] Upgrade to Jetty9

Repository: incubator-brooklyn
Updated Branches:
  refs/heads/master 6c4b5170d -> b39daf205


[BROOKLYN-190] Upgrade to Jetty9

Move from jetty-8.1.17.v20150415 to 9.2.13.v20150730


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/598f9ac5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/598f9ac5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/598f9ac5

Branch: refs/heads/master
Commit: 598f9ac5ea88c2579dc28fc50ba7e96ad44bebec
Parents: ae30539
Author: Ciprian Ciubotariu <ch...@gmx.net>
Authored: Fri Oct 30 23:10:55 2015 +0200
Committer: Ciprian Ciubotariu <ch...@gmx.net>
Committed: Mon Nov 9 18:59:06 2015 +0200

----------------------------------------------------------------------
 camp/camp-server/pom.xml                        |  4 +--
 .../brooklyn/camp/server/rest/CampServer.java   | 20 ++++++++----
 .../apache/brooklyn/core/test/HttpService.java  | 20 +++++++++---
 parent/pom.xml                                  |  6 ++--
 pom.xml                                         |  4 +--
 .../jsgui/BrooklynJavascriptGuiLauncher.java    |  3 +-
 .../BrooklynJavascriptGuiLauncherTest.java      |  3 +-
 usage/launcher/pom.xml                          |  4 +--
 .../brooklyn/launcher/BrooklynWebServer.java    | 34 +++++++++++++-------
 .../launcher/BrooklynWebServerTest.java         | 21 +++++++++---
 usage/rest-api/pom.xml                          |  4 +--
 .../ApplicationResourceIntegrationTest.java     |  3 +-
 .../rest/client/BrooklynApiRestClientTest.java  |  3 +-
 .../brooklyn/rest/BrooklynRestApiLauncher.java  |  3 +-
 .../rest/BrooklynRestApiLauncherTest.java       |  3 +-
 .../BrooklynRestApiLauncherTestFixture.java     |  3 +-
 .../json/BrooklynJacksonSerializerTest.java     |  5 +--
 17 files changed, 96 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/598f9ac5/camp/camp-server/pom.xml
----------------------------------------------------------------------
diff --git a/camp/camp-server/pom.xml b/camp/camp-server/pom.xml
index b7530f4..8388c61 100644
--- a/camp/camp-server/pom.xml
+++ b/camp/camp-server/pom.xml
@@ -121,8 +121,8 @@
             <artifactId>jetty-util</artifactId>
         </dependency>
         <dependency>
-            <groupId>org.eclipse.jetty.orbit</groupId>
-            <artifactId>javax.servlet</artifactId>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
         </dependency>
         
         <dependency>

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/598f9ac5/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/rest/CampServer.java
----------------------------------------------------------------------
diff --git a/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/rest/CampServer.java b/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/rest/CampServer.java
index be2f7e9..0ad6bc2 100644
--- a/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/rest/CampServer.java
+++ b/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/rest/CampServer.java
@@ -43,6 +43,8 @@ import com.google.common.io.Files;
 import com.sun.jersey.api.core.DefaultResourceConfig;
 import com.sun.jersey.api.core.ResourceConfig;
 import com.sun.jersey.spi.container.servlet.ServletContainer;
+import org.eclipse.jetty.server.NetworkConnector;
+import org.eclipse.jetty.server.ServerConnector;
 
 public class CampServer {
 
@@ -118,7 +120,8 @@ public class CampServer {
     
     public Integer getPort() {
         if (server==null) return null;
-        return server.getConnectors()[0].getLocalPort();
+        NetworkConnector networkConnector = (NetworkConnector) server.getConnectors()[0];
+        return networkConnector.getLocalPort();
     }
 
     public static class CampServerUtils {
@@ -148,13 +151,18 @@ public class CampServer {
         public static Server startServer(ContextHandler context, String summary) {
             // FIXME port hardcoded
             int port = Networking.nextAvailablePort(8080);
-            Server server = new Server(port);
-            server.setHandler(context);
-            
+
             // use a nice name in the thread pool (otherwise this is exactly the same as Server defaults)
             QueuedThreadPool threadPool = new QueuedThreadPool();
             threadPool.setName("camp-jetty-server-"+port+"-"+threadPool.getName());
-            server.setThreadPool(threadPool);
+
+            Server server = new Server(threadPool);
+
+            ServerConnector httpConnector = new ServerConnector(server);
+            httpConnector.setPort(port);
+            server.addConnector(httpConnector);
+
+            server.setHandler(context);
 
             try {
                 server.start();
@@ -162,7 +170,7 @@ public class CampServer {
                 throw Exceptions.propagate(e);
             } 
             log.info("CAMP REST server started ("+summary+") on");
-            log.info("  http://localhost:"+server.getConnectors()[0].getLocalPort()+"/");
+            log.info("  http://localhost:"+httpConnector.getLocalPort()+"/");
 
             return server;
         }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/598f9ac5/core/src/test/java/org/apache/brooklyn/core/test/HttpService.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/test/HttpService.java b/core/src/test/java/org/apache/brooklyn/core/test/HttpService.java
index d054dbe..b2ff422 100644
--- a/core/src/test/java/org/apache/brooklyn/core/test/HttpService.java
+++ b/core/src/test/java/org/apache/brooklyn/core/test/HttpService.java
@@ -35,7 +35,6 @@ import org.eclipse.jetty.security.SecurityHandler;
 import org.eclipse.jetty.security.authentication.BasicAuthenticator;
 import org.eclipse.jetty.server.Connector;
 import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.server.ssl.SslSocketConnector;
 import org.eclipse.jetty.util.security.Constraint;
 import org.eclipse.jetty.util.security.Credential;
 import org.eclipse.jetty.util.ssl.SslContextFactory;
@@ -47,6 +46,11 @@ import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocati
 import org.apache.brooklyn.test.support.TestResourceUnavailableException;
 
 import com.google.common.base.Optional;
+import org.eclipse.jetty.http.HttpVersion;
+import org.eclipse.jetty.server.HttpConfiguration;
+import org.eclipse.jetty.server.HttpConnectionFactory;
+import org.eclipse.jetty.server.ServerConnector;
+import org.eclipse.jetty.server.SslConnectionFactory;
 
 /**
  * Starts an in-memory web-server, which for example can be used for testing HttpFeed.
@@ -128,15 +132,21 @@ public class HttpService {
                 } finally {
                     keyStoreStream.close();
                 }
-                
+
+                // manually create like seen in XMLs at http://www.eclipse.org/jetty/documentation/current/configuring-ssl.html
                 SslContextFactory sslContextFactory = new SslContextFactory();
                 sslContextFactory.setKeyStore(keyStore);
                 sslContextFactory.setTrustAll(true);
                 sslContextFactory.setKeyStorePassword("password");
 
-                SslSocketConnector sslSocketConnector = new SslSocketConnector(sslContextFactory);
-                sslSocketConnector.setPort(actualPort);
-                server.addConnector(sslSocketConnector);
+                HttpConfiguration sslHttpConfig = new HttpConfiguration();
+                sslHttpConfig.setSecureScheme("https");
+                sslHttpConfig.setSecurePort(actualPort);
+
+                ServerConnector httpsConnector = new ServerConnector(server, new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()), new HttpConnectionFactory(sslHttpConfig));
+                httpsConnector.setPort(actualPort);
+
+                server.addConnector(httpsConnector);
             }
     
             addShutdownHook();

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/598f9ac5/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 2c6d7bd..faf0f40 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -208,9 +208,9 @@
                 <version>${swagger.version}</version>
             </dependency>
             <dependency>
-                <groupId>org.eclipse.jetty.orbit</groupId>
-                <artifactId>javax.servlet</artifactId>
-                <version>${jetty-orbit-javax-servlet.version}</version>
+                <groupId>javax.servlet</groupId>
+                <artifactId>javax.servlet-api</artifactId>
+                <version>${javax-servlet.version}</version>
             </dependency>
             <dependency>
                 <groupId>org.eclipse.jetty</groupId>

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/598f9ac5/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 5624c80..5ba1ce5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -119,7 +119,7 @@
         <sshj.version>0.8.1</sshj.version>
         <felix.framework.version>4.4.0</felix.framework.version>
         <reflections.version>0.9.9-RC1</reflections.version>
-        <jetty.version>8.1.17.v20150415</jetty.version>
+        <jetty.version>9.2.13.v20150730</jetty.version>
         <airline.version>0.6</airline.version>
         <mockwebserver.version>20121111</mockwebserver.version>
         <freemarker.version>2.3.22</freemarker.version>
@@ -159,7 +159,7 @@
         <jasmine-maven-plugin.version>1.3.1.5</jasmine-maven-plugin.version>
         <requirejs-maven-plugin.version>2.0.0</requirejs-maven-plugin.version>
         <maven-antrun-plugin.version>1.7</maven-antrun-plugin.version>
-        <jetty-orbit-javax-servlet.version>3.0.0.v201112011016</jetty-orbit-javax-servlet.version>
+        <javax-servlet.version>3.1.0</javax-servlet.version>
         <jcommander.version>1.27</jcommander.version>
         <xml-apis.version>1.0.b2</xml-apis.version>
         <jsr250-api.version>1.0</jsr250-api.version>

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/598f9ac5/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
index 8e64624..0f573c6 100644
--- 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
@@ -26,6 +26,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.apache.brooklyn.rest.BrooklynRestApiLauncher;
 import org.apache.brooklyn.util.net.Networking;
+import org.eclipse.jetty.server.NetworkConnector;
 
 /** launches Javascript GUI programmatically. and used for tests.
  * see {@link BrooklynRestApiLauncher} for more information.
@@ -71,7 +72,7 @@ public class BrooklynJavascriptGuiLauncher {
         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()+"/");
+        log.info("JS GUI server started (no REST) at  http://localhost:"+((NetworkConnector)server.getConnectors()[0]).getLocalPort()+"/");
         
         return server;
     }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/598f9ac5/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
index 8af689a..16c5996 100644
--- 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
@@ -28,6 +28,7 @@ import org.apache.brooklyn.api.mgmt.ManagementContext;
 import org.apache.brooklyn.core.entity.Entities;
 import org.apache.brooklyn.core.server.BrooklynServiceAttributes;
 import org.apache.brooklyn.rest.BrooklynRestApiLauncherTestFixture;
+import org.eclipse.jetty.server.NetworkConnector;
 
 /** Convenience and demo for launching programmatically. */
 public class BrooklynJavascriptGuiLauncherTest {
@@ -71,7 +72,7 @@ public class BrooklynJavascriptGuiLauncherTest {
     }
 
     protected String rootUrl() {
-        return "http://localhost:"+server.getConnectors()[0].getLocalPort();
+        return "http://localhost:"+((NetworkConnector)server.getConnectors()[0]).getLocalPort();
     }
 
     private ManagementContext getManagementContextFromJettyServerAttributes(Server server) {

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/598f9ac5/usage/launcher/pom.xml
----------------------------------------------------------------------
diff --git a/usage/launcher/pom.xml b/usage/launcher/pom.xml
index 24504e0..1c63f21 100644
--- a/usage/launcher/pom.xml
+++ b/usage/launcher/pom.xml
@@ -117,8 +117,8 @@
             <artifactId>jetty-webapp</artifactId>
         </dependency>
         <dependency>
-            <groupId>org.eclipse.jetty.orbit</groupId>
-            <artifactId>javax.servlet</artifactId>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
         </dependency>
         <dependency>
             <groupId>org.apache.httpcomponents</groupId>

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/598f9ac5/usage/launcher/src/main/java/org/apache/brooklyn/launcher/BrooklynWebServer.java
----------------------------------------------------------------------
diff --git a/usage/launcher/src/main/java/org/apache/brooklyn/launcher/BrooklynWebServer.java b/usage/launcher/src/main/java/org/apache/brooklyn/launcher/BrooklynWebServer.java
index 50f0a8c..9fb7d61 100644
--- a/usage/launcher/src/main/java/org/apache/brooklyn/launcher/BrooklynWebServer.java
+++ b/usage/launcher/src/main/java/org/apache/brooklyn/launcher/BrooklynWebServer.java
@@ -40,8 +40,6 @@ import javax.servlet.DispatcherType;
 import org.eclipse.jetty.server.Connector;
 import org.eclipse.jetty.server.Server;
 import org.eclipse.jetty.server.SessionManager;
-import org.eclipse.jetty.server.nio.SelectChannelConnector;
-import org.eclipse.jetty.server.ssl.SslSelectChannelConnector;
 import org.eclipse.jetty.servlet.FilterHolder;
 import org.eclipse.jetty.servlet.ServletContextHandler;
 import org.eclipse.jetty.util.ssl.SslContextFactory;
@@ -99,6 +97,11 @@ import org.apache.brooklyn.util.stream.Streams;
 import org.apache.brooklyn.util.text.Identifiers;
 import org.apache.brooklyn.util.text.Strings;
 import org.apache.brooklyn.util.web.ContextHandlerCollectionHotSwappable;
+import org.eclipse.jetty.http.HttpVersion;
+import org.eclipse.jetty.server.HttpConfiguration;
+import org.eclipse.jetty.server.HttpConnectionFactory;
+import org.eclipse.jetty.server.ServerConnector;
+import org.eclipse.jetty.server.SslConnectionFactory;
 
 /**
  * Starts the web-app running, connected to the given management context
@@ -379,13 +382,25 @@ public class BrooklynWebServer {
                 throw new IllegalStateException("Unable to provision port for web console (wanted "+portRange+")");
         }
 
-        server = new Server();
-        final Connector connector;
+
+        // use a nice name in the thread pool (otherwise this is exactly the same as Server defaults)
+        QueuedThreadPool threadPool = new QueuedThreadPool();
+        threadPool.setName("brooklyn-jetty-server-"+actualPort+"-"+threadPool.getName());
+
+        server = new Server(threadPool);
+        final ServerConnector connector;
+
         if (getHttpsEnabled()) {
-            connector = new SslSelectChannelConnector(createContextFactory());
+            HttpConfiguration sslHttpConfig = new HttpConfiguration();
+            sslHttpConfig.setSecureScheme("https");
+            sslHttpConfig.setSecurePort(actualPort);
+
+            SslContextFactory sslContextFactory = createContextFactory();
+            connector = new ServerConnector(server, new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()), new HttpConnectionFactory(sslHttpConfig));
         } else {
-            connector = new SelectChannelConnector();
+            connector = new ServerConnector(server, new HttpConnectionFactory());
         }
+
         if (bindAddress != null) {
             connector.setHost(bindAddress.getHostName());
         }
@@ -398,11 +413,6 @@ public class BrooklynWebServer {
             actualAddress = bindAddress;
         }
 
-        // use a nice name in the thread pool (otherwise this is exactly the same as Server defaults)
-        QueuedThreadPool threadPool = new QueuedThreadPool();
-        threadPool.setName("brooklyn-jetty-server-"+actualPort+"-"+threadPool.getName());
-        server.setThreadPool(threadPool);
-
         if (log.isDebugEnabled())
             log.debug("Starting Brooklyn console at "+getRootUrl()+", running " + war + (wars != null ? " and " + wars.values() : ""));
         
@@ -481,7 +491,7 @@ public class BrooklynWebServer {
             sslContextFactory.setCertAlias(ksCertAlias);
         }
         if (!Strings.isEmpty(truststorePath)) {
-            sslContextFactory.setTrustStore(checkFileExists(truststorePath, "truststore"));
+            sslContextFactory.setTrustStorePath(checkFileExists(truststorePath, "truststore"));
             sslContextFactory.setTrustStorePassword(trustStorePassword);
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/598f9ac5/usage/launcher/src/test/java/org/apache/brooklyn/launcher/BrooklynWebServerTest.java
----------------------------------------------------------------------
diff --git a/usage/launcher/src/test/java/org/apache/brooklyn/launcher/BrooklynWebServerTest.java b/usage/launcher/src/test/java/org/apache/brooklyn/launcher/BrooklynWebServerTest.java
index a241a9b..eafaa49 100644
--- a/usage/launcher/src/test/java/org/apache/brooklyn/launcher/BrooklynWebServerTest.java
+++ b/usage/launcher/src/test/java/org/apache/brooklyn/launcher/BrooklynWebServerTest.java
@@ -37,7 +37,6 @@ import java.util.List;
 import java.util.Map;
 
 import javax.net.ssl.SSLHandshakeException;
-import javax.net.ssl.SSLPeerUnverifiedException;
 
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.conn.ssl.SSLSocketFactory;
@@ -56,6 +55,7 @@ import org.apache.brooklyn.util.exceptions.Exceptions;
 
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Lists;
+import java.net.SocketException;
 
 public class BrooklynWebServerTest {
 
@@ -90,7 +90,7 @@ public class BrooklynWebServerTest {
         webServer = new BrooklynWebServer(newManagementContext(brooklynProperties));
         try {
             webServer.start();
-    
+
             HttpToolResponse response = HttpTool.execAndConsume(new DefaultHttpClient(), new HttpGet(webServer.getRootUrl()));
             assertEquals(response.getResponseCode(), 200);
         } finally {
@@ -151,8 +151,21 @@ public class BrooklynWebServerTest {
             verifyHttpsFromConfig(brooklynProperties);
             fail("Expected to fail due to unsupported ciphers during connection negotiation");
         } catch (Exception e) {
-            assertTrue(Exceptions.getFirstThrowableOfType(e, SSLPeerUnverifiedException.class) != null ||
-                    Exceptions.getFirstThrowableOfType(e, SSLHandshakeException.class) != null,
+            // if the server manages to process the error in the protocol ciphers above
+            // before the client enters the SSL handshake, then the server closes the socket
+            // abruptly and the client throws java.net.SocketException
+            // (see org.eclipse.jetty.io.ssl.SslConnection.onOpen)
+            //
+            // however, if the client manages to enter SSL negotiations, then the same behavior above
+            // causes the client to reports javax.net.ssl.SSLHandshakeException
+            // (see org.apache.http.conn.ssl.SSLSocketFactory.connectSocket)
+            //
+            // this race happens because org.apache.http.conn.ssl.SSLSockerFactory.connectSocket(...)
+            // calls java.net.Socket.connect(), and next javax.net.ssl.SSLSocket.startHandshake(),
+            // which provides the opportunity for the server to interweave between those and close the
+            // socket before the client calls startHandshake(), or maybe miss it
+            assertTrue((Exceptions.getFirstThrowableOfType(e, SocketException.class) != null)
+                    || (Exceptions.getFirstThrowableOfType(e, SSLHandshakeException.class) != null),
                     "Expected to fail due to inability to negotiate");
         }
     }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/598f9ac5/usage/rest-api/pom.xml
----------------------------------------------------------------------
diff --git a/usage/rest-api/pom.xml b/usage/rest-api/pom.xml
index 6a8faed..4d20ea0 100644
--- a/usage/rest-api/pom.xml
+++ b/usage/rest-api/pom.xml
@@ -67,8 +67,8 @@
             <artifactId>swagger-core_2.9.1</artifactId>
         </dependency>
         <dependency>
-            <groupId>org.eclipse.jetty.orbit</groupId>
-            <artifactId>javax.servlet</artifactId>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
         </dependency>
         <dependency>
             <groupId>com.sun.jersey</groupId>

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/598f9ac5/usage/rest-client/src/test/java/org/apache/brooklyn/rest/client/ApplicationResourceIntegrationTest.java
----------------------------------------------------------------------
diff --git a/usage/rest-client/src/test/java/org/apache/brooklyn/rest/client/ApplicationResourceIntegrationTest.java b/usage/rest-client/src/test/java/org/apache/brooklyn/rest/client/ApplicationResourceIntegrationTest.java
index 645fd8b..3679975 100644
--- a/usage/rest-client/src/test/java/org/apache/brooklyn/rest/client/ApplicationResourceIntegrationTest.java
+++ b/usage/rest-client/src/test/java/org/apache/brooklyn/rest/client/ApplicationResourceIntegrationTest.java
@@ -54,6 +54,7 @@ import com.google.common.base.Predicate;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Iterables;
+import org.eclipse.jetty.server.NetworkConnector;
 
 @Test(singleThreaded = true)
 public class ApplicationResourceIntegrationTest {
@@ -89,7 +90,7 @@ public class ApplicationResourceIntegrationTest {
                 .managementContext(getManagementContext())
                 .start();
 
-        api = BrooklynApi.newInstance("http://localhost:" + server.getConnectors()[0].getPort() + "/");
+        api = BrooklynApi.newInstance("http://localhost:" + ((NetworkConnector)server.getConnectors()[0]).getPort() + "/");
     }
 
     @AfterClass(alwaysRun = true)

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/598f9ac5/usage/rest-client/src/test/java/org/apache/brooklyn/rest/client/BrooklynApiRestClientTest.java
----------------------------------------------------------------------
diff --git a/usage/rest-client/src/test/java/org/apache/brooklyn/rest/client/BrooklynApiRestClientTest.java b/usage/rest-client/src/test/java/org/apache/brooklyn/rest/client/BrooklynApiRestClientTest.java
index f952c01..993673c 100644
--- a/usage/rest-client/src/test/java/org/apache/brooklyn/rest/client/BrooklynApiRestClientTest.java
+++ b/usage/rest-client/src/test/java/org/apache/brooklyn/rest/client/BrooklynApiRestClientTest.java
@@ -44,6 +44,7 @@ import org.apache.brooklyn.rest.BrooklynRestApiLauncherTest;
 import org.apache.brooklyn.rest.domain.ApplicationSummary;
 import org.apache.brooklyn.rest.domain.CatalogLocationSummary;
 import org.apache.brooklyn.rest.security.provider.TestSecurityProvider;
+import org.eclipse.jetty.server.NetworkConnector;
 
 @Test
 public class BrooklynApiRestClientTest {
@@ -71,7 +72,7 @@ public class BrooklynApiRestClientTest {
                 .securityProvider(TestSecurityProvider.class)
                 .start();
 
-        api = BrooklynApi.newInstance("http://localhost:" + server.getConnectors()[0].getPort() + "/",
+        api = BrooklynApi.newInstance("http://localhost:" + ((NetworkConnector)server.getConnectors()[0]).getPort() + "/",
                 TestSecurityProvider.USER, TestSecurityProvider.PASSWORD);
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/598f9ac5/usage/rest-server/src/test/java/org/apache/brooklyn/rest/BrooklynRestApiLauncher.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/test/java/org/apache/brooklyn/rest/BrooklynRestApiLauncher.java b/usage/rest-server/src/test/java/org/apache/brooklyn/rest/BrooklynRestApiLauncher.java
index 4261471..221d1ad 100644
--- a/usage/rest-server/src/test/java/org/apache/brooklyn/rest/BrooklynRestApiLauncher.java
+++ b/usage/rest-server/src/test/java/org/apache/brooklyn/rest/BrooklynRestApiLauncher.java
@@ -70,6 +70,7 @@ import com.google.common.io.Files;
 import com.sun.jersey.api.core.DefaultResourceConfig;
 import com.sun.jersey.api.core.ResourceConfig;
 import com.sun.jersey.spi.container.servlet.ServletContainer;
+import org.eclipse.jetty.server.NetworkConnector;
 
 /** Convenience and demo for launching programmatically. Also used for automated tests.
  * <p>
@@ -297,7 +298,7 @@ public class BrooklynRestApiLauncher {
             throw Exceptions.propagate(e);
         }
         log.info("Brooklyn REST server started ("+summary+") on");
-        log.info("  http://localhost:"+server.getConnectors()[0].getLocalPort()+"/");
+        log.info("  http://localhost:"+((NetworkConnector)server.getConnectors()[0]).getLocalPort()+"/");
 
         return server;
     }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/598f9ac5/usage/rest-server/src/test/java/org/apache/brooklyn/rest/BrooklynRestApiLauncherTest.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/test/java/org/apache/brooklyn/rest/BrooklynRestApiLauncherTest.java b/usage/rest-server/src/test/java/org/apache/brooklyn/rest/BrooklynRestApiLauncherTest.java
index a6fc407..50c7cb4 100644
--- a/usage/rest-server/src/test/java/org/apache/brooklyn/rest/BrooklynRestApiLauncherTest.java
+++ b/usage/rest-server/src/test/java/org/apache/brooklyn/rest/BrooklynRestApiLauncherTest.java
@@ -31,6 +31,7 @@ import org.eclipse.jetty.server.Server;
 import org.testng.annotations.Test;
 import org.apache.brooklyn.rest.security.provider.AnyoneSecurityProvider;
 import org.apache.brooklyn.rest.util.BrooklynRestResourceUtilsTest.SampleNoOpApplication;
+import org.eclipse.jetty.server.NetworkConnector;
 
 public class BrooklynRestApiLauncherTest extends BrooklynRestApiLauncherTestFixture {
 
@@ -56,7 +57,7 @@ public class BrooklynRestApiLauncherTest extends BrooklynRestApiLauncherTestFixt
     }
     
     private static void checkRestCatalogApplications(Server server) throws Exception {
-        final String rootUrl = "http://localhost:"+server.getConnectors()[0].getLocalPort();
+        final String rootUrl = "http://localhost:"+((NetworkConnector)server.getConnectors()[0]).getLocalPort();
         int code = Asserts.succeedsEventually(new Callable<Integer>() {
             @Override
             public Integer call() throws Exception {

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/598f9ac5/usage/rest-server/src/test/java/org/apache/brooklyn/rest/BrooklynRestApiLauncherTestFixture.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/test/java/org/apache/brooklyn/rest/BrooklynRestApiLauncherTestFixture.java b/usage/rest-server/src/test/java/org/apache/brooklyn/rest/BrooklynRestApiLauncherTestFixture.java
index 25e8ed9..6cb2970 100644
--- a/usage/rest-server/src/test/java/org/apache/brooklyn/rest/BrooklynRestApiLauncherTestFixture.java
+++ b/usage/rest-server/src/test/java/org/apache/brooklyn/rest/BrooklynRestApiLauncherTestFixture.java
@@ -31,6 +31,7 @@ import org.apache.brooklyn.core.server.BrooklynServerConfig;
 import org.apache.brooklyn.core.server.BrooklynServiceAttributes;
 import org.apache.brooklyn.rest.security.provider.AnyoneSecurityProvider;
 import org.apache.brooklyn.util.exceptions.Exceptions;
+import org.eclipse.jetty.server.NetworkConnector;
 
 public abstract class BrooklynRestApiLauncherTestFixture {
 
@@ -71,7 +72,7 @@ public abstract class BrooklynRestApiLauncherTestFixture {
         return getBaseUri(server);
     }
     public static String getBaseUri(Server server) {
-        return "http://localhost:"+server.getConnectors()[0].getLocalPort();
+        return "http://localhost:"+((NetworkConnector)server.getConnectors()[0]).getLocalPort();
     }
     
     public static void forceUseOfDefaultCatalogWithJavaClassPath(Server server) {

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/598f9ac5/usage/rest-server/src/test/java/org/apache/brooklyn/rest/util/json/BrooklynJacksonSerializerTest.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/test/java/org/apache/brooklyn/rest/util/json/BrooklynJacksonSerializerTest.java b/usage/rest-server/src/test/java/org/apache/brooklyn/rest/util/json/BrooklynJacksonSerializerTest.java
index 6280cb0..7a255a3 100644
--- a/usage/rest-server/src/test/java/org/apache/brooklyn/rest/util/json/BrooklynJacksonSerializerTest.java
+++ b/usage/rest-server/src/test/java/org/apache/brooklyn/rest/util/json/BrooklynJacksonSerializerTest.java
@@ -56,6 +56,7 @@ import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Multimap;
 import com.google.common.collect.MultimapBuilder;
 import com.google.gson.Gson;
+import org.eclipse.jetty.server.NetworkConnector;
 
 public class BrooklynJacksonSerializerTest {
 
@@ -290,7 +291,7 @@ public class BrooklynJacksonSerializerTest {
 
             TestApplication app = TestApplication.Factory.newManagedInstanceForTests(mgmt);
 
-            String serverAddress = "http://localhost:"+server.getConnectors()[0].getLocalPort();
+            String serverAddress = "http://localhost:"+((NetworkConnector)server.getConnectors()[0]).getLocalPort();
             String appUrl = serverAddress + "/v1/applications/" + app.getId();
             String entityUrl = appUrl + "/entities/" + app.getId();
             URI configUri = new URIBuilder(entityUrl + "/config/" + TestEntity.CONF_OBJECT.getName())
@@ -323,7 +324,7 @@ public class BrooklynJacksonSerializerTest {
 
             TestApplication app = TestApplication.Factory.newManagedInstanceForTests(mgmt);
 
-            String serverAddress = "http://localhost:"+server.getConnectors()[0].getLocalPort();
+            String serverAddress = "http://localhost:"+((NetworkConnector)server.getConnectors()[0]).getLocalPort();
             String appUrl = serverAddress + "/v1/applications/" + app.getId();
             String entityUrl = appUrl + "/entities/" + app.getId();
             URI configUri = new URIBuilder(entityUrl + "/config/" + TestEntity.CONF_OBJECT.getName())


[2/2] incubator-brooklyn git commit: This closes #997

Posted by ha...@apache.org.
This closes #997


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/b39daf20
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/b39daf20
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/b39daf20

Branch: refs/heads/master
Commit: b39daf20506953cb1cf98c6b9185e1af22a37d77
Parents: 6c4b517 598f9ac
Author: Hadrian Zbarcea <ha...@apache.org>
Authored: Mon Nov 9 20:51:30 2015 -0500
Committer: Hadrian Zbarcea <ha...@apache.org>
Committed: Mon Nov 9 20:51:30 2015 -0500

----------------------------------------------------------------------
 camp/camp-server/pom.xml                        |  4 +--
 .../brooklyn/camp/server/rest/CampServer.java   | 20 ++++++++----
 .../apache/brooklyn/core/test/HttpService.java  | 20 +++++++++---
 parent/pom.xml                                  |  6 ++--
 pom.xml                                         |  4 +--
 .../jsgui/BrooklynJavascriptGuiLauncher.java    |  3 +-
 .../BrooklynJavascriptGuiLauncherTest.java      |  3 +-
 usage/launcher/pom.xml                          |  4 +--
 .../brooklyn/launcher/BrooklynWebServer.java    | 34 +++++++++++++-------
 .../launcher/BrooklynWebServerTest.java         | 21 +++++++++---
 usage/rest-api/pom.xml                          |  4 +--
 .../ApplicationResourceIntegrationTest.java     |  3 +-
 .../rest/client/BrooklynApiRestClientTest.java  |  3 +-
 .../brooklyn/rest/BrooklynRestApiLauncher.java  |  3 +-
 .../rest/BrooklynRestApiLauncherTest.java       |  3 +-
 .../BrooklynRestApiLauncherTestFixture.java     |  3 +-
 .../json/BrooklynJacksonSerializerTest.java     |  5 +--
 17 files changed, 96 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/b39daf20/parent/pom.xml
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/b39daf20/pom.xml
----------------------------------------------------------------------