Skip to content

Commit

Permalink
ARTEMIS-4387 Improving Consumer Memory Leak test with a non empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
clebertsuconic committed Aug 14, 2023
1 parent 019b682 commit ea1a556
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,14 @@ public void setUp() throws Exception {
}

@Test
public void testConsumerCreatedWithEmptyFilterString() throws Exception {
public void testConsumerFiltered() throws Exception {

ServerLocator locator = ActiveMQClient.createServerLocator("tcp://localhost:61616");
SimpleString queue = RandomUtil.randomSimpleString();
SimpleString address = RandomUtil.randomSimpleString();
SimpleString filter = SimpleString.toSimpleString("");
SimpleString emptyString = SimpleString.toSimpleString("");
SimpleString dummyFilter = SimpleString.toSimpleString("dummy=true");


try (ClientSessionFactory sf = createSessionFactory(locator);
ClientSession clientSession = sf.createSession()) {
Expand All @@ -66,8 +68,14 @@ public void testConsumerCreatedWithEmptyFilterString() throws Exception {
clientSession.createQueue(new QueueConfiguration(queue).setAddress(address).setDurable(true));
CheckLeak checkLeak = new CheckLeak();
int initialSimpleString = 0;

for (int i = 0; i < 500; i++) {
ClientConsumer consumer = clientSession.createConsumer(queue, filter);
ClientConsumer consumer;
if (i % 2 == 0) {
consumer = clientSession.createConsumer(queue, emptyString);
} else {
consumer = clientSession.createConsumer(queue, dummyFilter);
}
consumer.close();
consumer = null; // setting it to null to release the consumer earlier before the checkLeak call bellow
if (i == 100) {
Expand Down

0 comments on commit ea1a556

Please sign in to comment.