@@ -33,6 +33,7 @@ public class QueueSizeLimit extends BrokerTestCase {
33
33
34
34
private final int MAXLENGTH = 5 ;
35
35
private final int MAXLENGTH1 = MAXLENGTH + 1 ;
36
+ private final int EXPIRY_TIMEOUT = 100 ;
36
37
private final String q = "queue-maxlength" ;
37
38
38
39
@ Override
@@ -97,6 +98,21 @@ public void testMaxlenZero() throws IOException, InterruptedException {
97
98
assertNull (channel .basicGet (q , true ));
98
99
}
99
100
101
+ public void testMaxlenOne () throws IOException , InterruptedException {
102
+ Map <String , Object > args = new HashMap <String , Object >();
103
+ args .put ("x-max-length" , 1 );
104
+ channel .queueDeclare (q , false , true , true , args );
105
+
106
+ AMQP .BasicProperties props = new AMQP .BasicProperties ();
107
+ props .setExpiration ((new Integer (EXPIRY_TIMEOUT )).toString ());
108
+ channel .basicPublish ("" , q , props , "msg1" .getBytes ());
109
+ channel .basicPublish ("" , q , null , "msg2" .getBytes ());
110
+
111
+ channel .waitForConfirms ();
112
+ Thread .sleep (EXPIRY_TIMEOUT * 2 );
113
+ assertHead (1 , "msg2" , q );
114
+ }
115
+
100
116
public void testRequeue () throws IOException , InterruptedException {
101
117
declareQueue (false , false );
102
118
ArrayList <Long > tags = new ArrayList <Long >(MAXLENGTH );;
0 commit comments