@Test public void testResolveGETWithNoHeaders() throws IOException { HTTPRequest request = new HTTPRequest(URI.create("http://dummy/uri/123"), HTTPMethod.GET); final HttpMethod method = mock(GetMethod.class); HTTPClientResponseResolver resolver = createResponseResolver(method, Status.valueOf(200), new Header[0]); HTTPResponse response = resolver.resolve(request); assertNotNull("Response was null", response); assertEquals(200, response.getStatus().getCode()); assertEquals(0, response.getHeaders().size()); }
@Test public void testResolvePUTWithNoHeaders() throws IOException { HTTPRequest request = new HTTPRequest(URI.create("http://dummy/uri/123"), HTTPMethod.PUT); final Payload payload = mock(Payload.class); request = request.payload(payload); when(payload.getMimeType()).thenReturn(new MIMEType("text/plain")); final HttpMethod method = mock(PostMethod.class); HTTPClientResponseResolver resolver = createResponseResolver(method, Status.valueOf(200), new Header[0]); HTTPResponse response = resolver.resolve(request); assertNotNull(response); assertEquals(200, response.getStatus().getCode()); assertEquals(0, response.getHeaders().size()); }
public CacheItemHolder mapRow(ResultSet rs, Connection connection) throws SQLException { URI uri = URI.create(rs.getString("uri")); Vary vary = convertToVary(rs.getString("vary")); Blob blob = rs.getBlob("payload"); Payload payload = null; if (blob != null && !rs.wasNull()) { payload = new InputStreamPayload( new ResultSetInputStream(rs, connection, blob.getBinaryStream()), MIMEType.valueOf(rs.getString("mimetype"))); } Status status = Status.valueOf(rs.getInt("status")); Headers headers = convertToHeaders(rs.getString("headers")); DateTime cacheTime = new DateTime(rs.getTimestamp("cachetime").getTime()); HTTPResponse response = new HTTPResponse(payload, status, headers); return new CacheItemHolder(uri, vary, new CacheItem(rewriteResponse(response), cacheTime)); }