"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/ContainsHeaderMatcher.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.

ContainsHeaderMatcher.java  (httpcomponents-client-5.2-src):ContainsHeaderMatcher.java  (httpcomponents-client-5.2.1-src)
skipping to change at line 30 skipping to change at line 30
* *
* 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.util.Iterator; import java.util.Iterator;
import java.util.Objects;
import org.apache.hc.client5.http.cache.HttpCacheEntry; import org.apache.hc.client5.http.cache.HttpCacheEntry;
import org.apache.hc.core5.http.Header; import org.apache.hc.core5.http.Header;
import org.apache.hc.core5.http.MessageHeaders; import org.apache.hc.core5.http.MessageHeaders;
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 ContainsHeaderMatcher extends BaseMatcher<HttpCacheEntry> { public class ContainsHeaderMatcher extends BaseMatcher<HttpCacheEntry> {
private final String headerName; private final String headerName;
private final Object headerValue; private final Object headerValue;
public ContainsHeaderMatcher(final String headerName, final Object headerVal ue) { public ContainsHeaderMatcher(final String headerName, final Object headerVal ue) {
this.headerName = headerName; this.headerName = headerName;
this.headerValue = headerValue; this.headerValue = headerValue;
} }
@Override @Override
public boolean matches(final Object item) { public boolean matches(final Object item) {
if (item instanceof MessageHeaders) { if (item instanceof MessageHeaders) {
final MessageHeaders messageHeaders = (MessageHeaders) item; final MessageHeaders messageHeaders = (MessageHeaders) item;
for (final Iterator<Header> it = messageHeaders.headerIterator(); it .hasNext(); ) { for (final Iterator<Header> it = messageHeaders.headerIterator(); it .hasNext(); ) {
final Header header = it.next(); final Header header = it.next();
if (headerName.equalsIgnoreCase(header.getName()) && LangUtils.e quals(headerValue, header.getValue())) { if (headerName.equalsIgnoreCase(header.getName()) && Objects.equ als(headerValue, header.getValue())) {
return true; return true;
} }
} }
} }
return false; return false;
} }
@Override @Override
public void describeTo(final Description description) { public void describeTo(final Description description) {
description.appendText("contains header ").appendValue(headerValue).appe ndText(": ").appendValue(headerValue); description.appendText("contains header ").appendValue(headerValue).appe ndText(": ").appendValue(headerValue);
 End of changes. 3 change blocks. 
2 lines changed or deleted 2 lines changed or added

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