Search in sources :

Example 6 with ConsumptionProbe

use of io.github.bucket4j.ConsumptionProbe in project bucket4j-spring-boot-starter by MarcGiffing.

the class ZuulRateLimitFilterTest method setup.

@Before
public void setup() {
    consumptionProbe = Mockito.mock(ConsumptionProbe.class);
    when(consumptionProbe.isConsumed()).thenReturn(true);
    rateLimitCheck1 = mock(RateLimitCheck.class);
    rateLimitCheck2 = mock(RateLimitCheck.class);
    rateLimitCheck3 = mock(RateLimitCheck.class);
    configuration = new FilterConfiguration();
    configuration.setRateLimitChecks(Arrays.asList(rateLimitCheck1, rateLimitCheck2, rateLimitCheck3));
    configuration.setUrl("url");
    filter = new ZuulRateLimitFilter(configuration) {

        @Override
        protected RequestContext getCurrentRequestContext() {
            return Mockito.mock(RequestContext.class);
        }
    };
}
Also used : RateLimitCheck(com.giffing.bucket4j.spring.boot.starter.context.RateLimitCheck) FilterConfiguration(com.giffing.bucket4j.spring.boot.starter.context.FilterConfiguration) ConsumptionProbe(io.github.bucket4j.ConsumptionProbe) RequestContext(com.netflix.zuul.context.RequestContext) Before(org.junit.Before)

Aggregations

RateLimitCheck (com.giffing.bucket4j.spring.boot.starter.context.RateLimitCheck)6 ConsumptionProbe (io.github.bucket4j.ConsumptionProbe)6 FilterConfiguration (com.giffing.bucket4j.spring.boot.starter.context.FilterConfiguration)3 RequestContext (com.netflix.zuul.context.RequestContext)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)3 Before (org.junit.Before)2 Bucket4JAutoConfigurationServletFilter (com.giffing.bucket4j.spring.boot.starter.config.servlet.Bucket4JAutoConfigurationServletFilter)1 Bucket4JAutoConfigurationZuul (com.giffing.bucket4j.spring.boot.starter.config.zuul.Bucket4JAutoConfigurationZuul)1 BandWidthConfig (com.giffing.bucket4j.spring.boot.starter.context.BandWidthConfig)1 Condition (com.giffing.bucket4j.spring.boot.starter.context.Condition)1 KeyFilter (com.giffing.bucket4j.spring.boot.starter.context.KeyFilter)1 Bucket4JConfiguration (com.giffing.bucket4j.spring.boot.starter.context.properties.Bucket4JConfiguration)1 RateLimit (com.giffing.bucket4j.spring.boot.starter.context.properties.RateLimit)1 JCacheNotFoundException (com.giffing.bucket4j.spring.boot.starter.exception.JCacheNotFoundException)1 MissingKeyFilterExpressionException (com.giffing.bucket4j.spring.boot.starter.exception.MissingKeyFilterExpressionException)1 ServletRequestFilter (com.giffing.bucket4j.spring.boot.starter.servlet.ServletRequestFilter)1 Bandwidth (io.github.bucket4j.Bandwidth)1 Bucket (io.github.bucket4j.Bucket)1 Bucket4j (io.github.bucket4j.Bucket4j)1 ConfigurationBuilder (io.github.bucket4j.ConfigurationBuilder)1