summaryrefslogtreecommitdiff
path: root/qpid/java/broker/src/test
diff options
context:
space:
mode:
authorMarnie McCormack <marnie@apache.org>2010-07-05 20:00:54 +0000
committerMarnie McCormack <marnie@apache.org>2010-07-05 20:00:54 +0000
commit8db7ae7ca30bdf2f71598d5a52b5711705a1a011 (patch)
tree0fec823649ec255325dde0c915b0e4a8a994ef3d /qpid/java/broker/src/test
parent94a3e6777e07f5b3f56d1cb7de5e9ccafaf94bc9 (diff)
downloadqpid-python-8db7ae7ca30bdf2f71598d5a52b5711705a1a011.tar.gz
QPID-2700 Patch for ability to remove bindings from exchanges and additional tests for direct and topic exchange add/remove logic from Andrew Kennedy
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@960678 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/broker/src/test')
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/ExchangeMBeanTest.java79
1 files changed, 79 insertions, 0 deletions
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/ExchangeMBeanTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/ExchangeMBeanTest.java
index e3e736509e..b51c88680e 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/ExchangeMBeanTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/ExchangeMBeanTest.java
@@ -36,6 +36,7 @@ import org.apache.qpid.framing.AMQShortString;
import javax.management.openmbean.TabularData;
import java.util.ArrayList;
+import java.util.Collections;
/**
* Unit test class for testing different Exchange MBean operations
@@ -126,6 +127,84 @@ public class ExchangeMBeanTest extends InternalBrokerBaseCase
assertTrue(!mbean.isDurable());
assertTrue(mbean.isAutoDelete());
}
+
+ /**
+ * Test adding bindings and removing them from the topic exchange via JMX.
+ * <p>
+ * QPID-2700
+ */
+ public void testTopicBindings() throws Exception
+ {
+ int bindings = _queue.getBindingCount();
+
+ Exchange exchange = _queue.getVirtualHost().getExchangeRegistry().getExchange(new AMQShortString("amq.topic"));
+ ManagedExchange mbean = (ManagedExchange) ((AbstractExchange) exchange).getManagedObject();
+
+ mbean.createNewBinding(_queue.getName(), "robot.#");
+ mbean.createNewBinding(_queue.getName(), "#.kitten");
+
+ assertEquals("Should have added two bindings", bindings + 2, _queue.getBindingCount());
+
+ mbean.removeBinding(_queue.getName(), "robot.#");
+
+ assertEquals("Should have one extra binding", bindings + 1, _queue.getBindingCount());
+
+ mbean.removeBinding(_queue.getName(), "#.kitten");
+
+ assertEquals("Should have original number of binding", bindings, _queue.getBindingCount());
+ }
+
+ /**
+ * Test adding bindings and removing them from the default exchange via JMX.
+ * <p>
+ * QPID-2700
+ */
+ public void testDefaultBindings() throws Exception
+ {
+ int bindings = _queue.getBindingCount();
+
+ Exchange exchange = _queue.getVirtualHost().getExchangeRegistry().getDefaultExchange();
+ ManagedExchange mbean = (ManagedExchange) ((AbstractExchange) exchange).getManagedObject();
+
+ mbean.createNewBinding(_queue.getName(), "robot");
+ mbean.createNewBinding(_queue.getName(), "kitten");
+
+ assertEquals("Should have added two bindings", bindings + 2, _queue.getBindingCount());
+
+ mbean.removeBinding(_queue.getName(), "robot");
+
+ assertEquals("Should have one extra binding", bindings + 1, _queue.getBindingCount());
+
+ mbean.removeBinding(_queue.getName(), "kitten");
+
+ assertEquals("Should have original number of binding", bindings, _queue.getBindingCount());
+ }
+
+ /**
+ * Test adding bindings and removing them from the topic exchange via JMX.
+ * <p>
+ * QPID-2700
+ */
+ public void testTopicBindings() throws Exception
+ {
+ int bindings = _queue.getBindingCount();
+
+ Exchange exchange = _queue.getVirtualHost().getExchangeRegistry().getExchange(new AMQShortString("amq.topic"));
+ ManagedExchange mbean = (ManagedExchange) ((AbstractExchange) exchange).getManagedObject();
+
+ mbean.createNewBinding(_queue.getName(), "robot.#");
+ mbean.createNewBinding(_queue.getName(), "#.kitten");
+
+ assertEquals("Should have added two bindings", bindings + 2, _queue.getBindingCount());
+
+ mbean.removeBinding(_queue.getName(), "robot.#");
+
+ assertEquals("Should have one extra binding", bindings + 1, _queue.getBindingCount());
+
+ mbean.removeBinding(_queue.getName(), "#.kitten");
+
+ assertEquals("Should have original number of binding", bindings, _queue.getBindingCount());
+ }
@Override
public void setUp() throws Exception