Skip to content

Commit ff49a79

Browse files
committed
add tests for 'absent' queue error handling
1 parent c16bdd5 commit ff49a79

File tree

2 files changed

+99
-0
lines changed

2 files changed

+99
-0
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
// The contents of this file are subject to the Mozilla Public License
2+
// Version 1.1 (the "License"); you may not use this file except in
3+
// compliance with the License. You may obtain a copy of the License
4+
// at http://www.mozilla.org/MPL/
5+
//
6+
// Software distributed under the License is distributed on an "AS IS"
7+
// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
8+
// the License for the specific language governing rights and
9+
// limitations under the License.
10+
//
11+
// The Original Code is RabbitMQ.
12+
//
13+
// The Initial Developer of the Original Code is VMware, Inc.
14+
// Copyright (c) 2007-2012 VMware, Inc. All rights reserved.
15+
//
16+
17+
18+
package com.rabbitmq.client.test.server;
19+
20+
import com.rabbitmq.client.AMQP;
21+
import com.rabbitmq.client.test.functional.ClusteredTestBase;
22+
import com.rabbitmq.tools.Host;
23+
24+
import java.io.IOException;
25+
26+
/**
27+
* This tests whether 'absent' queues - durable queues whose home node
28+
* is down - are handled properly.
29+
*/
30+
public class AbsentQueue extends ClusteredTestBase {
31+
32+
private static final String Q = "absent-queue";
33+
34+
@Override protected void setUp() throws IOException {
35+
super.setUp();
36+
if (clusteredConnection != null)
37+
Host.executeCommand("cd ../rabbitmq-test; make stop-secondary-app");
38+
}
39+
40+
@Override protected void tearDown() throws IOException {
41+
if (clusteredConnection != null)
42+
Host.executeCommand("cd ../rabbitmq-test; make start-secondary-app");
43+
super.tearDown();
44+
}
45+
46+
@Override protected void createResources() throws IOException {
47+
alternateChannel.queueDeclare(Q, true, false, false, null);
48+
}
49+
50+
@Override protected void releaseResources() throws IOException {
51+
alternateChannel.queueDelete(Q);
52+
}
53+
54+
public void testNotFound() throws IOException {
55+
assertNotFound(new Task() {
56+
public void run() throws IOException {
57+
channel.queueDeclare(Q, true, false, false, null);
58+
}
59+
});
60+
assertNotFound(new Task() {
61+
public void run() throws IOException {
62+
channel.queueDeclarePassive(Q);
63+
}
64+
});
65+
assertNotFound(new Task() {
66+
public void run() throws IOException {
67+
channel.queuePurge(Q);
68+
}
69+
});
70+
assertNotFound(new Task() {
71+
public void run() throws IOException {
72+
channel.basicGet(Q, true);
73+
}
74+
});
75+
assertNotFound(new Task() {
76+
public void run() throws IOException {
77+
channel.queueBind(Q, "amq.fanout", "", null);
78+
}
79+
});
80+
}
81+
82+
protected void assertNotFound(Task t) throws IOException {
83+
if (clusteredChannel == null) return;
84+
try {
85+
t.run();
86+
fail("expected not_found");
87+
} catch (IOException ioe) {
88+
checkShutdownSignal(AMQP.NOT_FOUND, ioe);
89+
channel = connection.createChannel();
90+
}
91+
92+
}
93+
94+
private interface Task {
95+
public void run() throws IOException;
96+
}
97+
98+
}

test/src/com/rabbitmq/client/test/server/ServerTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public static void add(TestSuite suite) {
3232
suite.addTestSuite(DurableBindingLifecycle.class);
3333
suite.addTestSuite(EffectVisibilityCrossNodeTest.class);
3434
suite.addTestSuite(ExclusiveQueueDurability.class);
35+
suite.addTestSuite(AbsentQueue.class);
3536
suite.addTestSuite(AlternateExchangeEquivalence.class);
3637
suite.addTestSuite(MemoryAlarms.class);
3738
suite.addTestSuite(MessageRecovery.class);

0 commit comments

Comments
 (0)