@@ -33,6 +33,7 @@ public class QueueSizeLimit extends BrokerTestCase {
3333
3434 private final int MAXLENGTH = 5 ;
3535 private final int MAXLENGTH1 = MAXLENGTH + 1 ;
36+ private final int EXPIRY_TIMEOUT = 100 ;
3637 private final String q = "queue-maxlength" ;
3738
3839 @ Override
@@ -97,6 +98,21 @@ public void testMaxlenZero() throws IOException, InterruptedException {
9798 assertNull (channel .basicGet (q , true ));
9899 }
99100
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+
100116 public void testRequeue () throws IOException , InterruptedException {
101117 declareQueue (false , false );
102118 ArrayList <Long > tags = new ArrayList <Long >(MAXLENGTH );;
0 commit comments