Search in sources :

Example 21 with ServletServerHttpResponse

use of org.springframework.http.server.ServletServerHttpResponse in project spring-boot by spring-projects.

the class DispatcherFilter method doFilter.

private void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException {
    ServerHttpRequest serverRequest = new ServletServerHttpRequest(request);
    ServerHttpResponse serverResponse = new ServletServerHttpResponse(response);
    if (!this.dispatcher.handle(serverRequest, serverResponse)) {
        chain.doFilter(request, response);
    }
}
Also used : ServletServerHttpRequest(org.springframework.http.server.ServletServerHttpRequest) ServerHttpRequest(org.springframework.http.server.ServerHttpRequest) ServletServerHttpRequest(org.springframework.http.server.ServletServerHttpRequest) ServletServerHttpResponse(org.springframework.http.server.ServletServerHttpResponse) ServerHttpResponse(org.springframework.http.server.ServerHttpResponse) ServletServerHttpResponse(org.springframework.http.server.ServletServerHttpResponse)

Example 22 with ServletServerHttpResponse

use of org.springframework.http.server.ServletServerHttpResponse in project spring-boot by spring-projects.

the class HttpStatusHandlerTests method setup.

@Before
public void setup() {
    this.servletRequest = new MockHttpServletRequest();
    this.servletResponse = new MockHttpServletResponse();
    this.request = new ServletServerHttpRequest(this.servletRequest);
    this.response = new ServletServerHttpResponse(this.servletResponse);
}
Also used : ServletServerHttpRequest(org.springframework.http.server.ServletServerHttpRequest) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) ServletServerHttpResponse(org.springframework.http.server.ServletServerHttpResponse) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Before(org.junit.Before)

Example 23 with ServletServerHttpResponse

use of org.springframework.http.server.ServletServerHttpResponse in project spring-boot by spring-projects.

the class DispatcherTests method setup.

@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    this.request = new MockHttpServletRequest();
    this.response = new MockHttpServletResponse();
    this.serverRequest = new ServletServerHttpRequest(this.request);
    this.serverResponse = new ServletServerHttpResponse(this.response);
}
Also used : ServletServerHttpRequest(org.springframework.http.server.ServletServerHttpRequest) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) ServletServerHttpResponse(org.springframework.http.server.ServletServerHttpResponse) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Before(org.junit.Before)

Example 24 with ServletServerHttpResponse

use of org.springframework.http.server.ServletServerHttpResponse in project spring-boot by spring-projects.

the class HttpRestartServerTests method sendClassLoaderFiles.

@Test
public void sendClassLoaderFiles() throws Exception {
    MockHttpServletRequest request = new MockHttpServletRequest();
    MockHttpServletResponse response = new MockHttpServletResponse();
    ClassLoaderFiles files = new ClassLoaderFiles();
    files.addFile("name", new ClassLoaderFile(Kind.ADDED, new byte[0]));
    byte[] bytes = serialize(files);
    request.setContent(bytes);
    this.server.handle(new ServletServerHttpRequest(request), new ServletServerHttpResponse(response));
    verify(this.delegate).updateAndRestart(this.filesCaptor.capture());
    assertThat(this.filesCaptor.getValue().getFile("name")).isNotNull();
    assertThat(response.getStatus()).isEqualTo(200);
}
Also used : ServletServerHttpRequest(org.springframework.http.server.ServletServerHttpRequest) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) ClassLoaderFiles(org.springframework.boot.devtools.restart.classloader.ClassLoaderFiles) ServletServerHttpResponse(org.springframework.http.server.ServletServerHttpResponse) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) ClassLoaderFile(org.springframework.boot.devtools.restart.classloader.ClassLoaderFile) Test(org.junit.Test)

Example 25 with ServletServerHttpResponse

use of org.springframework.http.server.ServletServerHttpResponse in project spring-boot by spring-projects.

the class HttpTunnelPayloadTests method assignTo.

@Test
public void assignTo() throws Exception {
    ByteBuffer data = ByteBuffer.wrap("hello".getBytes());
    HttpTunnelPayload payload = new HttpTunnelPayload(2, data);
    MockHttpServletResponse servletResponse = new MockHttpServletResponse();
    HttpOutputMessage response = new ServletServerHttpResponse(servletResponse);
    payload.assignTo(response);
    assertThat(servletResponse.getHeader("x-seq")).isEqualTo("2");
    assertThat(servletResponse.getContentAsString()).isEqualTo("hello");
}
Also used : HttpOutputMessage(org.springframework.http.HttpOutputMessage) ServletServerHttpResponse(org.springframework.http.server.ServletServerHttpResponse) ByteBuffer(java.nio.ByteBuffer) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Aggregations

ServletServerHttpResponse (org.springframework.http.server.ServletServerHttpResponse)28 ServletServerHttpRequest (org.springframework.http.server.ServletServerHttpRequest)18 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)8 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)7 HttpServletResponse (javax.servlet.http.HttpServletResponse)6 Before (org.junit.Before)6 Test (org.junit.Test)6 ServerHttpResponse (org.springframework.http.server.ServerHttpResponse)6 ServerHttpRequest (org.springframework.http.server.ServerHttpRequest)4 MockHttpServletResponse (org.springframework.mock.web.test.MockHttpServletResponse)4 ResponseEntity (org.springframework.http.ResponseEntity)3 ServletRequest (javax.servlet.ServletRequest)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 HttpHeaders (org.springframework.http.HttpHeaders)2 MediaType (org.springframework.http.MediaType)2 MockHttpServletRequest (org.springframework.mock.web.test.MockHttpServletRequest)2 HandshakeFailureException (org.springframework.web.socket.server.HandshakeFailureException)2 IOException (java.io.IOException)1 ByteBuffer (java.nio.ByteBuffer)1 ByteChannel (java.nio.channels.ByteChannel)1