qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject git commit: Add a couple more tests for connection state handling.
Date Thu, 09 Oct 2014 15:40:45 GMT
Repository: qpid-jms
Updated Branches:
  refs/heads/master fdd1437c3 -> d5ef8fb95


Add a couple more tests for connection state handling.

Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/d5ef8fb9
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/d5ef8fb9
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/d5ef8fb9

Branch: refs/heads/master
Commit: d5ef8fb95777e00d63be2c7067982a34f9962541
Parents: fdd1437
Author: Timothy Bish <tabish121@gmail.com>
Authored: Thu Oct 9 11:40:25 2014 -0400
Committer: Timothy Bish <tabish121@gmail.com>
Committed: Thu Oct 9 11:40:40 2014 -0400

----------------------------------------------------------------------
 .../org/apache/qpid/jms/JmsConnectionTest.java  | 40 ++++++++++++++++++++
 1 file changed, 40 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/d5ef8fb9/qpid-jms-client/src/test/java/org/apache/qpid/jms/JmsConnectionTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/JmsConnectionTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/JmsConnectionTest.java
index b5700be..841fd51 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/JmsConnectionTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/JmsConnectionTest.java
@@ -27,16 +27,25 @@ import java.net.URI;
 import javax.jms.JMSException;
 
 import org.apache.qpid.jms.message.JmsInboundMessageDispatch;
+import org.apache.qpid.jms.meta.JmsConnectionInfo;
+import org.apache.qpid.jms.meta.JmsResource;
 import org.apache.qpid.jms.provider.Provider;
+import org.apache.qpid.jms.provider.ProviderFuture;
 import org.apache.qpid.jms.util.IdGenerator;
 import org.junit.Test;
 import org.mockito.Mockito;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Test basic functionality around JmsConnection
  */
 public class JmsConnectionTest {
 
+    private static final Logger LOG = LoggerFactory.getLogger(JmsConnectionTest.class);
+
     private final Provider provider = Mockito.mock(Provider.class);
     private final IdGenerator clientIdGenerator = new IdGenerator();
 
@@ -47,6 +56,15 @@ public class JmsConnectionTest {
     }
 
     @Test
+    public void testStateAfterCreate() throws JMSException {
+        JmsConnection connection = new JmsConnection("ID:TEST:1", provider, clientIdGenerator);
+
+        assertFalse(connection.isStarted());
+        assertFalse(connection.isClosed());
+        assertFalse(connection.isConnected());
+    }
+
+    @Test
     public void testGetProvider() throws JMSException {
         JmsConnection connection = new JmsConnection("ID:TEST:1", provider, clientIdGenerator);
         assertSame(provider, connection.getProvider());
@@ -94,4 +112,26 @@ public class JmsConnectionTest {
         connection.addConnectionListener(listener);
         assertTrue(connection.removeConnectionListener(listener));
     }
+
+    @Test
+    public void testConnectionStart() throws JMSException, IOException {
+
+        Mockito.doAnswer(new Answer<Object>() {
+            @Override
+            public Object answer(InvocationOnMock invocation) throws Throwable {
+                Object[] args = invocation.getArguments();
+                LOG.debug("Handling provider create call");
+                if (args[0] instanceof JmsConnectionInfo) {
+                    ProviderFuture request = (ProviderFuture) args[1];
+                    request.onSuccess();
+                }
+                return null;
+            }
+        }).when(provider).create(Mockito.any(JmsResource.class), Mockito.any(ProviderFuture.class));
+
+        JmsConnection connection = new JmsConnection("ID:TEST:1", provider, clientIdGenerator);
+        assertFalse(connection.isConnected());
+        connection.start();
+        assertTrue(connection.isConnected());
+    }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message