2828 */
2929public class QueueSizeLimit extends BrokerTestCase {
3030
31- private final int MAXDEPTH = 5 ;
31+ private final int MAXDEPTH = 5 ;
3232 private final String q = "queue" ;
3333
3434 @ Override
@@ -51,7 +51,7 @@ public void testQueueSize() throws IOException, InterruptedException {
5151 }
5252 }
5353
54- public void testQueueUnacked () throws IOException , InterruptedException {
54+ public void testQueueAllUnacked () throws IOException , InterruptedException {
5555 declareQueue ();
5656 for (int i =1 ; i <= MAXDEPTH ; i ++){
5757 channel .basicPublish ("" , q , null , ("msg" + i ).getBytes ());
@@ -64,6 +64,24 @@ public void testQueueUnacked() throws IOException, InterruptedException {
6464 assertEquals (null , channel .basicGet (q , false ));
6565 }
6666
67+ public void testQueueSomeUnacked () throws IOException , InterruptedException {
68+ declareQueue ();
69+ for (int i =1 ; i <= MAXDEPTH - 1 ; i ++){
70+ channel .basicPublish ("" , q , null , ("msg" + i ).getBytes ());
71+ channel .waitForConfirmsOrDie ();
72+ channel .basicGet (q , false );
73+ assertEquals (0 , declareQueue ());
74+ }
75+ channel .basicPublish ("" , q , null , ("msg" + MAXDEPTH ).getBytes ());
76+ channel .waitForConfirmsOrDie ();
77+ assertEquals (1 , declareQueue ());
78+
79+ channel .basicPublish ("" , q , null , ("msg overflow" ).getBytes ());
80+ channel .waitForConfirmsOrDie ();
81+ assertEquals ("msg overflow" , new String (channel .basicGet (q , false ).getBody ()));
82+ assertEquals (null , channel .basicGet (q , false ));
83+ }
84+
6785 private int declareQueue () throws IOException {
6886 Map <String , Object > args = new HashMap <String , Object >();
6987 args .put ("x-maxdepth" , MAXDEPTH );
0 commit comments