activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject [1/2] activemq git commit: https://issues.apache.org/jira/browse/AMQ-5621
Date Thu, 09 Jul 2015 21:35:50 GMT
Repository: activemq
Updated Branches:
  refs/heads/master 257a79de0 -> ba1bd264d


http://git-wip-us.apache.org/repos/asf/activemq/blob/ba1bd264/activemq-ra/src/test/java/org/apache/activemq/ra/SSLTest.java
----------------------------------------------------------------------
diff --git a/activemq-ra/src/test/java/org/apache/activemq/ra/SSLTest.java b/activemq-ra/src/test/java/org/apache/activemq/ra/SSLTest.java
index 042c09e..cdfa044 100644
--- a/activemq-ra/src/test/java/org/apache/activemq/ra/SSLTest.java
+++ b/activemq-ra/src/test/java/org/apache/activemq/ra/SSLTest.java
@@ -16,17 +16,20 @@
  */
 package org.apache.activemq.ra;
 
-import junit.framework.TestCase;
-import org.apache.activemq.ActiveMQSslConnectionFactory;
-import org.apache.activemq.advisory.AdvisorySupport;
-import org.apache.activemq.broker.SslBrokerService;
-import org.apache.activemq.broker.SslContext;
-import org.apache.activemq.broker.TransportConnector;
-import org.apache.activemq.command.ActiveMQMessage;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.command.ConsumerInfo;
-import org.apache.activemq.transport.TransportFactory;
-import org.apache.activemq.transport.tcp.SslTransportFactory;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.security.KeyStore;
+import java.util.Timer;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
 
 import javax.jms.Connection;
 import javax.jms.Message;
@@ -38,7 +41,6 @@ import javax.jms.Session;
 import javax.net.ssl.KeyManager;
 import javax.net.ssl.KeyManagerFactory;
 import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLSession;
 import javax.net.ssl.SSLSocket;
 import javax.net.ssl.TrustManager;
 import javax.net.ssl.TrustManagerFactory;
@@ -55,40 +57,43 @@ import javax.resource.spi.work.WorkListener;
 import javax.resource.spi.work.WorkManager;
 import javax.transaction.xa.XAResource;
 import javax.transaction.xa.Xid;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.lang.reflect.Method;
-import java.net.SocketException;
-import java.net.UnknownHostException;
-import java.security.KeyStore;
-import java.util.Timer;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
 
-public class SSLTest extends TestCase {
-    public static final String KEYSTORE_TYPE = "jks";
-    public static final String PASSWORD = "password";
-    public static final String SERVER_KEYSTORE = "src/test/resources/server.keystore";
-    public static final String TRUST_KEYSTORE = "src/test/resources/client.keystore";
+import org.apache.activemq.ActiveMQSslConnectionFactory;
+import org.apache.activemq.advisory.AdvisorySupport;
+import org.apache.activemq.broker.SslBrokerService;
+import org.apache.activemq.broker.SslContext;
+import org.apache.activemq.broker.TransportConnector;
+import org.apache.activemq.command.ActiveMQMessage;
+import org.apache.activemq.command.ActiveMQQueue;
+import org.apache.activemq.command.ConsumerInfo;
+import org.apache.activemq.transport.TransportFactory;
+import org.apache.activemq.transport.tcp.SslTransportFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
 
-    long txGenerator = System.currentTimeMillis();
+public class SSLTest {
+
+    private static final String KEYSTORE_TYPE = "jks";
+    private static final String PASSWORD = "password";
+    private static final String SERVER_KEYSTORE = "src/test/resources/server.keystore";
+    private static final String TRUST_KEYSTORE = "src/test/resources/client.keystore";
+    private static final String KAHADB_DIRECTORY = "target/activemq-data/";
 
     private static final String BIND_ADDRESS = "ssl://0.0.0.0:61616";
 
-    private SslBrokerService broker;
+    private long txGenerator = System.currentTimeMillis();
 
+    private SslBrokerService broker;
     private TransportConnector connector;
 
-    @Override
-    protected void setUp() throws Exception {
+    @Before
+    public void setUp() throws Exception {
         createAndStartBroker();
     }
 
-    @Override
-    protected void tearDown() throws Exception {
+    @After
+    public void tearDown() throws Exception {
         if (broker != null) {
             broker.stop();
         }
@@ -99,11 +104,13 @@ public class SSLTest extends TestCase {
         broker.setDeleteAllMessagesOnStartup(true);
         broker.setUseJmx(false);
         broker.setBrokerName("BROKER");
+        broker.setDataDirectory(KAHADB_DIRECTORY);
         KeyManager[] km = getKeyManager();
         TrustManager[] tm = getTrustManager();
         connector = broker.addSslConnector(BIND_ADDRESS, km, tm, null);
         broker.start();
         broker.waitUntilStarted();     // for client side
+
         SslTransportFactory sslFactory = new SslTransportFactory();
         SslContext ctx = new SslContext(km, tm, null);
         SslContext.setCurrentSslContext(ctx);
@@ -111,40 +118,49 @@ public class SSLTest extends TestCase {
     }
 
     private static final class StubBootstrapContext implements BootstrapContext {
+        @Override
         public WorkManager getWorkManager() {
             return new WorkManager() {
+                @Override
                 public void doWork(Work work) throws WorkException {
                     new Thread(work).start();
                 }
 
+                @Override
                 public void doWork(Work work, long arg1, ExecutionContext arg2, WorkListener
arg3) throws WorkException {
                     new Thread(work).start();
                 }
 
+                @Override
                 public long startWork(Work work) throws WorkException {
                     new Thread(work).start();
                     return 0;
                 }
 
+                @Override
                 public long startWork(Work work, long arg1, ExecutionContext arg2, WorkListener
arg3) throws WorkException {
                     new Thread(work).start();
                     return 0;
                 }
 
+                @Override
                 public void scheduleWork(Work work) throws WorkException {
                     new Thread(work).start();
                 }
 
+                @Override
                 public void scheduleWork(Work work, long arg1, ExecutionContext arg2, WorkListener
arg3) throws WorkException {
                     new Thread(work).start();
                 }
             };
         }
 
+        @Override
         public XATerminator getXATerminator() {
             return null;
         }
 
+        @Override
         public Timer createTimer() throws UnavailableException {
             return null;
         }
@@ -155,6 +171,7 @@ public class SSLTest extends TestCase {
         public XAResource xaresource;
         public Xid xid;
 
+        @Override
         public void beforeDelivery(Method method) throws NoSuchMethodException, ResourceException
{
             try {
                 if (xid == null) {
@@ -166,6 +183,7 @@ public class SSLTest extends TestCase {
             }
         }
 
+        @Override
         public void afterDelivery() throws ResourceException {
             try {
                 xaresource.end(xid, 0);
@@ -176,15 +194,17 @@ public class SSLTest extends TestCase {
             }
         }
 
+        @Override
         public void release() {
         }
 
+        @Override
         public void onMessage(Message message) {
             messageCount++;
         }
-
     }
 
+    @Test(timeout = 60000)
     public void testMessageDeliveryUsingSSLTruststoreOnly() throws Exception {
         SSLContext context = SSLContext.getInstance("TLS");
         context.init(getKeyManager(), getTrustManager(), null);
@@ -208,12 +228,11 @@ public class SSLTest extends TestCase {
         final CountDownLatch messageDelivered = new CountDownLatch(1);
 
         final StubMessageEndpoint endpoint = new StubMessageEndpoint() {
+            @Override
             public void onMessage(Message message) {
                 super.onMessage(message);
                 messageDelivered.countDown();
             }
-
-            ;
         };
 
         ActiveMQActivationSpec activationSpec = new ActiveMQActivationSpec();
@@ -223,11 +242,13 @@ public class SSLTest extends TestCase {
         activationSpec.validate();
 
         MessageEndpointFactory messageEndpointFactory = new MessageEndpointFactory() {
+            @Override
             public MessageEndpoint createEndpoint(XAResource resource) throws UnavailableException
{
                 endpoint.xaresource = resource;
                 return endpoint;
             }
 
+            @Override
             public boolean isDeliveryTransacted(Method method) throws NoSuchMethodException
{
                 return true;
             }
@@ -255,9 +276,9 @@ public class SSLTest extends TestCase {
         // Shut the Endpoint down.
         adapter.endpointDeactivation(messageEndpointFactory, activationSpec);
         adapter.stop();
-
     }
 
+    @Test(timeout = 60000)
     public void testMessageDeliveryUsingSSLTruststoreAndKeystore() throws Exception {
         SSLContext context = SSLContext.getInstance("TLS");
         context.init(getKeyManager(), getTrustManager(), null);
@@ -285,12 +306,11 @@ public class SSLTest extends TestCase {
         final CountDownLatch messageDelivered = new CountDownLatch(1);
 
         final StubMessageEndpoint endpoint = new StubMessageEndpoint() {
+            @Override
             public void onMessage(Message message) {
                 super.onMessage(message);
                 messageDelivered.countDown();
             }
-
-            ;
         };
 
         ActiveMQActivationSpec activationSpec = new ActiveMQActivationSpec();
@@ -300,11 +320,13 @@ public class SSLTest extends TestCase {
         activationSpec.validate();
 
         MessageEndpointFactory messageEndpointFactory = new MessageEndpointFactory() {
+            @Override
             public MessageEndpoint createEndpoint(XAResource resource) throws UnavailableException
{
                 endpoint.xaresource = resource;
                 return endpoint;
             }
 
+            @Override
             public boolean isDeliveryTransacted(Method method) throws NoSuchMethodException
{
                 return true;
             }
@@ -332,9 +354,9 @@ public class SSLTest extends TestCase {
         // Shut the Endpoint down.
         adapter.endpointDeactivation(messageEndpointFactory, activationSpec);
         adapter.stop();
+    }
 
-        }
-
+    @Test(timeout = 60000)
     public void testMessageDeliveryUsingSSLTruststoreAndKeystoreOverrides() throws Exception
{
         SSLContext context = SSLContext.getInstance("TLS");
         context.init(getKeyManager(), getTrustManager(), null);
@@ -358,12 +380,11 @@ public class SSLTest extends TestCase {
         final CountDownLatch messageDelivered = new CountDownLatch(1);
 
         final StubMessageEndpoint endpoint = new StubMessageEndpoint() {
+            @Override
             public void onMessage(Message message) {
                 super.onMessage(message);
                 messageDelivered.countDown();
             }
-
-            ;
         };
 
         ActiveMQActivationSpec activationSpec = new ActiveMQActivationSpec();
@@ -377,11 +398,13 @@ public class SSLTest extends TestCase {
         activationSpec.validate();
 
         MessageEndpointFactory messageEndpointFactory = new MessageEndpointFactory() {
+            @Override
             public MessageEndpoint createEndpoint(XAResource resource) throws UnavailableException
{
                 endpoint.xaresource = resource;
                 return endpoint;
             }
 
+            @Override
             public boolean isDeliveryTransacted(Method method) throws NoSuchMethodException
{
                 return true;
             }
@@ -409,10 +432,8 @@ public class SSLTest extends TestCase {
         // Shut the Endpoint down.
         adapter.endpointDeactivation(messageEndpointFactory, activationSpec);
         adapter.stop();
-
     }
 
-
     public Xid createXid() throws IOException {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         DataOutputStream os = new DataOutputStream(baos);
@@ -421,19 +442,21 @@ public class SSLTest extends TestCase {
         final byte[] bs = baos.toByteArray();
 
         return new Xid() {
+            @Override
             public int getFormatId() {
                 return 86;
             }
 
+            @Override
             public byte[] getGlobalTransactionId() {
                 return bs;
             }
 
+            @Override
             public byte[] getBranchQualifier() {
                 return bs;
             }
         };
-
     }
 
     public static TrustManager[] getTrustManager() throws Exception {
@@ -457,7 +480,6 @@ public class SSLTest extends TestCase {
 
         byte[] sslCert = loadClientCredential(SERVER_KEYSTORE);
 
-
         if (sslCert != null && sslCert.length > 0) {
             ByteArrayInputStream bin = new ByteArrayInputStream(sslCert);
             ks.load(bin, PASSWORD.toCharArray());
@@ -471,28 +493,30 @@ public class SSLTest extends TestCase {
         if (fileName == null) {
             return null;
         }
+
         FileInputStream in = new FileInputStream(fileName);
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         byte[] buf = new byte[512];
         int i = in.read(buf);
+
         while (i > 0) {
             out.write(buf, 0, i);
             i = in.read(buf);
         }
+
         in.close();
         return out.toByteArray();
     }
 
-    private void makeSSLConnection(SSLContext context, String enabledSuites[], TransportConnector
connector) throws Exception,
-            UnknownHostException, SocketException {
+    private void makeSSLConnection(SSLContext context, String enabledSuites[], TransportConnector
connector) throws Exception {
         SSLSocket sslSocket = (SSLSocket) context.getSocketFactory().createSocket("localhost",
connector.getUri().getPort());
 
         if (enabledSuites != null) {
             sslSocket.setEnabledCipherSuites(enabledSuites);
         }
-        sslSocket.setSoTimeout(5000);
 
-        SSLSession session = sslSocket.getSession();
+        sslSocket.setSoTimeout(5000);
+        sslSocket.getSession();
         sslSocket.startHandshake();
     }
 }

http://git-wip-us.apache.org/repos/asf/activemq/blob/ba1bd264/activemq-ra/src/test/java/org/apache/activemq/ra/ServerSessionImplTest.java
----------------------------------------------------------------------
diff --git a/activemq-ra/src/test/java/org/apache/activemq/ra/ServerSessionImplTest.java b/activemq-ra/src/test/java/org/apache/activemq/ra/ServerSessionImplTest.java
index 9323d7b..322defc 100644
--- a/activemq-ra/src/test/java/org/apache/activemq/ra/ServerSessionImplTest.java
+++ b/activemq-ra/src/test/java/org/apache/activemq/ra/ServerSessionImplTest.java
@@ -16,11 +16,14 @@
  */
 package org.apache.activemq.ra;
 
+import static org.junit.Assert.assertTrue;
+
 import java.lang.reflect.Method;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
+
 import javax.jms.Session;
 import javax.resource.spi.BootstrapContext;
 import javax.resource.spi.endpoint.MessageEndpointFactory;
@@ -28,9 +31,7 @@ import javax.resource.spi.work.ExecutionContext;
 import javax.resource.spi.work.Work;
 import javax.resource.spi.work.WorkListener;
 import javax.resource.spi.work.WorkManager;
-
 import javax.transaction.xa.XAResource;
-import junit.framework.TestCase;
 
 import org.apache.activemq.ActiveMQConnection;
 import org.apache.activemq.ActiveMQSession;
@@ -54,31 +55,30 @@ import org.junit.runner.RunWith;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-/**
- * 
- */
 @RunWith(JMock.class)
-public class ServerSessionImplTest extends TestCase {
+public class ServerSessionImplTest {
+
     private static final Logger LOG = LoggerFactory.getLogger(ServerSessionImplTest.class);
     private static final String BROKER_URL = "vm://localhost?broker.persistent=false";
+
     private ServerSessionImpl serverSession;
     private ServerSessionPoolImpl pool;
     private WorkManager workManager;
     private MessageEndpointProxy messageEndpoint;
     private ActiveMQConnection con;
     private ActiveMQSession session;
-    ActiveMQEndpointWorker endpointWorker;
+    private ActiveMQEndpointWorker endpointWorker;
     private Mockery context;
+
     @Before
-    public void setUp() throws Exception
-    {
-        super.setUp();
-        context = new Mockery() {{
-            setImposteriser(ClassImposteriser.INSTANCE);
-        }};
-        
-        org.apache.activemq.ActiveMQConnectionFactory factory = 
-                new org.apache.activemq.ActiveMQConnectionFactory(BROKER_URL);
+    public void setUp() throws Exception {
+        context = new Mockery() {
+            {
+                setImposteriser(ClassImposteriser.INSTANCE);
+            }
+        };
+
+        org.apache.activemq.ActiveMQConnectionFactory factory = new org.apache.activemq.ActiveMQConnectionFactory(BROKER_URL);
         con = (ActiveMQConnection) factory.createConnection();
         con.start();
         session = (ActiveMQSession) con.createSession(false, Session.AUTO_ACKNOWLEDGE);
@@ -98,18 +98,14 @@ public class ServerSessionImplTest extends TestCase {
         workManager = context.mock(WorkManager.class);
         messageEndpoint = context.mock(MessageEndpointProxy.class);
 
-        serverSession = new ServerSessionImpl(
-                (ServerSessionPoolImpl) pool,
-                session,
-                (WorkManager) workManager,
-                messageEndpoint,
-                false,
-                10);
+        serverSession = new ServerSessionImpl(pool, session, workManager, messageEndpoint,
false, 10);
 
         con.close();
-        context.checking(new Expectations() {{
-            oneOf (pool).removeFromPool(with(same(serverSession)));
-        }});
+        context.checking(new Expectations() {
+            {
+                oneOf(pool).removeFromPool(with(same(serverSession)));
+            }
+        });
         serverSession.run();
     }
 
@@ -126,53 +122,70 @@ public class ServerSessionImplTest extends TestCase {
         workManager = context.mock(WorkManager.class);
         final MessageActivationSpec messageActivationSpec = context.mock(MessageActivationSpec.class);
         final BootstrapContext boostrapContext = context.mock(BootstrapContext.class);
-        context.checking(new Expectations() {{
-            allowing(boostrapContext).getWorkManager(); will (returnValue(workManager));
-            allowing(resourceAdapter).getBootstrapContext(); will (returnValue(boostrapContext));
-            allowing(messageEndpointFactory).isDeliveryTransacted(with (any(Method.class)));
will(returnValue(Boolean.FALSE));
-            allowing(key).getMessageEndpointFactory();  will(returnValue(messageEndpointFactory));
-            allowing(key).getActivationSpec(); will (returnValue(messageActivationSpec));
-            allowing(messageActivationSpec).isUseJndi(); will (returnValue(Boolean.FALSE));
-            allowing(messageActivationSpec).getDestinationType(); will (returnValue("javax.jms.Queue"));
-            allowing(messageActivationSpec).getDestination(); will (returnValue("Queue"));
-            allowing(messageActivationSpec).getAcknowledgeModeForSession(); will (returnValue(1));
-            allowing(messageActivationSpec).getMaxSessionsIntValue(); will (returnValue(1));
-            allowing(messageActivationSpec).getEnableBatchBooleanValue(); will (returnValue(Boolean.FALSE));
-            allowing(messageActivationSpec).isUseRAManagedTransactionEnabled(); will (returnValue(Boolean.TRUE));
-            allowing(messageEndpointFactory).createEndpoint(with (any(XAResource.class)));
will (returnValue(messageEndpoint));
-
-            allowing(workManager).scheduleWork((Work) with(anything()), (long) with(any(long.class)),
with(any(ExecutionContext.class)), with(any(WorkListener.class)));
-            will (new Action() {
-                @Override
-                public Object invoke(Invocation invocation) throws Throwable {
-                    return null;
-                }
+        context.checking(new Expectations() {
+            {
+                allowing(boostrapContext).getWorkManager();
+                will(returnValue(workManager));
+                allowing(resourceAdapter).getBootstrapContext();
+                will(returnValue(boostrapContext));
+                allowing(messageEndpointFactory).isDeliveryTransacted(with(any(Method.class)));
+                will(returnValue(Boolean.FALSE));
+                allowing(key).getMessageEndpointFactory();
+                will(returnValue(messageEndpointFactory));
+                allowing(key).getActivationSpec();
+                will(returnValue(messageActivationSpec));
+                allowing(messageActivationSpec).isUseJndi();
+                will(returnValue(Boolean.FALSE));
+                allowing(messageActivationSpec).getDestinationType();
+                will(returnValue("javax.jms.Queue"));
+                allowing(messageActivationSpec).getDestination();
+                will(returnValue("Queue"));
+                allowing(messageActivationSpec).getAcknowledgeModeForSession();
+                will(returnValue(1));
+                allowing(messageActivationSpec).getMaxSessionsIntValue();
+                will(returnValue(1));
+                allowing(messageActivationSpec).getEnableBatchBooleanValue();
+                will(returnValue(Boolean.FALSE));
+                allowing(messageActivationSpec).isUseRAManagedTransactionEnabled();
+                will(returnValue(Boolean.TRUE));
+                allowing(messageEndpointFactory).createEndpoint(with(any(XAResource.class)));
+                will(returnValue(messageEndpoint));
+
+                allowing(workManager).scheduleWork((Work) with(anything()), with(any(long.class)),
with(any(ExecutionContext.class)),
+                    with(any(WorkListener.class)));
+                will(new Action() {
+                    @Override
+                    public Object invoke(Invocation invocation) throws Throwable {
+                        return null;
+                    }
 
-                @Override
-                public void describeTo(Description description) {
-                }
-            });
-
-            allowing(messageEndpoint).beforeDelivery((Method) with(anything()));
-            allowing (messageEndpoint).onMessage(with (any(javax.jms.Message.class))); will(new
Action(){
-                @Override
-                public Object invoke(Invocation invocation) throws Throwable {
-                    messageCount.countDown();
-                    if (messageCount.getCount() < maxMessages - 11) {
-                        TimeUnit.MILLISECONDS.sleep(200);
+                    @Override
+                    public void describeTo(Description description) {
+                    }
+                });
+
+                allowing(messageEndpoint).beforeDelivery((Method) with(anything()));
+                allowing(messageEndpoint).onMessage(with(any(javax.jms.Message.class)));
+                will(new Action() {
+                    @Override
+                    public Object invoke(Invocation invocation) throws Throwable {
+                        messageCount.countDown();
+                        if (messageCount.getCount() < maxMessages - 11) {
+                            TimeUnit.MILLISECONDS.sleep(200);
+                        }
+                        return null;
                     }
-                    return null;
-                }
 
-                @Override
-                public void describeTo(Description description) {
-                    description.appendText("Keep message count");
-                }
-            });
-            allowing(messageEndpoint).afterDelivery();
-            allowing(messageEndpoint).release();
+                    @Override
+                    public void describeTo(Description description) {
+                        description.appendText("Keep message count");
+                    }
+                });
+                allowing(messageEndpoint).afterDelivery();
+                allowing(messageEndpoint).release();
 
-        }});
+            }
+        });
 
         endpointWorker = new ActiveMQEndpointWorker(resourceAdapter, key);
         endpointWorker.setConnection(con);
@@ -183,8 +196,8 @@ public class ServerSessionImplTest extends TestCase {
 
         // preload the session dispatch queue to keep the session active
         ActiveMQSession session1 = (ActiveMQSession) serverSession1.getSession();
-        for (int i=0; i<maxMessages; i++) {
-            MessageDispatch messageDispatch = new  MessageDispatch();
+        for (int i = 0; i < maxMessages; i++) {
+            MessageDispatch messageDispatch = new MessageDispatch();
             ActiveMQMessage message = new ActiveMQTextMessage();
             message.setMessageId(new MessageId("0:0:0:" + i));
             message.getMessageId().setBrokerSequenceId(i);
@@ -195,7 +208,7 @@ public class ServerSessionImplTest extends TestCase {
 
         ExecutorService executorService = Executors.newCachedThreadPool();
         final CountDownLatch runState = new CountDownLatch(1);
-        executorService.execute(new Runnable(){
+        executorService.execute(new Runnable() {
             @Override
             public void run() {
                 try {

http://git-wip-us.apache.org/repos/asf/activemq/blob/ba1bd264/activemq-ra/src/test/java/org/apache/activemq/ra/UnsubscribeResubscribeTest.java
----------------------------------------------------------------------
diff --git a/activemq-ra/src/test/java/org/apache/activemq/ra/UnsubscribeResubscribeTest.java
b/activemq-ra/src/test/java/org/apache/activemq/ra/UnsubscribeResubscribeTest.java
index 56aa45f..60e8cda 100644
--- a/activemq-ra/src/test/java/org/apache/activemq/ra/UnsubscribeResubscribeTest.java
+++ b/activemq-ra/src/test/java/org/apache/activemq/ra/UnsubscribeResubscribeTest.java
@@ -16,6 +16,8 @@
  */
 package org.apache.activemq.ra;
 
+import static org.junit.Assert.assertNotNull;
+
 import javax.jms.ConnectionFactory;
 import javax.jms.JMSException;
 import javax.jms.Message;
@@ -26,13 +28,11 @@ import javax.jms.TopicSubscriber;
 import javax.resource.ResourceException;
 import javax.transaction.xa.XAException;
 
-import junit.framework.TestCase;
 import org.apache.activemq.ActiveMQConnectionFactory;
+import org.junit.Before;
+import org.junit.Test;
 
-/**
- * 
- */
-public class UnsubscribeResubscribeTest extends TestCase {
+public class UnsubscribeResubscribeTest {
 
     private static final String DEFAULT_HOST = "vm://localhost?broker.persistent=false";
 
@@ -42,17 +42,13 @@ public class UnsubscribeResubscribeTest extends TestCase {
     private ManagedConnectionProxy connection;
     private ActiveMQManagedConnection managedConnection;
 
-    /**
-     * @see junit.framework.TestCase#setUp()
-     */
-    protected void setUp() throws Exception {
-
+    @Before
+    public void setUp() throws Exception {
         managedConnectionFactory = new ActiveMQManagedConnectionFactory();
         managedConnectionFactory.setServerUrl(DEFAULT_HOST);
         managedConnectionFactory.setUserName(ActiveMQConnectionFactory.DEFAULT_USER);
         managedConnectionFactory.setPassword(ActiveMQConnectionFactory.DEFAULT_PASSWORD);
         managedConnectionFactory.setClientid("clientId");
-
     }
 
     private void getConnection() throws ResourceException, JMSException {
@@ -61,8 +57,10 @@ public class UnsubscribeResubscribeTest extends TestCase {
         managedConnection = connection.getManagedConnection();
     }
 
+    @Test(timeout = 60000)
     public void testUnsubscribeResubscribe() throws ResourceException, JMSException, XAException
{
         getConnection();
+        assertNotNull(managedConnection);
         Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
         Topic topic = session.createTopic("topic");
         TopicSubscriber sub = session.createDurableSubscriber(topic, "sub");
@@ -73,5 +71,4 @@ public class UnsubscribeResubscribeTest extends TestCase {
         session.unsubscribe("sub");
         sub = session.createDurableSubscriber(topic, "sub");
     }
-
 }
\ No newline at end of file


Mime
View raw message