### Question:
RequestProtocolCompliance { public void makeRequestCompliant(final HttpRequest request) { decrementOPTIONSMaxForwardsIfGreaterThen0(request); stripOtherFreshnessDirectivesWithNoCache(request); if (requestVersionIsTooLow(request) || requestMinorVersionIsTooHighMajorVersionsMatch(request)) { request.setVersion(HttpVersion.HTTP_1_1); } } RequestProtocolCompliance();  RequestProtocolCompliance(final boolean weakETagOnPutDeleteAllowed); List<RequestProtocolError> requestIsFatallyNonCompliant(final HttpRequest request); void makeRequestCompliant(final HttpRequest request);  }### Answer:
@Test public void doesNotModifyACompliantRequest() throws Exception { final HttpRequest req = new BasicHttpRequest("GET", "/"); final HttpRequest wrapper = RequestCopier.INSTANCE.copy(req); impl.makeRequestCompliant(wrapper); assertTrue(HttpTestUtils.equivalent(req, wrapper)); }
@Test public void upgrades1_0RequestTo1_1() throws Exception { final HttpRequest req = new BasicHttpRequest("GET", "/"); req.setVersion(HttpVersion.HTTP_1_0); final HttpRequest wrapper = RequestCopier.INSTANCE.copy(req); impl.makeRequestCompliant(wrapper); assertEquals(HttpVersion.HTTP_1_1, wrapper.getVersion()); }
@Test public void downgrades1_2RequestTo1_1() throws Exception { final HttpRequest req = new BasicHttpRequest("GET", "/"); req.setVersion(new ProtocolVersion("HTTP", 1, 2)); final HttpRequest wrapper = RequestCopier.INSTANCE.copy(req); impl.makeRequestCompliant(wrapper); assertEquals(HttpVersion.HTTP_1_1, wrapper.getVersion()); }
@Test public void stripsMinFreshFromRequestIfNoCachePresent() throws Exception { final HttpRequest req = new BasicHttpRequest("GET", "/"); req.setHeader("Cache-Control", "no-cache, min-fresh=10"); final HttpRequest wrapper = RequestCopier.INSTANCE.copy(req); impl.makeRequestCompliant(wrapper); assertEquals("no-cache", wrapper.getFirstHeader("Cache-Control").getValue()); }
@Test public void stripsMaxFreshFromRequestIfNoCachePresent() throws Exception { final HttpRequest req = new BasicHttpRequest("GET", "/"); req.setHeader("Cache-Control", "no-cache, max-stale=10"); final HttpRequest wrapper = RequestCopier.INSTANCE.copy(req); impl.makeRequestCompliant(wrapper); assertEquals("no-cache", wrapper.getFirstHeader("Cache-Control").getValue()); }
@Test public void stripsMaxAgeFromRequestIfNoCachePresent() throws Exception { final HttpRequest req = new BasicHttpRequest("GET", "/"); req.setHeader("Cache-Control", "no-cache, max-age=10"); final HttpRequest wrapper = RequestCopier.INSTANCE.copy(req); impl.makeRequestCompliant(wrapper); assertEquals("no-cache", wrapper.getFirstHeader("Cache-Control").getValue()); }
@Test public void doesNotStripMinFreshFromRequestWithoutNoCache() throws Exception { final HttpRequest req = new BasicHttpRequest("GET", "/"); req.setHeader("Cache-Control", "min-fresh=10"); final HttpRequest wrapper = RequestCopier.INSTANCE.copy(req); impl.makeRequestCompliant(wrapper); assertEquals("min-fresh=10", wrapper.getFirstHeader("Cache-Control").getValue()); }
@Test public void correctlyStripsMinFreshFromMiddleIfNoCache() throws Exception { final HttpRequest req = new BasicHttpRequest("GET", "/"); req.setHeader("Cache-Control", "no-cache,min-fresh=10,no-store"); final HttpRequest wrapper = RequestCopier.INSTANCE.copy(req); impl.makeRequestCompliant(wrapper); assertEquals("no-cache,no-store", wrapper.getFirstHeader("Cache-Control").getValue()); }