public void testSimpleEtag() throws Exception { MockHttpRequest request = new MockHttpRequest() { @Override public String getMethod() { return HttpGet.METHOD_NAME; } @Override public URI getURI() { return URI.create("http://test.com"); } @Override public boolean containsHeader(String name) { return false; } }; try { interceptor.onPreCall(request, null); } catch (UnsupportedOperationException e) { fail(); } assertTrue("should not give an exception", true); }
public void testGettingEtag() throws Exception { ETag etag = new ETag(); etag.etag = "test-etag"; etag.lastModified = "modified"; interceptor.helper.insertETagForUri(etag, "http://test.com"); MockHttpRequest request = new MockHttpRequest() { @Override public String getMethod() { return HttpGet.METHOD_NAME; } @Override public URI getURI() { return URI.create("http://test.com"); } @Override public boolean containsHeader(String name) { return false; } @Override public void addHeader(Header header) { if (header.getName().equals(ETag.ETAG)) { assertEquals("test-etag", header.getValue()); } if (header.getName().equals(ETag.LAST_MODIFIED)) { assertEquals("modified", header.getValue()); } } }; try { interceptor.onPreCall(request, null); } catch (UnsupportedOperationException e) { fail("should not give an exception"); } assertTrue(true); }