2222import java .util .ArrayList ;
2323import java .util .Arrays ;
2424import java .util .Collections ;
25- import java .util .Deque ;
2625import java .util .HashMap ;
2726import java .util .LinkedList ;
2827import java .util .List ;
2928import java .util .Map ;
30- import java .util .Queue ;
3129
3230import com .rabbitmq .client .AMQP ;
3331import com .rabbitmq .client .Channel ;
@@ -66,16 +64,16 @@ public void fill(int n)
6664 * receive n messages - check that we receive no fewer and cannot
6765 * receive more
6866 **/
69- public static Deque <Delivery > drain (QueueingConsumer c , int n )
67+ public static List <Delivery > drain (QueueingConsumer c , int n )
7068 throws IOException
7169 {
72- Deque <Delivery > res = new LinkedList <Delivery >();
70+ List <Delivery > res = new LinkedList <Delivery >();
7371 try {
7472 long start = System .currentTimeMillis ();
7573 for (int i = 0 ; i < n ; i ++) {
7674 Delivery d = c .nextDelivery (1000 );
7775 assertNotNull (d );
78- res .offer (d );
76+ res .add (d );
7977 }
8078 long finish = System .currentTimeMillis ();
8179 Thread .sleep ( (n == 0 ? 0 : (finish - start ) / n ) + 10 );
@@ -131,7 +129,7 @@ public void testNoAckObeysLimit()
131129 } catch (InterruptedException ie ) {
132130 fail ("interrupted" );
133131 }
134- Queue <Delivery > d = drain (c1 , 1 );
132+ List <Delivery > d = drain (c1 , 1 );
135133 ack (d , false ); // must ack before the next one appears
136134 d = drain (c1 , 1 );
137135 ack (d , false );
@@ -164,7 +162,7 @@ public void testFairness()
164162 List <String > queues = configure (c , 1 , queueCount , messageCount );
165163
166164 for (int i = 0 ; i < messageCount - 1 ; i ++) {
167- Queue <Delivery > d = drain (c , 1 );
165+ List <Delivery > d = drain (c , 1 );
168166 ack (d , false );
169167 }
170168
@@ -245,7 +243,7 @@ public void testConsumerLifecycle()
245243 String tag ;
246244 for (int i = 0 ; i < 2 ; i ++) {
247245 tag = channel .basicConsume (queue , false , c );
248- Queue <Delivery > d = drain (c , 1 );
246+ List <Delivery > d = drain (c , 1 );
249247 channel .basicCancel (tag );
250248 drain (c , 0 );
251249 ack (d , true );
@@ -264,7 +262,7 @@ public void testSetLimitAfterConsume()
264262 //We actually only guarantee that the limit takes effect
265263 //*eventually*, so this can in fact fail. It's pretty unlikely
266264 //though.
267- Queue <Delivery > d = drain (c , 1 );
265+ List <Delivery > d = drain (c , 1 );
268266 ack (d , true );
269267 drain (c , 1 );
270268 }
@@ -282,7 +280,7 @@ public void testLimitDecrease()
282280 throws IOException
283281 {
284282 QueueingConsumer c = new QueueingConsumer (channel );
285- Queue <Delivery > d = configure (c , 2 , 4 );
283+ List <Delivery > d = configure (c , 2 , 4 );
286284 channel .basicQos (1 , true );
287285 drain (c , 0 );
288286 ack (d , true );
@@ -312,10 +310,10 @@ public void testLimitingMultipleChannels()
312310 ch1 .basicQos (1 , true );
313311 ch2 .basicQos (1 , true );
314312 fill (5 );
315- Queue <Delivery > d1 = drain (c1 , 1 );
316- Queue <Delivery > d2 = drain (c2 , 1 );
317- ackDelivery (ch1 , d1 .remove (), true );
318- ackDelivery (ch2 , d2 .remove (), true );
313+ List <Delivery > d1 = drain (c1 , 1 );
314+ List <Delivery > d2 = drain (c2 , 1 );
315+ ackDelivery (ch1 , d1 .remove (0 ), true );
316+ ackDelivery (ch2 , d2 .remove (0 ), true );
319317 drain (c1 , 1 );
320318 drain (c2 , 1 );
321319 ch1 .close ();
@@ -364,7 +362,7 @@ protected void runLimitTests(int limit,
364362 }
365363
366364 //is limit enforced?
367- Queue <Delivery > d = drain (c , limit );
365+ List <Delivery > d = drain (c , limit );
368366
369367 //is basic.get not limited?
370368 List <Long > tags = new ArrayList <Long >();
@@ -396,7 +394,7 @@ protected void runLimitTests(int limit,
396394 drain (c , 0 );
397395 }
398396
399- protected Delivery ack (Queue <Delivery > d , boolean multiAck )
397+ protected Delivery ack (List <Delivery > d , boolean multiAck )
400398 throws IOException
401399 {
402400 Delivery last = null ;
@@ -430,7 +428,7 @@ protected List<String> configure(QueueingConsumer c,
430428 return queues ;
431429 }
432430
433- protected Queue <Delivery > configure (QueueingConsumer c ,
431+ protected List <Delivery > configure (QueueingConsumer c ,
434432 int limit ,
435433 int messages )
436434 throws IOException
0 commit comments