@Test public void testTokenBucketPersistsIfNotReconfigured() { settableConfig.setProperty("junit.initialNumberOfTokens", "1"); settableConfig.setProperty("junit.capacity", "1"); settableConfig.setProperty("junit.numberOfTokensPerInterval", "0"); TokenBucket tokenBucket = supplier.get(); assertThat(tokenBucket.tryTake()).isTrue(); assertThat(tokenBucket.tryTake()).isFalse(); tokenBucket.refill(1); assertThat(tokenBucket.tryTake()).isTrue(); assertThat(supplier.get() == tokenBucket).isTrue(); assertThat(buckets).hasSize(2); assertThat(buckets.get(1)).isEqualTo(tokenBucket); }
@Override public TokenBucket get() { return isSame() ? activeConfiguration.getTokenBucket() : reload().getTokenBucket(); }
FixedIntervalTokenBucketSupplier implements Supplier<TokenBucket> { @Override public TokenBucket get() { return isSame() ? activeConfiguration.getTokenBucket() : reload().getTokenBucket(); } }
FixedIntervalTokenBucketSupplier implements Supplier<TokenBucket> { @Override public TokenBucket get() { return isSame() ? activeConfiguration.getTokenBucket() : reload().getTokenBucket(); } FixedIntervalTokenBucketSupplier(String name,
                                            FixedIntervalTokenBucketConfiguration configuration,
                                            Consumer<TokenBucket> onChangeListener,
                                            Optional<TitusRuntime> titusRuntime); }
FixedIntervalTokenBucketSupplier implements Supplier<TokenBucket> { @Override public TokenBucket get() { return isSame() ? activeConfiguration.getTokenBucket() : reload().getTokenBucket(); } FixedIntervalTokenBucketSupplier(String name,
                                            FixedIntervalTokenBucketConfiguration configuration,
                                            Consumer<TokenBucket> onChangeListener,
                                            Optional<TitusRuntime> titusRuntime); @Override TokenBucket get(); }
FixedIntervalTokenBucketSupplier implements Supplier<TokenBucket> { @Override public TokenBucket get() { return isSame() ? activeConfiguration.getTokenBucket() : reload().getTokenBucket(); } FixedIntervalTokenBucketSupplier(String name,
                                            FixedIntervalTokenBucketConfiguration configuration,
                                            Consumer<TokenBucket> onChangeListener,
                                            Optional<TitusRuntime> titusRuntime); @Override TokenBucket get();  }