You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2021/02/09 18:54:59 UTC

[httpcomponents-core] branch master updated (aa9f12c -> d375a17)

This is an automated email from the ASF dual-hosted git repository.

olegk pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/httpcomponents-core.git.


    from aa9f12c  Fix typo
     new 3587341  Removed references to deprecated Assert#assertThat
     new d375a17  Improved message builder support

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../hc/core5/http2/hpack/TestHPackCoding.java      |  17 +-
 .../hc/core5/benchmark/ResultFormatterTest.java    |  12 +-
 .../testing/classic/ClassicAuthenticationTest.java |  36 +--
 .../classic/ClassicServerAndRequesterTest.java     |  34 +--
 .../testing/classic/ClassicTLSIntegrationTest.java |  24 +-
 .../testing/framework/TestTestingFramework.java    |  35 +--
 .../apache/hc/core5/testing/nio/H2AlpnTest.java    |  26 +-
 .../hc/core5/testing/nio/H2IntegrationTest.java    |  71 ++---
 .../testing/nio/H2ProtocolNegotiationTest.java     |  32 +--
 .../nio/H2ServerAndMultiplexingRequesterTest.java  |  64 ++---
 .../testing/nio/H2ServerAndRequesterTest.java      |  58 ++--
 .../hc/core5/testing/nio/H2TLSIntegrationTest.java |  40 +--
 .../core5/testing/nio/Http1AuthenticationTest.java |  52 ++--
 .../testing/nio/Http1ServerAndRequesterTest.java   |  84 +++---
 .../http/io/support/ClassicRequestBuilder.java     | 216 ++++++---------
 .../http/io/support/ClassicResponseBuilder.java    | 103 ++-----
 .../core5/http/nio/support/AsyncPushBuilder.java   |  94 +++----
 .../http/nio/support/AsyncRequestBuilder.java      | 182 ++++---------
 .../http/nio/support/AsyncResponseBuilder.java     | 103 ++-----
 .../core5/http/support/AbstractMessageBuilder.java | 143 ++++++++++
 .../core5/http/support/AbstractRequestBuilder.java | 183 +++++++++++++
 .../http/support/AbstractResponseBuilder.java      | 106 ++++++++
 .../hc/core5/http/support/BasicRequestBuilder.java | 295 +++++++++++++++++++++
 .../core5/http/support/BasicResponseBuilder.java   | 120 +++++++++
 .../core5/concurrent/TestComplexCancellable.java   |   7 +-
 .../hc/core5/concurrent/TestComplexFuture.java     |  23 +-
 .../org/apache/hc/core5/http/HeaderMatcher.java}   |  48 ++--
 ...luePairListMatcher.java => HeadersMatcher.java} |  45 ++--
 .../core5/http/config/TestNamedElementChain.java   |  80 +++---
 .../core5/http/impl/nio/TestExpandableBuffer.java  |  42 +--
 .../hc/core5/http/ssl/TestTlsVersionParser.java    |  16 +-
 .../http/support/TestBasicMessageBuilders.java     | 197 ++++++++++++++
 .../core5/reactor/TestAbstractIOSessionPool.java   |  68 ++---
 .../org/apache/hc/core5/util/TestTimeValue.java    |  47 ++--
 34 files changed, 1739 insertions(+), 964 deletions(-)
 create mode 100644 httpcore5/src/main/java/org/apache/hc/core5/http/support/AbstractMessageBuilder.java
 create mode 100644 httpcore5/src/main/java/org/apache/hc/core5/http/support/AbstractRequestBuilder.java
 create mode 100644 httpcore5/src/main/java/org/apache/hc/core5/http/support/AbstractResponseBuilder.java
 create mode 100644 httpcore5/src/main/java/org/apache/hc/core5/http/support/BasicRequestBuilder.java
 create mode 100644 httpcore5/src/main/java/org/apache/hc/core5/http/support/BasicResponseBuilder.java
 copy httpcore5/src/{main/java/org/apache/hc/core5/http/nio/ssl/FixedPortStrategy.java => test/java/org/apache/hc/core5/http/HeaderMatcher.java} (53%)
 copy httpcore5/src/test/java/org/apache/hc/core5/http/{NameValuePairListMatcher.java => HeadersMatcher.java} (55%)
 create mode 100644 httpcore5/src/test/java/org/apache/hc/core5/http/support/TestBasicMessageBuilders.java


[httpcomponents-core] 02/02: Improved message builder support

Posted by ol...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

olegk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/httpcomponents-core.git

commit d375a17a2e69b707498202a334c75045f0a10f6a
Author: Oleg Kalnichevski <ol...@apache.org>
AuthorDate: Tue Feb 9 17:53:22 2021 +0100

    Improved message builder support
---
 .../http/io/support/ClassicRequestBuilder.java     | 216 ++++++---------
 .../http/io/support/ClassicResponseBuilder.java    | 103 ++-----
 .../core5/http/nio/support/AsyncPushBuilder.java   |  94 +++----
 .../http/nio/support/AsyncRequestBuilder.java      | 182 ++++---------
 .../http/nio/support/AsyncResponseBuilder.java     | 103 ++-----
 .../core5/http/support/AbstractMessageBuilder.java | 143 ++++++++++
 .../core5/http/support/AbstractRequestBuilder.java | 183 +++++++++++++
 .../http/support/AbstractResponseBuilder.java      | 106 ++++++++
 .../hc/core5/http/support/BasicRequestBuilder.java | 295 +++++++++++++++++++++
 .../core5/http/support/BasicResponseBuilder.java   | 120 +++++++++
 .../org/apache/hc/core5/http/HeaderMatcher.java    |  66 +++++
 .../org/apache/hc/core5/http/HeadersMatcher.java   |  72 +++++
 .../http/support/TestBasicMessageBuilders.java     | 197 ++++++++++++++
 13 files changed, 1398 insertions(+), 482 deletions(-)

diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/io/support/ClassicRequestBuilder.java b/httpcore5/src/main/java/org/apache/hc/core5/http/io/support/ClassicRequestBuilder.java
index fd621ed..5c407f5 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/io/support/ClassicRequestBuilder.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/io/support/ClassicRequestBuilder.java
@@ -27,19 +27,10 @@
 
 package org.apache.hc.core5.http.io.support;
 
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
 import org.apache.hc.core5.http.ClassicHttpRequest;
 import org.apache.hc.core5.http.ContentType;
 import org.apache.hc.core5.http.Header;
 import org.apache.hc.core5.http.HttpEntity;
-import org.apache.hc.core5.http.HttpVersion;
 import org.apache.hc.core5.http.Method;
 import org.apache.hc.core5.http.NameValuePair;
 import org.apache.hc.core5.http.ProtocolVersion;
@@ -47,12 +38,16 @@ import org.apache.hc.core5.http.io.entity.ByteArrayEntity;
 import org.apache.hc.core5.http.io.entity.HttpEntities;
 import org.apache.hc.core5.http.io.entity.StringEntity;
 import org.apache.hc.core5.http.message.BasicClassicHttpRequest;
-import org.apache.hc.core5.http.message.BasicHeader;
-import org.apache.hc.core5.http.message.BasicNameValuePair;
-import org.apache.hc.core5.http.message.HeaderGroup;
+import org.apache.hc.core5.http.support.AbstractRequestBuilder;
 import org.apache.hc.core5.net.URIBuilder;
 import org.apache.hc.core5.util.Args;
 
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.nio.charset.Charset;
+import java.util.Arrays;
+import java.util.List;
+
 /**
  * Builder for {@link ClassicHttpRequest} instances.
  * <p>
@@ -65,44 +60,32 @@ import org.apache.hc.core5.util.Args;
  *
  * @since 5.0
  */
-public class ClassicRequestBuilder {
+public class ClassicRequestBuilder extends AbstractRequestBuilder<ClassicHttpRequest> {
 
-    private String method;
-    private URI uri;
-    private Charset charset;
-    private ProtocolVersion version;
-    private HeaderGroup headerGroup;
     private HttpEntity entity;
-    private List<NameValuePair> parameters;
-
-    ClassicRequestBuilder() {
-    }
 
     ClassicRequestBuilder(final String method) {
-        super();
-        this.method = method;
+        super(method);
     }
 
     ClassicRequestBuilder(final Method method) {
-        this(method.name());
+        super(method);
     }
 
     ClassicRequestBuilder(final String method, final URI uri) {
-        super();
-        this.method = method;
-        this.uri = uri;
+        super(method, uri);
     }
 
     ClassicRequestBuilder(final Method method, final URI uri) {
-        this(method.name(), uri);
+        super(method, uri);
     }
 
     ClassicRequestBuilder(final Method method, final String uri) {
-        this(method.name(), uri != null ? URI.create(uri) : null);
+        super(method, uri);
     }
 
     ClassicRequestBuilder(final String method, final String uri) {
-        this(method, uri != null ? URI.create(uri) : null);
+        super(method, uri);
     }
 
     public static ClassicRequestBuilder create(final String method) {
@@ -206,112 +189,87 @@ public class ClassicRequestBuilder {
         return new ClassicRequestBuilder(Method.OPTIONS, uri);
     }
 
-    public ClassicRequestBuilder setCharset(final Charset charset) {
-        this.charset = charset;
-        return this;
-    }
-
-    public Charset getCharset() {
-        return charset;
-    }
-
-    public String getMethod() {
-        return method;
-    }
-
-    public ProtocolVersion getVersion() {
-        return version;
-    }
-
+    @Override
     public ClassicRequestBuilder setVersion(final ProtocolVersion version) {
-        this.version = version;
+        super.setVersion(version);
         return this;
     }
 
-    public URI getUri() {
-        return uri;
-    }
-
+    @Override
     public ClassicRequestBuilder setUri(final URI uri) {
-        this.uri = uri;
+        super.setUri(uri);
         return this;
     }
 
+    @Override
     public ClassicRequestBuilder setUri(final String uri) {
-        this.uri = uri != null ? URI.create(uri) : null;
+        super.setUri(uri);
         return this;
     }
 
-    public Header[] getHeaders(final String name) {
-        return headerGroup != null ? headerGroup.getHeaders(name) : null;
-    }
-
+    @Override
     public ClassicRequestBuilder setHeaders(final Header... headers) {
-        if (headerGroup == null) {
-            headerGroup = new HeaderGroup();
-        }
-        headerGroup.setHeaders(headers);
+        super.setHeaders(headers);
         return this;
     }
 
-    public Header getFirstHeader(final String name) {
-        return headerGroup != null ? headerGroup.getFirstHeader(name) : null;
-    }
-
-    public Header getLastHeader(final String name) {
-        return headerGroup != null ? headerGroup.getLastHeader(name) : null;
-    }
-
+    @Override
     public ClassicRequestBuilder addHeader(final Header header) {
-        if (headerGroup == null) {
-            headerGroup = new HeaderGroup();
-        }
-        headerGroup.addHeader(header);
+        super.addHeader(header);
         return this;
     }
 
+    @Override
     public ClassicRequestBuilder addHeader(final String name, final String value) {
-        if (headerGroup == null) {
-            headerGroup = new HeaderGroup();
-        }
-        this.headerGroup.addHeader(new BasicHeader(name, value));
+        super.addHeader(name, value);
         return this;
     }
 
+    @Override
     public ClassicRequestBuilder removeHeader(final Header header) {
-        if (headerGroup == null) {
-            headerGroup = new HeaderGroup();
-        }
-        headerGroup.removeHeader(header);
+        super.removeHeader(header);
         return this;
     }
 
+    @Override
     public ClassicRequestBuilder removeHeaders(final String name) {
-        if (name == null || headerGroup == null) {
-            return this;
-        }
-        for (final Iterator<Header> i = headerGroup.headerIterator(); i.hasNext(); ) {
-            final Header header = i.next();
-            if (name.equalsIgnoreCase(header.getName())) {
-                i.remove();
-            }
-        }
+        super.removeHeaders(name);
         return this;
     }
 
+    @Override
     public ClassicRequestBuilder setHeader(final Header header) {
-        if (headerGroup == null) {
-            headerGroup = new HeaderGroup();
-        }
-        this.headerGroup.setHeader(header);
+        super.setHeader(header);
         return this;
     }
 
+    @Override
     public ClassicRequestBuilder setHeader(final String name, final String value) {
-        if (headerGroup == null) {
-            headerGroup = new HeaderGroup();
-        }
-        this.headerGroup.setHeader(new BasicHeader(name, value));
+        super.setHeader(name, value);
+        return this;
+    }
+
+    @Override
+    public ClassicRequestBuilder setCharset(final Charset charset) {
+        super.setCharset(charset);
+        return this;
+    }
+
+    @Override
+    public ClassicRequestBuilder addParameter(final NameValuePair nvp) {
+        super.addParameter(nvp);
+        return this;
+    }
+
+    @Override
+    public ClassicRequestBuilder addParameter(final String name, final String value) {
+        super.addParameter(name, value);
+        return this;
+    }
+
+    @Override
+    public ClassicRequestBuilder addParameters(final NameValuePair... nvps) {
+        super.addParameters(nvps);
         return this;
     }
 
@@ -339,41 +297,21 @@ public class ClassicRequestBuilder {
         return this;
     }
 
-    public List<NameValuePair> getParameters() {
-        return parameters != null ? new ArrayList<>(parameters) :
-                new ArrayList<NameValuePair>();
-    }
-
-    public ClassicRequestBuilder addParameter(final NameValuePair nvp) {
-        Args.notNull(nvp, "Name value pair");
-        if (parameters == null) {
-            parameters = new LinkedList<>();
-        }
-        parameters.add(nvp);
-        return this;
-    }
-
-    public ClassicRequestBuilder addParameter(final String name, final String value) {
-        return addParameter(new BasicNameValuePair(name, value));
-    }
-
-    public ClassicRequestBuilder addParameters(final NameValuePair... nvps) {
-        for (final NameValuePair nvp : nvps) {
-            addParameter(nvp);
-        }
-        return this;
-    }
-
     public ClassicHttpRequest build() {
-        URI uriCopy = this.uri != null ? this.uri : URI.create("/");
+        URI uriCopy = getUri();
+        if (uriCopy == null) {
+            uriCopy = URI.create("/");
+        }
         HttpEntity entityCopy = this.entity;
+        final String method = getMethod();
+        final List<NameValuePair> parameters = getParameters();
         if (parameters != null && !parameters.isEmpty()) {
             if (entityCopy == null && (Method.POST.isSame(method) || Method.PUT.isSame(method))) {
-                entityCopy = HttpEntities.createUrlEncoded(parameters, charset);
+                entityCopy = HttpEntities.createUrlEncoded(parameters, getCharset());
             } else {
                 try {
                     uriCopy = new URIBuilder(uriCopy)
-                            .setCharset(this.charset)
+                            .setCharset(getCharset())
                             .addParameters(parameters)
                             .build();
                 } catch (final URISyntaxException ex) {
@@ -386,11 +324,9 @@ public class ClassicRequestBuilder {
             throw new IllegalStateException(Method.TRACE + " requests may not include an entity");
         }
 
-        final ClassicHttpRequest result = new BasicClassicHttpRequest(method, uriCopy);
-        result.setVersion(this.version != null ? this.version : HttpVersion.HTTP_1_1);
-        if (this.headerGroup != null) {
-            result.setHeaders(this.headerGroup.getHeaders());
-        }
+        final BasicClassicHttpRequest result = new BasicClassicHttpRequest(method, uriCopy);
+        result.setVersion(getVersion());
+        result.setHeaders(getHeaders());
         result.setEntity(entityCopy);
         return result;
     }
@@ -399,19 +335,17 @@ public class ClassicRequestBuilder {
     public String toString() {
         final StringBuilder builder = new StringBuilder();
         builder.append("ClassicRequestBuilder [method=");
-        builder.append(method);
-        builder.append(", charset=");
-        builder.append(charset);
+        builder.append(getMethod());
         builder.append(", version=");
-        builder.append(version);
+        builder.append(getVersion());
         builder.append(", uri=");
-        builder.append(uri);
+        builder.append(getUri());
+        builder.append(", parameters=");
+        builder.append(getParameters());
         builder.append(", headerGroup=");
-        builder.append(headerGroup);
+        builder.append(Arrays.toString(getHeaders()));
         builder.append(", entity=");
         builder.append(entity != null ? entity.getClass() : null);
-        builder.append(", parameters=");
-        builder.append(parameters);
         builder.append("]");
         return builder.toString();
     }
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/io/support/ClassicResponseBuilder.java b/httpcore5/src/main/java/org/apache/hc/core5/http/io/support/ClassicResponseBuilder.java
index c8b583d..ce6d7bf 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/io/support/ClassicResponseBuilder.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/io/support/ClassicResponseBuilder.java
@@ -27,19 +27,17 @@
 
 package org.apache.hc.core5.http.io.support;
 
-import java.util.Iterator;
+import java.util.Arrays;
 
 import org.apache.hc.core5.http.ClassicHttpResponse;
 import org.apache.hc.core5.http.ContentType;
 import org.apache.hc.core5.http.Header;
 import org.apache.hc.core5.http.HttpEntity;
-import org.apache.hc.core5.http.HttpVersion;
 import org.apache.hc.core5.http.ProtocolVersion;
 import org.apache.hc.core5.http.io.entity.ByteArrayEntity;
 import org.apache.hc.core5.http.io.entity.StringEntity;
 import org.apache.hc.core5.http.message.BasicClassicHttpResponse;
-import org.apache.hc.core5.http.message.BasicHeader;
-import org.apache.hc.core5.http.message.HeaderGroup;
+import org.apache.hc.core5.http.support.AbstractResponseBuilder;
 import org.apache.hc.core5.util.Args;
 
 /**
@@ -47,19 +45,12 @@ import org.apache.hc.core5.util.Args;
  *
  * @since 5.0
  */
-public class ClassicResponseBuilder {
+public class ClassicResponseBuilder extends AbstractResponseBuilder<ClassicHttpResponse> {
 
-    private int status;
-    private ProtocolVersion version;
-    private HeaderGroup headerGroup;
     private HttpEntity entity;
 
-    ClassicResponseBuilder() {
-    }
-
     ClassicResponseBuilder(final int status) {
-        super();
-        this.status = status;
+        super(status);
     }
 
     public static ClassicResponseBuilder create(final int status) {
@@ -67,85 +58,51 @@ public class ClassicResponseBuilder {
         return new ClassicResponseBuilder(status);
     }
 
-    public ProtocolVersion getVersion() {
-        return version;
-    }
-
+    @Override
     public ClassicResponseBuilder setVersion(final ProtocolVersion version) {
-        this.version = version;
+        super.setVersion(version);
         return this;
     }
 
-    public Header[] getHeaders(final String name) {
-        return headerGroup != null ? headerGroup.getHeaders(name) : null;
-    }
-
+    @Override
     public ClassicResponseBuilder setHeaders(final Header... headers) {
-        if (headerGroup == null) {
-            headerGroup = new HeaderGroup();
-        }
-        headerGroup.setHeaders(headers);
+        super.setHeaders(headers);
         return this;
     }
 
-    public Header getFirstHeader(final String name) {
-        return headerGroup != null ? headerGroup.getFirstHeader(name) : null;
-    }
-
-    public Header getLastHeader(final String name) {
-        return headerGroup != null ? headerGroup.getLastHeader(name) : null;
-    }
-
+    @Override
     public ClassicResponseBuilder addHeader(final Header header) {
-        if (headerGroup == null) {
-            headerGroup = new HeaderGroup();
-        }
-        headerGroup.addHeader(header);
+        super.addHeader(header);
         return this;
     }
 
-    public ClassicResponseBuilder addHeader(final String name, final String value) {
-        if (headerGroup == null) {
-            headerGroup = new HeaderGroup();
-        }
-        this.headerGroup.addHeader(new BasicHeader(name, value));
+    @Override
+    public ClassicResponseBuilder addHeader(final String name, final    String value) {
+        super.addHeader(name, value);
         return this;
     }
 
+    @Override
     public ClassicResponseBuilder removeHeader(final Header header) {
-        if (headerGroup == null) {
-            headerGroup = new HeaderGroup();
-        }
-        headerGroup.removeHeader(header);
+        super.removeHeader(header);
         return this;
     }
 
+    @Override
     public ClassicResponseBuilder removeHeaders(final String name) {
-        if (name == null || headerGroup == null) {
-            return this;
-        }
-        for (final Iterator<Header> i = headerGroup.headerIterator(); i.hasNext(); ) {
-            final Header header = i.next();
-            if (name.equalsIgnoreCase(header.getName())) {
-                i.remove();
-            }
-        }
+        super.removeHeaders(name);
         return this;
     }
 
+    @Override
     public ClassicResponseBuilder setHeader(final Header header) {
-        if (headerGroup == null) {
-            headerGroup = new HeaderGroup();
-        }
-        this.headerGroup.setHeader(header);
+        super.setHeader(header);
         return this;
     }
 
+    @Override
     public ClassicResponseBuilder setHeader(final String name, final String value) {
-        if (headerGroup == null) {
-            headerGroup = new HeaderGroup();
-        }
-        this.headerGroup.setHeader(new BasicHeader(name, value));
+        super.setHeader(name, value);
         return this;
     }
 
@@ -174,11 +131,9 @@ public class ClassicResponseBuilder {
     }
 
     public ClassicHttpResponse build() {
-        final ClassicHttpResponse result = new BasicClassicHttpResponse(status);
-        result.setVersion(this.version != null ? this.version : HttpVersion.HTTP_1_1);
-        if (this.headerGroup != null) {
-            result.setHeaders(this.headerGroup.getHeaders());
-        }
+        final BasicClassicHttpResponse result = new BasicClassicHttpResponse(getStatus());
+        result.setVersion(getVersion());
+        result.setHeaders(getHeaders());
         result.setEntity(entity);
         return result;
     }
@@ -186,14 +141,10 @@ public class ClassicResponseBuilder {
     @Override
     public String toString() {
         final StringBuilder builder = new StringBuilder();
-        builder.append("ClassicResponseBuilder [method=");
-        builder.append(status);
-        builder.append(", status=");
-        builder.append(status);
-        builder.append(", version=");
-        builder.append(version);
+        builder.append("ClassicResponseBuilder [status=");
+        builder.append(getStatus());
         builder.append(", headerGroup=");
-        builder.append(headerGroup);
+        builder.append(Arrays.toString(getHeaders()));
         builder.append(", entity=");
         builder.append(entity != null ? entity.getClass() : null);
         builder.append("]");
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AsyncPushBuilder.java b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AsyncPushBuilder.java
index 66af20a..4155f61 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AsyncPushBuilder.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AsyncPushBuilder.java
@@ -27,36 +27,30 @@
 
 package org.apache.hc.core5.http.nio.support;
 
-import java.util.Iterator;
-
 import org.apache.hc.core5.http.ContentType;
 import org.apache.hc.core5.http.Header;
 import org.apache.hc.core5.http.HttpResponse;
-import org.apache.hc.core5.http.message.BasicHeader;
+import org.apache.hc.core5.http.ProtocolVersion;
 import org.apache.hc.core5.http.message.BasicHttpResponse;
-import org.apache.hc.core5.http.message.HeaderGroup;
 import org.apache.hc.core5.http.nio.AsyncEntityProducer;
 import org.apache.hc.core5.http.nio.AsyncPushProducer;
 import org.apache.hc.core5.http.nio.entity.BasicAsyncEntityProducer;
+import org.apache.hc.core5.http.support.AbstractResponseBuilder;
 import org.apache.hc.core5.util.Args;
 
+import java.util.Arrays;
+
 /**
  * Builder for {@link AsyncPushProducer} instances.
  *
  * @since 5.0
  */
-public class AsyncPushBuilder {
+public class AsyncPushBuilder extends AbstractResponseBuilder<AsyncPushProducer> {
 
-    private int status;
-    private HeaderGroup headerGroup;
     private AsyncEntityProducer entityProducer;
 
-    AsyncPushBuilder() {
-    }
-
     AsyncPushBuilder(final int status) {
-        super();
-        this.status = status;
+        super(status);
     }
 
     public static AsyncPushBuilder create(final int status) {
@@ -64,76 +58,51 @@ public class AsyncPushBuilder {
         return new AsyncPushBuilder(status);
     }
 
-    public Header[] getHeaders(final String name) {
-        return headerGroup != null ? headerGroup.getHeaders(name) : null;
+    @Override
+    public AsyncPushBuilder setVersion(final ProtocolVersion version) {
+        super.setVersion(version);
+        return this;
     }
 
+    @Override
     public AsyncPushBuilder setHeaders(final Header... headers) {
-        if (headerGroup == null) {
-            headerGroup = new HeaderGroup();
-        }
-        headerGroup.setHeaders(headers);
+        super.setHeaders(headers);
         return this;
     }
 
-    public Header getFirstHeader(final String name) {
-        return headerGroup != null ? headerGroup.getFirstHeader(name) : null;
-    }
-
-    public Header getLastHeader(final String name) {
-        return headerGroup != null ? headerGroup.getLastHeader(name) : null;
-    }
-
+    @Override
     public AsyncPushBuilder addHeader(final Header header) {
-        if (headerGroup == null) {
-            headerGroup = new HeaderGroup();
-        }
-        headerGroup.addHeader(header);
+        super.addHeader(header);
         return this;
     }
 
+    @Override
     public AsyncPushBuilder addHeader(final String name, final String value) {
-        if (headerGroup == null) {
-            headerGroup = new HeaderGroup();
-        }
-        this.headerGroup.addHeader(new BasicHeader(name, value));
+        super.addHeader(name, value);
         return this;
     }
 
+    @Override
     public AsyncPushBuilder removeHeader(final Header header) {
-        if (headerGroup == null) {
-            headerGroup = new HeaderGroup();
-        }
-        headerGroup.removeHeader(header);
+        super.removeHeader(header);
         return this;
     }
 
+    @Override
     public AsyncPushBuilder removeHeaders(final String name) {
-        if (name == null || headerGroup == null) {
-            return this;
-        }
-        for (final Iterator<Header> i = headerGroup.headerIterator(); i.hasNext(); ) {
-            final Header header = i.next();
-            if (name.equalsIgnoreCase(header.getName())) {
-                i.remove();
-            }
-        }
+        super.removeHeaders(name);
         return this;
     }
 
+    @Override
     public AsyncPushBuilder setHeader(final Header header) {
-        if (headerGroup == null) {
-            headerGroup = new HeaderGroup();
-        }
-        this.headerGroup.setHeader(header);
+        super.setHeader(header);
         return this;
     }
 
+    @Override
     public AsyncPushBuilder setHeader(final String name, final String value) {
-        if (headerGroup == null) {
-            headerGroup = new HeaderGroup();
-        }
-        this.headerGroup.setHeader(new BasicHeader(name, value));
+        super.setHeader(name, value);
         return this;
     }
 
@@ -162,22 +131,19 @@ public class AsyncPushBuilder {
     }
 
     public AsyncPushProducer build() {
-        final HttpResponse response = new BasicHttpResponse(status);
-        if (this.headerGroup != null) {
-            response.setHeaders(this.headerGroup.getHeaders());
-        }
+        final HttpResponse response = new BasicHttpResponse(getStatus());
+        response.setVersion(getVersion());
+        response.setHeaders(getHeaders());
         return new BasicPushProducer(response, entityProducer);
     }
 
     @Override
     public String toString() {
         final StringBuilder builder = new StringBuilder();
-        builder.append("AsyncPushProducer [method=");
-        builder.append(status);
-        builder.append(", status=");
-        builder.append(status);
+        builder.append("AsyncPushProducer [status=");
+        builder.append(getStatus());
         builder.append(", headerGroup=");
-        builder.append(headerGroup);
+        builder.append(Arrays.toString(getHeaders()));
         builder.append(", entity=");
         builder.append(entityProducer != null ? entityProducer.getClass() : null);
         builder.append("]");
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AsyncRequestBuilder.java b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AsyncRequestBuilder.java
index 720980e..a80737c 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AsyncRequestBuilder.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AsyncRequestBuilder.java
@@ -30,25 +30,20 @@ package org.apache.hc.core5.http.nio.support;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.LinkedList;
+import java.util.Arrays;
 import java.util.List;
 
 import org.apache.hc.core5.http.ContentType;
 import org.apache.hc.core5.http.Header;
-import org.apache.hc.core5.http.HttpRequest;
 import org.apache.hc.core5.http.Method;
 import org.apache.hc.core5.http.NameValuePair;
 import org.apache.hc.core5.http.ProtocolVersion;
-import org.apache.hc.core5.http.message.BasicHeader;
 import org.apache.hc.core5.http.message.BasicHttpRequest;
-import org.apache.hc.core5.http.message.BasicNameValuePair;
-import org.apache.hc.core5.http.message.HeaderGroup;
 import org.apache.hc.core5.http.nio.AsyncEntityProducer;
 import org.apache.hc.core5.http.nio.AsyncRequestProducer;
 import org.apache.hc.core5.http.nio.entity.BasicAsyncEntityProducer;
 import org.apache.hc.core5.http.nio.entity.StringAsyncEntityProducer;
+import org.apache.hc.core5.http.support.AbstractRequestBuilder;
 import org.apache.hc.core5.net.URIBuilder;
 import org.apache.hc.core5.net.WWWFormCodec;
 import org.apache.hc.core5.util.Args;
@@ -65,32 +60,20 @@ import org.apache.hc.core5.util.Args;
  *
  * @since 5.0
  */
-public class AsyncRequestBuilder {
+public class AsyncRequestBuilder extends AbstractRequestBuilder<AsyncRequestProducer> {
 
-    private String method;
-    private URI uri;
-    private Charset charset;
-    private ProtocolVersion version;
-    private HeaderGroup headerGroup;
     private AsyncEntityProducer entityProducer;
-    private List<NameValuePair> parameters;
-
-    AsyncRequestBuilder() {
-    }
 
     AsyncRequestBuilder(final String method) {
-        super();
-        this.method = method;
+        super(method);
     }
 
     AsyncRequestBuilder(final Method method) {
-        this(method.name());
+        super(method);
     }
 
     AsyncRequestBuilder(final String method, final URI uri) {
-        super();
-        this.method = method;
-        this.uri = uri;
+        super(method, uri);
     }
 
     AsyncRequestBuilder(final Method method, final URI uri) {
@@ -206,136 +189,87 @@ public class AsyncRequestBuilder {
         return new AsyncRequestBuilder(Method.OPTIONS, uri);
     }
 
-    public AsyncRequestBuilder setCharset(final Charset charset) {
-        this.charset = charset;
+    @Override
+    public AsyncRequestBuilder setVersion(final ProtocolVersion version) {
+        super.setVersion(version);
         return this;
     }
 
-    public Charset getCharset() {
-        return charset;
-    }
-
-    public String getMethod() {
-        return method;
-    }
-
-    public URI getUri() {
-        return uri;
-    }
-
+    @Override
     public AsyncRequestBuilder setUri(final URI uri) {
-        this.uri = uri;
+        super.setUri(uri);
         return this;
     }
 
+    @Override
     public AsyncRequestBuilder setUri(final String uri) {
-        this.uri = uri != null ? URI.create(uri) : null;
-        return this;
-    }
-
-    public ProtocolVersion getVersion() {
-        return version;
-    }
-
-    public AsyncRequestBuilder setVersion(final ProtocolVersion version) {
-        this.version = version;
+        super.setUri(uri);
         return this;
     }
 
-    public Header[] getHeaders(final String name) {
-        return headerGroup != null ? headerGroup.getHeaders(name) : null;
-    }
-
+    @Override
     public AsyncRequestBuilder setHeaders(final Header... headers) {
-        if (headerGroup == null) {
-            headerGroup = new HeaderGroup();
-        }
-        headerGroup.setHeaders(headers);
+        super.setHeaders(headers);
         return this;
     }
 
-    public Header getFirstHeader(final String name) {
-        return headerGroup != null ? headerGroup.getFirstHeader(name) : null;
-    }
-
-    public Header getLastHeader(final String name) {
-        return headerGroup != null ? headerGroup.getLastHeader(name) : null;
-    }
-
+    @Override
     public AsyncRequestBuilder addHeader(final Header header) {
-        if (headerGroup == null) {
-            headerGroup = new HeaderGroup();
-        }
-        headerGroup.addHeader(header);
+        super.addHeader(header);
         return this;
     }
 
+    @Override
     public AsyncRequestBuilder addHeader(final String name, final String value) {
-        if (headerGroup == null) {
-            headerGroup = new HeaderGroup();
-        }
-        this.headerGroup.addHeader(new BasicHeader(name, value));
+        super.addHeader(name, value);
         return this;
     }
 
+    @Override
     public AsyncRequestBuilder removeHeader(final Header header) {
-        if (headerGroup == null) {
-            headerGroup = new HeaderGroup();
-        }
-        headerGroup.removeHeader(header);
+        super.removeHeader(header);
         return this;
     }
 
+    @Override
     public AsyncRequestBuilder removeHeaders(final String name) {
-        if (name == null || headerGroup == null) {
-            return this;
-        }
-        for (final Iterator<Header> i = headerGroup.headerIterator(); i.hasNext(); ) {
-            final Header header = i.next();
-            if (name.equalsIgnoreCase(header.getName())) {
-                i.remove();
-            }
-        }
+        super.removeHeaders(name);
         return this;
     }
 
+    @Override
     public AsyncRequestBuilder setHeader(final Header header) {
-        if (headerGroup == null) {
-            headerGroup = new HeaderGroup();
-        }
-        this.headerGroup.setHeader(header);
+        super.setHeader(header);
         return this;
     }
 
+    @Override
     public AsyncRequestBuilder setHeader(final String name, final String value) {
-        if (headerGroup == null) {
-            headerGroup = new HeaderGroup();
-        }
-        this.headerGroup.setHeader(new BasicHeader(name, value));
+        super.setHeader(name, value);
         return this;
     }
 
-    public List<NameValuePair> getParameters() {
-        return parameters != null ? new ArrayList<>(parameters) : new ArrayList<NameValuePair>();
+    @Override
+    public AsyncRequestBuilder setCharset(final Charset charset) {
+        super.setCharset(charset);
+        return this;
     }
 
+    @Override
     public AsyncRequestBuilder addParameter(final NameValuePair nvp) {
-        Args.notNull(nvp, "Name value pair");
-        if (parameters == null) {
-            parameters = new LinkedList<>();
-        }
-        parameters.add(nvp);
+        super.addParameter(nvp);
         return this;
     }
 
+    @Override
     public AsyncRequestBuilder addParameter(final String name, final String value) {
-        return addParameter(new BasicNameValuePair(name, value));
+        super.addParameter(name, value);
+        return this;
     }
 
+    @Override
     public AsyncRequestBuilder addParameters(final NameValuePair... nvps) {
-        for (final NameValuePair nvp: nvps) {
-            addParameter(nvp);
-        }
+        super.addParameters(nvps);
         return this;
     }
 
@@ -364,9 +298,15 @@ public class AsyncRequestBuilder {
     }
 
     public AsyncRequestProducer build() {
-        URI uriCopy = uri != null ? uri : URI.create("/");
+        URI uriCopy = getUri();
+        if (uriCopy == null) {
+            uriCopy = URI.create("/");
+        }
         AsyncEntityProducer entityProducerCopy = entityProducer;
+        final String method = getMethod();
+        final List<NameValuePair> parameters = getParameters();
         if (parameters != null && !parameters.isEmpty()) {
+            final Charset charset = getCharset();
             if (entityProducerCopy == null && (Method.POST.isSame(method) || Method.PUT.isSame(method))) {
                 final String content = WWWFormCodec.format(
                         parameters,
@@ -377,9 +317,9 @@ public class AsyncRequestBuilder {
             } else {
                 try {
                     uriCopy = new URIBuilder(uriCopy)
-                      .setCharset(this.charset)
-                      .addParameters(parameters)
-                      .build();
+                            .setCharset(charset)
+                            .addParameters(parameters)
+                            .build();
                 } catch (final URISyntaxException ex) {
                     // should never happen
                 }
@@ -387,16 +327,12 @@ public class AsyncRequestBuilder {
         }
 
         if (entityProducerCopy != null && Method.TRACE.isSame(method)) {
-            throw new IllegalStateException(Method.TRACE + " requests may not include an entity.");
+            throw new IllegalStateException(Method.TRACE + " requests may not include an entity");
         }
 
-        final HttpRequest request = new BasicHttpRequest(method, uriCopy);
-        if (this.headerGroup != null) {
-            request.setHeaders(this.headerGroup.getHeaders());
-        }
-        if (version != null) {
-            request.setVersion(version);
-        }
+        final BasicHttpRequest request = new BasicHttpRequest(method, uriCopy);
+        request.setVersion(getVersion());
+        request.setHeaders(getHeaders());
         return new BasicRequestProducer(request, entityProducerCopy);
     }
 
@@ -404,19 +340,17 @@ public class AsyncRequestBuilder {
     public String toString() {
         final StringBuilder builder = new StringBuilder();
         builder.append("AsyncRequestBuilder [method=");
-        builder.append(method);
-        builder.append(", charset=");
-        builder.append(charset);
+        builder.append(getMethod());
         builder.append(", version=");
-        builder.append(version);
+        builder.append(getVersion());
         builder.append(", uri=");
-        builder.append(uri);
+        builder.append(getUri());
+        builder.append(", parameters=");
+        builder.append(getParameters());
         builder.append(", headerGroup=");
-        builder.append(headerGroup);
+        builder.append(Arrays.toString(getHeaders()));
         builder.append(", entity=");
         builder.append(entityProducer != null ? entityProducer.getClass() : null);
-        builder.append(", parameters=");
-        builder.append(parameters);
         builder.append("]");
         return builder.toString();
     }
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AsyncResponseBuilder.java b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AsyncResponseBuilder.java
index abb2294..42c6577 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AsyncResponseBuilder.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AsyncResponseBuilder.java
@@ -27,18 +27,16 @@
 
 package org.apache.hc.core5.http.nio.support;
 
-import java.util.Iterator;
+import java.util.Arrays;
 
 import org.apache.hc.core5.http.ContentType;
 import org.apache.hc.core5.http.Header;
-import org.apache.hc.core5.http.HttpResponse;
 import org.apache.hc.core5.http.ProtocolVersion;
-import org.apache.hc.core5.http.message.BasicHeader;
 import org.apache.hc.core5.http.message.BasicHttpResponse;
-import org.apache.hc.core5.http.message.HeaderGroup;
 import org.apache.hc.core5.http.nio.AsyncEntityProducer;
 import org.apache.hc.core5.http.nio.AsyncResponseProducer;
 import org.apache.hc.core5.http.nio.entity.BasicAsyncEntityProducer;
+import org.apache.hc.core5.http.support.AbstractResponseBuilder;
 import org.apache.hc.core5.util.Args;
 
 /**
@@ -46,19 +44,12 @@ import org.apache.hc.core5.util.Args;
  *
  * @since 5.0
  */
-public class AsyncResponseBuilder {
+public class AsyncResponseBuilder extends AbstractResponseBuilder<AsyncResponseProducer>  {
 
-    private int status;
-    private ProtocolVersion version;
-    private HeaderGroup headerGroup;
     private AsyncEntityProducer entityProducer;
 
-    AsyncResponseBuilder() {
-    }
-
     AsyncResponseBuilder(final int status) {
-        super();
-        this.status = status;
+        super(status);
     }
 
     public static AsyncResponseBuilder create(final int status) {
@@ -66,85 +57,51 @@ public class AsyncResponseBuilder {
         return new AsyncResponseBuilder(status);
     }
 
-    public ProtocolVersion getVersion() {
-        return version;
-    }
-
+    @Override
     public AsyncResponseBuilder setVersion(final ProtocolVersion version) {
-        this.version = version;
+        super.setVersion(version);
         return this;
     }
 
-    public Header[] getHeaders(final String name) {
-        return headerGroup != null ? headerGroup.getHeaders(name) : null;
-    }
-
+    @Override
     public AsyncResponseBuilder setHeaders(final Header... headers) {
-        if (headerGroup == null) {
-            headerGroup = new HeaderGroup();
-        }
-        headerGroup.setHeaders(headers);
+        super.setHeaders(headers);
         return this;
     }
 
-    public Header getFirstHeader(final String name) {
-        return headerGroup != null ? headerGroup.getFirstHeader(name) : null;
-    }
-
-    public Header getLastHeader(final String name) {
-        return headerGroup != null ? headerGroup.getLastHeader(name) : null;
-    }
-
+    @Override
     public AsyncResponseBuilder addHeader(final Header header) {
-        if (headerGroup == null) {
-            headerGroup = new HeaderGroup();
-        }
-        headerGroup.addHeader(header);
+        super.addHeader(header);
         return this;
     }
 
+    @Override
     public AsyncResponseBuilder addHeader(final String name, final String value) {
-        if (headerGroup == null) {
-            headerGroup = new HeaderGroup();
-        }
-        this.headerGroup.addHeader(new BasicHeader(name, value));
+        super.addHeader(name, value);
         return this;
     }
 
+    @Override
     public AsyncResponseBuilder removeHeader(final Header header) {
-        if (headerGroup == null) {
-            headerGroup = new HeaderGroup();
-        }
-        headerGroup.removeHeader(header);
+        super.removeHeader(header);
         return this;
     }
 
+    @Override
     public AsyncResponseBuilder removeHeaders(final String name) {
-        if (name == null || headerGroup == null) {
-            return this;
-        }
-        for (final Iterator<Header> i = headerGroup.headerIterator(); i.hasNext(); ) {
-            final Header header = i.next();
-            if (name.equalsIgnoreCase(header.getName())) {
-                i.remove();
-            }
-        }
+        super.removeHeaders(name);
         return this;
     }
 
+    @Override
     public AsyncResponseBuilder setHeader(final Header header) {
-        if (headerGroup == null) {
-            headerGroup = new HeaderGroup();
-        }
-        this.headerGroup.setHeader(header);
+        super.setHeader(header);
         return this;
     }
 
+    @Override
     public AsyncResponseBuilder setHeader(final String name, final String value) {
-        if (headerGroup == null) {
-            headerGroup = new HeaderGroup();
-        }
-        this.headerGroup.setHeader(new BasicHeader(name, value));
+        super.setHeader(name, value);
         return this;
     }
 
@@ -173,27 +130,19 @@ public class AsyncResponseBuilder {
     }
 
     public AsyncResponseProducer build() {
-        final HttpResponse response = new BasicHttpResponse(status);
-        if (this.headerGroup != null) {
-            response.setHeaders(this.headerGroup.getHeaders());
-        }
-        if (version != null) {
-            response.setVersion(version);
-        }
+        final BasicHttpResponse response = new BasicHttpResponse(getStatus());
+        response.setVersion(getVersion());
+        response.setHeaders(getHeaders());
         return new BasicResponseProducer(response, entityProducer);
     }
 
     @Override
     public String toString() {
         final StringBuilder builder = new StringBuilder();
-        builder.append("AsyncResponseBuilder [method=");
-        builder.append(status);
-        builder.append(", status=");
-        builder.append(status);
-        builder.append(", version=");
-        builder.append(version);
+        builder.append("AsyncResponseBuilder [status=");
+        builder.append(getStatus());
         builder.append(", headerGroup=");
-        builder.append(headerGroup);
+        builder.append(Arrays.toString(getHeaders()));
         builder.append(", entity=");
         builder.append(entityProducer != null ? entityProducer.getClass() : null);
         builder.append("]");
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/support/AbstractMessageBuilder.java b/httpcore5/src/main/java/org/apache/hc/core5/http/support/AbstractMessageBuilder.java
new file mode 100644
index 0000000..143c30c
--- /dev/null
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/support/AbstractMessageBuilder.java
@@ -0,0 +1,143 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.hc.core5.http.support;
+
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpMessage;
+import org.apache.hc.core5.http.ProtocolVersion;
+import org.apache.hc.core5.http.message.BasicHeader;
+import org.apache.hc.core5.http.message.HeaderGroup;
+
+import java.util.Iterator;
+
+/**
+ * Abstract {@link HttpMessage} builder.
+ *
+ * @since 5.1
+ */
+public abstract class AbstractMessageBuilder<T> {
+
+    private ProtocolVersion version;
+    private HeaderGroup headerGroup;
+
+    protected AbstractMessageBuilder() {
+    }
+
+    public ProtocolVersion getVersion() {
+        return version;
+    }
+
+    public AbstractMessageBuilder<T> setVersion(final ProtocolVersion version) {
+        this.version = version;
+        return this;
+    }
+
+    public Header[] getHeaders() {
+        return headerGroup != null ? headerGroup.getHeaders() : null;
+    }
+
+    public Header[] getHeaders(final String name) {
+        return headerGroup != null ? headerGroup.getHeaders(name) : null;
+    }
+
+    public AbstractMessageBuilder<T> setHeaders(final Header... headers) {
+        if (headerGroup == null) {
+            headerGroup = new HeaderGroup();
+        }
+        headerGroup.setHeaders(headers);
+        return this;
+    }
+
+    public Header[] getFirstHeaders() {
+        return headerGroup != null ? headerGroup.getHeaders() : null;
+    }
+
+    public Header getFirstHeader(final String name) {
+        return headerGroup != null ? headerGroup.getFirstHeader(name) : null;
+    }
+
+    public Header getLastHeader(final String name) {
+        return headerGroup != null ? headerGroup.getLastHeader(name) : null;
+    }
+
+    public AbstractMessageBuilder<T> addHeader(final Header header) {
+        if (headerGroup == null) {
+            headerGroup = new HeaderGroup();
+        }
+        headerGroup.addHeader(header);
+        return this;
+    }
+
+    public AbstractMessageBuilder<T> addHeader(final String name, final String value) {
+        if (headerGroup == null) {
+            headerGroup = new HeaderGroup();
+        }
+        headerGroup.addHeader(new BasicHeader(name, value));
+        return this;
+    }
+
+    public AbstractMessageBuilder<T> removeHeader(final Header header) {
+        if (headerGroup == null) {
+            headerGroup = new HeaderGroup();
+        }
+        headerGroup.removeHeader(header);
+        return this;
+    }
+
+    public AbstractMessageBuilder<T> removeHeaders(final String name) {
+        if (name == null || headerGroup == null) {
+            return this;
+        }
+        for (final Iterator<Header> i = headerGroup.headerIterator(); i.hasNext(); ) {
+            final Header header = i.next();
+            if (name.equalsIgnoreCase(header.getName())) {
+                i.remove();
+            }
+        }
+        return this;
+    }
+
+    public AbstractMessageBuilder<T> setHeader(final Header header) {
+        if (headerGroup == null) {
+            headerGroup = new HeaderGroup();
+        }
+        headerGroup.setHeader(header);
+        return this;
+    }
+
+    public AbstractMessageBuilder<T> setHeader(final String name, final String value) {
+        if (headerGroup == null) {
+            headerGroup = new HeaderGroup();
+        }
+        headerGroup.setHeader(new BasicHeader(name, value));
+        return this;
+    }
+
+    protected abstract T build();
+
+}
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/support/AbstractRequestBuilder.java b/httpcore5/src/main/java/org/apache/hc/core5/http/support/AbstractRequestBuilder.java
new file mode 100644
index 0000000..9c3c801
--- /dev/null
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/support/AbstractRequestBuilder.java
@@ -0,0 +1,183 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.hc.core5.http.support;
+
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.Method;
+import org.apache.hc.core5.http.NameValuePair;
+import org.apache.hc.core5.http.ProtocolVersion;
+import org.apache.hc.core5.http.message.BasicHttpRequest;
+import org.apache.hc.core5.http.message.BasicNameValuePair;
+
+import java.net.URI;
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * Builder for {@link BasicHttpRequest} instances.
+ *
+ * @since 5.1
+ */
+public abstract class AbstractRequestBuilder<T> extends AbstractMessageBuilder<T> {
+
+    private String method;
+    private URI uri;
+    private Charset charset;
+    private List<NameValuePair> parameters;
+
+    protected AbstractRequestBuilder(final String method) {
+        super();
+        this.method = method;
+    }
+
+    protected AbstractRequestBuilder(final Method method) {
+        this(method.name());
+    }
+
+    protected AbstractRequestBuilder(final String method, final URI uri) {
+        super();
+        this.method = method;
+        this.uri = uri;
+    }
+
+    protected AbstractRequestBuilder(final Method method, final URI uri) {
+        this(method.name(), uri);
+    }
+
+    protected AbstractRequestBuilder(final Method method, final String uri) {
+        this(method.name(), uri != null ? URI.create(uri) : null);
+    }
+
+    protected AbstractRequestBuilder(final String method, final String uri) {
+        this(method, uri != null ? URI.create(uri) : null);
+    }
+
+    public String getMethod() {
+        return method;
+    }
+
+    @Override
+    public AbstractRequestBuilder<T> setVersion(final ProtocolVersion version) {
+        super.setVersion(version);
+        return this;
+    }
+
+    public URI getUri() {
+        return uri;
+    }
+
+    public AbstractRequestBuilder<T> setUri(final URI uri) {
+        this.uri = uri;
+        return this;
+    }
+
+    public AbstractRequestBuilder<T> setUri(final String uri) {
+        this.uri = uri != null ? URI.create(uri) : null;
+        return this;
+    }
+
+    @Override
+    public AbstractRequestBuilder<T> setHeaders(final Header... headers) {
+        super.setHeaders(headers);
+        return this;
+    }
+
+    @Override
+    public AbstractRequestBuilder<T> addHeader(final Header header) {
+        super.addHeader(header);
+        return this;
+    }
+
+    @Override
+    public AbstractRequestBuilder<T> addHeader(final String name, final String value) {
+        super.addHeader(name, value);
+        return this;
+    }
+
+    @Override
+    public AbstractRequestBuilder<T> removeHeader(final Header header) {
+        super.removeHeader(header);
+        return this;
+    }
+
+    @Override
+    public AbstractRequestBuilder<T> removeHeaders(final String name) {
+        super.removeHeaders(name);
+        return this;
+    }
+
+    @Override
+    public AbstractRequestBuilder<T> setHeader(final Header header) {
+        super.setHeader(header);
+        return this;
+    }
+
+    @Override
+    public AbstractRequestBuilder<T> setHeader(final String name, final String value) {
+        super.setHeader(name, value);
+        return this;
+    }
+
+    public Charset getCharset() {
+        return charset;
+    }
+
+    public AbstractRequestBuilder<T> setCharset(final Charset charset) {
+        this.charset = charset;
+        return this;
+    }
+
+    public List<NameValuePair> getParameters() {
+        return parameters != null ? new ArrayList<>(parameters) : null;
+    }
+
+    public AbstractRequestBuilder<T> addParameter(final NameValuePair nvp) {
+        if (nvp == null) {
+            return this;
+        }
+        if (parameters == null) {
+            parameters = new LinkedList<>();
+        }
+        parameters.add(nvp);
+        return this;
+    }
+
+    public AbstractRequestBuilder<T> addParameter(final String name, final String value) {
+        return addParameter(new BasicNameValuePair(name, value));
+    }
+
+    public AbstractRequestBuilder<T> addParameters(final NameValuePair... nvps) {
+        for (final NameValuePair nvp : nvps) {
+            addParameter(nvp);
+        }
+        return this;
+    }
+
+}
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/support/AbstractResponseBuilder.java b/httpcore5/src/main/java/org/apache/hc/core5/http/support/AbstractResponseBuilder.java
new file mode 100644
index 0000000..d371e8e
--- /dev/null
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/support/AbstractResponseBuilder.java
@@ -0,0 +1,106 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.hc.core5.http.support;
+
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.ProtocolVersion;
+import org.apache.hc.core5.http.message.BasicHttpRequest;
+
+/**
+ * Builder for {@link BasicHttpRequest} instances.
+ *
+ * @since 5.1
+ */
+public abstract class AbstractResponseBuilder<T> extends AbstractMessageBuilder<T> {
+
+    private int status;
+
+    protected AbstractResponseBuilder(final int status) {
+        super();
+        this.status = status;
+    }
+
+    public int getStatus() {
+        return status;
+    }
+
+    public void setStatus(final int status) {
+        this.status = status;
+    }
+
+    @Override
+    public AbstractResponseBuilder<T> setVersion(final ProtocolVersion version) {
+        super.setVersion(version);
+        return this;
+    }
+
+    @Override
+    public AbstractResponseBuilder<T> setHeaders(final Header... headers) {
+        super.setHeaders(headers);
+        return this;
+    }
+
+    @Override
+    public AbstractResponseBuilder<T> addHeader(final Header header) {
+        super.addHeader(header);
+        return this;
+    }
+
+    @Override
+    public AbstractResponseBuilder<T> addHeader(final String name, final String value) {
+        super.addHeader(name, value);
+        return this;
+    }
+
+    @Override
+    public AbstractResponseBuilder<T> removeHeader(final Header header) {
+        super.removeHeader(header);
+        return this;
+    }
+
+    @Override
+    public AbstractResponseBuilder<T> removeHeaders(final String name) {
+        super.removeHeaders(name);
+        return this;
+    }
+
+    @Override
+    public AbstractResponseBuilder<T> setHeader(final Header header) {
+        super.setHeader(header);
+        return this;
+    }
+
+    @Override
+    public AbstractResponseBuilder<T> setHeader(final String name, final String value) {
+        super.setHeader(name, value);
+        return this;
+    }
+
+    protected abstract T build();
+
+}
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/support/BasicRequestBuilder.java b/httpcore5/src/main/java/org/apache/hc/core5/http/support/BasicRequestBuilder.java
new file mode 100644
index 0000000..dab7bb7
--- /dev/null
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/support/BasicRequestBuilder.java
@@ -0,0 +1,295 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.hc.core5.http.support;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.nio.charset.Charset;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.Method;
+import org.apache.hc.core5.http.NameValuePair;
+import org.apache.hc.core5.http.ProtocolVersion;
+import org.apache.hc.core5.http.message.BasicHttpRequest;
+import org.apache.hc.core5.net.URIBuilder;
+import org.apache.hc.core5.util.Args;
+
+/**
+ * Builder for {@link BasicHttpRequest} instances.
+ *
+ * @since 5.1
+ */
+public class BasicRequestBuilder extends AbstractRequestBuilder<BasicHttpRequest> {
+
+    BasicRequestBuilder(final String method) {
+        super(method);
+    }
+
+    BasicRequestBuilder(final Method method) {
+        super(method);
+    }
+
+    BasicRequestBuilder(final String method, final URI uri) {
+        super(method, uri);
+    }
+
+    BasicRequestBuilder(final Method method, final URI uri) {
+        super(method, uri);
+    }
+
+    BasicRequestBuilder(final Method method, final String uri) {
+        super(method, uri);
+    }
+
+    BasicRequestBuilder(final String method, final String uri) {
+        super(method, uri);
+    }
+
+    public static BasicRequestBuilder create(final String method) {
+        Args.notBlank(method, "HTTP method");
+        return new BasicRequestBuilder(method);
+    }
+
+    public static BasicRequestBuilder get() {
+        return new BasicRequestBuilder(Method.GET);
+    }
+
+    public static BasicRequestBuilder get(final URI uri) {
+        return new BasicRequestBuilder(Method.GET, uri);
+    }
+
+    public static BasicRequestBuilder get(final String uri) {
+        return new BasicRequestBuilder(Method.GET, uri);
+    }
+
+    public static BasicRequestBuilder head() {
+        return new BasicRequestBuilder(Method.HEAD);
+    }
+
+    public static BasicRequestBuilder head(final URI uri) {
+        return new BasicRequestBuilder(Method.HEAD, uri);
+    }
+
+    public static BasicRequestBuilder head(final String uri) {
+        return new BasicRequestBuilder(Method.HEAD, uri);
+    }
+
+    public static BasicRequestBuilder patch() {
+        return new BasicRequestBuilder(Method.PATCH);
+    }
+
+    public static BasicRequestBuilder patch(final URI uri) {
+        return new BasicRequestBuilder(Method.PATCH, uri);
+    }
+
+    public static BasicRequestBuilder patch(final String uri) {
+        return new BasicRequestBuilder(Method.PATCH, uri);
+    }
+
+    public static BasicRequestBuilder post() {
+        return new BasicRequestBuilder(Method.POST);
+    }
+
+    public static BasicRequestBuilder post(final URI uri) {
+        return new BasicRequestBuilder(Method.POST, uri);
+    }
+
+    public static BasicRequestBuilder post(final String uri) {
+        return new BasicRequestBuilder(Method.POST, uri);
+    }
+
+    public static BasicRequestBuilder put() {
+        return new BasicRequestBuilder(Method.PUT);
+    }
+
+    public static BasicRequestBuilder put(final URI uri) {
+        return new BasicRequestBuilder(Method.PUT, uri);
+    }
+
+    public static BasicRequestBuilder put(final String uri) {
+        return new BasicRequestBuilder(Method.PUT, uri);
+    }
+
+    public static BasicRequestBuilder delete() {
+        return new BasicRequestBuilder(Method.DELETE);
+    }
+
+    public static BasicRequestBuilder delete(final URI uri) {
+        return new BasicRequestBuilder(Method.DELETE, uri);
+    }
+
+    public static BasicRequestBuilder delete(final String uri) {
+        return new BasicRequestBuilder(Method.DELETE, uri);
+    }
+
+    public static BasicRequestBuilder trace() {
+        return new BasicRequestBuilder(Method.TRACE);
+    }
+
+    public static BasicRequestBuilder trace(final URI uri) {
+        return new BasicRequestBuilder(Method.TRACE, uri);
+    }
+
+    public static BasicRequestBuilder trace(final String uri) {
+        return new BasicRequestBuilder(Method.TRACE, uri);
+    }
+
+    public static BasicRequestBuilder options() {
+        return new BasicRequestBuilder(Method.OPTIONS);
+    }
+
+    public static BasicRequestBuilder options(final URI uri) {
+        return new BasicRequestBuilder(Method.OPTIONS, uri);
+    }
+
+    public static BasicRequestBuilder options(final String uri) {
+        return new BasicRequestBuilder(Method.OPTIONS, uri);
+    }
+
+    @Override
+    public BasicRequestBuilder setVersion(final ProtocolVersion version) {
+        super.setVersion(version);
+        return this;
+    }
+
+    @Override
+    public BasicRequestBuilder setUri(final URI uri) {
+        super.setUri(uri);
+        return this;
+    }
+
+    @Override
+    public BasicRequestBuilder setUri(final String uri) {
+        super.setUri(uri);
+        return this;
+    }
+
+    @Override
+    public BasicRequestBuilder setHeaders(final Header... headers) {
+        super.setHeaders(headers);
+        return this;
+    }
+
+    @Override
+    public BasicRequestBuilder addHeader(final Header header) {
+        super.addHeader(header);
+        return this;
+    }
+
+    @Override
+    public BasicRequestBuilder addHeader(final String name, final String value) {
+        super.addHeader(name, value);
+        return this;
+    }
+
+    @Override
+    public BasicRequestBuilder removeHeader(final Header header) {
+        super.removeHeader(header);
+        return this;
+    }
+
+    @Override
+    public BasicRequestBuilder removeHeaders(final String name) {
+        super.removeHeaders(name);
+        return this;
+    }
+
+    @Override
+    public BasicRequestBuilder setHeader(final Header header) {
+        super.setHeader(header);
+        return this;
+    }
+
+    @Override
+    public BasicRequestBuilder setHeader(final String name, final String value) {
+        super.setHeader(name, value);
+        return this;
+    }
+
+    @Override
+    public BasicRequestBuilder setCharset(final Charset charset) {
+        super.setCharset(charset);
+        return this;
+    }
+
+    @Override
+    public BasicRequestBuilder addParameter(final NameValuePair nvp) {
+        super.addParameter(nvp);
+        return this;
+    }
+
+    @Override
+    public BasicRequestBuilder addParameter(final String name, final String value) {
+        super.addParameter(name, value);
+        return this;
+    }
+
+    @Override
+    public BasicRequestBuilder addParameters(final NameValuePair... nvps) {
+        super.addParameters(nvps);
+        return this;
+    }
+
+    @Override
+    public BasicHttpRequest build() {
+        URI uri = getUri();
+        final List<NameValuePair> parameters = getParameters();
+        if (parameters != null && !parameters.isEmpty()) {
+            try {
+                uri = new URIBuilder(uri)
+                        .setCharset(getCharset())
+                        .addParameters(parameters)
+                        .build();
+            } catch (final URISyntaxException ex) {
+                // should never happen
+            }
+        }
+        final BasicHttpRequest result = new BasicHttpRequest(getMethod(), uri != null ? uri : URI.create("/"));
+        result.setVersion(getVersion());
+        result.setHeaders(getHeaders());
+        return result;
+    }
+
+    @Override
+    public String toString() {
+        final StringBuilder builder = new StringBuilder();
+        builder.append("BasicRequestBuilder [method=");
+        builder.append(getMethod());
+        builder.append(", uri=");
+        builder.append(getUri());
+        builder.append(", parameters=");
+        builder.append(getParameters());
+        builder.append(", headerGroup=");
+        builder.append(Arrays.toString(getHeaders()));
+        builder.append("]");
+        return builder.toString();
+    }
+
+}
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/support/BasicResponseBuilder.java b/httpcore5/src/main/java/org/apache/hc/core5/http/support/BasicResponseBuilder.java
new file mode 100644
index 0000000..de6baa3
--- /dev/null
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/support/BasicResponseBuilder.java
@@ -0,0 +1,120 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.hc.core5.http.support;
+
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.ProtocolVersion;
+import org.apache.hc.core5.http.message.BasicHttpResponse;
+import org.apache.hc.core5.util.Args;
+
+import java.util.Arrays;
+
+/**
+ * Builder for {@link BasicHttpResponse} instances.
+ *
+ * @since 5.1
+ */
+public class BasicResponseBuilder extends AbstractResponseBuilder<BasicHttpResponse> {
+
+    protected BasicResponseBuilder(final int status) {
+        super(status);
+    }
+
+    public static BasicResponseBuilder create(final int status) {
+        Args.checkRange(status, 100, 599, "HTTP status code");
+        return new BasicResponseBuilder(status);
+    }
+
+    @Override
+    public BasicResponseBuilder setVersion(final ProtocolVersion version) {
+        super.setVersion(version);
+        return this;
+    }
+
+    @Override
+    public BasicResponseBuilder setHeaders(final Header... headers) {
+        super.setHeaders(headers);
+        return this;
+    }
+
+    @Override
+    public BasicResponseBuilder addHeader(final Header header) {
+        super.addHeader(header);
+        return this;
+    }
+
+    @Override
+    public BasicResponseBuilder addHeader(final String name, final String value) {
+        super.addHeader(name, value);
+        return this;
+    }
+
+    @Override
+    public BasicResponseBuilder removeHeader(final Header header) {
+        super.removeHeader(header);
+        return this;
+    }
+
+    @Override
+    public BasicResponseBuilder removeHeaders(final String name) {
+        super.removeHeaders(name);
+        return this;
+    }
+
+    @Override
+    public BasicResponseBuilder setHeader(final Header header) {
+        super.setHeader(header);
+        return this;
+    }
+
+    @Override
+    public BasicResponseBuilder setHeader(final String name, final String value) {
+        super.setHeader(name, value);
+        return this;
+    }
+
+    @Override
+    public BasicHttpResponse build() {
+        final BasicHttpResponse result = new BasicHttpResponse(getStatus());
+        result.setVersion(getVersion());
+        result.setHeaders(getHeaders());
+        return result;
+    }
+
+    @Override
+    public String toString() {
+        final StringBuilder builder = new StringBuilder();
+        builder.append("BasicResponseBuilder [status=");
+        builder.append(getStatus());
+        builder.append(", headerGroup=");
+        builder.append(Arrays.toString(getHeaders()));
+        builder.append("]");
+        return builder.toString();
+    }
+
+}
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/HeaderMatcher.java b/httpcore5/src/test/java/org/apache/hc/core5/http/HeaderMatcher.java
new file mode 100644
index 0000000..528cfb7
--- /dev/null
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/HeaderMatcher.java
@@ -0,0 +1,66 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+package org.apache.hc.core5.http;
+
+import org.apache.hc.core5.util.LangUtils;
+import org.hamcrest.BaseMatcher;
+import org.hamcrest.Description;
+import org.hamcrest.Factory;
+import org.hamcrest.Matcher;
+
+public class HeaderMatcher extends BaseMatcher<Header> {
+
+    private final String headerName;
+    private final Object headerValue;
+
+    public HeaderMatcher(final String headerName, final Object headerValue) {
+        this.headerName = headerName;
+        this.headerValue = headerValue;
+    }
+
+    @Override
+    public boolean matches(final Object item) {
+        if (item instanceof Header) {
+            final Header header = (Header) item;
+            if (headerName.equalsIgnoreCase(header.getName()) && LangUtils.equals(headerValue, header.getValue())) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    @Override
+    public void describeTo(final Description description) {
+        description.appendText("same header as ").appendValue(headerValue).appendText(": ").appendValue(headerValue);
+    }
+
+    @Factory
+    public static Matcher<Header> same(final String headerName, final Object headerValue) {
+        return new HeaderMatcher(headerName, headerValue);
+    }
+
+}
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/HeadersMatcher.java b/httpcore5/src/test/java/org/apache/hc/core5/http/HeadersMatcher.java
new file mode 100644
index 0000000..5b6ae44
--- /dev/null
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/HeadersMatcher.java
@@ -0,0 +1,72 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+package org.apache.hc.core5.http;
+
+import org.apache.hc.core5.util.LangUtils;
+import org.hamcrest.BaseMatcher;
+import org.hamcrest.Description;
+import org.hamcrest.Factory;
+import org.hamcrest.Matcher;
+
+public class HeadersMatcher extends BaseMatcher<Header[]> {
+
+    private final Header[] expectedHeaders;
+
+    public HeadersMatcher(final Header... headers) {
+        this.expectedHeaders = headers;
+    }
+
+    @Override
+    public boolean matches(final Object item) {
+        if (item instanceof Header[]) {
+            final Header[] headers = (Header[]) item;
+            if (headers.length == expectedHeaders.length) {
+                for (int i = 0; i < headers.length; i++) {
+                    final Header h1 = headers[i];
+                    final Header h2 = expectedHeaders[i];
+                    if (!h1.getName().equalsIgnoreCase(h2.getName())
+                            || !LangUtils.equals(h1.getValue(), h2.getValue())) {
+                        return false;
+                    }
+                }
+                return true;
+            }
+        }
+        return false;
+    }
+
+    @Override
+    public void describeTo(final Description description) {
+        description.appendText("same headers as ").appendValueList("[", "; ", "]", expectedHeaders);
+    }
+
+    @Factory
+    public static Matcher<Header[]> same(final Header... headers) {
+        return new HeadersMatcher(headers);
+    }
+
+}
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/support/TestBasicMessageBuilders.java b/httpcore5/src/test/java/org/apache/hc/core5/http/support/TestBasicMessageBuilders.java
new file mode 100644
index 0000000..b4f7923
--- /dev/null
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/support/TestBasicMessageBuilders.java
@@ -0,0 +1,197 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.hc.core5.http.support;
+
+import org.apache.hc.core5.http.HeaderMatcher;
+import org.apache.hc.core5.http.HeadersMatcher;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.message.BasicHeader;
+import org.apache.hc.core5.http.message.BasicHttpRequest;
+import org.apache.hc.core5.http.message.BasicHttpResponse;
+import org.apache.hc.core5.http.message.BasicNameValuePair;
+import org.apache.hc.core5.net.URIAuthority;
+import org.hamcrest.MatcherAssert;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.net.URI;
+import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
+
+/**
+ * Simple tests for {@link BasicResponseBuilder} and {@link BasicRequestBuilder}.
+ */
+public class TestBasicMessageBuilders {
+
+    @Test
+    public void testResponseBasics() throws Exception {
+        final BasicResponseBuilder builder = BasicResponseBuilder.create(200);
+        Assert.assertEquals(200, builder.getStatus());
+        Assert.assertNull(builder.getHeaders());
+        Assert.assertNull(builder.getVersion());
+
+        final BasicHttpResponse r1 = builder.build();
+        Assert.assertNotNull(r1);
+        Assert.assertEquals(200, r1.getCode());
+        Assert.assertNull(r1.getVersion());
+
+        builder.setStatus(500);
+        builder.setVersion(HttpVersion.HTTP_1_0);
+        Assert.assertEquals(500, builder.getStatus());
+        Assert.assertEquals(HttpVersion.HTTP_1_0, builder.getVersion());
+
+        final BasicHttpResponse r2 = builder.build();
+        Assert.assertEquals(500, r2.getCode());
+        Assert.assertEquals(HttpVersion.HTTP_1_0, r2.getVersion());
+
+        builder.addHeader("h1", "v1");
+        builder.addHeader("h1", "v2");
+        builder.addHeader("h2", "v2");
+        MatcherAssert.assertThat(builder.getHeaders(), HeadersMatcher.same(
+                new BasicHeader("h1", "v1"), new BasicHeader("h1", "v2"), new BasicHeader("h2", "v2")));
+        MatcherAssert.assertThat(builder.getHeaders("h1"), HeadersMatcher.same(
+                new BasicHeader("h1", "v1"), new BasicHeader("h1", "v2")));
+        MatcherAssert.assertThat(builder.getFirstHeader("h1"), HeaderMatcher.same("h1", "v1"));
+        MatcherAssert.assertThat(builder.getLastHeader("h1"), HeaderMatcher.same("h1", "v2"));
+
+        final BasicHttpResponse r3 = builder.build();
+        MatcherAssert.assertThat(r3.getHeaders(), HeadersMatcher.same(
+                new BasicHeader("h1", "v1"), new BasicHeader("h1", "v2"), new BasicHeader("h2", "v2")));
+        MatcherAssert.assertThat(r3.getHeaders("h1"), HeadersMatcher.same(
+                new BasicHeader("h1", "v1"), new BasicHeader("h1", "v2")));
+        MatcherAssert.assertThat(r3.getFirstHeader("h1"), HeaderMatcher.same("h1", "v1"));
+        MatcherAssert.assertThat(r3.getLastHeader("h1"), HeaderMatcher.same("h1", "v2"));
+
+        builder.removeHeader(new BasicHeader("h1", "v2"));
+        MatcherAssert.assertThat(builder.getHeaders("h1"), HeadersMatcher.same(new BasicHeader("h1", "v1")));
+        MatcherAssert.assertThat(builder.getHeaders(), HeadersMatcher.same(
+                new BasicHeader("h1", "v1"), new BasicHeader("h2", "v2")));
+
+        final BasicHttpResponse r4 = builder.build();
+        MatcherAssert.assertThat(r4.getHeaders("h1"), HeadersMatcher.same(new BasicHeader("h1", "v1")));
+        MatcherAssert.assertThat(r4.getHeaders(), HeadersMatcher.same(
+                new BasicHeader("h1", "v1"), new BasicHeader("h2", "v2")));
+
+        builder.removeHeaders("h1");
+        MatcherAssert.assertThat(builder.getHeaders("h1"), HeadersMatcher.same());
+        MatcherAssert.assertThat(builder.getHeaders(), HeadersMatcher.same(new BasicHeader("h2", "v2")));
+
+        final BasicHttpResponse r5 = builder.build();
+        MatcherAssert.assertThat(r5.getHeaders("h1"), HeadersMatcher.same());
+        MatcherAssert.assertThat(r5.getHeaders(), HeadersMatcher.same(new BasicHeader("h2", "v2")));
+    }
+
+    @Test
+    public void testRequestBasics() throws Exception {
+        final BasicRequestBuilder builder = BasicRequestBuilder.get();
+        Assert.assertNull(builder.getUri());
+        Assert.assertEquals("GET", builder.getMethod());
+        Assert.assertNull(builder.getHeaders());
+        Assert.assertNull(builder.getVersion());
+        Assert.assertNull(builder.getCharset());
+        Assert.assertNull(builder.getParameters());
+
+        final BasicHttpRequest r1 = builder.build();
+        Assert.assertNotNull(r1);
+        Assert.assertEquals("GET", r1.getMethod());
+        Assert.assertNull(r1.getScheme());
+        Assert.assertNull(r1.getAuthority());
+        Assert.assertEquals("/", r1.getPath());
+        Assert.assertEquals(URI.create("/"), r1.getUri());
+        Assert.assertNull(r1.getVersion());
+
+        builder.setUri(URI.create("http://host:1234/blah?param=value"));
+        builder.setVersion(HttpVersion.HTTP_1_1);
+        Assert.assertEquals(URI.create("http://host:1234/blah?param=value"), builder.getUri());
+        Assert.assertEquals(HttpVersion.HTTP_1_1, builder.getVersion());
+
+        final BasicHttpRequest r2 = builder.build();
+        Assert.assertEquals("GET", r2.getMethod());
+        Assert.assertEquals("http", r2.getScheme());
+        Assert.assertEquals(new URIAuthority("host", 1234), r2.getAuthority());
+        Assert.assertEquals("/blah?param=value", r2.getPath());
+        Assert.assertEquals(URI.create("http://host:1234/blah?param=value"), r2.getUri());
+        Assert.assertEquals(HttpVersion.HTTP_1_1, builder.getVersion());
+
+        builder.setCharset(StandardCharsets.US_ASCII);
+        builder.addParameter("param1", "value1");
+        builder.addParameter("param2", null);
+        builder.addParameters(new BasicNameValuePair("param3", "value3"), new BasicNameValuePair("param4", null));
+
+        Assert.assertEquals(builder.getParameters(), Arrays.asList(
+                new BasicNameValuePair("param1", "value1"), new BasicNameValuePair("param2", null),
+                new BasicNameValuePair("param3", "value3"), new BasicNameValuePair("param4", null)
+        ));
+        Assert.assertEquals(URI.create("http://host:1234/blah?param=value"), builder.getUri());
+
+        final BasicHttpRequest r3 = builder.build();
+        Assert.assertEquals("GET", r3.getMethod());
+        Assert.assertEquals("http", r3.getScheme());
+        Assert.assertEquals(new URIAuthority("host", 1234), r3.getAuthority());
+        Assert.assertEquals("/blah?param=value&param1=value1&param2&param3=value3&param4", r3.getPath());
+        Assert.assertEquals(URI.create("http://host:1234/blah?param=value&param1=value1&param2&param3=value3&param4"),
+                r3.getUri());
+
+        builder.addHeader("h1", "v1");
+        builder.addHeader("h1", "v2");
+        builder.addHeader("h2", "v2");
+        MatcherAssert.assertThat(builder.getHeaders(), HeadersMatcher.same(
+                new BasicHeader("h1", "v1"), new BasicHeader("h1", "v2"), new BasicHeader("h2", "v2")));
+        MatcherAssert.assertThat(builder.getHeaders("h1"), HeadersMatcher.same(
+                new BasicHeader("h1", "v1"), new BasicHeader("h1", "v2")));
+        MatcherAssert.assertThat(builder.getFirstHeader("h1"), HeaderMatcher.same("h1", "v1"));
+        MatcherAssert.assertThat(builder.getLastHeader("h1"), HeaderMatcher.same("h1", "v2"));
+
+        final BasicHttpRequest r4 = builder.build();
+        MatcherAssert.assertThat(r4.getHeaders(), HeadersMatcher.same(
+                new BasicHeader("h1", "v1"), new BasicHeader("h1", "v2"), new BasicHeader("h2", "v2")));
+        MatcherAssert.assertThat(r4.getHeaders("h1"), HeadersMatcher.same(
+                new BasicHeader("h1", "v1"), new BasicHeader("h1", "v2")));
+        MatcherAssert.assertThat(r4.getFirstHeader("h1"), HeaderMatcher.same("h1", "v1"));
+        MatcherAssert.assertThat(r4.getLastHeader("h1"), HeaderMatcher.same("h1", "v2"));
+
+        builder.removeHeader(new BasicHeader("h1", "v2"));
+        MatcherAssert.assertThat(builder.getHeaders("h1"), HeadersMatcher.same(new BasicHeader("h1", "v1")));
+        MatcherAssert.assertThat(builder.getHeaders(), HeadersMatcher.same(
+                new BasicHeader("h1", "v1"), new BasicHeader("h2", "v2")));
+
+        final BasicHttpRequest r5 = builder.build();
+        MatcherAssert.assertThat(r5.getHeaders("h1"), HeadersMatcher.same(new BasicHeader("h1", "v1")));
+        MatcherAssert.assertThat(r5.getHeaders(), HeadersMatcher.same(
+                new BasicHeader("h1", "v1"), new BasicHeader("h2", "v2")));
+
+        builder.removeHeaders("h1");
+        MatcherAssert.assertThat(builder.getHeaders("h1"), HeadersMatcher.same());
+        MatcherAssert.assertThat(builder.getHeaders(), HeadersMatcher.same(new BasicHeader("h2", "v2")));
+
+        final BasicHttpRequest r6 = builder.build();
+        MatcherAssert.assertThat(r6.getHeaders("h1"), HeadersMatcher.same());
+        MatcherAssert.assertThat(r6.getHeaders(), HeadersMatcher.same(new BasicHeader("h2", "v2")));
+    }
+
+}


[httpcomponents-core] 01/02: Removed references to deprecated Assert#assertThat

Posted by ol...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

olegk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/httpcomponents-core.git

commit 35873412ba799f78c953898e93e02e512d1a5437
Author: Oleg Kalnichevski <ol...@apache.org>
AuthorDate: Tue Feb 9 17:53:04 2021 +0100

    Removed references to deprecated Assert#assertThat
---
 .../hc/core5/http2/hpack/TestHPackCoding.java      | 17 ++---
 .../hc/core5/benchmark/ResultFormatterTest.java    | 12 ++--
 .../testing/classic/ClassicAuthenticationTest.java | 36 +++++-----
 .../classic/ClassicServerAndRequesterTest.java     | 34 ++++-----
 .../testing/classic/ClassicTLSIntegrationTest.java | 24 +++----
 .../testing/framework/TestTestingFramework.java    | 35 ++++-----
 .../apache/hc/core5/testing/nio/H2AlpnTest.java    | 26 +++----
 .../hc/core5/testing/nio/H2IntegrationTest.java    | 71 +++++++++---------
 .../testing/nio/H2ProtocolNegotiationTest.java     | 32 ++++-----
 .../nio/H2ServerAndMultiplexingRequesterTest.java  | 64 ++++++++---------
 .../testing/nio/H2ServerAndRequesterTest.java      | 58 +++++++--------
 .../hc/core5/testing/nio/H2TLSIntegrationTest.java | 40 +++++------
 .../core5/testing/nio/Http1AuthenticationTest.java | 52 +++++++-------
 .../testing/nio/Http1ServerAndRequesterTest.java   | 84 +++++++++++-----------
 .../core5/concurrent/TestComplexCancellable.java   |  7 +-
 .../hc/core5/concurrent/TestComplexFuture.java     | 23 +++---
 .../core5/http/config/TestNamedElementChain.java   | 80 ++++++++++-----------
 .../core5/http/impl/nio/TestExpandableBuffer.java  | 42 +++++------
 .../hc/core5/http/ssl/TestTlsVersionParser.java    | 16 ++---
 .../core5/reactor/TestAbstractIOSessionPool.java   | 68 +++++++++---------
 .../org/apache/hc/core5/util/TestTimeValue.java    | 47 ++++++------
 21 files changed, 437 insertions(+), 431 deletions(-)

diff --git a/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/hpack/TestHPackCoding.java b/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/hpack/TestHPackCoding.java
index 8e71d5f..d296f85 100644
--- a/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/hpack/TestHPackCoding.java
+++ b/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/hpack/TestHPackCoding.java
@@ -27,19 +27,20 @@
 
 package org.apache.hc.core5.http2.hpack;
 
-import java.nio.ByteBuffer;
-import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
-import java.util.Arrays;
-import java.util.List;
-
 import org.apache.hc.core5.http.Header;
 import org.apache.hc.core5.http.message.BasicHeader;
 import org.apache.hc.core5.util.ByteArrayBuffer;
 import org.hamcrest.CoreMatchers;
+import org.hamcrest.MatcherAssert;
 import org.junit.Assert;
 import org.junit.Test;
 
+import java.nio.ByteBuffer;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
+import java.util.List;
+
 public class TestHPackCoding {
 
     @Test
@@ -1053,10 +1054,10 @@ public class TestHPackCoding {
                                 "123456789012345678901234567890123456789012345678901234567890")),
                 false);
 
-        Assert.assertThat(decoder.decodeHeaders(wrap(buf)).size(), CoreMatchers.equalTo(2));
+        MatcherAssert.assertThat(decoder.decodeHeaders(wrap(buf)).size(), CoreMatchers.equalTo(2));
 
         decoder.setMaxListSize(1000000);
-        Assert.assertThat(decoder.decodeHeaders(wrap(buf)).size(), CoreMatchers.equalTo(2));
+        MatcherAssert.assertThat(decoder.decodeHeaders(wrap(buf)).size(), CoreMatchers.equalTo(2));
 
         decoder.setMaxListSize(200);
         decoder.decodeHeaders(wrap(buf));
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/benchmark/ResultFormatterTest.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/benchmark/ResultFormatterTest.java
index 023f81b..bde0796 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/benchmark/ResultFormatterTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/benchmark/ResultFormatterTest.java
@@ -26,15 +26,15 @@
  */
 package org.apache.hc.core5.benchmark;
 
-import java.io.ByteArrayOutputStream;
-import java.io.PrintStream;
-import java.nio.charset.StandardCharsets;
-
 import org.apache.hc.core5.http.HttpVersion;
 import org.hamcrest.CoreMatchers;
-import org.junit.Assert;
+import org.hamcrest.MatcherAssert;
 import org.junit.Test;
 
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+import java.nio.charset.StandardCharsets;
+
 public class ResultFormatterTest {
 
     @Test
@@ -56,7 +56,7 @@ public class ResultFormatterTest {
                 50000000);
         final ByteArrayOutputStream buf = new ByteArrayOutputStream();
         ResultFormatter.print(new PrintStream(buf, true, StandardCharsets.US_ASCII.name()), results);
-        Assert.assertThat(new String(buf.toByteArray(), StandardCharsets.US_ASCII).replace("\r\n", "\n"),
+        MatcherAssert.assertThat(new String(buf.toByteArray(), StandardCharsets.US_ASCII).replace("\r\n", "\n"),
                 CoreMatchers.equalTo(
                 "Server Software:\t\tTestServer/1.1\n" +
                         "Protocol version:\t\tHTTP/1.1\n" +
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/classic/ClassicAuthenticationTest.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/classic/ClassicAuthenticationTest.java
index c14254d..707f4c7 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/classic/ClassicAuthenticationTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/classic/ClassicAuthenticationTest.java
@@ -27,11 +27,6 @@
 
 package org.apache.hc.core5.testing.classic;
 
-import java.nio.charset.StandardCharsets;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Random;
-
 import org.apache.hc.core5.http.ClassicHttpRequest;
 import org.apache.hc.core5.http.ClassicHttpResponse;
 import org.apache.hc.core5.http.ContentType;
@@ -60,7 +55,7 @@ import org.apache.hc.core5.io.CloseMode;
 import org.apache.hc.core5.net.URIAuthority;
 import org.apache.hc.core5.util.Timeout;
 import org.hamcrest.CoreMatchers;
-import org.junit.Assert;
+import org.hamcrest.MatcherAssert;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExternalResource;
@@ -69,6 +64,11 @@ import org.junit.runners.Parameterized;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Random;
+
 @RunWith(Parameterized.class)
 public class ClassicAuthenticationTest {
 
@@ -193,16 +193,16 @@ public class ClassicAuthenticationTest {
         final HttpCoreContext context = HttpCoreContext.create();
         final ClassicHttpRequest request1 = new BasicClassicHttpRequest(Method.GET, "/stuff");
         try (final ClassicHttpResponse response1 = requester.execute(target, request1, TIMEOUT, context)) {
-            Assert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_UNAUTHORIZED));
+            MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_UNAUTHORIZED));
             final String body1 = EntityUtils.toString(response1.getEntity());
-            Assert.assertThat(body1, CoreMatchers.equalTo("You shall not pass!!!"));
+            MatcherAssert.assertThat(body1, CoreMatchers.equalTo("You shall not pass!!!"));
         }
         final ClassicHttpRequest request2 = new BasicClassicHttpRequest(Method.GET, "/stuff");
         request2.setHeader(HttpHeaders.AUTHORIZATION, "let me pass");
         try (final ClassicHttpResponse response2 = requester.execute(target, request2, TIMEOUT, context)) {
-            Assert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+            MatcherAssert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
             final String body1 = EntityUtils.toString(response2.getEntity());
-            Assert.assertThat(body1, CoreMatchers.equalTo(""));
+            MatcherAssert.assertThat(body1, CoreMatchers.equalTo(""));
         }
     }
 
@@ -219,17 +219,17 @@ public class ClassicAuthenticationTest {
         final ClassicHttpRequest request1 = new BasicClassicHttpRequest(Method.POST, "/stuff");
         request1.setEntity(new ByteArrayEntity(stuff, ContentType.TEXT_PLAIN));
         try (final ClassicHttpResponse response1 = requester.execute(target, request1, TIMEOUT, context)) {
-            Assert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_UNAUTHORIZED));
+            MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_UNAUTHORIZED));
             final String body1 = EntityUtils.toString(response1.getEntity());
-            Assert.assertThat(body1, CoreMatchers.equalTo("You shall not pass!!!"));
+            MatcherAssert.assertThat(body1, CoreMatchers.equalTo("You shall not pass!!!"));
         }
         final ClassicHttpRequest request2 = new BasicClassicHttpRequest(Method.POST, "/stuff");
         request2.setHeader(HttpHeaders.AUTHORIZATION, "let me pass");
         request2.setEntity(new ByteArrayEntity(stuff, ContentType.TEXT_PLAIN));
         try (final ClassicHttpResponse response2 = requester.execute(target, request2, TIMEOUT, context)) {
-            Assert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+            MatcherAssert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
             final String body1 = EntityUtils.toString(response2.getEntity());
-            Assert.assertThat(body1, CoreMatchers.equalTo(new String(stuff, StandardCharsets.US_ASCII)));
+            MatcherAssert.assertThat(body1, CoreMatchers.equalTo(new String(stuff, StandardCharsets.US_ASCII)));
         }
     }
 
@@ -247,18 +247,18 @@ public class ClassicAuthenticationTest {
         request1.setVersion(HttpVersion.HTTP_1_0);
         request1.setEntity(new ByteArrayEntity(stuff, ContentType.TEXT_PLAIN));
         try (final ClassicHttpResponse response1 = requester.execute(target, request1, TIMEOUT, context)) {
-            Assert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_UNAUTHORIZED));
+            MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_UNAUTHORIZED));
             final String body1 = EntityUtils.toString(response1.getEntity());
-            Assert.assertThat(body1, CoreMatchers.equalTo("You shall not pass!!!"));
+            MatcherAssert.assertThat(body1, CoreMatchers.equalTo("You shall not pass!!!"));
         }
         final ClassicHttpRequest request2 = new BasicClassicHttpRequest(Method.POST, "/stuff");
         request2.setHeader(HttpHeaders.AUTHORIZATION, "let me pass");
         request2.setVersion(HttpVersion.HTTP_1_0);
         request2.setEntity(new ByteArrayEntity(stuff, ContentType.TEXT_PLAIN));
         try (final ClassicHttpResponse response2 = requester.execute(target, request2, TIMEOUT, context)) {
-            Assert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+            MatcherAssert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
             final String body1 = EntityUtils.toString(response2.getEntity());
-            Assert.assertThat(body1, CoreMatchers.equalTo(new String(stuff, StandardCharsets.US_ASCII)));
+            MatcherAssert.assertThat(body1, CoreMatchers.equalTo(new String(stuff, StandardCharsets.US_ASCII)));
         }
     }
 
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/classic/ClassicServerAndRequesterTest.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/classic/ClassicServerAndRequesterTest.java
index 462cd8d..77b1f2b 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/classic/ClassicServerAndRequesterTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/classic/ClassicServerAndRequesterTest.java
@@ -27,10 +27,6 @@
 
 package org.apache.hc.core5.testing.classic;
 
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.Collection;
-
 import org.apache.hc.core5.http.ClassicHttpRequest;
 import org.apache.hc.core5.http.ClassicHttpResponse;
 import org.apache.hc.core5.http.ContentType;
@@ -58,7 +54,7 @@ import org.apache.hc.core5.io.CloseMode;
 import org.apache.hc.core5.testing.SSLTestContexts;
 import org.apache.hc.core5.util.Timeout;
 import org.hamcrest.CoreMatchers;
-import org.junit.Assert;
+import org.hamcrest.MatcherAssert;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExternalResource;
@@ -67,6 +63,10 @@ import org.junit.runners.Parameterized;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collection;
+
 @RunWith(Parameterized.class)
 public class ClassicServerAndRequesterTest {
 
@@ -189,23 +189,23 @@ public class ClassicServerAndRequesterTest {
         final ClassicHttpRequest request1 = new BasicClassicHttpRequest(Method.POST, "/stuff");
         request1.setEntity(new StringEntity("some stuff", ContentType.TEXT_PLAIN));
         try (final ClassicHttpResponse response1 = requester.execute(target, request1, TIMEOUT, context)) {
-            Assert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+            MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
             final String body1 = EntityUtils.toString(response1.getEntity());
-            Assert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
+            MatcherAssert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
         }
         final ClassicHttpRequest request2 = new BasicClassicHttpRequest(Method.POST, "/other-stuff");
         request2.setEntity(new StringEntity("some other stuff", ContentType.TEXT_PLAIN));
         try (final ClassicHttpResponse response2 = requester.execute(target, request2, TIMEOUT, context)) {
-            Assert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+            MatcherAssert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
             final String body2 = EntityUtils.toString(response2.getEntity());
-            Assert.assertThat(body2, CoreMatchers.equalTo("some other stuff"));
+            MatcherAssert.assertThat(body2, CoreMatchers.equalTo("some other stuff"));
         }
         final ClassicHttpRequest request3 = new BasicClassicHttpRequest(Method.POST, "/more-stuff");
         request3.setEntity(new StringEntity("some more stuff", ContentType.TEXT_PLAIN));
         try (final ClassicHttpResponse response3 = requester.execute(target, request3, TIMEOUT, context)) {
-            Assert.assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+            MatcherAssert.assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
             final String body3 = EntityUtils.toString(response3.getEntity());
-            Assert.assertThat(body3, CoreMatchers.equalTo("some more stuff"));
+            MatcherAssert.assertThat(body3, CoreMatchers.equalTo("some more stuff"));
         }
     }
 
@@ -217,23 +217,23 @@ public class ClassicServerAndRequesterTest {
         final ClassicHttpRequest request1 = new BasicClassicHttpRequest(Method.POST, "/no-keep-alive/stuff");
         request1.setEntity(new StringEntity("some stuff", ContentType.TEXT_PLAIN));
         try (final ClassicHttpResponse response1 = requester.execute(target, request1, TIMEOUT, context)) {
-            Assert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+            MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
             final String body1 = EntityUtils.toString(response1.getEntity());
-            Assert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
+            MatcherAssert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
         }
         final ClassicHttpRequest request2 = new BasicClassicHttpRequest(Method.POST, "/no-keep-alive/other-stuff");
         request2.setEntity(new StringEntity("some other stuff", ContentType.TEXT_PLAIN));
         try (final ClassicHttpResponse response2 = requester.execute(target, request2, TIMEOUT, context)) {
-            Assert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+            MatcherAssert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
             final String body2 = EntityUtils.toString(response2.getEntity());
-            Assert.assertThat(body2, CoreMatchers.equalTo("some other stuff"));
+            MatcherAssert.assertThat(body2, CoreMatchers.equalTo("some other stuff"));
         }
         final ClassicHttpRequest request3 = new BasicClassicHttpRequest(Method.POST, "/no-keep-alive/more-stuff");
         request3.setEntity(new StringEntity("some more stuff", ContentType.TEXT_PLAIN));
         try (final ClassicHttpResponse response3 = requester.execute(target, request3, TIMEOUT, context)) {
-            Assert.assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+            MatcherAssert.assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
             final String body3 = EntityUtils.toString(response3.getEntity());
-            Assert.assertThat(body3, CoreMatchers.equalTo("some more stuff"));
+            MatcherAssert.assertThat(body3, CoreMatchers.equalTo("some more stuff"));
         }
     }
 
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/classic/ClassicTLSIntegrationTest.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/classic/ClassicTLSIntegrationTest.java
index bd344b0..df95f32 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/classic/ClassicTLSIntegrationTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/classic/ClassicTLSIntegrationTest.java
@@ -27,14 +27,6 @@
 
 package org.apache.hc.core5.testing.classic;
 
-import java.io.IOException;
-import java.util.concurrent.atomic.AtomicReference;
-
-import javax.net.ssl.SSLException;
-import javax.net.ssl.SSLHandshakeException;
-import javax.net.ssl.SSLParameters;
-import javax.net.ssl.SSLSession;
-
 import org.apache.hc.core5.function.Callback;
 import org.apache.hc.core5.http.ClassicHttpRequest;
 import org.apache.hc.core5.http.ClassicHttpResponse;
@@ -60,11 +52,19 @@ import org.apache.hc.core5.ssl.SSLContexts;
 import org.apache.hc.core5.testing.SSLTestContexts;
 import org.apache.hc.core5.util.Timeout;
 import org.hamcrest.CoreMatchers;
+import org.hamcrest.MatcherAssert;
 import org.junit.Assert;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExternalResource;
 
+import javax.net.ssl.SSLException;
+import javax.net.ssl.SSLHandshakeException;
+import javax.net.ssl.SSLParameters;
+import javax.net.ssl.SSLSession;
+import java.io.IOException;
+import java.util.concurrent.atomic.AtomicReference;
+
 public class ClassicTLSIntegrationTest {
 
     private static final Timeout TIMEOUT = Timeout.ofSeconds(30);
@@ -140,15 +140,15 @@ public class ClassicTLSIntegrationTest {
         final ClassicHttpRequest request1 = new BasicClassicHttpRequest(Method.POST, "/stuff");
         request1.setEntity(new StringEntity("some stuff", ContentType.TEXT_PLAIN));
         try (final ClassicHttpResponse response1 = requester.execute(target, request1, TIMEOUT, context)) {
-            Assert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+            MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
             final String body1 = EntityUtils.toString(response1.getEntity());
-            Assert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
+            MatcherAssert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
         }
 
         final SSLSession sslSession = sslSessionRef.getAndSet(null);
         final ProtocolVersion tlsVersion = TLS.parse(sslSession.getProtocol());
-        Assert.assertThat(tlsVersion.greaterEquals(TLS.V_1_2.version), CoreMatchers.equalTo(true));
-        Assert.assertThat(sslSession.getPeerPrincipal().getName(),
+        MatcherAssert.assertThat(tlsVersion.greaterEquals(TLS.V_1_2.version), CoreMatchers.equalTo(true));
+        MatcherAssert.assertThat(sslSession.getPeerPrincipal().getName(),
                 CoreMatchers.equalTo("CN=localhost,OU=Apache HttpComponents,O=Apache Software Foundation"));
     }
 
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestTestingFramework.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestTestingFramework.java
index c9b7980..5877106 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestTestingFramework.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestTestingFramework.java
@@ -27,6 +27,23 @@
 
 package org.apache.hc.core5.testing.framework;
 
+import org.apache.hc.core5.http.ContentType;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.ProtocolVersion;
+import org.hamcrest.BaseMatcher;
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+import org.hamcrest.MatcherAssert;
+import org.junit.Assert;
+import org.junit.Test;
+import org.mockito.ArgumentMatchers;
+import org.mockito.Mockito;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
 import static org.apache.hc.core5.testing.framework.ClientPOJOAdapter.BODY;
 import static org.apache.hc.core5.testing.framework.ClientPOJOAdapter.CONTENT_TYPE;
 import static org.apache.hc.core5.testing.framework.ClientPOJOAdapter.HEADERS;
@@ -39,22 +56,6 @@ import static org.apache.hc.core5.testing.framework.ClientPOJOAdapter.REQUEST;
 import static org.apache.hc.core5.testing.framework.ClientPOJOAdapter.RESPONSE;
 import static org.apache.hc.core5.testing.framework.ClientPOJOAdapter.STATUS;
 
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.hc.core5.http.ContentType;
-import org.apache.hc.core5.http.HttpVersion;
-import org.apache.hc.core5.http.ProtocolVersion;
-import org.hamcrest.BaseMatcher;
-import org.hamcrest.Description;
-import org.hamcrest.Matcher;
-import org.junit.Assert;
-import org.junit.Test;
-import org.mockito.ArgumentMatchers;
-import org.mockito.Mockito;
-
 public class TestTestingFramework {
 
     @Test
@@ -179,7 +180,7 @@ public class TestTestingFramework {
                                    final Map<String, Object> request,
                                    final TestingFrameworkRequestHandler requestHandler,
                                    final Map<String, Object> responseExpectations) throws TestingFrameworkException {
-                Assert.assertThat(defaultURI, matchesDefaultURI());
+                MatcherAssert.assertThat(defaultURI, matchesDefaultURI());
 
                 Assert.assertNotNull("request should not be null", request);
 
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2AlpnTest.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2AlpnTest.java
index 76e8d9a..dbb91fe 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2AlpnTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2AlpnTest.java
@@ -27,15 +27,6 @@
 
 package org.apache.hc.core5.testing.nio;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.net.InetSocketAddress;
-import java.util.Arrays;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-
 import org.apache.hc.core5.function.Supplier;
 import org.apache.hc.core5.http.ContentType;
 import org.apache.hc.core5.http.HttpHost;
@@ -65,7 +56,7 @@ import org.apache.hc.core5.testing.SSLTestContexts;
 import org.apache.hc.core5.util.ReflectionUtils;
 import org.apache.hc.core5.util.Timeout;
 import org.hamcrest.CoreMatchers;
-import org.junit.Assert;
+import org.hamcrest.MatcherAssert;
 import org.junit.Assume;
 import org.junit.BeforeClass;
 import org.junit.Rule;
@@ -77,6 +68,15 @@ import org.junit.runners.Parameterized.Parameters;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.net.InetSocketAddress;
+import java.util.Arrays;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
 @RunWith(Parameterized.class)
 public class H2AlpnTest {
     private final Logger log = LoggerFactory.getLogger(getClass());
@@ -204,10 +204,10 @@ public class H2AlpnTest {
         }
 
         assertTrue("h2 negotiation was disabled, but h2 was negotiated", h2Allowed);
-        Assert.assertThat(message1, CoreMatchers.notNullValue());
+        MatcherAssert.assertThat(message1, CoreMatchers.notNullValue());
         final HttpResponse response1 = message1.getHead();
-        Assert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+        MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
         final String body1 = message1.getBody();
-        Assert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
+        MatcherAssert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
     }
 }
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2IntegrationTest.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2IntegrationTest.java
index 35b1a66..e8785ba 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2IntegrationTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2IntegrationTest.java
@@ -27,39 +27,6 @@
 
 package org.apache.hc.core5.testing.nio;
 
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.InterruptedIOException;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.net.InetSocketAddress;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.nio.ByteBuffer;
-import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Queue;
-import java.util.StringTokenizer;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.concurrent.LinkedBlockingDeque;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicReference;
-
 import org.apache.hc.core5.function.Callback;
 import org.apache.hc.core5.function.Decorator;
 import org.apache.hc.core5.function.Supplier;
@@ -125,6 +92,7 @@ import org.apache.hc.core5.util.TextUtils;
 import org.apache.hc.core5.util.TimeValue;
 import org.apache.hc.core5.util.Timeout;
 import org.hamcrest.CoreMatchers;
+import org.hamcrest.MatcherAssert;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
@@ -134,6 +102,39 @@ import org.junit.runners.Parameterized;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.InterruptedIOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.net.InetSocketAddress;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.nio.ByteBuffer;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Queue;
+import java.util.StringTokenizer;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.LinkedBlockingDeque;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReference;
+
 @RunWith(Parameterized.class)
 public class H2IntegrationTest extends InternalH2ServerTestBase {
 
@@ -1048,11 +1049,11 @@ public class H2IntegrationTest extends InternalH2ServerTestBase {
             future.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
             Assert.fail("ExecutionException is expected");
         } catch (final ExecutionException ex) {
-            Assert.assertThat(ex.getCause(), CoreMatchers.instanceOf(ProtocolException.class));
+            MatcherAssert.assertThat(ex.getCause(), CoreMatchers.instanceOf(ProtocolException.class));
         }
 
         final EndpointDetails endpointDetails = coreContext.getEndpointDetails();
-        Assert.assertThat(endpointDetails.getRequestCount(), CoreMatchers.equalTo(0L));
+        MatcherAssert.assertThat(endpointDetails.getRequestCount(), CoreMatchers.equalTo(0L));
     }
 
     @Test
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2ProtocolNegotiationTest.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2ProtocolNegotiationTest.java
index b77d390..21d82bd 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2ProtocolNegotiationTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2ProtocolNegotiationTest.java
@@ -27,11 +27,6 @@
 
 package org.apache.hc.core5.testing.nio;
 
-import java.net.InetSocketAddress;
-import java.util.concurrent.Future;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
 import org.apache.hc.core5.function.Supplier;
 import org.apache.hc.core5.http.ContentType;
 import org.apache.hc.core5.http.HttpHost;
@@ -63,7 +58,7 @@ import org.apache.hc.core5.testing.classic.LoggingConnPoolListener;
 import org.apache.hc.core5.util.ReflectionUtils;
 import org.apache.hc.core5.util.Timeout;
 import org.hamcrest.CoreMatchers;
-import org.junit.Assert;
+import org.hamcrest.MatcherAssert;
 import org.junit.Assume;
 import org.junit.Before;
 import org.junit.BeforeClass;
@@ -73,6 +68,11 @@ import org.junit.rules.ExternalResource;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.net.InetSocketAddress;
+import java.util.concurrent.Future;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
 public class H2ProtocolNegotiationTest {
 
     private static final Timeout TIMEOUT = Timeout.ofSeconds(30);
@@ -184,10 +184,10 @@ public class H2ProtocolNegotiationTest {
                         new StringAsyncEntityProducer("some stuff", ContentType.TEXT_PLAIN)),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
         final Message<HttpResponse, String> message1 = resultFuture1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
-        Assert.assertThat(message1, CoreMatchers.notNullValue());
+        MatcherAssert.assertThat(message1, CoreMatchers.notNullValue());
         final HttpResponse response1 = message1.getHead();
-        Assert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
-        Assert.assertThat(response1.getVersion(), CoreMatchers.<ProtocolVersion>equalTo(HttpVersion.HTTP_1_1));
+        MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+        MatcherAssert.assertThat(response1.getVersion(), CoreMatchers.<ProtocolVersion>equalTo(HttpVersion.HTTP_1_1));
     }
 
     @Test
@@ -207,10 +207,10 @@ public class H2ProtocolNegotiationTest {
                         new StringAsyncEntityProducer("some stuff", ContentType.TEXT_PLAIN)),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
         final Message<HttpResponse, String> message1 = resultFuture1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
-        Assert.assertThat(message1, CoreMatchers.notNullValue());
+        MatcherAssert.assertThat(message1, CoreMatchers.notNullValue());
         final HttpResponse response1 = message1.getHead();
-        Assert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
-        Assert.assertThat(response1.getVersion(), CoreMatchers.<ProtocolVersion>equalTo(HttpVersion.HTTP_2));
+        MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+        MatcherAssert.assertThat(response1.getVersion(), CoreMatchers.<ProtocolVersion>equalTo(HttpVersion.HTTP_2));
     }
 
     @Test
@@ -230,14 +230,14 @@ public class H2ProtocolNegotiationTest {
                         new StringAsyncEntityProducer("some stuff", ContentType.TEXT_PLAIN)),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
         final Message<HttpResponse, String> message1 = resultFuture1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
-        Assert.assertThat(message1, CoreMatchers.notNullValue());
+        MatcherAssert.assertThat(message1, CoreMatchers.notNullValue());
         final HttpResponse response1 = message1.getHead();
-        Assert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+        MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
 
         if (isAlpnSupported()) {
-            Assert.assertThat(response1.getVersion(), CoreMatchers.<ProtocolVersion>equalTo(HttpVersion.HTTP_2));
+            MatcherAssert.assertThat(response1.getVersion(), CoreMatchers.<ProtocolVersion>equalTo(HttpVersion.HTTP_2));
         } else {
-            Assert.assertThat(response1.getVersion(), CoreMatchers.<ProtocolVersion>equalTo(HttpVersion.HTTP_1_1));
+            MatcherAssert.assertThat(response1.getVersion(), CoreMatchers.<ProtocolVersion>equalTo(HttpVersion.HTTP_1_1));
         }
     }
 
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2ServerAndMultiplexingRequesterTest.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2ServerAndMultiplexingRequesterTest.java
index 6a60017..e7c0504 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2ServerAndMultiplexingRequesterTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2ServerAndMultiplexingRequesterTest.java
@@ -27,15 +27,6 @@
 
 package org.apache.hc.core5.testing.nio;
 
-import java.net.InetSocketAddress;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.Queue;
-import java.util.Random;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.Future;
-
 import org.apache.hc.core5.concurrent.Cancellable;
 import org.apache.hc.core5.concurrent.FutureCallback;
 import org.apache.hc.core5.function.Supplier;
@@ -67,7 +58,7 @@ import org.apache.hc.core5.util.ReflectionUtils;
 import org.apache.hc.core5.util.TimeValue;
 import org.apache.hc.core5.util.Timeout;
 import org.hamcrest.CoreMatchers;
-import org.junit.Assert;
+import org.hamcrest.MatcherAssert;
 import org.junit.Assume;
 import org.junit.Before;
 import org.junit.BeforeClass;
@@ -79,6 +70,15 @@ import org.junit.runners.Parameterized;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.net.InetSocketAddress;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.Queue;
+import java.util.Random;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.Future;
+
 @RunWith(Parameterized.class)
 public class H2ServerAndMultiplexingRequesterTest {
 
@@ -197,33 +197,33 @@ public class H2ServerAndMultiplexingRequesterTest {
                         new StringAsyncEntityProducer("some stuff", ContentType.TEXT_PLAIN)),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
         final Message<HttpResponse, String> message1 = resultFuture1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
-        Assert.assertThat(message1, CoreMatchers.notNullValue());
+        MatcherAssert.assertThat(message1, CoreMatchers.notNullValue());
         final HttpResponse response1 = message1.getHead();
-        Assert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+        MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
         final String body1 = message1.getBody();
-        Assert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
+        MatcherAssert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
 
         final Future<Message<HttpResponse, String>> resultFuture2 = requester.execute(
                 new BasicRequestProducer(Method.POST, target, "/other-stuff",
                         new StringAsyncEntityProducer("some other stuff", ContentType.TEXT_PLAIN)),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
         final Message<HttpResponse, String> message2 = resultFuture2.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
-        Assert.assertThat(message2, CoreMatchers.notNullValue());
+        MatcherAssert.assertThat(message2, CoreMatchers.notNullValue());
         final HttpResponse response2 = message2.getHead();
-        Assert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+        MatcherAssert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
         final String body2 = message2.getBody();
-        Assert.assertThat(body2, CoreMatchers.equalTo("some other stuff"));
+        MatcherAssert.assertThat(body2, CoreMatchers.equalTo("some other stuff"));
 
         final Future<Message<HttpResponse, String>> resultFuture3 = requester.execute(
                 new BasicRequestProducer(Method.POST, target, "/more-stuff",
                         new StringAsyncEntityProducer("some more stuff", ContentType.TEXT_PLAIN)),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
         final Message<HttpResponse, String> message3 = resultFuture3.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
-        Assert.assertThat(message3, CoreMatchers.notNullValue());
+        MatcherAssert.assertThat(message3, CoreMatchers.notNullValue());
         final HttpResponse response3 = message3.getHead();
-        Assert.assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+        MatcherAssert.assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
         final String body3 = message3.getBody();
-        Assert.assertThat(body3, CoreMatchers.equalTo("some more stuff"));
+        MatcherAssert.assertThat(body3, CoreMatchers.equalTo("some more stuff"));
     }
 
     @Test
@@ -253,11 +253,11 @@ public class H2ServerAndMultiplexingRequesterTest {
         while (!queue.isEmpty()) {
             final Future<Message<HttpResponse, String>> resultFuture = queue.remove();
             final Message<HttpResponse, String> message = resultFuture.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
-            Assert.assertThat(message, CoreMatchers.notNullValue());
+            MatcherAssert.assertThat(message, CoreMatchers.notNullValue());
             final HttpResponse response = message.getHead();
-            Assert.assertThat(response.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+            MatcherAssert.assertThat(response.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
             final String body = message.getBody();
-            Assert.assertThat(body, CoreMatchers.containsString("stuff"));
+            MatcherAssert.assertThat(body, CoreMatchers.containsString("stuff"));
         }
     }
 
@@ -276,11 +276,11 @@ public class H2ServerAndMultiplexingRequesterTest {
                         new StringAsyncEntityProducer("some stuff", ContentType.TEXT_PLAIN)),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
         final Message<HttpResponse, String> message1 = resultFuture1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
-        Assert.assertThat(message1, CoreMatchers.notNullValue());
+        MatcherAssert.assertThat(message1, CoreMatchers.notNullValue());
         final HttpResponse response1 = message1.getHead();
-        Assert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+        MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
         final String body1 = message1.getBody();
-        Assert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
+        MatcherAssert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
 
         Thread.sleep(100);
 
@@ -289,11 +289,11 @@ public class H2ServerAndMultiplexingRequesterTest {
                         new StringAsyncEntityProducer("some other stuff", ContentType.TEXT_PLAIN)),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
         final Message<HttpResponse, String> message2 = resultFuture2.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
-        Assert.assertThat(message2, CoreMatchers.notNullValue());
+        MatcherAssert.assertThat(message2, CoreMatchers.notNullValue());
         final HttpResponse response2 = message2.getHead();
-        Assert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+        MatcherAssert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
         final String body2 = message2.getBody();
-        Assert.assertThat(body2, CoreMatchers.equalTo("some other stuff"));
+        MatcherAssert.assertThat(body2, CoreMatchers.equalTo("some other stuff"));
 
         Thread.sleep(100);
 
@@ -302,11 +302,11 @@ public class H2ServerAndMultiplexingRequesterTest {
                         new StringAsyncEntityProducer("some more stuff", ContentType.TEXT_PLAIN)),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
         final Message<HttpResponse, String> message3 = resultFuture3.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
-        Assert.assertThat(message3, CoreMatchers.notNullValue());
+        MatcherAssert.assertThat(message3, CoreMatchers.notNullValue());
         final HttpResponse response3 = message3.getHead();
-        Assert.assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+        MatcherAssert.assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
         final String body3 = message3.getBody();
-        Assert.assertThat(body3, CoreMatchers.equalTo("some more stuff"));
+        MatcherAssert.assertThat(body3, CoreMatchers.equalTo("some more stuff"));
     }
 
     @Test
@@ -350,7 +350,7 @@ public class H2ServerAndMultiplexingRequesterTest {
             Thread.sleep(random.nextInt(10));
             cancellable.cancel();
         }
-        Assert.assertThat(countDownLatch.await(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit()), CoreMatchers.equalTo(true));
+        MatcherAssert.assertThat(countDownLatch.await(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit()), CoreMatchers.equalTo(true));
     }
 
 }
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2ServerAndRequesterTest.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2ServerAndRequesterTest.java
index fc8a0d0..931f1a7 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2ServerAndRequesterTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2ServerAndRequesterTest.java
@@ -27,13 +27,6 @@
 
 package org.apache.hc.core5.testing.nio;
 
-import java.net.InetSocketAddress;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.Queue;
-import java.util.concurrent.Future;
-
 import org.apache.hc.core5.function.Supplier;
 import org.apache.hc.core5.http.ContentType;
 import org.apache.hc.core5.http.HttpHost;
@@ -64,7 +57,7 @@ import org.apache.hc.core5.testing.classic.LoggingConnPoolListener;
 import org.apache.hc.core5.util.ReflectionUtils;
 import org.apache.hc.core5.util.Timeout;
 import org.hamcrest.CoreMatchers;
-import org.junit.Assert;
+import org.hamcrest.MatcherAssert;
 import org.junit.Assume;
 import org.junit.Before;
 import org.junit.BeforeClass;
@@ -76,6 +69,13 @@ import org.junit.runners.Parameterized;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.net.InetSocketAddress;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.Queue;
+import java.util.concurrent.Future;
+
 @RunWith(Parameterized.class)
 public class H2ServerAndRequesterTest {
 
@@ -200,33 +200,33 @@ public class H2ServerAndRequesterTest {
                         new StringAsyncEntityProducer("some stuff", ContentType.TEXT_PLAIN)),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
         final Message<HttpResponse, String> message1 = resultFuture1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
-        Assert.assertThat(message1, CoreMatchers.notNullValue());
+        MatcherAssert.assertThat(message1, CoreMatchers.notNullValue());
         final HttpResponse response1 = message1.getHead();
-        Assert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+        MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
         final String body1 = message1.getBody();
-        Assert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
+        MatcherAssert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
 
         final Future<Message<HttpResponse, String>> resultFuture2 = requester.execute(
                 new BasicRequestProducer(Method.POST, target, "/other-stuff",
                         new StringAsyncEntityProducer("some other stuff", ContentType.TEXT_PLAIN)),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
         final Message<HttpResponse, String> message2 = resultFuture2.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
-        Assert.assertThat(message2, CoreMatchers.notNullValue());
+        MatcherAssert.assertThat(message2, CoreMatchers.notNullValue());
         final HttpResponse response2 = message2.getHead();
-        Assert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+        MatcherAssert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
         final String body2 = message2.getBody();
-        Assert.assertThat(body2, CoreMatchers.equalTo("some other stuff"));
+        MatcherAssert.assertThat(body2, CoreMatchers.equalTo("some other stuff"));
 
         final Future<Message<HttpResponse, String>> resultFuture3 = requester.execute(
                 new BasicRequestProducer(Method.POST, target, "/more-stuff",
                         new StringAsyncEntityProducer("some more stuff", ContentType.TEXT_PLAIN)),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
         final Message<HttpResponse, String> message3 = resultFuture3.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
-        Assert.assertThat(message3, CoreMatchers.notNullValue());
+        MatcherAssert.assertThat(message3, CoreMatchers.notNullValue());
         final HttpResponse response3 = message3.getHead();
-        Assert.assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+        MatcherAssert.assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
         final String body3 = message3.getBody();
-        Assert.assertThat(body3, CoreMatchers.equalTo("some more stuff"));
+        MatcherAssert.assertThat(body3, CoreMatchers.equalTo("some more stuff"));
     }
 
     @Test
@@ -247,33 +247,33 @@ public class H2ServerAndRequesterTest {
                             new StringAsyncEntityProducer("some stuff", ContentType.TEXT_PLAIN)),
                     new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
             final Message<HttpResponse, String> message1 = resultFuture1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
-            Assert.assertThat(message1, CoreMatchers.notNullValue());
+            MatcherAssert.assertThat(message1, CoreMatchers.notNullValue());
             final HttpResponse response1 = message1.getHead();
-            Assert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+            MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
             final String body1 = message1.getBody();
-            Assert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
+            MatcherAssert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
 
             final Future<Message<HttpResponse, String>> resultFuture2 = endpoint.execute(
                     new BasicRequestProducer(Method.POST, target, "/other-stuff",
                             new StringAsyncEntityProducer("some other stuff", ContentType.TEXT_PLAIN)),
                     new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
             final Message<HttpResponse, String> message2 = resultFuture2.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
-            Assert.assertThat(message2, CoreMatchers.notNullValue());
+            MatcherAssert.assertThat(message2, CoreMatchers.notNullValue());
             final HttpResponse response2 = message2.getHead();
-            Assert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+            MatcherAssert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
             final String body2 = message2.getBody();
-            Assert.assertThat(body2, CoreMatchers.equalTo("some other stuff"));
+            MatcherAssert.assertThat(body2, CoreMatchers.equalTo("some other stuff"));
 
             final Future<Message<HttpResponse, String>> resultFuture3 = endpoint.execute(
                     new BasicRequestProducer(Method.POST, target, "/more-stuff",
                             new StringAsyncEntityProducer("some more stuff", ContentType.TEXT_PLAIN)),
                     new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
             final Message<HttpResponse, String> message3 = resultFuture3.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
-            Assert.assertThat(message3, CoreMatchers.notNullValue());
+            MatcherAssert.assertThat(message3, CoreMatchers.notNullValue());
             final HttpResponse response3 = message3.getHead();
-            Assert.assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+            MatcherAssert.assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
             final String body3 = message3.getBody();
-            Assert.assertThat(body3, CoreMatchers.equalTo("some more stuff"));
+            MatcherAssert.assertThat(body3, CoreMatchers.equalTo("some more stuff"));
 
         } finally {
             endpoint.releaseAndReuse();
@@ -311,11 +311,11 @@ public class H2ServerAndRequesterTest {
             while (!queue.isEmpty()) {
                 final Future<Message<HttpResponse, String>> resultFuture = queue.remove();
                 final Message<HttpResponse, String> message = resultFuture.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
-                Assert.assertThat(message, CoreMatchers.notNullValue());
+                MatcherAssert.assertThat(message, CoreMatchers.notNullValue());
                 final HttpResponse response = message.getHead();
-                Assert.assertThat(response.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+                MatcherAssert.assertThat(response.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
                 final String body = message.getBody();
-                Assert.assertThat(body, CoreMatchers.containsString("stuff"));
+                MatcherAssert.assertThat(body, CoreMatchers.containsString("stuff"));
             }
 
         } finally {
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2TLSIntegrationTest.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2TLSIntegrationTest.java
index 0833c57..6c1e09b 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2TLSIntegrationTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2TLSIntegrationTest.java
@@ -27,17 +27,6 @@
 
 package org.apache.hc.core5.testing.nio;
 
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-import java.util.concurrent.atomic.AtomicReference;
-
-import javax.net.ssl.SSLEngine;
-import javax.net.ssl.SSLException;
-import javax.net.ssl.SSLHandshakeException;
-import javax.net.ssl.SSLSession;
-
 import org.apache.hc.core5.function.Supplier;
 import org.apache.hc.core5.http.ContentType;
 import org.apache.hc.core5.http.HttpHost;
@@ -72,11 +61,22 @@ import org.apache.hc.core5.testing.SSLTestContexts;
 import org.apache.hc.core5.testing.classic.LoggingConnPoolListener;
 import org.apache.hc.core5.util.Timeout;
 import org.hamcrest.CoreMatchers;
+import org.hamcrest.MatcherAssert;
 import org.junit.Assert;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExternalResource;
 
+import javax.net.ssl.SSLEngine;
+import javax.net.ssl.SSLException;
+import javax.net.ssl.SSLHandshakeException;
+import javax.net.ssl.SSLSession;
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicReference;
+
 public class H2TLSIntegrationTest {
 
     private static final Timeout TIMEOUT = Timeout.ofSeconds(30);
@@ -176,16 +176,16 @@ public class H2TLSIntegrationTest {
                         new StringAsyncEntityProducer("some stuff", ContentType.TEXT_PLAIN)),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
         final Message<HttpResponse, String> message1 = resultFuture1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
-        Assert.assertThat(message1, CoreMatchers.notNullValue());
+        MatcherAssert.assertThat(message1, CoreMatchers.notNullValue());
         final HttpResponse response1 = message1.getHead();
-        Assert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+        MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
         final String body1 = message1.getBody();
-        Assert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
+        MatcherAssert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
 
         final SSLSession sslSession = sslSessionRef.getAndSet(null);
         final ProtocolVersion tlsVersion = TLS.parse(sslSession.getProtocol());
-        Assert.assertThat(tlsVersion.greaterEquals(TLS.V_1_2.version), CoreMatchers.equalTo(true));
-        Assert.assertThat(sslSession.getPeerPrincipal().getName(),
+        MatcherAssert.assertThat(tlsVersion.greaterEquals(TLS.V_1_2.version), CoreMatchers.equalTo(true));
+        MatcherAssert.assertThat(sslSession.getPeerPrincipal().getName(),
                 CoreMatchers.equalTo("CN=localhost,OU=Apache HttpComponents,O=Apache Software Foundation"));
     }
 
@@ -241,7 +241,7 @@ public class H2TLSIntegrationTest {
             Assert.fail("ExecutionException expected");
         } catch (final ExecutionException ex) {
             final Throwable cause = ex.getCause();
-            Assert.assertThat(cause, CoreMatchers.<Throwable>instanceOf(SSLHandshakeException.class));
+            MatcherAssert.assertThat(cause, CoreMatchers.<Throwable>instanceOf(SSLHandshakeException.class));
         }
     }
 
@@ -306,7 +306,7 @@ public class H2TLSIntegrationTest {
             Assert.fail("ExecutionException expected");
         } catch (final ExecutionException ex) {
             final Throwable cause = ex.getCause();
-            Assert.assertThat(cause, CoreMatchers.<Throwable>instanceOf(IOException.class));
+            MatcherAssert.assertThat(cause, CoreMatchers.<Throwable>instanceOf(IOException.class));
         }
     }
 
@@ -371,7 +371,7 @@ public class H2TLSIntegrationTest {
             Assert.fail("ExecutionException expected");
         } catch (final ExecutionException ex) {
             final Throwable cause = ex.getCause();
-            Assert.assertThat(cause, CoreMatchers.<Throwable>instanceOf(IOException.class));
+            MatcherAssert.assertThat(cause, CoreMatchers.<Throwable>instanceOf(IOException.class));
         }
     }
 
@@ -454,7 +454,7 @@ public class H2TLSIntegrationTest {
                     Assert.fail("ExecutionException expected");
                 } catch (final ExecutionException ex) {
                     final Throwable cause = ex.getCause();
-                    Assert.assertThat(cause, CoreMatchers.<Throwable>instanceOf(IOException.class));
+                    MatcherAssert.assertThat(cause, CoreMatchers.<Throwable>instanceOf(IOException.class));
                 }
             } finally {
                 server.close(CloseMode.IMMEDIATE);
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http1AuthenticationTest.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http1AuthenticationTest.java
index 8d12aa1..859fdbb 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http1AuthenticationTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http1AuthenticationTest.java
@@ -27,13 +27,6 @@
 
 package org.apache.hc.core5.testing.nio;
 
-import java.net.InetSocketAddress;
-import java.nio.charset.StandardCharsets;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Random;
-import java.util.concurrent.Future;
-
 import org.apache.hc.core5.function.Supplier;
 import org.apache.hc.core5.http.ContentType;
 import org.apache.hc.core5.http.HttpException;
@@ -67,7 +60,7 @@ import org.apache.hc.core5.reactor.ListenerEndpoint;
 import org.apache.hc.core5.testing.classic.LoggingConnPoolListener;
 import org.apache.hc.core5.util.Timeout;
 import org.hamcrest.CoreMatchers;
-import org.junit.Assert;
+import org.hamcrest.MatcherAssert;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExternalResource;
@@ -76,6 +69,13 @@ import org.junit.runners.Parameterized;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.net.InetSocketAddress;
+import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Random;
+import java.util.concurrent.Future;
+
 @RunWith(Parameterized.class)
 public class Http1AuthenticationTest {
 
@@ -217,11 +217,11 @@ public class Http1AuthenticationTest {
                 new BasicRequestProducer(request1, null),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
         final Message<HttpResponse, String> message1 = resultFuture1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
-        Assert.assertThat(message1, CoreMatchers.notNullValue());
+        MatcherAssert.assertThat(message1, CoreMatchers.notNullValue());
         final HttpResponse response1 = message1.getHead();
-        Assert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_UNAUTHORIZED));
+        MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_UNAUTHORIZED));
         final String body1 = message1.getBody();
-        Assert.assertThat(body1, CoreMatchers.equalTo("You shall not pass!!!"));
+        MatcherAssert.assertThat(body1, CoreMatchers.equalTo("You shall not pass!!!"));
 
         final HttpRequest request2 = new BasicHttpRequest(Method.GET, target, "/stuff");
         request2.setHeader(HttpHeaders.AUTHORIZATION, "let me pass");
@@ -229,11 +229,11 @@ public class Http1AuthenticationTest {
                 new BasicRequestProducer(request2, null),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
         final Message<HttpResponse, String> message2 = resultFuture2.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
-        Assert.assertThat(message2, CoreMatchers.notNullValue());
+        MatcherAssert.assertThat(message2, CoreMatchers.notNullValue());
         final HttpResponse response2 = message2.getHead();
-        Assert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+        MatcherAssert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
         final String body2 = message2.getBody();
-        Assert.assertThat(body2, CoreMatchers.equalTo(""));
+        MatcherAssert.assertThat(body2, CoreMatchers.equalTo(""));
     }
 
     @Test
@@ -255,11 +255,11 @@ public class Http1AuthenticationTest {
                 new BasicRequestProducer(request1, AsyncEntityProducers.create(stuff, ContentType.TEXT_PLAIN)),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
         final Message<HttpResponse, String> message1 = resultFuture1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
-        Assert.assertThat(message1, CoreMatchers.notNullValue());
+        MatcherAssert.assertThat(message1, CoreMatchers.notNullValue());
         final HttpResponse response1 = message1.getHead();
-        Assert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_UNAUTHORIZED));
+        MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_UNAUTHORIZED));
         final String body1 = message1.getBody();
-        Assert.assertThat(body1, CoreMatchers.equalTo("You shall not pass!!!"));
+        MatcherAssert.assertThat(body1, CoreMatchers.equalTo("You shall not pass!!!"));
 
         final HttpRequest request2 = new BasicHttpRequest(Method.POST, target, "/stuff");
         request2.setHeader(HttpHeaders.AUTHORIZATION, "let me pass");
@@ -267,11 +267,11 @@ public class Http1AuthenticationTest {
                 new BasicRequestProducer(request2, AsyncEntityProducers.create(stuff, ContentType.TEXT_PLAIN)),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
         final Message<HttpResponse, String> message2 = resultFuture2.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
-        Assert.assertThat(message2, CoreMatchers.notNullValue());
+        MatcherAssert.assertThat(message2, CoreMatchers.notNullValue());
         final HttpResponse response2 = message2.getHead();
-        Assert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+        MatcherAssert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
         final String body2 = message2.getBody();
-        Assert.assertThat(body2, CoreMatchers.equalTo(new String(stuff, StandardCharsets.US_ASCII)));
+        MatcherAssert.assertThat(body2, CoreMatchers.equalTo(new String(stuff, StandardCharsets.US_ASCII)));
     }
 
     @Test
@@ -295,11 +295,11 @@ public class Http1AuthenticationTest {
                 new BasicRequestProducer(request1, AsyncEntityProducers.create(stuff, ContentType.TEXT_PLAIN)),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
         final Message<HttpResponse, String> message1 = resultFuture1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
-        Assert.assertThat(message1, CoreMatchers.notNullValue());
+        MatcherAssert.assertThat(message1, CoreMatchers.notNullValue());
         final HttpResponse response1 = message1.getHead();
-        Assert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_UNAUTHORIZED));
+        MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_UNAUTHORIZED));
         final String body1 = message1.getBody();
-        Assert.assertThat(body1, CoreMatchers.equalTo("You shall not pass!!!"));
+        MatcherAssert.assertThat(body1, CoreMatchers.equalTo("You shall not pass!!!"));
 
         final HttpRequest request2 = new BasicHttpRequest(Method.POST, target, "/stuff");
         request2.setVersion(HttpVersion.HTTP_1_0);
@@ -308,11 +308,11 @@ public class Http1AuthenticationTest {
                 new BasicRequestProducer(request2, AsyncEntityProducers.create(stuff, ContentType.TEXT_PLAIN)),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
         final Message<HttpResponse, String> message2 = resultFuture2.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
-        Assert.assertThat(message2, CoreMatchers.notNullValue());
+        MatcherAssert.assertThat(message2, CoreMatchers.notNullValue());
         final HttpResponse response2 = message2.getHead();
-        Assert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+        MatcherAssert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
         final String body2 = message2.getBody();
-        Assert.assertThat(body2, CoreMatchers.equalTo(new String(stuff, StandardCharsets.US_ASCII)));
+        MatcherAssert.assertThat(body2, CoreMatchers.equalTo(new String(stuff, StandardCharsets.US_ASCII)));
     }
 
 }
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http1ServerAndRequesterTest.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http1ServerAndRequesterTest.java
index 2d961d7..9cd2bcc 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http1ServerAndRequesterTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http1ServerAndRequesterTest.java
@@ -27,14 +27,6 @@
 
 package org.apache.hc.core5.testing.nio;
 
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.Queue;
-import java.util.concurrent.Future;
-
 import org.apache.hc.core5.function.Supplier;
 import org.apache.hc.core5.http.ContentType;
 import org.apache.hc.core5.http.EntityDetails;
@@ -76,7 +68,7 @@ import org.apache.hc.core5.testing.SSLTestContexts;
 import org.apache.hc.core5.testing.classic.LoggingConnPoolListener;
 import org.apache.hc.core5.util.Timeout;
 import org.hamcrest.CoreMatchers;
-import org.junit.Assert;
+import org.hamcrest.MatcherAssert;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExternalResource;
@@ -85,6 +77,14 @@ import org.junit.runners.Parameterized;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.Queue;
+import java.util.concurrent.Future;
+
 @RunWith(Parameterized.class)
 public class Http1ServerAndRequesterTest {
 
@@ -228,33 +228,33 @@ public class Http1ServerAndRequesterTest {
                         new StringAsyncEntityProducer("some stuff", ContentType.TEXT_PLAIN)),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
         final Message<HttpResponse, String> message1 = resultFuture1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
-        Assert.assertThat(message1, CoreMatchers.notNullValue());
+        MatcherAssert.assertThat(message1, CoreMatchers.notNullValue());
         final HttpResponse response1 = message1.getHead();
-        Assert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+        MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
         final String body1 = message1.getBody();
-        Assert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
+        MatcherAssert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
 
         final Future<Message<HttpResponse, String>> resultFuture2 = requester.execute(
                 new BasicRequestProducer(Method.POST, target, "/other-stuff",
                         new StringAsyncEntityProducer("some other stuff", ContentType.TEXT_PLAIN)),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
         final Message<HttpResponse, String> message2 = resultFuture2.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
-        Assert.assertThat(message2, CoreMatchers.notNullValue());
+        MatcherAssert.assertThat(message2, CoreMatchers.notNullValue());
         final HttpResponse response2 = message2.getHead();
-        Assert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+        MatcherAssert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
         final String body2 = message2.getBody();
-        Assert.assertThat(body2, CoreMatchers.equalTo("some other stuff"));
+        MatcherAssert.assertThat(body2, CoreMatchers.equalTo("some other stuff"));
 
         final Future<Message<HttpResponse, String>> resultFuture3 = requester.execute(
                 new BasicRequestProducer(Method.POST, target, "/more-stuff",
                         new StringAsyncEntityProducer("some more stuff", ContentType.TEXT_PLAIN)),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
         final Message<HttpResponse, String> message3 = resultFuture3.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
-        Assert.assertThat(message3, CoreMatchers.notNullValue());
+        MatcherAssert.assertThat(message3, CoreMatchers.notNullValue());
         final HttpResponse response3 = message3.getHead();
-        Assert.assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+        MatcherAssert.assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
         final String body3 = message3.getBody();
-        Assert.assertThat(body3, CoreMatchers.equalTo("some more stuff"));
+        MatcherAssert.assertThat(body3, CoreMatchers.equalTo("some more stuff"));
     }
 
     @Test
@@ -271,33 +271,33 @@ public class Http1ServerAndRequesterTest {
                         new StringAsyncEntityProducer("some stuff", ContentType.TEXT_PLAIN)),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
         final Message<HttpResponse, String> message1 = resultFuture1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
-        Assert.assertThat(message1, CoreMatchers.notNullValue());
+        MatcherAssert.assertThat(message1, CoreMatchers.notNullValue());
         final HttpResponse response1 = message1.getHead();
-        Assert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+        MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
         final String body1 = message1.getBody();
-        Assert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
+        MatcherAssert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
 
         final Future<Message<HttpResponse, String>> resultFuture2 = requester.execute(
                 new BasicRequestProducer(Method.POST, target, "/no-keep-alive/other-stuff",
                         new StringAsyncEntityProducer("some other stuff", ContentType.TEXT_PLAIN)),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
         final Message<HttpResponse, String> message2 = resultFuture2.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
-        Assert.assertThat(message2, CoreMatchers.notNullValue());
+        MatcherAssert.assertThat(message2, CoreMatchers.notNullValue());
         final HttpResponse response2 = message2.getHead();
-        Assert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+        MatcherAssert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
         final String body2 = message2.getBody();
-        Assert.assertThat(body2, CoreMatchers.equalTo("some other stuff"));
+        MatcherAssert.assertThat(body2, CoreMatchers.equalTo("some other stuff"));
 
         final Future<Message<HttpResponse, String>> resultFuture3 = requester.execute(
                 new BasicRequestProducer(Method.POST, target, "/no-keep-alive/more-stuff",
                         new StringAsyncEntityProducer("some more stuff", ContentType.TEXT_PLAIN)),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
         final Message<HttpResponse, String> message3 = resultFuture3.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
-        Assert.assertThat(message3, CoreMatchers.notNullValue());
+        MatcherAssert.assertThat(message3, CoreMatchers.notNullValue());
         final HttpResponse response3 = message3.getHead();
-        Assert.assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+        MatcherAssert.assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
         final String body3 = message3.getBody();
-        Assert.assertThat(body3, CoreMatchers.equalTo("some more stuff"));
+        MatcherAssert.assertThat(body3, CoreMatchers.equalTo("some more stuff"));
     }
 
     @Test
@@ -318,33 +318,33 @@ public class Http1ServerAndRequesterTest {
                             new StringAsyncEntityProducer("some stuff", ContentType.TEXT_PLAIN)),
                     new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
             final Message<HttpResponse, String> message1 = resultFuture1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
-            Assert.assertThat(message1, CoreMatchers.notNullValue());
+            MatcherAssert.assertThat(message1, CoreMatchers.notNullValue());
             final HttpResponse response1 = message1.getHead();
-            Assert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+            MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
             final String body1 = message1.getBody();
-            Assert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
+            MatcherAssert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
 
             final Future<Message<HttpResponse, String>> resultFuture2 = endpoint.execute(
                     new BasicRequestProducer(Method.POST, target, "/other-stuff",
                             new StringAsyncEntityProducer("some other stuff", ContentType.TEXT_PLAIN)),
                     new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
             final Message<HttpResponse, String> message2 = resultFuture2.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
-            Assert.assertThat(message2, CoreMatchers.notNullValue());
+            MatcherAssert.assertThat(message2, CoreMatchers.notNullValue());
             final HttpResponse response2 = message2.getHead();
-            Assert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+            MatcherAssert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
             final String body2 = message2.getBody();
-            Assert.assertThat(body2, CoreMatchers.equalTo("some other stuff"));
+            MatcherAssert.assertThat(body2, CoreMatchers.equalTo("some other stuff"));
 
             final Future<Message<HttpResponse, String>> resultFuture3 = endpoint.execute(
                     new BasicRequestProducer(Method.POST, target, "/more-stuff",
                             new StringAsyncEntityProducer("some more stuff", ContentType.TEXT_PLAIN)),
                     new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
             final Message<HttpResponse, String> message3 = resultFuture3.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
-            Assert.assertThat(message3, CoreMatchers.notNullValue());
+            MatcherAssert.assertThat(message3, CoreMatchers.notNullValue());
             final HttpResponse response3 = message3.getHead();
-            Assert.assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+            MatcherAssert.assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
             final String body3 = message3.getBody();
-            Assert.assertThat(body3, CoreMatchers.equalTo("some more stuff"));
+            MatcherAssert.assertThat(body3, CoreMatchers.equalTo("some more stuff"));
 
         } finally {
             endpoint.releaseAndReuse();
@@ -382,11 +382,11 @@ public class Http1ServerAndRequesterTest {
             while (!queue.isEmpty()) {
                 final Future<Message<HttpResponse, String>> resultFuture = queue.remove();
                 final Message<HttpResponse, String> message = resultFuture.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
-                Assert.assertThat(message, CoreMatchers.notNullValue());
+                MatcherAssert.assertThat(message, CoreMatchers.notNullValue());
                 final HttpResponse response = message.getHead();
-                Assert.assertThat(response.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+                MatcherAssert.assertThat(response.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
                 final String body = message.getBody();
-                Assert.assertThat(body, CoreMatchers.containsString("stuff"));
+                MatcherAssert.assertThat(body, CoreMatchers.containsString("stuff"));
             }
 
         } finally {
@@ -415,10 +415,10 @@ public class Http1ServerAndRequesterTest {
         while (!queue.isEmpty()) {
             final Future<Message<HttpResponse, String>> resultFuture = queue.remove();
             final Message<HttpResponse, String> message = resultFuture.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
-            Assert.assertThat(message, CoreMatchers.notNullValue());
+            MatcherAssert.assertThat(message, CoreMatchers.notNullValue());
             final HttpResponse response = message.getHead();
-            Assert.assertThat(response.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
-            Assert.assertThat(message.getBody(), CoreMatchers.nullValue());
+            MatcherAssert.assertThat(response.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+            MatcherAssert.assertThat(message.getBody(), CoreMatchers.nullValue());
         }
     }
 
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/concurrent/TestComplexCancellable.java b/httpcore5/src/test/java/org/apache/hc/core5/concurrent/TestComplexCancellable.java
index 8013dd9..9904576 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/concurrent/TestComplexCancellable.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/concurrent/TestComplexCancellable.java
@@ -27,6 +27,7 @@
 package org.apache.hc.core5.concurrent;
 
 import org.hamcrest.CoreMatchers;
+import org.hamcrest.MatcherAssert;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -42,12 +43,12 @@ public class TestComplexCancellable {
         Assert.assertFalse(cancellable.isCancelled());
 
         cancellable.cancel();
-        Assert.assertThat(cancellable.isCancelled(), CoreMatchers.is(true));
-        Assert.assertThat(dependency1.isCancelled(), CoreMatchers.is(true));
+        MatcherAssert.assertThat(cancellable.isCancelled(), CoreMatchers.is(true));
+        MatcherAssert.assertThat(dependency1.isCancelled(), CoreMatchers.is(true));
 
         final BasicFuture<Object> dependency2 = new BasicFuture<>(null);
         cancellable.setDependency(dependency2);
-        Assert.assertThat(dependency2.isCancelled(), CoreMatchers.is(true));
+        MatcherAssert.assertThat(dependency2.isCancelled(), CoreMatchers.is(true));
     }
 
 }
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/concurrent/TestComplexFuture.java b/httpcore5/src/test/java/org/apache/hc/core5/concurrent/TestComplexFuture.java
index ed04a82..e21a97c 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/concurrent/TestComplexFuture.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/concurrent/TestComplexFuture.java
@@ -26,12 +26,13 @@
  */
 package org.apache.hc.core5.concurrent;
 
-import java.util.concurrent.Future;
-
 import org.hamcrest.CoreMatchers;
+import org.hamcrest.MatcherAssert;
 import org.junit.Assert;
 import org.junit.Test;
 
+import java.util.concurrent.Future;
+
 public class TestComplexFuture {
 
     @Test
@@ -44,12 +45,12 @@ public class TestComplexFuture {
         Assert.assertFalse(future.isDone());
 
         future.cancel();
-        Assert.assertThat(future.isCancelled(), CoreMatchers.is(true));
-        Assert.assertThat(dependency1.isCancelled(), CoreMatchers.is(true));
+        MatcherAssert.assertThat(future.isCancelled(), CoreMatchers.is(true));
+        MatcherAssert.assertThat(dependency1.isCancelled(), CoreMatchers.is(true));
 
         final Future<Object> dependency2 = new BasicFuture<>(null);
         future.setDependency(dependency2);
-        Assert.assertThat(dependency2.isCancelled(), CoreMatchers.is(true));
+        MatcherAssert.assertThat(dependency2.isCancelled(), CoreMatchers.is(true));
     }
 
     @Test
@@ -62,12 +63,12 @@ public class TestComplexFuture {
         Assert.assertFalse(future.isDone());
 
         future.completed(Boolean.TRUE);
-        Assert.assertThat(future.isCancelled(), CoreMatchers.is(false));
-        Assert.assertThat(dependency1.isCancelled(), CoreMatchers.is(false));
+        MatcherAssert.assertThat(future.isCancelled(), CoreMatchers.is(false));
+        MatcherAssert.assertThat(dependency1.isCancelled(), CoreMatchers.is(false));
 
         final Future<Object> dependency2 = new BasicFuture<>(null);
         future.setDependency(dependency2);
-        Assert.assertThat(dependency2.isCancelled(), CoreMatchers.is(true));
+        MatcherAssert.assertThat(dependency2.isCancelled(), CoreMatchers.is(true));
     }
 
     @Test
@@ -86,12 +87,12 @@ public class TestComplexFuture {
         Assert.assertFalse(future.isDone());
 
         future.cancel();
-        Assert.assertThat(future.isCancelled(), CoreMatchers.is(true));
-        Assert.assertThat(dependency1.isCancelled(), CoreMatchers.is(true));
+        MatcherAssert.assertThat(future.isCancelled(), CoreMatchers.is(true));
+        MatcherAssert.assertThat(dependency1.isCancelled(), CoreMatchers.is(true));
 
         final Future<Object> dependency2 = new BasicFuture<>(null);
         future.setDependency(dependency2);
-        Assert.assertThat(dependency2.isCancelled(), CoreMatchers.is(true));
+        MatcherAssert.assertThat(dependency2.isCancelled(), CoreMatchers.is(true));
     }
 
 }
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/config/TestNamedElementChain.java b/httpcore5/src/test/java/org/apache/hc/core5/http/config/TestNamedElementChain.java
index 203d54d..67c2ad1 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/config/TestNamedElementChain.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/config/TestNamedElementChain.java
@@ -28,7 +28,7 @@
 package org.apache.hc.core5.http.config;
 
 import org.hamcrest.CoreMatchers;
-import org.junit.Assert;
+import org.hamcrest.MatcherAssert;
 import org.junit.Test;
 
 /**
@@ -39,59 +39,59 @@ public class TestNamedElementChain {
     @Test
     public void testBasics() {
         final NamedElementChain<Character> list = new NamedElementChain<>();
-        Assert.assertThat(list.getFirst(), CoreMatchers.nullValue());
-        Assert.assertThat(list.getLast(), CoreMatchers.nullValue());
+        MatcherAssert.assertThat(list.getFirst(), CoreMatchers.nullValue());
+        MatcherAssert.assertThat(list.getLast(), CoreMatchers.nullValue());
 
         final NamedElementChain<Character>.Node nodeA = list.addFirst('a', "a");
 
-        Assert.assertThat(list.getFirst(), CoreMatchers.sameInstance(nodeA));
-        Assert.assertThat(list.getLast(), CoreMatchers.sameInstance(nodeA));
+        MatcherAssert.assertThat(list.getFirst(), CoreMatchers.sameInstance(nodeA));
+        MatcherAssert.assertThat(list.getLast(), CoreMatchers.sameInstance(nodeA));
 
         final NamedElementChain<Character>.Node nodeB = list.addLast('b', "b");
 
-        Assert.assertThat(list.getFirst(), CoreMatchers.sameInstance(nodeA));
-        Assert.assertThat(list.getLast(), CoreMatchers.sameInstance(nodeB));
+        MatcherAssert.assertThat(list.getFirst(), CoreMatchers.sameInstance(nodeA));
+        MatcherAssert.assertThat(list.getLast(), CoreMatchers.sameInstance(nodeB));
 
         final NamedElementChain<Character>.Node nodeZ = list.addLast('z', "z");
 
-        Assert.assertThat(list.getFirst(), CoreMatchers.sameInstance(nodeA));
-        Assert.assertThat(list.getLast(), CoreMatchers.sameInstance(nodeZ));
+        MatcherAssert.assertThat(list.getFirst(), CoreMatchers.sameInstance(nodeA));
+        MatcherAssert.assertThat(list.getLast(), CoreMatchers.sameInstance(nodeZ));
 
-        Assert.assertThat(nodeA.getPrevious(), CoreMatchers.nullValue());
-        Assert.assertThat(nodeA.getNext(), CoreMatchers.sameInstance(nodeB));
-        Assert.assertThat(nodeB.getPrevious(), CoreMatchers.sameInstance(nodeA));
-        Assert.assertThat(nodeB.getNext(), CoreMatchers.sameInstance(nodeZ));
-        Assert.assertThat(nodeZ.getPrevious(), CoreMatchers.sameInstance(nodeB));
-        Assert.assertThat(nodeZ.getNext(), CoreMatchers.nullValue());
+        MatcherAssert.assertThat(nodeA.getPrevious(), CoreMatchers.nullValue());
+        MatcherAssert.assertThat(nodeA.getNext(), CoreMatchers.sameInstance(nodeB));
+        MatcherAssert.assertThat(nodeB.getPrevious(), CoreMatchers.sameInstance(nodeA));
+        MatcherAssert.assertThat(nodeB.getNext(), CoreMatchers.sameInstance(nodeZ));
+        MatcherAssert.assertThat(nodeZ.getPrevious(), CoreMatchers.sameInstance(nodeB));
+        MatcherAssert.assertThat(nodeZ.getNext(), CoreMatchers.nullValue());
 
         final NamedElementChain<Character>.Node nodeD = list.addAfter("b", 'd', "d");
-        Assert.assertThat(nodeD.getPrevious(), CoreMatchers.sameInstance(nodeB));
-        Assert.assertThat(nodeD.getNext(), CoreMatchers.sameInstance(nodeZ));
-        Assert.assertThat(nodeB.getNext(), CoreMatchers.sameInstance(nodeD));
-        Assert.assertThat(nodeZ.getPrevious(), CoreMatchers.sameInstance(nodeD));
+        MatcherAssert.assertThat(nodeD.getPrevious(), CoreMatchers.sameInstance(nodeB));
+        MatcherAssert.assertThat(nodeD.getNext(), CoreMatchers.sameInstance(nodeZ));
+        MatcherAssert.assertThat(nodeB.getNext(), CoreMatchers.sameInstance(nodeD));
+        MatcherAssert.assertThat(nodeZ.getPrevious(), CoreMatchers.sameInstance(nodeD));
 
         final NamedElementChain<Character>.Node nodeC = list.addBefore("d", 'c', "c");
-        Assert.assertThat(nodeC.getPrevious(), CoreMatchers.sameInstance(nodeB));
-        Assert.assertThat(nodeC.getNext(), CoreMatchers.sameInstance(nodeD));
-        Assert.assertThat(nodeB.getNext(), CoreMatchers.sameInstance(nodeC));
-        Assert.assertThat(nodeD.getPrevious(), CoreMatchers.sameInstance(nodeC));
-        Assert.assertThat(list.getSize(), CoreMatchers.equalTo(5));
-
-        Assert.assertThat(list.remove("a"), CoreMatchers.is(true));
-        Assert.assertThat(list.remove("z"), CoreMatchers.is(true));
-        Assert.assertThat(list.remove("c"), CoreMatchers.is(true));
-        Assert.assertThat(list.remove("c"), CoreMatchers.is(false));
-        Assert.assertThat(list.remove("blah"), CoreMatchers.is(false));
-
-        Assert.assertThat(list.getFirst(), CoreMatchers.sameInstance(nodeB));
-        Assert.assertThat(list.getLast(), CoreMatchers.sameInstance(nodeD));
-
-        Assert.assertThat(list.getSize(), CoreMatchers.equalTo(2));
-        Assert.assertThat(list.addBefore("blah", 'e', "e"), CoreMatchers.nullValue());
-        Assert.assertThat(list.getSize(), CoreMatchers.equalTo(2));
-
-        Assert.assertThat(list.addAfter("yada", 'e', "e"), CoreMatchers.nullValue());
-        Assert.assertThat(list.getSize(), CoreMatchers.equalTo(2));
+        MatcherAssert.assertThat(nodeC.getPrevious(), CoreMatchers.sameInstance(nodeB));
+        MatcherAssert.assertThat(nodeC.getNext(), CoreMatchers.sameInstance(nodeD));
+        MatcherAssert.assertThat(nodeB.getNext(), CoreMatchers.sameInstance(nodeC));
+        MatcherAssert.assertThat(nodeD.getPrevious(), CoreMatchers.sameInstance(nodeC));
+        MatcherAssert.assertThat(list.getSize(), CoreMatchers.equalTo(5));
+
+        MatcherAssert.assertThat(list.remove("a"), CoreMatchers.is(true));
+        MatcherAssert.assertThat(list.remove("z"), CoreMatchers.is(true));
+        MatcherAssert.assertThat(list.remove("c"), CoreMatchers.is(true));
+        MatcherAssert.assertThat(list.remove("c"), CoreMatchers.is(false));
+        MatcherAssert.assertThat(list.remove("blah"), CoreMatchers.is(false));
+
+        MatcherAssert.assertThat(list.getFirst(), CoreMatchers.sameInstance(nodeB));
+        MatcherAssert.assertThat(list.getLast(), CoreMatchers.sameInstance(nodeD));
+
+        MatcherAssert.assertThat(list.getSize(), CoreMatchers.equalTo(2));
+        MatcherAssert.assertThat(list.addBefore("blah", 'e', "e"), CoreMatchers.nullValue());
+        MatcherAssert.assertThat(list.getSize(), CoreMatchers.equalTo(2));
+
+        MatcherAssert.assertThat(list.addAfter("yada", 'e', "e"), CoreMatchers.nullValue());
+        MatcherAssert.assertThat(list.getSize(), CoreMatchers.equalTo(2));
     }
 
 }
\ No newline at end of file
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestExpandableBuffer.java b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestExpandableBuffer.java
index 4f0dfe7..d98d3fc 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestExpandableBuffer.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestExpandableBuffer.java
@@ -28,7 +28,7 @@
 package org.apache.hc.core5.http.impl.nio;
 
 import org.hamcrest.CoreMatchers;
-import org.junit.Assert;
+import org.hamcrest.MatcherAssert;
 import org.junit.Test;
 
 public class TestExpandableBuffer {
@@ -36,47 +36,47 @@ public class TestExpandableBuffer {
     @Test
     public void testBasics() throws Exception {
         final ExpandableBuffer buffer = new ExpandableBuffer(16);
-        Assert.assertThat(buffer.mode(), CoreMatchers.equalTo(ExpandableBuffer.Mode.INPUT));
-        Assert.assertThat(buffer.hasData(), CoreMatchers.equalTo(false));
+        MatcherAssert.assertThat(buffer.mode(), CoreMatchers.equalTo(ExpandableBuffer.Mode.INPUT));
+        MatcherAssert.assertThat(buffer.hasData(), CoreMatchers.equalTo(false));
 
         buffer.setInputMode();
         buffer.buffer().put(new byte[] { 0, 1, 2, 3, 4, 5});
-        Assert.assertThat(buffer.hasData(), CoreMatchers.equalTo(true));
-        Assert.assertThat(buffer.length(), CoreMatchers.equalTo(6));
-        Assert.assertThat(buffer.buffer().capacity(), CoreMatchers.equalTo(16));
-        Assert.assertThat(buffer.mode(), CoreMatchers.equalTo(ExpandableBuffer.Mode.OUTPUT));
+        MatcherAssert.assertThat(buffer.hasData(), CoreMatchers.equalTo(true));
+        MatcherAssert.assertThat(buffer.length(), CoreMatchers.equalTo(6));
+        MatcherAssert.assertThat(buffer.buffer().capacity(), CoreMatchers.equalTo(16));
+        MatcherAssert.assertThat(buffer.mode(), CoreMatchers.equalTo(ExpandableBuffer.Mode.OUTPUT));
 
         buffer.setInputMode();
         buffer.buffer().put(new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 });
-        Assert.assertThat(buffer.length(), CoreMatchers.equalTo(16));
-        Assert.assertThat(buffer.buffer().capacity(), CoreMatchers.equalTo(16));
-        Assert.assertThat(buffer.mode(), CoreMatchers.equalTo(ExpandableBuffer.Mode.OUTPUT));
+        MatcherAssert.assertThat(buffer.length(), CoreMatchers.equalTo(16));
+        MatcherAssert.assertThat(buffer.buffer().capacity(), CoreMatchers.equalTo(16));
+        MatcherAssert.assertThat(buffer.mode(), CoreMatchers.equalTo(ExpandableBuffer.Mode.OUTPUT));
 
         buffer.setInputMode();
         buffer.ensureCapacity(22);
         buffer.buffer().put(new byte[] { 0, 1, 2, 3, 4, 5});
-        Assert.assertThat(buffer.length(), CoreMatchers.equalTo(22));
-        Assert.assertThat(buffer.buffer().capacity(), CoreMatchers.equalTo(22));
-        Assert.assertThat(buffer.mode(), CoreMatchers.equalTo(ExpandableBuffer.Mode.OUTPUT));
+        MatcherAssert.assertThat(buffer.length(), CoreMatchers.equalTo(22));
+        MatcherAssert.assertThat(buffer.buffer().capacity(), CoreMatchers.equalTo(22));
+        MatcherAssert.assertThat(buffer.mode(), CoreMatchers.equalTo(ExpandableBuffer.Mode.OUTPUT));
 
         buffer.clear();
-        Assert.assertThat(buffer.mode(), CoreMatchers.equalTo(ExpandableBuffer.Mode.INPUT));
-        Assert.assertThat(buffer.hasData(), CoreMatchers.equalTo(false));
-        Assert.assertThat(buffer.capacity(), CoreMatchers.equalTo(22));
+        MatcherAssert.assertThat(buffer.mode(), CoreMatchers.equalTo(ExpandableBuffer.Mode.INPUT));
+        MatcherAssert.assertThat(buffer.hasData(), CoreMatchers.equalTo(false));
+        MatcherAssert.assertThat(buffer.capacity(), CoreMatchers.equalTo(22));
     }
 
     @Test
     public void testAdjustCapacity() throws Exception {
         final ExpandableBuffer buffer = new ExpandableBuffer(16);
-        Assert.assertThat(buffer.capacity(), CoreMatchers.equalTo(16));
+        MatcherAssert.assertThat(buffer.capacity(), CoreMatchers.equalTo(16));
 
         buffer.ensureCapacity(21);
-        Assert.assertThat(buffer.capacity(), CoreMatchers.equalTo(21));
+        MatcherAssert.assertThat(buffer.capacity(), CoreMatchers.equalTo(21));
         buffer.ensureAdjustedCapacity(22);
-        Assert.assertThat(buffer.capacity(), CoreMatchers.equalTo(1024));
+        MatcherAssert.assertThat(buffer.capacity(), CoreMatchers.equalTo(1024));
         buffer.ensureAdjustedCapacity(1024);
-        Assert.assertThat(buffer.capacity(), CoreMatchers.equalTo(1024));
+        MatcherAssert.assertThat(buffer.capacity(), CoreMatchers.equalTo(1024));
         buffer.ensureAdjustedCapacity(1025);
-        Assert.assertThat(buffer.capacity(), CoreMatchers.equalTo(2048));
+        MatcherAssert.assertThat(buffer.capacity(), CoreMatchers.equalTo(2048));
     }
 }
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/ssl/TestTlsVersionParser.java b/httpcore5/src/test/java/org/apache/hc/core5/http/ssl/TestTlsVersionParser.java
index 221f49d..7966ae2 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/ssl/TestTlsVersionParser.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/ssl/TestTlsVersionParser.java
@@ -31,7 +31,7 @@ import org.apache.hc.core5.http.ParseException;
 import org.apache.hc.core5.http.ProtocolVersion;
 import org.apache.hc.core5.util.Tokenizer;
 import org.hamcrest.CoreMatchers;
-import org.junit.Assert;
+import org.hamcrest.MatcherAssert;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -49,19 +49,19 @@ public class TestTlsVersionParser {
 
     @Test
     public void testParseBasic() throws Exception {
-        Assert.assertThat(impl.parse("TLSv1"), CoreMatchers.equalTo(TLS.V_1_0.version));
-        Assert.assertThat(impl.parse("TLSv1.1"), CoreMatchers.equalTo(TLS.V_1_1.version));
-        Assert.assertThat(impl.parse("TLSv1.2"), CoreMatchers.equalTo(TLS.V_1_2.version));
-        Assert.assertThat(impl.parse("TLSv1.3"), CoreMatchers.equalTo(TLS.V_1_3.version));
-        Assert.assertThat(impl.parse("TLSv22.356"), CoreMatchers.equalTo(new ProtocolVersion("TLS", 22, 356)));
+        MatcherAssert.assertThat(impl.parse("TLSv1"), CoreMatchers.equalTo(TLS.V_1_0.version));
+        MatcherAssert.assertThat(impl.parse("TLSv1.1"), CoreMatchers.equalTo(TLS.V_1_1.version));
+        MatcherAssert.assertThat(impl.parse("TLSv1.2"), CoreMatchers.equalTo(TLS.V_1_2.version));
+        MatcherAssert.assertThat(impl.parse("TLSv1.3"), CoreMatchers.equalTo(TLS.V_1_3.version));
+        MatcherAssert.assertThat(impl.parse("TLSv22.356"), CoreMatchers.equalTo(new ProtocolVersion("TLS", 22, 356)));
     }
 
     @Test
     public void testParseBuffer() throws Exception {
         final Tokenizer.Cursor cursor = new Tokenizer.Cursor(1, 13);
-        Assert.assertThat(impl.parse(" TLSv1.2,0000", cursor, Tokenizer.INIT_BITSET(',')),
+        MatcherAssert.assertThat(impl.parse(" TLSv1.2,0000", cursor, Tokenizer.INIT_BITSET(',')),
                 CoreMatchers.equalTo(TLS.V_1_2.version));
-        Assert.assertThat(cursor.getPos(), CoreMatchers.equalTo(8));
+        MatcherAssert.assertThat(cursor.getPos(), CoreMatchers.equalTo(8));
     }
 
     @Test(expected = ParseException.class)
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/reactor/TestAbstractIOSessionPool.java b/httpcore5/src/test/java/org/apache/hc/core5/reactor/TestAbstractIOSessionPool.java
index fe87e61..cca22d1 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/reactor/TestAbstractIOSessionPool.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/reactor/TestAbstractIOSessionPool.java
@@ -26,15 +26,13 @@
  */
 package org.apache.hc.core5.reactor;
 
-import java.util.concurrent.Future;
-
 import org.apache.hc.core5.concurrent.FutureCallback;
 import org.apache.hc.core5.function.Callback;
 import org.apache.hc.core5.io.CloseMode;
 import org.apache.hc.core5.util.TimeValue;
 import org.apache.hc.core5.util.Timeout;
 import org.hamcrest.CoreMatchers;
-import org.junit.Assert;
+import org.hamcrest.MatcherAssert;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -47,6 +45,8 @@ import org.mockito.invocation.InvocationOnMock;
 import org.mockito.junit.MockitoJUnitRunner;
 import org.mockito.stubbing.Answer;
 
+import java.util.concurrent.Future;
+
 @RunWith(MockitoJUnitRunner.class)
 public class TestAbstractIOSessionPool {
 
@@ -92,9 +92,9 @@ public class TestAbstractIOSessionPool {
         Mockito.when(ioSession1.isOpen()).thenReturn(true);
 
         final Future<IOSession> future1 = impl.getSession("somehost", Timeout.ofSeconds(123L), null);
-        Assert.assertThat(future1, CoreMatchers.notNullValue());
-        Assert.assertThat(future1.isDone(), CoreMatchers.equalTo(false));
-        Assert.assertThat(impl.getRoutes(), CoreMatchers.hasItem("somehost"));
+        MatcherAssert.assertThat(future1, CoreMatchers.notNullValue());
+        MatcherAssert.assertThat(future1.isDone(), CoreMatchers.equalTo(false));
+        MatcherAssert.assertThat(impl.getRoutes(), CoreMatchers.hasItem("somehost"));
 
         Mockito.verify(impl).connectSession(
                 ArgumentMatchers.eq("somehost"),
@@ -102,9 +102,9 @@ public class TestAbstractIOSessionPool {
                 ArgumentMatchers.<FutureCallback<IOSession>>any());
 
         final Future<IOSession> future2 = impl.getSession("somehost", Timeout.ofSeconds(123L), null);
-        Assert.assertThat(future2, CoreMatchers.notNullValue());
-        Assert.assertThat(future2.isDone(), CoreMatchers.equalTo(false));
-        Assert.assertThat(impl.getRoutes(), CoreMatchers.hasItem("somehost"));
+        MatcherAssert.assertThat(future2, CoreMatchers.notNullValue());
+        MatcherAssert.assertThat(future2.isDone(), CoreMatchers.equalTo(false));
+        MatcherAssert.assertThat(impl.getRoutes(), CoreMatchers.hasItem("somehost"));
 
         Mockito.verify(impl, Mockito.times(1)).connectSession(
                 ArgumentMatchers.eq("somehost"),
@@ -119,11 +119,11 @@ public class TestAbstractIOSessionPool {
 
                 }));
 
-        Assert.assertThat(future1.isDone(), CoreMatchers.equalTo(true));
-        Assert.assertThat(future1.get(), CoreMatchers.sameInstance(ioSession1));
+        MatcherAssert.assertThat(future1.isDone(), CoreMatchers.equalTo(true));
+        MatcherAssert.assertThat(future1.get(), CoreMatchers.sameInstance(ioSession1));
 
-        Assert.assertThat(future2.isDone(), CoreMatchers.equalTo(true));
-        Assert.assertThat(future2.get(), CoreMatchers.sameInstance(ioSession1));
+        MatcherAssert.assertThat(future2.isDone(), CoreMatchers.equalTo(true));
+        MatcherAssert.assertThat(future2.get(), CoreMatchers.sameInstance(ioSession1));
 
         Mockito.verify(impl, Mockito.times(2)).validateSession(ArgumentMatchers.<IOSession>any(), ArgumentMatchers.<Callback<Boolean>>any());
 
@@ -136,8 +136,8 @@ public class TestAbstractIOSessionPool {
 
         Mockito.verify(impl, Mockito.times(3)).validateSession(ArgumentMatchers.<IOSession>any(), ArgumentMatchers.<Callback<Boolean>>any());
 
-        Assert.assertThat(future3.isDone(), CoreMatchers.equalTo(true));
-        Assert.assertThat(future3.get(), CoreMatchers.sameInstance(ioSession1));
+        MatcherAssert.assertThat(future3.isDone(), CoreMatchers.equalTo(true));
+        MatcherAssert.assertThat(future3.get(), CoreMatchers.sameInstance(ioSession1));
     }
 
     @Test
@@ -149,9 +149,9 @@ public class TestAbstractIOSessionPool {
                 ArgumentMatchers.<FutureCallback<IOSession>>any())).thenReturn(connectFuture);
 
         final Future<IOSession> future1 = impl.getSession("somehost", Timeout.ofSeconds(123L), null);
-        Assert.assertThat(future1, CoreMatchers.notNullValue());
-        Assert.assertThat(future1.isDone(), CoreMatchers.equalTo(false));
-        Assert.assertThat(impl.getRoutes(), CoreMatchers.hasItem("somehost"));
+        MatcherAssert.assertThat(future1, CoreMatchers.notNullValue());
+        MatcherAssert.assertThat(future1.isDone(), CoreMatchers.equalTo(false));
+        MatcherAssert.assertThat(impl.getRoutes(), CoreMatchers.hasItem("somehost"));
 
         Mockito.verify(impl).connectSession(
                 ArgumentMatchers.eq("somehost"),
@@ -159,9 +159,9 @@ public class TestAbstractIOSessionPool {
                 ArgumentMatchers.<FutureCallback<IOSession>>any());
 
         final Future<IOSession> future2 = impl.getSession("somehost", Timeout.ofSeconds(123L), null);
-        Assert.assertThat(future2, CoreMatchers.notNullValue());
-        Assert.assertThat(future2.isDone(), CoreMatchers.equalTo(false));
-        Assert.assertThat(impl.getRoutes(), CoreMatchers.hasItem("somehost"));
+        MatcherAssert.assertThat(future2, CoreMatchers.notNullValue());
+        MatcherAssert.assertThat(future2.isDone(), CoreMatchers.equalTo(false));
+        MatcherAssert.assertThat(impl.getRoutes(), CoreMatchers.hasItem("somehost"));
 
         Mockito.verify(impl, Mockito.times(1)).connectSession(
                 ArgumentMatchers.eq("somehost"),
@@ -176,22 +176,22 @@ public class TestAbstractIOSessionPool {
 
                 }));
 
-        Assert.assertThat(future1.isDone(), CoreMatchers.equalTo(true));
-        Assert.assertThat(future2.isDone(), CoreMatchers.equalTo(true));
+        MatcherAssert.assertThat(future1.isDone(), CoreMatchers.equalTo(true));
+        MatcherAssert.assertThat(future2.isDone(), CoreMatchers.equalTo(true));
     }
 
     @Test
     public void testShutdownPool() throws Exception {
         final AbstractIOSessionPool.PoolEntry entry1 = impl.getPoolEntry("host1");
-        Assert.assertThat(entry1, CoreMatchers.notNullValue());
+        MatcherAssert.assertThat(entry1, CoreMatchers.notNullValue());
         entry1.session = ioSession1;
 
         final AbstractIOSessionPool.PoolEntry entry2 = impl.getPoolEntry("host2");
-        Assert.assertThat(entry2, CoreMatchers.notNullValue());
+        MatcherAssert.assertThat(entry2, CoreMatchers.notNullValue());
         entry2.session = ioSession2;
 
         final AbstractIOSessionPool.PoolEntry entry3 = impl.getPoolEntry("host3");
-        Assert.assertThat(entry3, CoreMatchers.notNullValue());
+        MatcherAssert.assertThat(entry3, CoreMatchers.notNullValue());
         entry3.sessionFuture = connectFuture;
         entry3.requestQueue.add(callback1);
         entry3.requestQueue.add(callback2);
@@ -208,11 +208,11 @@ public class TestAbstractIOSessionPool {
     @Test
     public void testCloseIdleSessions() throws Exception {
         final AbstractIOSessionPool.PoolEntry entry1 = impl.getPoolEntry("host1");
-        Assert.assertThat(entry1, CoreMatchers.notNullValue());
+        MatcherAssert.assertThat(entry1, CoreMatchers.notNullValue());
         entry1.session = ioSession1;
 
         final AbstractIOSessionPool.PoolEntry entry2 = impl.getPoolEntry("host2");
-        Assert.assertThat(entry2, CoreMatchers.notNullValue());
+        MatcherAssert.assertThat(entry2, CoreMatchers.notNullValue());
         entry2.session = ioSession2;
 
         impl.closeIdle(TimeValue.ZERO_MILLISECONDS);
@@ -220,18 +220,18 @@ public class TestAbstractIOSessionPool {
         Mockito.verify(impl).closeSession(ioSession1, CloseMode.GRACEFUL);
         Mockito.verify(impl).closeSession(ioSession2, CloseMode.GRACEFUL);
 
-        Assert.assertThat(entry1.session, CoreMatchers.nullValue());
-        Assert.assertThat(entry2.session, CoreMatchers.nullValue());
+        MatcherAssert.assertThat(entry1.session, CoreMatchers.nullValue());
+        MatcherAssert.assertThat(entry2.session, CoreMatchers.nullValue());
     }
 
     @Test
     public void testEnumSessions() throws Exception {
         final AbstractIOSessionPool.PoolEntry entry1 = impl.getPoolEntry("host1");
-        Assert.assertThat(entry1, CoreMatchers.notNullValue());
+        MatcherAssert.assertThat(entry1, CoreMatchers.notNullValue());
         entry1.session = ioSession1;
 
         final AbstractIOSessionPool.PoolEntry entry2 = impl.getPoolEntry("host2");
-        Assert.assertThat(entry2, CoreMatchers.notNullValue());
+        MatcherAssert.assertThat(entry2, CoreMatchers.notNullValue());
         entry2.session = ioSession2;
 
         impl.enumAvailable(new Callback<IOSession>() {
@@ -249,7 +249,7 @@ public class TestAbstractIOSessionPool {
     @Test
     public void testGetSessionReconnectAfterValidate() throws Exception {
         final AbstractIOSessionPool.PoolEntry entry1 = impl.getPoolEntry("somehost");
-        Assert.assertThat(entry1, CoreMatchers.notNullValue());
+        MatcherAssert.assertThat(entry1, CoreMatchers.notNullValue());
         entry1.session = ioSession1;
 
         Mockito.when(ioSession1.isOpen()).thenReturn(true);
@@ -275,7 +275,7 @@ public class TestAbstractIOSessionPool {
     @Test
     public void testGetSessionReconnectIfClosed() throws Exception {
         final AbstractIOSessionPool.PoolEntry entry1 = impl.getPoolEntry("somehost");
-        Assert.assertThat(entry1, CoreMatchers.notNullValue());
+        MatcherAssert.assertThat(entry1, CoreMatchers.notNullValue());
         entry1.session = ioSession1;
 
         Mockito.when(ioSession1.isOpen()).thenReturn(false);
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/util/TestTimeValue.java b/httpcore5/src/test/java/org/apache/hc/core5/util/TestTimeValue.java
index 18bc451..2e852ce 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/util/TestTimeValue.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/util/TestTimeValue.java
@@ -27,13 +27,14 @@
 
 package org.apache.hc.core5.util;
 
-import java.text.ParseException;
-import java.util.concurrent.TimeUnit;
-
 import org.hamcrest.CoreMatchers;
+import org.hamcrest.MatcherAssert;
 import org.junit.Assert;
 import org.junit.Test;
 
+import java.text.ParseException;
+import java.util.concurrent.TimeUnit;
+
 public class TestTimeValue {
 
     private void checkToDays(final long value, final TimeUnit timeUnit) {
@@ -271,19 +272,19 @@ public class TestTimeValue {
         final TimeValue tv4 = TimeValue.ofSeconds(1L);
         final TimeValue tv5 = TimeValue.ofSeconds(1000L);
 
-        Assert.assertThat(tv1.equals(tv1), CoreMatchers.equalTo(true));
-        Assert.assertThat(tv1.equals(null), CoreMatchers.equalTo(false));
-        Assert.assertThat(tv1.equals(tv2), CoreMatchers.equalTo(false));
-        Assert.assertThat(tv1.equals(tv3), CoreMatchers.equalTo(true));
-        Assert.assertThat(tv1.equals(tv4), CoreMatchers.equalTo(true));
-        Assert.assertThat(tv4.equals(tv1), CoreMatchers.equalTo(true));
-        Assert.assertThat(tv1.equals(tv5), CoreMatchers.equalTo(false));
-
-        Assert.assertThat(tv1.hashCode() == tv2.hashCode(), CoreMatchers.equalTo(false));
-        Assert.assertThat(tv1.hashCode() == tv3.hashCode(), CoreMatchers.equalTo(true));
-        Assert.assertThat(tv1.hashCode() == tv4.hashCode(), CoreMatchers.equalTo(true));
-        Assert.assertThat(tv4.hashCode() == tv1.hashCode(), CoreMatchers.equalTo(true));
-        Assert.assertThat(tv1.hashCode() == tv5.hashCode(), CoreMatchers.equalTo(false));
+        MatcherAssert.assertThat(tv1.equals(tv1), CoreMatchers.equalTo(true));
+        MatcherAssert.assertThat(tv1.equals(null), CoreMatchers.equalTo(false));
+        MatcherAssert.assertThat(tv1.equals(tv2), CoreMatchers.equalTo(false));
+        MatcherAssert.assertThat(tv1.equals(tv3), CoreMatchers.equalTo(true));
+        MatcherAssert.assertThat(tv1.equals(tv4), CoreMatchers.equalTo(true));
+        MatcherAssert.assertThat(tv4.equals(tv1), CoreMatchers.equalTo(true));
+        MatcherAssert.assertThat(tv1.equals(tv5), CoreMatchers.equalTo(false));
+
+        MatcherAssert.assertThat(tv1.hashCode() == tv2.hashCode(), CoreMatchers.equalTo(false));
+        MatcherAssert.assertThat(tv1.hashCode() == tv3.hashCode(), CoreMatchers.equalTo(true));
+        MatcherAssert.assertThat(tv1.hashCode() == tv4.hashCode(), CoreMatchers.equalTo(true));
+        MatcherAssert.assertThat(tv4.hashCode() == tv1.hashCode(), CoreMatchers.equalTo(true));
+        MatcherAssert.assertThat(tv1.hashCode() == tv5.hashCode(), CoreMatchers.equalTo(false));
     }
 
     @Test
@@ -295,13 +296,13 @@ public class TestTimeValue {
         final TimeValue tv5 = TimeValue.ofSeconds(60L);
         final TimeValue tv6 = TimeValue.ofMinutes(1L);
 
-        Assert.assertThat(tv1.compareTo(tv1) == 0, CoreMatchers.equalTo(true));
-        Assert.assertThat(tv1.compareTo(tv2) < 0, CoreMatchers.equalTo(true));
-        Assert.assertThat(tv1.compareTo(tv3) == 0, CoreMatchers.equalTo(true));
-        Assert.assertThat(tv1.compareTo(tv4) == 0, CoreMatchers.equalTo(true));
-        Assert.assertThat(tv1.compareTo(tv5) < 0, CoreMatchers.equalTo(true));
-        Assert.assertThat(tv6.compareTo(tv5) == 0, CoreMatchers.equalTo(true));
-        Assert.assertThat(tv6.compareTo(tv4) > 0, CoreMatchers.equalTo(true));
+        MatcherAssert.assertThat(tv1.compareTo(tv1) == 0, CoreMatchers.equalTo(true));
+        MatcherAssert.assertThat(tv1.compareTo(tv2) < 0, CoreMatchers.equalTo(true));
+        MatcherAssert.assertThat(tv1.compareTo(tv3) == 0, CoreMatchers.equalTo(true));
+        MatcherAssert.assertThat(tv1.compareTo(tv4) == 0, CoreMatchers.equalTo(true));
+        MatcherAssert.assertThat(tv1.compareTo(tv5) < 0, CoreMatchers.equalTo(true));
+        MatcherAssert.assertThat(tv6.compareTo(tv5) == 0, CoreMatchers.equalTo(true));
+        MatcherAssert.assertThat(tv6.compareTo(tv4) > 0, CoreMatchers.equalTo(true));
         try {
             tv1.compareTo(null);
             Assert.fail("NullPointerException expected");