use of org.springframework.http.server.ServerHttpRequest in project spring-boot by spring-projects.
the class DispatcherFilterTests method handledByDispatcher.
@Test
public void handledByDispatcher() throws Exception {
HttpServletRequest request = new MockHttpServletRequest("GET", "/hello");
HttpServletResponse response = new MockHttpServletResponse();
willReturn(true).given(this.dispatcher).handle(any(ServerHttpRequest.class), any(ServerHttpResponse.class));
this.filter.doFilter(request, response, this.chain);
verifyZeroInteractions(this.chain);
verify(this.dispatcher).handle(this.serverRequestCaptor.capture(), this.serverResponseCaptor.capture());
ServerHttpRequest dispatcherRequest = this.serverRequestCaptor.getValue();
ServletServerHttpRequest actualRequest = (ServletServerHttpRequest) dispatcherRequest;
ServerHttpResponse dispatcherResponse = this.serverResponseCaptor.getValue();
ServletServerHttpResponse actualResponse = (ServletServerHttpResponse) dispatcherResponse;
assertThat(actualRequest.getServletRequest()).isEqualTo(request);
assertThat(actualResponse.getServletResponse()).isEqualTo(response);
}
use of org.springframework.http.server.ServerHttpRequest in project spring-boot by spring-projects.
the class HttpRestartServerHandlerTests method handleDelegatesToServer.
@Test
public void handleDelegatesToServer() throws Exception {
HttpRestartServer server = mock(HttpRestartServer.class);
HttpRestartServerHandler handler = new HttpRestartServerHandler(server);
ServerHttpRequest request = mock(ServerHttpRequest.class);
ServerHttpResponse response = mock(ServerHttpResponse.class);
handler.handle(request, response);
verify(server).handle(request, response);
}
use of org.springframework.http.server.ServerHttpRequest in project spring-boot by spring-projects.
the class UrlHandlerMapperTests method handlesMatchedUrl.
@Test
public void handlesMatchedUrl() throws Exception {
UrlHandlerMapper mapper = new UrlHandlerMapper("/tunnel", this.handler);
HttpServletRequest servletRequest = new MockHttpServletRequest("GET", "/tunnel");
ServerHttpRequest request = new ServletServerHttpRequest(servletRequest);
assertThat(mapper.getHandler(request)).isEqualTo(this.handler);
}
use of org.springframework.http.server.ServerHttpRequest in project spring-boot by spring-projects.
the class HttpTunnelServerHandlerTests method handleDelegatesToServer.
@Test
public void handleDelegatesToServer() throws Exception {
HttpTunnelServer server = mock(HttpTunnelServer.class);
HttpTunnelServerHandler handler = new HttpTunnelServerHandler(server);
ServerHttpRequest request = mock(ServerHttpRequest.class);
ServerHttpResponse response = mock(ServerHttpResponse.class);
handler.handle(request, response);
verify(server).handle(request, response);
}
use of org.springframework.http.server.ServerHttpRequest in project spring-boot by spring-projects.
the class HttpTunnelServerTests method testHttpConnectionNonAsync.
private void testHttpConnectionNonAsync(long sleepBeforeResponse) throws IOException, InterruptedException {
ServerHttpRequest request = mock(ServerHttpRequest.class);
given(request.getAsyncRequestControl(this.response)).willThrow(new IllegalArgumentException());
final HttpConnection connection = new HttpConnection(request, this.response);
final AtomicBoolean responded = new AtomicBoolean();
Thread connectionThread = new Thread() {
@Override
public void run() {
connection.waitForResponse();
responded.set(true);
}
};
connectionThread.start();
assertThat(responded.get()).isFalse();
Thread.sleep(sleepBeforeResponse);
connection.respond(HttpStatus.NO_CONTENT);
connectionThread.join();
assertThat(responded.get()).isTrue();
}
Aggregations