Skip to content

Commit 495abf1

Browse files
committed
[#] Fix flaky test: ActiveDurableSubscriptionBrowseExpireTest.java
1 parent 172c79d commit 495abf1

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

activemq-unit-tests/src/test/java/org/apache/activemq/usecases/ActiveDurableSubscriptionBrowseExpireTest.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import static org.junit.Assert.assertEquals;
2020
import static org.junit.Assert.assertNotNull;
21+
import static org.junit.Assert.assertTrue;
2122

2223
import java.io.IOException;
2324
import java.util.Arrays;
@@ -40,6 +41,7 @@
4041
import org.apache.activemq.store.TopicMessageStore;
4142
import org.apache.activemq.broker.region.Destination;
4243
import org.apache.activemq.command.MessageId;
44+
import org.apache.activemq.util.Wait;
4345
import org.junit.Test;
4446
import org.junit.runner.RunWith;
4547
import org.junit.runners.Parameterized;
@@ -144,8 +146,13 @@ public boolean isDuplicate(MessageId id) {
144146
// browse (should | should not) expire the messages on the destination if expiration is (enabled | not enabled)
145147
data = sub.browse();
146148
assertNotNull(data);
147-
assertEquals(enableExpiration ? messagesToExpire.size() : 0, dest.getDestinationStatistics().getExpired().getCount());
148-
149+
150+
if(enableExpiration) {
151+
assertTrue(Wait.waitFor(() -> dest.getDestinationStatistics().getExpired().getCount() == messagesToExpire.size(), 5_000, 100));
152+
} else {
153+
assertEquals(Long.valueOf(0), Long.valueOf(dest.getDestinationStatistics().getExpired().getCount()));
154+
}
155+
149156
session.close();
150157
con.close();
151158
}

0 commit comments

Comments
 (0)