Skip to content

Commit fa33135

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

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/test/java/com/rabbitmq/stream/oauth2/TokenCredentialsManagerTest.java

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

134135
// unregister half of the connections
135136
int splitCount = connectionCount / 2;
136137
registrations.subList(0, splitCount).forEach(r -> r.v1().close());
137138
// only the remaining connections should get refreshed again
138139
waitAtMost(
139-
timeout, waitTime, () -> totalRefreshCount.get() == refreshCountSnapshot + splitCount);
140+
timeout, waitTime, () -> totalRefreshCount.get() >= refreshCountSnapshot + splitCount);
140141
// waiting another round of refresh
141142
waitAtMost(
142-
timeout, waitTime, () -> totalRefreshCount.get() == refreshCountSnapshot + splitCount * 2);
143+
timeout, waitTime, () -> totalRefreshCount.get() >= refreshCountSnapshot + splitCount * 2);
143144
// unregister all connections
144145
registrations.forEach(r -> r.v1().close());
146+
int finalRefreshCount = totalRefreshCount.get();
145147
// wait 2 expiry times
146148
Thread.sleep(tokenExpiry.multipliedBy(2).toMillis());
147149
// no new refresh
148-
assertThat(totalRefreshCount).hasValue(refreshCountSnapshot + splitCount * 2);
150+
assertThat(totalRefreshCount).hasValue(finalRefreshCount);
149151
}
150152

151153
@Test

0 commit comments

Comments
 (0)