Search in sources :

Example 1 with RestCountFilter

use of com.linkedin.r2.testutils.filter.RestCountFilter in project rest.li by linkedin.

the class RestFilterTest method setUp.

@BeforeMethod
public void setUp() throws Exception {
    _filter = new RestFilter() {
    };
    _beforeFilter = new RestCountFilter();
    _afterFilter = new RestCountFilter();
    _fc = FilterChains.createRestChain(_beforeFilter, _filter, _afterFilter);
}
Also used : BaseRestFilter(com.linkedin.r2.filter.message.rest.BaseRestFilter) RestFilter(com.linkedin.r2.filter.message.rest.RestFilter) RestCountFilter(com.linkedin.r2.testutils.filter.RestCountFilter) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with RestCountFilter

use of com.linkedin.r2.testutils.filter.RestCountFilter in project rest.li by linkedin.

the class TestFilterChainImpl method testStreamErrorFilter.

@Test
public void testStreamErrorFilter() {
    final RestCountFilter restCountFilter = new RestCountFilter();
    final StreamCountFilter streamCountFilter = new StreamCountFilter();
    FilterChain fc = FilterChains.createRestChain(restCountFilter);
    fc = fc.addLast(streamCountFilter);
    fireStreamError(fc);
    assertRestCounts(0, 0, 0, restCountFilter);
    assertStreamCounts(0, 0, 1, streamCountFilter);
}
Also used : StreamCountFilter(com.linkedin.r2.testutils.filter.StreamCountFilter) FilterChain(com.linkedin.r2.filter.FilterChain) RestCountFilter(com.linkedin.r2.testutils.filter.RestCountFilter) Test(org.testng.annotations.Test)

Example 3 with RestCountFilter

use of com.linkedin.r2.testutils.filter.RestCountFilter in project rest.li by linkedin.

the class TestFilterChainImpl method testStreamRequestFilter.

@Test
public void testStreamRequestFilter() {
    final RestCountFilter restCountFilter = new RestCountFilter();
    final StreamCountFilter streamCountFilter = new StreamCountFilter();
    FilterChain fc = FilterChains.createRestChain(restCountFilter);
    fc = fc.addLast(streamCountFilter);
    fireStreamRequest(fc);
    assertRestCounts(0, 0, 0, restCountFilter);
    assertStreamCounts(1, 0, 0, streamCountFilter);
}
Also used : StreamCountFilter(com.linkedin.r2.testutils.filter.StreamCountFilter) FilterChain(com.linkedin.r2.filter.FilterChain) RestCountFilter(com.linkedin.r2.testutils.filter.RestCountFilter) Test(org.testng.annotations.Test)

Example 4 with RestCountFilter

use of com.linkedin.r2.testutils.filter.RestCountFilter in project rest.li by linkedin.

the class TestFilterChainImpl method testNullFilterInList.

@Test(expectedExceptions = IllegalArgumentException.class)
public void testNullFilterInList() {
    List<RestFilter> restFilters = new ArrayList<>();
    restFilters.add(new RestCountFilter());
    restFilters.add(null);
    FilterChains.create(restFilters, Collections.<StreamFilter>emptyList());
}
Also used : RestFilter(com.linkedin.r2.filter.message.rest.RestFilter) ArrayList(java.util.ArrayList) RestCountFilter(com.linkedin.r2.testutils.filter.RestCountFilter) Test(org.testng.annotations.Test)

Example 5 with RestCountFilter

use of com.linkedin.r2.testutils.filter.RestCountFilter in project rest.li by linkedin.

the class TestFilterChainImpl method testChainRestErrorFilters.

@Test
public void testChainRestErrorFilters() {
    final RestCountFilter filter1 = new RestCountFilter();
    final RestCountFilter filter2 = new RestCountFilter();
    final RestCountFilter filter3 = new RestCountFilter();
    final FilterChain fc = FilterChains.createRestChain(filter1, filter2, filter3);
    fireRestError(fc);
    assertRestCounts(0, 0, 1, filter1);
    assertRestCounts(0, 0, 1, filter2);
    assertRestCounts(0, 0, 1, filter3);
}
Also used : FilterChain(com.linkedin.r2.filter.FilterChain) RestCountFilter(com.linkedin.r2.testutils.filter.RestCountFilter) Test(org.testng.annotations.Test)

Aggregations

RestCountFilter (com.linkedin.r2.testutils.filter.RestCountFilter)12 Test (org.testng.annotations.Test)11 FilterChain (com.linkedin.r2.filter.FilterChain)10 StreamCountFilter (com.linkedin.r2.testutils.filter.StreamCountFilter)6 RestFilter (com.linkedin.r2.filter.message.rest.RestFilter)2 BaseRestFilter (com.linkedin.r2.filter.message.rest.BaseRestFilter)1 RequestContext (com.linkedin.r2.message.RequestContext)1 RestRequest (com.linkedin.r2.message.rest.RestRequest)1 RestRequestBuilder (com.linkedin.r2.message.rest.RestRequestBuilder)1 RestResponse (com.linkedin.r2.message.rest.RestResponse)1 RestResponseBuilder (com.linkedin.r2.message.rest.RestResponseBuilder)1 CaptureLastCallFilter (com.linkedin.r2.testutils.filter.CaptureLastCallFilter)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 BeforeMethod (org.testng.annotations.BeforeMethod)1