@@ -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