Repository: qpid-jms
Updated Branches:
  refs/heads/master 790198118 -> 6eac59222


QPIDJMS-207 Add additional tests for exception handlers

Test that the session handles throwing the right error on use of invalid
temporary destination values. 

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

Branch: refs/heads/master
Commit: bc7ef64495e2b4ba09979b830c0dd37f46b210bd
Parents: 7901981
Author: Timothy Bish <tabish...@gmail.com>
Authored: Mon Sep 19 12:48:22 2016 -0400
Committer: Timothy Bish <tabish...@gmail.com>
Committed: Mon Sep 19 12:48:22 2016 -0400

----------------------------------------------------------------------
 .../apache/qpid/jms/session/JmsSessionTest.java | 37 ++++++++++++++++++++
 1 file changed, 37 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/bc7ef644/qpid-jms-client/src/test/java/org/apache/qpid/jms/session/JmsSessionTest.java
----------------------------------------------------------------------
diff --git 
a/qpid-jms-client/src/test/java/org/apache/qpid/jms/session/JmsSessionTest.java 
b/qpid-jms-client/src/test/java/org/apache/qpid/jms/session/JmsSessionTest.java
index 531828a..c4f78d4 100644
--- 
a/qpid-jms-client/src/test/java/org/apache/qpid/jms/session/JmsSessionTest.java
+++ 
b/qpid-jms-client/src/test/java/org/apache/qpid/jms/session/JmsSessionTest.java
@@ -21,18 +21,24 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.UUID;
 
 import javax.jms.IllegalStateException;
 import javax.jms.InvalidDestinationException;
 import javax.jms.JMSException;
 import javax.jms.Message;
 import javax.jms.MessageListener;
+import javax.jms.MessageProducer;
 import javax.jms.ObjectMessage;
 import javax.jms.Session;
+import javax.jms.TemporaryQueue;
 import javax.jms.TextMessage;
 
 import org.apache.qpid.jms.JmsConnectionTestSupport;
 import org.apache.qpid.jms.JmsSession;
+import org.apache.qpid.jms.JmsTemporaryQueue;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -266,4 +272,35 @@ public class JmsSessionTest extends 
JmsConnectionTestSupport {
         JmsSession session = (JmsSession) connection.createSession(false, 
Session.AUTO_ACKNOWLEDGE);
         session.createDurableConsumer(null, "name", "a > b", true);
     }
+
+    @Test(timeout = 10000)
+    public void testCannotCreateConsumerOnTempDestinationFromSomeOtherSource() 
throws JMSException {
+        JmsSession session = (JmsSession) connection.createSession(false, 
Session.AUTO_ACKNOWLEDGE);
+        TemporaryQueue tempQueue = new JmsTemporaryQueue("ID:" + 
UUID.randomUUID().toString());
+
+        try {
+            session.createConsumer(tempQueue);
+            fail("Should not be able to create a consumer");
+        } catch (InvalidDestinationException idex) {}
+    }
+
+    @Test//(timeout = 10000)
+    public void testCannotCreateConsumerOnDeletedTemporaryDestination() throws 
JMSException {
+        JmsSession session = (JmsSession) connection.createSession(false, 
Session.AUTO_ACKNOWLEDGE);
+        TemporaryQueue tempQueue = session.createTemporaryQueue();
+        MessageProducer producer = session.createProducer(tempQueue);
+
+        try {
+            producer.send(session.createMessage());
+        } catch (Exception ex) {
+            fail("Should be able to send to this temporary destination");
+        }
+
+        tempQueue.delete();
+
+        try {
+            producer.send(session.createMessage());
+            fail("Should not be able to send to this temporary destination");
+        } catch (IllegalStateException ise) {}
+    }
 }


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

Reply via email to