Skip to content

Commit

Permalink
Issue ReactiveX#12 make timeout constant
Browse files Browse the repository at this point in the history
  • Loading branch information
storozhukBM committed Dec 4, 2016
1 parent e3a091c commit 0b928e1
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public class AtomicRateLimiterTest {
public static final String LIMITER_NAME = "test";
public static final long CYCLE_IN_NANOS = 500_000_000L;
public static final long POLL_INTERVAL_IN_NANOS = 2_000_000L;
public static final int TIMEOUT = 100;
private RateLimiterConfig rateLimiterConfig;
private AtomicRateLimiter rateLimiter;
private AtomicRateLimiter.AtomicRateLimiterMetrics metrics;
Expand Down Expand Up @@ -109,7 +110,7 @@ public void reserveAndRefresh() throws Exception {
caller.setDaemon(true);
caller.start();
awaitImpatiently()
.atMost(10, MILLISECONDS)
.atMost(TIMEOUT, MILLISECONDS)
.until(caller::getState, equalTo(Thread.State.TIMED_WAITING));
then(metrics.getAvailablePermissions()).isEqualTo(-1);
then(metrics.getNanosToWait()).isEqualTo(CYCLE_IN_NANOS + CYCLE_IN_NANOS);
Expand Down Expand Up @@ -140,7 +141,7 @@ public void reserveFewThenSkipCyclesBeforeRefresh() throws Exception {
firstCaller.setDaemon(true);
firstCaller.start();
awaitImpatiently()
.atMost(50, MILLISECONDS)
.atMost(TIMEOUT, MILLISECONDS)
.until(firstCaller::getState, equalTo(Thread.State.TIMED_WAITING));
then(metrics.getAvailablePermissions()).isEqualTo(-1);
then(metrics.getNanosToWait()).isEqualTo(CYCLE_IN_NANOS * 2);
Expand All @@ -153,7 +154,7 @@ public void reserveFewThenSkipCyclesBeforeRefresh() throws Exception {
secondCaller.setDaemon(true);
secondCaller.start();
awaitImpatiently()
.atMost(50, MILLISECONDS)
.atMost(TIMEOUT, MILLISECONDS)
.until(secondCaller::getState, equalTo(Thread.State.TIMED_WAITING));
then(metrics.getAvailablePermissions()).isEqualTo(-2);
then(metrics.getNanosToWait()).isEqualTo(CYCLE_IN_NANOS * 3);
Expand Down Expand Up @@ -187,7 +188,7 @@ public void rejectedByTimeout() throws Exception {
caller.start();

awaitImpatiently()
.atMost(100, MILLISECONDS)
.atMost(TIMEOUT, MILLISECONDS)
.until(caller::getState, equalTo(Thread.State.TIMED_WAITING));
then(metrics.getAvailablePermissions()).isEqualTo(0);
then(metrics.getNanosToWait()).isEqualTo(CYCLE_IN_NANOS);
Expand Down Expand Up @@ -223,7 +224,7 @@ public void waitingThreadIsInterrupted() throws Exception {
caller.start();

awaitImpatiently()
.atMost(100, MILLISECONDS)
.atMost(TIMEOUT, MILLISECONDS)
.until(caller::getState, equalTo(Thread.State.TIMED_WAITING));
then(metrics.getAvailablePermissions()).isEqualTo(0);
then(metrics.getNanosToWait()).isEqualTo(CYCLE_IN_NANOS);
Expand Down

0 comments on commit 0b928e1

Please sign in to comment.