Skip to content

Commit afff448

Browse files
author
Simon MacMullen
committed
Merged bug 22768
2 parents fe1d27d + fb95c54 commit afff448

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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.functional;
33+
34+
import java.io.IOException;
35+
36+
import com.rabbitmq.client.AMQP;
37+
import com.rabbitmq.client.ShutdownSignalException;
38+
import com.rabbitmq.client.test.BrokerTestCase;
39+
40+
/* Declare an exchange, bind a queue to it, then try to delete it,
41+
* setting if-unused to true. This should throw an exception. */
42+
public class ExchangeDeleteIfUnused extends BrokerTestCase {
43+
private final static String EXCHANGE_NAME = "xchg1";
44+
private final static String ROUTING_KEY = "something";
45+
46+
protected void createResources()
47+
throws IOException
48+
{
49+
super.createResources();
50+
channel.exchangeDeclare(EXCHANGE_NAME, "direct");
51+
String queueName = channel.queueDeclare().getQueue();
52+
channel.queueBind(queueName, EXCHANGE_NAME, ROUTING_KEY);
53+
}
54+
55+
protected void releaseResources()
56+
throws IOException
57+
{
58+
channel.exchangeDelete(EXCHANGE_NAME);
59+
super.releaseResources();
60+
}
61+
62+
/* Attempt to Exchange.Delete(ifUnused = true) a used exchange.
63+
* Should throw an exception. */
64+
public void testExchangeDelete() {
65+
try {
66+
channel.exchangeDelete(EXCHANGE_NAME, true);
67+
fail("Exception expected if exchange in use");
68+
} catch (IOException e) {
69+
checkShutdownSignal(AMQP.PRECONDITION_FAILED, e);
70+
}
71+
}
72+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public static TestSuite suite() {
5050
suite.addTestSuite(DurableOnTransient.class);
5151
suite.addTestSuite(NoRequeueOnCancel.class);
5252
suite.addTestSuite(Bug20004Test.class);
53+
suite.addTestSuite(ExchangeDeleteIfUnused.class);
5354
suite.addTestSuite(QosTests.class);
5455
suite.addTestSuite(AlternateExchange.class);
5556
suite.addTestSuite(ExchangeDeclare.class);

0 commit comments

Comments
 (0)