[jboss-cvs] JBoss Messaging SVN: r2787 - in trunk/tests/src/org/jboss/test/messaging: tools/jmx and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Jun 18 08:48:39 EDT 2007


Author: sergeypk
Date: 2007-06-18 08:48:39 -0400 (Mon, 18 Jun 2007)
New Revision: 2787

Modified:
   trunk/tests/src/org/jboss/test/messaging/jms/SecurityTest.java
   trunk/tests/src/org/jboss/test/messaging/tools/jmx/MockJBossSecurityManager.java
Log:
http://jira.jboss.com/jira/browse/JBMESSAGING-964
Uncommented the tests, changed them to use user dilbert, password dogbert, instead of john/needle (since dilbert is preconfigured in all the *-persistence-service.xml files). Added role durpublisher for dilbert in MockJBossSecurityManager so that dilbert can have a durable subscription to testTopic.

Modified: trunk/tests/src/org/jboss/test/messaging/jms/SecurityTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/SecurityTest.java	2007-06-18 07:51:35 UTC (rev 2786)
+++ trunk/tests/src/org/jboss/test/messaging/jms/SecurityTest.java	2007-06-18 12:48:39 UTC (rev 2787)
@@ -140,6 +140,7 @@
       try
       {
          conn1 = cf.createConnection("john", "blobby");
+         fail();
       }
       catch (JMSSecurityException e)
       {
@@ -175,34 +176,26 @@
 
    /* Now some client id tests */
 
-
-
-   /*
+   /**
     * user/pwd with preconfigured clientID, should return preconf
     */
-   // TODO
-   /*
-
-
-    This test will not work until client id is automatically preconfigured into
-    connection for specific user
-
     public void testPreConfClientID() throws Exception
-    {
-    Connection conn = null;
-    try
-    {
-    conn = cf.createConnection("john", "needle");
-    String clientID = conn.getClientID();
-    assertEquals("Invalid ClientID", "DurableSubscriberExample", clientID);
-    }
-    finally
-    {
-    if (conn != null) conn.close();
-    }
-    }
-    */
-   /*
+   {
+      Connection conn = null;
+      try
+      {
+         conn = cf.createConnection("dilbert", "dogbert");
+         String clientID = conn.getClientID();
+         assertEquals("Invalid ClientID", "dilbert-id", clientID);
+      }
+      finally
+      {
+         if (conn != null)
+            conn.close();
+      }
+   }
+
+   /**
     * Try setting client ID
     */
    public void testSetClientID() throws Exception
@@ -221,37 +214,29 @@
       }
    }
 
-   // TODO
-   /*
+   /**
     * Try setting client ID on preconfigured connection - should throw exception
     */
-   /*
-    *
+   public void testSetClientIDPreConf() throws Exception
+   {
+      Connection conn = null;
+      try
+      {
+         conn = cf.createConnection("dilbert", "dogbert");
+         conn.setClientID("myID");
+         fail();
+      }
+      catch (IllegalStateException e)
+      {
+         // Expected
+      }
+      finally
+      {
+         if (conn != null)
+            conn.close();
+      }
+   }
 
-
-    This test will not work until client id is automatically preconfigured into
-    connection for specific user
-
-    public void testSetClientIDPreConf() throws Exception
-    {
-    Connection conn = null;
-    try
-    {
-    conn = cf.createConnection("john", "needle");
-    conn.setClientID("myID");
-    fail();
-    }
-    catch (InvalidClientIDException e)
-    {
-    //Expected
-     }
-     finally
-     {
-     if (conn != null) conn.close();
-     }
-     }
-     */
-
    /*
     * Try setting client ID after an operation has been performed on the connection
     */
@@ -452,59 +437,44 @@
       }
    }
 
-   // TODO
-   /*
+   /**
     * Test valid durable subscription creation for connection preconfigured with client id
     */
+   public void testValidDurableSubscriptionCreationPreConf() throws Exception
+   {
+      Connection conn = null;
+      try
+      {
+         conn = cf.createConnection("dilbert", "dogbert");
+         assertTrue(this.canCreateDurableSub(conn, testTopic, "sub2"));
+      }
+      finally
+      {
+         if (conn != null)
+            conn.close();
+      }
+   }
 
    /*
-
-    This test will not work until client id is automatically preconfigured into
-    connection for specific user
-
-    public void testValidDurableSubscriptionCreationPreConf() throws Exception
-    {
-    Connection conn = null;
-    try
-    {
-    conn = cf.createConnection("john", "needle");
-    assertTrue(this.canCreateDurableSub(conn, testTopic, "sub2"));
-    }
-    finally
-    {
-    if (conn != null) conn.close();
-    }
-    }
-
-    */
-
-   /*
     * Test invalid durable subscription creation for connection preconfigured with client id
     */
 
+   public void testInvalidDurableSubscriptionCreationPreConf() throws Exception
+   {
+      Connection conn = null;
+      try
+      {
+         conn = cf.createConnection("dilbert", "dogbert");
+         assertFalse(this.canCreateDurableSub(conn, securedTopic, "sub3"));
+      }
+      finally
+      {
+         if (conn != null)
+            conn.close();
+      }
+   }
 
-   // TODO
    /*
-
-    This test will not work until client id is automatically preconfigured into
-    connection for specific user
-    public void testInvalidDurableSubscriptionCreationPreConf() throws Exception
-    {
-    Connection conn = null;
-    try
-    {
-    conn = cf.createConnection("john", "needle");
-    assertFalse(this.canCreateDurableSub(conn, securedTopic, "sub3"));
-    }
-    finally
-    {
-    if (conn != null) conn.close();
-    }
-    }
-
-    */
-
-   /*
     * Test valid durable subscription creation for connection not preconfigured with client id
     */
    public void testValidDurableSubscriptionCreationNotPreConf() throws Exception
@@ -1058,7 +1028,7 @@
       }
       catch (JMSSecurityException e)
       {
-         log.trace("Can't create durable sub");
+         log.trace("Can't create durable sub", e);
          return false;
       }
    }

Modified: trunk/tests/src/org/jboss/test/messaging/tools/jmx/MockJBossSecurityManager.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jmx/MockJBossSecurityManager.java	2007-06-18 07:51:35 UTC (rev 2786)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jmx/MockJBossSecurityManager.java	2007-06-18 12:48:39 UTC (rev 2787)
@@ -246,6 +246,10 @@
          {
             return containsRole("noacc", roles);
          }
+         else if ("dilbert".equals(username))
+         {
+            return containsRole("durpublisher", roles);
+         }
          else
          {
             return false;




More information about the jboss-cvs-commits mailing list