[jboss-cvs] JBoss Messaging SVN: r2746 - in trunk: tests/src/org/jboss/test/messaging/core/plugin/postoffice/cluster and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu May 31 04:07:01 EDT 2007
Author: timfox
Date: 2007-05-31 04:07:01 -0400 (Thu, 31 May 2007)
New Revision: 2746
Modified:
trunk/src/main/org/jboss/jms/server/destination/DestinationServiceSupport.java
trunk/src/main/org/jboss/jms/server/destination/QueueService.java
trunk/src/main/org/jboss/jms/server/destination/TopicService.java
trunk/tests/src/org/jboss/test/messaging/core/plugin/postoffice/cluster/RedistributionWithDefaultMessagePullPolicyTest.java
trunk/tests/src/org/jboss/test/messaging/jms/SecurityTest.java
Log:
Mainly http://jira.jboss.com/jira/browse/JBMESSAGING-976
Modified: trunk/src/main/org/jboss/jms/server/destination/DestinationServiceSupport.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/destination/DestinationServiceSupport.java 2007-05-30 18:48:55 UTC (rev 2745)
+++ trunk/src/main/org/jboss/jms/server/destination/DestinationServiceSupport.java 2007-05-31 08:07:01 UTC (rev 2746)
@@ -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: trunk/src/main/org/jboss/jms/server/destination/QueueService.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/destination/QueueService.java 2007-05-30 18:48:55 UTC (rev 2745)
+++ trunk/src/main/org/jboss/jms/server/destination/QueueService.java 2007-05-31 08:07:01 UTC (rev 2746)
@@ -146,9 +146,6 @@
started = true;
- // Need to set security config after service is started http://jira.jboss.com/jira/browse/JBMESSAGING-976
- serverPeer.getSecurityManager().setSecurityConfig(true, destination.getName(), destination.getSecurityConfig());
-
log.info(this + " started, fullSize=" + destination.getFullSize() +
", pageSize=" + destination.getPageSize() + ", downCacheSize=" + destination.getDownCacheSize());
}
Modified: trunk/src/main/org/jboss/jms/server/destination/TopicService.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/destination/TopicService.java 2007-05-30 18:48:55 UTC (rev 2745)
+++ trunk/src/main/org/jboss/jms/server/destination/TopicService.java 2007-05-31 08:07:01 UTC (rev 2746)
@@ -119,9 +119,6 @@
started = true;
- // Need to set security config after service is started http://jira.jboss.com/jira/browse/JBMESSAGING-976
- serverPeer.getSecurityManager().setSecurityConfig(true, destination.getName(), destination.getSecurityConfig());
-
log.info(this + " started, fullSize=" + destination.getFullSize() + ", pageSize=" + destination.getPageSize() + ", downCacheSize=" + destination.getDownCacheSize());
}
catch (Throwable t)
Modified: trunk/tests/src/org/jboss/test/messaging/core/plugin/postoffice/cluster/RedistributionWithDefaultMessagePullPolicyTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/core/plugin/postoffice/cluster/RedistributionWithDefaultMessagePullPolicyTest.java 2007-05-30 18:48:55 UTC (rev 2745)
+++ trunk/tests/src/org/jboss/test/messaging/core/plugin/postoffice/cluster/RedistributionWithDefaultMessagePullPolicyTest.java 2007-05-31 08:07:01 UTC (rev 2746)
@@ -426,97 +426,98 @@
// }
// }
- public void testFailHandleMessagePullResult() throws Throwable
- {
- DefaultClusteredPostOffice office1 = null;
- DefaultClusteredPostOffice office2 = null;
+// Commented because of http://jira.jboss.com/jira/browse/JBMESSAGING-972
+// public void testFailHandleMessagePullResult() throws Throwable
+// {
+// DefaultClusteredPostOffice office1 = null;
+// DefaultClusteredPostOffice office2 = null;
+//
+// try
+// {
+// office1 = (DefaultClusteredPostOffice)
+// createClusteredPostOffice(1, "testgroup", 10000, 10000, new DefaultMessagePullPolicy(),
+// sc, ms, pm, tr);
+//
+// office2 = (DefaultClusteredPostOffice)
+// createClusteredPostOffice(2, "testgroup", 10000, 10000, new DefaultMessagePullPolicy(),
+// sc, ms, pm, tr);
+//
+// LocalClusteredQueue queue1 =
+// new LocalClusteredQueue(office1, 1, "queue1", channelIDManager.getID(), ms, pm,
+// true, true, -1, null, tr);
+// office1.bindClusteredQueue(new SimpleCondition("queue1"), queue1);
+//
+// LocalClusteredQueue queue2 =
+// new LocalClusteredQueue(office2, 2, "queue1", channelIDManager.getID(), ms, pm,
+// true, true, -1, null, tr);
+// office2.bindClusteredQueue(new SimpleCondition("queue1"), queue2);
+//
+// Message msg = CoreMessageFactory.createCoreMessage(1, true, null);
+//
+// MessageReference ref = ms.reference(msg);
+//
+// office1.route(ref, new SimpleCondition("queue1"), null);
+//
+// Thread.sleep(2000);
+//
+// //Messages should all be in queue1
+//
+// List msgs = queue1.browse();
+// assertEquals(1, msgs.size());
+//
+// msgs = queue2.browse();
+// assertTrue(msgs.isEmpty());
+//
+// SimpleReceiver receiver1 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING_TO_MAX);
+// receiver1.setMaxRefs(0);
+// queue1.add(receiver1);
+// SimpleReceiver receiver2 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING_TO_MAX);
+// receiver2.setMaxRefs(0);
+// queue2.add(receiver2);
+//
+// //Prompt delivery so the channels know if the receivers are ready
+// queue1.deliver();
+// Thread.sleep(2000);
+//
+// //Pull from 1 to 2
+//
+// receiver2.setMaxRefs(1);
+//
+// office2.setFail(false, false, true);
+//
+// log.trace("delivering");
+// queue2.deliver();
+//
+// Thread.sleep(3000);
+//
+// //The delivery should be rolled back
+//
+// assertTrue(office2.getHoldingTransactions().isEmpty());
+// assertTrue(office2.getHoldingTransactions().isEmpty());
+//
+// log.trace("queue1 refs:" + queue1.memoryRefCount() + " dels:" + queue1.getDeliveringCount());
+// log.trace("queue2 refs:" + queue2.memoryRefCount() + " dels:" + queue2.getDeliveringCount());
+//
+// assertEquals(1, queue1.memoryRefCount());
+// assertEquals(0, queue1.getDeliveringCount());
+//
+// assertEquals(0, queue2.memoryRefCount());
+// assertEquals(0, queue2.getDeliveringCount());
+// }
+// finally
+// {
+// if (office1 != null)
+// {
+// office1.stop();
+// }
+//
+// if (office2 != null)
+// {
+// office2.stop();
+// }
+// }
+// }
- try
- {
- office1 = (DefaultClusteredPostOffice)
- createClusteredPostOffice(1, "testgroup", 10000, 10000, new DefaultMessagePullPolicy(),
- sc, ms, pm, tr);
-
- office2 = (DefaultClusteredPostOffice)
- createClusteredPostOffice(2, "testgroup", 10000, 10000, new DefaultMessagePullPolicy(),
- sc, ms, pm, tr);
-
- LocalClusteredQueue queue1 =
- new LocalClusteredQueue(office1, 1, "queue1", channelIDManager.getID(), ms, pm,
- true, true, -1, null, tr);
- office1.bindClusteredQueue(new SimpleCondition("queue1"), queue1);
-
- LocalClusteredQueue queue2 =
- new LocalClusteredQueue(office2, 2, "queue1", channelIDManager.getID(), ms, pm,
- true, true, -1, null, tr);
- office2.bindClusteredQueue(new SimpleCondition("queue1"), queue2);
-
- Message msg = CoreMessageFactory.createCoreMessage(1, true, null);
-
- MessageReference ref = ms.reference(msg);
-
- office1.route(ref, new SimpleCondition("queue1"), null);
-
- Thread.sleep(2000);
-
- //Messages should all be in queue1
-
- List msgs = queue1.browse();
- assertEquals(1, msgs.size());
-
- msgs = queue2.browse();
- assertTrue(msgs.isEmpty());
-
- SimpleReceiver receiver1 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING_TO_MAX);
- receiver1.setMaxRefs(0);
- queue1.add(receiver1);
- SimpleReceiver receiver2 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING_TO_MAX);
- receiver2.setMaxRefs(0);
- queue2.add(receiver2);
-
- //Prompt delivery so the channels know if the receivers are ready
- queue1.deliver();
- Thread.sleep(2000);
-
- //Pull from 1 to 2
-
- receiver2.setMaxRefs(1);
-
- office2.setFail(false, false, true);
-
- log.trace("delivering");
- queue2.deliver();
-
- Thread.sleep(3000);
-
- //The delivery should be rolled back
-
- assertTrue(office2.getHoldingTransactions().isEmpty());
- assertTrue(office2.getHoldingTransactions().isEmpty());
-
- log.trace("queue1 refs:" + queue1.memoryRefCount() + " dels:" + queue1.getDeliveringCount());
- log.trace("queue2 refs:" + queue2.memoryRefCount() + " dels:" + queue2.getDeliveringCount());
-
- assertEquals(1, queue1.memoryRefCount());
- assertEquals(0, queue1.getDeliveringCount());
-
- assertEquals(0, queue2.memoryRefCount());
- assertEquals(0, queue2.getDeliveringCount());
- }
- finally
- {
- if (office1 != null)
- {
- office1.stop();
- }
-
- if (office2 != null)
- {
- office2.stop();
- }
- }
- }
-
protected void consumeAll(boolean persistent, boolean recoverable) throws Throwable
{
DefaultClusteredPostOffice office1 = null;
Modified: trunk/tests/src/org/jboss/test/messaging/jms/SecurityTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/SecurityTest.java 2007-05-30 18:48:55 UTC (rev 2745)
+++ trunk/tests/src/org/jboss/test/messaging/jms/SecurityTest.java 2007-05-31 08:07:01 UTC (rev 2746)
@@ -634,7 +634,245 @@
}
}
}
+
+ /**
+ * 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
+ ServerManagement.deployQueue("SomeQueue");
+
+ ObjectName on = new ObjectName("jboss.messaging.destination:service=Queue,name=SomeQueue");
+
+ Connection conn = null;
+ try
+ {
+ Queue someQueue = (Queue)ic.lookup("/queue/SomeQueue");
+
+ conn = cf.createConnection("john", "needle");
+ assertTrue(canReadDestination(conn, someQueue));
+ assertTrue(canWriteDestination(conn, someQueue));
+
+
+ String newSecurityConfig =
+ "<security><role name=\"someotherrole\" read=\"true\" write=\"true\" create=\"false\"/></security>";
+
+ ServerManagement.invoke(on, "stop", null, null);
+ ServerManagement.configureSecurityForDestination("SomeQueue", newSecurityConfig);
+ ServerManagement.invoke(on, "start", null, null);
+
+ assertFalse(canReadDestination(conn, someQueue));
+ assertFalse(canWriteDestination(conn, someQueue));
+
+
+ newSecurityConfig =
+ "<security><role name=\"def\" read=\"true\" write=\"false\" create=\"false\"/></security>";
+
+ ServerManagement.invoke(on, "stop", null, null);
+ ServerManagement.configureSecurityForDestination("SomeQueue", newSecurityConfig);
+ ServerManagement.invoke(on, "start", null, null);
+
+ assertTrue(canReadDestination(conn, someQueue));
+ assertFalse(canWriteDestination(conn, someQueue));
+
+ newSecurityConfig =
+ "<security><role name=\"def\" read=\"true\" write=\"true\" create=\"false\"/></security>";
+
+ ServerManagement.invoke(on, "stop", null, null);
+ ServerManagement.configureSecurityForDestination("SomeQueue", newSecurityConfig);
+ ServerManagement.invoke(on, "start", null, null);
+
+ assertTrue(canReadDestination(conn, someQueue));
+ assertTrue(canWriteDestination(conn, someQueue));
+ }
+ finally
+ {
+ ServerManagement.undeployQueue("SomeQueue");
+ 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
+ ServerManagement.deployTopic("SomeTopic");
+
+ ObjectName on = new ObjectName("jboss.messaging.destination:service=Topic,name=SomeTopic");
+
+ Connection conn = null;
+
+ try
+ {
+ Topic someTopic = (Topic)ic.lookup("/topic/SomeTopic");
+
+ conn = cf.createConnection("john", "needle");
+ assertTrue(canReadDestination(conn, someTopic));
+ assertTrue(canWriteDestination(conn, someTopic));
+
+
+ String newSecurityConfig =
+ "<security><role name=\"someotherrole\" read=\"true\" write=\"true\" create=\"false\"/></security>";
+
+ ServerManagement.invoke(on, "stop", null, null);
+ ServerManagement.configureSecurityForDestination("SomeTopic", newSecurityConfig);
+ ServerManagement.invoke(on, "start", null, null);
+
+ assertFalse(canReadDestination(conn, someTopic));
+ assertFalse(canWriteDestination(conn, someTopic));
+
+
+ newSecurityConfig =
+ "<security><role name=\"def\" read=\"true\" write=\"false\" create=\"false\"/></security>";
+
+ ServerManagement.invoke(on, "stop", null, null);
+ ServerManagement.configureSecurityForDestination("SomeTopic", newSecurityConfig);
+ ServerManagement.invoke(on, "start", null, null);
+
+ assertTrue(canReadDestination(conn, someTopic));
+ assertFalse(canWriteDestination(conn, someTopic));
+
+ newSecurityConfig =
+ "<security><role name=\"def\" read=\"true\" write=\"true\" create=\"false\"/></security>";
+
+ ServerManagement.invoke(on, "stop", null, null);
+ ServerManagement.configureSecurityForDestination("SomeTopic", newSecurityConfig);
+ ServerManagement.invoke(on, "start", null, null);
+
+ assertTrue(canReadDestination(conn, someTopic));
+ assertTrue(canWriteDestination(conn, someTopic));
+ }
+ finally
+ {
+ ServerManagement.undeployTopic("SomeTopic");
+ if (conn != null)
+ {
+ conn.close();
+ }
+ }
+ }
+
+ /**
+ * This test makes sure that changing the queue security configuration on the server has effect
+ * over already deployed destinations.
+ */
+ public void testQueueSecurityUpdate() throws Exception
+ {
+ // "john" has the role def, so he should be able to create a producer and a consumer on a queue
+ ServerManagement.deployQueue("SomeQueue");
+ Connection conn = null;
+
+ try
+ {
+ Queue someQueue = (Queue)ic.lookup("/queue/SomeQueue");
+
+ conn = cf.createConnection("john", "needle");
+ assertTrue(canReadDestination(conn, someQueue));
+ assertTrue(canWriteDestination(conn, someQueue));
+
+
+ String newSecurityConfig =
+ "<security><role name=\"someotherrole\" read=\"true\" write=\"true\" create=\"false\"/></security>";
+
+ ServerManagement.configureSecurityForDestination("SomeQueue", newSecurityConfig);
+
+ assertFalse(canReadDestination(conn, someQueue));
+ assertFalse(canWriteDestination(conn, someQueue));
+
+
+ newSecurityConfig =
+ "<security><role name=\"def\" read=\"true\" write=\"false\" create=\"false\"/></security>";
+
+ ServerManagement.configureSecurityForDestination("SomeQueue", newSecurityConfig);
+
+ assertTrue(canReadDestination(conn, someQueue));
+ assertFalse(canWriteDestination(conn, someQueue));
+
+ newSecurityConfig =
+ "<security><role name=\"def\" read=\"true\" write=\"true\" create=\"false\"/></security>";
+
+ ServerManagement.configureSecurityForDestination("SomeQueue", newSecurityConfig);
+
+ assertTrue(canReadDestination(conn, someQueue));
+ assertTrue(canWriteDestination(conn, someQueue));
+ }
+ finally
+ {
+ ServerManagement.undeployQueue("SomeQueue");
+ if (conn != null)
+ {
+ conn.close();
+ }
+ }
+ }
+
+ /**
+ * This test makes sure that changing the topic security configuration on the server has effect
+ * over already deployed destinations.
+ */
+ public void testTopicSecurityUpdate() throws Exception
+ {
+ // "john" has the role def, so he should be able to create a producer and a consumer on a queue
+ ServerManagement.deployTopic("SomeTopic");
+ Connection conn = null;
+
+ try
+ {
+ Topic someTopic = (Topic)ic.lookup("/topic/SomeTopic");
+
+ conn = cf.createConnection("john", "needle");
+ assertTrue(canReadDestination(conn, someTopic));
+ assertTrue(canWriteDestination(conn, someTopic));
+
+
+ String newSecurityConfig =
+ "<security><role name=\"someotherrole\" read=\"true\" write=\"true\" create=\"false\"/></security>";
+
+ ServerManagement.configureSecurityForDestination("SomeTopic", newSecurityConfig);
+
+ assertFalse(canReadDestination(conn, someTopic));
+ assertFalse(canWriteDestination(conn, someTopic));
+
+
+ newSecurityConfig =
+ "<security><role name=\"def\" read=\"true\" write=\"false\" create=\"false\"/></security>";
+
+ ServerManagement.configureSecurityForDestination("SomeTopic", newSecurityConfig);
+
+ assertTrue(canReadDestination(conn, someTopic));
+ assertFalse(canWriteDestination(conn, someTopic));
+
+ newSecurityConfig =
+ "<security><role name=\"def\" read=\"true\" write=\"true\" create=\"false\"/></security>";
+
+ ServerManagement.configureSecurityForDestination("SomeTopic", newSecurityConfig);
+
+ assertTrue(canReadDestination(conn, someTopic));
+ assertTrue(canWriteDestination(conn, someTopic));
+ }
+ finally
+ {
+ ServerManagement.undeployTopic("SomeTopic");
+ if (conn != null)
+ {
+ conn.close();
+ }
+ }
+ }
+
public void testSecurityForQueuesAndTopicsWithTheSameName() throws Exception
{
ServerManagement.deployQueue("Accounting");
More information about the jboss-cvs-commits
mailing list