"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/HttpCacheEntryMatcher.java" between
httpcomponents-client-5.2-src.tar.gz and httpcomponents-client-5.2.1-src.tar.gz

About: Apache HttpComponents Client provides reusable components for client-side authentication, HTTP state management, and HTTP connection management. Java sources.

HttpCacheEntryMatcher.java  (httpcomponents-client-5.2-src):HttpCacheEntryMatcher.java  (httpcomponents-client-5.2.1-src)
skipping to change at line 31 skipping to change at line 31
* This software consists of voluntary contributions made by many * This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more * individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see * information on the Apache Software Foundation, please see
* <http://www.apache.org/>. * <http://www.apache.org/>.
* *
*/ */
package org.apache.hc.client5.http.impl.cache; package org.apache.hc.client5.http.impl.cache;
import java.time.Instant; import java.time.Instant;
import java.util.Arrays; import java.util.Arrays;
import java.util.Objects;
import org.apache.hc.client5.http.cache.HttpCacheEntry; import org.apache.hc.client5.http.cache.HttpCacheEntry;
import org.apache.hc.client5.http.cache.Resource; import org.apache.hc.client5.http.cache.Resource;
import org.apache.hc.client5.http.cache.ResourceIOException; import org.apache.hc.client5.http.cache.ResourceIOException;
import org.apache.hc.core5.http.Header; import org.apache.hc.core5.http.Header;
import org.apache.hc.core5.util.LangUtils;
import org.hamcrest.BaseMatcher; import org.hamcrest.BaseMatcher;
import org.hamcrest.Description; import org.hamcrest.Description;
import org.hamcrest.Matcher; import org.hamcrest.Matcher;
public class HttpCacheEntryMatcher extends BaseMatcher<HttpCacheEntry> { public class HttpCacheEntryMatcher extends BaseMatcher<HttpCacheEntry> {
private final HttpCacheEntry expectedValue; private final HttpCacheEntry expectedValue;
public HttpCacheEntryMatcher(final HttpCacheEntry expectedValue) { public HttpCacheEntryMatcher(final HttpCacheEntry expectedValue) {
this.expectedValue = expectedValue; this.expectedValue = expectedValue;
skipping to change at line 62 skipping to change at line 62
try { try {
final HttpCacheEntry otherValue = (HttpCacheEntry) item; final HttpCacheEntry otherValue = (HttpCacheEntry) item;
final int expectedStatus = expectedValue.getStatus(); final int expectedStatus = expectedValue.getStatus();
final int otherStatus = otherValue.getStatus(); final int otherStatus = otherValue.getStatus();
if (expectedStatus != otherStatus) { if (expectedStatus != otherStatus) {
return false; return false;
} }
final Instant expectedRequestInstant = expectedValue.getRequestI nstant(); final Instant expectedRequestInstant = expectedValue.getRequestI nstant();
final Instant otherRequestInstant = otherValue.getRequestInstant (); final Instant otherRequestInstant = otherValue.getRequestInstant ();
if (!LangUtils.equals(expectedRequestInstant, otherRequestInstan t)) { if (!Objects.equals(expectedRequestInstant, otherRequestInstant) ) {
return false; return false;
} }
final Instant expectedResponseInstant = expectedValue.getRespons eInstant(); final Instant expectedResponseInstant = expectedValue.getRespons eInstant();
final Instant otherResponseInstant = otherValue.getResponseInsta nt(); final Instant otherResponseInstant = otherValue.getResponseInsta nt();
if (!LangUtils.equals(expectedResponseInstant, otherResponseInst ant)) { if (!Objects.equals(expectedResponseInstant, otherResponseInstan t)) {
return false; return false;
} }
final Header[] expectedHeaders = expectedValue.getHeaders(); final Header[] expectedHeaders = expectedValue.getHeaders();
final Header[] otherHeaders = otherValue.getHeaders(); final Header[] otherHeaders = otherValue.getHeaders();
if (expectedHeaders.length != otherHeaders.length) { if (expectedHeaders.length != otherHeaders.length) {
return false; return false;
} }
for (int i = 0; i < expectedHeaders.length; i++) { for (int i = 0; i < expectedHeaders.length; i++) {
final Header h1 = expectedHeaders[i]; final Header h1 = expectedHeaders[i];
final Header h2 = otherHeaders[i]; final Header h2 = otherHeaders[i];
if (!h1.getName().equals(h2.getName()) || !LangUtils.equals( h1.getValue(), h2.getValue())) { if (!h1.getName().equals(h2.getName()) || !Objects.equals(h1 .getValue(), h2.getValue())) {
return false; return false;
} }
} }
final Resource expectedResource = expectedValue.getResource(); final Resource expectedResource = expectedValue.getResource();
final byte[] expectedContent = expectedResource != null ? expect edResource.get() : null; final byte[] expectedContent = expectedResource != null ? expect edResource.get() : null;
final Resource otherResource = otherValue.getResource(); final Resource otherResource = otherValue.getResource();
final byte[] otherContent = otherResource != null ? otherResourc e.get() : null; final byte[] otherContent = otherResource != null ? otherResourc e.get() : null;
return Arrays.equals(expectedContent, otherContent); return Arrays.equals(expectedContent, otherContent);
} catch (final ResourceIOException ex) { } catch (final ResourceIOException ex) {
throw new RuntimeException(ex); throw new RuntimeException(ex);
 End of changes. 5 change blocks. 
4 lines changed or deleted 4 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)