Search in sources :

Example 1 with FilterUsageNotifier

use of com.netflix.zuul.FilterUsageNotifier in project zuul by Netflix.

the class ZuulFilterChainRunnerTest method testInboundFilterChain.

@Test
public void testInboundFilterChain() {
    final SimpleInboundFilter inbound1 = spy(new SimpleInboundFilter(true));
    final SimpleInboundFilter inbound2 = spy(new SimpleInboundFilter(false));
    final ZuulFilter[] filters = new ZuulFilter[] { inbound1, inbound2 };
    final FilterUsageNotifier notifier = mock(FilterUsageNotifier.class);
    final Registry registry = mock(Registry.class);
    final ZuulFilterChainRunner runner = new ZuulFilterChainRunner(filters, notifier, registry);
    runner.filter(request);
    verify(inbound1, times(1)).applyAsync(eq(request));
    verify(inbound2, never()).applyAsync(eq(request));
    verify(notifier).notify(eq(inbound1), eq(ExecutionStatus.SUCCESS));
    verify(notifier).notify(eq(inbound2), eq(ExecutionStatus.SKIPPED));
    verifyNoMoreInteractions(notifier);
}
Also used : FilterUsageNotifier(com.netflix.zuul.FilterUsageNotifier) ZuulFilter(com.netflix.zuul.filters.ZuulFilter) Registry(com.netflix.spectator.api.Registry) Test(org.junit.Test)

Example 2 with FilterUsageNotifier

use of com.netflix.zuul.FilterUsageNotifier in project zuul by Netflix.

the class ZuulFilterChainRunnerTest method testOutboundFilterChain.

@Test
public void testOutboundFilterChain() {
    final SimpleOutboundFilter outbound1 = spy(new SimpleOutboundFilter(true));
    final SimpleOutboundFilter outbound2 = spy(new SimpleOutboundFilter(false));
    final ZuulFilter[] filters = new ZuulFilter[] { outbound1, outbound2 };
    final FilterUsageNotifier notifier = mock(FilterUsageNotifier.class);
    final Registry registry = mock(Registry.class);
    final ZuulFilterChainRunner runner = new ZuulFilterChainRunner(filters, notifier, registry);
    runner.filter(response);
    verify(outbound1, times(1)).applyAsync(any());
    verify(outbound2, never()).applyAsync(any());
    verify(notifier).notify(eq(outbound1), eq(ExecutionStatus.SUCCESS));
    verify(notifier).notify(eq(outbound2), eq(ExecutionStatus.SKIPPED));
    verifyNoMoreInteractions(notifier);
}
Also used : FilterUsageNotifier(com.netflix.zuul.FilterUsageNotifier) ZuulFilter(com.netflix.zuul.filters.ZuulFilter) Registry(com.netflix.spectator.api.Registry) Test(org.junit.Test)

Aggregations

Registry (com.netflix.spectator.api.Registry)2 FilterUsageNotifier (com.netflix.zuul.FilterUsageNotifier)2 ZuulFilter (com.netflix.zuul.filters.ZuulFilter)2 Test (org.junit.Test)2