Skip to content

Commit 7579dfc

Browse files
author
Alexandru Scvortov
committed
added test case for Exchange.Delete with isUnused set
1 parent 470f567 commit 7579dfc

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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 at
4+
// 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 the
8+
// License for the specific language governing rights and limitations
9+
// under the License.
10+
//
11+
// The Original Code is RabbitMQ.
12+
//
13+
// The Initial Developers of the Original Code are LShift Ltd,
14+
// Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd.
15+
//
16+
// Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd,
17+
// Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd
18+
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
19+
// Technologies LLC, and Rabbit Technologies Ltd.
20+
//
21+
// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
22+
// Ltd. Portions created by Cohesive Financial Technologies LLC are
23+
// Copyright (C) 2007-2010 Cohesive Financial Technologies
24+
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
25+
// (C) 2007-2010 Rabbit Technologies Ltd.
26+
//
27+
// All Rights Reserved.
28+
//
29+
// Contributor(s): ______________________________________.
30+
//
31+
32+
package com.rabbitmq.client.test.server;
33+
34+
import java.io.IOException;
35+
36+
import com.rabbitmq.client.ShutdownSignalException;
37+
import com.rabbitmq.client.test.BrokerTestCase;
38+
39+
public class ExchangeDeleteIfUnused extends BrokerTestCase {
40+
private final static String ExchangeName = "xchg1";
41+
private final static String QueueName = "myQueue";
42+
private final static String RoutingKey = "something";
43+
44+
protected void createResources()
45+
throws IOException
46+
{
47+
super.createResources();
48+
channel.exchangeDeclare(ExchangeName, "direct");
49+
channel.queueDeclare(QueueName);
50+
channel.queueBind(QueueName, ExchangeName, RoutingKey);
51+
}
52+
53+
protected void releaseResources()
54+
throws IOException
55+
{
56+
channel.queueDelete(QueueName);
57+
channel.exchangeDelete(ExchangeName);
58+
super.releaseResources();
59+
}
60+
61+
public void testExchangeDelete() {
62+
try {
63+
// exchange.delete(ifUnused = true)
64+
// should throw a channel exception if the exchange is being used
65+
channel.exchangeDelete(ExchangeName, true);
66+
fail("Exception expected if exchange in use");
67+
} catch (IOException e) {
68+
assertTrue("Should be com.rabbitmq.client.ShutdownSignalException",
69+
e.getCause() instanceof ShutdownSignalException);
70+
String msg = e.getCause().getMessage();
71+
assertTrue("Exception should contain ``in use''", msg.toLowerCase().contains("in use"));
72+
// ok
73+
}
74+
}
75+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public static TestSuite suite() {
4040
suite.addTestSuite(Permissions.class);
4141
suite.addTestSuite(DurableBindingLifecycle.class);
4242
suite.addTestSuite(EffectVisibilityCrossNodeTest.class);
43+
suite.addTestSuite(ExchangeDeleteIfUnused.class);
4344
suite.addTest(PersisterRestartTests.suite());
4445
return suite;
4546
}

0 commit comments

Comments
 (0)