Skip to content

Commit 13e5e75

Browse files
author
Alexandru Scvortov
committed
add test for dead-lettering to a deleted exchange
Also, some of the other tests weren't binding queues when they should have.
1 parent 94245e4 commit 13e5e75

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

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

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ protected void createResources() throws IOException {
3131

3232
@Override
3333
protected void releaseResources() throws IOException {
34-
channel.exchangeDelete(DLX);
34+
try {
35+
channel.exchangeDelete(DLX);
36+
} catch (IOException err) {
37+
// whoosh!
38+
}
3539
}
3640

3741
public void testDeclareQueueWithExistingDeadLetterExchange()
@@ -85,8 +89,11 @@ public void testDeclareQueueWithRoutingKeyButNoDeadLetterExchange()
8589

8690
public void testDeadLetterEmpty() throws Exception {
8791
declareQueue(TEST_QUEUE_NAME, DLX, null, null);
92+
channel.queueBind(TEST_QUEUE_NAME, "amq.direct", "test");
93+
8894
channel.queuePurge(TEST_QUEUE_NAME);
8995
channel.queueDelete(TEST_QUEUE_NAME);
96+
9097
// Nothing was dead-lettered.
9198
consumeN(DLQ, 0, WithResponse.NULL);
9299
}
@@ -102,10 +109,24 @@ public void run() {
102109
}, args, "expired");
103110
}
104111

112+
public void testDeadLetterNonExistingDLX() throws Exception {
113+
declareQueue(TEST_QUEUE_NAME, DLX, null, null, 1);
114+
channel.queueBind(TEST_QUEUE_NAME, "amq.direct", "test");
115+
116+
channel.exchangeDelete(DLX);
117+
118+
publishN(MSG_COUNT);
119+
sleep(100);
120+
121+
// Nothing was dead-lettered.
122+
consumeN(DLQ, 0, WithResponse.NULL);
123+
}
124+
105125
public void testDeadLetterExchangeDeleteTwice()
106126
throws IOException
107127
{
108128
declareQueue(TEST_QUEUE_NAME, DLX, null, null, 1);
129+
channel.queueBind(TEST_QUEUE_NAME, "amq.direct", "test");
109130

110131
publishN(MSG_COUNT_MANY);
111132
channel.queueDelete(TEST_QUEUE_NAME);
@@ -126,8 +147,10 @@ public void testDeadLetterOnNack() throws Exception {
126147

127148
public void testDeadLetterNoDeadLetterQueue() throws IOException {
128149
channel.queueDelete(DLQ);
150+
129151
declareQueue(TEST_QUEUE_NAME, DLX, null, null, 1);
130152
channel.queueBind(TEST_QUEUE_NAME, "amq.direct", "test");
153+
131154
publishN(MSG_COUNT);
132155
}
133156

0 commit comments

Comments
 (0)