@@ -146,6 +146,52 @@ public void testQueueRedeclareEquivalence() throws IOException {
146
146
}
147
147
}
148
148
149
+ public void testActiveQueueDeclareExtendsLease ()
150
+ throws InterruptedException , IOException {
151
+ Map <String , Object > args = new HashMap <String , Object >();
152
+ args .put ("x-expires" , QUEUE_EXPIRES );
153
+ channel .queueDeclare (TEST_EXPIRE_QUEUE , false , false , false , args );
154
+
155
+ Thread .sleep (QUEUE_EXPIRES * 3 / 4 );
156
+ try {
157
+ channel .queueDeclare (TEST_EXPIRE_QUEUE , false , false , false , args );
158
+ } catch (IOException e ) {
159
+ checkShutdownSignal (AMQP .NOT_FOUND , e );
160
+ fail ("Queue expired before active re-declaration." );
161
+ }
162
+
163
+ Thread .sleep (QUEUE_EXPIRES * 3 / 4 );
164
+ try {
165
+ channel .queueDeclarePassive (TEST_EXPIRE_QUEUE );
166
+ } catch (IOException e ) {
167
+ checkShutdownSignal (AMQP .NOT_FOUND , e );
168
+ fail ("Queue expired: active re-declaration did not extend lease." );
169
+ }
170
+ }
171
+
172
+ public void testPassiveQueueDeclareExtendsLease ()
173
+ throws InterruptedException , IOException {
174
+ Map <String , Object > args = new HashMap <String , Object >();
175
+ args .put ("x-expires" , QUEUE_EXPIRES );
176
+ channel .queueDeclare (TEST_EXPIRE_QUEUE , false , false , false , args );
177
+
178
+ Thread .sleep (QUEUE_EXPIRES * 3 / 4 );
179
+ try {
180
+ channel .queueDeclarePassive (TEST_EXPIRE_QUEUE );
181
+ } catch (IOException e ) {
182
+ checkShutdownSignal (AMQP .NOT_FOUND , e );
183
+ fail ("Queue expired before before passive re-declaration." );
184
+ }
185
+
186
+ Thread .sleep (QUEUE_EXPIRES * 3 / 4 );
187
+ try {
188
+ channel .queueDeclarePassive (TEST_EXPIRE_QUEUE );
189
+ } catch (IOException e ) {
190
+ checkShutdownSignal (AMQP .NOT_FOUND , e );
191
+ fail ("Queue expired: passive redeclaration did not extend lease." );
192
+ }
193
+ }
194
+
149
195
void verifyQueueExpires (String name , boolean expire ) throws IOException ,
150
196
InterruptedException {
151
197
Map <String , Object > args = new HashMap <String , Object >();
0 commit comments