@Test
public void notModified() throws Exception {

    MockHttpStack mockHttpStack = new MockHttpStack();
    List<Header> headers = new ArrayList<>();
    headers.add(new Header("ServerKeyA", "ServerValueA"));
    headers.add(new Header("ServerKeyB", "ServerValueB"));
    headers.add(new Header("SharedKey", "ServerValueShared"));
    headers.add(new Header("sharedcaseinsensitivekey", "ServerValueShared1"));
    headers.add(new Header("SharedCaseInsensitiveKey", "ServerValueShared2"));
    HttpResponse fakeResponse = new HttpResponse(HttpURLConnection.HTTP_NOT_MODIFIED, headers);
    mockHttpStack.setResponseToReturn(fakeResponse);
    BasicNetwork httpNetwork = new BasicNetwork(mockHttpStack);
    Request<String> request = buildRequest();
    Entry entry = new Entry();
    entry.allResponseHeaders = new ArrayList<>();
    entry.allResponseHeaders.add(new Header("CachedKeyA", "CachedValueA"));
    entry.allResponseHeaders.add(new Header("CachedKeyB", "CachedValueB"));
    entry.allResponseHeaders.add(new Header("SharedKey", "CachedValueShared"));
    entry.allResponseHeaders.add(new Header("SHAREDCASEINSENSITIVEKEY", "CachedValueShared1"));
    entry.allResponseHeaders.add(new Header("shAREDcaSEinSENSITIVEkeY", "CachedValueShared2"));
    request.setCacheEntry(entry);
    NetworkResponse response = httpNetwork.performRequest(request);
    List<Header> expectedHeaders = new ArrayList<>();
    // Should have all server headers + cache headers that didn't show up in server response.
    expectedHeaders.add(new Header("ServerKeyA", "ServerValueA"));
    expectedHeaders.add(new Header("ServerKeyB", "ServerValueB"));
    expectedHeaders.add(new Header("SharedKey", "ServerValueShared"));
    expectedHeaders.add(new Header("sharedcaseinsensitivekey", "ServerValueShared1"));
    expectedHeaders.add(new Header("SharedCaseInsensitiveKey", "ServerValueShared2"));
    expectedHeaders.add(new Header("CachedKeyA", "CachedValueA"));
    expectedHeaders.add(new Header("CachedKeyB", "CachedValueB"));
    assertThat(expectedHeaders, containsInAnyOrder(response.allHeaders.toArray(new Header[0])));
}