activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cshan...@apache.org
Subject activemq git commit: https://issues.apache.org/jira/browse/AMQ-6491
Date Tue, 22 Nov 2016 12:28:36 GMT
Repository: activemq
Updated Branches:
  refs/heads/master 7dc70e03e -> f40532a23


https://issues.apache.org/jira/browse/AMQ-6491

Changing the WebSocket servlet to return a succesful empty response
instead of an error when a GET request is made


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

Branch: refs/heads/master
Commit: f40532a23d70639a027fcf87893de8683edf430f
Parents: 7dc70e0
Author: Christopher L. Shannon (cshannon) <christopher.l.shannon@gmail.com>
Authored: Tue Nov 22 07:27:29 2016 -0500
Committer: Christopher L. Shannon (cshannon) <christopher.l.shannon@gmail.com>
Committed: Tue Nov 22 07:27:29 2016 -0500

----------------------------------------------------------------------
 .../activemq/transport/ws/jetty9/WSServlet.java |  2 +-
 .../transport/ws/WSTransportHttpTraceTest.java  |  8 +---
 .../ws/WSTransportLinkStealingTest.java         |  2 +-
 .../activemq/transport/ws/WSTransportTest.java  | 41 +++++++++++++++++++-
 .../transport/wss/WSSTransportTest.java         | 17 ++++++--
 5 files changed, 56 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/f40532a2/activemq-http/src/main/java/org/apache/activemq/transport/ws/jetty9/WSServlet.java
----------------------------------------------------------------------
diff --git a/activemq-http/src/main/java/org/apache/activemq/transport/ws/jetty9/WSServlet.java
b/activemq-http/src/main/java/org/apache/activemq/transport/ws/jetty9/WSServlet.java
index 1f7c5e7..21754ad 100644
--- a/activemq-http/src/main/java/org/apache/activemq/transport/ws/jetty9/WSServlet.java
+++ b/activemq-http/src/main/java/org/apache/activemq/transport/ws/jetty9/WSServlet.java
@@ -85,7 +85,7 @@ public class WSServlet extends WebSocketServlet implements BrokerServiceAware
{
 
     @Override
     protected void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
-        getServletContext().getNamedDispatcher("default").forward(request, response);
+        //return empty response - AMQ-6491
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/activemq/blob/f40532a2/activemq-http/src/test/java/org/apache/activemq/transport/ws/WSTransportHttpTraceTest.java
----------------------------------------------------------------------
diff --git a/activemq-http/src/test/java/org/apache/activemq/transport/ws/WSTransportHttpTraceTest.java
b/activemq-http/src/test/java/org/apache/activemq/transport/ws/WSTransportHttpTraceTest.java
index 5b82ce0..64392b1 100644
--- a/activemq-http/src/test/java/org/apache/activemq/transport/ws/WSTransportHttpTraceTest.java
+++ b/activemq-http/src/test/java/org/apache/activemq/transport/ws/WSTransportHttpTraceTest.java
@@ -20,14 +20,13 @@ package org.apache.activemq.transport.ws;
 import java.util.Collection;
 
 import org.apache.activemq.transport.http.HttpTraceTestSupport;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 import org.junit.runners.Parameterized.Parameters;
 
 @RunWith(Parameterized.class)
-public class WSTransportHttpTraceTest extends WSTransportTest {
+public class WSTransportHttpTraceTest extends WSTransportTestSupport {
 
     protected String enableTraceParam;
     protected int expectedStatus;
@@ -58,9 +57,4 @@ public class WSTransportHttpTraceTest extends WSTransportTest {
         HttpTraceTestSupport.testHttpTraceEnabled("http://127.0.0.1:61623", expectedStatus,
null);
     }
 
-    @Override
-    @Ignore
-    @Test
-    public void testBrokerStart() throws Exception {
-    }
 }

http://git-wip-us.apache.org/repos/asf/activemq/blob/f40532a2/activemq-http/src/test/java/org/apache/activemq/transport/ws/WSTransportLinkStealingTest.java
----------------------------------------------------------------------
diff --git a/activemq-http/src/test/java/org/apache/activemq/transport/ws/WSTransportLinkStealingTest.java
b/activemq-http/src/test/java/org/apache/activemq/transport/ws/WSTransportLinkStealingTest.java
index bd5770c..2ca03c8 100644
--- a/activemq-http/src/test/java/org/apache/activemq/transport/ws/WSTransportLinkStealingTest.java
+++ b/activemq-http/src/test/java/org/apache/activemq/transport/ws/WSTransportLinkStealingTest.java
@@ -50,7 +50,7 @@ public class WSTransportLinkStealingTest {
         context.afterPropertiesSet();
         broker.setSslContext(context);
 
-        broker.addConnector(getWSConnectorURI()).setName("ws+mqtt");;
+        broker.addConnector(getWSConnectorURI()).setName("ws+mqtt");
         broker.setDeleteAllMessagesOnStartup(deleteMessages);
         broker.start();
         broker.waitUntilStarted();

http://git-wip-us.apache.org/repos/asf/activemq/blob/f40532a2/activemq-http/src/test/java/org/apache/activemq/transport/ws/WSTransportTest.java
----------------------------------------------------------------------
diff --git a/activemq-http/src/test/java/org/apache/activemq/transport/ws/WSTransportTest.java
b/activemq-http/src/test/java/org/apache/activemq/transport/ws/WSTransportTest.java
index f9fe74d..ca11876 100644
--- a/activemq-http/src/test/java/org/apache/activemq/transport/ws/WSTransportTest.java
+++ b/activemq-http/src/test/java/org/apache/activemq/transport/ws/WSTransportTest.java
@@ -17,6 +17,7 @@
 
 package org.apache.activemq.transport.ws;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
 import java.io.File;
@@ -25,13 +26,22 @@ import java.net.Socket;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.UnknownHostException;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.activemq.broker.BrokerService;
 import org.apache.activemq.transport.SocketConnectorFactory;
 import org.apache.activemq.transport.stomp.StompConnection;
 import org.apache.activemq.util.Wait;
+import org.eclipse.jetty.client.HttpClient;
+import org.eclipse.jetty.client.api.Request;
+import org.eclipse.jetty.client.api.Result;
+import org.eclipse.jetty.client.util.BufferingResponseListener;
+import org.eclipse.jetty.http.HttpMethod;
+import org.eclipse.jetty.http.HttpStatus;
 import org.eclipse.jetty.server.Connector;
 import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.util.ssl.SslContextFactory;
 import org.eclipse.jetty.webapp.WebAppContext;
 import org.junit.After;
 import org.junit.Before;
@@ -57,9 +67,10 @@ public class WSTransportTest extends WSTransportTestSupport {
     private File profileDir;
 
     private String stompUri;
-
     private StompConnection stompConnection = new StompConnection();
 
+    protected final int port = 61623;
+
     @Override
     protected void addAdditionalConnectors(BrokerService service) throws Exception {
         stompUri = service.addConnector("stomp://localhost:0").getPublishableConnectString();
@@ -67,7 +78,7 @@ public class WSTransportTest extends WSTransportTestSupport {
 
     @Override
     protected String getWSConnectorURI() {
-        return "ws://127.0.0.1:61623?websocket.maxTextMessageSize=99999&transport.maxIdleTime=1001";
+        return "ws://127.0.0.1:" + port + "?websocket.maxTextMessageSize=99999&transport.maxIdleTime=1001";
     }
 
     protected Server createWebServer() throws Exception {
@@ -143,6 +154,32 @@ public class WSTransportTest extends WSTransportTestSupport {
         assertTrue(broker.isStarted());
     }
 
+    @Test(timeout=10000)
+    public void testGet() throws Exception {
+        testGet("http://127.0.0.1:" + port, null);
+    }
+
+
+    protected void testGet(final String uri, SslContextFactory
+            sslContextFactory) throws Exception {
+        HttpClient httpClient = sslContextFactory != null ? new HttpClient(sslContextFactory)
:
+            new HttpClient(new SslContextFactory());
+        httpClient.start();
+
+        final CountDownLatch latch = new CountDownLatch(1);
+        Request request = httpClient.newRequest(uri).method(HttpMethod.GET);
+        final AtomicInteger status = new AtomicInteger();
+        request.send(new BufferingResponseListener() {
+            @Override
+            public void onComplete(Result result) {
+                status.set(result.getResponse().getStatus());
+                latch.countDown();
+            }
+        });
+        latch.await();
+        assertEquals(HttpStatus.OK_200, status.get());
+    }
+
     @Ignore
     @Test
     public void testFireFoxWebSockets() throws Exception {

http://git-wip-us.apache.org/repos/asf/activemq/blob/f40532a2/activemq-http/src/test/java/org/apache/activemq/transport/wss/WSSTransportTest.java
----------------------------------------------------------------------
diff --git a/activemq-http/src/test/java/org/apache/activemq/transport/wss/WSSTransportTest.java
b/activemq-http/src/test/java/org/apache/activemq/transport/wss/WSSTransportTest.java
index 6af0f4e..a3722c2 100644
--- a/activemq-http/src/test/java/org/apache/activemq/transport/wss/WSSTransportTest.java
+++ b/activemq-http/src/test/java/org/apache/activemq/transport/wss/WSSTransportTest.java
@@ -21,6 +21,8 @@ import org.apache.activemq.transport.ws.WSTransportTest;
 import org.eclipse.jetty.server.Connector;
 import org.eclipse.jetty.server.Server;
 import org.eclipse.jetty.server.ServerConnector;
+import org.eclipse.jetty.util.ssl.SslContextFactory;
+import org.junit.Test;
 
 public class WSSTransportTest extends WSTransportTest {
     @Override
@@ -38,12 +40,21 @@ public class WSSTransportTest extends WSTransportTest {
 
     @Override
     protected String getWSConnectorURI() {
-        return "wss://localhost:61623";
+        return "wss://localhost:" + port;
+    }
+
+    @Override
+    @Test(timeout=10000)
+    public void testGet() throws Exception {
+        SslContextFactory factory = new SslContextFactory();
+        factory.setSslContext(broker.getSslContext().getSSLContext());
+
+        testGet("https://127.0.0.1:" + port, factory);
     }
 
     @Override
     protected String getTestURI() {
-        int port = getProxyPort();
-        return "https://localhost:" + port + "/websocket.html#wss://localhost:61623";
+        int proxyPort = getProxyPort();
+        return "https://localhost:" + proxyPort + "/websocket.html#wss://localhost:" + port;
     }
 }


Mime
View raw message