use of io.gravitee.gateway.reactor.handler.AbstractReactorHandler in project gravitee-gateway by gravitee-io.
the class ReactorTest method processRequest_startedApi.
@Test
public void processRequest_startedApi() throws Exception {
Request request = mock(Request.class);
when(request.method()).thenReturn(HttpMethod.GET);
when(request.headers()).thenReturn(new HttpHeaders());
when(request.headers()).thenReturn(new HttpHeaders());
when(request.path()).thenReturn("/team");
when(request.metrics()).thenReturn(Metrics.on(System.currentTimeMillis()).build());
when(handlerResolver.resolve(any(Request.class))).thenReturn(new AbstractReactorHandler() {
@Override
public Reactable reactable() {
return new Reactable() {
@Override
public Object item() {
return null;
}
@Override
public String contextPath() {
return "";
}
@Override
public boolean enabled() {
return true;
}
@Override
public Set dependencies(Class type) {
return null;
}
@Override
public Map<String, Object> properties() {
return null;
}
};
}
@Override
protected void doHandle(Request request, Response response, Handler<Response> handler) {
Response proxyResponse = mock(Response.class);
when(proxyResponse.headers()).thenReturn(new HttpHeaders());
when(proxyResponse.status()).thenReturn(HttpStatusCode.OK_200);
handler.handle(proxyResponse);
}
});
final CountDownLatch lock = new CountDownLatch(1);
Response proxyResponse = mock(Response.class);
when(proxyResponse.headers()).thenReturn(new HttpHeaders());
reactor.route(request, proxyResponse, response -> {
Assert.assertEquals(HttpStatusCode.OK_200, response.status());
lock.countDown();
});
Assert.assertEquals(true, lock.await(10000, TimeUnit.MILLISECONDS));
}
Aggregations