|
| 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 | +} |
0 commit comments