use of io.apiman.gateway.engine.policy.RequestChain in project apiman by apiman.
the class PolicyChainTest method shouldExecuteRequestChainTwice.
@Test
public void shouldExecuteRequestChainTwice() {
policies.add(pwcOne);
policies.add(pwcTwo);
requestChain = new RequestChain(policies, mockContext);
requestChain.bodyHandler(mockBodyHandler);
requestChain.endHandler(mockEndHandler);
requestChain.doApply(mockRequest);
requestChain.write(mockBuffer);
requestChain.write(mockBuffer);
requestChain.end();
verify(mockBodyHandler, times(2)).handle(mockBuffer);
verify(mockEndHandler, times(1)).handle((Void) null);
InOrder order = inOrder(policyOne, policyTwo);
order.verify(policyOne).apply(mockRequest, mockContext, pwcOne.getConfiguration(), requestChain);
order.verify(policyTwo).apply(mockRequest, mockContext, pwcTwo.getConfiguration(), requestChain);
}
use of io.apiman.gateway.engine.policy.RequestChain in project apiman by apiman.
the class PolicyChainTest method shouldCallErrorHandlerOnThrowError.
@Test
public void shouldCallErrorHandlerOnThrowError() {
policies.add(pwcOne);
policies.add(pwcTwo);
requestChain = new RequestChain(policies, mockContext);
IAsyncHandler<Throwable> mThrowableFailureHandler = mock(IAsyncHandler.class);
Throwable mThrowable = mock(Throwable.class);
requestChain.policyErrorHandler(mThrowableFailureHandler);
requestChain.bodyHandler(mockBodyHandler);
requestChain.endHandler(mockEndHandler);
requestChain.doApply(mockRequest);
requestChain.throwError(mThrowable);
verify(mThrowableFailureHandler).handle(mThrowable);
}
use of io.apiman.gateway.engine.policy.RequestChain in project apiman by apiman.
the class PolicyChainTest method shouldExecuteWithoutHandlers.
@Test
public void shouldExecuteWithoutHandlers() {
policies.add(pwcOne);
requestChain = new RequestChain(policies, mockContext);
requestChain.doApply(mockRequest);
requestChain.end();
}
Aggregations