summaryrefslogtreecommitdiff
path: root/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
commit3c57e4b18865b717404ea41efbd4b80516a92a33 (patch)
tree4ca087388cc0ee54ef99961f48b4340c08d05feb /java/broker/src/test
parent0f7f0aa39aabb79d49f0fb7294fa233d3f8d5981 (diff)
downloadqpid-python-3c57e4b18865b717404ea41efbd4b80516a92a33.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/qpid@960678 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/broker/src/test')
-rw-r--r--java/broker/src/test/java/org/apache/qpid/server/exchange/ExchangeMBeanTest.java79
1 files changed, 79 insertions, 0 deletions
diff --git a/java/broker/src/test/java/org/apache/qpid/server/exchange/ExchangeMBeanTest.java b/java/broker/src/test/java/org/apache/qpid/server/exchange/ExchangeMBeanTest.java
index e3e736509e..b51c88680e 100644
--- a/java/broker/src/test/java/org/apache/qpid/server/exchange/ExchangeMBeanTest.java
+++ b/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