Search in sources :

Example 6 with ServletServerHttpRequest

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

the class HttpHeaderAccessManagerTests method setup.

@Before
public void setup() {
    this.request = new MockHttpServletRequest("GET", "/");
    this.serverRequest = new ServletServerHttpRequest(this.request);
    this.manager = new HttpHeaderAccessManager(HEADER, SECRET);
}
Also used : ServletServerHttpRequest(org.springframework.http.server.ServletServerHttpRequest) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) Before(org.junit.Before)

Example 7 with ServletServerHttpRequest

use of org.springframework.http.server.ServletServerHttpRequest 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);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) ServletServerHttpRequest(org.springframework.http.server.ServletServerHttpRequest) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) ServletServerHttpRequest(org.springframework.http.server.ServletServerHttpRequest) ServerHttpRequest(org.springframework.http.server.ServerHttpRequest) Test(org.junit.Test)

Example 8 with ServletServerHttpRequest

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

the class HttpTunnelPayloadTests method getWithData.

@Test
public void getWithData() throws Exception {
    MockHttpServletRequest servletRequest = new MockHttpServletRequest();
    servletRequest.setContent("hello".getBytes());
    servletRequest.addHeader("x-seq", 123);
    HttpInputMessage request = new ServletServerHttpRequest(servletRequest);
    HttpTunnelPayload payload = HttpTunnelPayload.get(request);
    assertThat(payload.getSequence()).isEqualTo(123L);
    assertThat(getData(payload)).isEqualTo("hello".getBytes());
}
Also used : HttpInputMessage(org.springframework.http.HttpInputMessage) ServletServerHttpRequest(org.springframework.http.server.ServletServerHttpRequest) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) Test(org.junit.Test)

Example 9 with ServletServerHttpRequest

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

the class HttpTunnelPayloadTests method getNoData.

@Test
public void getNoData() throws Exception {
    MockHttpServletRequest servletRequest = new MockHttpServletRequest();
    HttpInputMessage request = new ServletServerHttpRequest(servletRequest);
    HttpTunnelPayload payload = HttpTunnelPayload.get(request);
    assertThat(payload).isNull();
}
Also used : HttpInputMessage(org.springframework.http.HttpInputMessage) ServletServerHttpRequest(org.springframework.http.server.ServletServerHttpRequest) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) Test(org.junit.Test)

Example 10 with ServletServerHttpRequest

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

the class HttpTunnelPayloadTests method getWithMissingHeader.

@Test
public void getWithMissingHeader() throws Exception {
    MockHttpServletRequest servletRequest = new MockHttpServletRequest();
    servletRequest.setContent("hello".getBytes());
    HttpInputMessage request = new ServletServerHttpRequest(servletRequest);
    this.thrown.expect(IllegalStateException.class);
    this.thrown.expectMessage("Missing sequence header");
    HttpTunnelPayload.get(request);
}
Also used : HttpInputMessage(org.springframework.http.HttpInputMessage) ServletServerHttpRequest(org.springframework.http.server.ServletServerHttpRequest) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) Test(org.junit.Test)

Aggregations

ServletServerHttpRequest (org.springframework.http.server.ServletServerHttpRequest)64 Test (org.junit.Test)33 MockHttpServletRequest (org.springframework.mock.web.test.MockHttpServletRequest)29 HttpRequest (org.springframework.http.HttpRequest)20 ServletServerHttpResponse (org.springframework.http.server.ServletServerHttpResponse)18 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)15 HttpServletRequest (javax.servlet.http.HttpServletRequest)11 Before (org.junit.Before)8 ServerHttpRequest (org.springframework.http.server.ServerHttpRequest)8 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)7 HttpInputMessage (org.springframework.http.HttpInputMessage)5 ServerHttpResponse (org.springframework.http.server.ServerHttpResponse)4 MediaType (org.springframework.http.MediaType)3 HttpServletResponse (javax.servlet.http.HttpServletResponse)2 HttpEntity (org.springframework.http.HttpEntity)2 HttpMessageNotReadableException (org.springframework.http.converter.HttpMessageNotReadableException)2 MockHttpServletResponse (org.springframework.mock.web.test.MockHttpServletResponse)2 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 ParameterizedType (java.lang.reflect.ParameterizedType)1