You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2014/08/18 23:37:41 UTC

git commit: https://issues.apache.org/jira/browse/AMQ-5237

Repository: activemq
Updated Branches:
  refs/heads/trunk 6e9ecdfe2 -> 3aec42db4


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

Ensure that the allowLinkStealing option gets applied to the
WebTransportServer

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

Branch: refs/heads/trunk
Commit: 3aec42db4f5b360c35959c8b555f1ecf8cda34bf
Parents: 6e9ecdf
Author: Timothy Bish <ta...@gmail.com>
Authored: Mon Aug 18 17:37:35 2014 -0400
Committer: Timothy Bish <ta...@gmail.com>
Committed: Mon Aug 18 17:37:35 2014 -0400

----------------------------------------------------------------------
 .../transport/ws/WSTransportFactory.java        |  6 +-
 .../transport/wss/WSSTransportFactory.java      |  5 +-
 .../ws/WSTransportLinkStealingTest.java         | 95 ++++++++++++++++++++
 .../wss/WSSTransportLinkStealingTest.java       | 27 ++++++
 4 files changed, 127 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/3aec42db/activemq-http/src/main/java/org/apache/activemq/transport/ws/WSTransportFactory.java
----------------------------------------------------------------------
diff --git a/activemq-http/src/main/java/org/apache/activemq/transport/ws/WSTransportFactory.java b/activemq-http/src/main/java/org/apache/activemq/transport/ws/WSTransportFactory.java
index c57e931..f3503ee 100644
--- a/activemq-http/src/main/java/org/apache/activemq/transport/ws/WSTransportFactory.java
+++ b/activemq-http/src/main/java/org/apache/activemq/transport/ws/WSTransportFactory.java
@@ -28,23 +28,23 @@ import org.apache.activemq.transport.TransportServer;
 import org.apache.activemq.util.IOExceptionSupport;
 import org.apache.activemq.util.IntrospectionSupport;
 import org.apache.activemq.util.URISupport;
+
 /**
- * 
  * Factory for WebSocket (ws) transport
- *
  */
 public class WSTransportFactory extends TransportFactory {
 
+    @Override
     public TransportServer doBind(URI location) throws IOException {
         try {
             Map<String, String> options = new HashMap<String, String>(URISupport.parseParameters(location));
             WSTransportServer result = new WSTransportServer(location);
             Map<String, Object> transportOptions = IntrospectionSupport.extractProperties(options, "");
+            IntrospectionSupport.setProperties(result, transportOptions);
             result.setTransportOption(transportOptions);
             return result;
         } catch (URISyntaxException e) {
             throw IOExceptionSupport.create(e);
         }
     }
-
 }

http://git-wip-us.apache.org/repos/asf/activemq/blob/3aec42db/activemq-http/src/main/java/org/apache/activemq/transport/wss/WSSTransportFactory.java
----------------------------------------------------------------------
diff --git a/activemq-http/src/main/java/org/apache/activemq/transport/wss/WSSTransportFactory.java b/activemq-http/src/main/java/org/apache/activemq/transport/wss/WSSTransportFactory.java
index 64935ce..ff19714 100644
--- a/activemq-http/src/main/java/org/apache/activemq/transport/wss/WSSTransportFactory.java
+++ b/activemq-http/src/main/java/org/apache/activemq/transport/wss/WSSTransportFactory.java
@@ -30,22 +30,21 @@ import org.apache.activemq.util.IntrospectionSupport;
 import org.apache.activemq.util.URISupport;
 
 /**
- *
  * Factory for Secure WebSocket (wss) transport
- *
  */
 public class WSSTransportFactory extends TransportFactory {
 
+    @Override
     public TransportServer doBind(URI location) throws IOException {
         try {
             Map<String, String> options = new HashMap<String, String>(URISupport.parseParameters(location));
             WSSTransportServer result = new WSSTransportServer(location, SslContext.getCurrentSslContext());
             Map<String, Object> transportOptions = IntrospectionSupport.extractProperties(options, "");
+            IntrospectionSupport.setProperties(result, transportOptions);
             result.setTransportOption(transportOptions);
             return result;
         } catch (URISyntaxException e) {
             throw IOExceptionSupport.create(e);
         }
     }
-
 }

http://git-wip-us.apache.org/repos/asf/activemq/blob/3aec42db/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
new file mode 100644
index 0000000..bd5770c
--- /dev/null
+++ b/activemq-http/src/test/java/org/apache/activemq/transport/ws/WSTransportLinkStealingTest.java
@@ -0,0 +1,95 @@
+/**
+ * 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.activemq.transport.ws;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.net.URI;
+
+import org.apache.activemq.broker.BrokerFactory;
+import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.broker.TransportConnector;
+import org.apache.activemq.spring.SpringSslContext;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class WSTransportLinkStealingTest {
+
+    private static final Logger LOG = LoggerFactory.getLogger(WSTransportLinkStealingTest.class);
+
+    private BrokerService broker;
+
+    protected BrokerService createBroker(boolean deleteMessages) throws Exception {
+        BrokerService broker = BrokerFactory.createBroker(
+                new URI("broker:()/localhost?persistent=false&useJmx=false"));
+
+        SpringSslContext context = new SpringSslContext();
+        context.setKeyStore("src/test/resources/server.keystore");
+        context.setKeyStoreKeyPassword("password");
+        context.setTrustStore("src/test/resources/client.keystore");
+        context.setTrustStorePassword("password");
+        context.afterPropertiesSet();
+        broker.setSslContext(context);
+
+        broker.addConnector(getWSConnectorURI()).setName("ws+mqtt");;
+        broker.setDeleteAllMessagesOnStartup(deleteMessages);
+        broker.start();
+        broker.waitUntilStarted();
+
+        return broker;
+    }
+
+    protected String getWSConnectorURI() {
+        return "ws://127.0.0.1:61623?allowLinkStealing=true&websocket.maxTextMessageSize=99999&transport.maxIdleTime=1001";
+    }
+
+    protected void stopBroker() {
+        try {
+            if (broker != null) {
+                broker.stop();
+                broker.waitUntilStopped();
+                broker = null;
+            }
+        } catch (Exception e) {
+            LOG.warn("Error during Broker stop");
+        }
+    }
+
+    @Before
+    public void setUp() throws Exception {
+        broker = createBroker(true);
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        stopBroker();
+    }
+
+    @Test
+    public void testBrokerStart() throws Exception {
+        assertTrue(broker.isStarted());
+
+        TransportConnector connector = broker.getTransportConnectorByName("ws+mqtt");
+        assertNotNull("Should have an WS transport", connector);
+        assertTrue(connector.isAllowLinkStealing());
+    }
+}

http://git-wip-us.apache.org/repos/asf/activemq/blob/3aec42db/activemq-http/src/test/java/org/apache/activemq/transport/wss/WSSTransportLinkStealingTest.java
----------------------------------------------------------------------
diff --git a/activemq-http/src/test/java/org/apache/activemq/transport/wss/WSSTransportLinkStealingTest.java b/activemq-http/src/test/java/org/apache/activemq/transport/wss/WSSTransportLinkStealingTest.java
new file mode 100644
index 0000000..dfa9a79
--- /dev/null
+++ b/activemq-http/src/test/java/org/apache/activemq/transport/wss/WSSTransportLinkStealingTest.java
@@ -0,0 +1,27 @@
+/**
+ * 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.activemq.transport.wss;
+
+import org.apache.activemq.transport.ws.WSTransportLinkStealingTest;
+
+public class WSSTransportLinkStealingTest extends WSTransportLinkStealingTest {
+
+    @Override
+    protected String getWSConnectorURI() {
+        return "wss://localhost:61623?allowLinkStealing=true";
+    }
+}