1515
1616package com .rabbitmq .client .test .functional ;
1717
18- import static org . junit . Assert . assertEquals ;
19- import static org . junit . Assert . assertNotNull ;
20- import static org . junit . Assert . assertNull ;
21- import static org . junit . Assert . assertTrue ;
22- import static org .junit .Assert . fail ;
18+ import com . rabbitmq . client .* ;
19+ import com . rabbitmq . client . AMQP . BasicProperties ;
20+ import com . rabbitmq . client . QueueingConsumer . Delivery ;
21+ import com . rabbitmq . client . test . BrokerTestCase ;
22+ import org .junit .Test ;
2323
2424import java .io .IOException ;
25- import java .util .ArrayList ;
26- import java .util .Arrays ;
27- import java .util .Collections ;
28- import java .util .HashMap ;
29- import java .util .List ;
30- import java .util .Map ;
25+ import java .util .*;
3126import java .util .concurrent .Callable ;
3227import java .util .concurrent .CountDownLatch ;
3328import java .util .concurrent .TimeUnit ;
3429
35- import org .junit .Test ;
36-
37- import com .rabbitmq .client .AMQP ;
38- import com .rabbitmq .client .AMQP .BasicProperties ;
39- import com .rabbitmq .client .Channel ;
40- import com .rabbitmq .client .DefaultConsumer ;
41- import com .rabbitmq .client .Envelope ;
42- import com .rabbitmq .client .GetResponse ;
43- import com .rabbitmq .client .MessageProperties ;
44- import com .rabbitmq .client .QueueingConsumer ;
45- import com .rabbitmq .client .QueueingConsumer .Delivery ;
46- import com .rabbitmq .client .test .BrokerTestCase ;
30+ import static org .junit .Assert .*;
4731
4832public class DeadLetterExchange extends BrokerTestCase {
4933 public static final String DLX = "dead.letter.exchange" ;
@@ -55,11 +39,6 @@ public class DeadLetterExchange extends BrokerTestCase {
5539 public static final int MSG_COUNT = 10 ;
5640 public static final int TTL = 1000 ;
5741
58- @ Override
59- protected boolean isAutomaticRecoveryEnabled () {
60- return false ;
61- }
62-
6342 @ Override
6443 protected void createResources () throws IOException {
6544 channel .exchangeDelete (DLX );
@@ -154,7 +133,7 @@ protected void releaseResources() throws IOException {
154133 Map <String , Object > args = new HashMap <String , Object >();
155134 args .put (DLX_RK_ARG , "foo" );
156135
157- channel .queueDeclare ("bar" , false , true , false , args );
136+ channel .queueDeclare (randomQueueName () , false , true , false , args );
158137 fail ("dlx must be defined if dl-rk is set" );
159138 } catch (IOException ex ) {
160139 checkShutdownSignal (AMQP .PRECONDITION_FAILED , ex );
@@ -164,12 +143,13 @@ protected void releaseResources() throws IOException {
164143 @ Test public void redeclareQueueWithRoutingKeyButNoDeadLetterExchange ()
165144 throws IOException , InterruptedException {
166145 try {
146+ String queueName = randomQueueName ();
167147 Map <String , Object > args = new HashMap <String , Object >();
168- channel .queueDeclare ("bar" , false , true , false , args );
148+ channel .queueDeclare (queueName , false , true , false , args );
169149
170150 args .put (DLX_RK_ARG , "foo" );
171151
172- channel .queueDeclare ("bar" , false , true , false , args );
152+ channel .queueDeclare (queueName , false , true , false , args );
173153 fail ("x-dead-letter-exchange must be specified if " +
174154 "x-dead-letter-routing-key is set" );
175155 } catch (IOException ex ) {
@@ -715,4 +695,8 @@ public void process(GetResponse getResponse) {
715695
716696 public void process (GetResponse response );
717697 }
698+
699+ private static String randomQueueName () {
700+ return DeadLetterExchange .class .getSimpleName () + "-" + UUID .randomUUID ().toString ();
701+ }
718702}
0 commit comments