mirror of https://github.com/apache/activemq.git
fix and tests for: https://issues.apache.org/jira/browse/AMQ-3897
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1355183 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
87b2920927
commit
b7a1883b4b
|
@ -87,5 +87,14 @@ public class StompNIOTransportFactory extends NIOTransportFactory implements Bro
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -65,4 +65,13 @@ public class StompSslTransportFactory extends SslTransportFactory implements Bro
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
|
@ -197,12 +197,12 @@ public class Stomp11Test extends CombinationTestSupport {
|
|||
|
||||
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 CombinationTestSupport {
|
|||
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());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue