diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingReceiveTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingReceiveTest.java index 3e564610c2..e9d1c99c34 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingReceiveTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingReceiveTest.java @@ -41,6 +41,8 @@ public class PagingReceiveTest extends ActiveMQTestBase { private ServerLocator locator; + private int numMsgs = 500; + protected boolean isNetty() { return false; } @@ -48,11 +50,20 @@ public class PagingReceiveTest extends ActiveMQTestBase { @Test public void testReceive() throws Exception { ClientMessage message = receiveMessage(); - System.out.println("message received:" + message); - assertNotNull("Message not found.", message); } + @Test + public void testReceiveThenCheckCounter() throws Exception { + + Queue queue = server.locateQueue(ADDRESS); + assertEquals(numMsgs, queue.getMessagesAdded()); + receiveAllMessages(); + queue.getPageSubscription().cleanupEntries(true); + assertEquals(numMsgs, queue.getMessagesAdded()); + } + + @Override @Before public void setUp() throws Exception { @@ -85,7 +96,7 @@ public class PagingReceiveTest extends ActiveMQTestBase { server.stop(); - internalCreateServer(); + server = internalCreateServer(); } @@ -100,6 +111,22 @@ public class PagingReceiveTest extends ActiveMQTestBase { return server; } + private void receiveAllMessages() throws Exception { + final ClientSessionFactory sf = createSessionFactory(locator); + ClientSession session = sf.createSession(null, null, false, true, true, false, 0); + + session.start(); + ClientConsumer consumer = session.createConsumer(ADDRESS); + for (int i = 0; i < numMsgs; i++) { + ClientMessage message = consumer.receive(2000); + assertNotNull(message); + message.acknowledge(); + } + + session.commit(); + session.close(); + } + private ClientMessage receiveMessage() throws Exception { final ClientSessionFactory sf = createSessionFactory(locator); ClientSession session = sf.createSession(null, null, false, true, true, false, 0);