Example usage for org.apache.http.client.cache HttpCacheEntry getProtocolVersion

List of usage examples for org.apache.http.client.cache HttpCacheEntry getProtocolVersion

Introduction

In this page you can find the example usage for org.apache.http.client.cache HttpCacheEntry getProtocolVersion.

Prototype

public ProtocolVersion getProtocolVersion() 

Source Link

Document

Returns the ProtocolVersion from the origin HttpResponse .

Usage

From source file:org.apache.http.impl.client.cache.TestHttpCacheEntrySerializers.java

private boolean areEqual(HttpCacheEntry one, HttpCacheEntry two) throws IOException {
    // dates are only stored with second precision, so scrub milliseconds
    if (!((one.getRequestDate().getTime() / 1000) == (two.getRequestDate().getTime() / 1000)))
        return false;
    if (!((one.getResponseDate().getTime() / 1000) == (two.getResponseDate().getTime() / 1000)))
        return false;
    if (!one.getProtocolVersion().equals(two.getProtocolVersion()))
        return false;

    byte[] onesByteArray = resourceToBytes(one.getResource());
    byte[] twosByteArray = resourceToBytes(two.getResource());

    if (!Arrays.equals(onesByteArray, twosByteArray))
        return false;

    Header[] oneHeaders = one.getAllHeaders();
    Header[] twoHeaders = two.getAllHeaders();
    if (!(oneHeaders.length == twoHeaders.length))
        return false;
    for (int i = 0; i < oneHeaders.length; i++) {
        if (!oneHeaders[i].getName().equals(twoHeaders[i].getName()))
            return false;
        if (!oneHeaders[i].getValue().equals(twoHeaders[i].getValue()))
            return false;
    }//w w  w.ja v a2s.  c om

    return true;
}