Search in sources :

Example 21 with MockHttpServletRequest

use of org.minijax.test.MockHttpServletRequest in project minijax by minijax.

the class HttpHeadersTest method testContentLengthMissing.

@Test
public void testContentLengthMissing() {
    final MultivaluedMap<String, String> headers = new MultivaluedHashMap<>();
    final MockHttpServletRequest request = new MockHttpServletRequest("GET", URI.create("/"), headers, null, null);
    final MinijaxHttpHeaders httpHeaders = new MinijaxHttpHeaders(request);
    assertEquals(-1, httpHeaders.getLength());
}
Also used : MultivaluedHashMap(javax.ws.rs.core.MultivaluedHashMap) MockHttpServletRequest(org.minijax.test.MockHttpServletRequest) Test(org.junit.Test)

Example 22 with MockHttpServletRequest

use of org.minijax.test.MockHttpServletRequest in project minijax by minijax.

the class HttpHeadersTest method testContentLengthMalformed.

@Test
public void testContentLengthMalformed() {
    final MultivaluedMap<String, String> headers = new MultivaluedHashMap<>();
    headers.add("Content-Length", "x");
    final MockHttpServletRequest request = new MockHttpServletRequest("GET", URI.create("/"), headers, null, null);
    final MinijaxHttpHeaders httpHeaders = new MinijaxHttpHeaders(request);
    assertEquals(-1, httpHeaders.getLength());
}
Also used : MultivaluedHashMap(javax.ws.rs.core.MultivaluedHashMap) MockHttpServletRequest(org.minijax.test.MockHttpServletRequest) Test(org.junit.Test)

Example 23 with MockHttpServletRequest

use of org.minijax.test.MockHttpServletRequest in project minijax by minijax.

the class HttpHeadersTest method testDate.

@Test(expected = UnsupportedOperationException.class)
public void testDate() {
    final MultivaluedMap<String, String> headers = new MultivaluedHashMap<>();
    final MockHttpServletRequest request = new MockHttpServletRequest("GET", URI.create("/"), headers, null, null);
    final MinijaxHttpHeaders httpHeaders = new MinijaxHttpHeaders(request);
    httpHeaders.getDate();
}
Also used : MultivaluedHashMap(javax.ws.rs.core.MultivaluedHashMap) MockHttpServletRequest(org.minijax.test.MockHttpServletRequest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)23 MockHttpServletRequest (org.minijax.test.MockHttpServletRequest)23 MultivaluedHashMap (javax.ws.rs.core.MultivaluedHashMap)16 ByteArrayInputStream (java.io.ByteArrayInputStream)4 Minijax (org.minijax.Minijax)3 MinijaxApplication (org.minijax.MinijaxApplication)3 MinijaxRequestContext (org.minijax.MinijaxRequestContext)3 MockHttpServletResponse (org.minijax.test.MockHttpServletResponse)3 Cookie (javax.servlet.http.Cookie)2 MinijaxTest (org.minijax.test.MinijaxTest)2 DeploymentInfo (io.undertow.servlet.api.DeploymentInfo)1 WebSocketDeploymentInfo (io.undertow.websockets.jsr.WebSocketDeploymentInfo)1 AnnotatedEndpoint (io.undertow.websockets.jsr.annotated.AnnotatedEndpoint)1 ArrayList (java.util.ArrayList)1 Locale (java.util.Locale)1 ServerEndpointConfig (javax.websocket.server.ServerEndpointConfig)1 Cookie (javax.ws.rs.core.Cookie)1 MediaType (javax.ws.rs.core.MediaType)1 Widget (org.minijax.db.test.Widget)1