Author: tabish
Date: Mon Mar 18 21:07:51 2013
New Revision: 1457996
URL: http://svn.apache.org/r1457996
Log:
fix for: https://issues.apache.org/jira/browse/AMQ-4386
Modified:
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4133Test.java
Modified:
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4133Test.java
URL:
http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4133Test.java?rev=1457996&r1=1457995&r2=1457996&view=diff
==============================================================================
---
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4133Test.java
(original)
+++
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4133Test.java
Mon Mar 18 21:07:51 2013
@@ -16,10 +16,13 @@
*/
package org.apache.activemq.bugs;
-import java.io.File;
import java.net.Socket;
+import javax.net.SocketFactory;
+import javax.net.ssl.SSLSocketFactory;
+
import junit.framework.TestCase;
+
import org.apache.activemq.broker.BrokerFactory;
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.transport.stomp.Stomp;
@@ -29,76 +32,72 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import javax.net.SocketFactory;
-import javax.net.ssl.SSLSocketFactory;
-
public class AMQ4133Test {
-
- protected String java_security_auth_login_config =
"java.security.auth.login.config";
+
+ protected String java_security_auth_login_config =
"java.security.auth.login.config";
protected String xbean = "xbean:";
protected String confBase =
"src/test/resources/org/apache/activemq/bugs/amq4126";
protected String certBase =
"src/test/resources/org/apache/activemq/security";
- protected String sep = File.separator;
protected String activemqXml =
"InconsistentConnectorPropertiesBehaviour.xml";
- protected BrokerService broker;
-
- protected String oldLoginConf = null;
+ protected BrokerService broker;
+
+ protected String oldLoginConf = null;
@Before
public void before() throws Exception {
- if (System.getProperty(java_security_auth_login_config) != null) {
+ if (System.getProperty(java_security_auth_login_config) != null) {
oldLoginConf = System.getProperty(java_security_auth_login_config);
}
- System.setProperty(java_security_auth_login_config, confBase + sep +
"login.config");
- broker = BrokerFactory.createBroker(xbean + confBase + sep +
activemqXml);
-
+ System.setProperty(java_security_auth_login_config, confBase + "/" +
"login.config");
+ broker = BrokerFactory.createBroker(xbean + confBase + "/" +
activemqXml);
+
broker.start();
broker.waitUntilStarted();
}
@After
public void after() throws Exception {
- if (broker != null) {
+ if (broker != null) {
broker.stop();
broker.waitUntilStopped();
}
}
-
+
@Test
public void stompSSLTransportNeedClientAuthTrue() throws Exception {
- stompConnectTo("localhost",
broker.getConnectorByName("stomp+ssl").getConnectUri().getPort());
+ stompConnectTo("localhost",
broker.getConnectorByName("stomp+ssl").getConnectUri().getPort());
}
-
+
@Test
public void stompSSLNeedClientAuthTrue() throws Exception {
- stompConnectTo("localhost",
broker.getConnectorByName("stomp+ssl+special").getConnectUri().getPort());
+ stompConnectTo("localhost",
broker.getConnectorByName("stomp+ssl+special").getConnectUri().getPort());
}
-
+
@Test
public void stompNIOSSLTransportNeedClientAuthTrue() throws Exception {
- stompConnectTo("localhost",
broker.getConnectorByName("stomp+nio+ssl").getConnectUri().getPort());
+ stompConnectTo("localhost",
broker.getConnectorByName("stomp+nio+ssl").getConnectUri().getPort());
}
-
+
@Test
public void stompNIOSSLNeedClientAuthTrue() throws Exception {
- stompConnectTo("localhost",
broker.getConnectorByName("stomp+nio+ssl+special").getConnectUri().getPort());
+ stompConnectTo("localhost",
broker.getConnectorByName("stomp+nio+ssl+special").getConnectUri().getPort());
}
-
+
public Socket createSocket(String host, int port) throws Exception {
- System.setProperty("javax.net.ssl.trustStore", certBase + sep +
"broker1.ks");
+ System.setProperty("javax.net.ssl.trustStore", certBase + "/" +
"broker1.ks");
System.setProperty("javax.net.ssl.trustStorePassword", "password");
System.setProperty("javax.net.ssl.trustStoreType", "jks");
- System.setProperty("javax.net.ssl.keyStore", certBase + sep +
"client.ks");
+ System.setProperty("javax.net.ssl.keyStore", certBase + "/" +
"client.ks");
System.setProperty("javax.net.ssl.keyStorePassword", "password");
System.setProperty("javax.net.ssl.keyStoreType", "jks");
SocketFactory factory = SSLSocketFactory.getDefault();
return factory.createSocket(host, port);
}
-
+
public void stompConnectTo(String host, int port) throws Exception {
- StompConnection stompConnection = new StompConnection();
- stompConnection.open(createSocket(host, port));
+ StompConnection stompConnection = new StompConnection();
+ stompConnection.open(createSocket(host, port));
stompConnection.sendFrame("CONNECT\n" + "\n" + Stomp.NULL);
StompFrame f = stompConnection.receive();
TestCase.assertEquals(f.getBody(), "CONNECTED", f.getAction());