Skip to content

Commit d8c8fe8

Browse files
author
Alexandru Scvortov
committed
added checks for shutdown signals
1 parent b42f848 commit d8c8fe8

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

test/src/com/rabbitmq/client/test/functional/ExchangeDeclare.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import java.util.HashMap;
3636
import java.io.IOException;
3737

38+
import com.rabbitmq.client.AMQP;
3839
import com.rabbitmq.client.Channel;
3940

4041
import com.rabbitmq.client.test.BrokerTestCase;
@@ -57,14 +58,15 @@ public static void verifyEquivalent(Channel channel, String name,
5758
}
5859

5960
// Note: this will close the channel
60-
public static void verifyNotEquivalent(Channel channel, String name,
61+
public void verifyNotEquivalent(Channel channel, String name,
6162
String type, boolean durable, boolean autoDelete,
6263
Map<String, Object> args) throws IOException {
6364
channel.exchangeDeclarePassive(name);
6465
try {
6566
channel.exchangeDeclare(name, type, durable, autoDelete, args);
6667
fail("Exchange was supposed to be not equivalent");
6768
} catch (IOException ioe) {
69+
checkShutdownSignal(AMQP.NOT_ALLOWED, ioe);
6870
return;
6971
}
7072
}

test/src/com/rabbitmq/client/test/functional/QueueExclusivity.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import java.io.IOException;
3535
import java.util.HashMap;
3636

37+
import com.rabbitmq.client.AMQP;
3738
import com.rabbitmq.client.Channel;
3839
import com.rabbitmq.client.Connection;
3940
import com.rabbitmq.client.QueueingConsumer;
@@ -66,6 +67,7 @@ public void testQueueExclusiveForPassiveDeclare() throws Exception {
6667
try {
6768
channel.queueDeclarePassive(q);
6869
} catch (IOException ioe) {
70+
checkShutdownSignal(AMQP.RESOURCE_LOCKED, ioe);
6971
return;
7072
}
7173
fail("Passive queue declaration of an exclusive queue from another connection should fail");
@@ -77,6 +79,7 @@ public void testQueueExclusiveForDeclare() throws Exception {
7779
try {
7880
channel.queueDeclare(q, false, true, false, noArgs);
7981
} catch (IOException ioe) {
82+
checkShutdownSignal(AMQP.RESOURCE_LOCKED, ioe);
8083
return;
8184
}
8285
fail("Active queue declaration of an exclusive queue from another connection should fail");
@@ -87,6 +90,7 @@ public void testQueueExclusiveForConsume() throws Exception {
8790
try {
8891
channel.basicConsume(q, c);
8992
} catch (IOException ioe) {
93+
checkShutdownSignal(AMQP.RESOURCE_LOCKED, ioe);
9094
return;
9195
}
9296
fail("Exclusive queue should be locked for basic consume from another connection");
@@ -96,6 +100,7 @@ public void testQueueExclusiveForPurge() throws Exception {
96100
try {
97101
channel.queuePurge(q);
98102
} catch (IOException ioe) {
103+
checkShutdownSignal(AMQP.RESOURCE_LOCKED, ioe);
99104
return;
100105
}
101106
fail("Exclusive queue should be locked for queue purge from another connection");
@@ -105,6 +110,7 @@ public void testQueueExclusiveForDelete() throws Exception {
105110
try {
106111
channel.queueDelete(q);
107112
} catch (IOException ioe) {
113+
checkShutdownSignal(AMQP.RESOURCE_LOCKED, ioe);
108114
return;
109115
}
110116
fail("Exclusive queue should be locked for queue delete from another connection");
@@ -114,6 +120,7 @@ public void testQueueExclusiveForBind() throws Exception {
114120
try {
115121
channel.queueBind(q, "", ""); // NB uses default exchange
116122
} catch (IOException ioe) {
123+
checkShutdownSignal(AMQP.INTERNAL_ERROR, ioe);
117124
return;
118125
}
119126
fail("Exclusive queue should be locked for queue bind from another connection");
@@ -131,6 +138,7 @@ public void testQueueExclusiveForUnbind() throws Exception {
131138
try {
132139
channel.queueUnbind(q, "", "");
133140
} catch (IOException ioe) {
141+
checkShutdownSignal(AMQP.INTERNAL_ERROR, ioe);
134142
return;
135143
}
136144
fail("Exclusive queue should be locked for queue unbind from another connection");
@@ -140,6 +148,7 @@ public void testQueueExclusiveForGet() throws Exception {
140148
try {
141149
channel.basicGet(q, true);
142150
} catch (IOException ioe) {
151+
checkShutdownSignal(AMQP.RESOURCE_LOCKED, ioe);
143152
return;
144153
}
145154
fail("Exclusive queue should be locked for basic get from another connection");

test/src/com/rabbitmq/client/test/functional/QueueLifecycle.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import java.util.HashMap;
3636
import java.util.Map;
3737

38+
import com.rabbitmq.client.AMQP;
3839
import com.rabbitmq.client.QueueingConsumer;
3940
import com.rabbitmq.client.test.BrokerTestCase;
4041

@@ -81,6 +82,10 @@ void verifyNotEquivalent(boolean durable, boolean exclusive,
8182
try {
8283
verifyQueue(q, durable, exclusive, autoDelete, null);
8384
} catch (IOException ioe) {
85+
if (exclusive)
86+
checkShutdownSignal(AMQP.RESOURCE_LOCKED, ioe);
87+
else
88+
checkShutdownSignal(AMQP.NOT_ALLOWED, ioe);
8489
return;
8590
}
8691
fail("Queue.declare should have been rejected as not equivalent");

0 commit comments

Comments
 (0)