Search in sources :

Example 16 with RequestFilter

use of com.yahoo.jdisc.http.filter.RequestFilter in project vespa by vespa-engine.

the class FilterTestCase method requireThatRequestFilterChainRetainsFilters.

@Test
public void requireThatRequestFilterChainRetainsFilters() {
    final RequestFilter requestFilter1 = mock(RequestFilter.class);
    final RequestFilter requestFilter2 = mock(RequestFilter.class);
    verify(requestFilter1, never()).refer();
    verify(requestFilter2, never()).refer();
    final ResourceReference reference1 = mock(ResourceReference.class);
    final ResourceReference reference2 = mock(ResourceReference.class);
    when(requestFilter1.refer()).thenReturn(reference1);
    when(requestFilter2.refer()).thenReturn(reference2);
    final RequestFilter chain = RequestFilterChain.newInstance(requestFilter1, requestFilter2);
    verify(requestFilter1, times(1)).refer();
    verify(requestFilter2, times(1)).refer();
    verify(reference1, never()).close();
    verify(reference2, never()).close();
    chain.release();
    verify(reference1, times(1)).close();
    verify(reference2, times(1)).close();
}
Also used : ResourceReference(com.yahoo.jdisc.ResourceReference) RequestFilter(com.yahoo.jdisc.http.filter.RequestFilter) Test(org.testng.annotations.Test)

Aggregations

RequestFilter (com.yahoo.jdisc.http.filter.RequestFilter)16 Test (org.testng.annotations.Test)11 ResponseHandler (com.yahoo.jdisc.handler.ResponseHandler)10 HttpRequest (com.yahoo.jdisc.http.HttpRequest)10 ResponseFilter (com.yahoo.jdisc.http.filter.ResponseFilter)10 BindingRepository (com.yahoo.jdisc.application.BindingRepository)6 Response (com.yahoo.jdisc.Response)5 HttpResponse (com.yahoo.jdisc.http.HttpResponse)5 Request (com.yahoo.jdisc.Request)3 ComponentId (com.yahoo.component.ComponentId)2 ComponentRegistry (com.yahoo.component.provider.ComponentRegistry)2 ChainsConfig (com.yahoo.container.core.ChainsConfig)2 FilterChainRepository (com.yahoo.container.http.filter.FilterChainRepository)2 ContentChannel (com.yahoo.jdisc.handler.ContentChannel)2 ServerConfig (com.yahoo.jdisc.http.ServerConfig)2 SecurityRequestFilter (com.yahoo.jdisc.http.filter.SecurityRequestFilter)2 SecurityResponseFilter (com.yahoo.jdisc.http.filter.SecurityResponseFilter)2 FilterBindings (com.yahoo.jdisc.http.server.FilterBindings)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 Test (org.junit.Test)2