qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject qpid-jms git commit: https://issues.apache.org/jira/browse/QPIDJMS-40
Date Wed, 15 Apr 2015 20:01:46 GMT
Repository: qpid-jms
Updated Branches:
  refs/heads/master cf732f901 -> d26dedf53


https://issues.apache.org/jira/browse/QPIDJMS-40

Add some additional tests to validate that error data is embedded in the
JMSException that is thrown.

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

Branch: refs/heads/master
Commit: d26dedf53ecbb05a9787d0f637575a93906c2f1d
Parents: cf732f9
Author: Timothy Bish <tabish121@gmail.com>
Authored: Wed Apr 15 16:01:28 2015 -0400
Committer: Timothy Bish <tabish121@gmail.com>
Committed: Wed Apr 15 16:01:28 2015 -0400

----------------------------------------------------------------------
 .../integration/ConnectionIntegrationTest.java  | 22 +++++++++--
 .../integration/ConsumerIntegrationTest.java    |  9 ++++-
 .../integration/ProducerIntegrationTest.java    |  9 ++++-
 .../jms/integration/SessionIntegrationTest.java | 40 ++++++++++++++++++--
 .../qpid/jms/test/testpeer/TestAmqpPeer.java    | 37 +++++++++++++++---
 5 files changed, 101 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/d26dedf5/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/ConnectionIntegrationTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/ConnectionIntegrationTest.java
b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/ConnectionIntegrationTest.java
index 360d3ad..6d4e3f0 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/ConnectionIntegrationTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/ConnectionIntegrationTest.java
@@ -41,6 +41,7 @@ import org.apache.qpid.jms.JmsConnection;
 import org.apache.qpid.jms.test.QpidJmsTestCase;
 import org.apache.qpid.jms.test.Wait;
 import org.apache.qpid.jms.test.testpeer.TestAmqpPeer;
+import org.apache.qpid.jms.test.testpeer.basictypes.AmqpError;
 import org.apache.qpid.jms.test.testpeer.matchers.CoordinatorMatcher;
 import org.apache.qpid.proton.amqp.transaction.TxnCapability;
 import org.junit.Test;
@@ -137,6 +138,8 @@ public class ConnectionIntegrationTest extends QpidJmsTestCase {
 
     @Test(timeout = 5000)
     public void testRemotelyEndConnectionWithSessionWithConsumer() throws Exception {
+        final String BREAD_CRUMB = "ErrorMessage";
+
         try (TestAmqpPeer testPeer = new TestAmqpPeer();) {
             final Connection connection = testFixture.establishConnecton(testPeer);
 
@@ -146,7 +149,7 @@ public class ConnectionIntegrationTest extends QpidJmsTestCase {
             // Create a consumer, then remotely end the connection afterwards.
             testPeer.expectReceiverAttach();
             testPeer.expectLinkFlow();
-            testPeer.remotelyCloseConnection(true);
+            testPeer.remotelyCloseConnection(true, AmqpError.RESOURCE_LIMIT_EXCEEDED, BREAD_CRUMB);
 
             Queue queue = session.createQueue("myQueue");
             MessageConsumer consumer = session.createConsumer(queue);
@@ -159,12 +162,23 @@ public class ConnectionIntegrationTest extends QpidJmsTestCase {
                 }
             }, 1000, 10));
 
+            try {
+                connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+                fail("Expected ISE to be thrown due to being closed");
+            } catch (IllegalStateException jmsise) {
+                String message = jmsise.getCause().getMessage();
+                assertTrue(message.contains(AmqpError.RESOURCE_LIMIT_EXCEEDED.toString()));
+                assertTrue(message.contains(BREAD_CRUMB));
+            }
+
             // Verify the session is now marked closed
             try {
                 session.getAcknowledgeMode();
                 fail("Expected ISE to be thrown due to being closed");
             } catch (IllegalStateException jmsise) {
-                // expected
+                String message = jmsise.getCause().getMessage();
+                assertTrue(message.contains(AmqpError.RESOURCE_LIMIT_EXCEEDED.toString()));
+                assertTrue(message.contains(BREAD_CRUMB));
             }
 
             // Verify the consumer is now marked closed
@@ -172,7 +186,9 @@ public class ConnectionIntegrationTest extends QpidJmsTestCase {
                 consumer.getMessageListener();
                 fail("Expected ISE to be thrown due to being closed");
             } catch (IllegalStateException jmsise) {
-                // expected
+                String message = jmsise.getCause().getMessage();
+                assertTrue(message.contains(AmqpError.RESOURCE_LIMIT_EXCEEDED.toString()));
+                assertTrue(message.contains(BREAD_CRUMB));
             }
 
             // Try closing them explicitly, should effectively no-op in client.

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/d26dedf5/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/ConsumerIntegrationTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/ConsumerIntegrationTest.java
b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/ConsumerIntegrationTest.java
index 97697d8..d0ae2c0 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/ConsumerIntegrationTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/ConsumerIntegrationTest.java
@@ -29,6 +29,7 @@ import javax.jms.Session;
 import org.apache.qpid.jms.test.QpidJmsTestCase;
 import org.apache.qpid.jms.test.Wait;
 import org.apache.qpid.jms.test.testpeer.TestAmqpPeer;
+import org.apache.qpid.jms.test.testpeer.basictypes.AmqpError;
 import org.junit.Test;
 
 public class ConsumerIntegrationTest extends QpidJmsTestCase {
@@ -55,6 +56,8 @@ public class ConsumerIntegrationTest extends QpidJmsTestCase {
 
     @Test(timeout = 5000)
     public void testRemotelyCloseConsumer() throws Exception {
+        final String BREAD_CRUMB = "ErrorMessage";
+
         try (TestAmqpPeer testPeer = new TestAmqpPeer();) {
             Connection connection = testFixture.establishConnecton(testPeer);
 
@@ -64,7 +67,7 @@ public class ConsumerIntegrationTest extends QpidJmsTestCase {
             // Create a consumer, then remotely end it afterwards.
             testPeer.expectReceiverAttach();
             testPeer.expectLinkFlow();
-            testPeer.remotelyDetachLastOpenedLinkOnLastOpenedSession(true, true);
+            testPeer.remotelyDetachLastOpenedLinkOnLastOpenedSession(true, true, AmqpError.RESOURCE_DELETED,
BREAD_CRUMB);
 
             Queue queue = session.createQueue("myQueue");
             final MessageConsumer consumer = session.createConsumer(queue);
@@ -78,7 +81,9 @@ public class ConsumerIntegrationTest extends QpidJmsTestCase {
                         consumer.getMessageListener();
                     } catch (IllegalStateException jmsise) {
                         if (jmsise.getCause() != null) {
-                            return true;
+                            String message = jmsise.getCause().getMessage();
+                            return message.contains(AmqpError.RESOURCE_DELETED.toString())
&&
+                                   message.contains(BREAD_CRUMB);
                         } else {
                             return false;
                         }

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/d26dedf5/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/ProducerIntegrationTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/ProducerIntegrationTest.java
b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/ProducerIntegrationTest.java
index cfba435..885c5e9 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/ProducerIntegrationTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/ProducerIntegrationTest.java
@@ -43,6 +43,7 @@ import org.apache.qpid.jms.provider.amqp.message.AmqpMessageSupport;
 import org.apache.qpid.jms.test.QpidJmsTestCase;
 import org.apache.qpid.jms.test.Wait;
 import org.apache.qpid.jms.test.testpeer.TestAmqpPeer;
+import org.apache.qpid.jms.test.testpeer.basictypes.AmqpError;
 import org.apache.qpid.jms.test.testpeer.matchers.sections.MessageAnnotationsSectionMatcher;
 import org.apache.qpid.jms.test.testpeer.matchers.sections.MessageHeaderSectionMatcher;
 import org.apache.qpid.jms.test.testpeer.matchers.sections.MessagePropertiesSectionMatcher;
@@ -521,6 +522,8 @@ public class ProducerIntegrationTest extends QpidJmsTestCase {
 
     @Test(timeout = 5000)
     public void testRemotelyCloseProducer() throws Exception {
+        final String BREAD_CRUMB = "ErrorMessage";
+
         try (TestAmqpPeer testPeer = new TestAmqpPeer();) {
             Connection connection = testFixture.establishConnecton(testPeer);
 
@@ -529,7 +532,7 @@ public class ProducerIntegrationTest extends QpidJmsTestCase {
 
             // Create a producer, then remotely end it afterwards.
             testPeer.expectSenderAttach();
-            testPeer.remotelyDetachLastOpenedLinkOnLastOpenedSession(true, true);
+            testPeer.remotelyDetachLastOpenedLinkOnLastOpenedSession(true, true, AmqpError.RESOURCE_DELETED,
BREAD_CRUMB);
 
             Queue queue = session.createQueue("myQueue");
             final MessageProducer producer = session.createProducer(queue);
@@ -543,7 +546,9 @@ public class ProducerIntegrationTest extends QpidJmsTestCase {
                         producer.getDestination();
                     } catch (IllegalStateException jmsise) {
                         if (jmsise.getCause() != null) {
-                            return true;
+                            String message = jmsise.getCause().getMessage();
+                            return message.contains(AmqpError.RESOURCE_DELETED.toString())
&&
+                                   message.contains(BREAD_CRUMB);
                         } else {
                             return false;
                         }

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/d26dedf5/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SessionIntegrationTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SessionIntegrationTest.java
b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SessionIntegrationTest.java
index 7891e92..3cbf6db 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SessionIntegrationTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SessionIntegrationTest.java
@@ -1233,6 +1233,8 @@ public class SessionIntegrationTest extends QpidJmsTestCase {
 
     @Test(timeout = 5000)
     public void testRemotelyEndSessionWithProducer() throws Exception {
+        final String BREAD_CRUMB = "ErrorMessage";
+
         try (TestAmqpPeer testPeer = new TestAmqpPeer();) {
             Connection connection = testFixture.establishConnecton(testPeer);
 
@@ -1241,7 +1243,7 @@ public class SessionIntegrationTest extends QpidJmsTestCase {
 
             // Create a producer, then remotely end the session afterwards.
             testPeer.expectSenderAttach();
-            testPeer.remotelyEndLastOpenedSession(true);
+            testPeer.remotelyEndLastOpenedSession(true, 0, AmqpError.RESOURCE_DELETED, BREAD_CRUMB);
 
             Queue queue = session.createQueue("myQueue");
             final MessageProducer producer = session.createProducer(queue);
@@ -1256,12 +1258,28 @@ public class SessionIntegrationTest extends QpidJmsTestCase {
                     try {
                         producer.getDestination();
                     } catch (IllegalStateException jmsise) {
-                        return true;
+                        if (jmsise.getCause() != null) {
+                            String message = jmsise.getCause().getMessage();
+                            return message.contains(AmqpError.RESOURCE_DELETED.toString())
&&
+                                   message.contains(BREAD_CRUMB);
+                        } else {
+                            return false;
+                        }
                     }
                     return false;
                 }
             }, 2000, 10));
 
+            // Verify the session is now marked closed
+            try {
+                session.getAcknowledgeMode();
+                fail("Expected ISE to be thrown due to being closed");
+            } catch (IllegalStateException jmsise) {
+                String message = jmsise.getCause().getMessage();
+                assertTrue(message.contains(AmqpError.RESOURCE_DELETED.toString()));
+                assertTrue(message.contains(BREAD_CRUMB));
+            }
+
             // Try closing it explicitly, should effectively no-op in client.
             // The test peer will throw during close if it sends anything.
             producer.close();
@@ -1270,6 +1288,8 @@ public class SessionIntegrationTest extends QpidJmsTestCase {
 
     @Test(timeout = 5000)
     public void testRemotelyEndSessionWithConsumer() throws Exception {
+        final String BREAD_CRUMB = "ErrorMessage";
+
         try (TestAmqpPeer testPeer = new TestAmqpPeer();) {
             Connection connection = testFixture.establishConnecton(testPeer);
 
@@ -1279,7 +1299,7 @@ public class SessionIntegrationTest extends QpidJmsTestCase {
             // Create a consumer, then remotely end the session afterwards.
             testPeer.expectReceiverAttach();
             testPeer.expectLinkFlow();
-            testPeer.remotelyEndLastOpenedSession(true);
+            testPeer.remotelyEndLastOpenedSession(true, 0, AmqpError.RESOURCE_DELETED, BREAD_CRUMB);
 
             Queue queue = session.createQueue("myQueue");
             final MessageConsumer consumer = session.createConsumer(queue);
@@ -1293,7 +1313,9 @@ public class SessionIntegrationTest extends QpidJmsTestCase {
                         consumer.getMessageListener();
                     } catch (IllegalStateException jmsise) {
                         if (jmsise.getCause() != null) {
-                            return true;
+                            String message = jmsise.getCause().getMessage();
+                            return message.contains(AmqpError.RESOURCE_DELETED.toString())
&&
+                                   message.contains(BREAD_CRUMB);
                         } else {
                             return false;
                         }
@@ -1302,6 +1324,16 @@ public class SessionIntegrationTest extends QpidJmsTestCase {
                 }
             }, 2000, 10));
 
+            // Verify the session is now marked closed
+            try {
+                session.getAcknowledgeMode();
+                fail("Expected ISE to be thrown due to being closed");
+            } catch (IllegalStateException jmsise) {
+                String message = jmsise.getCause().getMessage();
+                assertTrue(message.contains(AmqpError.RESOURCE_DELETED.toString()));
+                assertTrue(message.contains(BREAD_CRUMB));
+            }
+
             // Try closing it explicitly, should effectively no-op in client.
             // The test peer will throw during close if it sends anything.
             consumer.close();

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/d26dedf5/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java
b/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java
index b76dffc..0c3bac5 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java
@@ -1247,16 +1247,25 @@ public class TestAmqpPeer implements AutoCloseable
     }
 
     public void remotelyEndLastOpenedSession(boolean expectEndResponse) {
-        remotelyEndLastOpenedSession(expectEndResponse, 0);
+        remotelyEndLastOpenedSession(expectEndResponse, 0, null, null);
     }
 
-    public void remotelyEndLastOpenedSession(boolean expectEndResponse, final long delayBeforeSend)
{
+    public void remotelyEndLastOpenedSession(boolean expectEndResponse, long delayBeforeSend)
{
+        remotelyEndLastOpenedSession(expectEndResponse, 0, null, null);
+    }
+
+    public void remotelyEndLastOpenedSession(boolean expectEndResponse, final long delayBeforeSend,
Symbol errorType, String errorMessage) {
         synchronized (_handlersLock) {
             CompositeAmqpPeerRunnable comp = insertCompsiteActionForLastHandler();
 
             // Now generate the End for the appropriate session
             final EndFrame endFrame = new EndFrame();
-            // TODO: add an optional error msg+condition?
+            if (errorType != null) {
+                org.apache.qpid.jms.test.testpeer.describedtypes.Error detachError = new
org.apache.qpid.jms.test.testpeer.describedtypes.Error();
+                detachError.setCondition(errorType);
+                detachError.setDescription(errorMessage);
+                endFrame.setError(detachError);
+            }
 
             int channel = -1;
             final FrameSender frameSender = new FrameSender(this, FrameType.AMQP, channel,
endFrame, null);
@@ -1287,13 +1296,22 @@ public class TestAmqpPeer implements AutoCloseable
     }
 
     public void remotelyCloseConnection(boolean expectCloseResponse) {
+        remotelyCloseConnection(expectCloseResponse, null, null);
+    }
+
+    public void remotelyCloseConnection(boolean expectCloseResponse, Symbol errorType, String
errorMessage) {
         synchronized (_handlersLock) {
             // Prepare a composite to insert this action at the end of the handler sequence
             CompositeAmqpPeerRunnable comp = insertCompsiteActionForLastHandler();
 
             // Now generate the Close
             final CloseFrame closeFrame = new CloseFrame();
-            // TODO: add an optional error msg+condition?
+            if (errorType != null) {
+                org.apache.qpid.jms.test.testpeer.describedtypes.Error detachError = new
org.apache.qpid.jms.test.testpeer.describedtypes.Error();
+                detachError.setCondition(errorType);
+                detachError.setDescription(errorMessage);
+                closeFrame.setError(detachError);
+            }
 
             final FrameSender frameSender = new FrameSender(this, FrameType.AMQP, CONNECTION_CHANNEL,
closeFrame, null);
 
@@ -1308,13 +1326,22 @@ public class TestAmqpPeer implements AutoCloseable
     }
 
     public void remotelyDetachLastOpenedLinkOnLastOpenedSession(boolean expectDetachResponse,
boolean closed) {
+        remotelyDetachLastOpenedLinkOnLastOpenedSession(expectDetachResponse, closed, null,
null);
+    }
+
+    public void remotelyDetachLastOpenedLinkOnLastOpenedSession(boolean expectDetachResponse,
boolean closed, Symbol errorType, String errorMessage) {
         synchronized (_handlersLock) {
             CompositeAmqpPeerRunnable comp = insertCompsiteActionForLastHandler();
 
             // Now generate the Detach for the appropriate link on the appropriate session
             final DetachFrame detachFrame = new DetachFrame();
             detachFrame.setClosed(closed);
-            // TODO: add an optional error msg+condition?
+            if (errorType != null) {
+                org.apache.qpid.jms.test.testpeer.describedtypes.Error detachError = new
org.apache.qpid.jms.test.testpeer.describedtypes.Error();
+                detachError.setCondition(errorType);
+                detachError.setDescription(errorMessage);
+                detachFrame.setError(detachError);
+            }
 
             // The response frame channel will be dynamically set based on the previous frames.
Using the -1 is an illegal placeholder.
             final FrameSender frameSender = new FrameSender(this, FrameType.AMQP, -1, detachFrame,
null);


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


Mime
View raw message