[jboss-cvs] JBoss Messaging SVN: r2923 - trunk/tests/src/org/jboss/test/messaging/jms.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Jul 23 14:25:43 EDT 2007


Author: clebert.suconic at jboss.com
Date: 2007-07-23 14:25:43 -0400 (Mon, 23 Jul 2007)
New Revision: 2923

Modified:
   trunk/tests/src/org/jboss/test/messaging/jms/SecurityTest.java
Log:
Adding Security Test

Modified: trunk/tests/src/org/jboss/test/messaging/jms/SecurityTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/SecurityTest.java	2007-07-21 11:16:07 UTC (rev 2922)
+++ trunk/tests/src/org/jboss/test/messaging/jms/SecurityTest.java	2007-07-23 18:25:43 UTC (rev 2923)
@@ -32,6 +32,12 @@
 import javax.jms.Queue;
 import javax.jms.Session;
 import javax.jms.Topic;
+import javax.jms.JMSException;
+import javax.jms.TopicConnection;
+import javax.jms.TopicSession;
+import javax.jms.TopicConnectionFactory;
+import javax.jms.TopicPublisher;
+import javax.jms.DeliveryMode;
 import javax.management.ObjectName;
 import javax.naming.InitialContext;
 
@@ -455,6 +461,55 @@
       }
    }
 
+   public void testTransactedPublish() throws JMSException
+   {
+
+      TopicConnection conn = null;
+
+      try
+      {
+
+         conn = ((TopicConnectionFactory)cf).createTopicConnection("nobody", "nobody");
+         TopicSession topicSess = conn.createTopicSession(true , Session.AUTO_ACKNOWLEDGE);
+         try
+         {
+            TopicPublisher publisher = topicSess.createPublisher(testTopic);
+            publisher.publish(topicSess.createTextMessage("test"), DeliveryMode.PERSISTENT, 4, 0l);
+            topicSess.commit();
+
+            fail("Test didn't throw expected exception");
+         }
+         catch (JMSSecurityException expected)
+         {
+         }
+
+         try
+         {
+            MessageProducer prod = topicSess.createPublisher(testTopic);
+            prod.send(topicSess.createTextMessage("hello"));
+            topicSess.commit();
+
+            fail("Test didn't throw expected exception");
+         }
+         catch (JMSSecurityException expected)
+         {
+         }
+
+
+      }
+      finally
+      {
+         try
+         {
+            if (conn!=null) conn.close();
+         }
+         catch (Throwable ignored)
+         {
+         }
+      }
+
+   }
+
    /*
     * Test invalid durable subscription creation for connection preconfigured with client id
     */
@@ -1036,9 +1091,14 @@
       }
       catch (JMSSecurityException e)
       {
+         log.error(e,e);
          log.trace("Can't create durable sub", e);
          return false;
       }
+      finally
+      {
+         sess.close();
+      }
    }
 
    private void testSecurityForTemporaryDestination(boolean isQueue) throws Exception




More information about the jboss-cvs-commits mailing list