summaryrefslogtreecommitdiff
path: root/qpid/java/broker/src/test
diff options
context:
space:
mode:
authorAlex Rudyy <orudyy@apache.org>2013-03-28 15:42:39 +0000
committerAlex Rudyy <orudyy@apache.org>2013-03-28 15:42:39 +0000
commiteae2b134840386ce3654737476142b96a12a404f (patch)
treec9f0a71ebb2d19496f6a656cd21002935e2d15f4 /qpid/java/broker/src/test
parent56bd292e1e13798edef69bc58c6b84bbc38aa888 (diff)
downloadqpid-python-eae2b134840386ce3654737476142b96a12a404f.tar.gz
QPID-4671: [Java Broker] Fix NPE occuring in FanoutExchange#isBound(... AMQQueue) when queue parameter is null
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1462162 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/FanoutExchangeTest.java67
1 files changed, 67 insertions, 0 deletions
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/FanoutExchangeTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/FanoutExchangeTest.java
new file mode 100644
index 0000000000..67739373e1
--- /dev/null
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/FanoutExchangeTest.java
@@ -0,0 +1,67 @@
+package org.apache.qpid.server.exchange;
+
+import static org.mockito.Mockito.mock;
+
+import java.util.UUID;
+
+import junit.framework.TestCase;
+
+import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.framing.FieldTable;
+import org.apache.qpid.server.binding.Binding;
+import org.apache.qpid.server.queue.AMQQueue;
+
+public class FanoutExchangeTest extends TestCase
+{
+ private FanoutExchange _exchange;
+
+ public void setUp()
+ {
+ _exchange = new FanoutExchange();
+ }
+
+ public void testIsBoundAMQShortStringFieldTableAMQQueueWhenQueueIsNull()
+ {
+ assertFalse("calling isBound(AMQShortString,FieldTable,AMQQueue) with null queue should return false",
+ _exchange.isBound((AMQShortString) null, (FieldTable) null, (AMQQueue) null));
+ }
+
+ public void testIsBoundAMQShortStringAMQQueueWhenQueueIsNull()
+ {
+ assertFalse("calling isBound(AMQShortString,AMQQueue) with null queue should return false",
+ _exchange.isBound((AMQShortString) null, (AMQQueue) null));
+ }
+
+ public void testIsBoundAMQQueueWhenQueueIsNull()
+ {
+ assertFalse("calling isBound(AMQQueue) with null queue should return false", _exchange.isBound((AMQQueue) null));
+ }
+
+ public void testIsBoundAMQShortStringFieldTableAMQQueue()
+ {
+ AMQQueue queue = bindQueue();
+ assertTrue("Should return true for a bound queue",
+ _exchange.isBound((AMQShortString) null, (FieldTable) null, queue));
+ }
+
+ public void testIsBoundAMQShortStringAMQQueue()
+ {
+ AMQQueue queue = bindQueue();
+ assertTrue("Should return true for a bound queue",
+ _exchange.isBound((AMQShortString) null, queue));
+ }
+
+ public void testIsBoundAMQQueue()
+ {
+ AMQQueue queue = bindQueue();
+ assertTrue("Should return true for a bound queue",
+ _exchange.isBound(queue));
+ }
+
+ private AMQQueue bindQueue()
+ {
+ AMQQueue queue = mock(AMQQueue.class);
+ _exchange.addBinding(new Binding(UUID.randomUUID(), "does not matter", queue, _exchange, null));
+ return queue;
+ }
+}