Skip to content

Commit e952b70

Browse files
author
Matthew Sackman
committed
Factor out auto-deletion tests
1 parent bb9e0bf commit e952b70

File tree

3 files changed

+111
-71
lines changed

3 files changed

+111
-71
lines changed

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

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -172,75 +172,4 @@ public void testExchangeRoutingLoop() throws IOException,
172172
channel.exchangeUnbind("e1", "e2", "");
173173
channel.exchangeUnbind("e2", "e0", "");
174174
}
175-
176-
/*
177-
* build (A -> B) and (B -> A) and then delete one binding and
178-
* both exchanges should autodelete
179-
*/
180-
public void testAutoDeleteExchangesSimpleLoop() throws IOException {
181-
channel.exchangeDeclare("A", "fanout", false, true, null);
182-
channel.exchangeDeclare("B", "fanout", false, true, null);
183-
channel.exchangeBind("A", "B", "");
184-
channel.exchangeBind("B", "A", "");
185-
186-
channel.exchangeUnbind("A", "B", "");
187-
// both exchanges should not exist now, so it should not be an
188-
// error to redeclare either with different arguments
189-
channel.exchangeDeclare("A", "fanout", true, true, null);
190-
channel.exchangeDeclare("B", "fanout", true, true, null);
191-
channel.exchangeDelete("A");
192-
channel.exchangeDelete("B");
193-
}
194-
195-
/*
196-
* build (A -> B) (B -> C) (C -> D) and then delete D.
197-
* All should autodelete
198-
*/
199-
public void testTransientAutoDelete() throws IOException {
200-
channel.exchangeDeclare("A", "fanout", false, true, null);
201-
channel.exchangeDeclare("B", "fanout", false, true, null);
202-
channel.exchangeDeclare("C", "fanout", false, true, null);
203-
channel.exchangeDeclare("D", "fanout", false, true, null);
204-
205-
channel.exchangeBind("B", "A", "");
206-
channel.exchangeBind("C", "B", "");
207-
channel.exchangeBind("D", "C", "");
208-
209-
channel.exchangeDelete("D");
210-
211-
channel.exchangeDeclare("A", "fanout", true, true, null);
212-
channel.exchangeDelete("A");
213-
}
214-
215-
/*
216-
* build (A -> B) (B -> C) (C -> D)
217-
* (Source -> A) (Source -> B) (Source -> C) (Source -> D)
218-
* On removal of D, all should autodelete
219-
*/
220-
public void testRepeatedTargetAutoDelete() throws IOException {
221-
channel.exchangeDeclare("A", "fanout", false, true, null);
222-
channel.exchangeDeclare("B", "fanout", false, true, null);
223-
channel.exchangeDeclare("C", "fanout", false, true, null);
224-
channel.exchangeDeclare("D", "fanout", false, true, null);
225-
channel.exchangeDeclare("Source", "fanout", false, true, null);
226-
227-
channel.exchangeBind("B", "A", "");
228-
channel.exchangeBind("C", "B", "");
229-
channel.exchangeBind("D", "C", "");
230-
231-
channel.exchangeBind("A", "Source", "");
232-
channel.exchangeBind("B", "Source", "");
233-
channel.exchangeBind("C", "Source", "");
234-
channel.exchangeBind("D", "Source", "");
235-
236-
channel.exchangeDelete("A");
237-
// Source should still be there. We'll verify this by redeclaring
238-
// it here and verifying it goes away later
239-
channel.exchangeDeclare("Source", "fanout", false, true, null);
240-
241-
channel.exchangeDelete("D");
242-
243-
channel.exchangeDeclare("Source", "fanout", true, true, null);
244-
channel.exchangeDelete("Source");
245-
}
246175
}
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
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.test.BrokerTestCase;
37+
38+
public class ExchangeExchangeBindingsAutoDelete extends BrokerTestCase {
39+
40+
/*
41+
* build (A -> B) and (B -> A) and then delete one binding and
42+
* both exchanges should autodelete
43+
*/
44+
public void testAutoDeleteExchangesSimpleLoop() throws IOException {
45+
channel.exchangeDeclare("A", "fanout", false, true, null);
46+
channel.exchangeDeclare("B", "fanout", false, true, null);
47+
channel.exchangeBind("A", "B", "");
48+
channel.exchangeBind("B", "A", "");
49+
50+
channel.exchangeUnbind("A", "B", "");
51+
// both exchanges should not exist now, so it should not be an
52+
// error to redeclare either with different arguments
53+
channel.exchangeDeclare("A", "fanout", true, true, null);
54+
channel.exchangeDeclare("B", "fanout", true, true, null);
55+
channel.exchangeDelete("A");
56+
channel.exchangeDelete("B");
57+
}
58+
59+
/*
60+
* build (A -> B) (B -> C) (C -> D) and then delete D.
61+
* All should autodelete
62+
*/
63+
public void testTransientAutoDelete() throws IOException {
64+
channel.exchangeDeclare("A", "fanout", false, true, null);
65+
channel.exchangeDeclare("B", "fanout", false, true, null);
66+
channel.exchangeDeclare("C", "fanout", false, true, null);
67+
channel.exchangeDeclare("D", "fanout", false, true, null);
68+
69+
channel.exchangeBind("B", "A", "");
70+
channel.exchangeBind("C", "B", "");
71+
channel.exchangeBind("D", "C", "");
72+
73+
channel.exchangeDelete("D");
74+
75+
channel.exchangeDeclare("A", "fanout", true, true, null);
76+
channel.exchangeDelete("A");
77+
}
78+
79+
/*
80+
* build (A -> B) (B -> C) (C -> D)
81+
* (Source -> A) (Source -> B) (Source -> C) (Source -> D)
82+
* On removal of D, all should autodelete
83+
*/
84+
public void testRepeatedTargetAutoDelete() throws IOException {
85+
channel.exchangeDeclare("A", "fanout", false, true, null);
86+
channel.exchangeDeclare("B", "fanout", false, true, null);
87+
channel.exchangeDeclare("C", "fanout", false, true, null);
88+
channel.exchangeDeclare("D", "fanout", false, true, null);
89+
channel.exchangeDeclare("Source", "fanout", false, true, null);
90+
91+
channel.exchangeBind("B", "A", "");
92+
channel.exchangeBind("C", "B", "");
93+
channel.exchangeBind("D", "C", "");
94+
95+
channel.exchangeBind("A", "Source", "");
96+
channel.exchangeBind("B", "Source", "");
97+
channel.exchangeBind("C", "Source", "");
98+
channel.exchangeBind("D", "Source", "");
99+
100+
channel.exchangeDelete("A");
101+
// Source should still be there. We'll verify this by redeclaring
102+
// it here and verifying it goes away later
103+
channel.exchangeDeclare("Source", "fanout", false, true, null);
104+
105+
channel.exchangeDelete("D");
106+
107+
channel.exchangeDeclare("Source", "fanout", true, true, null);
108+
channel.exchangeDelete("Source");
109+
}
110+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public static TestSuite suite() {
5757
suite.addTestSuite(QosTests.class);
5858
suite.addTestSuite(AlternateExchange.class);
5959
suite.addTestSuite(ExchangeExchangeBindings.class);
60+
suite.addTestSuite(ExchangeExchangeBindingsAutoDelete.class);
6061
suite.addTestSuite(ExchangeDeclare.class);
6162
suite.addTestSuite(FrameMax.class);
6263
suite.addTestSuite(QueueLifecycle.class);

0 commit comments

Comments
 (0)