You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2017/07/24 13:49:11 UTC

[1/2] activemq-artemis git commit: This closes #1411

Repository: activemq-artemis
Updated Branches:
  refs/heads/master 2526ecb33 -> 9647c19e7


This closes #1411


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/9647c19e
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/9647c19e
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/9647c19e

Branch: refs/heads/master
Commit: 9647c19e7f9c84e0dd366c86168c89b8074c7cba
Parents: 2526ecb 212bd17
Author: Clebert Suconic <cl...@apache.org>
Authored: Mon Jul 24 09:45:02 2017 -0400
Committer: Clebert Suconic <cl...@apache.org>
Committed: Mon Jul 24 09:45:02 2017 -0400

----------------------------------------------------------------------
 .../artemis/component/WebServerComponent.java   |  9 ++++++++-
 .../cli/test/WebServerComponentTest.java        | 20 ++++++++++++--------
 2 files changed, 20 insertions(+), 9 deletions(-)
----------------------------------------------------------------------



[2/2] activemq-artemis git commit: NO-JIRA use random available port in WebServerComponentTest

Posted by cl...@apache.org.
NO-JIRA use random available port in WebServerComponentTest


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/212bd173
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/212bd173
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/212bd173

Branch: refs/heads/master
Commit: 212bd173d3d0aa994f7dd7e81bb3a5ff847177da
Parents: 2526ecb
Author: Jiri Danek <jd...@redhat.com>
Authored: Wed Jul 19 23:57:16 2017 +0200
Committer: Clebert Suconic <cl...@apache.org>
Committed: Mon Jul 24 09:45:02 2017 -0400

----------------------------------------------------------------------
 .../artemis/component/WebServerComponent.java   |  9 ++++++++-
 .../cli/test/WebServerComponentTest.java        | 20 ++++++++++++--------
 2 files changed, 20 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/212bd173/artemis-web/src/main/java/org/apache/activemq/artemis/component/WebServerComponent.java
----------------------------------------------------------------------
diff --git a/artemis-web/src/main/java/org/apache/activemq/artemis/component/WebServerComponent.java b/artemis-web/src/main/java/org/apache/activemq/artemis/component/WebServerComponent.java
index 5ac42df..601ea4c 100644
--- a/artemis-web/src/main/java/org/apache/activemq/artemis/component/WebServerComponent.java
+++ b/artemis-web/src/main/java/org/apache/activemq/artemis/component/WebServerComponent.java
@@ -56,6 +56,7 @@ public class WebServerComponent implements ExternalComponent {
    private URI uri;
    private String jolokiaUrl;
    private List<WebAppContext> webContexts;
+   private ServerConnector connector;
 
    @Override
    public void configure(ComponentDTO config, String artemisInstance, String artemisHome) throws Exception {
@@ -63,7 +64,6 @@ public class WebServerComponent implements ExternalComponent {
       uri = new URI(webServerConfig.bind);
       server = new Server();
       String scheme = uri.getScheme();
-      ServerConnector connector = null;
 
       if ("https".equals(scheme)) {
          SslContextFactory sslFactory = new SslContextFactory();
@@ -172,6 +172,13 @@ public class WebServerComponent implements ExternalComponent {
       return server != null && server.isStarted();
    }
 
+   /**
+    * @return started server's port number; useful if it was specified as 0 (to use a random port)
+    */
+   public int getPort() {
+      return (connector != null) ? connector.getLocalPort() : -1;
+   }
+
    private WebAppContext deployWar(String url, String warFile, Path warDirectory) throws IOException {
       WebAppContext webapp = new WebAppContext();
       if (url.startsWith("/")) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/212bd173/artemis-web/src/test/java/org/apache/activemq/cli/test/WebServerComponentTest.java
----------------------------------------------------------------------
diff --git a/artemis-web/src/test/java/org/apache/activemq/cli/test/WebServerComponentTest.java b/artemis-web/src/test/java/org/apache/activemq/cli/test/WebServerComponentTest.java
index 9eff9f8..00691ed 100644
--- a/artemis-web/src/test/java/org/apache/activemq/cli/test/WebServerComponentTest.java
+++ b/artemis-web/src/test/java/org/apache/activemq/cli/test/WebServerComponentTest.java
@@ -78,13 +78,14 @@ public class WebServerComponentTest extends Assert {
    @Test
    public void simpleServer() throws Exception {
       WebServerDTO webServerDTO = new WebServerDTO();
-      webServerDTO.bind = "http://localhost:8161";
+      webServerDTO.bind = "http://localhost:0";
       webServerDTO.path = "webapps";
       WebServerComponent webServerComponent = new WebServerComponent();
       Assert.assertFalse(webServerComponent.isStarted());
       webServerComponent.configure(webServerDTO, "./src/test/resources/", "./src/test/resources/");
       testedComponents.add(webServerComponent);
       webServerComponent.start();
+      final int port = webServerComponent.getPort();
       // Make the connection attempt.
       CountDownLatch latch = new CountDownLatch(1);
       final ClientHandler clientHandler = new ClientHandler(latch);
@@ -95,7 +96,7 @@ public class WebServerComponentTest extends Assert {
             ch.pipeline().addLast(clientHandler);
          }
       });
-      Channel ch = bootstrap.connect("localhost", 8161).sync().channel();
+      Channel ch = bootstrap.connect("localhost", port).sync().channel();
 
       URI uri = new URI(URL);
       // Prepare the HTTP request.
@@ -116,12 +117,13 @@ public class WebServerComponentTest extends Assert {
    @Test
    public void testComponentStopBehavior() throws Exception {
       WebServerDTO webServerDTO = new WebServerDTO();
-      webServerDTO.bind = "http://localhost:8161";
+      webServerDTO.bind = "http://localhost:0";
       webServerDTO.path = "webapps";
       WebServerComponent webServerComponent = new WebServerComponent();
       Assert.assertFalse(webServerComponent.isStarted());
       webServerComponent.configure(webServerDTO, "./src/test/resources/", "./src/test/resources/");
       webServerComponent.start();
+      final int port = webServerComponent.getPort();
       // Make the connection attempt.
       CountDownLatch latch = new CountDownLatch(1);
       final ClientHandler clientHandler = new ClientHandler(latch);
@@ -132,7 +134,7 @@ public class WebServerComponentTest extends Assert {
             ch.pipeline().addLast(clientHandler);
          }
       });
-      Channel ch = bootstrap.connect("localhost", 8161).sync().channel();
+      Channel ch = bootstrap.connect("localhost", port).sync().channel();
 
       URI uri = new URI(URL);
       // Prepare the HTTP request.
@@ -158,7 +160,7 @@ public class WebServerComponentTest extends Assert {
    @Test
    public void simpleSecureServer() throws Exception {
       WebServerDTO webServerDTO = new WebServerDTO();
-      webServerDTO.bind = "https://localhost:8448";
+      webServerDTO.bind = "https://localhost:0";
       webServerDTO.path = "webapps";
       webServerDTO.keyStorePath = "./src/test/resources/server.keystore";
       webServerDTO.keyStorePassword = "password";
@@ -168,6 +170,7 @@ public class WebServerComponentTest extends Assert {
       webServerComponent.configure(webServerDTO, "./src/test/resources/", "./src/test/resources/");
       testedComponents.add(webServerComponent);
       webServerComponent.start();
+      final int port = webServerComponent.getPort();
       // Make the connection attempt.
       String keyStoreProvider = "JKS";
 
@@ -188,7 +191,7 @@ public class WebServerComponentTest extends Assert {
             ch.pipeline().addLast(clientHandler);
          }
       });
-      Channel ch = bootstrap.connect("localhost", 8448).sync().channel();
+      Channel ch = bootstrap.connect("localhost", port).sync().channel();
 
       URI uri = new URI(SECURE_URL);
       // Prepare the HTTP request.
@@ -209,7 +212,7 @@ public class WebServerComponentTest extends Assert {
    @Test
    public void simpleSecureServerWithClientAuth() throws Exception {
       WebServerDTO webServerDTO = new WebServerDTO();
-      webServerDTO.bind = "https://localhost:8448";
+      webServerDTO.bind = "https://localhost:0";
       webServerDTO.path = "webapps";
       webServerDTO.keyStorePath = "./src/test/resources/server.keystore";
       webServerDTO.keyStorePassword = "password";
@@ -222,6 +225,7 @@ public class WebServerComponentTest extends Assert {
       webServerComponent.configure(webServerDTO, "./src/test/resources/", "./src/test/resources/");
       testedComponents.add(webServerComponent);
       webServerComponent.start();
+      final int port = webServerComponent.getPort();
       // Make the connection attempt.
       String keyStoreProvider = "JKS";
 
@@ -242,7 +246,7 @@ public class WebServerComponentTest extends Assert {
             ch.pipeline().addLast(clientHandler);
          }
       });
-      Channel ch = bootstrap.connect("localhost", 8448).sync().channel();
+      Channel ch = bootstrap.connect("localhost", port).sync().channel();
 
       URI uri = new URI(SECURE_URL);
       // Prepare the HTTP request.