Skip to content

Commit c16a72d

Browse files
committed
Make token expiry test more lenient
Replace equals expectations by greater than ones.
1 parent fac6fde commit c16a72d

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/test/java/com/rabbitmq/client/amqp/oauth2/TokenCredentialsManagerTest.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,23 +133,25 @@ void severalRegistrationsShouldBeRefreshed() throws Exception {
133133
}
134134
// all connections have been refreshed once
135135
int refreshCountSnapshot = totalRefreshCount.get();
136-
assertThat(refreshCountSnapshot).isEqualTo(connectionCount * expectedRefreshCountPerConnection);
136+
assertThat(refreshCountSnapshot)
137+
.isGreaterThanOrEqualTo(connectionCount * expectedRefreshCountPerConnection);
137138

138139
// unregister half of the connections
139140
int splitCount = connectionCount / 2;
140141
registrations.subList(0, splitCount).forEach(r -> r.v1().close());
141142
// only the remaining connections should get refreshed again
142143
waitAtMost(
143-
timeout, waitTime, () -> totalRefreshCount.get() == refreshCountSnapshot + splitCount);
144+
timeout, waitTime, () -> totalRefreshCount.get() >= refreshCountSnapshot + splitCount);
144145
// waiting another round of refresh
145146
waitAtMost(
146-
timeout, waitTime, () -> totalRefreshCount.get() == refreshCountSnapshot + splitCount * 2);
147+
timeout, waitTime, () -> totalRefreshCount.get() >= refreshCountSnapshot + splitCount * 2);
147148
// unregister all connections
148149
registrations.forEach(r -> r.v1().close());
150+
int finalRefreshCount = totalRefreshCount.get();
149151
// wait 2 expiry times
150152
Thread.sleep(tokenExpiry.multipliedBy(2).toMillis());
151153
// no new refresh
152-
assertThat(totalRefreshCount).hasValue(refreshCountSnapshot + splitCount * 2);
154+
assertThat(totalRefreshCount).hasValue(finalRefreshCount);
153155
}
154156

155157
@Test

0 commit comments

Comments
 (0)