Skip to content

Commit 84c21a9

Browse files
author
Matthias Radestock
committed
move unbind tests to where they belong
1 parent 912c07f commit 84c21a9

File tree

2 files changed

+41
-39
lines changed

2 files changed

+41
-39
lines changed

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

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
package com.rabbitmq.client.test.functional;
3333

34+
import com.rabbitmq.client.AMQP;
3435
import com.rabbitmq.client.Channel;
3536
import com.rabbitmq.client.Connection;
3637
import com.rabbitmq.client.GetResponse;
@@ -309,6 +310,46 @@ public void testExchangeAutoDeleteDurableManyBindings() throws IOException {
309310
doAutoDelete(true, 10);
310311
}
311312

313+
/**
314+
* Test the behaviour of queue.unbind
315+
*/
316+
public void testUnbind() throws Exception {
317+
318+
Binding b = new Binding(channel.queueDeclare().getQueue(),
319+
"amq.direct",
320+
"quay");
321+
322+
// failure cases
323+
324+
Binding[] tests = new Binding[] {
325+
new Binding("unknown_queue", b.x, b.k),
326+
new Binding(b.q, "unknown_exchange", b.k),
327+
new Binding("unknown_unknown", "exchange_queue", b.k),
328+
// see bug 20633
329+
// new Binding(b.q, b.x, "unknown_rk"),
330+
new Binding("unknown_queue", "unknown_exchange", "unknown_rk")
331+
};
332+
333+
for (int i = 0; i < tests.length; i++) {
334+
335+
Binding test = tests[i];
336+
try {
337+
channel.queueUnbind(test.q, test.x, test.k);
338+
fail("expected not_found in test " + i);
339+
} catch (IOException ee) {
340+
checkShutdownSignal(AMQP.NOT_FOUND, ee);
341+
openChannel();
342+
}
343+
}
344+
345+
// success case
346+
347+
channel.queueBind(b.q, b.x, b.k);
348+
sendRoutable(b);
349+
channel.queueUnbind(b.q, b.x, b.k);
350+
sendUnroutable(b);
351+
}
352+
312353
private void doAutoDelete(boolean durable, int queues) throws IOException {
313354

314355
String[] queueNames = null;

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

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -217,43 +217,4 @@ public void testHeadersRouting() throws Exception {
217217
checkGet(Q2, false);
218218
}
219219

220-
public void testUnbind() throws Exception {
221-
222-
String x = "amq.direct";
223-
String q = "testUnbind";
224-
String routingKey = "quay";
225-
226-
AMQP.Queue.DeclareOk ok = channel.queueDeclare(q);
227-
channel.queueBind(q, x, routingKey);
228-
channel.basicPublish(x, routingKey, null, "foobar".getBytes());
229-
checkGet(q, true);
230-
231-
String[][] tests = new String[][] {
232-
new String[] {"unknown_queue", x, routingKey},
233-
new String[] {q, "unknown_exchange", routingKey},
234-
new String[] {"unknown_queue", "unknown_exchange", routingKey},
235-
// see bug 20633
236-
// new String[] {q, x, "unknown_rk"},
237-
new String[] {"unknown_queue", "unknown_exchange", "unknown_rk"}
238-
};
239-
240-
for (int i = 0; i < tests.length; i++) {
241-
242-
String[] test = tests[i];
243-
try {
244-
channel.queueUnbind(test[0], test[1], test[2]);
245-
fail("expected not_found in test " + i);
246-
} catch (IOException ee) {
247-
checkShutdownSignal(AMQP.NOT_FOUND, ee);
248-
openChannel();
249-
}
250-
}
251-
252-
channel.queueUnbind(q, x, routingKey);
253-
254-
channel.basicPublish(x, routingKey, null, "foobar".getBytes());
255-
checkGet(q, false);
256-
257-
channel.queueDelete(q);
258-
}
259220
}

0 commit comments

Comments
 (0)