[jboss-cvs] JBoss Messaging SVN: r2933 - in branches/Branch_1_2_0_SP: src/main/org/jboss/jms/server/destination and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Jul 30 06:02:30 EDT 2007


Author: timfox
Date: 2007-07-30 06:02:30 -0400 (Mon, 30 Jul 2007)
New Revision: 2933

Modified:
   branches/Branch_1_2_0_SP/src/main/org/jboss/jms/client/container/ConsumerAspect.java
   branches/Branch_1_2_0_SP/src/main/org/jboss/jms/server/destination/DestinationServiceSupport.java
   branches/Branch_1_2_0_SP/tests/src/org/jboss/test/messaging/jms/ConnectionFactoryTest.java
   branches/Branch_1_2_0_SP/tests/src/org/jboss/test/messaging/jms/SecurityTest.java
Log:
Backported JBMESSAGING-939 and JBMESSAGING-976 to 1_2_0_SP for customer patch


Modified: branches/Branch_1_2_0_SP/src/main/org/jboss/jms/client/container/ConsumerAspect.java
===================================================================
--- branches/Branch_1_2_0_SP/src/main/org/jboss/jms/client/container/ConsumerAspect.java	2007-07-28 13:12:47 UTC (rev 2932)
+++ branches/Branch_1_2_0_SP/src/main/org/jboss/jms/client/container/ConsumerAspect.java	2007-07-30 10:02:30 UTC (rev 2933)
@@ -31,6 +31,7 @@
 import org.jboss.jms.client.state.ConnectionState;
 import org.jboss.jms.client.state.ConsumerState;
 import org.jboss.jms.client.state.SessionState;
+import org.jboss.jms.delegate.ConnectionDelegate;
 import org.jboss.jms.delegate.ConsumerDelegate;
 import org.jboss.jms.delegate.SessionDelegate;
 import org.jboss.jms.util.MessageQueueNameHelper;
@@ -82,10 +83,16 @@
       
       //We need the queue name for recovering any deliveries after failover
       String queueName = null;
+
       if (consumerState.getSubscriptionName() != null)
       {
+        // I have to use the clientID from connectionDelegate instead of connectionState...
+        // this is because when a pre configured CF is used we need to get the clientID from
+        // server side.
+        // This was a condition verified by the TCK and it was fixed as part of
+        // http://jira.jboss.com/jira/browse/JBMESSAGING-939
          queueName = MessageQueueNameHelper.
-            createSubscriptionName(connectionState.getClientID(),
+           createSubscriptionName(((ConnectionDelegate)connectionState.getDelegate()).getClientID(),
                                    consumerState.getSubscriptionName());
       }
       else if (consumerState.getDestination().isQueue())

Modified: branches/Branch_1_2_0_SP/src/main/org/jboss/jms/server/destination/DestinationServiceSupport.java
===================================================================
--- branches/Branch_1_2_0_SP/src/main/org/jboss/jms/server/destination/DestinationServiceSupport.java	2007-07-28 13:12:47 UTC (rev 2932)
+++ branches/Branch_1_2_0_SP/src/main/org/jboss/jms/server/destination/DestinationServiceSupport.java	2007-07-30 10:02:30 UTC (rev 2933)
@@ -134,7 +134,13 @@
                                              "ObjectName");
          }                  
          
-         destination.setName(name);                   
+         destination.setName(name);   
+         
+         // http://jira.jboss.com/jira/browse/JBMESSAGING-976
+         if (destination.getSecurityConfig() != null)
+         {
+         	serverPeer.getSecurityManager().setSecurityConfig(isQueue(), destination.getName(), destination.getSecurityConfig());
+         }
       }
       catch (Throwable t)
       {

Modified: branches/Branch_1_2_0_SP/tests/src/org/jboss/test/messaging/jms/ConnectionFactoryTest.java
===================================================================
--- branches/Branch_1_2_0_SP/tests/src/org/jboss/test/messaging/jms/ConnectionFactoryTest.java	2007-07-28 13:12:47 UTC (rev 2932)
+++ branches/Branch_1_2_0_SP/tests/src/org/jboss/test/messaging/jms/ConnectionFactoryTest.java	2007-07-30 10:02:30 UTC (rev 2933)
@@ -26,8 +26,11 @@
 import javax.jms.JMSException;
 import javax.jms.QueueConnection;
 import javax.jms.QueueConnectionFactory;
+import javax.jms.Session;
+import javax.jms.Topic;
 import javax.jms.TopicConnection;
 import javax.jms.TopicConnectionFactory;
+import javax.jms.TopicSubscriber;
 import javax.management.ObjectName;
 import javax.naming.InitialContext;
 
@@ -35,6 +38,7 @@
 import org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate;
 import org.jboss.test.messaging.MessagingTestCase;
 import org.jboss.test.messaging.tools.ServerManagement;
+import org.jboss.test.messaging.tools.jmx.ServiceContainer;
 
 /**
  * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
@@ -264,7 +268,69 @@
       c.close();
    }
 
+   // Added for http://jira.jboss.org/jira/browse/JBMESSAGING-939
+   public void testDurableSubscriptionOnPreConfiguredConnectionFactory() throws Exception
+   {
+   	ObjectName cf1 = deployConnectionFactory("jboss.messaging.destination:service=TestConnectionFactory1", ServiceContainer.REMOTING_OBJECT_NAME.getCanonicalName(), "/TestDurableCF", "cfTest");
 
+   	ServerManagement.deployTopic("TestSubscriber");
+
+   	Connection conn = null;
+
+   	try
+   	{
+   		Topic topic = (Topic) initialContext.lookup("/topic/TestSubscriber");
+   		ConnectionFactory cf = (ConnectionFactory) initialContext.lookup("/TestDurableCF");
+   		conn = cf.createConnection();
+
+   		// I have to remove this asertion, as the test would work if doing this assertion
+   		// as getClientID performed some operation that cleared the bug condition during
+   		// the creation of this testcase
+   		//assertEquals("cfTest", conn.getClientID());
+
+   		Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+   		TopicSubscriber subs = session.createDurableSubscriber(topic,
+   				"durableSubscriberChangeSelectorTest", "TEST = 'test'", false);
+   	}
+   	finally
+   	{
+   		try
+   		{
+   			if (conn != null)
+   			{
+   				conn.close();
+   			}
+   		}
+   		catch (Exception e)
+   		{
+   			log.warn(e.toString(), e);
+   		}
+
+
+   		try
+   		{
+   			stopService(cf1);
+   		}
+   		catch (Exception e)
+   		{
+   			log.warn(e.toString(), e);
+   		}
+
+   		try
+   		{
+   			ServerManagement.destroyTopic("TestSubscriber");
+   		}
+   		catch (Exception e)
+   		{
+   			log.warn(e.toString(), e);
+   		}
+
+   	}
+
+   }
+
+
    // Package protected ---------------------------------------------
 
    // Protected -----------------------------------------------------

Modified: branches/Branch_1_2_0_SP/tests/src/org/jboss/test/messaging/jms/SecurityTest.java
===================================================================
--- branches/Branch_1_2_0_SP/tests/src/org/jboss/test/messaging/jms/SecurityTest.java	2007-07-28 13:12:47 UTC (rev 2932)
+++ branches/Branch_1_2_0_SP/tests/src/org/jboss/test/messaging/jms/SecurityTest.java	2007-07-30 10:02:30 UTC (rev 2933)
@@ -689,7 +689,129 @@
          }
       }
    }
+   
+   /**
+    * This test makes sure that changing the queue security configuration on the server has effect
+    * over destinations when they are stopped (this is what happens in a real deployment - the security config
+    * gets set before the queue/topic is started
+    * See http://jira.jboss.com/jira/browse/JBMESSAGING-976
+    */
+   public void testQueueSecurityUpdateStopped() throws Exception
+   {
+      // "john" has the role def, so he should be able to create a producer and a consumer on a queue
 
+      ObjectName on = new ObjectName("jboss.messaging.destination:service=Queue,name=testQueue");
+      
+      Connection conn = null;
+
+      try
+      {
+         conn = cf.createConnection("john", "needle");
+         assertTrue(canReadDestination(conn, testQueue));
+         assertTrue(canWriteDestination(conn, testQueue));
+
+         String newSecurityConfig =
+            "<security><role name=\"someotherrole\" read=\"true\" write=\"true\" create=\"false\"/></security>";
+
+         ServerManagement.invoke(on, "stop", null, null);         
+         ServerManagement.configureSecurityForDestination("testQueue", newSecurityConfig);         
+         ServerManagement.invoke(on, "start", null, null);
+         
+         assertFalse(canReadDestination(conn, testQueue));
+         // non transacted to avoid evict timeout
+         assertFalse(canWriteDestination(conn, testQueue));
+
+
+         newSecurityConfig =
+            "<security><role name=\"def\" read=\"true\" write=\"false\" create=\"false\"/></security>";
+
+         ServerManagement.invoke(on, "stop", null, null);         
+         ServerManagement.configureSecurityForDestination("testQueue", newSecurityConfig);         
+         ServerManagement.invoke(on, "start", null, null);
+
+         assertTrue(canReadDestination(conn, testQueue));
+         assertFalse(canWriteDestination(conn, testQueue));
+
+         newSecurityConfig =
+            "<security><role name=\"def\" read=\"true\" write=\"true\" create=\"false\"/></security>";
+
+         ServerManagement.invoke(on, "stop", null, null);         
+         ServerManagement.configureSecurityForDestination("testQueue", newSecurityConfig);         
+         ServerManagement.invoke(on, "start", null, null);
+
+         assertTrue(canReadDestination(conn, testQueue));
+         assertTrue(canWriteDestination(conn, testQueue));
+      }
+      finally
+      {      	         
+         if (conn != null)
+         {
+            conn.close();
+         }
+      }
+   }
+   
+   /**
+    * This test makes sure that changing the topic security configuration on the server has effect
+    * over destinations when they are stopped (this is what happens in a real deployment - the security config
+    * gets set before the queue/topic is started
+    * See http://jira.jboss.com/jira/browse/JBMESSAGING-976
+    */
+   public void testTopicSecurityUpdateStopped() throws Exception
+   {
+      // "john" has the role def, so he should be able to create a producer and a consumer on a queue
+
+      ObjectName on = new ObjectName("jboss.messaging.destination:service=Topic,name=testTopic");
+      
+      Connection conn = null;
+
+      try
+      {
+         conn = cf.createConnection("john", "needle");
+         assertTrue(canReadDestination(conn, testTopic));
+         assertTrue(canWriteDestination(conn, testTopic));
+
+
+         String newSecurityConfig =
+            "<security><role name=\"someotherrole\" read=\"true\" write=\"true\" create=\"false\"/></security>";
+
+         ServerManagement.invoke(on, "stop", null, null);         
+         ServerManagement.configureSecurityForDestination("testTopic", newSecurityConfig);         
+         ServerManagement.invoke(on, "start", null, null);
+         
+         assertFalse(canReadDestination(conn, testTopic));
+         assertFalse(canWriteDestination(conn, testTopic));
+
+
+         newSecurityConfig =
+            "<security><role name=\"def\" read=\"true\" write=\"false\" create=\"false\"/></security>";
+
+         ServerManagement.invoke(on, "stop", null, null);         
+         ServerManagement.configureSecurityForDestination("testTopic", newSecurityConfig);         
+         ServerManagement.invoke(on, "start", null, null);
+
+         assertTrue(canReadDestination(conn, testTopic));
+         assertFalse(canWriteDestination(conn, testTopic));
+
+         newSecurityConfig =
+            "<security><role name=\"def\" read=\"true\" write=\"true\" create=\"false\"/></security>";
+
+         ServerManagement.invoke(on, "stop", null, null);         
+         ServerManagement.configureSecurityForDestination("testTopic", newSecurityConfig);         
+         ServerManagement.invoke(on, "start", null, null);
+
+         assertTrue(canReadDestination(conn, testTopic));
+         assertTrue(canWriteDestination(conn, testTopic));
+      }
+      finally
+      {      	
+         if (conn != null)
+         {
+            conn.close();
+         }
+      }
+   }
+
    // Package protected ---------------------------------------------
 
    // Protected -----------------------------------------------------




More information about the jboss-cvs-commits mailing list