@@ -56,6 +56,20 @@ public void testDeclareQueueWithNonExistingDeadLetterExchange()
5656 declareQueue ("some.random.exchange.name" );
5757 }
5858
59+ public void testDeclareQueueWithEquivalentDeadLetterExchange ()
60+ throws IOException
61+ {
62+ declareQueue (DLX );
63+ declareQueue (DLX );
64+ }
65+
66+ public void testDeclareQueueWithEquivalentDeadLetterRoutingKey ()
67+ throws IOException
68+ {
69+ declareQueue (TEST_QUEUE_NAME , DLX , "routing_key" , null );
70+ declareQueue (TEST_QUEUE_NAME , DLX , "routing_key" , null );
71+ }
72+
5973 public void testDeclareQueueWithInvalidDeadLetterExchangeArg ()
6074 throws IOException
6175 {
@@ -67,6 +81,19 @@ public void testDeclareQueueWithInvalidDeadLetterExchangeArg()
6781 }
6882 }
6983
84+ public void testRedeclareQueueWithInvalidDeadLetterExchangeArg ()
85+ throws IOException
86+ {
87+ declareQueue ("inequivalent_dlx_name" , "dlx_foo" , null , null );
88+ try {
89+ declareQueue ("inequivalent_dlx_name" , 133 , null , null );
90+ fail ("x-dead-letter-exchange must be a valid exchange name " +
91+ "and must not change in subsequent declarations" );
92+ } catch (IOException ex ) {
93+ checkShutdownSignal (AMQP .PRECONDITION_FAILED , ex );
94+ }
95+ }
96+
7097 public void testDeclareQueueWithInvalidDeadLetterRoutingKeyArg ()
7198 throws IOException
7299 {
@@ -78,6 +105,19 @@ public void testDeclareQueueWithInvalidDeadLetterRoutingKeyArg()
78105 }
79106 }
80107
108+ public void testRedeclareQueueWithInvalidDeadLetterRoutingKeyArg ()
109+ throws IOException
110+ {
111+ declareQueue ("inequivalent_dlx_rk" , "amq.direct" , "dlx_rk" , null );
112+ try {
113+ declareQueue ("inequivalent_dlx_rk" , "amq.direct" , 144 , null );
114+ fail ("x-dead-letter-routing-key must be a string and must not " +
115+ "change in subsequent declarations" );
116+ } catch (IOException ex ) {
117+ checkShutdownSignal (AMQP .PRECONDITION_FAILED , ex );
118+ }
119+ }
120+
81121 public void testDeclareQueueWithRoutingKeyButNoDeadLetterExchange ()
82122 throws IOException
83123 {
@@ -90,7 +130,23 @@ public void testDeclareQueueWithRoutingKeyButNoDeadLetterExchange()
90130 } catch (IOException ex ) {
91131 checkShutdownSignal (AMQP .PRECONDITION_FAILED , ex );
92132 }
133+ }
93134
135+ public void testRedeclareQueueWithRoutingKeyButNoDeadLetterExchange ()
136+ throws IOException
137+ {
138+ try {
139+ Map <String , Object > args = new HashMap <String , Object >();
140+ channel .queueDeclare ("bar" , false , true , false , args );
141+
142+ args .put (DLX_RK_ARG , "foo" );
143+
144+ channel .queueDeclare ("bar" , false , true , false , args );
145+ fail ("x-dead-letter-exchange must be specified if " +
146+ "x-dead-letter-routing-key is set" );
147+ } catch (IOException ex ) {
148+ checkShutdownSignal (AMQP .PRECONDITION_FAILED , ex );
149+ }
94150 }
95151
96152 public void testDeadLetterQueueTTLExpiredMessages () throws Exception {
0 commit comments