@Test public void testTwoDifferentRequests() { final Request req1 = request(); final Request req2 = req1.requestBuilder().setEntity("This is a different request".getBytes()).build(); final Response res1 = response(); final Response res2 = res1.responseBuilder().setEntity("This is a different response".getBytes()).build(); FilterUtil.fireUntypedRequestResponse(getFilterChain(), req1, res1); FilterUtil.fireUntypedRequestResponse(getFilterChain(), req2, res2); // Should have created two separate entries Assert.assertEquals(res1, getDb().<Response>replay(req1)); Assert.assertEquals(res2, getDb().<Response>replay(req2)); }
public String formatRequest(Request request) { StringBuilder builder = new StringBuilder(); if (request instanceof RestRequest) { RestRequest restRequest = (RestRequest) request; builder.append("\"").append(restRequest.getMethod()); builder.append(" ").append(formatRequestURI(restRequest)).append("\""); builder.append(" headers=[").append(formatHeaders(restRequest.getHeaders())).append("]"); } builder.append(" entityLength=").append(request.getEntity().length()); return builder.toString(); }
public String formatRequestURI(Request request) { // We want the ascii representation without the query string String uriText = request.getURI().toASCIIString(); return extractURI(uriText); }