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 2012/06/29 00:20:11 UTC

svn commit: r1355183 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/transport/stomp/ test/java/org/apache/activemq/transport/stomp/

Author: tabish
Date: Thu Jun 28 22:20:09 2012
New Revision: 1355183

URL: http://svn.apache.org/viewvc?rev=1355183&view=rev
Log:
fix and tests for: https://issues.apache.org/jira/browse/AMQ-3897

Added:
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/Stomp11NIOSSLTest.java   (with props)
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/Stomp11NIOTest.java   (with props)
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/Stomp11SslAuthTest.java   (with props)
Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompNIOTransportFactory.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompSslTransportFactory.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/Stomp11Test.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompNIOTransportFactory.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompNIOTransportFactory.java?rev=1355183&r1=1355182&r2=1355183&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompNIOTransportFactory.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompNIOTransportFactory.java Thu Jun 28 22:20:09 2012
@@ -87,5 +87,14 @@ public class StompNIOTransportFactory ex
         this.brokerContext = brokerService.getBrokerContext();
     }
 
+    @Override
+    protected Transport createInactivityMonitor(Transport transport, WireFormat format) {
+        StompInactivityMonitor monitor = new StompInactivityMonitor(transport, format);
+
+        StompTransportFilter filter = (StompTransportFilter) transport.narrow(StompTransportFilter.class);
+        filter.setInactivityMonitor(monitor);
+
+        return monitor;
+    }
 }
 

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompSslTransportFactory.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompSslTransportFactory.java?rev=1355183&r1=1355182&r2=1355183&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompSslTransportFactory.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompSslTransportFactory.java Thu Jun 28 22:20:09 2012
@@ -65,4 +65,13 @@ public class StompSslTransportFactory ex
         this.brokerContext = brokerService.getBrokerContext();
     }
 
+    @Override
+    protected Transport createInactivityMonitor(Transport transport, WireFormat format) {
+        StompInactivityMonitor monitor = new StompInactivityMonitor(transport, format);
+
+        StompTransportFilter filter = (StompTransportFilter) transport.narrow(StompTransportFilter.class);
+        filter.setInactivityMonitor(monitor);
+
+        return monitor;
+    }
 }

Added: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/Stomp11NIOSSLTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/Stomp11NIOSSLTest.java?rev=1355183&view=auto
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/Stomp11NIOSSLTest.java (added)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/Stomp11NIOSSLTest.java Thu Jun 28 22:20:09 2012
@@ -0,0 +1,44 @@
+/**
+ * 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.stomp;
+
+import java.io.IOException;
+import java.net.Socket;
+import java.net.URI;
+
+import javax.net.SocketFactory;
+import javax.net.ssl.SSLSocketFactory;
+
+public class Stomp11NIOSSLTest extends Stomp11Test {
+
+    protected void setUp() throws Exception {
+        bindAddress = "stomp+nio+ssl://localhost:61613";
+        confUri = "xbean:org/apache/activemq/transport/stomp/sslstomp-auth-broker.xml";
+        System.setProperty("javax.net.ssl.trustStore", "src/test/resources/client.keystore");
+        System.setProperty("javax.net.ssl.trustStorePassword", "password");
+        System.setProperty("javax.net.ssl.trustStoreType", "jks");
+        System.setProperty("javax.net.ssl.keyStore", "src/test/resources/server.keystore");
+        System.setProperty("javax.net.ssl.keyStorePassword", "password");
+        System.setProperty("javax.net.ssl.keyStoreType", "jks");
+        super.setUp();
+    }
+
+    protected Socket createSocket(URI connectUri) throws IOException {
+        SocketFactory factory = SSLSocketFactory.getDefault();
+        return factory.createSocket("127.0.0.1", connectUri.getPort());
+    }
+}

Propchange: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/Stomp11NIOSSLTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/Stomp11NIOTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/Stomp11NIOTest.java?rev=1355183&view=auto
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/Stomp11NIOTest.java (added)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/Stomp11NIOTest.java Thu Jun 28 22:20:09 2012
@@ -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.stomp;
+
+public class Stomp11NIOTest extends Stomp11Test {
+
+    @Override
+    protected void setUp() throws Exception {
+        bindAddress = "stomp+nio://localhost:61612";
+        confUri = "xbean:org/apache/activemq/transport/stomp/niostomp-auth-broker.xml";
+        super.setUp();
+    }
+}

Propchange: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/Stomp11NIOTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/Stomp11SslAuthTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/Stomp11SslAuthTest.java?rev=1355183&view=auto
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/Stomp11SslAuthTest.java (added)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/Stomp11SslAuthTest.java Thu Jun 28 22:20:09 2012
@@ -0,0 +1,56 @@
+/**
+ * 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.stomp;
+
+import java.io.IOException;
+import java.net.Socket;
+import java.net.URI;
+
+import javax.net.SocketFactory;
+import javax.net.ssl.SSLSocketFactory;
+
+
+
+/**
+ *
+ */
+public class Stomp11SslAuthTest extends Stomp11Test {
+
+
+    protected void setUp() throws Exception {
+
+        // Test mutual authentication on both stomp and standard ssl transports
+        bindAddress = "stomp+ssl://localhost:61612";
+        confUri = "xbean:org/apache/activemq/transport/stomp/sslstomp-mutual-auth-broker.xml";
+        jmsUri="ssl://localhost:61617";
+
+        System.setProperty("javax.net.ssl.trustStore", "src/test/resources/client.keystore");
+        System.setProperty("javax.net.ssl.trustStorePassword", "password");
+        System.setProperty("javax.net.ssl.trustStoreType", "jks");
+        System.setProperty("javax.net.ssl.keyStore", "src/test/resources/server.keystore");
+        System.setProperty("javax.net.ssl.keyStorePassword", "password");
+        System.setProperty("javax.net.ssl.keyStoreType", "jks");
+        //System.setProperty("javax.net.debug","ssl,handshake");
+        super.setUp();
+    }
+
+    protected Socket createSocket(URI connectUri) throws IOException {
+        SocketFactory factory = SSLSocketFactory.getDefault();
+        return factory.createSocket("127.0.0.1", connectUri.getPort());
+    }
+
+}

Propchange: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/Stomp11SslAuthTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/Stomp11Test.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/Stomp11Test.java?rev=1355183&r1=1355182&r2=1355183&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/Stomp11Test.java (original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/Stomp11Test.java Thu Jun 28 22:20:09 2012
@@ -197,12 +197,12 @@ public class Stomp11Test extends Combina
 
         stompConnection.sendFrame(connectFrame);
         String f = stompConnection.receiveFrame();
-        assertTrue(f.startsWith("CONNECTED"));
-        assertTrue(f.indexOf("version:1.1") >= 0);
-        assertTrue(f.indexOf("heart-beat:") >= 0);
-        assertTrue(f.indexOf("session:") >= 0);
+        assertTrue("Failed to receive a connected frame.", f.startsWith("CONNECTED"));
+        assertTrue("Frame should have a versoion 1.1 header.", f.indexOf("version:1.1") >= 0);
+        assertTrue("Frame should have a heart beat header.", f.indexOf("heart-beat:") >= 0);
+        assertTrue("Frame should have a session header.", f.indexOf("session:") >= 0);
 
-        LOG.debug("Broker sent: " + f);
+        LOG.info("Broker sent: " + f);
 
         stompConnection.getStompSocket().getOutputStream().write('\n');
 
@@ -278,11 +278,13 @@ public class Stomp11Test extends Combina
         Thread.sleep(TimeUnit.SECONDS.toMillis(10));
 
         try {
-            String message = "SEND\n" + "destination:/queue/" + getQueueName() + "\n\n" + "Hello World" + Stomp.NULL;
+            String message = "SEND\n" + "destination:/queue/" + getQueueName() + "\n" +
+                             "receipt:1\n\n" + "Hello World" + Stomp.NULL;
             stompConnection.sendFrame(message);
+            stompConnection.receiveFrame();
             fail("SEND frame has been accepted after missing heart beat");
         } catch (Exception ex) {
-            System.out.println(ex.getMessage());
+            LOG.info(ex.getMessage());
         }
     }