use of com.linkedin.r2.filter.FilterChain in project rest.li by linkedin.
the class TestFilterChainImpl method testChainStreamRequestFilters.
@Test
public void testChainStreamRequestFilters() {
final StreamCountFilter filter1 = new StreamCountFilter();
final StreamCountFilter filter2 = new StreamCountFilter();
final StreamCountFilter filter3 = new StreamCountFilter();
final FilterChain fc = FilterChains.createStreamChain(filter1, filter2, filter3);
fireStreamRequest(fc);
assertStreamCounts(1, 0, 0, filter1);
assertStreamCounts(1, 0, 0, filter2);
assertStreamCounts(1, 0, 0, filter3);
}
use of com.linkedin.r2.filter.FilterChain in project rest.li by linkedin.
the class TestFilterChainImpl method testChainRestRequestFilters.
@Test
public void testChainRestRequestFilters() {
final RestCountFilter filter1 = new RestCountFilter();
final RestCountFilter filter2 = new RestCountFilter();
final RestCountFilter filter3 = new RestCountFilter();
final FilterChain fc = FilterChains.createRestChain(filter1, filter2, filter3);
fireRestRequest(fc);
assertRestCounts(1, 0, 0, filter1);
assertRestCounts(1, 0, 0, filter2);
assertRestCounts(1, 0, 0, filter3);
}
use of com.linkedin.r2.filter.FilterChain in project rest.li by linkedin.
the class TestFilterChainImpl method testChainStreamErrorFilters.
@Test
public void testChainStreamErrorFilters() {
final StreamCountFilter filter1 = new StreamCountFilter();
final StreamCountFilter filter2 = new StreamCountFilter();
final StreamCountFilter filter3 = new StreamCountFilter();
final FilterChain fc = FilterChains.createStreamChain(filter1, filter2, filter3);
fireStreamError(fc);
assertStreamCounts(0, 0, 1, filter1);
assertStreamCounts(0, 0, 1, filter2);
assertStreamCounts(0, 0, 1, filter3);
}
use of com.linkedin.r2.filter.FilterChain in project rest.li by linkedin.
the class TestFilterChainImpl method testFilterOrderTwoChains.
@Test
public void testFilterOrderTwoChains() {
AtomicInteger count = new AtomicInteger(0);
CheckOrderFilter filter1 = new CheckOrderFilter(count);
CheckOrderFilter filter2 = new CheckOrderFilter(count);
List<RestFilter> restFilters = new ArrayList<RestFilter>();
restFilters.add(filter1);
restFilters.add(filter2);
List<StreamFilter> streamFilters = new ArrayList<StreamFilter>();
streamFilters.add(filter1);
streamFilters.add(filter2);
final FilterChain fc = FilterChains.create(restFilters, streamFilters);
fireRestRequest(fc);
Assert.assertEquals(filter1.getOrder(), 1);
Assert.assertEquals(filter2.getOrder(), 2);
fireRestResponse(fc);
Assert.assertEquals(filter1.getOrder(), 4);
Assert.assertEquals(filter2.getOrder(), 3);
fireRestError(fc);
Assert.assertEquals(filter1.getOrder(), 6);
Assert.assertEquals(filter2.getOrder(), 5);
count.set(0);
fireStreamRequest(fc);
Assert.assertEquals(filter1.getOrder(), 1);
Assert.assertEquals(filter2.getOrder(), 2);
fireStreamResponse(fc);
Assert.assertEquals(filter1.getOrder(), 4);
Assert.assertEquals(filter2.getOrder(), 3);
fireStreamError(fc);
Assert.assertEquals(filter1.getOrder(), 6);
Assert.assertEquals(filter2.getOrder(), 5);
}
use of com.linkedin.r2.filter.FilterChain in project rest.li by linkedin.
the class TestFilterChainImpl method testRestRequestFilter.
@Test
public void testRestRequestFilter() {
final RestCountFilter restCountFilter = new RestCountFilter();
final StreamCountFilter streamCountFilter = new StreamCountFilter();
FilterChain fc = FilterChains.createRestChain(restCountFilter);
fc = fc.addLast(streamCountFilter);
fireRestRequest(fc);
assertRestCounts(1, 0, 0, restCountFilter);
assertStreamCounts(0, 0, 0, streamCountFilter);
}
Aggregations