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/11/20 14:18:55 UTC
[httpcomponents-core] branch master updated: HTTPCORE-698 - Migrate Test to Unit 5.
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
The following commit(s) were added to refs/heads/master by this push:
new 8b02bdf HTTPCORE-698 - Migrate Test to Unit 5.
8b02bdf is described below
commit 8b02bdf8e0421d455008bc6d2e367b126721c2ed
Author: Arturo Bernal <ar...@gmail.com>
AuthorDate: Tue Nov 16 20:18:20 2021 +0100
HTTPCORE-698 - Migrate Test to Unit 5.
---
httpcore5-h2/pom.xml | 9 +-
.../core5/http2/frame/TestDefaultFrameFactory.java | 46 +--
.../apache/hc/core5/http2/frame/TestFrameFlag.java | 6 +-
.../hc/core5/http2/frame/TestH2Settings.java | 20 +-
.../hc/core5/http2/hpack/TestFifoBuffer.java | 106 +++---
.../hc/core5/http2/hpack/TestFifoLinkedList.java | 128 +++----
.../hc/core5/http2/hpack/TestHPackCoding.java | 249 ++++++------
.../core5/http2/hpack/TestInboundDynamicTable.java | 26 +-
.../http2/hpack/TestOutboundDynamicTable.java | 26 +-
.../http2/impl/TestDefaultH2RequestConverter.java | 175 +++++----
.../http2/impl/TestDefaultH2ResponseConverter.java | 76 ++--
.../core5/http2/impl/io/TestFrameInOutBuffers.java | 184 ++++-----
.../http2/impl/nio/TestFrameInOutBuffers.java | 196 +++++-----
httpcore5-reactive/pom.xml | 4 +-
.../core5/reactive/TestReactiveDataConsumer.java | 34 +-
.../core5/reactive/TestReactiveDataProducer.java | 20 +-
httpcore5-testing/pom.xml | 14 +-
.../hc/core5/benchmark/BenchmarkToolTest.java | 57 ++-
.../hc/core5/benchmark/ResultFormatterTest.java | 7 +-
.../testing/classic/ClassicAuthenticationTest.java | 29 +-
.../testing/classic/ClassicIntegrationTest.java | 64 ++--
.../classic/ClassicServerAndRequesterTest.java | 29 +-
.../classic/ClassicServerBootstrapFilterTest.java | 11 +-
.../testing/classic/ClassicTLSIntegrationTest.java | 25 +-
...gResponseOutOfOrderStrategyIntegrationTest.java | 9 +-
.../testing/compatibility/http2/HttpBinIT.java | 10 +-
.../TestClassicTestClientTestingAdapter.java | 44 +--
.../testing/framework/TestClientPojoAdapter.java | 10 +-
.../framework/TestClientTestingAdapter.java | 8 +-
.../core5/testing/framework/TestFrameworkTest.java | 55 ++-
.../testing/framework/TestTestingFramework.java | 123 +++---
.../TestTestingFrameworkRequestHandler.java | 8 +-
.../nio/AsyncServerBootstrapFilterTest.java | 13 +-
.../apache/hc/core5/testing/nio/H2AlpnTest.java | 25 +-
.../hc/core5/testing/nio/H2IntegrationTest.java | 207 +++++-----
.../testing/nio/H2ProtocolNegotiationTest.java | 25 +-
.../nio/H2ServerAndMultiplexingRequesterTest.java | 49 +--
.../testing/nio/H2ServerAndRequesterTest.java | 47 +--
.../testing/nio/H2ServerBootstrapFiltersTest.java | 13 +-
.../testing/nio/H2SocksProxyIntegrationTest.java | 8 +-
.../hc/core5/testing/nio/H2TLSIntegrationTest.java | 35 +-
.../core5/testing/nio/Http1AuthenticationTest.java | 41 +-
.../hc/core5/testing/nio/Http1IntegrationTest.java | 417 +++++++++++----------
.../testing/nio/Http1ServerAndRequesterTest.java | 71 ++--
.../nio/Http1SocksProxyIntegrationTest.java | 10 +-
.../testing/nio/InternalH2ServerTestBase.java | 17 +-
.../testing/nio/InternalHttp1ServerTestBase.java | 2 +
.../testing/nio/JSSEProviderIntegrationTest.java | 31 +-
.../testing/nio/TestDefaultListeningIOReactor.java | 32 +-
.../core5/testing/reactive/ReactiveClientTest.java | 48 +--
httpcore5/pom.xml | 9 +-
.../hc/core5/concurrent/TestBasicFuture.java | 94 ++---
.../core5/concurrent/TestComplexCancellable.java | 15 +-
.../hc/core5/concurrent/TestComplexFuture.java | 31 +-
.../org/apache/hc/core5/http/HeaderMatcher.java | 2 -
.../org/apache/hc/core5/http/HeadersMatcher.java | 2 -
.../hc/core5/http/NameValuePairListMatcher.java | 3 -
.../org/apache/hc/core5/http/TestContentType.java | 116 +++---
.../apache/hc/core5/http/TestHttpExceptions.java | 16 +-
.../org/apache/hc/core5/http/TestHttpHost.java | 156 ++++----
.../org/apache/hc/core5/http/TestHttpVersion.java | 94 ++---
.../apache/hc/core5/http/TestProtocolVersion.java | 12 +-
.../core5/http/config/TestNamedElementChain.java | 83 ++--
.../apache/hc/core5/http/config/TestRegistry.java | 12 +-
.../impl/TestDefaultConnectionReuseStrategy.java | 64 ++--
.../impl/TestDefaultContentLengthStrategy.java | 18 +-
.../http/impl/TestEnglishReasonPhraseCatalog.java | 18 +-
.../http/impl/io/TestBHttpConnectionBase.java | 95 +++--
.../hc/core5/http/impl/io/TestChunkCoding.java | 110 +++---
.../http/impl/io/TestContentLengthInputStream.java | 44 +--
.../impl/io/TestContentLengthOutputStream.java | 10 +-
.../impl/io/TestDefaultBHttpClientConnection.java | 175 +++++----
.../impl/io/TestDefaultBHttpServerConnection.java | 145 ++++---
.../http/impl/io/TestHttpRequestExecutor.java | 58 +--
.../hc/core5/http/impl/io/TestHttpService.java | 65 ++--
.../http/impl/io/TestIdentityInputStream.java | 32 +-
.../http/impl/io/TestIdentityOutputStream.java | 20 +-
.../hc/core5/http/impl/io/TestMessageParser.java | 50 +--
.../TestMonitoringResponseOutOfOrderStrategy.java | 20 +-
.../hc/core5/http/impl/io/TestRequestParser.java | 30 +-
.../hc/core5/http/impl/io/TestResponseParser.java | 30 +-
.../http/impl/io/TestSessionInOutBuffers.java | 172 ++++-----
...tAbstractHttp1StreamDuplexerCapacityWindow.java | 23 +-
.../hc/core5/http/impl/nio/TestChunkDecoder.java | 158 ++++----
.../hc/core5/http/impl/nio/TestChunkEncoder.java | 62 +--
.../core5/http/impl/nio/TestExpandableBuffer.java | 45 +--
.../core5/http/impl/nio/TestIdentityDecoder.java | 142 +++----
.../core5/http/impl/nio/TestIdentityEncoder.java | 182 ++++-----
.../http/impl/nio/TestLengthDelimitedDecoder.java | 248 ++++++------
.../http/impl/nio/TestLengthDelimitedEncoder.java | 196 +++++-----
.../http/impl/nio/TestSessionInOutBuffers.java | 136 +++----
.../hc/core5/http/io/TestEofSensorInputStream.java | 76 ++--
.../core5/http/io/entity/TestBasicHttpEntity.java | 18 +-
.../http/io/entity/TestBufferedHttpEntity.java | 58 +--
.../core5/http/io/entity/TestByteArrayEntity.java | 56 +--
.../core5/http/io/entity/TestByteBufferEntity.java | 26 +-
.../hc/core5/http/io/entity/TestEntityUtils.java | 56 +--
.../hc/core5/http/io/entity/TestFileEntity.java | 26 +-
.../http/io/entity/TestHttpEntityWrapper.java | 34 +-
.../http/io/entity/TestInputStreamEntity.java | 36 +-
.../hc/core5/http/io/entity/TestNullEntity.java | 8 +-
.../hc/core5/http/io/entity/TestPathEntity.java | 26 +-
.../http/io/entity/TestSerializableEntity.java | 20 +-
.../hc/core5/http/io/entity/TestStringEntity.java | 46 +--
.../hc/core5/http/message/TestBasicHeader.java | 14 +-
.../message/TestBasicHeaderElementIterator.java | 48 +--
.../http/message/TestBasicHeaderIterator.java | 232 ++++++------
.../message/TestBasicHeaderValueFormatter.java | 60 +--
.../http/message/TestBasicHeaderValueParser.java | 192 +++++-----
.../core5/http/message/TestBasicLineFormatter.java | 36 +-
.../hc/core5/http/message/TestBasicLineParser.java | 156 ++++----
.../hc/core5/http/message/TestBasicMessages.java | 138 +++----
.../hc/core5/http/message/TestBasicStatusLine.java | 46 +--
.../core5/http/message/TestBasicTokenIterator.java | 112 +++---
.../hc/core5/http/message/TestBufferedHeader.java | 30 +-
.../apache/hc/core5/http/message/TestHeader.java | 22 +-
.../hc/core5/http/message/TestHeaderElement.java | 32 +-
.../hc/core5/http/message/TestHeaderGroup.java | 98 ++---
.../hc/core5/http/message/TestMessageSupport.java | 40 +-
.../hc/core5/http/message/TestNameValuePair.java | 64 ++--
.../entity/TestAbstractBinAsyncEntityConsumer.java | 10 +-
.../entity/TestAbstractBinAsyncEntityProducer.java | 62 +--
.../TestAbstractCharAsyncEntityConsumer.java | 10 +-
.../TestAbstractCharAsyncEntityProducer.java | 34 +-
.../http/nio/entity/TestAsyncEntityProducers.java | 16 +-
.../nio/entity/TestBasicAsyncEntityProducer.java | 34 +-
.../nio/entity/TestDigestingEntityConsumer.java | 8 +-
.../nio/entity/TestDigestingEntityProducer.java | 18 +-
.../nio/entity/TestFileAsyncEntityProducer.java | 32 +-
.../http/nio/entity/TestFileEntityProducer.java | 23 +-
.../nio/entity/TestPathAsyncEntityProducer.java | 32 +-
.../http/nio/entity/TestPathEntityProducer.java | 21 +-
.../nio/entity/TestStringAsyncEntityProducer.java | 24 +-
.../nio/support/classic/TestSharedInputBuffer.java | 40 +-
.../support/classic/TestSharedOutputBuffer.java | 30 +-
.../hc/core5/http/protocol/TestChainBuilder.java | 18 +-
.../http/protocol/TestHttpExecutionContext.java | 36 +-
.../http/protocol/TestRequestHandlerRegistry.java | 32 +-
.../http/protocol/TestStandardInterceptors.java | 272 +++++++-------
.../core5/http/protocol/TestUriPatternMatcher.java | 68 ++--
.../protocol/TestUriPatternOrderedMatcher.java | 76 ++--
.../hc/core5/http/protocol/TestUriPatternType.java | 10 +-
.../core5/http/protocol/TestUriRegexMatcher.java | 84 ++---
.../apache/hc/core5/http/ssl/TestTlsCiphers.java | 8 +-
.../hc/core5/http/ssl/TestTlsVersionParser.java | 35 +-
.../http/support/TestBasicMessageBuilders.java | 177 ++++-----
.../java/org/apache/hc/core5/net/TestHost.java | 58 +--
.../apache/hc/core5/net/TestInetAddressUtils.java | 134 +++----
.../org/apache/hc/core5/net/TestPercentCodec.java | 19 +-
.../org/apache/hc/core5/net/TestURIAuthority.java | 147 ++++----
.../org/apache/hc/core5/net/TestURIBuilder.java | 371 +++++++++---------
.../org/apache/hc/core5/net/TestWWWFormCodec.java | 53 +--
.../org/apache/hc/core5/pool/TestLaxConnPool.java | 192 +++++-----
.../org/apache/hc/core5/pool/TestPoolEntry.java | 48 +--
.../apache/hc/core5/pool/TestStrictConnPool.java | 316 ++++++++--------
.../hc/core5/reactor/IOReactorConfigTest.java | 32 +-
.../org/apache/hc/core5/reactor/IOWorkersTest.java | 2 +-
.../core5/reactor/TestAbstractIOSessionPool.java | 88 ++---
.../apache/hc/core5/ssl/TestSSLContextBuilder.java | 162 ++++----
.../java/org/apache/hc/core5/util/TestArgs.java | 98 ++---
.../java/org/apache/hc/core5/util/TestAsserts.java | 18 +-
.../apache/hc/core5/util/TestByteArrayBuffer.java | 196 +++++-----
.../apache/hc/core5/util/TestCharArrayBuffer.java | 184 ++++-----
.../org/apache/hc/core5/util/TestDeadline.java | 70 ++--
.../core5/util/TestDeadlineTimeoutException.java | 8 +-
.../org/apache/hc/core5/util/TestLangUtils.java | 34 +-
.../org/apache/hc/core5/util/TestTextUtils.java | 34 +-
.../org/apache/hc/core5/util/TestTimeValue.java | 231 ++++++------
.../java/org/apache/hc/core5/util/TestTimeout.java | 42 +--
.../hc/core5/util/TestTimeoutValueException.java | 6 +-
.../org/apache/hc/core5/util/TestTokenizer.java | 64 ++--
pom.xml | 21 +-
172 files changed, 5794 insertions(+), 5742 deletions(-)
diff --git a/httpcore5-h2/pom.xml b/httpcore5-h2/pom.xml
index ded573d..6af97d6 100644
--- a/httpcore5-h2/pom.xml
+++ b/httpcore5-h2/pom.xml
@@ -49,8 +49,13 @@
<optional>true</optional>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/frame/TestDefaultFrameFactory.java b/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/frame/TestDefaultFrameFactory.java
index 05946bb..6767442 100644
--- a/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/frame/TestDefaultFrameFactory.java
+++ b/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/frame/TestDefaultFrameFactory.java
@@ -32,8 +32,8 @@ import java.nio.charset.StandardCharsets;
import org.apache.hc.core5.http2.H2Error;
import org.apache.hc.core5.http2.config.H2Param;
import org.apache.hc.core5.http2.config.H2Setting;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestDefaultFrameFactory {
@@ -45,9 +45,9 @@ public class TestDefaultFrameFactory {
final byte[] data = new byte[]{'a', 'b', 'c', 'd', 'e', 'f'};
final Frame<ByteBuffer> dataFrame = frameFactory.createData(23, ByteBuffer.wrap(data), true);
- Assert.assertEquals(FrameType.DATA.value, dataFrame.getType());
- Assert.assertEquals(23, dataFrame.getStreamId());
- Assert.assertEquals(1L, dataFrame.getFlags());
+ Assertions.assertEquals(FrameType.DATA.value, dataFrame.getType());
+ Assertions.assertEquals(23, dataFrame.getStreamId());
+ Assertions.assertEquals(1L, dataFrame.getFlags());
}
@Test
@@ -58,12 +58,12 @@ public class TestDefaultFrameFactory {
new H2Setting(H2Param.HEADER_TABLE_SIZE, 1024),
new H2Setting(H2Param.MAX_CONCURRENT_STREAMS, 1));
- Assert.assertEquals(FrameType.SETTINGS.value, settingsFrame.getType());
- Assert.assertEquals(0, settingsFrame.getStreamId());
- Assert.assertEquals(0, settingsFrame.getFlags());
+ Assertions.assertEquals(FrameType.SETTINGS.value, settingsFrame.getType());
+ Assertions.assertEquals(0, settingsFrame.getStreamId());
+ Assertions.assertEquals(0, settingsFrame.getFlags());
final ByteBuffer payload = settingsFrame.getPayload();
- Assert.assertNotNull(payload);
- Assert.assertEquals(12, payload.remaining());
+ Assertions.assertNotNull(payload);
+ Assertions.assertEquals(12, payload.remaining());
}
@Test
@@ -72,13 +72,13 @@ public class TestDefaultFrameFactory {
final FrameFactory frameFactory = new DefaultFrameFactory();
final Frame<ByteBuffer> rstStreamFrame = frameFactory.createResetStream(12, H2Error.INTERNAL_ERROR);
- Assert.assertEquals(FrameType.RST_STREAM.value, rstStreamFrame.getType());
- Assert.assertEquals(12, rstStreamFrame.getStreamId());
- Assert.assertEquals(0, rstStreamFrame.getFlags());
+ Assertions.assertEquals(FrameType.RST_STREAM.value, rstStreamFrame.getType());
+ Assertions.assertEquals(12, rstStreamFrame.getStreamId());
+ Assertions.assertEquals(0, rstStreamFrame.getFlags());
final ByteBuffer payload = rstStreamFrame.getPayload();
- Assert.assertNotNull(payload);
- Assert.assertEquals(4, payload.remaining());
- Assert.assertEquals(H2Error.INTERNAL_ERROR.getCode(), payload.getInt());
+ Assertions.assertNotNull(payload);
+ Assertions.assertEquals(4, payload.remaining());
+ Assertions.assertEquals(H2Error.INTERNAL_ERROR.getCode(), payload.getInt());
}
@Test
@@ -87,16 +87,16 @@ public class TestDefaultFrameFactory {
final FrameFactory frameFactory = new DefaultFrameFactory();
final Frame<ByteBuffer> goAwayFrame = frameFactory.createGoAway(13, H2Error.INTERNAL_ERROR, "Oopsie");
- Assert.assertEquals(FrameType.GOAWAY.value, goAwayFrame.getType());
- Assert.assertEquals(0, goAwayFrame.getStreamId());
- Assert.assertEquals(0, goAwayFrame.getFlags());
+ Assertions.assertEquals(FrameType.GOAWAY.value, goAwayFrame.getType());
+ Assertions.assertEquals(0, goAwayFrame.getStreamId());
+ Assertions.assertEquals(0, goAwayFrame.getFlags());
final ByteBuffer payload = goAwayFrame.getPayload();
- Assert.assertNotNull(payload);
- Assert.assertEquals(13, payload.getInt());
- Assert.assertEquals(H2Error.INTERNAL_ERROR.getCode(), payload.getInt());
+ Assertions.assertNotNull(payload);
+ Assertions.assertEquals(13, payload.getInt());
+ Assertions.assertEquals(H2Error.INTERNAL_ERROR.getCode(), payload.getInt());
final byte[] tmp = new byte[payload.remaining()];
payload.get(tmp);
- Assert.assertEquals("Oopsie", new String(tmp, StandardCharsets.US_ASCII));
+ Assertions.assertEquals("Oopsie", new String(tmp, StandardCharsets.US_ASCII));
}
}
diff --git a/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/frame/TestFrameFlag.java b/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/frame/TestFrameFlag.java
index 1a52618..5623536 100644
--- a/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/frame/TestFrameFlag.java
+++ b/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/frame/TestFrameFlag.java
@@ -26,8 +26,8 @@
*/
package org.apache.hc.core5.http2.frame;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestFrameFlag {
@@ -35,7 +35,7 @@ public class TestFrameFlag {
public void testFrameFlagBasics() throws Exception {
final int flags = FrameFlag.of(FrameFlag.END_STREAM, FrameFlag.PADDED, FrameFlag.PRIORITY);
- Assert.assertEquals(0x01 | 0x08 | 0x20, flags);
+ Assertions.assertEquals(0x01 | 0x08 | 0x20, flags);
}
}
diff --git a/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/frame/TestH2Settings.java b/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/frame/TestH2Settings.java
index eca76d7..74d446f 100644
--- a/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/frame/TestH2Settings.java
+++ b/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/frame/TestH2Settings.java
@@ -28,21 +28,21 @@ package org.apache.hc.core5.http2.frame;
import org.apache.hc.core5.http2.config.H2Param;
import org.apache.hc.core5.http2.config.H2Setting;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestH2Settings {
@Test
public void testH2ParamBasics() throws Exception {
for (final H2Param param: H2Param.values()) {
- Assert.assertEquals(param, H2Param.valueOf(param.getCode()));
- Assert.assertEquals(param.name(), H2Param.toString(param.getCode()));
+ Assertions.assertEquals(param, H2Param.valueOf(param.getCode()));
+ Assertions.assertEquals(param.name(), H2Param.toString(param.getCode()));
}
- Assert.assertNull(H2Param.valueOf(0));
- Assert.assertNull(H2Param.valueOf(10));
- Assert.assertEquals("0", H2Param.toString(0));
- Assert.assertEquals("10", H2Param.toString(10));
+ Assertions.assertNull(H2Param.valueOf(0));
+ Assertions.assertNull(H2Param.valueOf(10));
+ Assertions.assertEquals("0", H2Param.toString(0));
+ Assertions.assertEquals("10", H2Param.toString(10));
}
@Test
@@ -51,8 +51,8 @@ public class TestH2Settings {
final H2Setting setting1 = new H2Setting(H2Param.ENABLE_PUSH, 0);
final H2Setting setting2 = new H2Setting(H2Param.INITIAL_WINDOW_SIZE, 1024);
- Assert.assertEquals("ENABLE_PUSH: 0", setting1.toString());
- Assert.assertEquals("INITIAL_WINDOW_SIZE: 1024", setting2.toString());
+ Assertions.assertEquals("ENABLE_PUSH: 0", setting1.toString());
+ Assertions.assertEquals("INITIAL_WINDOW_SIZE: 1024", setting2.toString());
}
}
diff --git a/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/hpack/TestFifoBuffer.java b/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/hpack/TestFifoBuffer.java
index c4ec0fe..fbf365e 100644
--- a/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/hpack/TestFifoBuffer.java
+++ b/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/hpack/TestFifoBuffer.java
@@ -27,8 +27,8 @@
package org.apache.hc.core5.http2.hpack;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestFifoBuffer {
@@ -43,47 +43,47 @@ public class TestFifoBuffer {
final HPackHeader h4 = new HPackHeader("h", "4");
for (int i = 0; i < 20; i++) {
- Assert.assertEquals(0, fifoBuffer.size());
- Assert.assertSame(null, fifoBuffer.getFirst());
- Assert.assertSame(null, fifoBuffer.getLast());
+ Assertions.assertEquals(0, fifoBuffer.size());
+ Assertions.assertSame(null, fifoBuffer.getFirst());
+ Assertions.assertSame(null, fifoBuffer.getLast());
fifoBuffer.addFirst(h1);
- Assert.assertSame(h1, fifoBuffer.getFirst());
- Assert.assertSame(h1, fifoBuffer.getLast());
- Assert.assertEquals(1, fifoBuffer.size());
+ Assertions.assertSame(h1, fifoBuffer.getFirst());
+ Assertions.assertSame(h1, fifoBuffer.getLast());
+ Assertions.assertEquals(1, fifoBuffer.size());
fifoBuffer.addFirst(h2);
- Assert.assertEquals(2, fifoBuffer.size());
- Assert.assertSame(h2, fifoBuffer.getFirst());
- Assert.assertSame(h1, fifoBuffer.getLast());
+ Assertions.assertEquals(2, fifoBuffer.size());
+ Assertions.assertSame(h2, fifoBuffer.getFirst());
+ Assertions.assertSame(h1, fifoBuffer.getLast());
fifoBuffer.addFirst(h3);
- Assert.assertEquals(3, fifoBuffer.size());
- Assert.assertSame(h3, fifoBuffer.getFirst());
- Assert.assertSame(h1, fifoBuffer.getLast());
+ Assertions.assertEquals(3, fifoBuffer.size());
+ Assertions.assertSame(h3, fifoBuffer.getFirst());
+ Assertions.assertSame(h1, fifoBuffer.getLast());
fifoBuffer.addFirst(h4);
- Assert.assertEquals(4, fifoBuffer.size());
- Assert.assertSame(h4, fifoBuffer.getFirst());
- Assert.assertSame(h1, fifoBuffer.getLast());
+ Assertions.assertEquals(4, fifoBuffer.size());
+ Assertions.assertSame(h4, fifoBuffer.getFirst());
+ Assertions.assertSame(h1, fifoBuffer.getLast());
- Assert.assertSame(h4, fifoBuffer.get(0));
- Assert.assertSame(h3, fifoBuffer.get(1));
- Assert.assertSame(h2, fifoBuffer.get(2));
- Assert.assertSame(h1, fifoBuffer.get(3));
+ Assertions.assertSame(h4, fifoBuffer.get(0));
+ Assertions.assertSame(h3, fifoBuffer.get(1));
+ Assertions.assertSame(h2, fifoBuffer.get(2));
+ Assertions.assertSame(h1, fifoBuffer.get(3));
fifoBuffer.removeLast();
- Assert.assertEquals(3, fifoBuffer.size());
- Assert.assertSame(h4, fifoBuffer.getFirst());
- Assert.assertSame(h2, fifoBuffer.getLast());
+ Assertions.assertEquals(3, fifoBuffer.size());
+ Assertions.assertSame(h4, fifoBuffer.getFirst());
+ Assertions.assertSame(h2, fifoBuffer.getLast());
fifoBuffer.removeLast();
- Assert.assertEquals(2, fifoBuffer.size());
- Assert.assertSame(h4, fifoBuffer.getFirst());
- Assert.assertSame(h3, fifoBuffer.getLast());
+ Assertions.assertEquals(2, fifoBuffer.size());
+ Assertions.assertSame(h4, fifoBuffer.getFirst());
+ Assertions.assertSame(h3, fifoBuffer.getLast());
fifoBuffer.removeLast();
- Assert.assertEquals(1, fifoBuffer.size());
- Assert.assertSame(h4, fifoBuffer.getFirst());
- Assert.assertSame(h4, fifoBuffer.getLast());
+ Assertions.assertEquals(1, fifoBuffer.size());
+ Assertions.assertSame(h4, fifoBuffer.getFirst());
+ Assertions.assertSame(h4, fifoBuffer.getLast());
fifoBuffer.removeLast();
- Assert.assertEquals(0, fifoBuffer.size());
- Assert.assertSame(null, fifoBuffer.getFirst());
- Assert.assertSame(null, fifoBuffer.getLast());
+ Assertions.assertEquals(0, fifoBuffer.size());
+ Assertions.assertSame(null, fifoBuffer.getFirst());
+ Assertions.assertSame(null, fifoBuffer.getLast());
}
}
@@ -105,30 +105,30 @@ public class TestFifoBuffer {
fifoBuffer.removeLast();
}
- Assert.assertEquals(0, fifoBuffer.size());
- Assert.assertSame(null, fifoBuffer.getFirst());
- Assert.assertSame(null, fifoBuffer.getLast());
+ Assertions.assertEquals(0, fifoBuffer.size());
+ Assertions.assertSame(null, fifoBuffer.getFirst());
+ Assertions.assertSame(null, fifoBuffer.getLast());
fifoBuffer.addFirst(h1);
- Assert.assertSame(h1, fifoBuffer.getFirst());
- Assert.assertSame(h1, fifoBuffer.getLast());
- Assert.assertEquals(1, fifoBuffer.size());
+ Assertions.assertSame(h1, fifoBuffer.getFirst());
+ Assertions.assertSame(h1, fifoBuffer.getLast());
+ Assertions.assertEquals(1, fifoBuffer.size());
fifoBuffer.addFirst(h2);
- Assert.assertEquals(2, fifoBuffer.size());
- Assert.assertSame(h2, fifoBuffer.getFirst());
- Assert.assertSame(h1, fifoBuffer.getLast());
+ Assertions.assertEquals(2, fifoBuffer.size());
+ Assertions.assertSame(h2, fifoBuffer.getFirst());
+ Assertions.assertSame(h1, fifoBuffer.getLast());
fifoBuffer.addFirst(h3);
- Assert.assertEquals(3, fifoBuffer.size());
- Assert.assertSame(h3, fifoBuffer.getFirst());
- Assert.assertSame(h1, fifoBuffer.getLast());
+ Assertions.assertEquals(3, fifoBuffer.size());
+ Assertions.assertSame(h3, fifoBuffer.getFirst());
+ Assertions.assertSame(h1, fifoBuffer.getLast());
fifoBuffer.addFirst(h4);
- Assert.assertEquals(4, fifoBuffer.size());
- Assert.assertSame(h4, fifoBuffer.getFirst());
- Assert.assertSame(h1, fifoBuffer.getLast());
-
- Assert.assertSame(h4, fifoBuffer.get(0));
- Assert.assertSame(h3, fifoBuffer.get(1));
- Assert.assertSame(h2, fifoBuffer.get(2));
- Assert.assertSame(h1, fifoBuffer.get(3));
+ Assertions.assertEquals(4, fifoBuffer.size());
+ Assertions.assertSame(h4, fifoBuffer.getFirst());
+ Assertions.assertSame(h1, fifoBuffer.getLast());
+
+ Assertions.assertSame(h4, fifoBuffer.get(0));
+ Assertions.assertSame(h3, fifoBuffer.get(1));
+ Assertions.assertSame(h2, fifoBuffer.get(2));
+ Assertions.assertSame(h1, fifoBuffer.get(3));
}
}
diff --git a/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/hpack/TestFifoLinkedList.java b/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/hpack/TestFifoLinkedList.java
index 4e825ce..ea31a58 100644
--- a/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/hpack/TestFifoLinkedList.java
+++ b/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/hpack/TestFifoLinkedList.java
@@ -27,8 +27,8 @@
package org.apache.hc.core5.http2.hpack;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestFifoLinkedList {
@@ -43,49 +43,49 @@ public class TestFifoLinkedList {
final HPackHeader h4 = new HPackHeader("h", "4");
for (int i = 0; i < 5; i++) {
- Assert.assertEquals(0, fifoLinkedList.size());
- Assert.assertSame(null, fifoLinkedList.getFirst());
- Assert.assertSame(null, fifoLinkedList.getLast());
+ Assertions.assertEquals(0, fifoLinkedList.size());
+ Assertions.assertSame(null, fifoLinkedList.getFirst());
+ Assertions.assertSame(null, fifoLinkedList.getLast());
fifoLinkedList.addFirst(h1);
- Assert.assertEquals(1, fifoLinkedList.size());
- Assert.assertSame(h1, fifoLinkedList.getFirst());
- Assert.assertSame(h1, fifoLinkedList.getLast());
+ Assertions.assertEquals(1, fifoLinkedList.size());
+ Assertions.assertSame(h1, fifoLinkedList.getFirst());
+ Assertions.assertSame(h1, fifoLinkedList.getLast());
fifoLinkedList.addFirst(h2);
- Assert.assertEquals(2, fifoLinkedList.size());
- Assert.assertSame(h2, fifoLinkedList.getFirst());
- Assert.assertSame(h1, fifoLinkedList.getLast());
+ Assertions.assertEquals(2, fifoLinkedList.size());
+ Assertions.assertSame(h2, fifoLinkedList.getFirst());
+ Assertions.assertSame(h1, fifoLinkedList.getLast());
fifoLinkedList.addFirst(h3);
- Assert.assertEquals(3, fifoLinkedList.size());
- Assert.assertSame(h3, fifoLinkedList.getFirst());
- Assert.assertSame(h1, fifoLinkedList.getLast());
+ Assertions.assertEquals(3, fifoLinkedList.size());
+ Assertions.assertSame(h3, fifoLinkedList.getFirst());
+ Assertions.assertSame(h1, fifoLinkedList.getLast());
fifoLinkedList.addFirst(h4);
- Assert.assertEquals(4, fifoLinkedList.size());
- Assert.assertSame(h4, fifoLinkedList.getFirst());
- Assert.assertSame(h1, fifoLinkedList.getLast());
+ Assertions.assertEquals(4, fifoLinkedList.size());
+ Assertions.assertSame(h4, fifoLinkedList.getFirst());
+ Assertions.assertSame(h1, fifoLinkedList.getLast());
fifoLinkedList.removeLast();
- Assert.assertEquals(3, fifoLinkedList.size());
- Assert.assertSame(h4, fifoLinkedList.getFirst());
- Assert.assertSame(h2, fifoLinkedList.getLast());
+ Assertions.assertEquals(3, fifoLinkedList.size());
+ Assertions.assertSame(h4, fifoLinkedList.getFirst());
+ Assertions.assertSame(h2, fifoLinkedList.getLast());
fifoLinkedList.removeLast();
- Assert.assertEquals(2, fifoLinkedList.size());
- Assert.assertSame(h4, fifoLinkedList.getFirst());
- Assert.assertSame(h3, fifoLinkedList.getLast());
+ Assertions.assertEquals(2, fifoLinkedList.size());
+ Assertions.assertSame(h4, fifoLinkedList.getFirst());
+ Assertions.assertSame(h3, fifoLinkedList.getLast());
fifoLinkedList.removeLast();
- Assert.assertEquals(1, fifoLinkedList.size());
- Assert.assertSame(h4, fifoLinkedList.getFirst());
- Assert.assertSame(h4, fifoLinkedList.getLast());
+ Assertions.assertEquals(1, fifoLinkedList.size());
+ Assertions.assertSame(h4, fifoLinkedList.getFirst());
+ Assertions.assertSame(h4, fifoLinkedList.getLast());
fifoLinkedList.removeLast();
- Assert.assertEquals(0, fifoLinkedList.size());
- Assert.assertSame(null, fifoLinkedList.getFirst());
- Assert.assertSame(null, fifoLinkedList.getLast());
+ Assertions.assertEquals(0, fifoLinkedList.size());
+ Assertions.assertSame(null, fifoLinkedList.getFirst());
+ Assertions.assertSame(null, fifoLinkedList.getLast());
}
}
@@ -104,58 +104,58 @@ public class TestFifoLinkedList {
final FifoLinkedList.InternalNode node3 = fifoLinkedList.addFirst(h3);
final FifoLinkedList.InternalNode node4 = fifoLinkedList.addFirst(h4);
- Assert.assertEquals(0, fifoLinkedList.getIndex(node4));
- Assert.assertEquals(1, fifoLinkedList.getIndex(node3));
- Assert.assertEquals(2, fifoLinkedList.getIndex(node2));
- Assert.assertEquals(3, fifoLinkedList.getIndex(node1));
+ Assertions.assertEquals(0, fifoLinkedList.getIndex(node4));
+ Assertions.assertEquals(1, fifoLinkedList.getIndex(node3));
+ Assertions.assertEquals(2, fifoLinkedList.getIndex(node2));
+ Assertions.assertEquals(3, fifoLinkedList.getIndex(node1));
- Assert.assertEquals(4, fifoLinkedList.size());
- Assert.assertSame(h4, fifoLinkedList.get(0));
- Assert.assertSame(h3, fifoLinkedList.get(1));
- Assert.assertSame(h2, fifoLinkedList.get(2));
- Assert.assertSame(h1, fifoLinkedList.get(3));
+ Assertions.assertEquals(4, fifoLinkedList.size());
+ Assertions.assertSame(h4, fifoLinkedList.get(0));
+ Assertions.assertSame(h3, fifoLinkedList.get(1));
+ Assertions.assertSame(h2, fifoLinkedList.get(2));
+ Assertions.assertSame(h1, fifoLinkedList.get(3));
fifoLinkedList.removeLast();
- Assert.assertEquals(0, fifoLinkedList.getIndex(node4));
- Assert.assertEquals(1, fifoLinkedList.getIndex(node3));
- Assert.assertEquals(2, fifoLinkedList.getIndex(node2));
- Assert.assertEquals(-1, fifoLinkedList.getIndex(node1));
+ Assertions.assertEquals(0, fifoLinkedList.getIndex(node4));
+ Assertions.assertEquals(1, fifoLinkedList.getIndex(node3));
+ Assertions.assertEquals(2, fifoLinkedList.getIndex(node2));
+ Assertions.assertEquals(-1, fifoLinkedList.getIndex(node1));
- Assert.assertEquals(3, fifoLinkedList.size());
- Assert.assertSame(h4, fifoLinkedList.get(0));
- Assert.assertSame(h3, fifoLinkedList.get(1));
- Assert.assertSame(h2, fifoLinkedList.get(2));
+ Assertions.assertEquals(3, fifoLinkedList.size());
+ Assertions.assertSame(h4, fifoLinkedList.get(0));
+ Assertions.assertSame(h3, fifoLinkedList.get(1));
+ Assertions.assertSame(h2, fifoLinkedList.get(2));
fifoLinkedList.removeLast();
- Assert.assertEquals(0, fifoLinkedList.getIndex(node4));
- Assert.assertEquals(1, fifoLinkedList.getIndex(node3));
- Assert.assertEquals(-1, fifoLinkedList.getIndex(node2));
- Assert.assertEquals(-1, fifoLinkedList.getIndex(node1));
+ Assertions.assertEquals(0, fifoLinkedList.getIndex(node4));
+ Assertions.assertEquals(1, fifoLinkedList.getIndex(node3));
+ Assertions.assertEquals(-1, fifoLinkedList.getIndex(node2));
+ Assertions.assertEquals(-1, fifoLinkedList.getIndex(node1));
- Assert.assertEquals(2, fifoLinkedList.size());
- Assert.assertSame(h4, fifoLinkedList.get(0));
- Assert.assertSame(h3, fifoLinkedList.get(1));
+ Assertions.assertEquals(2, fifoLinkedList.size());
+ Assertions.assertSame(h4, fifoLinkedList.get(0));
+ Assertions.assertSame(h3, fifoLinkedList.get(1));
fifoLinkedList.removeLast();
- Assert.assertEquals(0, fifoLinkedList.getIndex(node4));
- Assert.assertEquals(-1, fifoLinkedList.getIndex(node3));
- Assert.assertEquals(-1, fifoLinkedList.getIndex(node2));
- Assert.assertEquals(-1, fifoLinkedList.getIndex(node1));
+ Assertions.assertEquals(0, fifoLinkedList.getIndex(node4));
+ Assertions.assertEquals(-1, fifoLinkedList.getIndex(node3));
+ Assertions.assertEquals(-1, fifoLinkedList.getIndex(node2));
+ Assertions.assertEquals(-1, fifoLinkedList.getIndex(node1));
- Assert.assertEquals(1, fifoLinkedList.size());
- Assert.assertSame(h4, fifoLinkedList.get(0));
+ Assertions.assertEquals(1, fifoLinkedList.size());
+ Assertions.assertSame(h4, fifoLinkedList.get(0));
fifoLinkedList.removeLast();
- Assert.assertEquals(-1, fifoLinkedList.getIndex(node4));
- Assert.assertEquals(-1, fifoLinkedList.getIndex(node3));
- Assert.assertEquals(-1, fifoLinkedList.getIndex(node2));
- Assert.assertEquals(-1, fifoLinkedList.getIndex(node1));
+ Assertions.assertEquals(-1, fifoLinkedList.getIndex(node4));
+ Assertions.assertEquals(-1, fifoLinkedList.getIndex(node3));
+ Assertions.assertEquals(-1, fifoLinkedList.getIndex(node2));
+ Assertions.assertEquals(-1, fifoLinkedList.getIndex(node1));
- Assert.assertEquals(0, fifoLinkedList.size());
+ Assertions.assertEquals(0, fifoLinkedList.size());
}
}
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 85798e6..7674b53 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,6 +27,8 @@
package org.apache.hc.core5.http2.hpack;
+import static org.hamcrest.MatcherAssert.assertThat;
+
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
@@ -37,9 +39,8 @@ 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 org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestHPackCoding {
@@ -49,21 +50,21 @@ public class TestHPackCoding {
final ByteArrayBuffer buffer = new ByteArrayBuffer(16);
HPackEncoder.encodeInt(buffer, 5, 10, 0x0);
- Assert.assertEquals(1, buffer.length());
- Assert.assertEquals(0b00001010, buffer.byteAt(0) & 0xFF);
+ Assertions.assertEquals(1, buffer.length());
+ Assertions.assertEquals(0b00001010, buffer.byteAt(0) & 0xFF);
buffer.clear();
HPackEncoder.encodeInt(buffer, 5, 1337, 0x0);
- Assert.assertEquals(3, buffer.length());
- Assert.assertEquals(0b00011111, buffer.byteAt(0) & 0xFF);
- Assert.assertEquals(0b10011010, buffer.byteAt(1) & 0xFF);
- Assert.assertEquals(0b00001010, buffer.byteAt(2) & 0xFF);
+ Assertions.assertEquals(3, buffer.length());
+ Assertions.assertEquals(0b00011111, buffer.byteAt(0) & 0xFF);
+ Assertions.assertEquals(0b10011010, buffer.byteAt(1) & 0xFF);
+ Assertions.assertEquals(0b00001010, buffer.byteAt(2) & 0xFF);
buffer.clear();
HPackEncoder.encodeInt(buffer, 8, 42, 0x0);
- Assert.assertEquals(1, buffer.length());
- Assert.assertEquals(0b00101010, buffer.byteAt(0) & 0xFF);
+ Assertions.assertEquals(1, buffer.length());
+ Assertions.assertEquals(0b00101010, buffer.byteAt(0) & 0xFF);
}
static ByteBuffer wrap(final ByteArrayBuffer src) {
@@ -90,17 +91,17 @@ public class TestHPackCoding {
buffer.clear();
HPackEncoder.encodeInt(buffer, n, 10, 0x0);
- Assert.assertEquals(10, HPackDecoder.decodeInt(wrap(buffer), n));
+ Assertions.assertEquals(10, HPackDecoder.decodeInt(wrap(buffer), n));
buffer.clear();
HPackEncoder.encodeInt(buffer, n, 123456, 0x0);
- Assert.assertEquals(123456, HPackDecoder.decodeInt(wrap(buffer), n));
+ Assertions.assertEquals(123456, HPackDecoder.decodeInt(wrap(buffer), n));
buffer.clear();
HPackEncoder.encodeInt(buffer, n, Integer.MAX_VALUE, 0x0);
- Assert.assertEquals(Integer.MAX_VALUE, HPackDecoder.decodeInt(wrap(buffer), n));
+ Assertions.assertEquals(Integer.MAX_VALUE, HPackDecoder.decodeInt(wrap(buffer), n));
}
}
@@ -109,7 +110,7 @@ public class TestHPackCoding {
public void testIntegerCodingLimit() throws Exception {
final ByteBuffer src1 = createByteBuffer(0x7f, 0x80, 0xff, 0xff, 0xff, 0x07);
- Assert.assertEquals(Integer.MAX_VALUE, HPackDecoder.decodeInt(src1, 7));
+ Assertions.assertEquals(Integer.MAX_VALUE, HPackDecoder.decodeInt(src1, 7));
final ByteBuffer src2 = createByteBuffer(0x7f, 0x80, 0xff, 0xff, 0xff, 0x08);
try {
@@ -141,8 +142,8 @@ public class TestHPackCoding {
final ByteArrayBuffer buffer = new ByteArrayBuffer(16);
HPackDecoder.decodePlainString(buffer, src);
- Assert.assertEquals("custom-key", new String(buffer.array(), 0, buffer.length(), StandardCharsets.US_ASCII));
- Assert.assertFalse("Decoding completed", src.hasRemaining());
+ Assertions.assertEquals("custom-key", new String(buffer.array(), 0, buffer.length(), StandardCharsets.US_ASCII));
+ Assertions.assertFalse(src.hasRemaining(), "Decoding completed");
}
@Test
@@ -153,8 +154,8 @@ public class TestHPackCoding {
final ByteArrayBuffer buffer = new ByteArrayBuffer(16);
HPackDecoder.decodePlainString(buffer, src);
- Assert.assertEquals("custom-key", new String(buffer.array(), 0, buffer.length(), StandardCharsets.US_ASCII));
- Assert.assertEquals(4, src.remaining());
+ Assertions.assertEquals(new String(buffer.array(), 0, buffer.length(), StandardCharsets.US_ASCII), "custom-key");
+ Assertions.assertEquals(4, src.remaining());
}
@Test
@@ -166,8 +167,8 @@ public class TestHPackCoding {
final ByteBuffer srcRO = src.asReadOnlyBuffer();
final ByteArrayBuffer buffer = new ByteArrayBuffer(16);
HPackDecoder.decodePlainString(buffer, srcRO);
- Assert.assertEquals("custom-key", new String(buffer.array(), 0, buffer.length(), StandardCharsets.US_ASCII));
- Assert.assertEquals(4, srcRO.remaining());
+ Assertions.assertEquals("custom-key", new String(buffer.array(), 0, buffer.length(), StandardCharsets.US_ASCII));
+ Assertions.assertEquals(4, srcRO.remaining());
}
@Test
@@ -177,7 +178,7 @@ public class TestHPackCoding {
0x0a, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x2d, 0x6b, 0x65);
final ByteArrayBuffer buffer = new ByteArrayBuffer(16);
- Assert.assertThrows(HPackException.class, () -> HPackDecoder.decodePlainString(buffer, src));
+ Assertions.assertThrows(HPackException.class, () -> HPackDecoder.decodePlainString(buffer, src));
}
@Test
@@ -187,8 +188,8 @@ public class TestHPackCoding {
final ByteArrayBuffer buffer = new ByteArrayBuffer(16);
HPackDecoder.decodeHuffman(buffer, src);
- Assert.assertEquals("www.example.com", new String(buffer.array(), 0, buffer.length(), StandardCharsets.US_ASCII));
- Assert.assertFalse("Decoding completed", src.hasRemaining());
+ Assertions.assertEquals(new String(buffer.array(), 0, buffer.length(), StandardCharsets.US_ASCII), "www.example.com");
+ Assertions.assertFalse(src.hasRemaining(), "Decoding completed");
}
private static ByteBuffer createByteBuffer(final String s, final Charset charset) {
@@ -202,7 +203,7 @@ public class TestHPackCoding {
HPackEncoder.encodeHuffman(buffer, createByteBuffer("www.example.com", StandardCharsets.US_ASCII));
final ByteBuffer expected = createByteBuffer(
0xf1, 0xe3, 0xc2, 0xe5, 0xf2, 0x3a, 0x6b, 0xa0, 0xab, 0x90, 0xf4, 0xff);
- Assert.assertArrayEquals(toArray(expected), buffer.toByteArray());
+ Assertions.assertArrayEquals(toArray(expected), buffer.toByteArray());
}
@Test
@@ -216,13 +217,13 @@ public class TestHPackCoding {
final StringBuilder strBuf = new StringBuilder();
decoder.decodeString(wrap(buffer), strBuf);
- Assert.assertEquals("this and that", strBuf.toString());
+ Assertions.assertEquals("this and that", strBuf.toString());
buffer.clear();
strBuf.setLength(0);
encoder.encodeString(buffer, "this and that and Huffman", true);
decoder.decodeString(wrap(buffer), strBuf);
- Assert.assertEquals("this and that and Huffman", strBuf.toString());
+ Assertions.assertEquals("this and that and Huffman", strBuf.toString());
}
static final int SWISS_GERMAN_HELLO[] = {
@@ -269,7 +270,7 @@ public class TestHPackCoding {
strBuf.setLength(0);
decoder.decodeString(wrap(buffer), strBuf);
final String helloBack = strBuf.toString();
- Assert.assertEquals("charset: " + charset + "; huffman: " + b, hello, helloBack);
+ Assertions.assertEquals(hello, helloBack, "charset: " + charset + "; huffman: " + b);
}
}
}
@@ -297,7 +298,7 @@ public class TestHPackCoding {
encoder.encodeString(buffer, hello, b);
decoder.decodeString(wrap(buffer), strBuf);
final String helloBack = strBuf.toString();
- Assert.assertEquals("charset: " + charset + "; huffman: " + b, hello, helloBack);
+ Assertions.assertEquals(hello, helloBack, "charset: " + charset + "; huffman: " + b);
}
}
}
@@ -305,10 +306,10 @@ public class TestHPackCoding {
private static void assertHeaderEquals(final Header expected, final Header actual) {
- Assert.assertNotNull(actual);
- Assert.assertEquals("Header name", expected.getName(), actual.getName());
- Assert.assertEquals("Header value", expected.getValue(), actual.getValue());
- Assert.assertEquals("Header sensitive flag", expected.isSensitive(), actual.isSensitive());
+ Assertions.assertNotNull(actual);
+ Assertions.assertEquals(expected.getName(), actual.getName(), "Header name");
+ Assertions.assertEquals(expected.getValue(), actual.getValue(), "Header value");
+ Assertions.assertEquals(expected.isSensitive(), actual.isSensitive(), "Header sensitive flag");
}
@Test
@@ -322,9 +323,9 @@ public class TestHPackCoding {
final HPackDecoder decoder = new HPackDecoder(dynamicTable, StandardCharsets.US_ASCII);
final Header header = decoder.decodeLiteralHeader(src, HPackRepresentation.WITH_INDEXING);
assertHeaderEquals(new BasicHeader("custom-key", "custom-header"), header);
- Assert.assertFalse("Decoding completed", src.hasRemaining());
+ Assertions.assertFalse(src.hasRemaining(), "Decoding completed");
- Assert.assertEquals(1, dynamicTable.dynamicLength());
+ Assertions.assertEquals(1, dynamicTable.dynamicLength());
assertHeaderEquals(header, dynamicTable.getDynamicEntry(0));
}
@@ -338,9 +339,9 @@ public class TestHPackCoding {
final HPackDecoder decoder = new HPackDecoder(dynamicTable, StandardCharsets.US_ASCII);
final Header header = decoder.decodeLiteralHeader(src, HPackRepresentation.WITHOUT_INDEXING);
assertHeaderEquals(new BasicHeader(":path", "/sample/path"), header);
- Assert.assertFalse("Decoding completed", src.hasRemaining());
+ Assertions.assertFalse(src.hasRemaining(), "Decoding completed");
- Assert.assertEquals(0, dynamicTable.dynamicLength());
+ Assertions.assertEquals(0, dynamicTable.dynamicLength());
}
@Test
@@ -353,9 +354,9 @@ public class TestHPackCoding {
final HPackDecoder decoder = new HPackDecoder(dynamicTable, StandardCharsets.US_ASCII);
final Header header = decoder.decodeLiteralHeader(src, HPackRepresentation.NEVER_INDEXED);
assertHeaderEquals(new BasicHeader("password", "secret", true), header);
- Assert.assertFalse("Decoding completed", src.hasRemaining());
+ Assertions.assertFalse(src.hasRemaining(), "Decoding completed");
- Assert.assertEquals(0, dynamicTable.dynamicLength());
+ Assertions.assertEquals(0, dynamicTable.dynamicLength());
}
@Test
@@ -367,9 +368,9 @@ public class TestHPackCoding {
final HPackDecoder decoder = new HPackDecoder(dynamicTable, StandardCharsets.US_ASCII);
final Header header = decoder.decodeIndexedHeader(src);
assertHeaderEquals(new BasicHeader(":method", "GET"), header);
- Assert.assertFalse("Decoding completed", src.hasRemaining());
+ Assertions.assertFalse(src.hasRemaining(), "Decoding completed");
- Assert.assertEquals(0, dynamicTable.dynamicLength());
+ Assertions.assertEquals(0, dynamicTable.dynamicLength());
}
@Test
@@ -383,32 +384,32 @@ public class TestHPackCoding {
final HPackDecoder decoder = new HPackDecoder(dynamicTable, StandardCharsets.US_ASCII);
final List<Header> headers1 = decoder.decodeHeaders(src1);
- Assert.assertEquals(4, headers1.size());
+ Assertions.assertEquals(4, headers1.size());
assertHeaderEquals(new BasicHeader(":method", "GET"), headers1.get(0));
assertHeaderEquals(new BasicHeader(":scheme", "http"), headers1.get(1));
assertHeaderEquals(new BasicHeader(":path", "/"), headers1.get(2));
assertHeaderEquals(new BasicHeader(":authority", "www.example.com"), headers1.get(3));
- Assert.assertEquals(1, dynamicTable.dynamicLength());
+ Assertions.assertEquals(1, dynamicTable.dynamicLength());
assertHeaderEquals(new BasicHeader(":authority", "www.example.com"), dynamicTable.getDynamicEntry(0));
- Assert.assertEquals(57, dynamicTable.getCurrentSize());
+ Assertions.assertEquals(57, dynamicTable.getCurrentSize());
final ByteBuffer src2 = createByteBuffer(
0x82, 0x86, 0x84, 0xbe, 0x58, 0x08, 0x6e, 0x6f, 0x2d, 0x63, 0x61, 0x63, 0x68, 0x65);
final List<Header> headers2 = decoder.decodeHeaders(src2);
- Assert.assertEquals(5, headers2.size());
+ Assertions.assertEquals(5, headers2.size());
assertHeaderEquals(new BasicHeader(":method", "GET"), headers2.get(0));
assertHeaderEquals(new BasicHeader(":scheme", "http"), headers2.get(1));
assertHeaderEquals(new BasicHeader(":path", "/"), headers2.get(2));
assertHeaderEquals(new BasicHeader(":authority", "www.example.com"), headers2.get(3));
assertHeaderEquals(new BasicHeader("cache-control", "no-cache"), headers2.get(4));
- Assert.assertEquals(2, dynamicTable.dynamicLength());
+ Assertions.assertEquals(2, dynamicTable.dynamicLength());
assertHeaderEquals(new BasicHeader("cache-control", "no-cache"), dynamicTable.getDynamicEntry(0));
assertHeaderEquals(new BasicHeader(":authority", "www.example.com"), dynamicTable.getDynamicEntry(1));
- Assert.assertEquals(110, dynamicTable.getCurrentSize());
+ Assertions.assertEquals(110, dynamicTable.getCurrentSize());
final ByteBuffer src3 = createByteBuffer(
0x82, 0x87, 0x85, 0xbf, 0x40, 0x0a, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x2d, 0x6b, 0x65, 0x79,
@@ -416,18 +417,18 @@ public class TestHPackCoding {
final List<Header> headers3 = decoder.decodeHeaders(src3);
- Assert.assertEquals(5, headers3.size());
+ Assertions.assertEquals(5, headers3.size());
assertHeaderEquals(new BasicHeader(":method", "GET"), headers3.get(0));
assertHeaderEquals(new BasicHeader(":scheme", "https"), headers3.get(1));
assertHeaderEquals(new BasicHeader(":path", "/index.html"), headers3.get(2));
assertHeaderEquals(new BasicHeader(":authority", "www.example.com"), headers3.get(3));
assertHeaderEquals(new BasicHeader("custom-key", "custom-value"), headers3.get(4));
- Assert.assertEquals(3, dynamicTable.dynamicLength());
+ Assertions.assertEquals(3, dynamicTable.dynamicLength());
assertHeaderEquals(new BasicHeader("custom-key", "custom-value"), dynamicTable.getDynamicEntry(0));
assertHeaderEquals(new BasicHeader("cache-control", "no-cache"), dynamicTable.getDynamicEntry(1));
assertHeaderEquals(new BasicHeader(":authority", "www.example.com"), dynamicTable.getDynamicEntry(2));
- Assert.assertEquals(164, dynamicTable.getCurrentSize());
+ Assertions.assertEquals(164, dynamicTable.getCurrentSize());
}
@Test
@@ -440,32 +441,32 @@ public class TestHPackCoding {
final HPackDecoder decoder = new HPackDecoder(dynamicTable, StandardCharsets.US_ASCII);
final List<Header> headers1 = decoder.decodeHeaders(src1);
- Assert.assertEquals(4, headers1.size());
+ Assertions.assertEquals(4, headers1.size());
assertHeaderEquals(new BasicHeader(":method", "GET"), headers1.get(0));
assertHeaderEquals(new BasicHeader(":scheme", "http"), headers1.get(1));
assertHeaderEquals(new BasicHeader(":path", "/"), headers1.get(2));
assertHeaderEquals(new BasicHeader(":authority", "www.example.com"), headers1.get(3));
- Assert.assertEquals(1, dynamicTable.dynamicLength());
+ Assertions.assertEquals(1, dynamicTable.dynamicLength());
assertHeaderEquals(new BasicHeader(":authority", "www.example.com"), dynamicTable.getDynamicEntry(0));
- Assert.assertEquals(57, dynamicTable.getCurrentSize());
+ Assertions.assertEquals(57, dynamicTable.getCurrentSize());
final ByteBuffer src2 = createByteBuffer(
0x82, 0x86, 0x84, 0xbe, 0x58, 0x86, 0xa8, 0xeb, 0x10, 0x64, 0x9c, 0xbf);
final List<Header> headers2 = decoder.decodeHeaders(src2);
- Assert.assertEquals(5, headers2.size());
+ Assertions.assertEquals(5, headers2.size());
assertHeaderEquals(new BasicHeader(":method", "GET"), headers2.get(0));
assertHeaderEquals(new BasicHeader(":scheme", "http"), headers2.get(1));
assertHeaderEquals(new BasicHeader(":path", "/"), headers2.get(2));
assertHeaderEquals(new BasicHeader(":authority", "www.example.com"), headers2.get(3));
assertHeaderEquals(new BasicHeader("cache-control", "no-cache"), headers2.get(4));
- Assert.assertEquals(2, dynamicTable.dynamicLength());
+ Assertions.assertEquals(2, dynamicTable.dynamicLength());
assertHeaderEquals(new BasicHeader("cache-control", "no-cache"), dynamicTable.getDynamicEntry(0));
assertHeaderEquals(new BasicHeader(":authority", "www.example.com"), dynamicTable.getDynamicEntry(1));
- Assert.assertEquals(110, dynamicTable.getCurrentSize());
+ Assertions.assertEquals(110, dynamicTable.getCurrentSize());
final ByteBuffer src3 = createByteBuffer(
0x82, 0x87, 0x85, 0xbf, 0x40, 0x88, 0x25, 0xa8, 0x49, 0xe9, 0x5b, 0xa9, 0x7d, 0x7f, 0x89, 0x25,
@@ -473,18 +474,18 @@ public class TestHPackCoding {
final List<Header> headers3 = decoder.decodeHeaders(src3);
- Assert.assertEquals(5, headers3.size());
+ Assertions.assertEquals(5, headers3.size());
assertHeaderEquals(new BasicHeader(":method", "GET"), headers3.get(0));
assertHeaderEquals(new BasicHeader(":scheme", "https"), headers3.get(1));
assertHeaderEquals(new BasicHeader(":path", "/index.html"), headers3.get(2));
assertHeaderEquals(new BasicHeader(":authority", "www.example.com"), headers3.get(3));
assertHeaderEquals(new BasicHeader("custom-key", "custom-value"), headers3.get(4));
- Assert.assertEquals(3, dynamicTable.dynamicLength());
+ Assertions.assertEquals(3, dynamicTable.dynamicLength());
assertHeaderEquals(new BasicHeader("custom-key", "custom-value"), dynamicTable.getDynamicEntry(0));
assertHeaderEquals(new BasicHeader("cache-control", "no-cache"), dynamicTable.getDynamicEntry(1));
assertHeaderEquals(new BasicHeader(":authority", "www.example.com"), dynamicTable.getDynamicEntry(2));
- Assert.assertEquals(164, dynamicTable.getCurrentSize());
+ Assertions.assertEquals(164, dynamicTable.getCurrentSize());
}
@Test
@@ -502,37 +503,37 @@ public class TestHPackCoding {
final HPackDecoder decoder = new HPackDecoder(dynamicTable, StandardCharsets.US_ASCII);
final List<Header> headers1 = decoder.decodeHeaders(src1);
- Assert.assertEquals(4, headers1.size());
+ Assertions.assertEquals(4, headers1.size());
assertHeaderEquals(new BasicHeader(":status", "302"), headers1.get(0));
assertHeaderEquals(new BasicHeader("cache-control", "private"), headers1.get(1));
assertHeaderEquals(new BasicHeader("date", "Mon, 21 Oct 2013 20:13:21 GMT"), headers1.get(2));
assertHeaderEquals(new BasicHeader("location", "https://www.example.com"), headers1.get(3));
- Assert.assertEquals(4, dynamicTable.dynamicLength());
+ Assertions.assertEquals(4, dynamicTable.dynamicLength());
assertHeaderEquals(new BasicHeader("location", "https://www.example.com"), dynamicTable.getDynamicEntry(0));
assertHeaderEquals(new BasicHeader("date", "Mon, 21 Oct 2013 20:13:21 GMT"), dynamicTable.getDynamicEntry(1));
assertHeaderEquals(new BasicHeader("cache-control", "private"), dynamicTable.getDynamicEntry(2));
assertHeaderEquals(new BasicHeader(":status", "302"), dynamicTable.getDynamicEntry(3));
- Assert.assertEquals(222, dynamicTable.getCurrentSize());
+ Assertions.assertEquals(222, dynamicTable.getCurrentSize());
final ByteBuffer src2 = createByteBuffer(
0x48, 0x03, 0x33, 0x30, 0x37, 0xc1, 0xc0, 0xbf);
final List<Header> headers2 = decoder.decodeHeaders(src2);
- Assert.assertEquals(4, headers2.size());
+ Assertions.assertEquals(4, headers2.size());
assertHeaderEquals(new BasicHeader(":status", "307"), headers2.get(0));
assertHeaderEquals(new BasicHeader("cache-control", "private"), headers2.get(1));
assertHeaderEquals(new BasicHeader("date", "Mon, 21 Oct 2013 20:13:21 GMT"), headers2.get(2));
assertHeaderEquals(new BasicHeader("location", "https://www.example.com"), headers2.get(3));
- Assert.assertEquals(4, dynamicTable.dynamicLength());
+ Assertions.assertEquals(4, dynamicTable.dynamicLength());
assertHeaderEquals(new BasicHeader(":status", "307"), dynamicTable.getDynamicEntry(0));
assertHeaderEquals(new BasicHeader("location", "https://www.example.com"), dynamicTable.getDynamicEntry(1));
assertHeaderEquals(new BasicHeader("date", "Mon, 21 Oct 2013 20:13:21 GMT"), dynamicTable.getDynamicEntry(2));
assertHeaderEquals(new BasicHeader("cache-control", "private"), dynamicTable.getDynamicEntry(3));
- Assert.assertEquals(222, dynamicTable.getCurrentSize());
+ Assertions.assertEquals(222, dynamicTable.getCurrentSize());
final ByteBuffer src3 = createByteBuffer(
0x88, 0xc1, 0x61, 0x1d, 0x4d, 0x6f, 0x6e, 0x2c, 0x20, 0x32, 0x31, 0x20, 0x4f, 0x63, 0x74, 0x20, 0x32,
@@ -544,7 +545,7 @@ public class TestHPackCoding {
final List<Header> headers3 = decoder.decodeHeaders(src3);
- Assert.assertEquals(6, headers3.size());
+ Assertions.assertEquals(6, headers3.size());
assertHeaderEquals(new BasicHeader(":status", "200"), headers3.get(0));
assertHeaderEquals(new BasicHeader("cache-control", "private"), headers3.get(1));
assertHeaderEquals(new BasicHeader("date", "Mon, 21 Oct 2013 20:13:22 GMT"), headers3.get(2));
@@ -552,12 +553,12 @@ public class TestHPackCoding {
assertHeaderEquals(new BasicHeader("content-encoding", "gzip"), headers3.get(4));
assertHeaderEquals(new BasicHeader("set-cookie", "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1"), headers3.get(5));
- Assert.assertEquals(3, dynamicTable.dynamicLength());
+ Assertions.assertEquals(3, dynamicTable.dynamicLength());
assertHeaderEquals(new BasicHeader("set-cookie", "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1"), dynamicTable.getDynamicEntry(0));
assertHeaderEquals(new BasicHeader("content-encoding", "gzip"), dynamicTable.getDynamicEntry(1));
assertHeaderEquals(new BasicHeader("date", "Mon, 21 Oct 2013 20:13:22 GMT"), dynamicTable.getDynamicEntry(2));
- Assert.assertEquals(215, dynamicTable.getCurrentSize());
+ Assertions.assertEquals(215, dynamicTable.getCurrentSize());
}
@Test
@@ -574,37 +575,37 @@ public class TestHPackCoding {
final HPackDecoder decoder = new HPackDecoder(dynamicTable, StandardCharsets.US_ASCII);
final List<Header> headers1 = decoder.decodeHeaders(src1);
- Assert.assertEquals(4, headers1.size());
+ Assertions.assertEquals(4, headers1.size());
assertHeaderEquals(new BasicHeader(":status", "302"), headers1.get(0));
assertHeaderEquals(new BasicHeader("cache-control", "private"), headers1.get(1));
assertHeaderEquals(new BasicHeader("date", "Mon, 21 Oct 2013 20:13:21 GMT"), headers1.get(2));
assertHeaderEquals(new BasicHeader("location", "https://www.example.com"), headers1.get(3));
- Assert.assertEquals(4, dynamicTable.dynamicLength());
+ Assertions.assertEquals(4, dynamicTable.dynamicLength());
assertHeaderEquals(new BasicHeader("location", "https://www.example.com"), dynamicTable.getDynamicEntry(0));
assertHeaderEquals(new BasicHeader("date", "Mon, 21 Oct 2013 20:13:21 GMT"), dynamicTable.getDynamicEntry(1));
assertHeaderEquals(new BasicHeader("cache-control", "private"), dynamicTable.getDynamicEntry(2));
assertHeaderEquals(new BasicHeader(":status", "302"), dynamicTable.getDynamicEntry(3));
- Assert.assertEquals(222, dynamicTable.getCurrentSize());
+ Assertions.assertEquals(222, dynamicTable.getCurrentSize());
final ByteBuffer src2 = createByteBuffer(
0x48, 0x83, 0x64, 0x0e, 0xff, 0xc1, 0xc0, 0xbf);
final List<Header> headers2 = decoder.decodeHeaders(src2);
- Assert.assertEquals(4, headers2.size());
+ Assertions.assertEquals(4, headers2.size());
assertHeaderEquals(new BasicHeader(":status", "307"), headers2.get(0));
assertHeaderEquals(new BasicHeader("cache-control", "private"), headers2.get(1));
assertHeaderEquals(new BasicHeader("date", "Mon, 21 Oct 2013 20:13:21 GMT"), headers2.get(2));
assertHeaderEquals(new BasicHeader("location", "https://www.example.com"), headers2.get(3));
- Assert.assertEquals(4, dynamicTable.dynamicLength());
+ Assertions.assertEquals(4, dynamicTable.dynamicLength());
assertHeaderEquals(new BasicHeader(":status", "307"), dynamicTable.getDynamicEntry(0));
assertHeaderEquals(new BasicHeader("location", "https://www.example.com"), dynamicTable.getDynamicEntry(1));
assertHeaderEquals(new BasicHeader("date", "Mon, 21 Oct 2013 20:13:21 GMT"), dynamicTable.getDynamicEntry(2));
assertHeaderEquals(new BasicHeader("cache-control", "private"), dynamicTable.getDynamicEntry(3));
- Assert.assertEquals(222, dynamicTable.getCurrentSize());
+ Assertions.assertEquals(222, dynamicTable.getCurrentSize());
final ByteBuffer src3 = createByteBuffer(
0x88, 0xc1, 0x61, 0x96, 0xd0, 0x7a, 0xbe, 0x94, 0x10, 0x54, 0xd4, 0x44, 0xa8, 0x20, 0x05, 0x95, 0x04,
@@ -615,7 +616,7 @@ public class TestHPackCoding {
final List<Header> headers3 = decoder.decodeHeaders(src3);
- Assert.assertEquals(6, headers3.size());
+ Assertions.assertEquals(6, headers3.size());
assertHeaderEquals(new BasicHeader(":status", "200"), headers3.get(0));
assertHeaderEquals(new BasicHeader("cache-control", "private"), headers3.get(1));
assertHeaderEquals(new BasicHeader("date", "Mon, 21 Oct 2013 20:13:22 GMT"), headers3.get(2));
@@ -623,12 +624,12 @@ public class TestHPackCoding {
assertHeaderEquals(new BasicHeader("content-encoding", "gzip"), headers3.get(4));
assertHeaderEquals(new BasicHeader("set-cookie", "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1"), headers3.get(5));
- Assert.assertEquals(3, dynamicTable.dynamicLength());
+ Assertions.assertEquals(3, dynamicTable.dynamicLength());
assertHeaderEquals(new BasicHeader("set-cookie", "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1"), dynamicTable.getDynamicEntry(0));
assertHeaderEquals(new BasicHeader("content-encoding", "gzip"), dynamicTable.getDynamicEntry(1));
assertHeaderEquals(new BasicHeader("date", "Mon, 21 Oct 2013 20:13:22 GMT"), dynamicTable.getDynamicEntry(2));
- Assert.assertEquals(215, dynamicTable.getCurrentSize());
+ Assertions.assertEquals(215, dynamicTable.getCurrentSize());
}
private static byte[] createByteArray(final int... bytes) {
@@ -654,7 +655,7 @@ public class TestHPackCoding {
0x40, 0x0a, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x2d, 0x6b, 0x65, 0x79, 0x0d, 0x63, 0x75, 0x73,
0x74, 0x6f, 0x6d, 0x2d, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72);
- Assert.assertArrayEquals(expected, buf.toByteArray());
+ Assertions.assertArrayEquals(expected, buf.toByteArray());
}
@Test
@@ -680,7 +681,7 @@ public class TestHPackCoding {
final byte[] expected = createByteArray(
0x04, 0x0c, 0x2f, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x70, 0x61, 0x74, 0x68);
- Assert.assertArrayEquals(expected, buf.toByteArray());
+ Assertions.assertArrayEquals(expected, buf.toByteArray());
}
@Test
@@ -696,7 +697,7 @@ public class TestHPackCoding {
final byte[] expected = createByteArray(
0x10, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x06, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74);
- Assert.assertArrayEquals(expected, buf.toByteArray());
+ Assertions.assertArrayEquals(expected, buf.toByteArray());
}
@Test
@@ -709,7 +710,7 @@ public class TestHPackCoding {
encoder.encodeIndex(buf, 2);
final byte[] expected = createByteArray(0x82);
- Assert.assertArrayEquals(expected, buf.toByteArray());
+ Assertions.assertArrayEquals(expected, buf.toByteArray());
}
@Test
@@ -730,11 +731,11 @@ public class TestHPackCoding {
final byte[] expected1 = createByteArray(
0x82, 0x86, 0x84, 0x41, 0x0f, 0x77, 0x77, 0x77, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e,
0x63, 0x6f, 0x6d);
- Assert.assertArrayEquals(expected1, buf.toByteArray());
+ Assertions.assertArrayEquals(expected1, buf.toByteArray());
- Assert.assertEquals(1, dynamicTable.dynamicLength());
+ Assertions.assertEquals(1, dynamicTable.dynamicLength());
assertHeaderEquals(new BasicHeader(":authority", "www.example.com"), dynamicTable.getDynamicEntry(0));
- Assert.assertEquals(57, dynamicTable.getCurrentSize());
+ Assertions.assertEquals(57, dynamicTable.getCurrentSize());
final List<Header> headers2 = Arrays.asList(
new BasicHeader(":method", "GET"),
@@ -748,12 +749,12 @@ public class TestHPackCoding {
final byte[] expected2 = createByteArray(
0x82, 0x86, 0x84, 0xbe, 0x58, 0x08, 0x6e, 0x6f, 0x2d, 0x63, 0x61, 0x63, 0x68, 0x65);
- Assert.assertArrayEquals(expected2, buf.toByteArray());
+ Assertions.assertArrayEquals(expected2, buf.toByteArray());
- Assert.assertEquals(2, dynamicTable.dynamicLength());
+ Assertions.assertEquals(2, dynamicTable.dynamicLength());
assertHeaderEquals(new BasicHeader("cache-control", "no-cache"), dynamicTable.getDynamicEntry(0));
assertHeaderEquals(new BasicHeader(":authority", "www.example.com"), dynamicTable.getDynamicEntry(1));
- Assert.assertEquals(110, dynamicTable.getCurrentSize());
+ Assertions.assertEquals(110, dynamicTable.getCurrentSize());
final List<Header> headers3 = Arrays.asList(
new BasicHeader(":method", "GET"),
@@ -768,13 +769,13 @@ public class TestHPackCoding {
final byte[] expected3 = createByteArray(
0x82, 0x87, 0x85, 0xbf, 0x40, 0x0a, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x2d, 0x6b, 0x65, 0x79,
0x0c, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x2d, 0x76, 0x61, 0x6c, 0x75, 0x65);
- Assert.assertArrayEquals(expected3, buf.toByteArray());
+ Assertions.assertArrayEquals(expected3, buf.toByteArray());
- Assert.assertEquals(3, dynamicTable.dynamicLength());
+ Assertions.assertEquals(3, dynamicTable.dynamicLength());
assertHeaderEquals(new BasicHeader("custom-key", "custom-value"), dynamicTable.getDynamicEntry(0));
assertHeaderEquals(new BasicHeader("cache-control", "no-cache"), dynamicTable.getDynamicEntry(1));
assertHeaderEquals(new BasicHeader(":authority", "www.example.com"), dynamicTable.getDynamicEntry(2));
- Assert.assertEquals(164, dynamicTable.getCurrentSize());
+ Assertions.assertEquals(164, dynamicTable.getCurrentSize());
}
@Test
@@ -794,11 +795,11 @@ public class TestHPackCoding {
final byte[] expected1 = createByteArray(
0x82, 0x86, 0x84, 0x41, 0x8c, 0xf1, 0xe3, 0xc2, 0xe5, 0xf2, 0x3a, 0x6b, 0xa0, 0xab, 0x90, 0xf4, 0xff);
- Assert.assertArrayEquals(expected1, buf.toByteArray());
+ Assertions.assertArrayEquals(expected1, buf.toByteArray());
- Assert.assertEquals(1, dynamicTable.dynamicLength());
+ Assertions.assertEquals(1, dynamicTable.dynamicLength());
assertHeaderEquals(new BasicHeader(":authority", "www.example.com"), dynamicTable.getDynamicEntry(0));
- Assert.assertEquals(57, dynamicTable.getCurrentSize());
+ Assertions.assertEquals(57, dynamicTable.getCurrentSize());
final List<Header> headers2 = Arrays.asList(
new BasicHeader(":method", "GET"),
@@ -812,12 +813,12 @@ public class TestHPackCoding {
final byte[] expected2 = createByteArray(
0x82, 0x86, 0x84, 0xbe, 0x58, 0x86, 0xa8, 0xeb, 0x10, 0x64, 0x9c, 0xbf);
- Assert.assertArrayEquals(expected2, buf.toByteArray());
+ Assertions.assertArrayEquals(expected2, buf.toByteArray());
- Assert.assertEquals(2, dynamicTable.dynamicLength());
+ Assertions.assertEquals(2, dynamicTable.dynamicLength());
assertHeaderEquals(new BasicHeader("cache-control", "no-cache"), dynamicTable.getDynamicEntry(0));
assertHeaderEquals(new BasicHeader(":authority", "www.example.com"), dynamicTable.getDynamicEntry(1));
- Assert.assertEquals(110, dynamicTable.getCurrentSize());
+ Assertions.assertEquals(110, dynamicTable.getCurrentSize());
final List<Header> headers3 = Arrays.asList(
new BasicHeader(":method", "GET"),
@@ -832,13 +833,13 @@ public class TestHPackCoding {
final byte[] expected3 = createByteArray(
0x82, 0x87, 0x85, 0xbf, 0x40, 0x88, 0x25, 0xa8, 0x49, 0xe9, 0x5b, 0xa9, 0x7d, 0x7f, 0x89, 0x25,
0xa8, 0x49, 0xe9, 0x5b, 0xb8, 0xe8, 0xb4, 0xbf);
- Assert.assertArrayEquals(expected3, buf.toByteArray());
+ Assertions.assertArrayEquals(expected3, buf.toByteArray());
- Assert.assertEquals(3, dynamicTable.dynamicLength());
+ Assertions.assertEquals(3, dynamicTable.dynamicLength());
assertHeaderEquals(new BasicHeader("custom-key", "custom-value"), dynamicTable.getDynamicEntry(0));
assertHeaderEquals(new BasicHeader("cache-control", "no-cache"), dynamicTable.getDynamicEntry(1));
assertHeaderEquals(new BasicHeader(":authority", "www.example.com"), dynamicTable.getDynamicEntry(2));
- Assert.assertEquals(164, dynamicTable.getCurrentSize());
+ Assertions.assertEquals(164, dynamicTable.getCurrentSize());
}
@Test
@@ -863,14 +864,14 @@ public class TestHPackCoding {
0x30, 0x3a, 0x31, 0x33, 0x3a, 0x32, 0x31, 0x20, 0x47, 0x4d, 0x54, 0x6e, 0x17, 0x68, 0x74, 0x74, 0x70,
0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63,
0x6f, 0x6d);
- Assert.assertArrayEquals(expected1, buf.toByteArray());
+ Assertions.assertArrayEquals(expected1, buf.toByteArray());
- Assert.assertEquals(4, dynamicTable.dynamicLength());
+ Assertions.assertEquals(4, dynamicTable.dynamicLength());
assertHeaderEquals(new BasicHeader("location", "https://www.example.com"), dynamicTable.getDynamicEntry(0));
assertHeaderEquals(new BasicHeader("date", "Mon, 21 Oct 2013 20:13:21 GMT"), dynamicTable.getDynamicEntry(1));
assertHeaderEquals(new BasicHeader("cache-control", "private"), dynamicTable.getDynamicEntry(2));
assertHeaderEquals(new BasicHeader(":status", "302"), dynamicTable.getDynamicEntry(3));
- Assert.assertEquals(222, dynamicTable.getCurrentSize());
+ Assertions.assertEquals(222, dynamicTable.getCurrentSize());
final List<Header> headers2 = Arrays.asList(
new BasicHeader(":status", "307"),
@@ -883,15 +884,15 @@ public class TestHPackCoding {
final byte[] expected2 = createByteArray(
0x48, 0x03, 0x33, 0x30, 0x37, 0xc1, 0xc0, 0xbf);
- Assert.assertArrayEquals(expected2, buf.toByteArray());
+ Assertions.assertArrayEquals(expected2, buf.toByteArray());
- Assert.assertEquals(4, dynamicTable.dynamicLength());
+ Assertions.assertEquals(4, dynamicTable.dynamicLength());
assertHeaderEquals(new BasicHeader(":status", "307"), dynamicTable.getDynamicEntry(0));
assertHeaderEquals(new BasicHeader("location", "https://www.example.com"), dynamicTable.getDynamicEntry(1));
assertHeaderEquals(new BasicHeader("date", "Mon, 21 Oct 2013 20:13:21 GMT"), dynamicTable.getDynamicEntry(2));
assertHeaderEquals(new BasicHeader("cache-control", "private"), dynamicTable.getDynamicEntry(3));
- Assert.assertEquals(222, dynamicTable.getCurrentSize());
+ Assertions.assertEquals(222, dynamicTable.getCurrentSize());
final List<Header> headers3 = Arrays.asList(
new BasicHeader(":status", "200"),
@@ -911,14 +912,14 @@ public class TestHPackCoding {
0x48, 0x51, 0x4b, 0x42, 0x5a, 0x58, 0x4f, 0x51, 0x57, 0x45, 0x4f, 0x50, 0x49, 0x55, 0x41, 0x58, 0x51,
0x57, 0x45, 0x4f, 0x49, 0x55, 0x3b, 0x20, 0x6d, 0x61, 0x78, 0x2d, 0x61, 0x67, 0x65, 0x3d, 0x33, 0x36,
0x30, 0x30, 0x3b, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x3d, 0x31);
- Assert.assertArrayEquals(expected3, buf.toByteArray());
+ Assertions.assertArrayEquals(expected3, buf.toByteArray());
- Assert.assertEquals(3, dynamicTable.dynamicLength());
+ Assertions.assertEquals(3, dynamicTable.dynamicLength());
assertHeaderEquals(new BasicHeader("set-cookie", "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1"), dynamicTable.getDynamicEntry(0));
assertHeaderEquals(new BasicHeader("content-encoding", "gzip"), dynamicTable.getDynamicEntry(1));
assertHeaderEquals(new BasicHeader("date", "Mon, 21 Oct 2013 20:13:22 GMT"), dynamicTable.getDynamicEntry(2));
- Assert.assertEquals(215, dynamicTable.getCurrentSize());
+ Assertions.assertEquals(215, dynamicTable.getCurrentSize());
}
@Test
@@ -942,14 +943,14 @@ public class TestHPackCoding {
0x10, 0x54, 0xd4, 0x44, 0xa8, 0x20, 0x05, 0x95, 0x04, 0x0b, 0x81, 0x66, 0xe0, 0x82, 0xa6, 0x2d, 0x1b,
0xff, 0x6e, 0x91, 0x9d, 0x29, 0xad, 0x17, 0x18, 0x63, 0xc7, 0x8f, 0x0b, 0x97, 0xc8, 0xe9, 0xae, 0x82,
0xae, 0x43, 0xd3);
- Assert.assertArrayEquals(expected1, buf.toByteArray());
+ Assertions.assertArrayEquals(expected1, buf.toByteArray());
- Assert.assertEquals(4, dynamicTable.dynamicLength());
+ Assertions.assertEquals(4, dynamicTable.dynamicLength());
assertHeaderEquals(new BasicHeader("location", "https://www.example.com"), dynamicTable.getDynamicEntry(0));
assertHeaderEquals(new BasicHeader("date", "Mon, 21 Oct 2013 20:13:21 GMT"), dynamicTable.getDynamicEntry(1));
assertHeaderEquals(new BasicHeader("cache-control", "private"), dynamicTable.getDynamicEntry(2));
assertHeaderEquals(new BasicHeader(":status", "302"), dynamicTable.getDynamicEntry(3));
- Assert.assertEquals(222, dynamicTable.getCurrentSize());
+ Assertions.assertEquals(222, dynamicTable.getCurrentSize());
final List<Header> headers2 = Arrays.asList(
new BasicHeader(":status", "307"),
@@ -962,15 +963,15 @@ public class TestHPackCoding {
final byte[] expected2 = createByteArray(
0x48, 0x83, 0x64, 0x0e, 0xff, 0xc1, 0xc0, 0xbf);
- Assert.assertArrayEquals(expected2, buf.toByteArray());
+ Assertions.assertArrayEquals(expected2, buf.toByteArray());
- Assert.assertEquals(4, dynamicTable.dynamicLength());
+ Assertions.assertEquals(4, dynamicTable.dynamicLength());
assertHeaderEquals(new BasicHeader(":status", "307"), dynamicTable.getDynamicEntry(0));
assertHeaderEquals(new BasicHeader("location", "https://www.example.com"), dynamicTable.getDynamicEntry(1));
assertHeaderEquals(new BasicHeader("date", "Mon, 21 Oct 2013 20:13:21 GMT"), dynamicTable.getDynamicEntry(2));
assertHeaderEquals(new BasicHeader("cache-control", "private"), dynamicTable.getDynamicEntry(3));
- Assert.assertEquals(222, dynamicTable.getCurrentSize());
+ Assertions.assertEquals(222, dynamicTable.getCurrentSize());
final List<Header> headers3 = Arrays.asList(
new BasicHeader(":status", "200"),
@@ -989,14 +990,14 @@ public class TestHPackCoding {
0x94, 0xe7, 0x82, 0x1d, 0xd7, 0xf2, 0xe6, 0xc7, 0xb3, 0x35, 0xdf, 0xdf, 0xcd, 0x5b, 0x39, 0x60, 0xd5,
0xaf, 0x27, 0x08, 0x7f, 0x36, 0x72, 0xc1, 0xab, 0x27, 0x0f, 0xb5, 0x29, 0x1f, 0x95, 0x87, 0x31, 0x60,
0x65, 0xc0, 0x03, 0xed, 0x4e, 0xe5, 0xb1, 0x06, 0x3d, 0x50, 0x07);
- Assert.assertArrayEquals(expected3, buf.toByteArray());
+ Assertions.assertArrayEquals(expected3, buf.toByteArray());
- Assert.assertEquals(3, dynamicTable.dynamicLength());
+ Assertions.assertEquals(3, dynamicTable.dynamicLength());
assertHeaderEquals(new BasicHeader("set-cookie", "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1"), dynamicTable.getDynamicEntry(0));
assertHeaderEquals(new BasicHeader("content-encoding", "gzip"), dynamicTable.getDynamicEntry(1));
assertHeaderEquals(new BasicHeader("date", "Mon, 21 Oct 2013 20:13:22 GMT"), dynamicTable.getDynamicEntry(2));
- Assert.assertEquals(215, dynamicTable.getCurrentSize());
+ Assertions.assertEquals(215, dynamicTable.getCurrentSize());
}
@Test
@@ -1016,8 +1017,8 @@ public class TestHPackCoding {
encoder1.encodeHeader(buffer, header);
assertHeaderEquals(header, decoder1.decodeHeader(wrap(buffer)));
- Assert.assertEquals(1, outboundTable1.dynamicLength());
- Assert.assertEquals(1, inboundTable1.dynamicLength());
+ Assertions.assertEquals(1, outboundTable1.dynamicLength());
+ Assertions.assertEquals(1, inboundTable1.dynamicLength());
assertHeaderEquals(header, outboundTable1.getDynamicEntry(0));
assertHeaderEquals(header, inboundTable1.getDynamicEntry(0));
@@ -1035,8 +1036,8 @@ public class TestHPackCoding {
encoder2.encodeHeader(buffer, header);
assertHeaderEquals(header, decoder2.decodeHeader(wrap(buffer)));
- Assert.assertEquals(0, outboundTable2.dynamicLength());
- Assert.assertEquals(0, inboundTable2.dynamicLength());
+ Assertions.assertEquals(0, outboundTable2.dynamicLength());
+ Assertions.assertEquals(0, inboundTable2.dynamicLength());
}
@Test
@@ -1054,13 +1055,13 @@ public class TestHPackCoding {
"123456789012345678901234567890123456789012345678901234567890")),
false);
- MatcherAssert.assertThat(decoder.decodeHeaders(wrap(buf)).size(), CoreMatchers.equalTo(2));
+ assertThat(decoder.decodeHeaders(wrap(buf)).size(), CoreMatchers.equalTo(2));
decoder.setMaxListSize(1000000);
- MatcherAssert.assertThat(decoder.decodeHeaders(wrap(buf)).size(), CoreMatchers.equalTo(2));
+ assertThat(decoder.decodeHeaders(wrap(buf)).size(), CoreMatchers.equalTo(2));
decoder.setMaxListSize(200);
- Assert.assertThrows(HeaderListConstraintException.class, () ->
+ Assertions.assertThrows(HeaderListConstraintException.class, () ->
decoder.decodeHeaders(wrap(buf)));
}
diff --git a/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/hpack/TestInboundDynamicTable.java b/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/hpack/TestInboundDynamicTable.java
index 6a401fb..38039ac 100644
--- a/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/hpack/TestInboundDynamicTable.java
+++ b/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/hpack/TestInboundDynamicTable.java
@@ -27,8 +27,8 @@
package org.apache.hc.core5.http2.hpack;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestInboundDynamicTable {
@@ -36,16 +36,16 @@ public class TestInboundDynamicTable {
public void testBasics() throws Exception {
final InboundDynamicTable table = new InboundDynamicTable();
- Assert.assertEquals(Integer.MAX_VALUE, table.getMaxSize());
- Assert.assertEquals(0, table.getCurrentSize());
+ Assertions.assertEquals(Integer.MAX_VALUE, table.getMaxSize());
+ Assertions.assertEquals(0, table.getCurrentSize());
final HPackHeader header1 = new HPackHeader("h", "1");
table.add(header1);
- Assert.assertEquals(1, table.dynamicLength());
- Assert.assertEquals(61, table.staticLength());
- Assert.assertEquals(62, table.length());
- Assert.assertSame(header1, table.getHeader(62));
- Assert.assertEquals(34, table.getCurrentSize());
+ Assertions.assertEquals(1, table.dynamicLength());
+ Assertions.assertEquals(61, table.staticLength());
+ Assertions.assertEquals(62, table.length());
+ Assertions.assertSame(header1, table.getHeader(62));
+ Assertions.assertEquals(34, table.getCurrentSize());
}
@Test
@@ -56,14 +56,14 @@ public class TestInboundDynamicTable {
table.add(new HPackHeader("h", "1"));
table.add(new HPackHeader("h", "2"));
- Assert.assertEquals(68, table.getCurrentSize());
+ Assertions.assertEquals(68, table.getCurrentSize());
table.setMaxSize(256);
- Assert.assertEquals(68, table.getCurrentSize());
+ Assertions.assertEquals(68, table.getCurrentSize());
table.setMaxSize(67);
- Assert.assertEquals(34, table.getCurrentSize());
+ Assertions.assertEquals(34, table.getCurrentSize());
table.setMaxSize(10);
- Assert.assertEquals(0, table.getCurrentSize());
+ Assertions.assertEquals(0, table.getCurrentSize());
}
}
diff --git a/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/hpack/TestOutboundDynamicTable.java b/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/hpack/TestOutboundDynamicTable.java
index 7e58f6b..ec2649b 100644
--- a/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/hpack/TestOutboundDynamicTable.java
+++ b/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/hpack/TestOutboundDynamicTable.java
@@ -27,8 +27,8 @@
package org.apache.hc.core5.http2.hpack;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestOutboundDynamicTable {
@@ -36,16 +36,16 @@ public class TestOutboundDynamicTable {
public void testBasics() throws Exception {
final OutboundDynamicTable table = new OutboundDynamicTable();
- Assert.assertEquals(Integer.MAX_VALUE, table.getMaxSize());
- Assert.assertEquals(0, table.getCurrentSize());
+ Assertions.assertEquals(Integer.MAX_VALUE, table.getMaxSize());
+ Assertions.assertEquals(0, table.getCurrentSize());
final HPackHeader header1 = new HPackHeader("h", "1");
table.add(header1);
- Assert.assertEquals(1, table.dynamicLength());
- Assert.assertEquals(61, table.staticLength());
- Assert.assertEquals(62, table.length());
- Assert.assertSame(header1, table.getHeader(62));
- Assert.assertEquals(34, table.getCurrentSize());
+ Assertions.assertEquals(1, table.dynamicLength());
+ Assertions.assertEquals(61, table.staticLength());
+ Assertions.assertEquals(62, table.length());
+ Assertions.assertSame(header1, table.getHeader(62));
+ Assertions.assertEquals(34, table.getCurrentSize());
}
@Test
@@ -56,14 +56,14 @@ public class TestOutboundDynamicTable {
table.add(new HPackHeader("h", "1"));
table.add(new HPackHeader("h", "2"));
- Assert.assertEquals(68, table.getCurrentSize());
+ Assertions.assertEquals(68, table.getCurrentSize());
table.setMaxSize(256);
- Assert.assertEquals(68, table.getCurrentSize());
+ Assertions.assertEquals(68, table.getCurrentSize());
table.setMaxSize(67);
- Assert.assertEquals(34, table.getCurrentSize());
+ Assertions.assertEquals(34, table.getCurrentSize());
table.setMaxSize(10);
- Assert.assertEquals(0, table.getCurrentSize());
+ Assertions.assertEquals(0, table.getCurrentSize());
}
}
diff --git a/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/impl/TestDefaultH2RequestConverter.java b/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/impl/TestDefaultH2RequestConverter.java
index 1f8998c..1caf966 100644
--- a/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/impl/TestDefaultH2RequestConverter.java
+++ b/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/impl/TestDefaultH2RequestConverter.java
@@ -37,8 +37,8 @@ import org.apache.hc.core5.http.HttpRequest;
import org.apache.hc.core5.http.message.BasicHeader;
import org.apache.hc.core5.http.message.BasicHttpRequest;
import org.apache.hc.core5.net.URIAuthority;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestDefaultH2RequestConverter {
@@ -54,15 +54,15 @@ public class TestDefaultH2RequestConverter {
final DefaultH2RequestConverter converter = new DefaultH2RequestConverter();
final HttpRequest request = converter.convert(headers);
- Assert.assertNotNull(request);
- Assert.assertEquals("GET", request.getMethod());
- Assert.assertEquals("http", request.getScheme());
- Assert.assertEquals(new URIAuthority("www.example.com"), request.getAuthority());
- Assert.assertEquals("/", request.getPath());
+ Assertions.assertNotNull(request);
+ Assertions.assertEquals("GET", request.getMethod());
+ Assertions.assertEquals("http", request.getScheme());
+ Assertions.assertEquals(new URIAuthority("www.example.com"), request.getAuthority());
+ Assertions.assertEquals("/", request.getPath());
final Header[] allHeaders = request.getHeaders();
- Assert.assertEquals(1, allHeaders.length);
- Assert.assertEquals("custom123", allHeaders[0].getName());
- Assert.assertEquals("value", allHeaders[0].getValue());
+ Assertions.assertEquals(1, allHeaders.length);
+ Assertions.assertEquals("custom123", allHeaders[0].getName());
+ Assertions.assertEquals("value", allHeaders[0].getValue());
}
@Test
@@ -75,9 +75,8 @@ public class TestDefaultH2RequestConverter {
new BasicHeader("custom", "value"));
final DefaultH2RequestConverter converter = new DefaultH2RequestConverter();
-
- Assert.assertThrows("Header name ':Path' is invalid (header name contains uppercase characters)",
- HttpException.class, () -> converter.convert(headers));
+ Assertions.assertThrows(HttpException.class, () -> converter.convert(headers),
+ "Header name ':Path' is invalid (header name contains uppercase characters)");
}
@Test
@@ -90,8 +89,8 @@ public class TestDefaultH2RequestConverter {
new BasicHeader("connection", "keep-alive"));
final DefaultH2RequestConverter converter = new DefaultH2RequestConverter();
- Assert.assertThrows("Header 'connection: keep-alive' is illegal for HTTP/2 messages",
- HttpException.class, () -> converter.convert(headers));
+ Assertions.assertThrows(HttpException.class, () -> converter.convert(headers),
+ "Header 'connection: keep-alive' is illegal for HTTP/2 messages");
}
@Test
@@ -104,8 +103,8 @@ public class TestDefaultH2RequestConverter {
new BasicHeader(":path", "/"));
final DefaultH2RequestConverter converter = new DefaultH2RequestConverter();
- Assert.assertThrows("Invalid sequence of headers (pseudo-headers must precede message headers)",
- HttpException.class, () -> converter.convert(headers));
+ Assertions.assertThrows(HttpException.class, () -> converter.convert(headers),
+ "Invalid sequence of headers (pseudo-headers must precede message headers)");
}
@Test
@@ -117,8 +116,8 @@ public class TestDefaultH2RequestConverter {
new BasicHeader("custom", "value"));
final DefaultH2RequestConverter converter = new DefaultH2RequestConverter();
- Assert.assertThrows("Mandatory request header ':method' not found",
- HttpException.class, () -> converter.convert(headers));
+ Assertions.assertThrows(HttpException.class, () -> converter.convert(headers),
+ "Mandatory request header ':method' not found");
}
@Test
@@ -130,8 +129,8 @@ public class TestDefaultH2RequestConverter {
new BasicHeader("custom", "value"));
final DefaultH2RequestConverter converter = new DefaultH2RequestConverter();
- Assert.assertThrows("Mandatory request header ':scheme' not found",
- HttpException.class, () -> converter.convert(headers));
+ Assertions.assertThrows(HttpException.class, () -> converter.convert(headers),
+ "Mandatory request header ':scheme' not found");
}
@Test
@@ -143,8 +142,8 @@ public class TestDefaultH2RequestConverter {
new BasicHeader("custom", "value"));
final DefaultH2RequestConverter converter = new DefaultH2RequestConverter();
- Assert.assertThrows("Mandatory request header ':path' not found",
- HttpException.class, () -> converter.convert(headers));
+ Assertions.assertThrows(HttpException.class, () -> converter.convert(headers),
+ "Mandatory request header ':path' not found");
}
@Test
@@ -157,8 +156,8 @@ public class TestDefaultH2RequestConverter {
new BasicHeader(":custom", "value"));
final DefaultH2RequestConverter converter = new DefaultH2RequestConverter();
- Assert.assertThrows("Unsupported request header ':custom'",
- HttpException.class, () -> converter.convert(headers));
+ Assertions.assertThrows(HttpException.class, () -> converter.convert(headers),
+ "Unsupported request header ':custom'");
}
@Test
@@ -172,8 +171,8 @@ public class TestDefaultH2RequestConverter {
new BasicHeader("custom", "value"));
final DefaultH2RequestConverter converter = new DefaultH2RequestConverter();
- Assert.assertThrows("Multiple ':method' request headers are illegal",
- HttpException.class, () -> converter.convert(headers));
+ Assertions.assertThrows(HttpException.class, () -> converter.convert(headers),
+ "Multiple ':method' request headers are illegal");
}
@Test
@@ -187,8 +186,8 @@ public class TestDefaultH2RequestConverter {
new BasicHeader("custom", "value"));
final DefaultH2RequestConverter converter = new DefaultH2RequestConverter();
- Assert.assertThrows("Multiple ':scheme' request headers are illegal",
- HttpException.class, () -> converter.convert(headers));
+ Assertions.assertThrows(HttpException.class, () -> converter.convert(headers),
+ "Multiple ':scheme' request headers are illegal");
}
@Test
@@ -202,8 +201,8 @@ public class TestDefaultH2RequestConverter {
new BasicHeader("custom", "value"));
final DefaultH2RequestConverter converter = new DefaultH2RequestConverter();
- Assert.assertThrows("Multiple ':path' request headers are illegal",
- HttpException.class, () -> converter.convert(headers));
+ Assertions.assertThrows(HttpException.class, () -> converter.convert(headers),
+ "Multiple ':path' request headers are illegal");
}
@Test
@@ -225,8 +224,8 @@ public class TestDefaultH2RequestConverter {
new BasicHeader("custom", "value"));
final DefaultH2RequestConverter converter = new DefaultH2RequestConverter();
- Assert.assertThrows("Header ':authority' is mandatory for CONNECT request",
- HttpException.class, () -> converter.convert(headers));
+ Assertions.assertThrows(HttpException.class, () -> converter.convert(headers),
+ "Header ':authority' is mandatory for CONNECT request");
}
@Test
@@ -238,8 +237,8 @@ public class TestDefaultH2RequestConverter {
new BasicHeader("custom", "value"));
final DefaultH2RequestConverter converter = new DefaultH2RequestConverter();
- Assert.assertThrows("Header ':scheme' must not be set for CONNECT request",
- HttpException.class, () -> converter.convert(headers));
+ Assertions.assertThrows(HttpException.class, () -> converter.convert(headers),
+ "Header ':scheme' must not be set for CONNECT request");
}
@Test
@@ -251,8 +250,8 @@ public class TestDefaultH2RequestConverter {
new BasicHeader("custom", "value"));
final DefaultH2RequestConverter converter = new DefaultH2RequestConverter();
- Assert.assertThrows("Header ':path' must not be set for CONNECT request",
- HttpException.class, () -> converter.convert(headers));
+ Assertions.assertThrows(HttpException.class, () -> converter.convert(headers),
+ "Header ':path' must not be set for CONNECT request");
}
@Test
@@ -264,23 +263,23 @@ public class TestDefaultH2RequestConverter {
final DefaultH2RequestConverter converter = new DefaultH2RequestConverter();
final List<Header> headers = converter.convert(request);
- Assert.assertNotNull(headers);
- Assert.assertEquals(5, headers.size());
+ Assertions.assertNotNull(headers);
+ Assertions.assertEquals(5, headers.size());
final Header header1 = headers.get(0);
- Assert.assertEquals(":method", header1.getName());
- Assert.assertEquals("GET", header1.getValue());
+ Assertions.assertEquals(":method", header1.getName());
+ Assertions.assertEquals("GET", header1.getValue());
final Header header2 = headers.get(1);
- Assert.assertEquals(":scheme", header2.getName());
- Assert.assertEquals("http", header2.getValue());
+ Assertions.assertEquals(":scheme", header2.getName());
+ Assertions.assertEquals("http", header2.getValue());
final Header header3 = headers.get(2);
- Assert.assertEquals(":authority", header3.getName());
- Assert.assertEquals("host", header3.getValue());
+ Assertions.assertEquals(":authority", header3.getName());
+ Assertions.assertEquals("host", header3.getValue());
final Header header4 = headers.get(3);
- Assert.assertEquals(":path", header4.getName());
- Assert.assertEquals("/", header4.getValue());
+ Assertions.assertEquals(":path", header4.getName());
+ Assertions.assertEquals("/", header4.getValue());
final Header header5 = headers.get(4);
- Assert.assertEquals("custom123", header5.getName());
- Assert.assertEquals("Value", header5.getValue());
+ Assertions.assertEquals("custom123", header5.getName());
+ Assertions.assertEquals("Value", header5.getValue());
}
@Test
@@ -290,8 +289,7 @@ public class TestDefaultH2RequestConverter {
request.setScheme(null);
final DefaultH2RequestConverter converter = new DefaultH2RequestConverter();
- Assert.assertThrows("Request scheme is not set",
- HttpException.class, () -> converter.convert(request));
+ Assertions.assertThrows(HttpException.class, () -> converter.convert(request), "Request scheme is not set");
}
@Test
@@ -301,8 +299,7 @@ public class TestDefaultH2RequestConverter {
request.setPath(null);
final DefaultH2RequestConverter converter = new DefaultH2RequestConverter();
- Assert.assertThrows("Request path is not set",
- HttpException.class, () -> converter.convert(request));
+ Assertions.assertThrows(HttpException.class, () -> converter.convert(request), "Request path is not set");
}
@Test
@@ -314,17 +311,17 @@ public class TestDefaultH2RequestConverter {
final DefaultH2RequestConverter converter = new DefaultH2RequestConverter();
final List<Header> headers = converter.convert(request);
- Assert.assertNotNull(headers);
- Assert.assertEquals(3, headers.size());
+ Assertions.assertNotNull(headers);
+ Assertions.assertEquals(3, headers.size());
final Header header1 = headers.get(0);
- Assert.assertEquals(":method", header1.getName());
- Assert.assertEquals("CONNECT", header1.getValue());
+ Assertions.assertEquals(":method", header1.getName());
+ Assertions.assertEquals("CONNECT", header1.getValue());
final Header header2 = headers.get(1);
- Assert.assertEquals(":authority", header2.getName());
- Assert.assertEquals("host:80", header2.getValue());
+ Assertions.assertEquals(":authority", header2.getName());
+ Assertions.assertEquals("host:80", header2.getValue());
final Header header3 = headers.get(2);
- Assert.assertEquals("custom123", header3.getName());
- Assert.assertEquals("Value", header3.getValue());
+ Assertions.assertEquals("custom123", header3.getName());
+ Assertions.assertEquals("Value", header3.getValue());
}
@Test
@@ -333,8 +330,8 @@ public class TestDefaultH2RequestConverter {
request.addHeader("Custom123", "Value");
final DefaultH2RequestConverter converter = new DefaultH2RequestConverter();
- Assert.assertThrows("CONNECT request authority is not set",
- HttpException.class, () -> converter.convert(request));
+ Assertions.assertThrows(HttpException.class, () -> converter.convert(request),
+ "CONNECT request authority is not set");
}
@Test
@@ -344,8 +341,8 @@ public class TestDefaultH2RequestConverter {
request.addHeader("Custom123", "Value");
final DefaultH2RequestConverter converter = new DefaultH2RequestConverter();
- Assert.assertThrows("CONNECT request path must be null",
- HttpException.class, () -> converter.convert(request));
+ Assertions.assertThrows(HttpException.class, () -> converter.convert(request),
+ "CONNECT request path must be null");
}
@Test
@@ -354,8 +351,8 @@ public class TestDefaultH2RequestConverter {
request.addHeader("Connection", "Keep-Alive");
final DefaultH2RequestConverter converter = new DefaultH2RequestConverter();
- Assert.assertThrows("Header 'Connection: Keep-Alive' is illegal for HTTP/2 messages",
- HttpException.class, () -> converter.convert(request));
+ Assertions.assertThrows(HttpException.class, () -> converter.convert(request),
+ "Header 'Connection: Keep-Alive' is illegal for HTTP/2 messages");
}
@Test
@@ -364,8 +361,8 @@ public class TestDefaultH2RequestConverter {
request.addHeader("Keep-Alive", "timeout=5, max=1000");
final DefaultH2RequestConverter converter = new DefaultH2RequestConverter();
- Assert.assertThrows("Header 'Keep-Alive: timeout=5, max=1000' is illegal for HTTP/2 messages",
- HttpException.class, () -> converter.convert(request));
+ Assertions.assertThrows(HttpException.class, () -> converter.convert(request),
+ "Header 'Keep-Alive: timeout=5, max=1000' is illegal for HTTP/2 messages");
}
@Test
@@ -374,8 +371,8 @@ public class TestDefaultH2RequestConverter {
request.addHeader("Proxy-Connection", "keep-alive");
final DefaultH2RequestConverter converter = new DefaultH2RequestConverter();
- Assert.assertThrows("Header 'Proxy-Connection: Keep-Alive' is illegal for HTTP/2 messages",
- HttpException.class, () -> converter.convert(request));
+ Assertions.assertThrows(HttpException.class, () -> converter.convert(request),
+ "Header 'Proxy-Connection: Keep-Alive' is illegal for HTTP/2 messages");
}
@Test
@@ -384,8 +381,8 @@ public class TestDefaultH2RequestConverter {
request.addHeader("Transfer-Encoding", "gzip");
final DefaultH2RequestConverter converter = new DefaultH2RequestConverter();
- Assert.assertThrows("Header 'Transfer-Encoding: gzip' is illegal for HTTP/2 messages",
- HttpException.class, () -> converter.convert(request));
+ Assertions.assertThrows(HttpException.class, () -> converter.convert(request),
+ "Header 'Transfer-Encoding: gzip' is illegal for HTTP/2 messages");
}
@Test
@@ -394,8 +391,8 @@ public class TestDefaultH2RequestConverter {
request.addHeader("Host", "host");
final DefaultH2RequestConverter converter = new DefaultH2RequestConverter();
- Assert.assertThrows("Header 'Host: host' is illegal for HTTP/2 messages",
- HttpException.class, () -> converter.convert(request));
+ Assertions.assertThrows(HttpException.class, () -> converter.convert(request),
+ "Header 'Host: host' is illegal for HTTP/2 messages");
}
@Test
@@ -404,8 +401,8 @@ public class TestDefaultH2RequestConverter {
request.addHeader("Upgrade", "example/1, foo/2");
final DefaultH2RequestConverter converter = new DefaultH2RequestConverter();
- Assert.assertThrows("Header 'Upgrade: example/1, foo/2' is illegal for HTTP/2 messages",
- HttpException.class, () -> converter.convert(request));
+ Assertions.assertThrows(HttpException.class, () -> converter.convert(request),
+ "Header 'Upgrade: example/1, foo/2' is illegal for HTTP/2 messages");
}
@Test
@@ -414,8 +411,8 @@ public class TestDefaultH2RequestConverter {
request.addHeader("TE", "gzip");
final DefaultH2RequestConverter converter = new DefaultH2RequestConverter();
- Assert.assertThrows("Header 'TE: gzip' is illegal for HTTP/2 messages",
- HttpException.class, () -> converter.convert(request));
+ Assertions.assertThrows(HttpException.class, () -> converter.convert(request),
+ "Header 'TE: gzip' is illegal for HTTP/2 messages");
}
@Test
@@ -430,15 +427,15 @@ public class TestDefaultH2RequestConverter {
final DefaultH2RequestConverter converter = new DefaultH2RequestConverter();
final HttpRequest request = converter.convert(headers);
- Assert.assertNotNull(request);
- Assert.assertEquals("GET", request.getMethod());
- Assert.assertEquals("http", request.getScheme());
- Assert.assertEquals(new URIAuthority("www.example.com"), request.getAuthority());
- Assert.assertEquals("/", request.getPath());
+ Assertions.assertNotNull(request);
+ Assertions.assertEquals("GET", request.getMethod());
+ Assertions.assertEquals("http", request.getScheme());
+ Assertions.assertEquals(new URIAuthority("www.example.com"), request.getAuthority());
+ Assertions.assertEquals("/", request.getPath());
final Header[] allHeaders = request.getHeaders();
- Assert.assertEquals(1, allHeaders.length);
- Assert.assertEquals("te", allHeaders[0].getName());
- Assert.assertEquals("trailers", allHeaders[0].getValue());
+ Assertions.assertEquals(1, allHeaders.length);
+ Assertions.assertEquals("te", allHeaders[0].getName());
+ Assertions.assertEquals("trailers", allHeaders[0].getValue());
}
@Test
@@ -447,8 +444,8 @@ public class TestDefaultH2RequestConverter {
request.addHeader(":custom", "stuff");
final DefaultH2RequestConverter converter = new DefaultH2RequestConverter();
- Assert.assertThrows("Header name ':custom' is invalid",
- HttpException.class, () -> converter.convert(request));
+ Assertions.assertThrows(HttpException.class, () -> converter.convert(request),
+ "Header name ':custom' is invalid");
}
}
diff --git a/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/impl/TestDefaultH2ResponseConverter.java b/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/impl/TestDefaultH2ResponseConverter.java
index 90f3801..46d4e55 100644
--- a/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/impl/TestDefaultH2ResponseConverter.java
+++ b/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/impl/TestDefaultH2ResponseConverter.java
@@ -35,8 +35,8 @@ import org.apache.hc.core5.http.HttpException;
import org.apache.hc.core5.http.HttpResponse;
import org.apache.hc.core5.http.message.BasicHeader;
import org.apache.hc.core5.http.message.BasicHttpResponse;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestDefaultH2ResponseConverter {
@@ -50,14 +50,14 @@ public class TestDefaultH2ResponseConverter {
final DefaultH2ResponseConverter converter = new DefaultH2ResponseConverter();
final HttpResponse response = converter.convert(headers);
- Assert.assertNotNull(response );
- Assert.assertEquals(200, response .getCode());
+ Assertions.assertNotNull(response );
+ Assertions.assertEquals(200, response .getCode());
final Header[] allHeaders = response.getHeaders();
- Assert.assertEquals(2, allHeaders.length);
- Assert.assertEquals("location", allHeaders[0].getName());
- Assert.assertEquals("http://www.example.com/", allHeaders[0].getValue());
- Assert.assertEquals("custom123", allHeaders[1].getName());
- Assert.assertEquals("value", allHeaders[1].getValue());
+ Assertions.assertEquals(2, allHeaders.length);
+ Assertions.assertEquals("location", allHeaders[0].getName());
+ Assertions.assertEquals("http://www.example.com/", allHeaders[0].getValue());
+ Assertions.assertEquals("custom123", allHeaders[1].getName());
+ Assertions.assertEquals("value", allHeaders[1].getValue());
}
@Test
@@ -68,8 +68,8 @@ public class TestDefaultH2ResponseConverter {
new BasicHeader("custom123", "value"));
final DefaultH2ResponseConverter converter = new DefaultH2ResponseConverter();
- Assert.assertThrows("Header name ':Status' is invalid (header name contains uppercase characters)",
- HttpException.class, () -> converter.convert(headers));
+ Assertions.assertThrows(HttpException.class, () -> converter.convert(headers),
+ "Header name ':Status' is invalid (header name contains uppercase characters)");
}
@Test
@@ -80,7 +80,7 @@ public class TestDefaultH2ResponseConverter {
new BasicHeader("custom123", "value"));
final DefaultH2ResponseConverter converter = new DefaultH2ResponseConverter();
- Assert.assertThrows(HttpException.class, () -> converter.convert(headers));
+ Assertions.assertThrows(HttpException.class, () -> converter.convert(headers));
}
@Test
@@ -91,8 +91,8 @@ public class TestDefaultH2ResponseConverter {
new BasicHeader("connection", "keep-alive"));
final DefaultH2ResponseConverter converter = new DefaultH2ResponseConverter();
- Assert.assertThrows("Header 'connection: keep-alive' is illegal for HTTP/2 messages",
- HttpException.class, () -> converter.convert(headers));
+ Assertions.assertThrows(HttpException.class, () -> converter.convert(headers),
+ "Header 'connection: keep-alive' is illegal for HTTP/2 messages");
}
@Test
@@ -103,8 +103,8 @@ public class TestDefaultH2ResponseConverter {
new BasicHeader("keep-alive", "timeout=5, max=1000"));
final DefaultH2ResponseConverter converter = new DefaultH2ResponseConverter();
- Assert.assertThrows("Header 'keep-alive: timeout=5, max=1000' is illegal for HTTP/2 messages",
- HttpException.class, () -> converter.convert(headers));
+ Assertions.assertThrows(HttpException.class, () -> converter.convert(headers),
+ "Header 'keep-alive: timeout=5, max=1000' is illegal for HTTP/2 messages");
}
@Test
@@ -115,8 +115,8 @@ public class TestDefaultH2ResponseConverter {
new BasicHeader("transfer-encoding", "gzip"));
final DefaultH2ResponseConverter converter = new DefaultH2ResponseConverter();
- Assert.assertThrows("Header 'transfer-encoding: gzip' is illegal for HTTP/2 messages",
- HttpException.class, () -> converter.convert(headers));
+ Assertions.assertThrows(HttpException.class, () -> converter.convert(headers),
+ "Header 'transfer-encoding: gzip' is illegal for HTTP/2 messages");
}
@Test
@@ -127,8 +127,8 @@ public class TestDefaultH2ResponseConverter {
new BasicHeader("upgrade", "example/1, foo/2"));
final DefaultH2ResponseConverter converter = new DefaultH2ResponseConverter();
- Assert.assertThrows("Header 'upgrade: example/1, foo/2' is illegal for HTTP/2 messages",
- HttpException.class, () -> converter.convert(headers));
+ Assertions.assertThrows(HttpException.class, () -> converter.convert(headers),
+ "Header 'upgrade: example/1, foo/2' is illegal for HTTP/2 messages");
}
@Test
@@ -138,8 +138,8 @@ public class TestDefaultH2ResponseConverter {
new BasicHeader("custom", "value"));
final DefaultH2ResponseConverter converter = new DefaultH2ResponseConverter();
- Assert.assertThrows("Mandatory response header ':status' not found",
- HttpException.class, () -> converter.convert(headers));
+ Assertions.assertThrows(HttpException.class, () -> converter.convert(headers),
+ "Mandatory response header ':status' not found");
}
@Test
@@ -151,8 +151,8 @@ public class TestDefaultH2ResponseConverter {
new BasicHeader("custom1", "value"));
final DefaultH2ResponseConverter converter = new DefaultH2ResponseConverter();
- Assert.assertThrows("Unsupported response header ':custom'",
- HttpException.class, () -> converter.convert(headers));
+ Assertions.assertThrows(HttpException.class, () -> converter.convert(headers),
+ "Unsupported response header ':custom'");
}
@Test
@@ -164,8 +164,8 @@ public class TestDefaultH2ResponseConverter {
new BasicHeader("custom1", "value"));
final DefaultH2ResponseConverter converter = new DefaultH2ResponseConverter();
- Assert.assertThrows("Multiple ':status' response headers are illegal",
- HttpException.class, () -> converter.convert(headers));
+ Assertions.assertThrows(HttpException.class, () -> converter.convert(headers),
+ "Multiple ':status' response headers are illegal");
}
@Test
@@ -177,14 +177,14 @@ public class TestDefaultH2ResponseConverter {
final DefaultH2ResponseConverter converter = new DefaultH2ResponseConverter();
final List<Header> headers = converter.convert(response);
- Assert.assertNotNull(headers);
- Assert.assertEquals(2, headers.size());
+ Assertions.assertNotNull(headers);
+ Assertions.assertEquals(2, headers.size());
final Header header1 = headers.get(0);
- Assert.assertEquals(":status", header1.getName());
- Assert.assertEquals("200", header1.getValue());
+ Assertions.assertEquals(":status", header1.getName());
+ Assertions.assertEquals("200", header1.getValue());
final Header header2 = headers.get(1);
- Assert.assertEquals("custom123", header2.getName());
- Assert.assertEquals("Value", header2.getValue());
+ Assertions.assertEquals("custom123", header2.getName());
+ Assertions.assertEquals("Value", header2.getValue());
}
@Test
@@ -193,8 +193,8 @@ public class TestDefaultH2ResponseConverter {
response.addHeader("Custom123", "Value");
final DefaultH2ResponseConverter converter = new DefaultH2ResponseConverter();
- Assert.assertThrows("Response status 99 is invalid",
- HttpException.class, () -> converter.convert(response));
+ Assertions.assertThrows(HttpException.class, () -> converter.convert(response),
+ "Response status 99 is invalid");
}
@Test
@@ -203,8 +203,8 @@ public class TestDefaultH2ResponseConverter {
response.addHeader("Connection", "Keep-Alive");
final DefaultH2ResponseConverter converter = new DefaultH2ResponseConverter();
- Assert.assertThrows("Header 'Connection: Keep-Alive' is illegal for HTTP/2 messages",
- HttpException.class, () -> converter.convert(response));
+ Assertions.assertThrows(HttpException.class, () -> converter.convert(response),
+ "Header 'Connection: Keep-Alive' is illegal for HTTP/2 messages");
}
@Test
@@ -213,8 +213,8 @@ public class TestDefaultH2ResponseConverter {
response.addHeader(":custom", "stuff");
final DefaultH2ResponseConverter converter = new DefaultH2ResponseConverter();
- Assert.assertThrows("Header name ':custom' is invalid",
- HttpException.class, () -> converter.convert(response));
+ Assertions.assertThrows(HttpException.class, () -> converter.convert(response),
+ "Header name ':custom' is invalid");
}
}
diff --git a/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/impl/io/TestFrameInOutBuffers.java b/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/impl/io/TestFrameInOutBuffers.java
index 5a7b6cc..1800e42 100644
--- a/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/impl/io/TestFrameInOutBuffers.java
+++ b/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/impl/io/TestFrameInOutBuffers.java
@@ -39,8 +39,8 @@ import org.apache.hc.core5.http2.frame.FrameFlag;
import org.apache.hc.core5.http2.frame.FrameType;
import org.apache.hc.core5.http2.frame.RawFrame;
import org.apache.hc.core5.http2.impl.BasicH2TransportMetrics;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestFrameInOutBuffers {
@@ -56,27 +56,27 @@ public class TestFrameInOutBuffers {
final FrameInputBuffer inBuffer = new FrameInputBuffer(16 * 1024);
final byte[] bytes = outputStream.toByteArray();
final ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);
- Assert.assertEquals(FrameConsts.HEAD_LEN + 5, bytes.length);
+ Assertions.assertEquals(FrameConsts.HEAD_LEN + 5, bytes.length);
- Assert.assertEquals(1, outbuffer.getMetrics().getFramesTransferred());
- Assert.assertEquals(bytes.length, outbuffer.getMetrics().getBytesTransferred());
+ Assertions.assertEquals(1, outbuffer.getMetrics().getFramesTransferred());
+ Assertions.assertEquals(bytes.length, outbuffer.getMetrics().getBytesTransferred());
final RawFrame frame2 = inBuffer.read(inputStream);
- Assert.assertEquals(FrameType.DATA.getValue(), frame2.getType());
- Assert.assertEquals(0, frame2.getFlags());
- Assert.assertEquals(1L, frame2.getStreamId());
+ Assertions.assertEquals(FrameType.DATA.getValue(), frame2.getType());
+ Assertions.assertEquals(0, frame2.getFlags());
+ Assertions.assertEquals(1L, frame2.getStreamId());
final ByteBuffer payload2 = frame2.getPayloadContent();
- Assert.assertNotNull(payload2);
- Assert.assertEquals(5, payload2.remaining());
- Assert.assertEquals(1, payload2.get());
- Assert.assertEquals(2, payload2.get());
- Assert.assertEquals(3, payload2.get());
- Assert.assertEquals(4, payload2.get());
- Assert.assertEquals(5, payload2.get());
- Assert.assertEquals(-1, inputStream.read());
-
- Assert.assertEquals(1, inBuffer.getMetrics().getFramesTransferred());
- Assert.assertEquals(bytes.length, inBuffer.getMetrics().getBytesTransferred());
+ Assertions.assertNotNull(payload2);
+ Assertions.assertEquals(5, payload2.remaining());
+ Assertions.assertEquals(1, payload2.get());
+ Assertions.assertEquals(2, payload2.get());
+ Assertions.assertEquals(3, payload2.get());
+ Assertions.assertEquals(4, payload2.get());
+ Assertions.assertEquals(5, payload2.get());
+ Assertions.assertEquals(-1, inputStream.read());
+
+ Assertions.assertEquals(1, inBuffer.getMetrics().getFramesTransferred());
+ Assertions.assertEquals(bytes.length, inBuffer.getMetrics().getBytesTransferred());
}
@Test
@@ -89,32 +89,32 @@ public class TestFrameInOutBuffers {
});
final RawFrame frame1 = inBuffer.read(inputStream);
- Assert.assertEquals(FrameType.DATA, FrameType.valueOf(frame1.getType()));
- Assert.assertEquals(8, frame1.getFlags());
- Assert.assertEquals(8, frame1.getStreamId());
+ Assertions.assertEquals(FrameType.DATA, FrameType.valueOf(frame1.getType()));
+ Assertions.assertEquals(8, frame1.getFlags());
+ Assertions.assertEquals(8, frame1.getStreamId());
final ByteBuffer payload1 = frame1.getPayloadContent();
- Assert.assertNotNull(payload1);
- Assert.assertEquals(5, payload1.remaining());
- Assert.assertEquals(0, payload1.get());
- Assert.assertEquals(1, payload1.get());
- Assert.assertEquals(2, payload1.get());
- Assert.assertEquals(3, payload1.get());
- Assert.assertEquals(4, payload1.get());
+ Assertions.assertNotNull(payload1);
+ Assertions.assertEquals(5, payload1.remaining());
+ Assertions.assertEquals(0, payload1.get());
+ Assertions.assertEquals(1, payload1.get());
+ Assertions.assertEquals(2, payload1.get());
+ Assertions.assertEquals(3, payload1.get());
+ Assertions.assertEquals(4, payload1.get());
final RawFrame frame2 = inBuffer.read(inputStream);
- Assert.assertEquals(FrameType.DATA, FrameType.valueOf(frame2.getType()));
- Assert.assertEquals(FrameFlag.of(FrameFlag.END_STREAM, FrameFlag.PADDED), frame2.getFlags());
- Assert.assertEquals(8, frame2.getStreamId());
+ Assertions.assertEquals(FrameType.DATA, FrameType.valueOf(frame2.getType()));
+ Assertions.assertEquals(FrameFlag.of(FrameFlag.END_STREAM, FrameFlag.PADDED), frame2.getFlags());
+ Assertions.assertEquals(8, frame2.getStreamId());
final ByteBuffer payload2 = frame2.getPayloadContent();
- Assert.assertNotNull(payload2);
- Assert.assertEquals(5, payload2.remaining());
- Assert.assertEquals(5, payload2.get());
- Assert.assertEquals(6, payload2.get());
- Assert.assertEquals(7, payload2.get());
- Assert.assertEquals(8, payload2.get());
- Assert.assertEquals(9, payload2.get());
-
- Assert.assertEquals(-1, inputStream.read());
+ Assertions.assertNotNull(payload2);
+ Assertions.assertEquals(5, payload2.remaining());
+ Assertions.assertEquals(5, payload2.get());
+ Assertions.assertEquals(6, payload2.get());
+ Assertions.assertEquals(7, payload2.get());
+ Assertions.assertEquals(8, payload2.get());
+ Assertions.assertEquals(9, payload2.get());
+
+ Assertions.assertEquals(-1, inputStream.read());
}
@Test
@@ -128,45 +128,45 @@ public class TestFrameInOutBuffers {
});
final RawFrame frame1 = inBuffer.read(inputStream);
- Assert.assertEquals(FrameType.DATA, FrameType.valueOf(frame1.getType()));
- Assert.assertEquals(8, frame1.getFlags());
- Assert.assertEquals(8, frame1.getStreamId());
+ Assertions.assertEquals(FrameType.DATA, FrameType.valueOf(frame1.getType()));
+ Assertions.assertEquals(8, frame1.getFlags());
+ Assertions.assertEquals(8, frame1.getStreamId());
final ByteBuffer payload1 = frame1.getPayloadContent();
- Assert.assertNotNull(payload1);
- Assert.assertEquals(5, payload1.remaining());
- Assert.assertEquals(1, payload1.get());
- Assert.assertEquals(1, payload1.get());
- Assert.assertEquals(1, payload1.get());
- Assert.assertEquals(1, payload1.get());
- Assert.assertEquals(1, payload1.get());
+ Assertions.assertNotNull(payload1);
+ Assertions.assertEquals(5, payload1.remaining());
+ Assertions.assertEquals(1, payload1.get());
+ Assertions.assertEquals(1, payload1.get());
+ Assertions.assertEquals(1, payload1.get());
+ Assertions.assertEquals(1, payload1.get());
+ Assertions.assertEquals(1, payload1.get());
final RawFrame frame2 = inBuffer.read(inputStream);
- Assert.assertEquals(FrameType.DATA, FrameType.valueOf(frame2.getType()));
- Assert.assertEquals(0, frame2.getFlags());
- Assert.assertEquals(8, frame2.getStreamId());
+ Assertions.assertEquals(FrameType.DATA, FrameType.valueOf(frame2.getType()));
+ Assertions.assertEquals(0, frame2.getFlags());
+ Assertions.assertEquals(8, frame2.getStreamId());
final ByteBuffer payload2 = frame2.getPayloadContent();
- Assert.assertNotNull(payload2);
- Assert.assertEquals(5, payload2.remaining());
- Assert.assertEquals(2, payload2.get());
- Assert.assertEquals(2, payload2.get());
- Assert.assertEquals(2, payload2.get());
- Assert.assertEquals(2, payload2.get());
- Assert.assertEquals(2, payload2.get());
+ Assertions.assertNotNull(payload2);
+ Assertions.assertEquals(5, payload2.remaining());
+ Assertions.assertEquals(2, payload2.get());
+ Assertions.assertEquals(2, payload2.get());
+ Assertions.assertEquals(2, payload2.get());
+ Assertions.assertEquals(2, payload2.get());
+ Assertions.assertEquals(2, payload2.get());
final RawFrame frame3 = inBuffer.read(inputStream);
- Assert.assertEquals(FrameType.DATA, FrameType.valueOf(frame3.getType()));
- Assert.assertEquals(FrameFlag.of(FrameFlag.END_STREAM, FrameFlag.PADDED), frame3.getFlags());
- Assert.assertEquals(8, frame3.getStreamId());
+ Assertions.assertEquals(FrameType.DATA, FrameType.valueOf(frame3.getType()));
+ Assertions.assertEquals(FrameFlag.of(FrameFlag.END_STREAM, FrameFlag.PADDED), frame3.getFlags());
+ Assertions.assertEquals(8, frame3.getStreamId());
final ByteBuffer payload3 = frame3.getPayloadContent();
- Assert.assertNotNull(payload3);
- Assert.assertEquals(5, payload3.remaining());
- Assert.assertEquals(3, payload3.get());
- Assert.assertEquals(3, payload3.get());
- Assert.assertEquals(3, payload3.get());
- Assert.assertEquals(3, payload3.get());
- Assert.assertEquals(3, payload3.get());
-
- Assert.assertEquals(-1, inputStream.read());
+ Assertions.assertNotNull(payload3);
+ Assertions.assertEquals(5, payload3.remaining());
+ Assertions.assertEquals(3, payload3.get());
+ Assertions.assertEquals(3, payload3.get());
+ Assertions.assertEquals(3, payload3.get());
+ Assertions.assertEquals(3, payload3.get());
+ Assertions.assertEquals(3, payload3.get());
+
+ Assertions.assertEquals(-1, inputStream.read());
}
@Test
@@ -182,18 +182,18 @@ public class TestFrameInOutBuffers {
new byte[] {0,0,0});
final RawFrame frame = inBuffer.read(inputStream);
- Assert.assertEquals(FrameType.DATA, FrameType.valueOf(frame.getType()));
- Assert.assertEquals(FrameFlag.of(FrameFlag.END_STREAM, FrameFlag.PADDED), frame.getFlags());
- Assert.assertEquals(8, frame.getStreamId());
+ Assertions.assertEquals(FrameType.DATA, FrameType.valueOf(frame.getType()));
+ Assertions.assertEquals(FrameFlag.of(FrameFlag.END_STREAM, FrameFlag.PADDED), frame.getFlags());
+ Assertions.assertEquals(8, frame.getStreamId());
final ByteBuffer payload = frame.getPayloadContent();
- Assert.assertNotNull(payload);
- Assert.assertEquals(5, payload.remaining());
- Assert.assertEquals(1, payload.get());
- Assert.assertEquals(2, payload.get());
- Assert.assertEquals(3, payload.get());
- Assert.assertEquals(4, payload.get());
- Assert.assertEquals(5, payload.get());
- Assert.assertEquals(-1, inputStream.read());
+ Assertions.assertNotNull(payload);
+ Assertions.assertEquals(5, payload.remaining());
+ Assertions.assertEquals(1, payload.get());
+ Assertions.assertEquals(2, payload.get());
+ Assertions.assertEquals(3, payload.get());
+ Assertions.assertEquals(4, payload.get());
+ Assertions.assertEquals(5, payload.get());
+ Assertions.assertEquals(-1, inputStream.read());
}
@Test
@@ -202,11 +202,11 @@ public class TestFrameInOutBuffers {
final ByteArrayInputStream inputStream = new ByteArrayInputStream(new byte[] {0,0,0,0,0,0,0,0,0});
final RawFrame frame = inBuffer.read(inputStream);
- Assert.assertEquals(FrameType.DATA, FrameType.valueOf(frame.getType()));
- Assert.assertEquals(0, frame.getFlags());
- Assert.assertEquals(0, frame.getStreamId());
+ Assertions.assertEquals(FrameType.DATA, FrameType.valueOf(frame.getType()));
+ Assertions.assertEquals(0, frame.getFlags());
+ Assertions.assertEquals(0, frame.getStreamId());
final ByteBuffer payload = frame.getPayloadContent();
- Assert.assertNull(payload);
+ Assertions.assertNull(payload);
}
@Test
@@ -214,7 +214,7 @@ public class TestFrameInOutBuffers {
final FrameInputBuffer inBuffer = new FrameInputBuffer(16 * 1024);
final ByteArrayInputStream inputStream = new ByteArrayInputStream(new byte[] {});
- Assert.assertThrows(ConnectionClosedException.class, () -> inBuffer.read(inputStream));
+ Assertions.assertThrows(ConnectionClosedException.class, () -> inBuffer.read(inputStream));
}
@Test
@@ -222,7 +222,7 @@ public class TestFrameInOutBuffers {
final FrameInputBuffer inBuffer = new FrameInputBuffer(16 * 1024);
final ByteArrayInputStream inputStream = new ByteArrayInputStream(new byte[] {0,0});
- Assert.assertThrows(H2CorruptFrameException.class, () -> inBuffer.read(inputStream));
+ Assertions.assertThrows(H2CorruptFrameException.class, () -> inBuffer.read(inputStream));
}
@Test
@@ -232,7 +232,7 @@ public class TestFrameInOutBuffers {
final RawFrame frame = new RawFrame(FrameType.DATA.getValue(), 0, 1,
ByteBuffer.wrap(new byte[2048]));
- Assert.assertThrows(H2ConnectionException.class, () -> outbuffer.write(frame, outputStream));
+ Assertions.assertThrows(H2ConnectionException.class, () -> outbuffer.write(frame, outputStream));
}
@Test
@@ -241,7 +241,7 @@ public class TestFrameInOutBuffers {
final ByteArrayInputStream inputStream = new ByteArrayInputStream(
new byte[] {0,-128,-128,0,0,0,0,0,1});
- Assert.assertThrows(H2ConnectionException.class, () -> inBuffer.read(inputStream));
+ Assertions.assertThrows(H2ConnectionException.class, () -> inBuffer.read(inputStream));
}
}
diff --git a/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/impl/nio/TestFrameInOutBuffers.java b/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/impl/nio/TestFrameInOutBuffers.java
index 847af07..6465ad3 100644
--- a/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/impl/nio/TestFrameInOutBuffers.java
+++ b/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/impl/nio/TestFrameInOutBuffers.java
@@ -39,8 +39,8 @@ import org.apache.hc.core5.http2.frame.FrameFlag;
import org.apache.hc.core5.http2.frame.FrameType;
import org.apache.hc.core5.http2.frame.RawFrame;
import org.apache.hc.core5.http2.impl.BasicH2TransportMetrics;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestFrameInOutBuffers {
@@ -55,28 +55,28 @@ public class TestFrameInOutBuffers {
final FrameInputBuffer inBuffer = new FrameInputBuffer(16 * 1024);
final byte[] bytes = writableChannel.toByteArray();
- Assert.assertEquals(FrameConsts.HEAD_LEN + 5, bytes.length);
+ Assertions.assertEquals(FrameConsts.HEAD_LEN + 5, bytes.length);
- Assert.assertEquals(1, outbuffer.getMetrics().getFramesTransferred());
- Assert.assertEquals(bytes.length, outbuffer.getMetrics().getBytesTransferred());
+ Assertions.assertEquals(1, outbuffer.getMetrics().getFramesTransferred());
+ Assertions.assertEquals(bytes.length, outbuffer.getMetrics().getBytesTransferred());
final ReadableByteChannelMock readableChannel = new ReadableByteChannelMock(bytes);
final RawFrame frame2 = inBuffer.read(readableChannel);
- Assert.assertEquals(FrameType.DATA.getValue(), frame2.getType());
- Assert.assertEquals(0, frame2.getFlags());
- Assert.assertEquals(1L, frame2.getStreamId());
+ Assertions.assertEquals(FrameType.DATA.getValue(), frame2.getType());
+ Assertions.assertEquals(0, frame2.getFlags());
+ Assertions.assertEquals(1L, frame2.getStreamId());
final ByteBuffer payload2 = frame2.getPayloadContent();
- Assert.assertNotNull(payload2);
- Assert.assertEquals(5, payload2.remaining());
- Assert.assertEquals(1, payload2.get());
- Assert.assertEquals(2, payload2.get());
- Assert.assertEquals(3, payload2.get());
- Assert.assertEquals(4, payload2.get());
- Assert.assertEquals(5, payload2.get());
- Assert.assertEquals(-1, readableChannel.read(ByteBuffer.allocate(1024)));
-
- Assert.assertEquals(1, inBuffer.getMetrics().getFramesTransferred());
- Assert.assertEquals(bytes.length, inBuffer.getMetrics().getBytesTransferred());
+ Assertions.assertNotNull(payload2);
+ Assertions.assertEquals(5, payload2.remaining());
+ Assertions.assertEquals(1, payload2.get());
+ Assertions.assertEquals(2, payload2.get());
+ Assertions.assertEquals(3, payload2.get());
+ Assertions.assertEquals(4, payload2.get());
+ Assertions.assertEquals(5, payload2.get());
+ Assertions.assertEquals(-1, readableChannel.read(ByteBuffer.allocate(1024)));
+
+ Assertions.assertEquals(1, inBuffer.getMetrics().getFramesTransferred());
+ Assertions.assertEquals(bytes.length, inBuffer.getMetrics().getBytesTransferred());
}
@Test
@@ -87,17 +87,17 @@ public class TestFrameInOutBuffers {
ByteBuffer.wrap(new byte[]{'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'}));
outbuffer.write(frame, writableChannel);
- Assert.assertArrayEquals(new byte[] {0,0,16,0,1,0,0,0,5,48,49,50,51,52,53,54,55,56,57},
+ Assertions.assertArrayEquals(new byte[] {0,0,16,0,1,0,0,0,5,48,49,50,51,52,53,54,55,56,57},
writableChannel.toByteArray());
- Assert.assertFalse(outbuffer.isEmpty());
+ Assertions.assertFalse(outbuffer.isEmpty());
outbuffer.flush(writableChannel);
- Assert.assertArrayEquals(new byte[] {0,0,16,0,1,0,0,0,5,48,49,50,51,52,53,54,55,56,57},
+ Assertions.assertArrayEquals(new byte[] {0,0,16,0,1,0,0,0,5,48,49,50,51,52,53,54,55,56,57},
writableChannel.toByteArray());
writableChannel.flush();
outbuffer.flush(writableChannel);
- Assert.assertArrayEquals(new byte[] {0,0,16,0,1,0,0,0,5,48,49,50,51,52,53,54,55,56,57,97,98,99,100,101,102},
+ Assertions.assertArrayEquals(new byte[] {0,0,16,0,1,0,0,0,5,48,49,50,51,52,53,54,55,56,57,97,98,99,100,101,102},
writableChannel.toByteArray());
}
@@ -111,32 +111,32 @@ public class TestFrameInOutBuffers {
});
final RawFrame frame1 = inBuffer.read(readableChannel);
- Assert.assertEquals(FrameType.DATA, FrameType.valueOf(frame1.getType()));
- Assert.assertEquals(8, frame1.getFlags());
- Assert.assertEquals(8, frame1.getStreamId());
+ Assertions.assertEquals(FrameType.DATA, FrameType.valueOf(frame1.getType()));
+ Assertions.assertEquals(8, frame1.getFlags());
+ Assertions.assertEquals(8, frame1.getStreamId());
final ByteBuffer payload1 = frame1.getPayloadContent();
- Assert.assertNotNull(payload1);
- Assert.assertEquals(5, payload1.remaining());
- Assert.assertEquals(0, payload1.get());
- Assert.assertEquals(1, payload1.get());
- Assert.assertEquals(2, payload1.get());
- Assert.assertEquals(3, payload1.get());
- Assert.assertEquals(4, payload1.get());
+ Assertions.assertNotNull(payload1);
+ Assertions.assertEquals(5, payload1.remaining());
+ Assertions.assertEquals(0, payload1.get());
+ Assertions.assertEquals(1, payload1.get());
+ Assertions.assertEquals(2, payload1.get());
+ Assertions.assertEquals(3, payload1.get());
+ Assertions.assertEquals(4, payload1.get());
final RawFrame frame2 = inBuffer.read(readableChannel);
- Assert.assertEquals(FrameType.DATA, FrameType.valueOf(frame2.getType()));
- Assert.assertEquals(FrameFlag.of(FrameFlag.END_STREAM, FrameFlag.PADDED), frame2.getFlags());
- Assert.assertEquals(8, frame2.getStreamId());
+ Assertions.assertEquals(FrameType.DATA, FrameType.valueOf(frame2.getType()));
+ Assertions.assertEquals(FrameFlag.of(FrameFlag.END_STREAM, FrameFlag.PADDED), frame2.getFlags());
+ Assertions.assertEquals(8, frame2.getStreamId());
final ByteBuffer payload2 = frame2.getPayloadContent();
- Assert.assertNotNull(payload2);
- Assert.assertEquals(5, payload2.remaining());
- Assert.assertEquals(5, payload2.get());
- Assert.assertEquals(6, payload2.get());
- Assert.assertEquals(7, payload2.get());
- Assert.assertEquals(8, payload2.get());
- Assert.assertEquals(9, payload2.get());
-
- Assert.assertEquals(-1, readableChannel.read(ByteBuffer.allocate(1024)));
+ Assertions.assertNotNull(payload2);
+ Assertions.assertEquals(5, payload2.remaining());
+ Assertions.assertEquals(5, payload2.get());
+ Assertions.assertEquals(6, payload2.get());
+ Assertions.assertEquals(7, payload2.get());
+ Assertions.assertEquals(8, payload2.get());
+ Assertions.assertEquals(9, payload2.get());
+
+ Assertions.assertEquals(-1, readableChannel.read(ByteBuffer.allocate(1024)));
}
@Test
@@ -150,45 +150,45 @@ public class TestFrameInOutBuffers {
});
final RawFrame frame1 = inBuffer.read(readableChannel);
- Assert.assertEquals(FrameType.DATA, FrameType.valueOf(frame1.getType()));
- Assert.assertEquals(8, frame1.getFlags());
- Assert.assertEquals(8, frame1.getStreamId());
+ Assertions.assertEquals(FrameType.DATA, FrameType.valueOf(frame1.getType()));
+ Assertions.assertEquals(8, frame1.getFlags());
+ Assertions.assertEquals(8, frame1.getStreamId());
final ByteBuffer payload1 = frame1.getPayloadContent();
- Assert.assertNotNull(payload1);
- Assert.assertEquals(5, payload1.remaining());
- Assert.assertEquals(1, payload1.get());
- Assert.assertEquals(1, payload1.get());
- Assert.assertEquals(1, payload1.get());
- Assert.assertEquals(1, payload1.get());
- Assert.assertEquals(1, payload1.get());
+ Assertions.assertNotNull(payload1);
+ Assertions.assertEquals(5, payload1.remaining());
+ Assertions.assertEquals(1, payload1.get());
+ Assertions.assertEquals(1, payload1.get());
+ Assertions.assertEquals(1, payload1.get());
+ Assertions.assertEquals(1, payload1.get());
+ Assertions.assertEquals(1, payload1.get());
final RawFrame frame2 = inBuffer.read(readableChannel);
- Assert.assertEquals(FrameType.DATA, FrameType.valueOf(frame2.getType()));
- Assert.assertEquals(0, frame2.getFlags());
- Assert.assertEquals(8, frame2.getStreamId());
+ Assertions.assertEquals(FrameType.DATA, FrameType.valueOf(frame2.getType()));
+ Assertions.assertEquals(0, frame2.getFlags());
+ Assertions.assertEquals(8, frame2.getStreamId());
final ByteBuffer payload2 = frame2.getPayloadContent();
- Assert.assertNotNull(payload2);
- Assert.assertEquals(5, payload2.remaining());
- Assert.assertEquals(2, payload2.get());
- Assert.assertEquals(2, payload2.get());
- Assert.assertEquals(2, payload2.get());
- Assert.assertEquals(2, payload2.get());
- Assert.assertEquals(2, payload2.get());
+ Assertions.assertNotNull(payload2);
+ Assertions.assertEquals(5, payload2.remaining());
+ Assertions.assertEquals(2, payload2.get());
+ Assertions.assertEquals(2, payload2.get());
+ Assertions.assertEquals(2, payload2.get());
+ Assertions.assertEquals(2, payload2.get());
+ Assertions.assertEquals(2, payload2.get());
final RawFrame frame3 = inBuffer.read(readableChannel);
- Assert.assertEquals(FrameType.DATA, FrameType.valueOf(frame3.getType()));
- Assert.assertEquals(FrameFlag.of(FrameFlag.END_STREAM, FrameFlag.PADDED), frame3.getFlags());
- Assert.assertEquals(8, frame3.getStreamId());
+ Assertions.assertEquals(FrameType.DATA, FrameType.valueOf(frame3.getType()));
+ Assertions.assertEquals(FrameFlag.of(FrameFlag.END_STREAM, FrameFlag.PADDED), frame3.getFlags());
+ Assertions.assertEquals(8, frame3.getStreamId());
final ByteBuffer payload3 = frame3.getPayloadContent();
- Assert.assertNotNull(payload3);
- Assert.assertEquals(5, payload3.remaining());
- Assert.assertEquals(3, payload3.get());
- Assert.assertEquals(3, payload3.get());
- Assert.assertEquals(3, payload3.get());
- Assert.assertEquals(3, payload3.get());
- Assert.assertEquals(3, payload3.get());
-
- Assert.assertEquals(-1, readableChannel.read(ByteBuffer.allocate(1024)));
+ Assertions.assertNotNull(payload3);
+ Assertions.assertEquals(5, payload3.remaining());
+ Assertions.assertEquals(3, payload3.get());
+ Assertions.assertEquals(3, payload3.get());
+ Assertions.assertEquals(3, payload3.get());
+ Assertions.assertEquals(3, payload3.get());
+ Assertions.assertEquals(3, payload3.get());
+
+ Assertions.assertEquals(-1, readableChannel.read(ByteBuffer.allocate(1024)));
}
@Test
@@ -204,19 +204,19 @@ public class TestFrameInOutBuffers {
new byte[] {0,0,0});
final RawFrame frame = inBuffer.read(readableChannel);
- Assert.assertEquals(FrameType.DATA, FrameType.valueOf(frame.getType()));
- Assert.assertEquals(FrameFlag.of(FrameFlag.END_STREAM, FrameFlag.PADDED), frame.getFlags());
- Assert.assertEquals(8, frame.getStreamId());
+ Assertions.assertEquals(FrameType.DATA, FrameType.valueOf(frame.getType()));
+ Assertions.assertEquals(FrameFlag.of(FrameFlag.END_STREAM, FrameFlag.PADDED), frame.getFlags());
+ Assertions.assertEquals(8, frame.getStreamId());
final ByteBuffer payload = frame.getPayloadContent();
- Assert.assertNotNull(payload);
- Assert.assertEquals(5, payload.remaining());
- Assert.assertEquals(1, payload.get());
- Assert.assertEquals(2, payload.get());
- Assert.assertEquals(3, payload.get());
- Assert.assertEquals(4, payload.get());
- Assert.assertEquals(5, payload.get());
-
- Assert.assertEquals(-1, readableChannel.read(ByteBuffer.allocate(1024)));
+ Assertions.assertNotNull(payload);
+ Assertions.assertEquals(5, payload.remaining());
+ Assertions.assertEquals(1, payload.get());
+ Assertions.assertEquals(2, payload.get());
+ Assertions.assertEquals(3, payload.get());
+ Assertions.assertEquals(4, payload.get());
+ Assertions.assertEquals(5, payload.get());
+
+ Assertions.assertEquals(-1, readableChannel.read(ByteBuffer.allocate(1024)));
}
@Test
@@ -226,11 +226,11 @@ public class TestFrameInOutBuffers {
new byte[] {0,0,0,0,0,0,0,0,0});
final RawFrame frame = inBuffer.read(readableChannel);
- Assert.assertEquals(FrameType.DATA, FrameType.valueOf(frame.getType()));
- Assert.assertEquals(0, frame.getFlags());
- Assert.assertEquals(0, frame.getStreamId());
+ Assertions.assertEquals(FrameType.DATA, FrameType.valueOf(frame.getType()));
+ Assertions.assertEquals(0, frame.getFlags());
+ Assertions.assertEquals(0, frame.getStreamId());
final ByteBuffer payload = frame.getPayloadContent();
- Assert.assertNull(payload);
+ Assertions.assertNull(payload);
}
@Test
@@ -238,8 +238,8 @@ public class TestFrameInOutBuffers {
final FrameInputBuffer inBuffer = new FrameInputBuffer(16 * 1024);
final ReadableByteChannelMock readableChannel = new ReadableByteChannelMock(new byte[] {});
- Assert.assertNull(inBuffer.read(readableChannel));
- Assert.assertThrows(ConnectionClosedException.class, () ->
+ Assertions.assertNull(inBuffer.read(readableChannel));
+ Assertions.assertThrows(ConnectionClosedException.class, () ->
inBuffer.read(readableChannel));
}
@@ -248,7 +248,7 @@ public class TestFrameInOutBuffers {
final FrameInputBuffer inBuffer = new FrameInputBuffer(16 * 1024);
final ReadableByteChannelMock readableChannel = new ReadableByteChannelMock(new byte[] {0,0});
- Assert.assertThrows(H2CorruptFrameException.class, () ->
+ Assertions.assertThrows(H2CorruptFrameException.class, () ->
inBuffer.read(readableChannel));
}
@@ -259,7 +259,7 @@ public class TestFrameInOutBuffers {
final RawFrame frame = new RawFrame(FrameType.DATA.getValue(), 0, 1,
ByteBuffer.wrap(new byte[2048]));
- Assert.assertThrows(H2ConnectionException.class, () ->
+ Assertions.assertThrows(H2ConnectionException.class, () ->
outbuffer.write(frame, writableChannel));
}
@@ -269,7 +269,7 @@ public class TestFrameInOutBuffers {
final ReadableByteChannelMock readableChannel = new ReadableByteChannelMock(
new byte[] {0,-128,-128,0,0,0,0,0,1});
- Assert.assertThrows(H2ConnectionException.class, () ->
+ Assertions.assertThrows(H2ConnectionException.class, () ->
inBuffer.read(readableChannel));
}
diff --git a/httpcore5-reactive/pom.xml b/httpcore5-reactive/pom.xml
index 721518c..444deb6 100644
--- a/httpcore5-reactive/pom.xml
+++ b/httpcore5-reactive/pom.xml
@@ -50,8 +50,8 @@
<version>1.0.3</version>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/httpcore5-reactive/src/test/java/org/apache/hc/core5/reactive/TestReactiveDataConsumer.java b/httpcore5-reactive/src/test/java/org/apache/hc/core5/reactive/TestReactiveDataConsumer.java
index 3d1b283..efdf1a1 100644
--- a/httpcore5-reactive/src/test/java/org/apache/hc/core5/reactive/TestReactiveDataConsumer.java
+++ b/httpcore5-reactive/src/test/java/org/apache/hc/core5/reactive/TestReactiveDataConsumer.java
@@ -41,8 +41,8 @@ import io.reactivex.Observable;
import io.reactivex.Single;
import org.apache.hc.core5.http.HttpStreamResetException;
import org.apache.hc.core5.http.nio.CapacityChannel;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import org.reactivestreams.Subscriber;
import org.reactivestreams.Subscription;
@@ -72,11 +72,11 @@ public class TestReactiveDataConsumer {
consumer.consume(ByteBuffer.wrap(new byte[]{ '3' }));
consumer.streamEnd(null);
- Assert.assertTrue("Stream did not finish before timeout", complete.await(1, TimeUnit.SECONDS));
- Assert.assertEquals(3, output.size());
- Assert.assertEquals(ByteBuffer.wrap(new byte[]{ '1' }), output.get(0));
- Assert.assertEquals(ByteBuffer.wrap(new byte[]{ '2' }), output.get(1));
- Assert.assertEquals(ByteBuffer.wrap(new byte[]{ '3' }), output.get(2));
+ Assertions.assertTrue(complete.await(1, TimeUnit.SECONDS), "Stream did not finish before timeout");
+ Assertions.assertEquals(3, output.size());
+ Assertions.assertEquals(ByteBuffer.wrap(new byte[]{ '1' }), output.get(0));
+ Assertions.assertEquals(ByteBuffer.wrap(new byte[]{ '2' }), output.get(1));
+ Assertions.assertEquals(ByteBuffer.wrap(new byte[]{ '3' }), output.get(2));
}
@Test
@@ -89,7 +89,7 @@ public class TestReactiveDataConsumer {
final Exception ex = new RuntimeException();
consumer.failed(ex);
- Assert.assertSame(ex, single.blockingGet().get(0).getError());
+ Assertions.assertSame(ex, single.blockingGet().get(0).getError());
}
@Test
@@ -114,7 +114,7 @@ public class TestReactiveDataConsumer {
}
});
- Assert.assertThrows(HttpStreamResetException.class, () ->
+ Assertions.assertThrows(HttpStreamResetException.class, () ->
consumer.consume(ByteBuffer.wrap(new byte[1024])));
}
@@ -126,7 +126,7 @@ public class TestReactiveDataConsumer {
final AtomicInteger lastIncrement = new AtomicInteger(-1);
final CapacityChannel channel = lastIncrement::set;
consumer.updateCapacity(channel);
- Assert.assertEquals("CapacityChannel#update should not have been invoked yet", -1, lastIncrement.get());
+ Assertions.assertEquals(-1, lastIncrement.get(), "CapacityChannel#update should not have been invoked yet");
final AtomicInteger received = new AtomicInteger(0);
final AtomicReference<Subscription> subscription = new AtomicReference<>();
@@ -156,13 +156,13 @@ public class TestReactiveDataConsumer {
consumer.consume(data.duplicate());
subscription.get().request(1);
- Assert.assertEquals(1024, lastIncrement.get());
+ Assertions.assertEquals(1024, lastIncrement.get());
subscription.get().request(2);
- Assert.assertEquals(2 * 1024, lastIncrement.get());
+ Assertions.assertEquals(2 * 1024, lastIncrement.get());
subscription.get().request(99);
- Assert.assertEquals(1024, lastIncrement.get());
+ Assertions.assertEquals(1024, lastIncrement.get());
}
@Test
@@ -177,7 +177,7 @@ public class TestReactiveDataConsumer {
consumer.consume(data.duplicate());
consumer.streamEnd(null);
- Assert.assertEquals(Flowable.fromPublisher(consumer).count().blockingGet().longValue(), 3L);
+ Assertions.assertEquals(Flowable.fromPublisher(consumer).count().blockingGet().longValue(), 3L);
}
@Test
@@ -195,7 +195,7 @@ public class TestReactiveDataConsumer {
.materialize()
.singleOrError()
.blockingGet();
- Assert.assertSame(ex, result.getError());
+ Assertions.assertSame(ex, result.getError());
}
@Test
@@ -214,7 +214,7 @@ public class TestReactiveDataConsumer {
.materialize()
.singleOrError()
.blockingGet();
- Assert.assertFalse(result.isOnError());
- Assert.assertTrue(result.isOnComplete());
+ Assertions.assertFalse(result.isOnError());
+ Assertions.assertTrue(result.isOnComplete());
}
}
diff --git a/httpcore5-reactive/src/test/java/org/apache/hc/core5/reactive/TestReactiveDataProducer.java b/httpcore5-reactive/src/test/java/org/apache/hc/core5/reactive/TestReactiveDataProducer.java
index 65aa894..0e0f9ff 100644
--- a/httpcore5-reactive/src/test/java/org/apache/hc/core5/reactive/TestReactiveDataProducer.java
+++ b/httpcore5-reactive/src/test/java/org/apache/hc/core5/reactive/TestReactiveDataProducer.java
@@ -31,8 +31,8 @@ import java.nio.charset.StandardCharsets;
import org.apache.hc.core5.http.HttpStreamResetException;
import org.apache.hc.core5.http.nio.DataStreamChannel;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import io.reactivex.Flowable;
@@ -49,13 +49,13 @@ public class TestReactiveDataProducer {
producer.produce(streamChannel);
- Assert.assertTrue(byteChannel.isOpen());
- Assert.assertEquals("123456", byteChannel.dump(StandardCharsets.US_ASCII));
+ Assertions.assertTrue(byteChannel.isOpen());
+ Assertions.assertEquals("123456", byteChannel.dump(StandardCharsets.US_ASCII));
producer.produce(streamChannel);
- Assert.assertFalse(byteChannel.isOpen());
- Assert.assertEquals("", byteChannel.dump(StandardCharsets.US_ASCII));
+ Assertions.assertFalse(byteChannel.isOpen());
+ Assertions.assertEquals("", byteChannel.dump(StandardCharsets.US_ASCII));
}
@Test
@@ -76,11 +76,11 @@ public class TestReactiveDataProducer {
final DataStreamChannel streamChannel = new BasicDataStreamChannel(byteChannel);
producer.produce(streamChannel);
- Assert.assertEquals("12345", byteChannel.dump(StandardCharsets.US_ASCII));
+ Assertions.assertEquals("12345", byteChannel.dump(StandardCharsets.US_ASCII));
- final HttpStreamResetException exception = Assert.assertThrows(HttpStreamResetException.class, () ->
+ final HttpStreamResetException exception = Assertions.assertThrows(HttpStreamResetException.class, () ->
producer.produce(streamChannel));
- Assert.assertTrue("Expected published exception to be rethrown", exception.getCause() instanceof RuntimeException);
- Assert.assertEquals("", byteChannel.dump(StandardCharsets.US_ASCII));
+ Assertions.assertTrue(exception.getCause() instanceof RuntimeException, "Expected published exception to be rethrown");
+ Assertions.assertEquals("", byteChannel.dump(StandardCharsets.US_ASCII));
}
}
diff --git a/httpcore5-testing/pom.xml b/httpcore5-testing/pom.xml
index 20b9cbd..792e57d 100644
--- a/httpcore5-testing/pom.xml
+++ b/httpcore5-testing/pom.xml
@@ -81,8 +81,13 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
<dependency>
@@ -90,6 +95,11 @@
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-migrationsupport</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<profiles>
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/benchmark/BenchmarkToolTest.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/benchmark/BenchmarkToolTest.java
index becc3f0..fd4ce2e 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/benchmark/BenchmarkToolTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/benchmark/BenchmarkToolTest.java
@@ -28,9 +28,8 @@ package org.apache.hc.core5.benchmark;
import java.io.IOException;
import java.net.InetSocketAddress;
-import java.util.Arrays;
-import java.util.Collection;
import java.util.concurrent.Future;
+import java.util.stream.Stream;
import org.apache.hc.core5.http.EntityDetails;
import org.apache.hc.core5.http.HttpException;
@@ -52,34 +51,25 @@ import org.apache.hc.core5.http2.impl.nio.bootstrap.H2ServerBootstrap;
import org.apache.hc.core5.io.CloseMode;
import org.apache.hc.core5.net.URIBuilder;
import org.apache.hc.core5.reactor.ListenerEndpoint;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.api.AfterEach;;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
-@RunWith(Parameterized.class)
public class BenchmarkToolTest {
- @Parameterized.Parameters(name = "{0}")
- public static Collection<Object[]> protocols() {
- return Arrays.asList(new Object[][]{
- { HttpVersionPolicy.NEGOTIATE },
- { HttpVersionPolicy.FORCE_HTTP_2 }
- });
+ public static Stream<Arguments> protocols() {
+ return Stream.of(
+ Arguments.of(HttpVersionPolicy.NEGOTIATE),
+ Arguments.of(HttpVersionPolicy.FORCE_HTTP_2)
+ );
}
- private final HttpVersionPolicy versionPolicy;
private HttpAsyncServer server;
private InetSocketAddress address;
- public BenchmarkToolTest(final HttpVersionPolicy versionPolicy) {
- this.versionPolicy = versionPolicy;
- }
-
- @Before
- public void setup() throws Exception {
+ public void setup(final HttpVersionPolicy versionPolicy) throws Exception {
server = H2ServerBootstrap.bootstrap()
.register("/", new AsyncServerRequestHandler<Message<HttpRequest, Void>>() {
@@ -112,15 +102,18 @@ public class BenchmarkToolTest {
address = (InetSocketAddress) listener.getAddress();
}
- @After
+ @AfterEach
public void shutdown() throws Exception {
if (server != null) {
server.close(CloseMode.IMMEDIATE);
}
}
- @Test
- public void testBasics() throws Exception {
+
+ @ParameterizedTest(name = "{0}")
+ @MethodSource("protocols")
+ public void testBasics(final HttpVersionPolicy versionPolicy) throws Exception {
+ setup(versionPolicy);
final BenchmarkConfig config = BenchmarkConfig.custom()
.setKeepAlive(true)
.setMethod(Method.POST.name())
@@ -136,14 +129,14 @@ public class BenchmarkToolTest {
.build();
final HttpBenchmark httpBenchmark = new HttpBenchmark(config);
final Results results = httpBenchmark.execute();
- Assert.assertNotNull(results);
- Assert.assertEquals(100, results.getSuccessCount());
- Assert.assertEquals(0, results.getFailureCount());
- Assert.assertEquals(16, results.getContentLength());
- Assert.assertEquals(3, results.getConcurrencyLevel());
- Assert.assertEquals(100 * 16, results.getTotalContentBytesRecvd());
+ Assertions.assertNotNull(results);
+ Assertions.assertEquals(100, results.getSuccessCount());
+ Assertions.assertEquals(0, results.getFailureCount());
+ Assertions.assertEquals(16, results.getContentLength());
+ Assertions.assertEquals(3, results.getConcurrencyLevel());
+ Assertions.assertEquals(100 * 16, results.getTotalContentBytesRecvd());
if (versionPolicy == HttpVersionPolicy.FORCE_HTTP_2) {
- Assert.assertEquals(HttpVersion.HTTP_2, results.getProtocolVersion());
+ Assertions.assertEquals(HttpVersion.HTTP_2, results.getProtocolVersion());
}
}
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 33e7185..abb3e6b 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,14 +26,15 @@
*/
package org.apache.hc.core5.benchmark;
+import static org.hamcrest.MatcherAssert.assertThat;
+
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.hamcrest.MatcherAssert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class ResultFormatterTest {
@@ -56,7 +57,7 @@ public class ResultFormatterTest {
50000000);
final ByteArrayOutputStream buf = new ByteArrayOutputStream();
ResultFormatter.print(new PrintStream(buf, true, StandardCharsets.US_ASCII.name()), results);
- MatcherAssert.assertThat(new String(buf.toByteArray(), StandardCharsets.US_ASCII).replace("\r\n", "\n"),
+ 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 ce1b332..7841dc1 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,6 +27,8 @@
package org.apache.hc.core5.testing.classic;
+import static org.hamcrest.MatcherAssert.assertThat;
+
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Collection;
@@ -60,15 +62,16 @@ 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.hamcrest.MatcherAssert;
import org.junit.Rule;
import org.junit.Test;
+import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport;
import org.junit.rules.ExternalResource;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+@EnableRuleMigrationSupport
@RunWith(Parameterized.class)
public class ClassicAuthenticationTest {
@@ -193,16 +196,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)) {
- MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_UNAUTHORIZED));
+ assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_UNAUTHORIZED));
final String body1 = EntityUtils.toString(response1.getEntity());
- MatcherAssert.assertThat(body1, CoreMatchers.equalTo("You shall not pass!!!"));
+ 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)) {
- MatcherAssert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body1 = EntityUtils.toString(response2.getEntity());
- MatcherAssert.assertThat(body1, CoreMatchers.equalTo(""));
+ assertThat(body1, CoreMatchers.equalTo(""));
}
}
@@ -219,17 +222,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)) {
- MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_UNAUTHORIZED));
+ assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_UNAUTHORIZED));
final String body1 = EntityUtils.toString(response1.getEntity());
- MatcherAssert.assertThat(body1, CoreMatchers.equalTo("You shall not pass!!!"));
+ 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)) {
- MatcherAssert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body1 = EntityUtils.toString(response2.getEntity());
- MatcherAssert.assertThat(body1, CoreMatchers.equalTo(new String(stuff, StandardCharsets.US_ASCII)));
+ assertThat(body1, CoreMatchers.equalTo(new String(stuff, StandardCharsets.US_ASCII)));
}
}
@@ -247,18 +250,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)) {
- MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_UNAUTHORIZED));
+ assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_UNAUTHORIZED));
final String body1 = EntityUtils.toString(response1.getEntity());
- MatcherAssert.assertThat(body1, CoreMatchers.equalTo("You shall not pass!!!"));
+ 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)) {
- MatcherAssert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body1 = EntityUtils.toString(response2.getEntity());
- MatcherAssert.assertThat(body1, CoreMatchers.equalTo(new String(stuff, StandardCharsets.US_ASCII)));
+ assertThat(body1, CoreMatchers.equalTo(new String(stuff, StandardCharsets.US_ASCII)));
}
}
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/classic/ClassicIntegrationTest.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/classic/ClassicIntegrationTest.java
index fdb47e6..14aa998 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/classic/ClassicIntegrationTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/classic/ClassicIntegrationTest.java
@@ -72,14 +72,16 @@ import org.apache.hc.core5.http.protocol.RequestTargetHost;
import org.apache.hc.core5.http.protocol.RequestUserAgent;
import org.apache.hc.core5.io.CloseMode;
import org.apache.hc.core5.testing.SSLTestContexts;
-import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport;
import org.junit.rules.ExternalResource;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@RunWith(Parameterized.class)
+@EnableRuleMigrationSupport
public class ClassicIntegrationTest {
@Parameterized.Parameters(name = "{0}")
@@ -193,9 +195,9 @@ public class ClassicIntegrationTest {
final byte[] received = EntityUtils.toByteArray(response.getEntity());
final byte[] expected = testData.get(r);
- Assert.assertEquals(expected.length, received.length);
+ Assertions.assertEquals(expected.length, received.length);
for (int i = 0; i < expected.length; i++) {
- Assert.assertEquals(expected[i], received[i]);
+ Assertions.assertEquals(expected[i], received[i]);
}
}
}
@@ -246,9 +248,9 @@ public class ClassicIntegrationTest {
final byte[] received = EntityUtils.toByteArray(response.getEntity());
final byte[] expected = testData.get(r);
- Assert.assertEquals(expected.length, received.length);
+ Assertions.assertEquals(expected.length, received.length);
for (int i = 0; i < expected.length; i++) {
- Assert.assertEquals(expected[i], received[i]);
+ Assertions.assertEquals(expected[i], received[i]);
}
}
}
@@ -299,9 +301,9 @@ public class ClassicIntegrationTest {
final byte[] received = EntityUtils.toByteArray(response.getEntity());
final byte[] expected = testData.get(r);
- Assert.assertEquals(expected.length, received.length);
+ Assertions.assertEquals(expected.length, received.length);
for (int i = 0; i < expected.length; i++) {
- Assert.assertEquals(expected[i], received[i]);
+ Assertions.assertEquals(expected[i], received[i]);
}
}
}
@@ -353,16 +355,16 @@ public class ClassicIntegrationTest {
post.setEntity(new ByteArrayEntity(data, null));
try (final ClassicHttpResponse response = this.client.execute(host, post, context)) {
- Assert.assertEquals(HttpVersion.HTTP_1_1, response.getVersion());
+ Assertions.assertEquals(HttpVersion.HTTP_1_1, response.getVersion());
final Header h1 = response.getFirstHeader("Version");
- Assert.assertNotNull(h1);
- Assert.assertEquals("1.0", h1.getValue());
+ Assertions.assertNotNull(h1);
+ Assertions.assertEquals("1.0", h1.getValue());
final byte[] received = EntityUtils.toByteArray(response.getEntity());
final byte[] expected = testData.get(r);
- Assert.assertEquals(expected.length, received.length);
+ Assertions.assertEquals(expected.length, received.length);
for (int i = 0; i < expected.length; i++) {
- Assert.assertEquals(expected[i], received[i]);
+ Assertions.assertEquals(expected[i], received[i]);
}
}
}
@@ -413,9 +415,9 @@ public class ClassicIntegrationTest {
final byte[] received = EntityUtils.toByteArray(response.getEntity());
final byte[] expected = testData.get(r);
- Assert.assertEquals(expected.length, received.length);
+ Assertions.assertEquals(expected.length, received.length);
for (int i = 0; i < expected.length; i++) {
- Assert.assertEquals(expected[i], received[i]);
+ Assertions.assertEquals(expected[i], received[i]);
}
}
}
@@ -474,13 +476,13 @@ public class ClassicIntegrationTest {
try (final ClassicHttpResponse response = this.client.execute(host, post, context)) {
final HttpEntity responseEntity = response.getEntity();
- Assert.assertNotNull(responseEntity);
+ Assertions.assertNotNull(responseEntity);
EntityUtils.consume(responseEntity);
if (r >= 2) {
- Assert.assertEquals(HttpStatus.SC_EXPECTATION_FAILED, response.getCode());
+ Assertions.assertEquals(HttpStatus.SC_EXPECTATION_FAILED, response.getCode());
} else {
- Assert.assertEquals(HttpStatus.SC_OK, response.getCode());
+ Assertions.assertEquals(HttpStatus.SC_OK, response.getCode());
}
}
}
@@ -599,20 +601,20 @@ public class ClassicIntegrationTest {
try (final ClassicHttpResponse response = this.client.execute(host, post, context)) {
final HttpEntity entity = response.getEntity();
- Assert.assertNotNull(entity);
+ Assertions.assertNotNull(entity);
final InputStream inStream = entity.getContent();
final ContentType contentType = ContentType.parse(entity.getContentType());
final Charset charset = ContentType.getCharset(contentType, StandardCharsets.ISO_8859_1);
- Assert.assertNotNull(inStream);
+ Assertions.assertNotNull(inStream);
final BufferedReader reader = new BufferedReader(new InputStreamReader(inStream, charset));
String line;
int count = 0;
while ((line = reader.readLine()) != null) {
- Assert.assertEquals(pattern, line);
+ Assertions.assertEquals(pattern, line);
count++;
}
- Assert.assertEquals(n, count);
+ Assertions.assertEquals(n, count);
}
}
}
@@ -639,9 +641,9 @@ public class ClassicIntegrationTest {
post.setEntity(null);
try (final ClassicHttpResponse response = this.client.execute(host, post, context)) {
- Assert.assertEquals(HttpStatus.SC_OK, response.getCode());
+ Assertions.assertEquals(HttpStatus.SC_OK, response.getCode());
final byte[] received = EntityUtils.toByteArray(response.getEntity());
- Assert.assertEquals(0, received.length);
+ Assertions.assertEquals(0, received.length);
}
}
@@ -670,9 +672,9 @@ public class ClassicIntegrationTest {
post.setEntity(null);
try (final ClassicHttpResponse response = this.client.execute(host, post, context)) {
- Assert.assertEquals(HttpStatus.SC_OK, response.getCode());
+ Assertions.assertEquals(HttpStatus.SC_OK, response.getCode());
final byte[] received = EntityUtils.toByteArray(response.getEntity());
- Assert.assertEquals(0, received.length);
+ Assertions.assertEquals(0, received.length);
}
}
@@ -702,7 +704,7 @@ public class ClassicIntegrationTest {
post.setEntity(null);
try (final ClassicHttpResponse response = this.client.execute(host, post, context)) {
- Assert.assertEquals(HttpStatus.SC_NOT_IMPLEMENTED, response.getCode());
+ Assertions.assertEquals(HttpStatus.SC_NOT_IMPLEMENTED, response.getCode());
}
}
@@ -723,7 +725,7 @@ public class ClassicIntegrationTest {
for (int r = 0; r < reqNo; r++) {
final BasicClassicHttpRequest get = new BasicClassicHttpRequest(Method.GET, "/?" + r);
try (final ClassicHttpResponse response = this.client.execute(host, get, context)) {
- Assert.assertNull(response.getEntity());
+ Assertions.assertNull(response.getEntity());
}
}
}
@@ -743,13 +745,13 @@ public class ClassicIntegrationTest {
final BasicClassicHttpRequest get1 = new BasicClassicHttpRequest(Method.GET, "/");
get1.setVersion(HttpVersion.HTTP_1_0);
try (final ClassicHttpResponse response1 = this.client.execute(host, get1, context)) {
- Assert.assertEquals(200, response1.getCode());
+ Assertions.assertEquals(200, response1.getCode());
EntityUtils.consume(response1.getEntity());
}
final BasicClassicHttpRequest get2 = new BasicClassicHttpRequest(Method.GET, "/");
try (final ClassicHttpResponse response2 = this.client.execute(host, get2, context)) {
- Assert.assertEquals(400, response2.getCode());
+ Assertions.assertEquals(400, response2.getCode());
EntityUtils.consume(response2.getEntity());
}
}
@@ -773,7 +775,7 @@ public class ClassicIntegrationTest {
get1.setHeader("big-f-header", "1234567890123456789012345678901234567890123456789012345678901234567890" +
"1234567890123456789012345678901234567890");
try (final ClassicHttpResponse response1 = this.client.execute(host, get1, context)) {
- Assert.assertEquals(431, response1.getCode());
+ Assertions.assertEquals(431, response1.getCode());
EntityUtils.consume(response1.getEntity());
}
}
@@ -804,7 +806,7 @@ public class ClassicIntegrationTest {
post1.setEntity(new ByteArrayEntity(b, ContentType.TEXT_PLAIN));
try (final ClassicHttpResponse response1 = this.client.execute(host, post1, context)) {
- Assert.assertEquals(431, response1.getCode());
+ Assertions.assertEquals(431, response1.getCode());
EntityUtils.consume(response1.getEntity());
}
}
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 1d8b3e0..3daaccf 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,6 +27,8 @@
package org.apache.hc.core5.testing.classic;
+import static org.hamcrest.MatcherAssert.assertThat;
+
import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
@@ -56,15 +58,16 @@ 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.hamcrest.MatcherAssert;
import org.junit.Rule;
import org.junit.Test;
+import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport;
import org.junit.rules.ExternalResource;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+@EnableRuleMigrationSupport
@RunWith(Parameterized.class)
public class ClassicServerAndRequesterTest {
@@ -176,23 +179,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)) {
- MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body1 = EntityUtils.toString(response1.getEntity());
- MatcherAssert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
+ 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)) {
- MatcherAssert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body2 = EntityUtils.toString(response2.getEntity());
- MatcherAssert.assertThat(body2, CoreMatchers.equalTo("some other stuff"));
+ 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)) {
- MatcherAssert.assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body3 = EntityUtils.toString(response3.getEntity());
- MatcherAssert.assertThat(body3, CoreMatchers.equalTo("some more stuff"));
+ assertThat(body3, CoreMatchers.equalTo("some more stuff"));
}
}
@@ -204,23 +207,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)) {
- MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body1 = EntityUtils.toString(response1.getEntity());
- MatcherAssert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
+ 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)) {
- MatcherAssert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body2 = EntityUtils.toString(response2.getEntity());
- MatcherAssert.assertThat(body2, CoreMatchers.equalTo("some other stuff"));
+ 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)) {
- MatcherAssert.assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body3 = EntityUtils.toString(response3.getEntity());
- MatcherAssert.assertThat(body3, CoreMatchers.equalTo("some more stuff"));
+ assertThat(body3, CoreMatchers.equalTo("some more stuff"));
}
}
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/classic/ClassicServerBootstrapFilterTest.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/classic/ClassicServerBootstrapFilterTest.java
index 3e50e34..5ff9e78 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/classic/ClassicServerBootstrapFilterTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/classic/ClassicServerBootstrapFilterTest.java
@@ -27,6 +27,8 @@
package org.apache.hc.core5.testing.classic;
+import static org.hamcrest.MatcherAssert.assertThat;
+
import java.io.IOException;
import org.apache.hc.core5.http.ClassicHttpRequest;
@@ -49,13 +51,14 @@ import org.apache.hc.core5.http.protocol.HttpCoreContext;
import org.apache.hc.core5.io.CloseMode;
import org.apache.hc.core5.util.Timeout;
import org.hamcrest.CoreMatchers;
-import org.hamcrest.MatcherAssert;
import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport;
import org.junit.rules.ExternalResource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+@EnableRuleMigrationSupport
public class ClassicServerBootstrapFilterTest {
private static final Timeout TIMEOUT = Timeout.ofSeconds(30);
@@ -150,9 +153,9 @@ public class ClassicServerBootstrapFilterTest {
final ClassicHttpRequest request = new BasicClassicHttpRequest(Method.POST, "/filters");
request.setEntity(new StringEntity("some stuff", ContentType.TEXT_PLAIN));
try (final ClassicHttpResponse response = requester.execute(target, request, TIMEOUT, context)) {
- MatcherAssert.assertThat(response.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ assertThat(response.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final Header testFilterHeader = response.getHeader("X-Test-Filter");
- MatcherAssert.assertThat(testFilterHeader, CoreMatchers.notNullValue());
+ assertThat(testFilterHeader, CoreMatchers.notNullValue());
}
}
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 aa7a5df..37f996e 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,6 +27,8 @@
package org.apache.hc.core5.testing.classic;
+import static org.hamcrest.MatcherAssert.assertThat;
+
import java.io.IOException;
import java.util.concurrent.atomic.AtomicReference;
@@ -55,12 +57,13 @@ 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.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport;
import org.junit.rules.ExternalResource;
+@EnableRuleMigrationSupport
public class ClassicTLSIntegrationTest {
private static final Timeout TIMEOUT = Timeout.ofSeconds(30);
@@ -129,15 +132,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)) {
- MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body1 = EntityUtils.toString(response1.getEntity());
- MatcherAssert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
+ assertThat(body1, CoreMatchers.equalTo("some stuff"));
}
final SSLSession sslSession = sslSessionRef.getAndSet(null);
final ProtocolVersion tlsVersion = TLS.parse(sslSession.getProtocol());
- MatcherAssert.assertThat(tlsVersion.greaterEquals(TLS.V_1_2.version), CoreMatchers.equalTo(true));
- MatcherAssert.assertThat(sslSession.getPeerPrincipal().getName(),
+ assertThat(tlsVersion.greaterEquals(TLS.V_1_2.version), CoreMatchers.equalTo(true));
+ assertThat(sslSession.getPeerPrincipal().getName(),
CoreMatchers.equalTo("CN=localhost,OU=Apache HttpComponents,O=Apache Software Foundation"));
}
@@ -167,7 +170,7 @@ public class ClassicTLSIntegrationTest {
final HttpHost target = new HttpHost("https", "localhost", server.getLocalPort());
final ClassicHttpRequest request1 = new BasicClassicHttpRequest(Method.POST, "/stuff");
request1.setEntity(new StringEntity("some stuff", ContentType.TEXT_PLAIN));
- Assert.assertThrows(IOException.class, () -> {
+ Assertions.assertThrows(IOException.class, () -> {
try (final ClassicHttpResponse response1 = requester.execute(target, request1, TIMEOUT, context)) {
EntityUtils.consume(response1.getEntity());
}
@@ -202,7 +205,7 @@ public class ClassicTLSIntegrationTest {
final HttpHost target = new HttpHost("https", "localhost", server.getLocalPort());
final ClassicHttpRequest request1 = new BasicClassicHttpRequest(Method.POST, "/stuff");
request1.setEntity(new StringEntity("some stuff", ContentType.TEXT_PLAIN));
- Assert.assertThrows(IOException.class, () -> {
+ Assertions.assertThrows(IOException.class, () -> {
try (final ClassicHttpResponse response1 = requester.execute(target, request1, TIMEOUT, context)) {
EntityUtils.consume(response1.getEntity());
}
@@ -230,7 +233,7 @@ public class ClassicTLSIntegrationTest {
final HttpHost target = new HttpHost("https", "localhost", server.getLocalPort());
final ClassicHttpRequest request1 = new BasicClassicHttpRequest(Method.POST, "/stuff");
request1.setEntity(new StringEntity("some stuff", ContentType.TEXT_PLAIN));
- Assert.assertThrows(IOException.class, () -> {
+ Assertions.assertThrows(IOException.class, () -> {
try (final ClassicHttpResponse response1 = requester.execute(target, request1, TIMEOUT, context)) {
EntityUtils.consume(response1.getEntity());
}
@@ -271,7 +274,7 @@ public class ClassicTLSIntegrationTest {
.setSslContext(SSLTestContexts.createServerSSLContext())
.setSslSetupHandler(sslParameters -> sslParameters.setProtocols(new String[]{cipherSuite}))
.create();
- Assert.assertThrows(Exception.class, () -> {
+ Assertions.assertThrows(Exception.class, () -> {
try {
server.start();
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/classic/MonitoringResponseOutOfOrderStrategyIntegrationTest.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/classic/MonitoringResponseOutOfOrderStrategyIntegrationTest.java
index d8ce77c..ab03fcc 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/classic/MonitoringResponseOutOfOrderStrategyIntegrationTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/classic/MonitoringResponseOutOfOrderStrategyIntegrationTest.java
@@ -51,13 +51,16 @@ import org.apache.hc.core5.http.protocol.HttpCoreContext;
import org.apache.hc.core5.io.CloseMode;
import org.apache.hc.core5.testing.SSLTestContexts;
import org.apache.hc.core5.util.Timeout;
-import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport;
+import org.junit.jupiter.params.ParameterizedTest;
import org.junit.rules.ExternalResource;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
+@EnableRuleMigrationSupport
@RunWith(Parameterized.class)
public class MonitoringResponseOutOfOrderStrategyIntegrationTest {
@@ -65,7 +68,7 @@ public class MonitoringResponseOutOfOrderStrategyIntegrationTest {
private static final int BUFFER_SIZE = 16 * 1024;
private static final Timeout TIMEOUT = Timeout.ofSeconds(3);
- @Parameterized.Parameters(name = "{0}")
+ @ParameterizedTest(name = "{0}")
public static Collection<Object[]> protocols() {
return Arrays.asList(new Object[][]{
{ URIScheme.HTTP },
@@ -159,7 +162,7 @@ public class MonitoringResponseOutOfOrderStrategyIntegrationTest {
post.setEntity(new AllOnesHttpEntity(200000));
try (final ClassicHttpResponse response = requester.execute(host, post, TIMEOUT, context)) {
- Assert.assertEquals(400, response.getCode());
+ Assertions.assertEquals(400, response.getCode());
EntityUtils.consumeQuietly(response.getEntity());
}
}
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/compatibility/http2/HttpBinIT.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/compatibility/http2/HttpBinIT.java
index 1588b0c..93179c2 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/compatibility/http2/HttpBinIT.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/compatibility/http2/HttpBinIT.java
@@ -28,20 +28,20 @@
package org.apache.hc.core5.testing.compatibility.http2;
import org.apache.hc.core5.http.HttpHost;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
public class HttpBinIT {
private H2CompatibilityTest h2CompatibilityTest;
- @Before
+ @BeforeEach
public void start() throws Exception {
h2CompatibilityTest = new H2CompatibilityTest();
h2CompatibilityTest.start();
}
- @After
+ @AfterEach
public void shutdown() throws Exception {
h2CompatibilityTest.shutdown();
}
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestClassicTestClientTestingAdapter.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestClassicTestClientTestingAdapter.java
index a3e1bbd..8e2fb1b 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestClassicTestClientTestingAdapter.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestClassicTestClientTestingAdapter.java
@@ -48,10 +48,10 @@ import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.hc.core5.io.CloseMode;
import org.apache.hc.core5.testing.classic.ClassicTestServer;
import org.apache.hc.core5.testing.classic.EchoHandler;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
public class TestClassicTestClientTestingAdapter {
@@ -60,13 +60,13 @@ public class TestClassicTestClientTestingAdapter {
private ClassicTestServer server;
- @Before
+ @BeforeEach
public void initServer() throws Exception {
this.server = new ClassicTestServer(SocketConfig.custom()
.setSoTimeout(5, TimeUnit.SECONDS).build());
}
- @After
+ @AfterEach
public void shutDownServer() throws Exception {
if (this.server != null) {
this.server.shutdown(CloseMode.IMMEDIATE);
@@ -82,7 +82,7 @@ public class TestClassicTestClientTestingAdapter {
final TestingFrameworkRequestHandler requestHandler = Mockito.mock(TestingFrameworkRequestHandler.class);
final Map<String, Object> responseExpectations = new HashMap<>();
- Assert.assertThrows(TestingFrameworkException.class, () ->
+ Assertions.assertThrows(TestingFrameworkException.class, () ->
adapter.execute(defaultURI, request, requestHandler, responseExpectations));
}
@@ -95,7 +95,7 @@ public class TestClassicTestClientTestingAdapter {
final TestingFrameworkRequestHandler requestHandler = Mockito.mock(TestingFrameworkRequestHandler.class);
final Map<String, Object> responseExpectations = new HashMap<>();
- Assert.assertThrows(TestingFrameworkException.class, () ->
+ Assertions.assertThrows(TestingFrameworkException.class, () ->
adapter.execute(defaultURI, request, requestHandler, responseExpectations));
}
@@ -108,7 +108,7 @@ public class TestClassicTestClientTestingAdapter {
final TestingFrameworkRequestHandler requestHandler = null;
final Map<String, Object> responseExpectations = new HashMap<>();
- Assert.assertThrows(TestingFrameworkException.class, () ->
+ Assertions.assertThrows(TestingFrameworkException.class, () ->
adapter.execute(defaultURI, request, requestHandler, responseExpectations));
}
@@ -121,7 +121,7 @@ public class TestClassicTestClientTestingAdapter {
final TestingFrameworkRequestHandler requestHandler = Mockito.mock(TestingFrameworkRequestHandler.class);
final Map<String, Object> responseExpectations = null;
- Assert.assertThrows(TestingFrameworkException.class, () ->
+ Assertions.assertThrows(TestingFrameworkException.class, () ->
adapter.execute(defaultURI, request, requestHandler, responseExpectations));
}
@@ -134,7 +134,7 @@ public class TestClassicTestClientTestingAdapter {
final TestingFrameworkRequestHandler requestHandler = Mockito.mock(TestingFrameworkRequestHandler.class);
final Map<String, Object> responseExpectations = new HashMap<>();
- Assert.assertThrows(TestingFrameworkException.class, () ->
+ Assertions.assertThrows(TestingFrameworkException.class, () ->
adapter.execute(defaultURI, request, requestHandler, responseExpectations));
}
@@ -150,7 +150,7 @@ public class TestClassicTestClientTestingAdapter {
final TestingFrameworkRequestHandler requestHandler = Mockito.mock(TestingFrameworkRequestHandler.class);
final Map<String, Object> responseExpectations = new HashMap<>();
- Assert.assertThrows(TestingFrameworkException.class, () ->
+ Assertions.assertThrows(TestingFrameworkException.class, () ->
adapter.execute(defaultURI, request, requestHandler, responseExpectations));
}
@@ -167,7 +167,7 @@ public class TestClassicTestClientTestingAdapter {
final TestingFrameworkRequestHandler requestHandler = Mockito.mock(TestingFrameworkRequestHandler.class);
final Map<String, Object> responseExpectations = new HashMap<>();
- Assert.assertThrows(TestingFrameworkException.class, () ->
+ Assertions.assertThrows(TestingFrameworkException.class, () ->
adapter.execute(defaultURI, request, requestHandler, responseExpectations));
}
@@ -194,17 +194,17 @@ public class TestClassicTestClientTestingAdapter {
final TestingFrameworkRequestHandler requestHandler = Mockito.mock(TestingFrameworkRequestHandler.class);
final Map<String, Object> response = adapter.execute(defaultURI, request, requestHandler, responseExpectations);
- Assert.assertNotNull("response should not be null", response);
- Assert.assertEquals("status unexpected", 200, response.get(STATUS));
+ Assertions.assertNotNull(response, "response should not be null");
+ Assertions.assertEquals(200, response.get(STATUS), "status unexpected");
@SuppressWarnings("unchecked")
final Map<String, Object> headers = (Map<String, Object>) response.get(HEADERS);
- Assert.assertNotNull("headers should be in the response", headers);
- Assert.assertFalse(headers.isEmpty());
+ Assertions.assertNotNull(headers, "headers should be in the response");
+ Assertions.assertFalse(headers.isEmpty());
final String returnedBody = (String) response.get(BODY);
- Assert.assertNotNull("body should be in the response", returnedBody);
- Assert.assertEquals("Body should be echoed", body, returnedBody);
+ Assertions.assertNotNull(returnedBody, "body should be in the response");
+ Assertions.assertEquals(body, returnedBody, "Body should be echoed");
}
@@ -217,7 +217,7 @@ public class TestClassicTestClientTestingAdapter {
public void handle(final ClassicHttpRequest request, final ClassicHttpResponse response, final HttpContext context)
throws HttpException, IOException {
try {
- Assert.assertEquals("method not expected", "junk", request.getMethod());
+ Assertions.assertEquals("method not expected", "junk", request.getMethod());
} catch (final Throwable t) {
thrown = t;
}
@@ -247,7 +247,7 @@ public class TestClassicTestClientTestingAdapter {
final Map<String, Object> request = new HashMap<>();
final Map<String, Object> returnedRequest = adapter.modifyRequest(request);
- Assert.assertSame("Same request was not returned as expected.", request, returnedRequest);
+ Assertions.assertSame(request, returnedRequest, "Same request was not returned as expected.");
}
@Test
@@ -257,7 +257,7 @@ public class TestClassicTestClientTestingAdapter {
final Map<String, Object> responseExpectations = new HashMap<>();
final Map<String, Object> returnedResponseExpectations = adapter.modifyResponseExpectations(null, responseExpectations);
- Assert.assertSame("Same response expectations were not returned as expected.", responseExpectations, returnedResponseExpectations);
+ Assertions.assertSame(responseExpectations, returnedResponseExpectations, "Same response expectations were not returned as expected.");
}
}
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestClientPojoAdapter.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestClientPojoAdapter.java
index 547bbb7..0d8957c 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestClientPojoAdapter.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestClientPojoAdapter.java
@@ -29,8 +29,8 @@ package org.apache.hc.core5.testing.framework;
import java.util.HashMap;
import java.util.Map;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestClientPojoAdapter {
@Test
@@ -39,7 +39,7 @@ public class TestClientPojoAdapter {
final Map<String, Object> request = new HashMap<>();
final Map<String, Object> request2 = adapter.modifyRequest(request);
- Assert.assertSame("request should have been returned", request, request2);
+ Assertions.assertSame(request, request2, "request should have been returned");
}
@Test
@@ -47,7 +47,7 @@ public class TestClientPojoAdapter {
final ClientPOJOAdapter adapter = new ClassicTestClientAdapter();
final String reason = adapter.checkRequestSupport(null);
- Assert.assertNull("reason should be null", reason);
+ Assertions.assertNull(reason, "reason should be null");
adapter.assertRequestSupported(null);
}
@@ -72,6 +72,6 @@ public class TestClientPojoAdapter {
}
};
- Assert.assertThrows(Exception.class, () -> adapter.assertRequestSupported(null));
+ Assertions.assertThrows(Exception.class, () -> adapter.assertRequestSupported(null));
}
}
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestClientTestingAdapter.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestClientTestingAdapter.java
index 62af90f..8c134f3 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestClientTestingAdapter.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestClientTestingAdapter.java
@@ -28,8 +28,8 @@ package org.apache.hc.core5.testing.framework;
import java.util.Map;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestClientTestingAdapter {
@@ -39,7 +39,7 @@ public class TestClientTestingAdapter {
final ClientPOJOAdapter pojoAdapter = adapter.getClientPOJOAdapter();
- Assert.assertNotNull("pojoAdapter should not be null", pojoAdapter);
+ Assertions.assertNotNull(pojoAdapter, "pojoAdapter should not be null");
}
@Test
@@ -47,7 +47,7 @@ public class TestClientTestingAdapter {
final ClientTestingAdapter adapter = new ClassicTestClientTestingAdapter();
final Map<String, Object> request = null;
- Assert.assertTrue("isRequestSupported should return true", adapter.isRequestSupported(request));
+ Assertions.assertTrue(adapter.isRequestSupported(request), "isRequestSupported should return true");
}
}
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestFrameworkTest.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestFrameworkTest.java
index 57db424..6d7baa9 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestFrameworkTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestFrameworkTest.java
@@ -40,8 +40,8 @@ import static org.apache.hc.core5.testing.framework.ClientPOJOAdapter.STATUS;
import java.util.HashMap;
import java.util.Map;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestFrameworkTest {
@Test
@@ -49,42 +49,37 @@ public class TestFrameworkTest {
final FrameworkTest test = new FrameworkTest();
final Map<String, Object> request = test.initRequest();
- Assert.assertNotNull("request should not be null", request);
- Assert.assertEquals("Default method should be GET", "GET", request.get(METHOD));
+ Assertions.assertNotNull(request, "request should not be null");
+ Assertions.assertEquals(request.get(METHOD), "GET", "Default method should be GET");
- Assert.assertEquals("Default request body expected.",
- TestingFramework.DEFAULT_REQUEST_BODY,
- request.get(BODY));
+ Assertions.assertEquals(TestingFramework.DEFAULT_REQUEST_BODY,
+ request.get(BODY), "Default request body expected.");
- Assert.assertEquals("Default request content type expected.",
- TestingFramework.DEFAULT_REQUEST_CONTENT_TYPE,
- request.get(CONTENT_TYPE));
+ Assertions.assertEquals(TestingFramework.DEFAULT_REQUEST_CONTENT_TYPE,
+ request.get(CONTENT_TYPE), "Default request content type expected.");
- Assert.assertEquals("Default request query parameters expected.",
- TestingFramework.DEFAULT_REQUEST_QUERY,
- request.get(QUERY));
+ Assertions.assertEquals(TestingFramework.DEFAULT_REQUEST_QUERY,
+ request.get(QUERY), "Default request query parameters expected.");
- Assert.assertEquals("Default request headers expected.",
- TestingFramework.DEFAULT_REQUEST_HEADERS,
- request.get(HEADERS));
+ Assertions.assertEquals(TestingFramework.DEFAULT_REQUEST_HEADERS,
+ request.get(HEADERS), "Default request headers expected.");
- Assert.assertEquals("Default protocol version expected.",
- TestingFramework.DEFAULT_REQUEST_PROTOCOL_VERSION,
- request.get(PROTOCOL_VERSION));
+ Assertions.assertEquals(TestingFramework.DEFAULT_REQUEST_PROTOCOL_VERSION,
+ request.get(PROTOCOL_VERSION), "Default protocol version expected.");
final Map<String, Object> responseExpectations = test.initResponseExpectations();
- Assert.assertNotNull("responseExpectations should not be null", responseExpectations);
- Assert.assertEquals("Default status expected.", TestingFramework.DEFAULT_RESPONSE_STATUS,
- responseExpectations.get(STATUS));
+ Assertions.assertNotNull(responseExpectations, "responseExpectations should not be null");
+ Assertions.assertEquals(TestingFramework.DEFAULT_RESPONSE_STATUS,
+ responseExpectations.get(STATUS), "Default status expected.");
- Assert.assertEquals("Default body expected.", TestingFramework.DEFAULT_RESPONSE_BODY,
- responseExpectations.get(BODY));
+ Assertions.assertEquals(TestingFramework.DEFAULT_RESPONSE_BODY,
+ responseExpectations.get(BODY), "Default body expected.");
- Assert.assertEquals("Default response content type expected.", TestingFramework.DEFAULT_RESPONSE_CONTENT_TYPE,
- responseExpectations.get(CONTENT_TYPE));
+ Assertions.assertEquals(TestingFramework.DEFAULT_RESPONSE_CONTENT_TYPE,
+ responseExpectations.get(CONTENT_TYPE), "Default response content type expected.");
- Assert.assertEquals("Default headers expected.", TestingFramework.DEFAULT_RESPONSE_HEADERS,
- responseExpectations.get(HEADERS));
+ Assertions.assertEquals(TestingFramework.DEFAULT_RESPONSE_HEADERS,
+ responseExpectations.get(HEADERS), "Default headers expected.");
}
@Test
@@ -97,7 +92,7 @@ public class TestFrameworkTest {
final FrameworkTest test = new FrameworkTest(testMap);
final Map<String, Object> responseExpectations = test.initResponseExpectations();
- Assert.assertEquals("Status unexpected.", 201, responseExpectations.get(STATUS));
+ Assertions.assertEquals(201, responseExpectations.get(STATUS), "Status unexpected.");
}
@Test
@@ -110,6 +105,6 @@ public class TestFrameworkTest {
final FrameworkTest test = new FrameworkTest(testMap);
final Map<String, Object> requestExpectations = test.initRequest();
- Assert.assertEquals("Method unexpected.", "POST", requestExpectations.get(METHOD));
+ Assertions.assertEquals("POST", requestExpectations.get(METHOD), "Method unexpected.");
}
}
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 cf63850..dfb09be 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
@@ -38,6 +38,7 @@ import static org.apache.hc.core5.testing.framework.ClientPOJOAdapter.QUERY;
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 static org.hamcrest.MatcherAssert.assertThat;
import java.util.HashMap;
import java.util.HashSet;
@@ -50,9 +51,8 @@ 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.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import org.mockito.ArgumentMatchers;
import org.mockito.Mockito;
@@ -66,7 +66,7 @@ public class TestTestingFramework {
private void assertUnmodifiable(final Map<String, String> map) {
final String aKey = (String) map.keySet().toArray()[0];
- Assert.assertThrows(UnsupportedOperationException.class, () -> map.remove(aKey));
+ Assertions.assertThrows(UnsupportedOperationException.class, () -> map.remove(aKey));
}
private TestingFramework newWebServerTestingFramework(final ClientTestingAdapter adapter)
@@ -85,7 +85,7 @@ public class TestTestingFramework {
@Test
public void runTestsWithoutSettingAdapterThrows() throws Exception {
final TestingFramework framework = newWebServerTestingFramework();
- Assert.assertThrows(TestingFrameworkException.class, () -> framework.runTests());
+ Assertions.assertThrows(TestingFrameworkException.class, () -> framework.runTests());
}
@Test
@@ -93,7 +93,7 @@ public class TestTestingFramework {
final ClientTestingAdapter adapter = null;
final TestingFramework framework = newWebServerTestingFramework(adapter);
- Assert.assertThrows(TestingFrameworkException.class, () -> framework.runTests());
+ Assertions.assertThrows(TestingFrameworkException.class, () -> framework.runTests());
}
@Test
@@ -102,7 +102,7 @@ public class TestTestingFramework {
final TestingFramework framework = newWebServerTestingFramework(adapter);
framework.setAdapter(adapter);
- Assert.assertThrows(TestingFrameworkException.class, () -> framework.runTests());
+ Assertions.assertThrows(TestingFrameworkException.class, () -> framework.runTests());
}
@Test
@@ -160,21 +160,19 @@ public class TestTestingFramework {
final Map<String, Object> request,
final TestingFrameworkRequestHandler requestHandler,
final Map<String, Object> responseExpectations) throws TestingFrameworkException {
- MatcherAssert.assertThat(defaultURI, matchesDefaultURI());
+ assertThat(defaultURI, matchesDefaultURI());
- Assert.assertNotNull("request should not be null", request);
+ Assertions.assertNotNull(request, "request should not be null");
// The request should be equal to the default request.
final Map<String, Object> defaultRequest = new FrameworkTest().initRequest();
- Assert.assertEquals("The request does not match the default", defaultRequest, request);
+ Assertions.assertEquals(defaultRequest, request, "The request does not match the default");
- Assert.assertSame("The request handler should have been passed to the adapter",
- mockRequestHandler, requestHandler);
+ Assertions.assertSame(mockRequestHandler, requestHandler, "The request handler should have been passed to the adapter");
// The responseExpectations should be equal to the default.
final Map<String, Object> defaultResponseExpectations = new FrameworkTest().initResponseExpectations();
- Assert.assertEquals("The responseExpectations do not match the defaults",
- defaultResponseExpectations, responseExpectations);
+ Assertions.assertEquals(defaultResponseExpectations, responseExpectations, "The responseExpectations do not match the defaults");
final Map<String, Object> response = new HashMap<>();
response.put(STATUS, responseExpectations.get(STATUS));
@@ -224,7 +222,7 @@ public class TestTestingFramework {
final TestingFrameworkRequestHandler requestHandler,
final Map<String, Object> responseExpectations) {
- Assert.assertEquals(200, responseExpectations.get(STATUS));
+ Assertions.assertEquals(200, responseExpectations.get(STATUS));
// return a different status than expected.
final Map<String, Object> response = new HashMap<>();
@@ -237,7 +235,7 @@ public class TestTestingFramework {
framework.addTest();
- Assert.assertThrows(TestingFrameworkException.class, () -> framework.runTests());
+ Assertions.assertThrows(TestingFrameworkException.class, () -> framework.runTests());
}
private Map<String, Object> alreadyCheckedResponse() {
@@ -281,7 +279,7 @@ public class TestTestingFramework {
final TestingFrameworkRequestHandler requestHandler,
final Map<String, Object> responseExpectations) {
- Assert.assertEquals(TestingFramework.DEFAULT_RESPONSE_BODY, responseExpectations.get(BODY));
+ Assertions.assertEquals(TestingFramework.DEFAULT_RESPONSE_BODY, responseExpectations.get(BODY));
final Map<String, Object> response = new HashMap<>();
response.put(STATUS, TestingFramework.ALREADY_CHECKED);
@@ -296,7 +294,7 @@ public class TestTestingFramework {
framework.addTest();
- Assert.assertThrows(TestingFrameworkException.class, () -> framework.runTests());
+ Assertions.assertThrows(TestingFrameworkException.class, () -> framework.runTests());
}
@Test
@@ -309,7 +307,7 @@ public class TestTestingFramework {
final TestingFrameworkRequestHandler requestHandler,
final Map<String, Object> responseExpectations) {
- Assert.assertEquals(TestingFramework.DEFAULT_RESPONSE_CONTENT_TYPE, responseExpectations.get(CONTENT_TYPE));
+ Assertions.assertEquals(TestingFramework.DEFAULT_RESPONSE_CONTENT_TYPE, responseExpectations.get(CONTENT_TYPE));
final Map<String, Object> response = new HashMap<>();
response.put(STATUS, TestingFramework.ALREADY_CHECKED);
@@ -327,7 +325,7 @@ public class TestTestingFramework {
framework.addTest();
- Assert.assertThrows(TestingFrameworkException.class, () -> framework.runTests());
+ Assertions.assertThrows(TestingFrameworkException.class, () -> framework.runTests());
}
@Test
@@ -335,21 +333,21 @@ public class TestTestingFramework {
// save a copy of the headers to make sure they haven't changed at the end of this test.
@SuppressWarnings("unchecked")
final Map<String, String> headersCopy = (Map<String, String>) TestingFramework.deepcopy(TestingFramework.DEFAULT_RESPONSE_HEADERS);
- Assert.assertEquals(TestingFramework.DEFAULT_RESPONSE_HEADERS, headersCopy);
+ Assertions.assertEquals(TestingFramework.DEFAULT_RESPONSE_HEADERS, headersCopy);
final Map<String, Object> deepMap = new HashMap<>();
deepMap.put(HEADERS, TestingFramework.DEFAULT_RESPONSE_HEADERS);
@SuppressWarnings("unchecked")
final Map<String, Object> deepMapCopy = (Map<String, Object>) TestingFramework.deepcopy(deepMap);
- Assert.assertEquals(deepMap, deepMapCopy);
+ Assertions.assertEquals(deepMap, deepMapCopy);
@SuppressWarnings("unchecked")
final Map<String, String> headersMap = (Map<String, String>) deepMapCopy.get(HEADERS);
- Assert.assertEquals(headersCopy, headersMap);
+ Assertions.assertEquals(headersCopy, headersMap);
// now make sure the default headers have not changed for some unexpected reason.
- Assert.assertEquals(TestingFramework.DEFAULT_RESPONSE_HEADERS, headersCopy);
+ Assertions.assertEquals(TestingFramework.DEFAULT_RESPONSE_HEADERS, headersCopy);
}
@Test
@@ -362,7 +360,7 @@ public class TestTestingFramework {
final TestingFrameworkRequestHandler requestHandler,
final Map<String, Object> responseExpectations) {
- Assert.assertEquals(TestingFramework.DEFAULT_RESPONSE_HEADERS, responseExpectations.get(HEADERS));
+ Assertions.assertEquals(TestingFramework.DEFAULT_RESPONSE_HEADERS, responseExpectations.get(HEADERS));
@SuppressWarnings("unchecked")
final Map<String, String> headersCopy = (Map<String, String>) deepcopy(responseExpectations.get(HEADERS));
@@ -385,7 +383,7 @@ public class TestTestingFramework {
framework.addTest();
- Assert.assertThrows(TestingFrameworkException.class, () -> framework.runTests());
+ Assertions.assertThrows(TestingFrameworkException.class, () -> framework.runTests());
}
@Test
@@ -398,7 +396,7 @@ public class TestTestingFramework {
final TestingFrameworkRequestHandler requestHandler,
final Map<String, Object> responseExpectations) {
- Assert.assertEquals(TestingFramework.DEFAULT_RESPONSE_HEADERS, responseExpectations.get(HEADERS));
+ Assertions.assertEquals(TestingFramework.DEFAULT_RESPONSE_HEADERS, responseExpectations.get(HEADERS));
@SuppressWarnings("unchecked")
final Map<String, String> headersCopy = (Map<String, String>) deepcopy(responseExpectations.get(HEADERS));
@@ -421,14 +419,14 @@ public class TestTestingFramework {
framework.addTest();
- Assert.assertThrows(TestingFrameworkException.class, () -> framework.runTests());
+ Assertions.assertThrows(TestingFrameworkException.class, () -> framework.runTests());
}
private Object deepcopy(final Object obj) {
try {
return TestingFramework.deepcopy(obj);
} catch (final Exception e) {
- Assert.fail("deepcopy failed: " + e.getMessage());
+ Assertions.fail("deepcopy failed: " + e.getMessage());
return null;
}
}
@@ -443,7 +441,7 @@ public class TestTestingFramework {
final TestingFrameworkRequestHandler requestHandler,
final Map<String, Object> responseExpectations) throws TestingFrameworkException {
// change the request from what is expected.
- Assert.assertEquals("GET", request.get(METHOD));
+ Assertions.assertEquals("GET", request.get(METHOD));
request.put(METHOD, "POST");
return super.execute(defaultURI, request, requestHandler, responseExpectations);
}
@@ -458,7 +456,7 @@ public class TestTestingFramework {
framework.addTest(test);
- final TestingFrameworkException exception = Assert.assertThrows(TestingFrameworkException.class, () ->
+ final TestingFrameworkException exception = Assertions.assertThrows(TestingFrameworkException.class, () ->
framework.runTests());
// make sure the HTTP Client name is in the message.
final String message = exception.getMessage();
@@ -466,13 +464,9 @@ public class TestTestingFramework {
final String httpClientName = pojoAdapter == null ?
TestingFrameworkException.NO_HTTP_CLIENT :
pojoAdapter.getClientName();
- Assert.assertTrue(
- "Message should contain httpClientName of " + httpClientName + "; message=" + message,
- message.contains(httpClientName));
+ Assertions.assertTrue(message.contains(httpClientName), "Message should contain httpClientName of " + httpClientName + "; message=" + message);
- Assert.assertTrue(
- "Message should contain the test. message=" + message,
- message.contains("MyName"));
+ Assertions.assertTrue(message.contains("MyName"), "Message should contain the test. message=" + message);
}
@Test
@@ -502,7 +496,7 @@ public class TestTestingFramework {
final TestingFrameworkRequestHandler requestHandler,
final Map<String, Object> responseExpectations)
throws TestingFrameworkException {
- Assert.assertEquals(201, responseExpectations.get(STATUS));
+ Assertions.assertEquals(201, responseExpectations.get(STATUS));
return alreadyCheckedResponse();
}
};
@@ -535,7 +529,7 @@ public class TestTestingFramework {
// change the request from what is expected.
@SuppressWarnings("unchecked")
final Map<String, String> query = (Map<String, String>) request.get(QUERY);
- Assert.assertTrue(query.containsKey("p1"));
+ Assertions.assertTrue(query.containsKey("p1"));
query.remove("p1");
return super.execute(defaultURI, request, requestHandler, responseExpectations);
}
@@ -545,7 +539,7 @@ public class TestTestingFramework {
framework.addTest();
- Assert.assertThrows(TestingFrameworkException.class, () -> framework.runTests());
+ Assertions.assertThrows(TestingFrameworkException.class, () -> framework.runTests());
}
@Test
@@ -560,7 +554,7 @@ public class TestTestingFramework {
// change the request from what is expected.
@SuppressWarnings("unchecked")
final Map<String, String> query = (Map<String, String>) request.get(QUERY);
- Assert.assertTrue(query.containsKey("p1"));
+ Assertions.assertTrue(query.containsKey("p1"));
query.put("p1", query.get("p1") + "junk");
return super.execute(defaultURI, request, requestHandler, responseExpectations);
}
@@ -570,7 +564,7 @@ public class TestTestingFramework {
framework.addTest();
- Assert.assertThrows(TestingFrameworkException.class, () -> framework.runTests());
+ Assertions.assertThrows(TestingFrameworkException.class, () -> framework.runTests());
}
@Test
@@ -585,7 +579,7 @@ public class TestTestingFramework {
// change the request from what is expected.
@SuppressWarnings("unchecked")
final Map<String, String> headers = (Map<String, String>) request.get(HEADERS);
- Assert.assertTrue(headers.containsKey("header1"));
+ Assertions.assertTrue(headers.containsKey("header1"));
headers.remove("header1");
return super.execute(defaultURI, request, requestHandler, responseExpectations);
}
@@ -595,7 +589,7 @@ public class TestTestingFramework {
framework.addTest();
- Assert.assertThrows(TestingFrameworkException.class, () -> framework.runTests());
+ Assertions.assertThrows(TestingFrameworkException.class, () -> framework.runTests());
}
@Test
@@ -610,7 +604,7 @@ public class TestTestingFramework {
// change the request from what is expected.
@SuppressWarnings("unchecked")
final Map<String, String> headers = (Map<String, String>) request.get(HEADERS);
- Assert.assertTrue(headers.containsKey("header1"));
+ Assertions.assertTrue(headers.containsKey("header1"));
headers.put("header1", headers.get("header1") + "junk");
return super.execute(defaultURI, request, requestHandler, responseExpectations);
}
@@ -620,7 +614,7 @@ public class TestTestingFramework {
framework.addTest();
- Assert.assertThrows(TestingFrameworkException.class, () -> framework.runTests());
+ Assertions.assertThrows(TestingFrameworkException.class, () -> framework.runTests());
}
@Test
@@ -634,7 +628,7 @@ public class TestTestingFramework {
final Map<String, Object> responseExpectations) throws TestingFrameworkException {
// change the request from what is expected.
final String body = (String) request.get(BODY);
- Assert.assertNotNull(body);
+ Assertions.assertNotNull(body);
request.put(BODY, request.get(BODY) + "junk");
return super.execute(defaultURI, request, requestHandler, responseExpectations);
}
@@ -644,7 +638,7 @@ public class TestTestingFramework {
framework.addTest();
- Assert.assertThrows(TestingFrameworkException.class, () -> framework.runTests());
+ Assertions.assertThrows(TestingFrameworkException.class, () -> framework.runTests());
}
@Test
@@ -658,7 +652,7 @@ public class TestTestingFramework {
final Map<String, Object> responseExpectations) throws TestingFrameworkException {
// change the request from what is expected.
final String contentType = (String) request.get(CONTENT_TYPE);
- Assert.assertNotNull(contentType);
+ Assertions.assertNotNull(contentType);
request.put(CONTENT_TYPE, request.get(CONTENT_TYPE) + "junk");
return super.execute(defaultURI, request, requestHandler, responseExpectations);
}
@@ -668,7 +662,7 @@ public class TestTestingFramework {
framework.addTest();
- Assert.assertThrows(TestingFrameworkException.class, () -> framework.runTests());
+ Assertions.assertThrows(TestingFrameworkException.class, () -> framework.runTests());
}
@Test
@@ -682,7 +676,7 @@ public class TestTestingFramework {
final Map<String, Object> responseExpectations) throws TestingFrameworkException {
// change the request from what is expected.
final ProtocolVersion protocolVersion = (ProtocolVersion) request.get(PROTOCOL_VERSION);
- Assert.assertNotNull(protocolVersion);
+ Assertions.assertNotNull(protocolVersion);
request.put(PROTOCOL_VERSION, HttpVersion.HTTP_1_0);
return super.execute(defaultURI, request, requestHandler, responseExpectations);
}
@@ -692,7 +686,7 @@ public class TestTestingFramework {
framework.addTest();
- Assert.assertThrows(TestingFrameworkException.class, () -> framework.runTests());
+ Assertions.assertThrows(TestingFrameworkException.class, () -> framework.runTests());
}
@Test
@@ -720,7 +714,7 @@ public class TestTestingFramework {
framework.addTest();
- Assert.assertThrows(TestingFrameworkException.class, () -> framework.runTests());
+ Assertions.assertThrows(TestingFrameworkException.class, () -> framework.runTests());
}
@Test
@@ -734,14 +728,14 @@ public class TestTestingFramework {
final Map<String, Object> responseExpectations) throws TestingFrameworkException {
// change the responseExpectations from what is expected. The change should be ignored
// by the request handler, and a 200 should actually be returned.
- Assert.assertEquals(200, responseExpectations.get(STATUS));
+ Assertions.assertEquals(200, responseExpectations.get(STATUS));
// The next line is needed because we have to make a copy of the responseExpectations.
// It is an unmodifiable map.
final Map<String, Object> tempResponseExpectations = new HashMap<>(responseExpectations);
tempResponseExpectations.put(STATUS, 201);
final Map<String, Object> response = super.execute(defaultURI, request, requestHandler, tempResponseExpectations);
- Assert.assertEquals(200, response.get(STATUS));
+ Assertions.assertEquals(200, response.get(STATUS));
return response;
}
@@ -767,7 +761,7 @@ public class TestTestingFramework {
final TestingFrameworkRequestHandler requestHandler,
final Map<String, Object> responseExpectations) throws TestingFrameworkException {
// make sure the modifyRequest method was called by seeing if the request was modified.
- Assert.assertTrue("modifyRequest should have been called.", request.containsKey(UNLIKELY_ITEM));
+ Assertions.assertTrue(request.containsKey(UNLIKELY_ITEM), "modifyRequest should have been called.");
final Map<String, Object> response = new HashMap<>();
response.put(STATUS, responseExpectations.get(STATUS));
@@ -809,7 +803,7 @@ public class TestTestingFramework {
final TestingFrameworkRequestHandler requestHandler,
final Map<String, Object> responseExpectations) throws TestingFrameworkException {
// make sure the modifyRequest method was called by seeing if the request was modified.
- Assert.assertTrue("modifyResponseExpectations should have been called.", responseExpectations.containsKey(UNLIKELY_ITEM));
+ Assertions.assertTrue(responseExpectations.containsKey(UNLIKELY_ITEM), "modifyResponseExpectations should have been called.");
final Map<String, Object> response = new HashMap<>();
response.put(STATUS, responseExpectations.get(STATUS));
@@ -851,7 +845,7 @@ public class TestTestingFramework {
final TestingFrameworkRequestHandler requestHandler,
final Map<String, Object> responseExpectations) throws TestingFrameworkException {
- Assert.fail("callMethod should not have been called");
+ Assertions.fail("callMethod should not have been called");
return null;
}
@@ -892,7 +886,7 @@ public class TestTestingFramework {
framework.runTests();
for (final String method : TestingFramework.ALL_METHODS) {
- Assert.assertTrue("Method not in default tests. method=" + method, calledMethodSet.contains(method));
+ Assertions.assertTrue(calledMethodSet.contains(method), "Method not in default tests. method=" + method);
}
}
@@ -1046,14 +1040,13 @@ public class TestTestingFramework {
final Map<String, Object> responseExpectations) throws TestingFrameworkException {
@SuppressWarnings("unchecked")
final Map<String, String> query = (Map<String, String>) request.get(QUERY);
- Assert.assertTrue("Parameters appended to the path should have been put in the query.",
- query.containsKey("stuffParm"));
+ Assertions.assertTrue(query.containsKey("stuffParm"), "Parameters appended to the path should have been put in the query.");
- Assert.assertTrue(query.containsKey("stuffParm2"));
- Assert.assertEquals("stuff", query.get("stuffParm"));
- Assert.assertEquals("stuff2", query.get("stuffParm2"));
+ Assertions.assertTrue(query.containsKey("stuffParm2"));
+ Assertions.assertEquals("stuff", query.get("stuffParm"));
+ Assertions.assertEquals("stuff2", query.get("stuffParm2"));
- Assert.assertEquals("/stuff", request.get(PATH));
+ Assertions.assertEquals("/stuff", request.get(PATH));
return alreadyCheckedResponse();
}
};
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestTestingFrameworkRequestHandler.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestTestingFrameworkRequestHandler.java
index 7d92f1d..87e312f 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestTestingFrameworkRequestHandler.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestTestingFrameworkRequestHandler.java
@@ -33,8 +33,8 @@ import org.apache.hc.core5.http.ClassicHttpRequest;
import org.apache.hc.core5.http.ClassicHttpResponse;
import org.apache.hc.core5.http.HttpException;
import org.apache.hc.core5.http.protocol.HttpContext;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestTestingFrameworkRequestHandler {
@Test
@@ -64,9 +64,9 @@ public class TestTestingFrameworkRequestHandler {
};
handler.handle(null, null, null);
- final TestingFrameworkException exception = Assert.assertThrows(TestingFrameworkException.class,
+ final TestingFrameworkException exception = Assertions.assertThrows(TestingFrameworkException.class,
() -> handler.assertNothingThrown());
- Assert.assertEquals("Unexpected message", errorMessage, exception.getMessage());
+ Assertions.assertEquals(errorMessage, exception.getMessage(), "Unexpected message");
// a second call should not throw
handler.assertNothingThrown();
}
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/AsyncServerBootstrapFilterTest.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/AsyncServerBootstrapFilterTest.java
index ea8f3cd..3fc6a50 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/AsyncServerBootstrapFilterTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/AsyncServerBootstrapFilterTest.java
@@ -27,6 +27,8 @@
package org.apache.hc.core5.testing.nio;
+import static org.hamcrest.MatcherAssert.assertThat;
+
import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.concurrent.Future;
@@ -61,13 +63,14 @@ 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.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport;
import org.junit.rules.ExternalResource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+@EnableRuleMigrationSupport
public class AsyncServerBootstrapFilterTest {
private final Logger log = LoggerFactory.getLogger(getClass());
@@ -176,11 +179,11 @@ public class AsyncServerBootstrapFilterTest {
new StringAsyncEntityProducer("some stuff", ContentType.TEXT_PLAIN)),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
final Message<HttpResponse, String> message = resultFuture.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- MatcherAssert.assertThat(message, CoreMatchers.notNullValue());
+ assertThat(message, CoreMatchers.notNullValue());
final HttpResponse response = message.getHead();
- MatcherAssert.assertThat(response.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ assertThat(response.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final Header testFilterHeader = response.getHeader("X-Test-Filter");
- MatcherAssert.assertThat(testFilterHeader, CoreMatchers.notNullValue());
+ assertThat(testFilterHeader, CoreMatchers.notNullValue());
}
}
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 fc5cc36..f29d7cd 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,9 +27,10 @@
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 static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.net.InetSocketAddress;
import java.util.Arrays;
@@ -62,23 +63,23 @@ import org.apache.hc.core5.reactor.ListenerEndpoint;
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.Rule;
import org.junit.Test;
+import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport;
import org.junit.rules.ExternalResource;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+@EnableRuleMigrationSupport
@RunWith(Parameterized.class)
public class H2AlpnTest {
private final Logger log = LoggerFactory.getLogger(getClass());
private static final Timeout TIMEOUT = Timeout.ofSeconds(30);
- @Parameters(name = "strict h2 ALPN: {0}, h2 allowed: {1}")
+ @Parameterized.Parameters(name = "strict h2 ALPN: {0}, h2 allowed: {1}")
public static Iterable<Object[]> parameters() {
return Arrays.asList(new Object[][] {
{ true, true },
@@ -179,18 +180,18 @@ public class H2AlpnTest {
message1 = resultFuture1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
} catch (final ExecutionException e) {
final Throwable cause = e.getCause();
- assertFalse("h2 negotiation was enabled, but h2 was not negotiated", h2Allowed);
+ assertFalse(h2Allowed, "h2 negotiation was enabled, but h2 was not negotiated");
assertTrue(cause instanceof ProtocolNegotiationException);
assertEquals("ALPN: missing application protocol", cause.getMessage());
- assertTrue("strict ALPN mode was not enabled, but the client negotiator still threw", strictALPN);
+ assertTrue(strictALPN, "strict ALPN mode was not enabled, but the client negotiator still threw");
return;
}
- assertTrue("h2 negotiation was disabled, but h2 was negotiated", h2Allowed);
- MatcherAssert.assertThat(message1, CoreMatchers.notNullValue());
+ assertTrue(h2Allowed, "h2 negotiation was disabled, but h2 was negotiated");
+ assertThat(message1, CoreMatchers.notNullValue());
final HttpResponse response1 = message1.getHead();
- MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body1 = message1.getBody();
- MatcherAssert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
+ 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 19c127e..9651469 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,6 +27,8 @@
package org.apache.hc.core5.testing.nio;
+import static org.hamcrest.MatcherAssert.assertThat;
+
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
@@ -120,17 +122,18 @@ 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;
import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@RunWith(Parameterized.class)
+@EnableRuleMigrationSupport
public class H2IntegrationTest extends InternalH2ServerTestBase {
private final Logger log = LoggerFactory.getLogger(getClass());
@@ -152,7 +155,7 @@ public class H2IntegrationTest extends InternalH2ServerTestBase {
private H2TestClient client;
- @Before
+ @BeforeEach
public void setup() throws Exception {
log.debug("Starting up test client");
client = new H2TestClient(buildReactorConfig(),
@@ -163,7 +166,7 @@ public class H2IntegrationTest extends InternalH2ServerTestBase {
return IOReactorConfig.DEFAULT;
}
- @After
+ @AfterEach
public void cleanup() throws Exception {
log.debug("Shutting down test client");
if (client != null) {
@@ -199,12 +202,12 @@ public class H2IntegrationTest extends InternalH2ServerTestBase {
while (!queue.isEmpty()) {
final Future<Message<HttpResponse, String>> future = queue.remove();
final Message<HttpResponse, String> result = future.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result);
+ Assertions.assertNotNull(result);
final HttpResponse response = result.getHead();
final String entity = result.getBody();
- Assert.assertNotNull(response);
- Assert.assertEquals(200, response.getCode());
- Assert.assertEquals("Hi there", entity);
+ Assertions.assertNotNull(response);
+ Assertions.assertEquals(200, response.getCode());
+ Assertions.assertEquals("Hi there", entity);
}
}
@@ -223,11 +226,11 @@ public class H2IntegrationTest extends InternalH2ServerTestBase {
new BasicRequestProducer(Method.HEAD, createRequestURI(serverEndpoint, "/hello")),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
final Message<HttpResponse, String> result = future.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result);
+ Assertions.assertNotNull(result);
final HttpResponse response1 = result.getHead();
- Assert.assertNotNull(response1);
- Assert.assertEquals(200, response1.getCode());
- Assert.assertNull(result.getBody());
+ Assertions.assertNotNull(response1);
+ Assertions.assertEquals(200, response1.getCode());
+ Assertions.assertNull(result.getBody());
}
}
@@ -250,27 +253,27 @@ public class H2IntegrationTest extends InternalH2ServerTestBase {
new BasicResponseConsumer<>(new StringAsyncEntityConsumer(512)), null);
final Message<HttpResponse, String> result1 = future1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result1);
+ Assertions.assertNotNull(result1);
final HttpResponse response1 = result1.getHead();
- Assert.assertNotNull(response1);
- Assert.assertEquals(200, response1.getCode());
+ Assertions.assertNotNull(response1);
+ Assertions.assertEquals(200, response1.getCode());
final String s1 = result1.getBody();
- Assert.assertNotNull(s1);
+ Assertions.assertNotNull(s1);
final StringTokenizer t1 = new StringTokenizer(s1, "\r\n");
while (t1.hasMoreTokens()) {
- Assert.assertEquals("0123456789abcdef", t1.nextToken());
+ Assertions.assertEquals("0123456789abcdef", t1.nextToken());
}
final Message<HttpResponse, String> result2 = future2.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result2);
+ Assertions.assertNotNull(result2);
final HttpResponse response2 = result2.getHead();
- Assert.assertNotNull(response2);
- Assert.assertEquals(200, response2.getCode());
+ Assertions.assertNotNull(response2);
+ Assertions.assertEquals(200, response2.getCode());
final String s2 = result2.getBody();
- Assert.assertNotNull(s2);
+ Assertions.assertNotNull(s2);
final StringTokenizer t2 = new StringTokenizer(s2, "\r\n");
while (t2.hasMoreTokens()) {
- Assert.assertEquals("0123456789abcdef", t2.nextToken());
+ Assertions.assertEquals("0123456789abcdef", t2.nextToken());
}
}
@@ -295,12 +298,12 @@ public class H2IntegrationTest extends InternalH2ServerTestBase {
while (!queue.isEmpty()) {
final Future<Message<HttpResponse, String>> future = queue.remove();
final Message<HttpResponse, String> result = future.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result);
+ Assertions.assertNotNull(result);
final HttpResponse response = result.getHead();
final String entity1 = result.getBody();
- Assert.assertNotNull(response);
- Assert.assertEquals(200, response.getCode());
- Assert.assertEquals("Hi back", entity1);
+ Assertions.assertNotNull(response);
+ Assertions.assertEquals(200, response.getCode());
+ Assertions.assertEquals("Hi back", entity1);
}
}
@@ -319,15 +322,15 @@ public class H2IntegrationTest extends InternalH2ServerTestBase {
new MultiLineEntityProducer("0123456789abcdef", 5000)),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
final Message<HttpResponse, String> result1 = future1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result1);
+ Assertions.assertNotNull(result1);
final HttpResponse response1 = result1.getHead();
- Assert.assertNotNull(response1);
- Assert.assertEquals(200, response1.getCode());
+ Assertions.assertNotNull(response1);
+ Assertions.assertEquals(200, response1.getCode());
final String s1 = result1.getBody();
- Assert.assertNotNull(s1);
+ Assertions.assertNotNull(s1);
final StringTokenizer t1 = new StringTokenizer(s1, "\r\n");
while (t1.hasMoreTokens()) {
- Assert.assertEquals("0123456789abcdef", t1.nextToken());
+ Assertions.assertEquals("0123456789abcdef", t1.nextToken());
}
}
@@ -368,15 +371,15 @@ public class H2IntegrationTest extends InternalH2ServerTestBase {
null);
final Message<HttpResponse, String> result1 = future1.get(LONG_TIMEOUT.getDuration(), LONG_TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result1);
+ Assertions.assertNotNull(result1);
final HttpResponse response1 = result1.getHead();
- Assert.assertNotNull(response1);
- Assert.assertEquals(200, response1.getCode());
+ Assertions.assertNotNull(response1);
+ Assertions.assertEquals(200, response1.getCode());
final String s1 = result1.getBody();
- Assert.assertNotNull(s1);
+ Assertions.assertNotNull(s1);
final StringTokenizer t1 = new StringTokenizer(s1, "\r\n");
while (t1.hasMoreTokens()) {
- Assert.assertEquals("0123456789abcd", t1.nextToken());
+ Assertions.assertEquals("0123456789abcd", t1.nextToken());
}
}
@@ -414,15 +417,15 @@ public class H2IntegrationTest extends InternalH2ServerTestBase {
}),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
final Message<HttpResponse, String> result1 = future1.get(LONG_TIMEOUT.getDuration(), LONG_TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result1);
+ Assertions.assertNotNull(result1);
final HttpResponse response1 = result1.getHead();
- Assert.assertNotNull(response1);
- Assert.assertEquals(200, response1.getCode());
+ Assertions.assertNotNull(response1);
+ Assertions.assertEquals(200, response1.getCode());
final String s1 = result1.getBody();
- Assert.assertNotNull(s1);
+ Assertions.assertNotNull(s1);
final StringTokenizer t1 = new StringTokenizer(s1, "\r\n");
while (t1.hasMoreTokens()) {
- Assert.assertEquals("0123456789abcdef", t1.nextToken());
+ Assertions.assertEquals("0123456789abcdef", t1.nextToken());
}
}
@@ -490,15 +493,15 @@ public class H2IntegrationTest extends InternalH2ServerTestBase {
new BasicRequestProducer(request1, new MultiLineEntityProducer("0123456789abcd", 2000)),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
final Message<HttpResponse, String> result1 = future1.get(LONG_TIMEOUT.getDuration(), LONG_TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result1);
+ Assertions.assertNotNull(result1);
final HttpResponse response1 = result1.getHead();
- Assert.assertNotNull(response1);
- Assert.assertEquals(200, response1.getCode());
+ Assertions.assertNotNull(response1);
+ Assertions.assertEquals(200, response1.getCode());
final String s1 = result1.getBody();
- Assert.assertNotNull(s1);
+ Assertions.assertNotNull(s1);
final StringTokenizer t1 = new StringTokenizer(s1, "\r\n");
while (t1.hasMoreTokens()) {
- Assert.assertEquals("0123456789abcd", t1.nextToken());
+ Assertions.assertEquals("0123456789abcd", t1.nextToken());
}
}
@@ -551,22 +554,22 @@ public class H2IntegrationTest extends InternalH2ServerTestBase {
null,
null);
final Message<HttpResponse, String> result1 = future1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result1);
+ Assertions.assertNotNull(result1);
final HttpResponse response1 = result1.getHead();
final String entity1 = result1.getBody();
- Assert.assertNotNull(response1);
- Assert.assertEquals(200, response1.getCode());
- Assert.assertEquals("Hi there", entity1);
+ Assertions.assertNotNull(response1);
+ Assertions.assertEquals(200, response1.getCode());
+ Assertions.assertEquals("Hi there", entity1);
final Message<HttpResponse, String> result2 = pushMessageQueue.poll(5, TimeUnit.SECONDS);
- Assert.assertNotNull(result2);
+ Assertions.assertNotNull(result2);
final HttpResponse response2 = result2.getHead();
final String entity2 = result2.getBody();
- Assert.assertEquals(200, response2.getCode());
- Assert.assertNotNull(entity2);
+ Assertions.assertEquals(200, response2.getCode());
+ Assertions.assertNotNull(entity2);
final StringTokenizer t1 = new StringTokenizer(entity2, "\r\n");
while (t1.hasMoreTokens()) {
- Assert.assertEquals("Pushing lots of stuff", t1.nextToken());
+ Assertions.assertEquals("Pushing lots of stuff", t1.nextToken());
}
}
@@ -627,22 +630,22 @@ public class H2IntegrationTest extends InternalH2ServerTestBase {
new BasicRequestProducer(Method.GET, createRequestURI(serverEndpoint, "/hello")),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
final Message<HttpResponse, String> result1 = future1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result1);
+ Assertions.assertNotNull(result1);
final HttpResponse response1 = result1.getHead();
final String entity1 = result1.getBody();
- Assert.assertNotNull(response1);
- Assert.assertEquals(200, response1.getCode());
- Assert.assertEquals("Hi there", entity1);
+ Assertions.assertNotNull(response1);
+ Assertions.assertEquals(200, response1.getCode());
+ Assertions.assertEquals("Hi there", entity1);
final Object result2 = pushResultQueue.poll(5, TimeUnit.SECONDS);
- Assert.assertNotNull(result2);
- Assert.assertTrue(result2 instanceof H2StreamResetException);
- Assert.assertEquals(H2Error.REFUSED_STREAM.getCode(), ((H2StreamResetException) result2).getCode());
+ Assertions.assertNotNull(result2);
+ Assertions.assertTrue(result2 instanceof H2StreamResetException);
+ Assertions.assertEquals(H2Error.REFUSED_STREAM.getCode(), ((H2StreamResetException) result2).getCode());
final Object result3 = pushResultQueue.poll(5, TimeUnit.SECONDS);
- Assert.assertNotNull(result3);
- Assert.assertTrue(result3 instanceof H2StreamResetException);
- Assert.assertEquals(H2Error.REFUSED_STREAM.getCode(), ((H2StreamResetException) result3).getCode());
+ Assertions.assertNotNull(result3);
+ Assertions.assertTrue(result3 instanceof H2StreamResetException);
+ Assertions.assertEquals(H2Error.REFUSED_STREAM.getCode(), ((H2StreamResetException) result3).getCode());
}
@Test
@@ -667,10 +670,10 @@ public class H2IntegrationTest extends InternalH2ServerTestBase {
while (!queue.isEmpty()) {
final Future<Message<HttpResponse, Void>> future = queue.remove();
final Message<HttpResponse, Void> result = future.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result);
+ Assertions.assertNotNull(result);
final HttpResponse response = result.getHead();
- Assert.assertNotNull(response);
- Assert.assertEquals(200, response.getCode());
+ Assertions.assertNotNull(response);
+ Assertions.assertEquals(200, response.getCode());
}
}
@@ -711,22 +714,22 @@ public class H2IntegrationTest extends InternalH2ServerTestBase {
new BasicRequestProducer(request1, new MultiLineEntityProducer("0123456789abcdef", 5000)),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
final Message<HttpResponse, String> result1 = future1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result1);
+ Assertions.assertNotNull(result1);
final HttpResponse response1 = result1.getHead();
- Assert.assertNotNull(response1);
- Assert.assertEquals(200, response1.getCode());
- Assert.assertNotNull("All is well", result1.getBody());
+ Assertions.assertNotNull(response1);
+ Assertions.assertEquals(200, response1.getCode());
+ Assertions.assertNotNull("All is well", result1.getBody());
final HttpRequest request2 = new BasicHttpRequest(Method.POST, createRequestURI(serverEndpoint, "/echo"));
final Future<Message<HttpResponse, String>> future2 = streamEndpoint.execute(
new BasicRequestProducer(request2, new MultiLineEntityProducer("0123456789abcdef", 5000)),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
final Message<HttpResponse, String> result2 = future2.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result2);
+ Assertions.assertNotNull(result2);
final HttpResponse response2 = result2.getHead();
- Assert.assertNotNull(response2);
- Assert.assertEquals(HttpStatus.SC_UNAUTHORIZED, response2.getCode());
- Assert.assertNotNull("You shall not pass", result2.getBody());
+ Assertions.assertNotNull(response2);
+ Assertions.assertEquals(HttpStatus.SC_UNAUTHORIZED, response2.getCode());
+ Assertions.assertNotNull("You shall not pass", result2.getBody());
}
@Test
@@ -804,11 +807,11 @@ public class H2IntegrationTest extends InternalH2ServerTestBase {
new BasicRequestProducer(request1, new MultiLineEntityProducer("0123456789abcdef", 5000)),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
final Message<HttpResponse, String> result1 = future1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result1);
+ Assertions.assertNotNull(result1);
final HttpResponse response1 = result1.getHead();
- Assert.assertNotNull(response1);
- Assert.assertEquals(HttpStatus.SC_UNAUTHORIZED, response1.getCode());
- Assert.assertNotNull("You shall not pass", result1.getBody());
+ Assertions.assertNotNull(response1);
+ Assertions.assertEquals(HttpStatus.SC_UNAUTHORIZED, response1.getCode());
+ Assertions.assertNotNull("You shall not pass", result1.getBody());
}
@Test
@@ -848,22 +851,22 @@ public class H2IntegrationTest extends InternalH2ServerTestBase {
new BasicRequestProducer(request1, null),
new BasicResponseConsumer<>(entityConsumer), null);
final Message<HttpResponse, String> result1 = future1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result1);
+ Assertions.assertNotNull(result1);
final HttpResponse response1 = result1.getHead();
- Assert.assertNotNull(response1);
- Assert.assertEquals(200, response1.getCode());
- Assert.assertEquals("Hello back with some trailers", result1.getBody());
+ Assertions.assertNotNull(response1);
+ Assertions.assertEquals(200, response1.getCode());
+ Assertions.assertEquals("Hello back with some trailers", result1.getBody());
final List<Header> trailers = entityConsumer.getTrailers();
- Assert.assertNotNull(trailers);
- Assert.assertEquals(2, trailers.size());
+ Assertions.assertNotNull(trailers);
+ Assertions.assertEquals(2, trailers.size());
final Map<String, String> map = new HashMap<>();
for (final Header header: trailers) {
map.put(TextUtils.toLowerCase(header.getName()), header.getValue());
}
final String digest = TextUtils.toHexString(entityConsumer.getDigest());
- Assert.assertEquals("MD5", map.get("digest-algo"));
- Assert.assertEquals(digest, map.get("digest"));
+ Assertions.assertEquals("MD5", map.get("digest-algo"));
+ Assertions.assertEquals(digest, map.get("digest"));
}
@Test
@@ -891,8 +894,8 @@ public class H2IntegrationTest extends InternalH2ServerTestBase {
})), Command.Priority.NORMAL);
}
- Assert.assertTrue(latch.await(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit()));
- Assert.assertEquals(n, count.get());
+ Assertions.assertTrue(latch.await(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit()));
+ Assertions.assertEquals(n, count.get());
}
@Test
@@ -913,12 +916,12 @@ public class H2IntegrationTest extends InternalH2ServerTestBase {
new BasicRequestProducer(request, null),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()),
coreContext, null);
- final ExecutionException exception = Assert.assertThrows(ExecutionException.class, () ->
+ final ExecutionException exception = Assertions.assertThrows(ExecutionException.class, () ->
future.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit()));
- MatcherAssert.assertThat(exception.getCause(), CoreMatchers.instanceOf(ProtocolException.class));
+ assertThat(exception.getCause(), CoreMatchers.instanceOf(ProtocolException.class));
final EndpointDetails endpointDetails = coreContext.getEndpointDetails();
- MatcherAssert.assertThat(endpointDetails.getRequestCount(), CoreMatchers.equalTo(0L));
+ assertThat(endpointDetails.getRequestCount(), CoreMatchers.equalTo(0L));
}
@Test
@@ -940,11 +943,11 @@ public class H2IntegrationTest extends InternalH2ServerTestBase {
new BasicRequestProducer(request1, null),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
final Message<HttpResponse, String> result1 = future1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result1);
+ Assertions.assertNotNull(result1);
final HttpResponse response1 = result1.getHead();
- Assert.assertNotNull(response1);
- Assert.assertEquals(431, response1.getCode());
- Assert.assertEquals("Maximum header list size exceeded", result1.getBody());
+ Assertions.assertNotNull(response1);
+ Assertions.assertEquals(431, response1.getCode());
+ Assertions.assertEquals("Maximum header list size exceeded", result1.getBody());
}
@Test
@@ -974,11 +977,11 @@ public class H2IntegrationTest extends InternalH2ServerTestBase {
new BasicRequestProducer(request1, AsyncEntityProducers.create(b, ContentType.TEXT_PLAIN)),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
final Message<HttpResponse, String> result1 = future1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result1);
+ Assertions.assertNotNull(result1);
final HttpResponse response1 = result1.getHead();
- Assert.assertNotNull(response1);
- Assert.assertEquals(431, response1.getCode());
- Assert.assertEquals("Maximum header list size exceeded", result1.getBody());
+ Assertions.assertNotNull(response1);
+ Assertions.assertEquals(431, response1.getCode());
+ Assertions.assertEquals("Maximum header list size exceeded", result1.getBody());
}
}
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 1e3b06d..c5b8a36 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,6 +27,8 @@
package org.apache.hc.core5.testing.nio;
+import static org.hamcrest.MatcherAssert.assertThat;
+
import java.net.InetSocketAddress;
import java.util.concurrent.Future;
@@ -57,13 +59,14 @@ 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.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport;
import org.junit.rules.ExternalResource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+@EnableRuleMigrationSupport
public class H2ProtocolNegotiationTest {
private static final Timeout TIMEOUT = Timeout.ofSeconds(30);
@@ -156,10 +159,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());
- MatcherAssert.assertThat(message1, CoreMatchers.notNullValue());
+ assertThat(message1, CoreMatchers.notNullValue());
final HttpResponse response1 = message1.getHead();
- MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
- MatcherAssert.assertThat(response1.getVersion(), CoreMatchers.equalTo(HttpVersion.HTTP_1_1));
+ assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ assertThat(response1.getVersion(), CoreMatchers.equalTo(HttpVersion.HTTP_1_1));
}
@Test
@@ -179,10 +182,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());
- MatcherAssert.assertThat(message1, CoreMatchers.notNullValue());
+ assertThat(message1, CoreMatchers.notNullValue());
final HttpResponse response1 = message1.getHead();
- MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
- MatcherAssert.assertThat(response1.getVersion(), CoreMatchers.equalTo(HttpVersion.HTTP_2));
+ assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ assertThat(response1.getVersion(), CoreMatchers.equalTo(HttpVersion.HTTP_2));
}
@Test
@@ -202,10 +205,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());
- MatcherAssert.assertThat(message1, CoreMatchers.notNullValue());
+ assertThat(message1, CoreMatchers.notNullValue());
final HttpResponse response1 = message1.getHead();
- MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
- MatcherAssert.assertThat(response1.getVersion(), CoreMatchers.equalTo(HttpVersion.HTTP_2));
+ assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ assertThat(response1.getVersion(), CoreMatchers.equalTo(HttpVersion.HTTP_2));
}
}
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 7fb874e..0faec22 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,6 +27,8 @@
package org.apache.hc.core5.testing.nio;
+import static org.hamcrest.MatcherAssert.assertThat;
+
import java.net.InetSocketAddress;
import java.util.Arrays;
import java.util.Collection;
@@ -64,9 +66,9 @@ import org.apache.hc.core5.testing.SSLTestContexts;
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.Rule;
import org.junit.Test;
+import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport;
import org.junit.rules.ExternalResource;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@@ -74,6 +76,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@RunWith(Parameterized.class)
+@EnableRuleMigrationSupport
public class H2ServerAndMultiplexingRequesterTest {
private final Logger log = LoggerFactory.getLogger(getClass());
@@ -170,33 +173,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());
- MatcherAssert.assertThat(message1, CoreMatchers.notNullValue());
+ assertThat(message1, CoreMatchers.notNullValue());
final HttpResponse response1 = message1.getHead();
- MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body1 = message1.getBody();
- MatcherAssert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
+ 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());
- MatcherAssert.assertThat(message2, CoreMatchers.notNullValue());
+ assertThat(message2, CoreMatchers.notNullValue());
final HttpResponse response2 = message2.getHead();
- MatcherAssert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body2 = message2.getBody();
- MatcherAssert.assertThat(body2, CoreMatchers.equalTo("some other stuff"));
+ 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());
- MatcherAssert.assertThat(message3, CoreMatchers.notNullValue());
+ assertThat(message3, CoreMatchers.notNullValue());
final HttpResponse response3 = message3.getHead();
- MatcherAssert.assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body3 = message3.getBody();
- MatcherAssert.assertThat(body3, CoreMatchers.equalTo("some more stuff"));
+ assertThat(body3, CoreMatchers.equalTo("some more stuff"));
}
@Test
@@ -226,11 +229,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());
- MatcherAssert.assertThat(message, CoreMatchers.notNullValue());
+ assertThat(message, CoreMatchers.notNullValue());
final HttpResponse response = message.getHead();
- MatcherAssert.assertThat(response.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ assertThat(response.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body = message.getBody();
- MatcherAssert.assertThat(body, CoreMatchers.containsString("stuff"));
+ assertThat(body, CoreMatchers.containsString("stuff"));
}
}
@@ -249,11 +252,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());
- MatcherAssert.assertThat(message1, CoreMatchers.notNullValue());
+ assertThat(message1, CoreMatchers.notNullValue());
final HttpResponse response1 = message1.getHead();
- MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body1 = message1.getBody();
- MatcherAssert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
+ assertThat(body1, CoreMatchers.equalTo("some stuff"));
Thread.sleep(100);
@@ -262,11 +265,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());
- MatcherAssert.assertThat(message2, CoreMatchers.notNullValue());
+ assertThat(message2, CoreMatchers.notNullValue());
final HttpResponse response2 = message2.getHead();
- MatcherAssert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body2 = message2.getBody();
- MatcherAssert.assertThat(body2, CoreMatchers.equalTo("some other stuff"));
+ assertThat(body2, CoreMatchers.equalTo("some other stuff"));
Thread.sleep(100);
@@ -275,11 +278,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());
- MatcherAssert.assertThat(message3, CoreMatchers.notNullValue());
+ assertThat(message3, CoreMatchers.notNullValue());
final HttpResponse response3 = message3.getHead();
- MatcherAssert.assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body3 = message3.getBody();
- MatcherAssert.assertThat(body3, CoreMatchers.equalTo("some more stuff"));
+ assertThat(body3, CoreMatchers.equalTo("some more stuff"));
}
@Test
@@ -323,7 +326,7 @@ public class H2ServerAndMultiplexingRequesterTest {
Thread.sleep(random.nextInt(10));
cancellable.cancel();
}
- MatcherAssert.assertThat(countDownLatch.await(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit()), CoreMatchers.equalTo(true));
+ 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 a52d588..84fd59f 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,6 +27,8 @@
package org.apache.hc.core5.testing.nio;
+import static org.hamcrest.MatcherAssert.assertThat;
+
import java.net.InetSocketAddress;
import java.util.Arrays;
import java.util.Collection;
@@ -61,9 +63,9 @@ 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.Rule;
import org.junit.Test;
+import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport;
import org.junit.rules.ExternalResource;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@@ -71,6 +73,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@RunWith(Parameterized.class)
+@EnableRuleMigrationSupport
public class H2ServerAndRequesterTest {
private final Logger log = LoggerFactory.getLogger(getClass());
@@ -173,33 +176,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());
- MatcherAssert.assertThat(message1, CoreMatchers.notNullValue());
+ assertThat(message1, CoreMatchers.notNullValue());
final HttpResponse response1 = message1.getHead();
- MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body1 = message1.getBody();
- MatcherAssert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
+ 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());
- MatcherAssert.assertThat(message2, CoreMatchers.notNullValue());
+ assertThat(message2, CoreMatchers.notNullValue());
final HttpResponse response2 = message2.getHead();
- MatcherAssert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body2 = message2.getBody();
- MatcherAssert.assertThat(body2, CoreMatchers.equalTo("some other stuff"));
+ 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());
- MatcherAssert.assertThat(message3, CoreMatchers.notNullValue());
+ assertThat(message3, CoreMatchers.notNullValue());
final HttpResponse response3 = message3.getHead();
- MatcherAssert.assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body3 = message3.getBody();
- MatcherAssert.assertThat(body3, CoreMatchers.equalTo("some more stuff"));
+ assertThat(body3, CoreMatchers.equalTo("some more stuff"));
}
@Test
@@ -220,33 +223,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());
- MatcherAssert.assertThat(message1, CoreMatchers.notNullValue());
+ assertThat(message1, CoreMatchers.notNullValue());
final HttpResponse response1 = message1.getHead();
- MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body1 = message1.getBody();
- MatcherAssert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
+ 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());
- MatcherAssert.assertThat(message2, CoreMatchers.notNullValue());
+ assertThat(message2, CoreMatchers.notNullValue());
final HttpResponse response2 = message2.getHead();
- MatcherAssert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body2 = message2.getBody();
- MatcherAssert.assertThat(body2, CoreMatchers.equalTo("some other stuff"));
+ 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());
- MatcherAssert.assertThat(message3, CoreMatchers.notNullValue());
+ assertThat(message3, CoreMatchers.notNullValue());
final HttpResponse response3 = message3.getHead();
- MatcherAssert.assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body3 = message3.getBody();
- MatcherAssert.assertThat(body3, CoreMatchers.equalTo("some more stuff"));
+ assertThat(body3, CoreMatchers.equalTo("some more stuff"));
} finally {
endpoint.releaseAndReuse();
@@ -284,11 +287,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());
- MatcherAssert.assertThat(message, CoreMatchers.notNullValue());
+ assertThat(message, CoreMatchers.notNullValue());
final HttpResponse response = message.getHead();
- MatcherAssert.assertThat(response.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ assertThat(response.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body = message.getBody();
- MatcherAssert.assertThat(body, CoreMatchers.containsString("stuff"));
+ assertThat(body, CoreMatchers.containsString("stuff"));
}
} finally {
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2ServerBootstrapFiltersTest.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2ServerBootstrapFiltersTest.java
index 73dc943..55ef978 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2ServerBootstrapFiltersTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2ServerBootstrapFiltersTest.java
@@ -27,6 +27,8 @@
package org.apache.hc.core5.testing.nio;
+import static org.hamcrest.MatcherAssert.assertThat;
+
import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.concurrent.Future;
@@ -62,13 +64,14 @@ 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.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport;
import org.junit.rules.ExternalResource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+@EnableRuleMigrationSupport
public class H2ServerBootstrapFiltersTest {
private final Logger log = LoggerFactory.getLogger(getClass());
@@ -181,11 +184,11 @@ public class H2ServerBootstrapFiltersTest {
new StringAsyncEntityProducer("some stuff", ContentType.TEXT_PLAIN)),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
final Message<HttpResponse, String> message = resultFuture.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- MatcherAssert.assertThat(message, CoreMatchers.notNullValue());
+ assertThat(message, CoreMatchers.notNullValue());
final HttpResponse response = message.getHead();
- MatcherAssert.assertThat(response.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ assertThat(response.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final Header testFilterHeader = response.getHeader("X-Test-Filter");
- MatcherAssert.assertThat(testFilterHeader, CoreMatchers.notNullValue());
+ assertThat(testFilterHeader, CoreMatchers.notNullValue());
}
}
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2SocksProxyIntegrationTest.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2SocksProxyIntegrationTest.java
index 7c8f355..338c411 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2SocksProxyIntegrationTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2SocksProxyIntegrationTest.java
@@ -31,20 +31,20 @@ import org.apache.hc.core5.http.URIScheme;
import org.apache.hc.core5.reactor.IOReactorConfig;
import org.apache.hc.core5.testing.SocksProxy;
import org.apache.hc.core5.util.TimeValue;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
public class H2SocksProxyIntegrationTest extends H2IntegrationTest {
protected static SocksProxy PROXY;
- @BeforeClass
+ @BeforeAll
public static void before() throws Throwable {
PROXY = new SocksProxy();
PROXY.start();
}
- @AfterClass
+ @AfterAll
public static void after() {
if (PROXY != null) {
try {
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 0f40ab9..b66e029 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,6 +27,8 @@
package org.apache.hc.core5.testing.nio;
+import static org.hamcrest.MatcherAssert.assertThat;
+
import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.concurrent.ExecutionException;
@@ -64,12 +66,13 @@ 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.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport;
import org.junit.rules.ExternalResource;
+@EnableRuleMigrationSupport
public class H2TLSIntegrationTest {
private static final Timeout TIMEOUT = Timeout.ofSeconds(30);
@@ -156,16 +159,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());
- MatcherAssert.assertThat(message1, CoreMatchers.notNullValue());
+ assertThat(message1, CoreMatchers.notNullValue());
final HttpResponse response1 = message1.getHead();
- MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body1 = message1.getBody();
- MatcherAssert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
+ assertThat(body1, CoreMatchers.equalTo("some stuff"));
final SSLSession sslSession = sslSessionRef.getAndSet(null);
final ProtocolVersion tlsVersion = TLS.parse(sslSession.getProtocol());
- MatcherAssert.assertThat(tlsVersion.greaterEquals(TLS.V_1_2.version), CoreMatchers.equalTo(true));
- MatcherAssert.assertThat(sslSession.getPeerPrincipal().getName(),
+ assertThat(tlsVersion.greaterEquals(TLS.V_1_2.version), CoreMatchers.equalTo(true));
+ assertThat(sslSession.getPeerPrincipal().getName(),
CoreMatchers.equalTo("CN=localhost,OU=Apache HttpComponents,O=Apache Software Foundation"));
}
@@ -209,10 +212,10 @@ public class H2TLSIntegrationTest {
new BasicRequestProducer(Method.POST, target, "/stuff",
new StringAsyncEntityProducer("some stuff", ContentType.TEXT_PLAIN)),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
- final ExecutionException exception = Assert.assertThrows(ExecutionException.class, () ->
+ final ExecutionException exception = Assertions.assertThrows(ExecutionException.class, () ->
resultFuture1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit()));
final Throwable cause = exception.getCause();
- MatcherAssert.assertThat(cause, CoreMatchers.instanceOf(SSLHandshakeException.class));
+ assertThat(cause, CoreMatchers.instanceOf(SSLHandshakeException.class));
}
@Test
@@ -258,10 +261,10 @@ public class H2TLSIntegrationTest {
new BasicRequestProducer(Method.POST, target, "/stuff",
new StringAsyncEntityProducer("some stuff", ContentType.TEXT_PLAIN)),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
- final ExecutionException exception = Assert.assertThrows(ExecutionException.class, () ->
+ final ExecutionException exception = Assertions.assertThrows(ExecutionException.class, () ->
resultFuture1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit()));
final Throwable cause = exception.getCause();
- MatcherAssert.assertThat(cause, CoreMatchers.instanceOf(IOException.class));
+ assertThat(cause, CoreMatchers.instanceOf(IOException.class));
}
@Test
@@ -307,10 +310,10 @@ public class H2TLSIntegrationTest {
new BasicRequestProducer(Method.POST, target, "/stuff",
new StringAsyncEntityProducer("some stuff", ContentType.TEXT_PLAIN)),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
- final ExecutionException exception = Assert.assertThrows(ExecutionException.class, () ->
+ final ExecutionException exception = Assertions.assertThrows(ExecutionException.class, () ->
resultFuture1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit()));
final Throwable cause = exception.getCause();
- MatcherAssert.assertThat(cause, CoreMatchers.instanceOf(IOException.class));
+ assertThat(cause, CoreMatchers.instanceOf(IOException.class));
}
@Test
@@ -374,10 +377,10 @@ public class H2TLSIntegrationTest {
new BasicRequestProducer(Method.POST, target, "/stuff",
new StringAsyncEntityProducer("some stuff", ContentType.TEXT_PLAIN)),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
- final ExecutionException exception = Assert.assertThrows(ExecutionException.class, () ->
+ final ExecutionException exception = Assertions.assertThrows(ExecutionException.class, () ->
resultFuture1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit()));
final Throwable cause = exception.getCause();
- MatcherAssert.assertThat(cause, CoreMatchers.instanceOf(IOException.class));
+ assertThat(cause, CoreMatchers.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 29e600e..f633745 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,6 +27,8 @@
package org.apache.hc.core5.testing.nio;
+import static org.hamcrest.MatcherAssert.assertThat;
+
import java.net.InetSocketAddress;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
@@ -65,9 +67,9 @@ 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.hamcrest.MatcherAssert;
import org.junit.Rule;
import org.junit.Test;
+import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport;
import org.junit.rules.ExternalResource;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@@ -75,6 +77,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@RunWith(Parameterized.class)
+@EnableRuleMigrationSupport
public class Http1AuthenticationTest {
@Parameterized.Parameters(name = "respond immediately on auth failure: {0}")
@@ -208,11 +211,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());
- MatcherAssert.assertThat(message1, CoreMatchers.notNullValue());
+ assertThat(message1, CoreMatchers.notNullValue());
final HttpResponse response1 = message1.getHead();
- MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_UNAUTHORIZED));
+ assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_UNAUTHORIZED));
final String body1 = message1.getBody();
- MatcherAssert.assertThat(body1, CoreMatchers.equalTo("You shall not pass!!!"));
+ assertThat(body1, CoreMatchers.equalTo("You shall not pass!!!"));
final HttpRequest request2 = new BasicHttpRequest(Method.GET, target, "/stuff");
request2.setHeader(HttpHeaders.AUTHORIZATION, "let me pass");
@@ -220,11 +223,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());
- MatcherAssert.assertThat(message2, CoreMatchers.notNullValue());
+ assertThat(message2, CoreMatchers.notNullValue());
final HttpResponse response2 = message2.getHead();
- MatcherAssert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body2 = message2.getBody();
- MatcherAssert.assertThat(body2, CoreMatchers.equalTo(""));
+ assertThat(body2, CoreMatchers.equalTo(""));
}
@Test
@@ -246,11 +249,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());
- MatcherAssert.assertThat(message1, CoreMatchers.notNullValue());
+ assertThat(message1, CoreMatchers.notNullValue());
final HttpResponse response1 = message1.getHead();
- MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_UNAUTHORIZED));
+ assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_UNAUTHORIZED));
final String body1 = message1.getBody();
- MatcherAssert.assertThat(body1, CoreMatchers.equalTo("You shall not pass!!!"));
+ assertThat(body1, CoreMatchers.equalTo("You shall not pass!!!"));
final HttpRequest request2 = new BasicHttpRequest(Method.POST, target, "/stuff");
request2.setHeader(HttpHeaders.AUTHORIZATION, "let me pass");
@@ -258,11 +261,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());
- MatcherAssert.assertThat(message2, CoreMatchers.notNullValue());
+ assertThat(message2, CoreMatchers.notNullValue());
final HttpResponse response2 = message2.getHead();
- MatcherAssert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body2 = message2.getBody();
- MatcherAssert.assertThat(body2, CoreMatchers.equalTo(new String(stuff, StandardCharsets.US_ASCII)));
+ assertThat(body2, CoreMatchers.equalTo(new String(stuff, StandardCharsets.US_ASCII)));
}
@Test
@@ -286,11 +289,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());
- MatcherAssert.assertThat(message1, CoreMatchers.notNullValue());
+ assertThat(message1, CoreMatchers.notNullValue());
final HttpResponse response1 = message1.getHead();
- MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_UNAUTHORIZED));
+ assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_UNAUTHORIZED));
final String body1 = message1.getBody();
- MatcherAssert.assertThat(body1, CoreMatchers.equalTo("You shall not pass!!!"));
+ assertThat(body1, CoreMatchers.equalTo("You shall not pass!!!"));
final HttpRequest request2 = new BasicHttpRequest(Method.POST, target, "/stuff");
request2.setVersion(HttpVersion.HTTP_1_0);
@@ -299,11 +302,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());
- MatcherAssert.assertThat(message2, CoreMatchers.notNullValue());
+ assertThat(message2, CoreMatchers.notNullValue());
final HttpResponse response2 = message2.getHead();
- MatcherAssert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body2 = message2.getBody();
- MatcherAssert.assertThat(body2, CoreMatchers.equalTo(new String(stuff, StandardCharsets.US_ASCII)));
+ assertThat(body2, CoreMatchers.equalTo(new String(stuff, StandardCharsets.US_ASCII)));
}
}
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http1IntegrationTest.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http1IntegrationTest.java
index 57b0f20..180670b 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http1IntegrationTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http1IntegrationTest.java
@@ -27,6 +27,8 @@
package org.apache.hc.core5.testing.nio;
+import static org.hamcrest.MatcherAssert.assertThat;
+
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
@@ -131,16 +133,17 @@ 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;
import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+@EnableRuleMigrationSupport
@RunWith(Parameterized.class)
public class Http1IntegrationTest extends InternalHttp1ServerTestBase {
@@ -163,7 +166,7 @@ public class Http1IntegrationTest extends InternalHttp1ServerTestBase {
private Http1TestClient client;
- @Before
+ @BeforeEach
public void setup() throws Exception {
log.debug("Starting up test client");
client = new Http1TestClient(
@@ -175,7 +178,7 @@ public class Http1IntegrationTest extends InternalHttp1ServerTestBase {
return IOReactorConfig.DEFAULT;
}
- @After
+ @AfterEach
public void cleanup() throws Exception {
log.debug("Shutting down test client");
if (client != null) {
@@ -206,12 +209,12 @@ public class Http1IntegrationTest extends InternalHttp1ServerTestBase {
new BasicRequestProducer(Method.GET, createRequestURI(serverEndpoint, "/hello")),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
final Message<HttpResponse, String> result = future.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result);
+ Assertions.assertNotNull(result);
final HttpResponse response1 = result.getHead();
final String entity1 = result.getBody();
- Assert.assertNotNull(response1);
- Assert.assertEquals(200, response1.getCode());
- Assert.assertEquals("Hi there", entity1);
+ Assertions.assertNotNull(response1);
+ Assertions.assertEquals(200, response1.getCode());
+ Assertions.assertEquals("Hi there", entity1);
}
}
@@ -232,12 +235,12 @@ public class Http1IntegrationTest extends InternalHttp1ServerTestBase {
.build(),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
final Message<HttpResponse, String> result = future.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result);
+ Assertions.assertNotNull(result);
final HttpResponse response1 = result.getHead();
final String entity1 = result.getBody();
- Assert.assertNotNull(response1);
- Assert.assertEquals(200, response1.getCode());
- Assert.assertEquals("Hi there", entity1);
+ Assertions.assertNotNull(response1);
+ Assertions.assertEquals(200, response1.getCode());
+ Assertions.assertEquals("Hi there", entity1);
}
}
}
@@ -263,12 +266,12 @@ public class Http1IntegrationTest extends InternalHttp1ServerTestBase {
streamEndpoint.close();
- Assert.assertNotNull(result);
+ Assertions.assertNotNull(result);
final HttpResponse response = result.getHead();
final String entity = result.getBody();
- Assert.assertNotNull(response);
- Assert.assertEquals(200, response.getCode());
- Assert.assertEquals("Hi there", entity);
+ Assertions.assertNotNull(response);
+ Assertions.assertEquals(200, response.getCode());
+ Assertions.assertEquals("Hi there", entity);
}
}
@@ -296,12 +299,12 @@ public class Http1IntegrationTest extends InternalHttp1ServerTestBase {
streamEndpoint.close();
- Assert.assertNotNull(result);
+ Assertions.assertNotNull(result);
final HttpResponse response = result.getHead();
final String entity = result.getBody();
- Assert.assertNotNull(response);
- Assert.assertEquals(200, response.getCode());
- Assert.assertEquals("Hi there", entity);
+ Assertions.assertNotNull(response);
+ Assertions.assertEquals(200, response.getCode());
+ Assertions.assertEquals("Hi there", entity);
}
}
@@ -328,12 +331,12 @@ public class Http1IntegrationTest extends InternalHttp1ServerTestBase {
streamEndpoint.close();
- Assert.assertNotNull(result);
+ Assertions.assertNotNull(result);
final HttpResponse response = result.getHead();
final String entity = result.getBody();
- Assert.assertNotNull(response);
- Assert.assertEquals(500, response.getCode());
- Assert.assertEquals("Go away", entity);
+ Assertions.assertNotNull(response);
+ Assertions.assertEquals(500, response.getCode());
+ Assertions.assertEquals("Go away", entity);
}
}
@@ -356,12 +359,12 @@ public class Http1IntegrationTest extends InternalHttp1ServerTestBase {
while (!queue.isEmpty()) {
final Future<Message<HttpResponse, String>> future = queue.remove();
final Message<HttpResponse, String> result = future.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result);
+ Assertions.assertNotNull(result);
final HttpResponse response = result.getHead();
final String entity = result.getBody();
- Assert.assertNotNull(response);
- Assert.assertEquals(200, response.getCode());
- Assert.assertEquals("Hi there", entity);
+ Assertions.assertNotNull(response);
+ Assertions.assertEquals(200, response.getCode());
+ Assertions.assertEquals("Hi there", entity);
}
}
@@ -380,15 +383,15 @@ public class Http1IntegrationTest extends InternalHttp1ServerTestBase {
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
final Message<HttpResponse, String> result1 = future1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result1);
+ Assertions.assertNotNull(result1);
final HttpResponse response1 = result1.getHead();
- Assert.assertNotNull(response1);
- Assert.assertEquals(200, response1.getCode());
+ Assertions.assertNotNull(response1);
+ Assertions.assertEquals(200, response1.getCode());
final String s1 = result1.getBody();
- Assert.assertNotNull(s1);
+ Assertions.assertNotNull(s1);
final StringTokenizer t1 = new StringTokenizer(s1, "\r\n");
while (t1.hasMoreTokens()) {
- Assert.assertEquals("0123456789abcdef", t1.nextToken());
+ Assertions.assertEquals("0123456789abcdef", t1.nextToken());
}
final Future<Message<HttpResponse, String>> future2 = streamEndpoint.execute(
@@ -396,15 +399,15 @@ public class Http1IntegrationTest extends InternalHttp1ServerTestBase {
new BasicResponseConsumer<>(new StringAsyncEntityConsumer(512)), null);
final Message<HttpResponse, String> result2 = future2.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result2);
+ Assertions.assertNotNull(result2);
final HttpResponse response2 = result2.getHead();
- Assert.assertNotNull(response2);
- Assert.assertEquals(200, response2.getCode());
+ Assertions.assertNotNull(response2);
+ Assertions.assertEquals(200, response2.getCode());
final String s2 = result2.getBody();
- Assert.assertNotNull(s2);
+ Assertions.assertNotNull(s2);
final StringTokenizer t2 = new StringTokenizer(s2, "\r\n");
while (t2.hasMoreTokens()) {
- Assert.assertEquals("0123456789abcdef", t2.nextToken());
+ Assertions.assertEquals("0123456789abcdef", t2.nextToken());
}
}
@@ -427,15 +430,15 @@ public class Http1IntegrationTest extends InternalHttp1ServerTestBase {
while (!queue.isEmpty()) {
final Future<Message<HttpResponse, String>> future = queue.remove();
final Message<HttpResponse, String> result = future.get(LONG_TIMEOUT.getDuration(), LONG_TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result);
+ Assertions.assertNotNull(result);
final HttpResponse response = result.getHead();
- Assert.assertNotNull(response);
- Assert.assertEquals(200, response.getCode());
+ Assertions.assertNotNull(response);
+ Assertions.assertEquals(200, response.getCode());
final String entity = result.getBody();
- Assert.assertNotNull(entity);
+ Assertions.assertNotNull(entity);
final StringTokenizer t = new StringTokenizer(entity, "\r\n");
while (t.hasMoreTokens()) {
- Assert.assertEquals("0123456789abcdef", t.nextToken());
+ Assertions.assertEquals("0123456789abcdef", t.nextToken());
}
}
}
@@ -456,12 +459,12 @@ public class Http1IntegrationTest extends InternalHttp1ServerTestBase {
AsyncEntityProducers.create("Hi there")),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
final Message<HttpResponse, String> result = future.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result);
+ Assertions.assertNotNull(result);
final HttpResponse response1 = result.getHead();
final String entity1 = result.getBody();
- Assert.assertNotNull(response1);
- Assert.assertEquals(200, response1.getCode());
- Assert.assertEquals("Hi back", entity1);
+ Assertions.assertNotNull(response1);
+ Assertions.assertEquals(200, response1.getCode());
+ Assertions.assertEquals("Hi back", entity1);
}
}
@@ -485,12 +488,12 @@ public class Http1IntegrationTest extends InternalHttp1ServerTestBase {
while (!queue.isEmpty()) {
final Future<Message<HttpResponse, String>> future = queue.remove();
final Message<HttpResponse, String> result = future.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result);
+ Assertions.assertNotNull(result);
final HttpResponse response = result.getHead();
final String entity = result.getBody();
- Assert.assertNotNull(response);
- Assert.assertEquals(200, response.getCode());
- Assert.assertEquals("Hi back", entity);
+ Assertions.assertNotNull(response);
+ Assertions.assertEquals(200, response.getCode());
+ Assertions.assertEquals("Hi back", entity);
}
}
@@ -511,12 +514,12 @@ public class Http1IntegrationTest extends InternalHttp1ServerTestBase {
new BasicRequestProducer(request, AsyncEntityProducers.create("Hi there")),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
final Message<HttpResponse, String> result = future.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result);
+ Assertions.assertNotNull(result);
final HttpResponse response1 = result.getHead();
final String entity1 = result.getBody();
- Assert.assertNotNull(response1);
- Assert.assertEquals(200, response1.getCode());
- Assert.assertEquals("Hi back", entity1);
+ Assertions.assertNotNull(response1);
+ Assertions.assertEquals(200, response1.getCode());
+ Assertions.assertEquals("Hi back", entity1);
}
}
@@ -536,12 +539,12 @@ public class Http1IntegrationTest extends InternalHttp1ServerTestBase {
new BasicRequestProducer(request, null),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
final Message<HttpResponse, String> result = future.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result);
+ Assertions.assertNotNull(result);
final HttpResponse response1 = result.getHead();
final String entity1 = result.getBody();
- Assert.assertNotNull(response1);
- Assert.assertEquals(200, response1.getCode());
- Assert.assertEquals("Hi back", entity1);
+ Assertions.assertNotNull(response1);
+ Assertions.assertEquals(200, response1.getCode());
+ Assertions.assertEquals("Hi back", entity1);
}
}
@@ -561,15 +564,15 @@ public class Http1IntegrationTest extends InternalHttp1ServerTestBase {
new MultiLineEntityProducer("0123456789abcdef", 5000)),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
final Message<HttpResponse, String> result = future.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result);
+ Assertions.assertNotNull(result);
final HttpResponse response = result.getHead();
- Assert.assertNotNull(response);
- Assert.assertEquals(200, response.getCode());
+ Assertions.assertNotNull(response);
+ Assertions.assertEquals(200, response.getCode());
final String entity = result.getBody();
- Assert.assertNotNull(entity);
+ Assertions.assertNotNull(entity);
final StringTokenizer t = new StringTokenizer(entity, "\r\n");
while (t.hasMoreTokens()) {
- Assert.assertEquals("0123456789abcdef", t.nextToken());
+ Assertions.assertEquals("0123456789abcdef", t.nextToken());
}
}
}
@@ -594,15 +597,15 @@ public class Http1IntegrationTest extends InternalHttp1ServerTestBase {
while (!queue.isEmpty()) {
final Future<Message<HttpResponse, String>> future = queue.remove();
final Message<HttpResponse, String> result = future.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result);
+ Assertions.assertNotNull(result);
final HttpResponse response = result.getHead();
- Assert.assertNotNull(response);
- Assert.assertEquals(200, response.getCode());
+ Assertions.assertNotNull(response);
+ Assertions.assertEquals(200, response.getCode());
final String entity = result.getBody();
- Assert.assertNotNull(entity);
+ Assertions.assertNotNull(entity);
final StringTokenizer t = new StringTokenizer(entity, "\r\n");
while (t.hasMoreTokens()) {
- Assert.assertEquals("0123456789abcdef", t.nextToken());
+ Assertions.assertEquals("0123456789abcdef", t.nextToken());
}
}
}
@@ -628,15 +631,15 @@ public class Http1IntegrationTest extends InternalHttp1ServerTestBase {
while (!queue.isEmpty()) {
final Future<Message<HttpResponse, String>> future = queue.remove();
final Message<HttpResponse, String> result = future.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result);
+ Assertions.assertNotNull(result);
final HttpResponse response = result.getHead();
- Assert.assertNotNull(response);
- Assert.assertEquals(200, response.getCode());
+ Assertions.assertNotNull(response);
+ Assertions.assertEquals(200, response.getCode());
final String entity = result.getBody();
- Assert.assertNotNull(entity);
+ Assertions.assertNotNull(entity);
final StringTokenizer t = new StringTokenizer(entity, "\r\n");
while (t.hasMoreTokens()) {
- Assert.assertEquals("0123456789abcdef", t.nextToken());
+ Assertions.assertEquals("0123456789abcdef", t.nextToken());
}
}
}
@@ -656,11 +659,11 @@ public class Http1IntegrationTest extends InternalHttp1ServerTestBase {
new BasicRequestProducer(Method.HEAD, createRequestURI(serverEndpoint, "/hello")),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
final Message<HttpResponse, String> result = future.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result);
+ Assertions.assertNotNull(result);
final HttpResponse response1 = result.getHead();
- Assert.assertNotNull(response1);
- Assert.assertEquals(200, response1.getCode());
- Assert.assertNull(result.getBody());
+ Assertions.assertNotNull(response1);
+ Assertions.assertEquals(200, response1.getCode());
+ Assertions.assertNull(result.getBody());
}
}
@@ -681,11 +684,11 @@ public class Http1IntegrationTest extends InternalHttp1ServerTestBase {
.build(),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
final Message<HttpResponse, String> result = future.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result);
+ Assertions.assertNotNull(result);
final HttpResponse response1 = result.getHead();
- Assert.assertNotNull(response1);
- Assert.assertEquals(200, response1.getCode());
- Assert.assertNull(result.getBody());
+ Assertions.assertNotNull(response1);
+ Assertions.assertEquals(200, response1.getCode());
+ Assertions.assertNull(result.getBody());
}
}
}
@@ -709,11 +712,11 @@ public class Http1IntegrationTest extends InternalHttp1ServerTestBase {
while (!queue.isEmpty()) {
final Future<Message<HttpResponse, String>> future = queue.remove();
final Message<HttpResponse, String> result = future.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result);
+ Assertions.assertNotNull(result);
final HttpResponse response1 = result.getHead();
- Assert.assertNotNull(response1);
- Assert.assertEquals(200, response1.getCode());
- Assert.assertNull(result.getBody());
+ Assertions.assertNotNull(response1);
+ Assertions.assertEquals(200, response1.getCode());
+ Assertions.assertNull(result.getBody());
}
}
@@ -755,26 +758,26 @@ public class Http1IntegrationTest extends InternalHttp1ServerTestBase {
new BasicRequestProducer(request1, new MultiLineEntityProducer("0123456789abcdef", 1000)),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
final Message<HttpResponse, String> result1 = future1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result1);
+ Assertions.assertNotNull(result1);
final HttpResponse response1 = result1.getHead();
- Assert.assertNotNull(response1);
- Assert.assertEquals(200, response1.getCode());
- Assert.assertNotNull("All is well", result1.getBody());
+ Assertions.assertNotNull(response1);
+ Assertions.assertEquals(200, response1.getCode());
+ Assertions.assertNotNull("All is well", result1.getBody());
- Assert.assertTrue(ioSession.isOpen());
+ Assertions.assertTrue(ioSession.isOpen());
final HttpRequest request2 = new BasicHttpRequest(Method.POST, createRequestURI(serverEndpoint, "/echo"));
final Future<Message<HttpResponse, String>> future2 = streamEndpoint.execute(
new BasicRequestProducer(request2, new MultiLineEntityProducer("0123456789abcdef", 5000)),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
final Message<HttpResponse, String> result2 = future2.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result2);
+ Assertions.assertNotNull(result2);
final HttpResponse response2 = result2.getHead();
- Assert.assertNotNull(response2);
- Assert.assertEquals(HttpStatus.SC_UNAUTHORIZED, response2.getCode());
- Assert.assertNotNull("You shall not pass", result2.getBody());
+ Assertions.assertNotNull(response2);
+ Assertions.assertEquals(HttpStatus.SC_UNAUTHORIZED, response2.getCode());
+ Assertions.assertNotNull("You shall not pass", result2.getBody());
- Assert.assertTrue(ioSession.isOpen());
+ Assertions.assertTrue(ioSession.isOpen());
final HttpRequest request3 = new BasicHttpRequest(Method.POST, createRequestURI(serverEndpoint, "/echo"));
request3.addHeader("password", "secret");
@@ -782,26 +785,26 @@ public class Http1IntegrationTest extends InternalHttp1ServerTestBase {
new BasicRequestProducer(request3, new MultiLineEntityProducer("0123456789abcdef", 1000)),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
final Message<HttpResponse, String> result3 = future3.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result3);
+ Assertions.assertNotNull(result3);
final HttpResponse response3 = result3.getHead();
- Assert.assertNotNull(response3);
- Assert.assertEquals(200, response3.getCode());
- Assert.assertNotNull("All is well", result3.getBody());
+ Assertions.assertNotNull(response3);
+ Assertions.assertEquals(200, response3.getCode());
+ Assertions.assertNotNull("All is well", result3.getBody());
- Assert.assertTrue(ioSession.isOpen());
+ Assertions.assertTrue(ioSession.isOpen());
final HttpRequest request4 = new BasicHttpRequest(Method.POST, createRequestURI(serverEndpoint, "/echo"));
final Future<Message<HttpResponse, String>> future4 = streamEndpoint.execute(
new BasicRequestProducer(request4, AsyncEntityProducers.create("blah")),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
final Message<HttpResponse, String> result4 = future4.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result4);
+ Assertions.assertNotNull(result4);
final HttpResponse response4 = result4.getHead();
- Assert.assertNotNull(response4);
- Assert.assertEquals(HttpStatus.SC_UNAUTHORIZED, response4.getCode());
- Assert.assertNotNull("You shall not pass", result4.getBody());
+ Assertions.assertNotNull(response4);
+ Assertions.assertEquals(HttpStatus.SC_UNAUTHORIZED, response4.getCode());
+ Assertions.assertNotNull("You shall not pass", result4.getBody());
- Assert.assertFalse(ioSession.isOpen());
+ Assertions.assertFalse(ioSession.isOpen());
}
@Test
@@ -846,13 +849,13 @@ public class Http1IntegrationTest extends InternalHttp1ServerTestBase {
ContentType.TEXT_PLAIN)),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
final Message<HttpResponse, String> result1 = future1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result1);
+ Assertions.assertNotNull(result1);
final HttpResponse response1 = result1.getHead();
- Assert.assertNotNull(response1);
- Assert.assertEquals(HttpStatus.SC_UNAUTHORIZED, response1.getCode());
- Assert.assertNotNull("You shall not pass", result1.getBody());
+ Assertions.assertNotNull(response1);
+ Assertions.assertEquals(HttpStatus.SC_UNAUTHORIZED, response1.getCode());
+ Assertions.assertNotNull("You shall not pass", result1.getBody());
- Assert.assertFalse(streamEndpoint.isOpen());
+ Assertions.assertFalse(streamEndpoint.isOpen());
}
@Test
@@ -943,11 +946,11 @@ public class Http1IntegrationTest extends InternalHttp1ServerTestBase {
while (!queue.isEmpty()) {
final Future<Message<HttpResponse, String>> future = queue.remove();
final Message<HttpResponse, String> result = future.get(LONG_TIMEOUT.getDuration(), LONG_TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result);
+ Assertions.assertNotNull(result);
final HttpResponse response = result.getHead();
- Assert.assertNotNull(response);
- Assert.assertEquals(200, response.getCode());
- Assert.assertNotNull("All is well", result.getBody());
+ Assertions.assertNotNull(response);
+ Assertions.assertEquals(200, response.getCode());
+ Assertions.assertNotNull("All is well", result.getBody());
}
}
@@ -1020,13 +1023,13 @@ public class Http1IntegrationTest extends InternalHttp1ServerTestBase {
new BasicRequestProducer(request1, new MultiLineEntityProducer("0123456789abcdef", 100000)),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
final Message<HttpResponse, String> result1 = future1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result1);
+ Assertions.assertNotNull(result1);
final HttpResponse response1 = result1.getHead();
- Assert.assertNotNull(response1);
- Assert.assertEquals(HttpStatus.SC_UNAUTHORIZED, response1.getCode());
- Assert.assertNotNull("You shall not pass", result1.getBody());
+ Assertions.assertNotNull(response1);
+ Assertions.assertEquals(HttpStatus.SC_UNAUTHORIZED, response1.getCode());
+ Assertions.assertNotNull("You shall not pass", result1.getBody());
- Assert.assertTrue(streamEndpoint.isOpen());
+ Assertions.assertTrue(streamEndpoint.isOpen());
}
final HttpRequest request1 = new BasicHttpRequest(Method.POST, createRequestURI(serverEndpoint, "/echo"));
final Future<Message<HttpResponse, String>> future1 = streamEndpoint.execute(
@@ -1036,13 +1039,13 @@ public class Http1IntegrationTest extends InternalHttp1ServerTestBase {
ContentType.TEXT_PLAIN)),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
final Message<HttpResponse, String> result1 = future1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result1);
+ Assertions.assertNotNull(result1);
final HttpResponse response1 = result1.getHead();
- Assert.assertNotNull(response1);
- Assert.assertEquals(HttpStatus.SC_UNAUTHORIZED, response1.getCode());
- Assert.assertNotNull("You shall not pass", result1.getBody());
+ Assertions.assertNotNull(response1);
+ Assertions.assertEquals(HttpStatus.SC_UNAUTHORIZED, response1.getCode());
+ Assertions.assertNotNull("You shall not pass", result1.getBody());
- Assert.assertFalse(streamEndpoint.isOpen());
+ Assertions.assertFalse(streamEndpoint.isOpen());
}
@Test
@@ -1084,15 +1087,15 @@ public class Http1IntegrationTest extends InternalHttp1ServerTestBase {
null);
final Message<HttpResponse, String> result1 = future1.get(LONG_TIMEOUT.getDuration(), LONG_TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result1);
+ Assertions.assertNotNull(result1);
final HttpResponse response1 = result1.getHead();
- Assert.assertNotNull(response1);
- Assert.assertEquals(200, response1.getCode());
+ Assertions.assertNotNull(response1);
+ Assertions.assertEquals(200, response1.getCode());
final String s1 = result1.getBody();
- Assert.assertNotNull(s1);
+ Assertions.assertNotNull(s1);
final StringTokenizer t1 = new StringTokenizer(s1, "\r\n");
while (t1.hasMoreTokens()) {
- Assert.assertEquals("0123456789abcd", t1.nextToken());
+ Assertions.assertEquals("0123456789abcd", t1.nextToken());
}
}
@@ -1130,15 +1133,15 @@ public class Http1IntegrationTest extends InternalHttp1ServerTestBase {
}),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
final Message<HttpResponse, String> result1 = future1.get(LONG_TIMEOUT.getDuration(), LONG_TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result1);
+ Assertions.assertNotNull(result1);
final HttpResponse response1 = result1.getHead();
- Assert.assertNotNull(response1);
- Assert.assertEquals(200, response1.getCode());
+ Assertions.assertNotNull(response1);
+ Assertions.assertEquals(200, response1.getCode());
final String s1 = result1.getBody();
- Assert.assertNotNull(s1);
+ Assertions.assertNotNull(s1);
final StringTokenizer t1 = new StringTokenizer(s1, "\r\n");
while (t1.hasMoreTokens()) {
- Assert.assertEquals("0123456789abcdef", t1.nextToken());
+ Assertions.assertEquals("0123456789abcdef", t1.nextToken());
}
}
@@ -1204,15 +1207,15 @@ public class Http1IntegrationTest extends InternalHttp1ServerTestBase {
new BasicRequestProducer(request1, new MultiLineEntityProducer("0123456789abcd", 2000)),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
final Message<HttpResponse, String> result1 = future1.get(LONG_TIMEOUT.getDuration(), LONG_TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result1);
+ Assertions.assertNotNull(result1);
final HttpResponse response1 = result1.getHead();
- Assert.assertNotNull(response1);
- Assert.assertEquals(200, response1.getCode());
+ Assertions.assertNotNull(response1);
+ Assertions.assertEquals(200, response1.getCode());
final String s1 = result1.getBody();
- Assert.assertNotNull(s1);
+ Assertions.assertNotNull(s1);
final StringTokenizer t1 = new StringTokenizer(s1, "\r\n");
while (t1.hasMoreTokens()) {
- Assert.assertEquals("0123456789abcd", t1.nextToken());
+ Assertions.assertEquals("0123456789abcd", t1.nextToken());
}
}
@@ -1242,24 +1245,24 @@ public class Http1IntegrationTest extends InternalHttp1ServerTestBase {
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
final Message<HttpResponse, String> result1 = future1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result1);
+ Assertions.assertNotNull(result1);
final HttpResponse response1 = result1.getHead();
final String entity1 = result1.getBody();
- Assert.assertNotNull(response1);
- Assert.assertEquals(200, response1.getCode());
- Assert.assertEquals("Hi back", entity1);
+ Assertions.assertNotNull(response1);
+ Assertions.assertEquals(200, response1.getCode());
+ Assertions.assertEquals("Hi back", entity1);
final Message<HttpResponse, String> result2 = future2.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result2);
+ Assertions.assertNotNull(result2);
final HttpResponse response2 = result2.getHead();
final String entity2 = result2.getBody();
- Assert.assertNotNull(response2);
- Assert.assertEquals(200, response2.getCode());
- Assert.assertEquals("Hi back", entity2);
+ Assertions.assertNotNull(response2);
+ Assertions.assertEquals(200, response2.getCode());
+ Assertions.assertEquals("Hi back", entity2);
- final Exception exception = Assert.assertThrows(Exception.class, () ->
+ final Exception exception = Assertions.assertThrows(Exception.class, () ->
future3.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit()));
- MatcherAssert.assertThat(exception, CoreMatchers.anyOf(
+ assertThat(exception, CoreMatchers.anyOf(
CoreMatchers.instanceOf(CancellationException.class),
CoreMatchers.instanceOf(ExecutionException.class)));
@@ -1267,9 +1270,9 @@ public class Http1IntegrationTest extends InternalHttp1ServerTestBase {
new BasicRequestProducer(Method.POST, createRequestURI(serverEndpoint, "/hello-3"),
AsyncEntityProducers.create("Hi there")),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
- final Exception exception2 = Assert.assertThrows(Exception.class, () ->
+ final Exception exception2 = Assertions.assertThrows(Exception.class, () ->
future4.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit()));
- MatcherAssert.assertThat(exception2, CoreMatchers.anyOf(
+ assertThat(exception2, CoreMatchers.anyOf(
CoreMatchers.instanceOf(CancellationException.class),
CoreMatchers.instanceOf(ExecutionException.class)));
}
@@ -1300,25 +1303,25 @@ public class Http1IntegrationTest extends InternalHttp1ServerTestBase {
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
final Message<HttpResponse, String> result1 = future1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result1);
+ Assertions.assertNotNull(result1);
final HttpResponse response1 = result1.getHead();
final String entity1 = result1.getBody();
- Assert.assertNotNull(response1);
- Assert.assertEquals(200, response1.getCode());
- Assert.assertEquals("Hi back", entity1);
+ Assertions.assertNotNull(response1);
+ Assertions.assertEquals(200, response1.getCode());
+ Assertions.assertEquals("Hi back", entity1);
final Message<HttpResponse, String> result2 = future2.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result2);
+ Assertions.assertNotNull(result2);
final HttpResponse response2 = result2.getHead();
final String entity2 = result2.getBody();
- Assert.assertNotNull(response2);
- Assert.assertEquals(400, response2.getCode());
- Assert.assertTrue(entity2.length() > 0);
+ Assertions.assertNotNull(response2);
+ Assertions.assertEquals(400, response2.getCode());
+ Assertions.assertTrue(entity2.length() > 0);
- final Exception exception = Assert.assertThrows(Exception.class, () ->
+ final Exception exception = Assertions.assertThrows(Exception.class, () ->
future3.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit()));
- MatcherAssert.assertThat(exception, CoreMatchers.anyOf(
+ assertThat(exception, CoreMatchers.anyOf(
CoreMatchers.instanceOf(CancellationException.class),
CoreMatchers.instanceOf(ExecutionException.class)));
}
@@ -1443,11 +1446,11 @@ public class Http1IntegrationTest extends InternalHttp1ServerTestBase {
};
final BasicResponseConsumer<String> responseConsumer = new BasicResponseConsumer<>(entityConsumer);
final Future<Message<HttpResponse, String>> future1 = streamEndpoint.execute(requestProducer, responseConsumer, null);
- final ExecutionException exception = Assert.assertThrows(ExecutionException.class, () ->
+ final ExecutionException exception = Assertions.assertThrows(ExecutionException.class, () ->
future1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit()));
final Throwable cause = exception.getCause();
- Assert.assertTrue(cause instanceof MalformedChunkCodingException);
- Assert.assertEquals("garbage", entityConsumer.generateContent());
+ Assertions.assertTrue(cause instanceof MalformedChunkCodingException);
+ Assertions.assertEquals("garbage", entityConsumer.generateContent());
}
@Test
@@ -1473,12 +1476,12 @@ public class Http1IntegrationTest extends InternalHttp1ServerTestBase {
new BasicRequestProducer(Method.GET, createRequestURI(serverEndpoint, "/hello")),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
final Message<HttpResponse, String> result = future.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result);
+ Assertions.assertNotNull(result);
final HttpResponse response1 = result.getHead();
final String entity1 = result.getBody();
- Assert.assertNotNull(response1);
- Assert.assertEquals(500, response1.getCode());
- Assert.assertEquals("Boom", entity1);
+ Assertions.assertNotNull(response1);
+ Assertions.assertEquals(500, response1.getCode());
+ Assertions.assertEquals("Boom", entity1);
}
@Test
@@ -1494,12 +1497,12 @@ public class Http1IntegrationTest extends InternalHttp1ServerTestBase {
new BasicRequestProducer(Method.GET, createRequestURI(serverEndpoint, "/hello")),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
final Message<HttpResponse, String> result = future.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result);
+ Assertions.assertNotNull(result);
final HttpResponse response1 = result.getHead();
final String entity1 = result.getBody();
- Assert.assertNotNull(response1);
- Assert.assertEquals(404, response1.getCode());
- Assert.assertEquals("Resource not found", entity1);
+ Assertions.assertNotNull(response1);
+ Assertions.assertEquals(404, response1.getCode());
+ Assertions.assertEquals("Resource not found", entity1);
}
@Test
@@ -1526,11 +1529,11 @@ public class Http1IntegrationTest extends InternalHttp1ServerTestBase {
new BasicRequestProducer(Method.GET, createRequestURI(serverEndpoint, "/hello")),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
final Message<HttpResponse, String> result = future.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result);
+ Assertions.assertNotNull(result);
final HttpResponse response1 = result.getHead();
- Assert.assertNotNull(response1);
- Assert.assertEquals(204, response1.getCode());
- Assert.assertNull(result.getBody());
+ Assertions.assertNotNull(response1);
+ Assertions.assertEquals(204, response1.getCode());
+ Assertions.assertNull(result.getBody());
}
@Test
@@ -1550,11 +1553,11 @@ public class Http1IntegrationTest extends InternalHttp1ServerTestBase {
new BasicRequestProducer(request1, null),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
final Message<HttpResponse, String> result1 = future1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result1);
+ Assertions.assertNotNull(result1);
final HttpResponse response1 = result1.getHead();
- Assert.assertNotNull(response1);
- Assert.assertEquals(200, response1.getCode());
- Assert.assertEquals("Hi there", result1.getBody());
+ Assertions.assertNotNull(response1);
+ Assertions.assertEquals(200, response1.getCode());
+ Assertions.assertEquals("Hi there", result1.getBody());
final HttpRequest request2 = new BasicHttpRequest(Method.GET, createRequestURI(serverEndpoint, "/hello"));
request2.setVersion(HttpVersion.HTTP_1_1);
@@ -1562,11 +1565,11 @@ public class Http1IntegrationTest extends InternalHttp1ServerTestBase {
new BasicRequestProducer(request2, null),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
final Message<HttpResponse, String> result2 = future2.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result2);
+ Assertions.assertNotNull(result2);
final HttpResponse response2 = result2.getHead();
- Assert.assertNotNull(response2);
- Assert.assertEquals(400, response2.getCode());
- Assert.assertEquals("Host header is absent", result2.getBody());
+ Assertions.assertNotNull(response2);
+ Assertions.assertEquals(400, response2.getCode());
+ Assertions.assertEquals("Host header is absent", result2.getBody());
}
@Test
@@ -1606,22 +1609,22 @@ public class Http1IntegrationTest extends InternalHttp1ServerTestBase {
new BasicRequestProducer(request1, null),
new BasicResponseConsumer<>(entityConsumer), null);
final Message<HttpResponse, String> result1 = future1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result1);
+ Assertions.assertNotNull(result1);
final HttpResponse response1 = result1.getHead();
- Assert.assertNotNull(response1);
- Assert.assertEquals(200, response1.getCode());
- Assert.assertEquals("Hello back with some trailers", result1.getBody());
+ Assertions.assertNotNull(response1);
+ Assertions.assertEquals(200, response1.getCode());
+ Assertions.assertEquals("Hello back with some trailers", result1.getBody());
final List<Header> trailers = entityConsumer.getTrailers();
- Assert.assertNotNull(trailers);
- Assert.assertEquals(2, trailers.size());
+ Assertions.assertNotNull(trailers);
+ Assertions.assertEquals(2, trailers.size());
final Map<String, String> map = new HashMap<>();
for (final Header header: trailers) {
map.put(TextUtils.toLowerCase(header.getName()), header.getValue());
}
final String digest = TextUtils.toHexString(entityConsumer.getDigest());
- Assert.assertEquals("MD5", map.get("digest-algo"));
- Assert.assertEquals(digest, map.get("digest"));
+ Assertions.assertEquals("MD5", map.get("digest-algo"));
+ Assertions.assertEquals(digest, map.get("digest"));
}
@Test
@@ -1689,12 +1692,12 @@ public class Http1IntegrationTest extends InternalHttp1ServerTestBase {
new BasicRequestProducer(Method.GET, createRequestURI(serverEndpoint, "/boom")),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
final Message<HttpResponse, String> result = future.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result);
+ Assertions.assertNotNull(result);
final HttpResponse response1 = result.getHead();
final String entity1 = result.getBody();
- Assert.assertNotNull(response1);
- Assert.assertEquals(HttpStatus.SC_BAD_REQUEST, response1.getCode());
- Assert.assertEquals("Boom!!!", entity1);
+ Assertions.assertNotNull(response1);
+ Assertions.assertEquals(HttpStatus.SC_BAD_REQUEST, response1.getCode());
+ Assertions.assertEquals("Boom!!!", entity1);
}
@Test
@@ -1716,11 +1719,11 @@ public class Http1IntegrationTest extends InternalHttp1ServerTestBase {
new BasicRequestProducer(request1, null),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
final Message<HttpResponse, String> result1 = future1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result1);
+ Assertions.assertNotNull(result1);
final HttpResponse response1 = result1.getHead();
- Assert.assertNotNull(response1);
- Assert.assertEquals(431, response1.getCode());
- Assert.assertEquals("Maximum line length limit exceeded", result1.getBody());
+ Assertions.assertNotNull(response1);
+ Assertions.assertEquals(431, response1.getCode());
+ Assertions.assertEquals("Maximum line length limit exceeded", result1.getBody());
}
@Test
@@ -1749,11 +1752,11 @@ public class Http1IntegrationTest extends InternalHttp1ServerTestBase {
new BasicRequestProducer(request1, AsyncEntityProducers.create(b, ContentType.TEXT_PLAIN)),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
final Message<HttpResponse, String> result1 = future1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result1);
+ Assertions.assertNotNull(result1);
final HttpResponse response1 = result1.getHead();
- Assert.assertNotNull(response1);
- Assert.assertEquals(431, response1.getCode());
- Assert.assertEquals("Maximum line length limit exceeded", result1.getBody());
+ Assertions.assertNotNull(response1);
+ Assertions.assertEquals(431, response1.getCode());
+ Assertions.assertEquals("Maximum line length limit exceeded", result1.getBody());
}
}
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 8b8f15f..ae25847 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,6 +27,8 @@
package org.apache.hc.core5.testing.nio;
+import static org.hamcrest.MatcherAssert.assertThat;
+
import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.Arrays;
@@ -70,9 +72,9 @@ 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.Rule;
import org.junit.Test;
+import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport;
import org.junit.rules.ExternalResource;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@@ -80,6 +82,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@RunWith(Parameterized.class)
+@EnableRuleMigrationSupport
public class Http1ServerAndRequesterTest {
private final Logger log = LoggerFactory.getLogger(getClass());
@@ -204,33 +207,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());
- MatcherAssert.assertThat(message1, CoreMatchers.notNullValue());
+ assertThat(message1, CoreMatchers.notNullValue());
final HttpResponse response1 = message1.getHead();
- MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body1 = message1.getBody();
- MatcherAssert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
+ 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());
- MatcherAssert.assertThat(message2, CoreMatchers.notNullValue());
+ assertThat(message2, CoreMatchers.notNullValue());
final HttpResponse response2 = message2.getHead();
- MatcherAssert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body2 = message2.getBody();
- MatcherAssert.assertThat(body2, CoreMatchers.equalTo("some other stuff"));
+ 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());
- MatcherAssert.assertThat(message3, CoreMatchers.notNullValue());
+ assertThat(message3, CoreMatchers.notNullValue());
final HttpResponse response3 = message3.getHead();
- MatcherAssert.assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body3 = message3.getBody();
- MatcherAssert.assertThat(body3, CoreMatchers.equalTo("some more stuff"));
+ assertThat(body3, CoreMatchers.equalTo("some more stuff"));
}
@Test
@@ -247,33 +250,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());
- MatcherAssert.assertThat(message1, CoreMatchers.notNullValue());
+ assertThat(message1, CoreMatchers.notNullValue());
final HttpResponse response1 = message1.getHead();
- MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body1 = message1.getBody();
- MatcherAssert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
+ 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());
- MatcherAssert.assertThat(message2, CoreMatchers.notNullValue());
+ assertThat(message2, CoreMatchers.notNullValue());
final HttpResponse response2 = message2.getHead();
- MatcherAssert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body2 = message2.getBody();
- MatcherAssert.assertThat(body2, CoreMatchers.equalTo("some other stuff"));
+ 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());
- MatcherAssert.assertThat(message3, CoreMatchers.notNullValue());
+ assertThat(message3, CoreMatchers.notNullValue());
final HttpResponse response3 = message3.getHead();
- MatcherAssert.assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body3 = message3.getBody();
- MatcherAssert.assertThat(body3, CoreMatchers.equalTo("some more stuff"));
+ assertThat(body3, CoreMatchers.equalTo("some more stuff"));
}
@Test
@@ -294,33 +297,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());
- MatcherAssert.assertThat(message1, CoreMatchers.notNullValue());
+ assertThat(message1, CoreMatchers.notNullValue());
final HttpResponse response1 = message1.getHead();
- MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body1 = message1.getBody();
- MatcherAssert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
+ 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());
- MatcherAssert.assertThat(message2, CoreMatchers.notNullValue());
+ assertThat(message2, CoreMatchers.notNullValue());
final HttpResponse response2 = message2.getHead();
- MatcherAssert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body2 = message2.getBody();
- MatcherAssert.assertThat(body2, CoreMatchers.equalTo("some other stuff"));
+ 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());
- MatcherAssert.assertThat(message3, CoreMatchers.notNullValue());
+ assertThat(message3, CoreMatchers.notNullValue());
final HttpResponse response3 = message3.getHead();
- MatcherAssert.assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body3 = message3.getBody();
- MatcherAssert.assertThat(body3, CoreMatchers.equalTo("some more stuff"));
+ assertThat(body3, CoreMatchers.equalTo("some more stuff"));
} finally {
endpoint.releaseAndReuse();
@@ -358,11 +361,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());
- MatcherAssert.assertThat(message, CoreMatchers.notNullValue());
+ assertThat(message, CoreMatchers.notNullValue());
final HttpResponse response = message.getHead();
- MatcherAssert.assertThat(response.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ assertThat(response.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body = message.getBody();
- MatcherAssert.assertThat(body, CoreMatchers.containsString("stuff"));
+ assertThat(body, CoreMatchers.containsString("stuff"));
}
} finally {
@@ -391,10 +394,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());
- MatcherAssert.assertThat(message, CoreMatchers.notNullValue());
+ assertThat(message, CoreMatchers.notNullValue());
final HttpResponse response = message.getHead();
- MatcherAssert.assertThat(response.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
- MatcherAssert.assertThat(message.getBody(), CoreMatchers.nullValue());
+ assertThat(response.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ assertThat(message.getBody(), CoreMatchers.nullValue());
}
}
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http1SocksProxyIntegrationTest.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http1SocksProxyIntegrationTest.java
index be06284..9c30a79 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http1SocksProxyIntegrationTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http1SocksProxyIntegrationTest.java
@@ -31,20 +31,22 @@ import org.apache.hc.core5.http.URIScheme;
import org.apache.hc.core5.reactor.IOReactorConfig;
import org.apache.hc.core5.testing.SocksProxy;
import org.apache.hc.core5.util.TimeValue;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport;
+@EnableRuleMigrationSupport
public class Http1SocksProxyIntegrationTest extends Http1IntegrationTest {
protected static SocksProxy PROXY;
- @BeforeClass
+ @BeforeAll
public static void before() throws Throwable {
PROXY = new SocksProxy();
PROXY.start();
}
- @AfterClass
+ @AfterAll
public static void after() {
if (PROXY != null) {
try {
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/InternalH2ServerTestBase.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/InternalH2ServerTestBase.java
index 545e2f5..fae7f24 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/InternalH2ServerTestBase.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/InternalH2ServerTestBase.java
@@ -31,11 +31,14 @@ import org.apache.hc.core5.http.URIScheme;
import org.apache.hc.core5.reactor.IOReactorConfig;
import org.apache.hc.core5.testing.SSLTestContexts;
import org.apache.hc.core5.util.TimeValue;
-import org.junit.Rule;
-import org.junit.rules.ExternalResource;
+import org.junit.jupiter.api.extension.AfterEachCallback;
+import org.junit.jupiter.api.extension.BeforeEachCallback;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.jupiter.api.extension.ExtensionContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+@ExtendWith({InternalH2ServerTestBase.serverResource.class})
public abstract class InternalH2ServerTestBase {
private final Logger log = LoggerFactory.getLogger(getClass());
@@ -52,24 +55,22 @@ public abstract class InternalH2ServerTestBase {
protected H2TestServer server;
- @Rule
- public ExternalResource serverResource = new ExternalResource() {
+ class serverResource implements AfterEachCallback, BeforeEachCallback {
@Override
- protected void before() throws Throwable {
+ public void beforeEach(final ExtensionContext context) throws Exception {
log.debug("Starting up test server");
server = new H2TestServer(IOReactorConfig.DEFAULT,
scheme == URIScheme.HTTPS ? SSLTestContexts.createServerSSLContext() : null, null, null);
}
@Override
- protected void after() {
+ public void afterEach(final ExtensionContext context) throws Exception {
log.debug("Shutting down test server");
if (server != null) {
server.shutdown(TimeValue.ofSeconds(5));
}
}
-
- };
+ }
}
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/InternalHttp1ServerTestBase.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/InternalHttp1ServerTestBase.java
index b1fd93b..968c4ce 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/InternalHttp1ServerTestBase.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/InternalHttp1ServerTestBase.java
@@ -32,10 +32,12 @@ import org.apache.hc.core5.reactor.IOReactorConfig;
import org.apache.hc.core5.testing.SSLTestContexts;
import org.apache.hc.core5.util.TimeValue;
import org.junit.Rule;
+import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport;
import org.junit.rules.ExternalResource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+@EnableRuleMigrationSupport
public abstract class InternalHttp1ServerTestBase {
private final Logger log = LoggerFactory.getLogger(getClass());
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/JSSEProviderIntegrationTest.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/JSSEProviderIntegrationTest.java
index d4cb7c6..2737ecd 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/JSSEProviderIntegrationTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/JSSEProviderIntegrationTest.java
@@ -55,10 +55,10 @@ import org.apache.hc.core5.ssl.SSLContextBuilder;
import org.apache.hc.core5.util.TimeValue;
import org.apache.hc.core5.util.Timeout;
import org.conscrypt.Conscrypt;
-import org.junit.Assert;
-import org.junit.Assume;
import org.junit.Rule;
import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport;
import org.junit.rules.ExternalResource;
import org.junit.rules.RuleChain;
import org.junit.rules.TestRule;
@@ -68,6 +68,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@RunWith(Parameterized.class)
+@EnableRuleMigrationSupport
public class JSSEProviderIntegrationTest {
private final Logger log = LoggerFactory.getLogger(getClass());
@@ -106,7 +107,7 @@ public class JSSEProviderIntegrationTest {
try {
securityProvider = Conscrypt.newProviderBuilder().provideTrustManager(true).build();
} catch (final UnsatisfiedLinkError e) {
- Assume.assumeFalse("Conscrypt provider failed to be loaded: " + e.getMessage(), true);
+ Assertions.fail("Conscrypt provider failed to be loaded: " + e.getMessage());
}
} else {
securityProvider = null;
@@ -220,12 +221,12 @@ public class JSSEProviderIntegrationTest {
new BasicRequestProducer(Method.GET, createRequestURI(serverEndpoint, "/hello")),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
final Message<HttpResponse, String> result = future.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result);
+ Assertions.assertNotNull(result);
final HttpResponse response1 = result.getHead();
final String entity1 = result.getBody();
- Assert.assertNotNull(response1);
- Assert.assertEquals(200, response1.getCode());
- Assert.assertEquals("Hi there", entity1);
+ Assertions.assertNotNull(response1);
+ Assertions.assertEquals(200, response1.getCode());
+ Assertions.assertEquals("Hi there", entity1);
}
}
@@ -246,12 +247,12 @@ public class JSSEProviderIntegrationTest {
.build(),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
final Message<HttpResponse, String> result = future.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result);
+ Assertions.assertNotNull(result);
final HttpResponse response1 = result.getHead();
final String entity1 = result.getBody();
- Assert.assertNotNull(response1);
- Assert.assertEquals(200, response1.getCode());
- Assert.assertEquals("Hi there", entity1);
+ Assertions.assertNotNull(response1);
+ Assertions.assertEquals(200, response1.getCode());
+ Assertions.assertEquals("Hi there", entity1);
}
}
}
@@ -272,12 +273,12 @@ public class JSSEProviderIntegrationTest {
new BasicRequestProducer(Method.GET, createRequestURI(serverEndpoint, "/hello")),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
final Message<HttpResponse, String> result = future.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertNotNull(result);
+ Assertions.assertNotNull(result);
final HttpResponse response = result.getHead();
final String entity = result.getBody();
- Assert.assertNotNull(response);
- Assert.assertEquals(200, response.getCode());
- Assert.assertEquals("Hi there", entity);
+ Assertions.assertNotNull(response);
+ Assertions.assertEquals(200, response.getCode());
+ Assertions.assertEquals("Hi there", entity);
}
}
}
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/TestDefaultListeningIOReactor.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/TestDefaultListeningIOReactor.java
index 5005c32..945d023 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/TestDefaultListeningIOReactor.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/TestDefaultListeningIOReactor.java
@@ -44,10 +44,10 @@ import org.apache.hc.core5.reactor.ListenerEndpoint;
import org.apache.hc.core5.reactor.ProtocolIOSession;
import org.apache.hc.core5.util.TimeValue;
import org.apache.hc.core5.util.Timeout;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Basic tests for {@link DefaultListeningIOReactor}.
@@ -89,7 +89,7 @@ public class TestDefaultListeningIOReactor {
}
}
- @Before
+ @BeforeEach
public void setup() throws Exception {
final IOReactorConfig reactorConfig = IOReactorConfig.custom()
.setIoThreadCount(1)
@@ -97,7 +97,7 @@ public class TestDefaultListeningIOReactor {
this.ioReactor = new DefaultListeningIOReactor(new NoopIOEventHandlerFactory(), reactorConfig, null);
}
- @After
+ @AfterEach
public void cleanup() throws Exception {
if (this.ioReactor != null) {
this.ioReactor.close(CloseMode.IMMEDIATE);
@@ -109,8 +109,8 @@ public class TestDefaultListeningIOReactor {
ioReactor.start();
Set<ListenerEndpoint> endpoints = ioReactor.getEndpoints();
- Assert.assertNotNull(endpoints);
- Assert.assertEquals(0, endpoints.size());
+ Assertions.assertNotNull(endpoints);
+ Assertions.assertEquals(0, endpoints.size());
final Future<ListenerEndpoint> future1 = ioReactor.listen(new InetSocketAddress(0));
final ListenerEndpoint endpoint1 = future1.get();
@@ -120,22 +120,22 @@ public class TestDefaultListeningIOReactor {
final int port = ((InetSocketAddress) endpoint2.getAddress()).getPort();
endpoints = ioReactor.getEndpoints();
- Assert.assertNotNull(endpoints);
- Assert.assertEquals(2, endpoints.size());
+ Assertions.assertNotNull(endpoints);
+ Assertions.assertEquals(2, endpoints.size());
endpoint1.close();
endpoints = ioReactor.getEndpoints();
- Assert.assertNotNull(endpoints);
- Assert.assertEquals(1, endpoints.size());
+ Assertions.assertNotNull(endpoints);
+ Assertions.assertEquals(1, endpoints.size());
final ListenerEndpoint endpoint = endpoints.iterator().next();
- Assert.assertEquals(port, ((InetSocketAddress) endpoint.getAddress()).getPort());
+ Assertions.assertEquals(port, ((InetSocketAddress) endpoint.getAddress()).getPort());
ioReactor.close(CloseMode.GRACEFUL);
ioReactor.awaitShutdown(TimeValue.ofSeconds(5));
- Assert.assertEquals(IOReactorStatus.SHUT_DOWN, ioReactor.getStatus());
+ Assertions.assertEquals(IOReactorStatus.SHUT_DOWN, ioReactor.getStatus());
}
@Test
@@ -147,11 +147,11 @@ public class TestDefaultListeningIOReactor {
final int port = ((InetSocketAddress) endpoint1.getAddress()).getPort();
final Future<ListenerEndpoint> future2 = ioReactor.listen(new InetSocketAddress(port));
- Assert.assertThrows(ExecutionException.class, () -> future2.get());
+ Assertions.assertThrows(ExecutionException.class, () -> future2.get());
ioReactor.close(CloseMode.GRACEFUL);
ioReactor.awaitShutdown(TimeValue.ofSeconds(5));
- Assert.assertEquals(IOReactorStatus.SHUT_DOWN, ioReactor.getStatus());
+ Assertions.assertEquals(IOReactorStatus.SHUT_DOWN, ioReactor.getStatus());
}
}
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/reactive/ReactiveClientTest.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/reactive/ReactiveClientTest.java
index ec1bdbe..fa64c47 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/reactive/ReactiveClientTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/reactive/ReactiveClientTest.java
@@ -27,6 +27,7 @@
package org.apache.hc.core5.testing.reactive;
import static java.lang.String.format;
+import static org.hamcrest.MatcherAssert.assertThat;
import java.io.ByteArrayOutputStream;
import java.net.InetSocketAddress;
@@ -72,10 +73,10 @@ import org.apache.hc.core5.testing.reactive.ReactiveTestUtils.StreamDescription;
import org.apache.hc.core5.util.TextUtils;
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.jupiter.api.Assertions;
+import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport;
import org.junit.rules.ExternalResource;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@@ -87,6 +88,7 @@ import io.reactivex.Flowable;
import io.reactivex.Observable;
@RunWith(Parameterized.class)
+@EnableRuleMigrationSupport
public class ReactiveClientTest {
private final Logger log = LoggerFactory.getLogger(getClass());
@@ -197,7 +199,7 @@ public class ReactiveClientTest {
}
writableByteChannel.close();
final byte[] output = byteArrayOutputStream.toByteArray();
- Assert.assertArrayEquals(input, output);
+ Assertions.assertArrayEquals(input, output);
}
private BasicRequestProducer getRequestProducer(final InetSocketAddress address, final ReactiveEntityProducer producer) {
@@ -219,8 +221,8 @@ public class ReactiveClientTest {
.get(RESULT_TIMEOUT.getDuration(), RESULT_TIMEOUT.getTimeUnit());
final StreamDescription desc = ReactiveTestUtils.consumeStream(response.getBody()).blockingGet();
- Assert.assertEquals(expectedLength, desc.length);
- Assert.assertEquals(expectedHash.get(), TextUtils.toHexString(desc.md.digest()));
+ Assertions.assertEquals(expectedLength, desc.length);
+ Assertions.assertEquals(expectedHash.get(), TextUtils.toHexString(desc.md.digest()));
}
@Test
@@ -244,8 +246,8 @@ public class ReactiveClientTest {
.get(RESULT_TIMEOUT.getDuration(), RESULT_TIMEOUT.getTimeUnit());
final StreamDescription desc = ReactiveTestUtils.consumeStream(response.getBody()).blockingGet();
- Assert.assertEquals(expectedLength, desc.length);
- Assert.assertEquals(expectedHash.get(), TextUtils.toHexString(desc.md.digest()));
+ Assertions.assertEquals(expectedLength, desc.length);
+ Assertions.assertEquals(expectedHash.get(), TextUtils.toHexString(desc.md.digest()));
}
}
@@ -262,10 +264,10 @@ public class ReactiveClientTest {
final Future<Void> future = requester.execute(request, consumer, SOCKET_TIMEOUT, null);
- final ExecutionException exception = Assert.assertThrows(ExecutionException.class, () ->
+ final ExecutionException exception = Assertions.assertThrows(ExecutionException.class, () ->
future.get(RESULT_TIMEOUT.getDuration(), RESULT_TIMEOUT.getTimeUnit()));
- Assert.assertTrue(exception.getCause() instanceof HttpStreamResetException);
- Assert.assertSame(exceptionThrown, exception.getCause().getCause());
+ Assertions.assertTrue(exception.getCause() instanceof HttpStreamResetException);
+ Assertions.assertSame(exceptionThrown, exception.getCause().getCause());
}
@Test
@@ -280,18 +282,16 @@ public class ReactiveClientTest {
final ReactiveResponseConsumer consumer = new ReactiveResponseConsumer();
final Future<Void> future = requester.execute(request, consumer, Timeout.ofSeconds(1), null);
- final ExecutionException exception = Assert.assertThrows(ExecutionException.class, () ->
+ final ExecutionException exception = Assertions.assertThrows(ExecutionException.class, () ->
future.get(RESULT_TIMEOUT.getDuration(), RESULT_TIMEOUT.getTimeUnit()));
- Assert.assertTrue(requestPublisherWasCancelled.get());
+ Assertions.assertTrue(requestPublisherWasCancelled.get());
final Throwable cause = exception.getCause();
if (versionPolicy == HttpVersionPolicy.FORCE_HTTP_1) {
- Assert.assertTrue("Expected SocketTimeoutException, but got " + cause.getClass().getName(),
- cause instanceof SocketTimeoutException);
+ Assertions.assertTrue(cause instanceof SocketTimeoutException, "Expected SocketTimeoutException, but got " + cause.getClass().getName());
} else if (versionPolicy == HttpVersionPolicy.FORCE_HTTP_2) {
- Assert.assertTrue(format("Expected RST_STREAM, but %s was thrown", cause.getClass().getName()),
- cause instanceof HttpStreamResetException);
+ Assertions.assertTrue(cause instanceof HttpStreamResetException, format("Expected RST_STREAM, but %s was thrown", cause.getClass().getName()));
} else {
- Assert.fail("Unknown HttpVersionPolicy: " + versionPolicy);
+ Assertions.fail("Unknown HttpVersionPolicy: " + versionPolicy);
}
}
@@ -317,16 +317,16 @@ public class ReactiveClientTest {
.take(3)
.toList()
.blockingGet();
- Assert.assertEquals(3, outputBuffers.size());
- Assert.assertTrue("The response subscription should have been cancelled", responsePublisherWasCancelled.get());
- final Exception exception = Assert.assertThrows(Exception.class, () ->
+ Assertions.assertEquals(3, outputBuffers.size());
+ Assertions.assertTrue(responsePublisherWasCancelled.get(), "The response subscription should have been cancelled");
+ final Exception exception = Assertions.assertThrows(Exception.class, () ->
future.get(RESULT_TIMEOUT.getDuration(), RESULT_TIMEOUT.getTimeUnit()));
- MatcherAssert.assertThat(exception, CoreMatchers.anyOf(
+ assertThat(exception, CoreMatchers.anyOf(
CoreMatchers.instanceOf(CancellationException.class),
CoreMatchers.instanceOf(ExecutionException.class)));
- Assert.assertTrue(exception.getCause() instanceof HttpStreamResetException);
- Assert.assertTrue(requestPublisherWasCancelled.get());
- Assert.assertNull(requestStreamError.get());
+ Assertions.assertTrue(exception.getCause() instanceof HttpStreamResetException);
+ Assertions.assertTrue(requestPublisherWasCancelled.get());
+ Assertions.assertNull(requestStreamError.get());
}
private InetSocketAddress startClientAndServer() throws InterruptedException, ExecutionException {
diff --git a/httpcore5/pom.xml b/httpcore5/pom.xml
index ce6599a..3d8cdf3 100644
--- a/httpcore5/pom.xml
+++ b/httpcore5/pom.xml
@@ -41,8 +41,13 @@
<dependencies>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/concurrent/TestBasicFuture.java b/httpcore5/src/test/java/org/apache/hc/core5/concurrent/TestBasicFuture.java
index b51e2d7..f901b0a 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/concurrent/TestBasicFuture.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/concurrent/TestBasicFuture.java
@@ -32,8 +32,8 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.apache.hc.core5.util.TimeoutValueException;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestBasicFuture {
@@ -42,21 +42,21 @@ public class TestBasicFuture {
final BasicFutureCallback<Object> callback = new BasicFutureCallback<>();
final BasicFuture<Object> future = new BasicFuture<>(callback);
- Assert.assertFalse(future.isDone());
+ Assertions.assertFalse(future.isDone());
final Object result = new Object();
final Exception boom = new Exception();
future.completed(result);
future.failed(boom);
- Assert.assertTrue(callback.isCompleted());
- Assert.assertSame(result, callback.getResult());
- Assert.assertFalse(callback.isFailed());
- Assert.assertNull(callback.getException());
- Assert.assertFalse(callback.isCancelled());
+ Assertions.assertTrue(callback.isCompleted());
+ Assertions.assertSame(result, callback.getResult());
+ Assertions.assertFalse(callback.isFailed());
+ Assertions.assertNull(callback.getException());
+ Assertions.assertFalse(callback.isCancelled());
- Assert.assertSame(result, future.get());
- Assert.assertTrue(future.isDone());
- Assert.assertFalse(future.isCancelled());
+ Assertions.assertSame(result, future.get());
+ Assertions.assertTrue(future.isDone());
+ Assertions.assertFalse(future.isCancelled());
}
@@ -65,21 +65,21 @@ public class TestBasicFuture {
final BasicFutureCallback<Object> callback = new BasicFutureCallback<>();
final BasicFuture<Object> future = new BasicFuture<>(callback);
- Assert.assertFalse(future.isDone());
+ Assertions.assertFalse(future.isDone());
final Object result = new Object();
final Exception boom = new Exception();
future.completed(result);
future.failed(boom);
- Assert.assertTrue(callback.isCompleted());
- Assert.assertSame(result, callback.getResult());
- Assert.assertFalse(callback.isFailed());
- Assert.assertNull(callback.getException());
- Assert.assertFalse(callback.isCancelled());
-
- Assert.assertSame(result, future.get(1, TimeUnit.MILLISECONDS));
- Assert.assertTrue(future.isDone());
- Assert.assertFalse(future.isCancelled());
+ Assertions.assertTrue(callback.isCompleted());
+ Assertions.assertSame(result, callback.getResult());
+ Assertions.assertFalse(callback.isFailed());
+ Assertions.assertNull(callback.getException());
+ Assertions.assertFalse(callback.isCancelled());
+
+ Assertions.assertSame(result, future.get(1, TimeUnit.MILLISECONDS));
+ Assertions.assertTrue(future.isDone());
+ Assertions.assertFalse(future.isCancelled());
}
@Test
@@ -90,19 +90,19 @@ public class TestBasicFuture {
final Exception boom = new Exception();
future.failed(boom);
future.completed(result);
- Assert.assertFalse(callback.isCompleted());
- Assert.assertNull(callback.getResult());
- Assert.assertTrue(callback.isFailed());
- Assert.assertSame(boom, callback.getException());
- Assert.assertFalse(callback.isCancelled());
+ Assertions.assertFalse(callback.isCompleted());
+ Assertions.assertNull(callback.getResult());
+ Assertions.assertTrue(callback.isFailed());
+ Assertions.assertSame(boom, callback.getException());
+ Assertions.assertFalse(callback.isCancelled());
try {
future.get();
} catch (final ExecutionException ex) {
- Assert.assertSame(boom, ex.getCause());
+ Assertions.assertSame(boom, ex.getCause());
}
- Assert.assertTrue(future.isDone());
- Assert.assertFalse(future.isCancelled());
+ Assertions.assertTrue(future.isDone());
+ Assertions.assertFalse(future.isCancelled());
}
@Test
@@ -114,15 +114,15 @@ public class TestBasicFuture {
future.cancel(true);
future.failed(boom);
future.completed(result);
- Assert.assertFalse(callback.isCompleted());
- Assert.assertNull(callback.getResult());
- Assert.assertFalse(callback.isFailed());
- Assert.assertNull(callback.getException());
- Assert.assertTrue(callback.isCancelled());
-
- Assert.assertThrows(CancellationException.class, future::get);
- Assert.assertTrue(future.isDone());
- Assert.assertTrue(future.isCancelled());
+ Assertions.assertFalse(callback.isCompleted());
+ Assertions.assertNull(callback.getResult());
+ Assertions.assertFalse(callback.isFailed());
+ Assertions.assertNull(callback.getException());
+ Assertions.assertTrue(callback.isCancelled());
+
+ Assertions.assertThrows(CancellationException.class, future::get);
+ Assertions.assertTrue(future.isDone());
+ Assertions.assertTrue(future.isCancelled());
}
@Test
@@ -139,9 +139,9 @@ public class TestBasicFuture {
});
t.setDaemon(true);
t.start();
- Assert.assertSame(result, future.get(60, TimeUnit.SECONDS));
- Assert.assertTrue(future.isDone());
- Assert.assertFalse(future.isCancelled());
+ Assertions.assertSame(result, future.get(60, TimeUnit.SECONDS));
+ Assertions.assertTrue(future.isDone());
+ Assertions.assertFalse(future.isCancelled());
}
@Test
@@ -161,10 +161,10 @@ public class TestBasicFuture {
try {
future.get(60, TimeUnit.SECONDS);
} catch (final ExecutionException ex) {
- Assert.assertSame(boom, ex.getCause());
+ Assertions.assertSame(boom, ex.getCause());
}
- Assert.assertTrue(future.isDone());
- Assert.assertFalse(future.isCancelled());
+ Assertions.assertTrue(future.isDone());
+ Assertions.assertFalse(future.isCancelled());
}
@Test
@@ -180,7 +180,7 @@ public class TestBasicFuture {
});
t.setDaemon(true);
t.start();
- Assert.assertThrows(CancellationException.class, () ->
+ Assertions.assertThrows(CancellationException.class, () ->
future.get(60, TimeUnit.SECONDS));
}
@@ -198,14 +198,14 @@ public class TestBasicFuture {
});
t.setDaemon(true);
t.start();
- Assert.assertThrows(TimeoutException.class, () ->
+ Assertions.assertThrows(TimeoutException.class, () ->
future.get(1, TimeUnit.MILLISECONDS));
}
@Test
public void testAsyncNegativeTimeout() throws Exception {
final BasicFuture<Object> future = new BasicFuture<>(null);
- Assert.assertThrows(TimeoutValueException.class, () ->
+ Assertions.assertThrows(TimeoutValueException.class, () ->
future.get(-1, TimeUnit.MILLISECONDS));
}
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 9904576..928e889 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
@@ -26,10 +26,11 @@
*/
package org.apache.hc.core5.concurrent;
+import static org.hamcrest.MatcherAssert.assertThat;
+
import org.hamcrest.CoreMatchers;
-import org.hamcrest.MatcherAssert;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestComplexCancellable {
@@ -40,15 +41,15 @@ public class TestComplexCancellable {
final BasicFuture<Object> dependency1 = new BasicFuture<>(null);
cancellable.setDependency(dependency1);
- Assert.assertFalse(cancellable.isCancelled());
+ Assertions.assertFalse(cancellable.isCancelled());
cancellable.cancel();
- MatcherAssert.assertThat(cancellable.isCancelled(), CoreMatchers.is(true));
- MatcherAssert.assertThat(dependency1.isCancelled(), CoreMatchers.is(true));
+ assertThat(cancellable.isCancelled(), CoreMatchers.is(true));
+ assertThat(dependency1.isCancelled(), CoreMatchers.is(true));
final BasicFuture<Object> dependency2 = new BasicFuture<>(null);
cancellable.setDependency(dependency2);
- MatcherAssert.assertThat(dependency2.isCancelled(), CoreMatchers.is(true));
+ 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 7653260..8635bae 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 static org.hamcrest.MatcherAssert.assertThat;
+
import java.util.concurrent.Future;
import org.hamcrest.CoreMatchers;
-import org.hamcrest.MatcherAssert;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestComplexFuture {
@@ -42,15 +43,15 @@ public class TestComplexFuture {
final Future<Object> dependency1 = new BasicFuture<>(null);
future.setDependency(dependency1);
- Assert.assertFalse(future.isDone());
+ Assertions.assertFalse(future.isDone());
future.cancel();
- MatcherAssert.assertThat(future.isCancelled(), CoreMatchers.is(true));
- MatcherAssert.assertThat(dependency1.isCancelled(), CoreMatchers.is(true));
+ assertThat(future.isCancelled(), CoreMatchers.is(true));
+ assertThat(dependency1.isCancelled(), CoreMatchers.is(true));
final Future<Object> dependency2 = new BasicFuture<>(null);
future.setDependency(dependency2);
- MatcherAssert.assertThat(dependency2.isCancelled(), CoreMatchers.is(true));
+ assertThat(dependency2.isCancelled(), CoreMatchers.is(true));
}
@Test
@@ -60,15 +61,15 @@ public class TestComplexFuture {
final Future<Object> dependency1 = new BasicFuture<>(null);
future.setDependency(dependency1);
- Assert.assertFalse(future.isDone());
+ Assertions.assertFalse(future.isDone());
future.completed(Boolean.TRUE);
- MatcherAssert.assertThat(future.isCancelled(), CoreMatchers.is(false));
- MatcherAssert.assertThat(dependency1.isCancelled(), CoreMatchers.is(false));
+ assertThat(future.isCancelled(), CoreMatchers.is(false));
+ assertThat(dependency1.isCancelled(), CoreMatchers.is(false));
final Future<Object> dependency2 = new BasicFuture<>(null);
future.setDependency(dependency2);
- MatcherAssert.assertThat(dependency2.isCancelled(), CoreMatchers.is(true));
+ assertThat(dependency2.isCancelled(), CoreMatchers.is(true));
}
@Test
@@ -84,15 +85,15 @@ public class TestComplexFuture {
});
future.setDependency(dependency1);
- Assert.assertFalse(future.isDone());
+ Assertions.assertFalse(future.isDone());
future.cancel();
- MatcherAssert.assertThat(future.isCancelled(), CoreMatchers.is(true));
- MatcherAssert.assertThat(dependency1.isCancelled(), CoreMatchers.is(true));
+ assertThat(future.isCancelled(), CoreMatchers.is(true));
+ assertThat(dependency1.isCancelled(), CoreMatchers.is(true));
final Future<Object> dependency2 = new BasicFuture<>(null);
future.setDependency(dependency2);
- MatcherAssert.assertThat(dependency2.isCancelled(), CoreMatchers.is(true));
+ assertThat(dependency2.isCancelled(), CoreMatchers.is(true));
}
}
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
index 528cfb7..31b247f 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/HeaderMatcher.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/HeaderMatcher.java
@@ -29,7 +29,6 @@ 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> {
@@ -58,7 +57,6 @@ public class HeaderMatcher extends BaseMatcher<Header> {
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
index 5b6ae44..d958d6e 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/HeadersMatcher.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/HeadersMatcher.java
@@ -29,7 +29,6 @@ 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[]> {
@@ -64,7 +63,6 @@ public class HeadersMatcher extends BaseMatcher<Header[]> {
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/NameValuePairListMatcher.java b/httpcore5/src/test/java/org/apache/hc/core5/http/NameValuePairListMatcher.java
index ffc1c56..4600c4f 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/NameValuePairListMatcher.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/NameValuePairListMatcher.java
@@ -33,7 +33,6 @@ import java.util.List;
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 NameValuePairListMatcher extends BaseMatcher<List<NameValuePair>> {
@@ -72,12 +71,10 @@ public class NameValuePairListMatcher extends BaseMatcher<List<NameValuePair>> {
description.appendText("equals ").appendValueList("[", ";", "]", nvps);
}
- @Factory
public static Matcher<List<NameValuePair>> equalsTo(final NameValuePair... nvps) {
return new NameValuePairListMatcher(Arrays.asList(nvps));
}
- @Factory
public static Matcher<List<NameValuePair>> isEmpty() {
return new NameValuePairListMatcher(Collections.emptyList());
}
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/TestContentType.java b/httpcore5/src/test/java/org/apache/hc/core5/http/TestContentType.java
index 9d4c25b..8a0b01f 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/TestContentType.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/TestContentType.java
@@ -30,8 +30,8 @@ package org.apache.hc.core5.http;
import java.nio.charset.StandardCharsets;
import org.apache.hc.core5.http.message.BasicNameValuePair;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
/**
* Unit tests for {@link ContentType}.
@@ -42,98 +42,98 @@ public class TestContentType {
@Test
public void testBasis() throws Exception {
final ContentType contentType = ContentType.create("text/plain", "US-ASCII");
- Assert.assertEquals("text/plain", contentType.getMimeType());
- Assert.assertEquals(StandardCharsets.US_ASCII, contentType.getCharset());
- Assert.assertEquals("text/plain; charset=US-ASCII", contentType.toString());
+ Assertions.assertEquals("text/plain", contentType.getMimeType());
+ Assertions.assertEquals(StandardCharsets.US_ASCII, contentType.getCharset());
+ Assertions.assertEquals("text/plain; charset=US-ASCII", contentType.toString());
}
@Test
public void testWithCharset() throws Exception {
ContentType contentType = ContentType.create("text/plain", "US-ASCII");
- Assert.assertEquals("text/plain", contentType.getMimeType());
- Assert.assertEquals(StandardCharsets.US_ASCII, contentType.getCharset());
- Assert.assertEquals("text/plain; charset=US-ASCII", contentType.toString());
+ Assertions.assertEquals("text/plain", contentType.getMimeType());
+ Assertions.assertEquals(StandardCharsets.US_ASCII, contentType.getCharset());
+ Assertions.assertEquals("text/plain; charset=US-ASCII", contentType.toString());
contentType = contentType.withCharset(StandardCharsets.UTF_8);
- Assert.assertEquals("text/plain", contentType.getMimeType());
- Assert.assertEquals("UTF-8", contentType.getCharset().name());
- Assert.assertEquals("text/plain; charset=UTF-8", contentType.toString());
+ Assertions.assertEquals("text/plain", contentType.getMimeType());
+ Assertions.assertEquals("UTF-8", contentType.getCharset().name());
+ Assertions.assertEquals("text/plain; charset=UTF-8", contentType.toString());
}
@Test
public void testWithCharsetString() throws Exception {
ContentType contentType = ContentType.create("text/plain", "US-ASCII");
- Assert.assertEquals("text/plain", contentType.getMimeType());
- Assert.assertEquals(StandardCharsets.US_ASCII, contentType.getCharset());
- Assert.assertEquals("text/plain; charset=US-ASCII", contentType.toString());
+ Assertions.assertEquals("text/plain", contentType.getMimeType());
+ Assertions.assertEquals(StandardCharsets.US_ASCII, contentType.getCharset());
+ Assertions.assertEquals("text/plain; charset=US-ASCII", contentType.toString());
contentType = contentType.withCharset(StandardCharsets.UTF_8);
- Assert.assertEquals("text/plain", contentType.getMimeType());
- Assert.assertEquals(StandardCharsets.UTF_8, contentType.getCharset());
- Assert.assertEquals("text/plain; charset=UTF-8", contentType.toString());
+ Assertions.assertEquals("text/plain", contentType.getMimeType());
+ Assertions.assertEquals(StandardCharsets.UTF_8, contentType.getCharset());
+ Assertions.assertEquals("text/plain; charset=UTF-8", contentType.toString());
}
@Test
public void testLowCaseText() throws Exception {
final ContentType contentType = ContentType.create("Text/Plain", "ascii");
- Assert.assertEquals("text/plain", contentType.getMimeType());
- Assert.assertEquals(StandardCharsets.US_ASCII, contentType.getCharset());
+ Assertions.assertEquals("text/plain", contentType.getMimeType());
+ Assertions.assertEquals(StandardCharsets.US_ASCII, contentType.getCharset());
}
@Test
public void testCreateInvalidInput() throws Exception {
- Assert.assertThrows(NullPointerException.class, () -> ContentType.create(null, (String) null));
- Assert.assertThrows(IllegalArgumentException.class, () -> ContentType.create(" ", (String) null));
- Assert.assertThrows(IllegalArgumentException.class, () -> ContentType.create("stuff;", (String) null));
- Assert.assertThrows(IllegalArgumentException.class, () -> ContentType.create("text/plain", ","));
+ Assertions.assertThrows(NullPointerException.class, () -> ContentType.create(null, (String) null));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> ContentType.create(" ", (String) null));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> ContentType.create("stuff;", (String) null));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> ContentType.create("text/plain", ","));
}
@Test
public void testParse() throws Exception {
final ContentType contentType = ContentType.parse("text/plain; charset=\"ascii\"");
- Assert.assertEquals("text/plain", contentType.getMimeType());
- Assert.assertEquals(StandardCharsets.US_ASCII, contentType.getCharset());
- Assert.assertEquals("text/plain; charset=ascii", contentType.toString());
+ Assertions.assertEquals("text/plain", contentType.getMimeType());
+ Assertions.assertEquals(StandardCharsets.US_ASCII, contentType.getCharset());
+ Assertions.assertEquals("text/plain; charset=ascii", contentType.toString());
}
@Test
public void testParseMultiparam() throws Exception {
final ContentType contentType = ContentType.parse("text/plain; charset=\"ascii\"; " +
"p0 ; p1 = \"blah-blah\" ; p2 = \" yada yada \" ");
- Assert.assertEquals("text/plain", contentType.getMimeType());
- Assert.assertEquals(StandardCharsets.US_ASCII, contentType.getCharset());
- Assert.assertEquals("text/plain; charset=ascii; p0; p1=blah-blah; p2=\" yada yada \"",
+ Assertions.assertEquals("text/plain", contentType.getMimeType());
+ Assertions.assertEquals(StandardCharsets.US_ASCII, contentType.getCharset());
+ Assertions.assertEquals("text/plain; charset=ascii; p0; p1=blah-blah; p2=\" yada yada \"",
contentType.toString());
- Assert.assertNull(contentType.getParameter("p0"));
- Assert.assertEquals("blah-blah", contentType.getParameter("p1"));
- Assert.assertEquals(" yada yada ", contentType.getParameter("p2"));
- Assert.assertNull(contentType.getParameter("p3"));
+ Assertions.assertNull(contentType.getParameter("p0"));
+ Assertions.assertEquals("blah-blah", contentType.getParameter("p1"));
+ Assertions.assertEquals(" yada yada ", contentType.getParameter("p2"));
+ Assertions.assertNull(contentType.getParameter("p3"));
}
@Test
public void testParseEmptyCharset() throws Exception {
final ContentType contentType = ContentType.parse("text/plain; charset=\" \"");
- Assert.assertEquals("text/plain", contentType.getMimeType());
- Assert.assertNull(contentType.getCharset());
+ Assertions.assertEquals("text/plain", contentType.getMimeType());
+ Assertions.assertNull(contentType.getCharset());
}
@Test
public void testParseDefaultCharset() throws Exception {
final ContentType contentType = ContentType.parse("text/plain; charset=\" \"");
- Assert.assertEquals("text/plain", contentType.getMimeType());
- Assert.assertNull(contentType.getCharset());
- Assert.assertEquals(StandardCharsets.US_ASCII, contentType.getCharset(StandardCharsets.US_ASCII));
- Assert.assertNull(contentType.getCharset(null));
+ Assertions.assertEquals("text/plain", contentType.getMimeType());
+ Assertions.assertNull(contentType.getCharset());
+ Assertions.assertEquals(StandardCharsets.US_ASCII, contentType.getCharset(StandardCharsets.US_ASCII));
+ Assertions.assertNull(contentType.getCharset(null));
//
- Assert.assertNull(ContentType.getCharset(contentType, null));
- Assert.assertEquals(StandardCharsets.US_ASCII, ContentType.getCharset(contentType, StandardCharsets.US_ASCII));
+ Assertions.assertNull(ContentType.getCharset(contentType, null));
+ Assertions.assertEquals(StandardCharsets.US_ASCII, ContentType.getCharset(contentType, StandardCharsets.US_ASCII));
}
@Test
public void testParseEmptyValue() throws Exception {
- Assert.assertNull(ContentType.parse(null));
- Assert.assertNull(ContentType.parse(""));
- Assert.assertNull(ContentType.parse(" "));
- Assert.assertNull(ContentType.parse(";"));
- Assert.assertNull(ContentType.parse("="));
+ Assertions.assertNull(ContentType.parse(null));
+ Assertions.assertNull(ContentType.parse(""));
+ Assertions.assertNull(ContentType.parse(" "));
+ Assertions.assertNull(ContentType.parse(";"));
+ Assertions.assertNull(ContentType.parse("="));
}
@Test
@@ -142,28 +142,28 @@ public class TestContentType {
new BasicNameValuePair("charset", "UTF-8"),
new BasicNameValuePair("p", "this"),
new BasicNameValuePair("p", "that"));
- Assert.assertEquals("text/plain", contentType.getMimeType());
- Assert.assertEquals(StandardCharsets.UTF_8, contentType.getCharset());
- Assert.assertEquals("text/plain; charset=UTF-8; p=this; p=that", contentType.toString());
+ Assertions.assertEquals("text/plain", contentType.getMimeType());
+ Assertions.assertEquals(StandardCharsets.UTF_8, contentType.getCharset());
+ Assertions.assertEquals("text/plain; charset=UTF-8; p=this; p=that", contentType.toString());
contentType = contentType.withParameters(
new BasicNameValuePair("charset", "ascii"),
new BasicNameValuePair("p", "this and that"));
- Assert.assertEquals("text/plain", contentType.getMimeType());
- Assert.assertEquals(StandardCharsets.US_ASCII, contentType.getCharset());
- Assert.assertEquals("text/plain; charset=ascii; p=\"this and that\"", contentType.toString());
+ Assertions.assertEquals("text/plain", contentType.getMimeType());
+ Assertions.assertEquals(StandardCharsets.US_ASCII, contentType.getCharset());
+ Assertions.assertEquals("text/plain; charset=ascii; p=\"this and that\"", contentType.toString());
contentType = ContentType.create("text/blah").withParameters(
new BasicNameValuePair("p", "blah"));
- Assert.assertEquals("text/blah", contentType.getMimeType());
- Assert.assertNull(contentType.getCharset());
- Assert.assertEquals("text/blah; p=blah", contentType.toString());
+ Assertions.assertEquals("text/blah", contentType.getMimeType());
+ Assertions.assertNull(contentType.getCharset());
+ Assertions.assertEquals("text/blah; p=blah", contentType.toString());
contentType = ContentType.create("text/blah", StandardCharsets.ISO_8859_1).withParameters(
new BasicNameValuePair("p", "blah"));
- Assert.assertEquals("text/blah", contentType.getMimeType());
- Assert.assertEquals(StandardCharsets.ISO_8859_1, contentType.getCharset());
- Assert.assertEquals("text/blah; charset=ISO-8859-1; p=blah", contentType.toString());
+ Assertions.assertEquals("text/blah", contentType.getMimeType());
+ Assertions.assertEquals(StandardCharsets.ISO_8859_1, contentType.getCharset());
+ Assertions.assertEquals("text/blah; charset=ISO-8859-1; p=blah", contentType.toString());
}
}
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/TestHttpExceptions.java b/httpcore5/src/test/java/org/apache/hc/core5/http/TestHttpExceptions.java
index 30e671d..6262e70 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/TestHttpExceptions.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/TestHttpExceptions.java
@@ -27,8 +27,8 @@
package org.apache.hc.core5.http;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
/**
* Simple tests for various HTTP exception classes.
@@ -58,32 +58,32 @@ public class TestHttpExceptions {
@Test
public void testNonPrintableCharactersInConnectionClosedException() {
- Assert.assertEquals(CLEAN_MESSAGE, new ConnectionClosedException(nonPrintableMessage).getMessage());
+ Assertions.assertEquals(CLEAN_MESSAGE, new ConnectionClosedException(nonPrintableMessage).getMessage());
}
@Test
public void testNonPrintableCharactersInHttpException() {
- Assert.assertEquals(CLEAN_MESSAGE, new HttpException(nonPrintableMessage).getMessage());
+ Assertions.assertEquals(CLEAN_MESSAGE, new HttpException(nonPrintableMessage).getMessage());
}
@Test
public void testNonPrintableCharactersInMethodNotSupportedException() {
- Assert.assertEquals(CLEAN_MESSAGE, new MethodNotSupportedException(nonPrintableMessage).getMessage());
+ Assertions.assertEquals(CLEAN_MESSAGE, new MethodNotSupportedException(nonPrintableMessage).getMessage());
}
@Test
public void testNonPrintableCharactersInNoHttpResponseException() {
- Assert.assertEquals(CLEAN_MESSAGE, new NoHttpResponseException(nonPrintableMessage).getMessage());
+ Assertions.assertEquals(CLEAN_MESSAGE, new NoHttpResponseException(nonPrintableMessage).getMessage());
}
@Test
public void testNonPrintableCharactersInProtocolException() {
- Assert.assertEquals(CLEAN_MESSAGE, new ProtocolException(nonPrintableMessage).getMessage());
+ Assertions.assertEquals(CLEAN_MESSAGE, new ProtocolException(nonPrintableMessage).getMessage());
}
@Test
public void testNonPrintableCharactersInUnsupportedHttpVersionException() {
- Assert.assertEquals(CLEAN_MESSAGE, new UnsupportedHttpVersionException(nonPrintableMessage).getMessage());
+ Assertions.assertEquals(CLEAN_MESSAGE, new UnsupportedHttpVersionException(nonPrintableMessage).getMessage());
}
}
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/TestHttpHost.java b/httpcore5/src/test/java/org/apache/hc/core5/http/TestHttpHost.java
index e666bf9..c6032a1 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/TestHttpHost.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/TestHttpHost.java
@@ -35,8 +35,8 @@ import java.net.InetAddress;
import java.net.URI;
import java.net.URISyntaxException;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
/**
* Unit tests for {@link HttpHost}.
@@ -47,28 +47,28 @@ public class TestHttpHost {
@Test
public void testConstructor() {
final HttpHost host1 = new HttpHost("somehost");
- Assert.assertEquals("somehost", host1.getHostName());
- Assert.assertEquals(-1, host1.getPort());
- Assert.assertEquals("http", host1.getSchemeName());
+ Assertions.assertEquals("somehost", host1.getHostName());
+ Assertions.assertEquals(-1, host1.getPort());
+ Assertions.assertEquals("http", host1.getSchemeName());
final HttpHost host2 = new HttpHost("somehost", 8080);
- Assert.assertEquals("somehost", host2.getHostName());
- Assert.assertEquals(8080, host2.getPort());
- Assert.assertEquals("http", host2.getSchemeName());
+ Assertions.assertEquals("somehost", host2.getHostName());
+ Assertions.assertEquals(8080, host2.getPort());
+ Assertions.assertEquals("http", host2.getSchemeName());
final HttpHost host3 = new HttpHost("somehost", -1);
- Assert.assertEquals("somehost", host3.getHostName());
- Assert.assertEquals(-1, host3.getPort());
- Assert.assertEquals("http", host3.getSchemeName());
+ Assertions.assertEquals("somehost", host3.getHostName());
+ Assertions.assertEquals(-1, host3.getPort());
+ Assertions.assertEquals("http", host3.getSchemeName());
final HttpHost host4 = new HttpHost("https", "somehost", 443);
- Assert.assertEquals("somehost", host4.getHostName());
- Assert.assertEquals(443, host4.getPort());
- Assert.assertEquals("https", host4.getSchemeName());
+ Assertions.assertEquals("somehost", host4.getHostName());
+ Assertions.assertEquals(443, host4.getPort());
+ Assertions.assertEquals("https", host4.getSchemeName());
final HttpHost host5 = new HttpHost("https", "somehost");
- Assert.assertEquals("somehost", host5.getHostName());
- Assert.assertEquals(-1, host5.getPort());
- Assert.assertEquals("https", host5.getSchemeName());
- Assert.assertThrows(NullPointerException.class, () -> new HttpHost(null, (String) null, -1));
- Assert.assertThrows(IllegalArgumentException.class, () -> new HttpHost(null, " ", -1));
- Assert.assertThrows(NullPointerException.class, () -> new HttpHost(null, (InetAddress) null, -1));
+ Assertions.assertEquals("somehost", host5.getHostName());
+ Assertions.assertEquals(-1, host5.getPort());
+ Assertions.assertEquals("https", host5.getSchemeName());
+ Assertions.assertThrows(NullPointerException.class, () -> new HttpHost(null, (String) null, -1));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> new HttpHost(null, " ", -1));
+ Assertions.assertThrows(NullPointerException.class, () -> new HttpHost(null, (InetAddress) null, -1));
}
@Test
@@ -89,17 +89,17 @@ public class TestHttpHost {
final HttpHost host11 = new HttpHost(
"http", InetAddress.getByAddress("someotherhost",new byte[] {127,0,0,1}), 80);
- Assert.assertEquals(host1.hashCode(), host1.hashCode());
- Assert.assertTrue(host1.hashCode() != host2.hashCode());
- Assert.assertTrue(host1.hashCode() != host3.hashCode());
- Assert.assertEquals(host2.hashCode(), host4.hashCode());
- Assert.assertEquals(host2.hashCode(), host5.hashCode());
- Assert.assertTrue(host5.hashCode() != host6.hashCode());
- Assert.assertTrue(host7.hashCode() != host8.hashCode());
- Assert.assertTrue(host8.hashCode() != host9.hashCode());
- Assert.assertEquals(host9.hashCode(), host10.hashCode());
- Assert.assertTrue(host10.hashCode() != host11.hashCode());
- Assert.assertTrue(host9.hashCode() != host11.hashCode());
+ Assertions.assertEquals(host1.hashCode(), host1.hashCode());
+ Assertions.assertTrue(host1.hashCode() != host2.hashCode());
+ Assertions.assertTrue(host1.hashCode() != host3.hashCode());
+ Assertions.assertEquals(host2.hashCode(), host4.hashCode());
+ Assertions.assertEquals(host2.hashCode(), host5.hashCode());
+ Assertions.assertTrue(host5.hashCode() != host6.hashCode());
+ Assertions.assertTrue(host7.hashCode() != host8.hashCode());
+ Assertions.assertTrue(host8.hashCode() != host9.hashCode());
+ Assertions.assertEquals(host9.hashCode(), host10.hashCode());
+ Assertions.assertTrue(host10.hashCode() != host11.hashCode());
+ Assertions.assertTrue(host9.hashCode() != host11.hashCode());
}
@Test
@@ -120,54 +120,54 @@ public class TestHttpHost {
final HttpHost host11 = new HttpHost(
"http", InetAddress.getByAddress("someotherhost",new byte[] {127,0,0,1}), 80);
- Assert.assertEquals(host1, host1);
- Assert.assertNotEquals(host1, host2);
- Assert.assertNotEquals(host1, host3);
- Assert.assertEquals(host2, host4);
- Assert.assertEquals(host2, host5);
- Assert.assertNotEquals(host5, host6);
- Assert.assertNotEquals(host7, host8);
- Assert.assertFalse(host7.equals(host9));
- Assert.assertNotEquals(null, host1);
- Assert.assertNotEquals("http://somehost", host1);
- Assert.assertNotEquals("http://somehost", host9);
- Assert.assertNotEquals(host8, host9);
- Assert.assertEquals(host9, host10);
- Assert.assertNotEquals(host9, host11);
+ Assertions.assertEquals(host1, host1);
+ Assertions.assertNotEquals(host1, host2);
+ Assertions.assertNotEquals(host1, host3);
+ Assertions.assertEquals(host2, host4);
+ Assertions.assertEquals(host2, host5);
+ Assertions.assertNotEquals(host5, host6);
+ Assertions.assertNotEquals(host7, host8);
+ Assertions.assertFalse(host7.equals(host9));
+ Assertions.assertNotEquals(null, host1);
+ Assertions.assertNotEquals("http://somehost", host1);
+ Assertions.assertNotEquals("http://somehost", host9);
+ Assertions.assertNotEquals(host8, host9);
+ Assertions.assertEquals(host9, host10);
+ Assertions.assertNotEquals(host9, host11);
}
@Test
public void testToString() throws Exception {
final HttpHost host1 = new HttpHost("somehost");
- Assert.assertEquals("http://somehost", host1.toString());
+ Assertions.assertEquals("http://somehost", host1.toString());
final HttpHost host2 = new HttpHost("somehost", -1);
- Assert.assertEquals("http://somehost", host2.toString());
+ Assertions.assertEquals("http://somehost", host2.toString());
final HttpHost host3 = new HttpHost("somehost", -1);
- Assert.assertEquals("http://somehost", host3.toString());
+ Assertions.assertEquals("http://somehost", host3.toString());
final HttpHost host4 = new HttpHost("somehost", 8888);
- Assert.assertEquals("http://somehost:8888", host4.toString());
+ Assertions.assertEquals("http://somehost:8888", host4.toString());
final HttpHost host5 = new HttpHost("myhttp", "somehost", -1);
- Assert.assertEquals("myhttp://somehost", host5.toString());
+ Assertions.assertEquals("myhttp://somehost", host5.toString());
final HttpHost host6 = new HttpHost("myhttp", "somehost", 80);
- Assert.assertEquals("myhttp://somehost:80", host6.toString());
+ Assertions.assertEquals("myhttp://somehost:80", host6.toString());
final HttpHost host7 = new HttpHost(
"http", InetAddress.getByAddress("127.0.0.1", new byte[] {127,0,0,1}), 80);
- Assert.assertEquals("http://127.0.0.1:80", host7.toString());
+ Assertions.assertEquals("http://127.0.0.1:80", host7.toString());
final HttpHost host9 = new HttpHost(
"http", InetAddress.getByAddress("somehost", new byte[] {127,0,0,1}), 80);
- Assert.assertEquals("http://somehost:80", host9.toString());
+ Assertions.assertEquals("http://somehost:80", host9.toString());
}
@Test
public void testToHostString() {
final HttpHost host1 = new HttpHost("somehost");
- Assert.assertEquals("somehost", host1.toHostString());
+ Assertions.assertEquals("somehost", host1.toHostString());
final HttpHost host2 = new HttpHost("somehost");
- Assert.assertEquals("somehost", host2.toHostString());
+ Assertions.assertEquals("somehost", host2.toHostString());
final HttpHost host3 = new HttpHost("somehost", -1);
- Assert.assertEquals("somehost", host3.toHostString());
+ Assertions.assertEquals("somehost", host3.toHostString());
final HttpHost host4 = new HttpHost("somehost", 8888);
- Assert.assertEquals("somehost:8888", host4.toHostString());
+ Assertions.assertEquals("somehost:8888", host4.toHostString());
}
@Test
@@ -181,60 +181,60 @@ public class TestHttpHost {
final ByteArrayInputStream inBuffer = new ByteArrayInputStream(raw);
final ObjectInputStream inStream = new ObjectInputStream(inBuffer);
final HttpHost clone = (HttpHost) inStream.readObject();
- Assert.assertEquals(orig, clone);
+ Assertions.assertEquals(orig, clone);
}
@Test
public void testCreateFromString() throws Exception {
- Assert.assertEquals(new HttpHost("https", "somehost", 8080), HttpHost.create("https://somehost:8080"));
- Assert.assertEquals(new HttpHost("https", "somehost", 8080), HttpHost.create("HttpS://SomeHost:8080"));
- Assert.assertEquals(new HttpHost(null, "somehost", 1234), HttpHost.create("somehost:1234"));
- Assert.assertEquals(new HttpHost(null, "somehost", -1), HttpHost.create("somehost"));
+ Assertions.assertEquals(new HttpHost("https", "somehost", 8080), HttpHost.create("https://somehost:8080"));
+ Assertions.assertEquals(new HttpHost("https", "somehost", 8080), HttpHost.create("HttpS://SomeHost:8080"));
+ Assertions.assertEquals(new HttpHost(null, "somehost", 1234), HttpHost.create("somehost:1234"));
+ Assertions.assertEquals(new HttpHost(null, "somehost", -1), HttpHost.create("somehost"));
}
@Test
public void testCreateFromURI() throws Exception {
- Assert.assertEquals(new HttpHost("https", "somehost", 8080), HttpHost.create(URI.create("https://somehost:8080")));
- Assert.assertEquals(new HttpHost("https", "somehost", 8080), HttpHost.create(URI.create("HttpS://SomeHost:8080")));
- Assert.assertEquals(new HttpHost("https", "somehost", 8080), HttpHost.create(URI.create("HttpS://SomeHost:8080/foo")));
+ Assertions.assertEquals(new HttpHost("https", "somehost", 8080), HttpHost.create(URI.create("https://somehost:8080")));
+ Assertions.assertEquals(new HttpHost("https", "somehost", 8080), HttpHost.create(URI.create("HttpS://SomeHost:8080")));
+ Assertions.assertEquals(new HttpHost("https", "somehost", 8080), HttpHost.create(URI.create("HttpS://SomeHost:8080/foo")));
}
@Test
public void testCreateFromStringInvalid() throws Exception {
- Assert.assertThrows(URISyntaxException.class, () -> HttpHost.create(" host "));
- Assert.assertThrows(URISyntaxException.class, () -> HttpHost.create("host :8080"));
- Assert.assertThrows(IllegalArgumentException.class, () -> HttpHost.create(""));
+ Assertions.assertThrows(URISyntaxException.class, () -> HttpHost.create(" host "));
+ Assertions.assertThrows(URISyntaxException.class, () -> HttpHost.create("host :8080"));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> HttpHost.create(""));
}
@Test
public void testIpv6HostAndPort() throws Exception {
final HttpHost host = HttpHost.create("[::1]:80");
- Assert.assertEquals("http", host.getSchemeName());
- Assert.assertEquals("::1", host.getHostName());
- Assert.assertEquals(80, host.getPort());
+ Assertions.assertEquals("http", host.getSchemeName());
+ Assertions.assertEquals("::1", host.getHostName());
+ Assertions.assertEquals(80, host.getPort());
}
@Test
public void testIpv6HostAndPortWithScheme() throws Exception {
final HttpHost host = HttpHost.create("https://[::1]:80");
- Assert.assertEquals("https", host.getSchemeName());
- Assert.assertEquals("::1", host.getHostName());
- Assert.assertEquals(80, host.getPort());
+ Assertions.assertEquals("https", host.getSchemeName());
+ Assertions.assertEquals("::1", host.getHostName());
+ Assertions.assertEquals(80, host.getPort());
}
@Test
public void testIpv6HostAndPortWithoutBrackets() throws Exception {
- Assert.assertThrows(URISyntaxException.class, () -> HttpHost.create("::1:80"));
+ Assertions.assertThrows(URISyntaxException.class, () -> HttpHost.create("::1:80"));
}
@Test
public void testIpv6HostWithoutPort() throws Exception {
- Assert.assertThrows(URISyntaxException.class, () -> HttpHost.create("::1"));
+ Assertions.assertThrows(URISyntaxException.class, () -> HttpHost.create("::1"));
}
@Test
public void testIpv6HostToString() {
- Assert.assertEquals("http://[::1]:80", new HttpHost("::1", 80).toString());
- Assert.assertEquals("http://[::1]", new HttpHost("::1", -1).toString());
+ Assertions.assertEquals("http://[::1]:80", new HttpHost("::1", 80).toString());
+ Assertions.assertEquals("http://[::1]", new HttpHost("::1", -1).toString());
}
}
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/TestHttpVersion.java b/httpcore5/src/test/java/org/apache/hc/core5/http/TestHttpVersion.java
index c2e042c..bd64ab4 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/TestHttpVersion.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/TestHttpVersion.java
@@ -32,8 +32,8 @@ import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
/**
* Test cases for HTTP version class
@@ -42,37 +42,37 @@ public class TestHttpVersion {
@Test
public void testEqualsMajorMinor() {
- Assert.assertTrue(HttpVersion.HTTP_0_9.equals(0, 9));
- Assert.assertTrue(HttpVersion.HTTP_1_0.equals(1, 0));
- Assert.assertTrue(HttpVersion.HTTP_1_1.equals(1, 1));
- Assert.assertTrue(HttpVersion.HTTP_2.equals(2, 0));
- Assert.assertTrue(HttpVersion.HTTP_2_0.equals(2, 0));
+ Assertions.assertTrue(HttpVersion.HTTP_0_9.equals(0, 9));
+ Assertions.assertTrue(HttpVersion.HTTP_1_0.equals(1, 0));
+ Assertions.assertTrue(HttpVersion.HTTP_1_1.equals(1, 1));
+ Assertions.assertTrue(HttpVersion.HTTP_2.equals(2, 0));
+ Assertions.assertTrue(HttpVersion.HTTP_2_0.equals(2, 0));
//
- Assert.assertFalse(HttpVersion.HTTP_0_9.equals(2, 0));
+ Assertions.assertFalse(HttpVersion.HTTP_0_9.equals(2, 0));
}
@Test
public void testGet() {
- Assert.assertEquals(HttpVersion.HTTP_0_9, HttpVersion.get(0, 9));
- Assert.assertEquals(HttpVersion.HTTP_1_0, HttpVersion.get(1, 0));
- Assert.assertEquals(HttpVersion.HTTP_1_1, HttpVersion.get(1, 1));
- Assert.assertEquals(HttpVersion.HTTP_2_0, HttpVersion.get(2, 0));
- Assert.assertEquals(HttpVersion.HTTP_2, HttpVersion.get(2, 0));
- Assert.assertNotEquals(HttpVersion.HTTP_2_0, HttpVersion.get(2, 1));
+ Assertions.assertEquals(HttpVersion.HTTP_0_9, HttpVersion.get(0, 9));
+ Assertions.assertEquals(HttpVersion.HTTP_1_0, HttpVersion.get(1, 0));
+ Assertions.assertEquals(HttpVersion.HTTP_1_1, HttpVersion.get(1, 1));
+ Assertions.assertEquals(HttpVersion.HTTP_2_0, HttpVersion.get(2, 0));
+ Assertions.assertEquals(HttpVersion.HTTP_2, HttpVersion.get(2, 0));
+ Assertions.assertNotEquals(HttpVersion.HTTP_2_0, HttpVersion.get(2, 1));
//
- Assert.assertSame(HttpVersion.HTTP_0_9, HttpVersion.get(0, 9));
- Assert.assertSame(HttpVersion.HTTP_1_0, HttpVersion.get(1, 0));
- Assert.assertSame(HttpVersion.HTTP_1_1, HttpVersion.get(1, 1));
- Assert.assertSame(HttpVersion.HTTP_2_0, HttpVersion.get(2, 0));
- Assert.assertSame(HttpVersion.HTTP_2, HttpVersion.get(2, 0));
- Assert.assertNotSame(HttpVersion.HTTP_2_0, HttpVersion.get(2, 1));
+ Assertions.assertSame(HttpVersion.HTTP_0_9, HttpVersion.get(0, 9));
+ Assertions.assertSame(HttpVersion.HTTP_1_0, HttpVersion.get(1, 0));
+ Assertions.assertSame(HttpVersion.HTTP_1_1, HttpVersion.get(1, 1));
+ Assertions.assertSame(HttpVersion.HTTP_2_0, HttpVersion.get(2, 0));
+ Assertions.assertSame(HttpVersion.HTTP_2, HttpVersion.get(2, 0));
+ Assertions.assertNotSame(HttpVersion.HTTP_2_0, HttpVersion.get(2, 1));
}
@SuppressWarnings("unused")
@Test
public void testHttpVersionInvalidConstructorInput() throws Exception {
- Assert.assertThrows(IllegalArgumentException.class, () -> new HttpVersion(-1, -1));
- Assert.assertThrows(IllegalArgumentException.class, () -> new HttpVersion(0, -1));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> new HttpVersion(-1, -1));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> new HttpVersion(0, -1));
}
@Test
@@ -80,39 +80,39 @@ public class TestHttpVersion {
final HttpVersion ver1 = new HttpVersion(1, 1);
final HttpVersion ver2 = new HttpVersion(1, 1);
- Assert.assertEquals(ver1.hashCode(), ver2.hashCode());
- Assert.assertEquals(ver1, ver1);
- Assert.assertEquals(ver1, ver2);
- Assert.assertEquals(ver1, ver1);
- Assert.assertEquals(ver1, ver2);
+ Assertions.assertEquals(ver1.hashCode(), ver2.hashCode());
+ Assertions.assertEquals(ver1, ver1);
+ Assertions.assertEquals(ver1, ver2);
+ Assertions.assertEquals(ver1, ver1);
+ Assertions.assertEquals(ver1, ver2);
- Assert.assertFalse(ver1.equals(Float.valueOf(1.1f)));
+ Assertions.assertFalse(ver1.equals(Float.valueOf(1.1f)));
- Assert.assertEquals((new HttpVersion(0, 9)), HttpVersion.HTTP_0_9);
- Assert.assertEquals((new HttpVersion(1, 0)), HttpVersion.HTTP_1_0);
- Assert.assertEquals((new HttpVersion(1, 1)), HttpVersion.HTTP_1_1);
- Assert.assertNotEquals((new HttpVersion(1, 1)), HttpVersion.HTTP_1_0);
+ Assertions.assertEquals((new HttpVersion(0, 9)), HttpVersion.HTTP_0_9);
+ Assertions.assertEquals((new HttpVersion(1, 0)), HttpVersion.HTTP_1_0);
+ Assertions.assertEquals((new HttpVersion(1, 1)), HttpVersion.HTTP_1_1);
+ Assertions.assertNotEquals((new HttpVersion(1, 1)), HttpVersion.HTTP_1_0);
- Assert.assertEquals((new ProtocolVersion("HTTP", 0, 9)), HttpVersion.HTTP_0_9);
- Assert.assertEquals((new ProtocolVersion("HTTP", 1, 0)), HttpVersion.HTTP_1_0);
- Assert.assertEquals((new ProtocolVersion("HTTP", 1, 1)), HttpVersion.HTTP_1_1);
- Assert.assertNotEquals((new ProtocolVersion("http", 1, 1)), HttpVersion.HTTP_1_1);
+ Assertions.assertEquals((new ProtocolVersion("HTTP", 0, 9)), HttpVersion.HTTP_0_9);
+ Assertions.assertEquals((new ProtocolVersion("HTTP", 1, 0)), HttpVersion.HTTP_1_0);
+ Assertions.assertEquals((new ProtocolVersion("HTTP", 1, 1)), HttpVersion.HTTP_1_1);
+ Assertions.assertNotEquals((new ProtocolVersion("http", 1, 1)), HttpVersion.HTTP_1_1);
- Assert.assertEquals(HttpVersion.HTTP_0_9, new ProtocolVersion("HTTP", 0, 9));
- Assert.assertEquals(HttpVersion.HTTP_1_0, new ProtocolVersion("HTTP", 1, 0));
- Assert.assertEquals(HttpVersion.HTTP_1_1, new ProtocolVersion("HTTP", 1, 1));
- Assert.assertNotEquals(HttpVersion.HTTP_1_1, new ProtocolVersion("http", 1, 1));
+ Assertions.assertEquals(HttpVersion.HTTP_0_9, new ProtocolVersion("HTTP", 0, 9));
+ Assertions.assertEquals(HttpVersion.HTTP_1_0, new ProtocolVersion("HTTP", 1, 0));
+ Assertions.assertEquals(HttpVersion.HTTP_1_1, new ProtocolVersion("HTTP", 1, 1));
+ Assertions.assertNotEquals(HttpVersion.HTTP_1_1, new ProtocolVersion("http", 1, 1));
}
@Test
public void testHttpVersionComparison() {
- Assert.assertTrue(HttpVersion.HTTP_0_9.lessEquals(HttpVersion.HTTP_1_1));
- Assert.assertTrue(HttpVersion.HTTP_0_9.greaterEquals(HttpVersion.HTTP_0_9));
- Assert.assertFalse(HttpVersion.HTTP_0_9.greaterEquals(HttpVersion.HTTP_1_0));
+ Assertions.assertTrue(HttpVersion.HTTP_0_9.lessEquals(HttpVersion.HTTP_1_1));
+ Assertions.assertTrue(HttpVersion.HTTP_0_9.greaterEquals(HttpVersion.HTTP_0_9));
+ Assertions.assertFalse(HttpVersion.HTTP_0_9.greaterEquals(HttpVersion.HTTP_1_0));
- Assert.assertTrue(HttpVersion.HTTP_1_0.compareToVersion(HttpVersion.HTTP_1_1) < 0);
- Assert.assertTrue(HttpVersion.HTTP_1_0.compareToVersion(HttpVersion.HTTP_0_9) > 0);
- Assert.assertEquals(0, HttpVersion.HTTP_1_0.compareToVersion(HttpVersion.HTTP_1_0));
+ Assertions.assertTrue(HttpVersion.HTTP_1_0.compareToVersion(HttpVersion.HTTP_1_1) < 0);
+ Assertions.assertTrue(HttpVersion.HTTP_1_0.compareToVersion(HttpVersion.HTTP_0_9) > 0);
+ Assertions.assertEquals(0, HttpVersion.HTTP_1_0.compareToVersion(HttpVersion.HTTP_1_0));
}
@Test
@@ -126,7 +126,7 @@ public class TestHttpVersion {
final ByteArrayInputStream inBuffer = new ByteArrayInputStream(raw);
final ObjectInputStream inStream = new ObjectInputStream(inBuffer);
final HttpVersion clone = (HttpVersion) inStream.readObject();
- Assert.assertEquals(orig, clone);
+ Assertions.assertEquals(orig, clone);
}
}
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/TestProtocolVersion.java b/httpcore5/src/test/java/org/apache/hc/core5/http/TestProtocolVersion.java
index b7b980e..827e0a3 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/TestProtocolVersion.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/TestProtocolVersion.java
@@ -27,8 +27,8 @@
package org.apache.hc.core5.http;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestProtocolVersion {
@@ -38,11 +38,11 @@ public class TestProtocolVersion {
@Test
public void testEqualsMajorMinor() {
- Assert.assertTrue(PROTOCOL_VERSION_0_0.equals(0, 0));
- Assert.assertTrue(PROTOCOL_VERSION_1_0.equals(1, 0));
- Assert.assertTrue(PROTOCOL_VERSION_1_2.equals(1, 2));
+ Assertions.assertTrue(PROTOCOL_VERSION_0_0.equals(0, 0));
+ Assertions.assertTrue(PROTOCOL_VERSION_1_0.equals(1, 0));
+ Assertions.assertTrue(PROTOCOL_VERSION_1_2.equals(1, 2));
//
- Assert.assertFalse(PROTOCOL_VERSION_1_2.equals(2, 0));
+ Assertions.assertFalse(PROTOCOL_VERSION_1_2.equals(2, 0));
}
}
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 67c2ad1..68683b6 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
@@ -27,9 +27,10 @@
package org.apache.hc.core5.http.config;
+import static org.hamcrest.MatcherAssert.assertThat;
+
import org.hamcrest.CoreMatchers;
-import org.hamcrest.MatcherAssert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Tests for {@link NamedElementChain}.
@@ -39,59 +40,59 @@ public class TestNamedElementChain {
@Test
public void testBasics() {
final NamedElementChain<Character> list = new NamedElementChain<>();
- MatcherAssert.assertThat(list.getFirst(), CoreMatchers.nullValue());
- MatcherAssert.assertThat(list.getLast(), CoreMatchers.nullValue());
+ assertThat(list.getFirst(), CoreMatchers.nullValue());
+ assertThat(list.getLast(), CoreMatchers.nullValue());
final NamedElementChain<Character>.Node nodeA = list.addFirst('a', "a");
- MatcherAssert.assertThat(list.getFirst(), CoreMatchers.sameInstance(nodeA));
- MatcherAssert.assertThat(list.getLast(), CoreMatchers.sameInstance(nodeA));
+ assertThat(list.getFirst(), CoreMatchers.sameInstance(nodeA));
+ assertThat(list.getLast(), CoreMatchers.sameInstance(nodeA));
final NamedElementChain<Character>.Node nodeB = list.addLast('b', "b");
- MatcherAssert.assertThat(list.getFirst(), CoreMatchers.sameInstance(nodeA));
- MatcherAssert.assertThat(list.getLast(), CoreMatchers.sameInstance(nodeB));
+ assertThat(list.getFirst(), CoreMatchers.sameInstance(nodeA));
+ assertThat(list.getLast(), CoreMatchers.sameInstance(nodeB));
final NamedElementChain<Character>.Node nodeZ = list.addLast('z', "z");
- MatcherAssert.assertThat(list.getFirst(), CoreMatchers.sameInstance(nodeA));
- MatcherAssert.assertThat(list.getLast(), CoreMatchers.sameInstance(nodeZ));
+ assertThat(list.getFirst(), CoreMatchers.sameInstance(nodeA));
+ assertThat(list.getLast(), CoreMatchers.sameInstance(nodeZ));
- 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());
+ assertThat(nodeA.getPrevious(), CoreMatchers.nullValue());
+ assertThat(nodeA.getNext(), CoreMatchers.sameInstance(nodeB));
+ assertThat(nodeB.getPrevious(), CoreMatchers.sameInstance(nodeA));
+ assertThat(nodeB.getNext(), CoreMatchers.sameInstance(nodeZ));
+ assertThat(nodeZ.getPrevious(), CoreMatchers.sameInstance(nodeB));
+ assertThat(nodeZ.getNext(), CoreMatchers.nullValue());
final NamedElementChain<Character>.Node nodeD = list.addAfter("b", 'd', "d");
- 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));
+ assertThat(nodeD.getPrevious(), CoreMatchers.sameInstance(nodeB));
+ assertThat(nodeD.getNext(), CoreMatchers.sameInstance(nodeZ));
+ assertThat(nodeB.getNext(), CoreMatchers.sameInstance(nodeD));
+ assertThat(nodeZ.getPrevious(), CoreMatchers.sameInstance(nodeD));
final NamedElementChain<Character>.Node nodeC = list.addBefore("d", 'c', "c");
- 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));
+ assertThat(nodeC.getPrevious(), CoreMatchers.sameInstance(nodeB));
+ assertThat(nodeC.getNext(), CoreMatchers.sameInstance(nodeD));
+ assertThat(nodeB.getNext(), CoreMatchers.sameInstance(nodeC));
+ assertThat(nodeD.getPrevious(), CoreMatchers.sameInstance(nodeC));
+ assertThat(list.getSize(), CoreMatchers.equalTo(5));
+
+ assertThat(list.remove("a"), CoreMatchers.is(true));
+ assertThat(list.remove("z"), CoreMatchers.is(true));
+ assertThat(list.remove("c"), CoreMatchers.is(true));
+ assertThat(list.remove("c"), CoreMatchers.is(false));
+ assertThat(list.remove("blah"), CoreMatchers.is(false));
+
+ assertThat(list.getFirst(), CoreMatchers.sameInstance(nodeB));
+ assertThat(list.getLast(), CoreMatchers.sameInstance(nodeD));
+
+ assertThat(list.getSize(), CoreMatchers.equalTo(2));
+ assertThat(list.addBefore("blah", 'e', "e"), CoreMatchers.nullValue());
+ assertThat(list.getSize(), CoreMatchers.equalTo(2));
+
+ assertThat(list.addAfter("yada", 'e', "e"), CoreMatchers.nullValue());
+ assertThat(list.getSize(), CoreMatchers.equalTo(2));
}
}
\ No newline at end of file
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/config/TestRegistry.java b/httpcore5/src/test/java/org/apache/hc/core5/http/config/TestRegistry.java
index ed3d3e3..84a7a41 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/config/TestRegistry.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/config/TestRegistry.java
@@ -26,18 +26,18 @@
*/
package org.apache.hc.core5.http.config;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestRegistry {
@Test
public void testCompleted() throws Exception {
final Registry<String> reg = RegistryBuilder.<String>create().register("Stuff", "Stuff").build();
- Assert.assertEquals("Stuff", reg.lookup("Stuff"));
- Assert.assertEquals("Stuff", reg.lookup("stuff"));
- Assert.assertNull(reg.lookup("miss"));
- Assert.assertNull(reg.lookup(null));
+ Assertions.assertEquals("Stuff", reg.lookup("Stuff"));
+ Assertions.assertEquals("Stuff", reg.lookup("stuff"));
+ Assertions.assertNull(reg.lookup("miss"));
+ Assertions.assertNull(reg.lookup(null));
}
}
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/TestDefaultConnectionReuseStrategy.java b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/TestDefaultConnectionReuseStrategy.java
index 6ec240a..fd5f375 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/TestDefaultConnectionReuseStrategy.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/TestDefaultConnectionReuseStrategy.java
@@ -37,9 +37,9 @@ import org.apache.hc.core5.http.message.BasicHttpRequest;
import org.apache.hc.core5.http.message.BasicHttpResponse;
import org.apache.hc.core5.http.protocol.BasicHttpContext;
import org.apache.hc.core5.http.protocol.HttpContext;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
public class TestDefaultConnectionReuseStrategy {
@@ -49,7 +49,7 @@ public class TestDefaultConnectionReuseStrategy {
/** The reuse strategy to be tested. */
private ConnectionReuseStrategy reuseStrategy;
- @Before
+ @BeforeEach
public void setUp() {
reuseStrategy = DefaultConnectionReuseStrategy.INSTANCE;
context = new BasicHttpContext(null);
@@ -57,7 +57,7 @@ public class TestDefaultConnectionReuseStrategy {
@Test
public void testInvalidResponseArg() throws Exception {
- Assert.assertThrows(NullPointerException.class, () ->
+ Assertions.assertThrows(NullPointerException.class, () ->
reuseStrategy.keepAlive(null, null, this.context));
}
@@ -65,20 +65,20 @@ public class TestDefaultConnectionReuseStrategy {
public void testNoContentLengthResponseHttp1_0() throws Exception {
context.setProtocolVersion(HttpVersion.HTTP_1_0);
final HttpResponse response = new BasicHttpResponse(200, "OK");
- Assert.assertFalse(reuseStrategy.keepAlive(null, response, context));
+ Assertions.assertFalse(reuseStrategy.keepAlive(null, response, context));
}
@Test
public void testNoContentLengthResponseHttp1_1() throws Exception {
final HttpResponse response = new BasicHttpResponse(200, "OK");
- Assert.assertFalse(reuseStrategy.keepAlive(null, response, context));
+ Assertions.assertFalse(reuseStrategy.keepAlive(null, response, context));
}
@Test
public void testChunkedContent() throws Exception {
final HttpResponse response = new BasicHttpResponse(200, "OK");
response.addHeader("Transfer-Encoding", "chunked");
- Assert.assertTrue(reuseStrategy.keepAlive(null, response, context));
+ Assertions.assertTrue(reuseStrategy.keepAlive(null, response, context));
}
@Test
@@ -86,7 +86,7 @@ public class TestDefaultConnectionReuseStrategy {
context.setProtocolVersion(HttpVersion.HTTP_1_0);
final HttpResponse response = new BasicHttpResponse(200, "OK");
response.addHeader("Connection", "keep-alive");
- Assert.assertFalse(reuseStrategy.keepAlive(null, response, context));
+ Assertions.assertFalse(reuseStrategy.keepAlive(null, response, context));
}
@Test
@@ -95,7 +95,7 @@ public class TestDefaultConnectionReuseStrategy {
final HttpResponse response = new BasicHttpResponse(200, "OK");
response.addHeader("Transfer-Encoding", "chunked");
response.addHeader("Connection", "close");
- Assert.assertFalse(reuseStrategy.keepAlive(null, response, context));
+ Assertions.assertFalse(reuseStrategy.keepAlive(null, response, context));
}
@Test
@@ -106,7 +106,7 @@ public class TestDefaultConnectionReuseStrategy {
response.addHeader("Content-Length", "10");
response.addHeader("Connection", "keep-alive");
- Assert.assertTrue(reuseStrategy.keepAlive(null, response, context));
+ Assertions.assertTrue(reuseStrategy.keepAlive(null, response, context));
}
@Test
@@ -114,14 +114,14 @@ public class TestDefaultConnectionReuseStrategy {
context.setProtocolVersion(HttpVersion.HTTP_1_0);
final HttpResponse response = new BasicHttpResponse(200, "OK");
response.addHeader("Content-Length", "10");
- Assert.assertFalse(reuseStrategy.keepAlive(null, response, context));
+ Assertions.assertFalse(reuseStrategy.keepAlive(null, response, context));
}
@Test
public void testHTTP11Default() throws Exception {
final HttpResponse response = new BasicHttpResponse(200, "OK");
response.addHeader("Content-Length", "10");
- Assert.assertTrue(reuseStrategy.keepAlive(null, response, context));
+ Assertions.assertTrue(reuseStrategy.keepAlive(null, response, context));
}
@Test
@@ -131,7 +131,7 @@ public class TestDefaultConnectionReuseStrategy {
final HttpResponse response = new BasicHttpResponse(200, "OK");
response.addHeader("Content-Length", "10");
response.addHeader("Connection", "keep--alive");
- Assert.assertFalse(reuseStrategy.keepAlive(null, response, context));
+ Assertions.assertFalse(reuseStrategy.keepAlive(null, response, context));
}
@Test
@@ -141,7 +141,7 @@ public class TestDefaultConnectionReuseStrategy {
final HttpResponse response = new BasicHttpResponse(200, "OK");
response.addHeader("Content-Length", "10");
response.addHeader("Connection", null);
- Assert.assertFalse(reuseStrategy.keepAlive(null, response, context));
+ Assertions.assertFalse(reuseStrategy.keepAlive(null, response, context));
}
@Test
@@ -150,7 +150,7 @@ public class TestDefaultConnectionReuseStrategy {
final HttpResponse response = new BasicHttpResponse(200, "OK");
response.addHeader("Transfer-Encoding", "chunked");
response.addHeader("Connection", "yadda, cLOSe, dumdy");
- Assert.assertFalse(reuseStrategy.keepAlive(null, response, context));
+ Assertions.assertFalse(reuseStrategy.keepAlive(null, response, context));
}
@Test
@@ -159,7 +159,7 @@ public class TestDefaultConnectionReuseStrategy {
final HttpResponse response = new BasicHttpResponse(200, "OK");
response.addHeader("Transfer-Encoding", "chunked");
response.addHeader("Connection", "yadda, kEEP-alive, dumdy");
- Assert.assertTrue(reuseStrategy.keepAlive(null, response, context));
+ Assertions.assertTrue(reuseStrategy.keepAlive(null, response, context));
}
@Test
@@ -168,7 +168,7 @@ public class TestDefaultConnectionReuseStrategy {
final HttpResponse response = new BasicHttpResponse(200, "OK");
response.addHeader("Transfer-Encoding", "chunked");
response.addHeader("Connection", "yadda, keep-alive, close, dumdy");
- Assert.assertFalse(reuseStrategy.keepAlive(null, response, context));
+ Assertions.assertFalse(reuseStrategy.keepAlive(null, response, context));
}
@Test
@@ -179,7 +179,7 @@ public class TestDefaultConnectionReuseStrategy {
response.addHeader("Connection", "yadda, close, dumdy");
response.addHeader("Proxy-Connection", "keep-alive");
// Connection takes precedence over Proxy-Connection
- Assert.assertFalse(reuseStrategy.keepAlive(null, response, context));
+ Assertions.assertFalse(reuseStrategy.keepAlive(null, response, context));
}
@Test
@@ -192,7 +192,7 @@ public class TestDefaultConnectionReuseStrategy {
// Connection takes precedence over Proxy-Connection,
// even if it doesn't contain a recognized token.
// Default for HTTP/1.1 is to keep alive.
- Assert.assertTrue(reuseStrategy.keepAlive(null, response, context));
+ Assertions.assertTrue(reuseStrategy.keepAlive(null, response, context));
}
@Test
@@ -204,7 +204,7 @@ public class TestDefaultConnectionReuseStrategy {
response.addHeader("Proxy-Connection", "close");
// Connection takes precedence over Proxy-Connection,
// even if it is empty. Default for HTTP/1.1 is to keep alive.
- Assert.assertTrue(reuseStrategy.keepAlive(null, response, context));
+ Assertions.assertTrue(reuseStrategy.keepAlive(null, response, context));
}
@Test
@@ -213,14 +213,14 @@ public class TestDefaultConnectionReuseStrategy {
final HttpResponse response = new BasicHttpResponse(200, "OK");
response.addHeader("Content-Length", "10");
response.addHeader("Content-Length", "11");
- Assert.assertFalse(reuseStrategy.keepAlive(null, response, context));
+ Assertions.assertFalse(reuseStrategy.keepAlive(null, response, context));
}
@Test
public void testNoContentResponse() throws Exception {
// Use HTTP 1.1
final HttpResponse response = new BasicHttpResponse(HttpStatus.SC_NO_CONTENT, "No Content");
- Assert.assertTrue(reuseStrategy.keepAlive(null, response, context));
+ Assertions.assertTrue(reuseStrategy.keepAlive(null, response, context));
}
@Test
@@ -228,7 +228,7 @@ public class TestDefaultConnectionReuseStrategy {
// Use HTTP 1.0
context.setProtocolVersion(HttpVersion.HTTP_1_0);
final HttpResponse response = new BasicHttpResponse(HttpStatus.SC_NO_CONTENT, "No Content");
- Assert.assertFalse(reuseStrategy.keepAlive(null, response, context));
+ Assertions.assertFalse(reuseStrategy.keepAlive(null, response, context));
}
@Test
@@ -239,7 +239,7 @@ public class TestDefaultConnectionReuseStrategy {
final HttpResponse response = new BasicHttpResponse(200, "OK");
response.addHeader("Transfer-Encoding", "chunked");
response.addHeader("Connection", "keep-alive");
- Assert.assertFalse(reuseStrategy.keepAlive(request, response, context));
+ Assertions.assertFalse(reuseStrategy.keepAlive(request, response, context));
}
@Test
@@ -250,7 +250,7 @@ public class TestDefaultConnectionReuseStrategy {
final HttpResponse response = new BasicHttpResponse(200, "OK");
response.addHeader("Transfer-Encoding", "chunked");
response.addHeader("Connection", "keep-alive");
- Assert.assertTrue(reuseStrategy.keepAlive(request, response, context));
+ Assertions.assertTrue(reuseStrategy.keepAlive(request, response, context));
}
@Test
@@ -263,7 +263,7 @@ public class TestDefaultConnectionReuseStrategy {
final HttpResponse response = new BasicHttpResponse(200, "OK");
response.addHeader("Transfer-Encoding", "chunked");
response.addHeader("Connection", "keep-alive");
- Assert.assertFalse(reuseStrategy.keepAlive(request, response, context));
+ Assertions.assertFalse(reuseStrategy.keepAlive(request, response, context));
}
@Test
@@ -275,7 +275,7 @@ public class TestDefaultConnectionReuseStrategy {
response.addHeader("Content-Length", "10");
response.addHeader("Connection", "keep-alive");
- Assert.assertFalse(reuseStrategy.keepAlive(request, response, context));
+ Assertions.assertFalse(reuseStrategy.keepAlive(request, response, context));
}
@Test
@@ -283,7 +283,7 @@ public class TestDefaultConnectionReuseStrategy {
final HttpRequest request = new BasicHttpRequest(Method.HEAD, "/");
final HttpResponse response = new BasicHttpResponse(200, "OK");
- Assert.assertTrue(reuseStrategy.keepAlive(request, response, context));
+ Assertions.assertTrue(reuseStrategy.keepAlive(request, response, context));
}
@Test
@@ -291,7 +291,7 @@ public class TestDefaultConnectionReuseStrategy {
final HttpResponse response = new BasicHttpResponse(204, "OK");
response.addHeader("Content-Length", "10");
response.addHeader("Connection", "keep-alive");
- Assert.assertFalse(reuseStrategy.keepAlive(null, response, context));
+ Assertions.assertFalse(reuseStrategy.keepAlive(null, response, context));
}
@Test
@@ -299,7 +299,7 @@ public class TestDefaultConnectionReuseStrategy {
final HttpResponse response = new BasicHttpResponse(204, "OK");
response.addHeader("Content-Length", "0");
response.addHeader("Connection", "keep-alive");
- Assert.assertTrue(reuseStrategy.keepAlive(null, response, context));
+ Assertions.assertTrue(reuseStrategy.keepAlive(null, response, context));
}
@Test
@@ -307,7 +307,7 @@ public class TestDefaultConnectionReuseStrategy {
final HttpResponse response = new BasicHttpResponse(204, "OK");
response.addHeader("Transfer-Encoding", "chunked");
response.addHeader("Connection", "keep-alive");
- Assert.assertFalse(reuseStrategy.keepAlive(null, response, context));
+ Assertions.assertFalse(reuseStrategy.keepAlive(null, response, context));
}
}
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/TestDefaultContentLengthStrategy.java b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/TestDefaultContentLengthStrategy.java
index becda22..8f6df35 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/TestDefaultContentLengthStrategy.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/TestDefaultContentLengthStrategy.java
@@ -34,8 +34,8 @@ import org.apache.hc.core5.http.ProtocolException;
import org.apache.hc.core5.http.ProtocolVersion;
import org.apache.hc.core5.http.message.BasicHeader;
import org.apache.hc.core5.http.message.HeaderGroup;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestDefaultContentLengthStrategy {
@@ -70,7 +70,7 @@ public class TestDefaultContentLengthStrategy {
final HttpMessage message = new TestHttpMessage();
message.addHeader("Transfer-Encoding", "Chunked");
- Assert.assertEquals(ContentLengthStrategy.CHUNKED, lenStrategy.determineLength(message));
+ Assertions.assertEquals(ContentLengthStrategy.CHUNKED, lenStrategy.determineLength(message));
}
@Test
@@ -78,7 +78,7 @@ public class TestDefaultContentLengthStrategy {
final ContentLengthStrategy lenStrategy = new DefaultContentLengthStrategy();
final HttpMessage message = new TestHttpMessage();
message.addHeader("Transfer-Encoding", "Identity");
- Assert.assertThrows(NotImplementedException.class, () ->
+ Assertions.assertThrows(NotImplementedException.class, () ->
lenStrategy.determineLength(message));
}
@@ -87,7 +87,7 @@ public class TestDefaultContentLengthStrategy {
final ContentLengthStrategy lenStrategy = new DefaultContentLengthStrategy();
final HttpMessage message = new TestHttpMessage();
message.addHeader("Transfer-Encoding", "whatever");
- Assert.assertThrows(ProtocolException.class, () ->
+ Assertions.assertThrows(ProtocolException.class, () ->
lenStrategy.determineLength(message));
}
@@ -96,7 +96,7 @@ public class TestDefaultContentLengthStrategy {
final ContentLengthStrategy lenStrategy = new DefaultContentLengthStrategy();
final HttpMessage message = new TestHttpMessage();
message.addHeader("Content-Length", "100");
- Assert.assertEquals(100, lenStrategy.determineLength(message));
+ Assertions.assertEquals(100, lenStrategy.determineLength(message));
}
@Test
@@ -104,7 +104,7 @@ public class TestDefaultContentLengthStrategy {
final ContentLengthStrategy lenStrategy = new DefaultContentLengthStrategy();
final HttpMessage message = new TestHttpMessage();
message.addHeader("Content-Length", "whatever");
- Assert.assertThrows(ProtocolException.class, () ->
+ Assertions.assertThrows(ProtocolException.class, () ->
lenStrategy.determineLength(message));
}
@@ -113,7 +113,7 @@ public class TestDefaultContentLengthStrategy {
final ContentLengthStrategy lenStrategy = new DefaultContentLengthStrategy();
final HttpMessage message = new TestHttpMessage();
message.addHeader("Content-Length", "-10");
- Assert.assertThrows(ProtocolException.class, () ->
+ Assertions.assertThrows(ProtocolException.class, () ->
lenStrategy.determineLength(message));
}
@@ -121,7 +121,7 @@ public class TestDefaultContentLengthStrategy {
public void testEntityNoContentDelimiter() throws Exception {
final ContentLengthStrategy lenStrategy = new DefaultContentLengthStrategy();
final HttpMessage message = new TestHttpMessage();
- Assert.assertEquals(ContentLengthStrategy.UNDEFINED, lenStrategy.determineLength(message));
+ Assertions.assertEquals(ContentLengthStrategy.UNDEFINED, lenStrategy.determineLength(message));
}
}
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/TestEnglishReasonPhraseCatalog.java b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/TestEnglishReasonPhraseCatalog.java
index f2fbfb9..ae89fb1 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/TestEnglishReasonPhraseCatalog.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/TestEnglishReasonPhraseCatalog.java
@@ -31,8 +31,8 @@ import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import org.apache.hc.core5.http.HttpStatus;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
/**
*
@@ -45,9 +45,9 @@ public class TestEnglishReasonPhraseCatalog {
public void testReasonPhrases() throws IllegalAccessException {
final Field[] publicFields = HttpStatus.class.getFields();
- Assert.assertNotNull( publicFields );
+ Assertions.assertNotNull( publicFields );
- Assert.assertTrue( publicFields.length > 0 );
+ Assertions.assertTrue( publicFields.length > 0 );
for (final Field f : publicFields) {
final int modifiers = f.getModifiers();
@@ -60,8 +60,8 @@ public class TestEnglishReasonPhraseCatalog {
final int iValue = f.getInt(null);
final String text = EnglishReasonPhraseCatalog.
INSTANCE.getReason(iValue, null);
- Assert.assertNotNull("text is null for HttpStatus."+f.getName(), text);
- Assert.assertTrue(text.length() > 0);
+ Assertions.assertNotNull("text is null for HttpStatus."+f.getName(), text);
+ Assertions.assertTrue(text.length() > 0);
}
}
}
@@ -69,11 +69,11 @@ public class TestEnglishReasonPhraseCatalog {
@Test
public void testStatusInvalid() throws Exception {
- Assert.assertThrows(IllegalArgumentException.class, () ->
+ Assertions.assertThrows(IllegalArgumentException.class, () ->
EnglishReasonPhraseCatalog.INSTANCE.getReason(-1, null));
- Assert.assertThrows(IllegalArgumentException.class, () ->
+ Assertions.assertThrows(IllegalArgumentException.class, () ->
EnglishReasonPhraseCatalog.INSTANCE.getReason(99, null));
- Assert.assertThrows(IllegalArgumentException.class, () ->
+ Assertions.assertThrows(IllegalArgumentException.class, () ->
EnglishReasonPhraseCatalog.INSTANCE.getReason(600, null));
}
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestBHttpConnectionBase.java b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestBHttpConnectionBase.java
index 32032e6..1fc7fc1 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestBHttpConnectionBase.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestBHttpConnectionBase.java
@@ -42,16 +42,14 @@ import org.apache.hc.core5.http.config.Http1Config;
import org.apache.hc.core5.http.message.BasicClassicHttpResponse;
import org.apache.hc.core5.io.CloseMode;
import org.apache.hc.core5.util.Timeout;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.ArgumentMatchers;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.MockitoAnnotations;
-@RunWith(MockitoJUnitRunner.class)
public class TestBHttpConnectionBase {
@Mock
@@ -59,17 +57,18 @@ public class TestBHttpConnectionBase {
private BHttpConnectionBase conn;
- @Before
+ @BeforeEach
public void prepareMocks() {
+ MockitoAnnotations.openMocks(this);
conn = new BHttpConnectionBase(Http1Config.DEFAULT, null, null);
}
@Test
public void testBasics() throws Exception {
- Assert.assertFalse(conn.isOpen());
- Assert.assertNull(conn.getLocalAddress());
- Assert.assertNull(conn.getRemoteAddress());
- Assert.assertEquals("[Not bound]", conn.toString());
+ Assertions.assertFalse(conn.isOpen());
+ Assertions.assertNull(conn.getLocalAddress());
+ Assertions.assertNull(conn.getRemoteAddress());
+ Assertions.assertEquals("[Not bound]", conn.toString());
}
@Test
@@ -84,12 +83,12 @@ public class TestBHttpConnectionBase {
Mockito.when(socket.getRemoteSocketAddress()).thenReturn(remoteSockAddress);
conn.bind(socket);
- Assert.assertEquals("127.0.0.1:8888<->10.0.0.2:80", conn.toString());
- Assert.assertTrue(conn.isOpen());
+ Assertions.assertEquals("127.0.0.1:8888<->10.0.0.2:80", conn.toString());
+ Assertions.assertTrue(conn.isOpen());
- Assert.assertEquals(new InetSocketAddress(
+ Assertions.assertEquals(new InetSocketAddress(
InetAddress.getByAddress(new byte[] {127, 0, 0, 1}), 8888), conn.getLocalAddress());
- Assert.assertEquals(new InetSocketAddress(
+ Assertions.assertEquals(new InetSocketAddress(
InetAddress.getByAddress(new byte[] {10, 0, 0, 2}), 80), conn.getRemoteAddress());
}
@@ -102,11 +101,11 @@ public class TestBHttpConnectionBase {
conn.ensureOpen();
conn.outbuffer.write(0, outStream);
- Assert.assertTrue(conn.isOpen());
+ Assertions.assertTrue(conn.isOpen());
conn.close();
- Assert.assertFalse(conn.isOpen());
+ Assertions.assertFalse(conn.isOpen());
Mockito.verify(outStream, Mockito.times(1)).write(
ArgumentMatchers.any(), ArgumentMatchers.anyInt(), ArgumentMatchers.anyInt());
@@ -126,11 +125,11 @@ public class TestBHttpConnectionBase {
conn.ensureOpen();
conn.outbuffer.write(0, outStream);
- Assert.assertTrue(conn.isOpen());
+ Assertions.assertTrue(conn.isOpen());
conn.close(CloseMode.GRACEFUL);
- Assert.assertFalse(conn.isOpen());
+ Assertions.assertFalse(conn.isOpen());
Mockito.verify(outStream, Mockito.never()).write(
ArgumentMatchers.any(), ArgumentMatchers.anyInt(), ArgumentMatchers.anyInt());
@@ -153,14 +152,14 @@ public class TestBHttpConnectionBase {
message.addHeader("Content-Type", "stuff");
message.addHeader("Content-Encoding", "chunked");
final HttpEntity entity = conn.createIncomingEntity(message, conn.inBuffer, inStream, 10);
- Assert.assertNotNull(entity);
- Assert.assertFalse(entity.isChunked());
- Assert.assertEquals(10, entity.getContentLength());
- Assert.assertEquals("stuff", entity.getContentType());
- Assert.assertEquals("chunked", entity.getContentEncoding());
+ Assertions.assertNotNull(entity);
+ Assertions.assertFalse(entity.isChunked());
+ Assertions.assertEquals(10, entity.getContentLength());
+ Assertions.assertEquals("stuff", entity.getContentType());
+ Assertions.assertEquals("chunked", entity.getContentEncoding());
final InputStream content = entity.getContent();
- Assert.assertNotNull(content);
- Assert.assertTrue((content instanceof ContentLengthInputStream));
+ Assertions.assertNotNull(content);
+ Assertions.assertTrue((content instanceof ContentLengthInputStream));
}
@Test
@@ -168,12 +167,12 @@ public class TestBHttpConnectionBase {
final InputStream inStream = Mockito.mock(InputStream.class);
final ClassicHttpResponse message = new BasicClassicHttpResponse(200, "OK");
final HttpEntity entity = conn.createIncomingEntity(message, conn.inBuffer, inStream, ContentLengthStrategy.CHUNKED);
- Assert.assertNotNull(entity);
- Assert.assertTrue(entity.isChunked());
- Assert.assertEquals(-1, entity.getContentLength());
+ Assertions.assertNotNull(entity);
+ Assertions.assertTrue(entity.isChunked());
+ Assertions.assertEquals(-1, entity.getContentLength());
final InputStream content = entity.getContent();
- Assert.assertNotNull(content);
- Assert.assertTrue((content instanceof ChunkedInputStream));
+ Assertions.assertNotNull(content);
+ Assertions.assertTrue((content instanceof ChunkedInputStream));
}
@Test
@@ -181,12 +180,12 @@ public class TestBHttpConnectionBase {
final InputStream inStream = Mockito.mock(InputStream.class);
final ClassicHttpResponse message = new BasicClassicHttpResponse(200, "OK");
final HttpEntity entity = conn.createIncomingEntity(message, conn.inBuffer, inStream, ContentLengthStrategy.UNDEFINED);
- Assert.assertNotNull(entity);
- Assert.assertFalse(entity.isChunked());
- Assert.assertEquals(-1, entity.getContentLength());
+ Assertions.assertNotNull(entity);
+ Assertions.assertFalse(entity.isChunked());
+ Assertions.assertEquals(-1, entity.getContentLength());
final InputStream content = entity.getContent();
- Assert.assertNotNull(content);
- Assert.assertTrue((content instanceof IdentityInputStream));
+ Assertions.assertNotNull(content);
+ Assertions.assertTrue((content instanceof IdentityInputStream));
}
@Test
@@ -211,22 +210,22 @@ public class TestBHttpConnectionBase {
@Test
public void testGetSocketTimeout() throws Exception {
- Assert.assertEquals(Timeout.DISABLED, conn.getSocketTimeout());
+ Assertions.assertEquals(Timeout.DISABLED, conn.getSocketTimeout());
Mockito.when(socket.getSoTimeout()).thenReturn(345);
conn.bind(socket);
- Assert.assertEquals(Timeout.ofMilliseconds(345), conn.getSocketTimeout());
+ Assertions.assertEquals(Timeout.ofMilliseconds(345), conn.getSocketTimeout());
}
@Test
public void testGetSocketTimeoutException() throws Exception {
- Assert.assertEquals(Timeout.DISABLED, conn.getSocketTimeout());
+ Assertions.assertEquals(Timeout.DISABLED, conn.getSocketTimeout());
Mockito.when(socket.getSoTimeout()).thenThrow(new SocketException());
conn.bind(socket);
- Assert.assertEquals(Timeout.DISABLED, conn.getSocketTimeout());
+ Assertions.assertEquals(Timeout.DISABLED, conn.getSocketTimeout());
}
@Test
@@ -237,7 +236,7 @@ public class TestBHttpConnectionBase {
conn.ensureOpen();
conn.inBuffer.read(inStream);
- Assert.assertTrue(conn.awaitInput(Timeout.ofMilliseconds(432)));
+ Assertions.assertTrue(conn.awaitInput(Timeout.ofMilliseconds(432)));
Mockito.verify(socket, Mockito.never()).setSoTimeout(ArgumentMatchers.anyInt());
}
@@ -252,7 +251,7 @@ public class TestBHttpConnectionBase {
conn.bind(socket);
conn.ensureOpen();
- Assert.assertTrue(conn.awaitInput(Timeout.ofMilliseconds(432)));
+ Assertions.assertTrue(conn.awaitInput(Timeout.ofMilliseconds(432)));
Mockito.verify(socket, Mockito.times(1)).setSoTimeout(432);
Mockito.verify(socket, Mockito.times(1)).setSoTimeout(345);
@@ -268,7 +267,7 @@ public class TestBHttpConnectionBase {
conn.bind(socket);
conn.ensureOpen();
- Assert.assertFalse(conn.awaitInput(Timeout.ofMilliseconds(432)));
+ Assertions.assertFalse(conn.awaitInput(Timeout.ofMilliseconds(432)));
}
@Test
@@ -280,7 +279,7 @@ public class TestBHttpConnectionBase {
conn.bind(socket);
conn.ensureOpen();
conn.close();
- Assert.assertTrue(conn.isStale());
+ Assertions.assertTrue(conn.isStale());
}
@Test
@@ -292,7 +291,7 @@ public class TestBHttpConnectionBase {
conn.bind(socket);
conn.ensureOpen();
- Assert.assertFalse(conn.isStale());
+ Assertions.assertFalse(conn.isStale());
}
@Test
@@ -305,7 +304,7 @@ public class TestBHttpConnectionBase {
conn.bind(socket);
conn.ensureOpen();
- Assert.assertTrue(conn.isStale());
+ Assertions.assertTrue(conn.isStale());
}
@Test
@@ -318,7 +317,7 @@ public class TestBHttpConnectionBase {
conn.bind(socket);
conn.ensureOpen();
- Assert.assertFalse(conn.isStale());
+ Assertions.assertFalse(conn.isStale());
}
@Test
@@ -331,7 +330,7 @@ public class TestBHttpConnectionBase {
conn.bind(socket);
conn.ensureOpen();
- Assert.assertTrue(conn.isStale());
+ Assertions.assertTrue(conn.isStale());
}
}
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestChunkCoding.java b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestChunkCoding.java
index f89ef4d..ee152fc 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestChunkCoding.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestChunkCoding.java
@@ -42,8 +42,8 @@ import org.apache.hc.core5.http.StreamClosedException;
import org.apache.hc.core5.http.io.SessionInputBuffer;
import org.apache.hc.core5.http.io.SessionOutputBuffer;
import org.apache.hc.core5.http.message.BasicHeader;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestChunkCoding {
@@ -64,21 +64,21 @@ public class TestChunkCoding {
while ((len = in.read(buffer)) > 0) {
out.write(buffer, 0, len);
}
- Assert.assertEquals(-1, in.read(buffer));
- Assert.assertEquals(-1, in.read(buffer));
+ Assertions.assertEquals(-1, in.read(buffer));
+ Assertions.assertEquals(-1, in.read(buffer));
in.close();
final String result = new String(out.toByteArray(), StandardCharsets.ISO_8859_1);
- Assert.assertEquals(result, CHUNKED_RESULT);
+ Assertions.assertEquals(result, CHUNKED_RESULT);
final Header[] footers = in.getFooters();
- Assert.assertNotNull(footers);
- Assert.assertEquals(2, footers.length);
- Assert.assertEquals("Footer1", footers[0].getName());
- Assert.assertEquals("abcde", footers[0].getValue());
- Assert.assertEquals("Footer2", footers[1].getName());
- Assert.assertEquals("fghij", footers[1].getValue());
+ Assertions.assertNotNull(footers);
+ Assertions.assertEquals(2, footers.length);
+ Assertions.assertEquals("Footer1", footers[0].getName());
+ Assertions.assertEquals("abcde", footers[0].getValue());
+ Assertions.assertEquals("Footer2", footers[1].getName());
+ Assertions.assertEquals("fghij", footers[1].getValue());
}
//Test for when buffer is smaller than chunk size.
@@ -94,18 +94,18 @@ public class TestChunkCoding {
while ((len = in.read(buffer)) > 0) {
out.write(buffer, 0, len);
}
- Assert.assertEquals(-1, in.read(buffer));
- Assert.assertEquals(-1, in.read(buffer));
+ Assertions.assertEquals(-1, in.read(buffer));
+ Assertions.assertEquals(-1, in.read(buffer));
in.close();
final Header[] footers = in.getFooters();
- Assert.assertNotNull(footers);
- Assert.assertEquals(2, footers.length);
- Assert.assertEquals("Footer1", footers[0].getName());
- Assert.assertEquals("abcde", footers[0].getValue());
- Assert.assertEquals("Footer2", footers[1].getName());
- Assert.assertEquals("fghij", footers[1].getValue());
+ Assertions.assertNotNull(footers);
+ Assertions.assertEquals(2, footers.length);
+ Assertions.assertEquals("Footer1", footers[0].getName());
+ Assertions.assertEquals("abcde", footers[0].getValue());
+ Assertions.assertEquals("Footer2", footers[1].getName());
+ Assertions.assertEquals("fghij", footers[1].getValue());
}
// One byte read
@@ -118,11 +118,11 @@ public class TestChunkCoding {
int ch;
int i = '0';
while ((ch = in.read()) != -1) {
- Assert.assertEquals(i, ch);
+ Assertions.assertEquals(i, ch);
i++;
}
- Assert.assertEquals(-1, in.read());
- Assert.assertEquals(-1, in.read());
+ Assertions.assertEquals(-1, in.read());
+ Assertions.assertEquals(-1, in.read());
in.close();
}
@@ -133,9 +133,9 @@ public class TestChunkCoding {
final SessionInputBuffer inBuffer = new SessionInputBufferImpl(16);
final ByteArrayInputStream inputStream = new ByteArrayInputStream(s.getBytes(StandardCharsets.ISO_8859_1));
final ChunkedInputStream in = new ChunkedInputStream(inBuffer, inputStream);
- Assert.assertEquals(0, in.available());
+ Assertions.assertEquals(0, in.available());
in.read();
- Assert.assertEquals(4, in.available());
+ Assertions.assertEquals(4, in.available());
in.close();
}
@@ -147,10 +147,10 @@ public class TestChunkCoding {
final ChunkedInputStream in = new ChunkedInputStream(inBuffer, inputStream);
in.close();
in.close();
- Assert.assertThrows(StreamClosedException.class, () -> in.read());
+ Assertions.assertThrows(StreamClosedException.class, () -> in.read());
final byte[] tmp = new byte[10];
- Assert.assertThrows(StreamClosedException.class, () -> in.read(tmp));
- Assert.assertThrows(StreamClosedException.class, () -> in.read(tmp, 0, tmp.length));
+ Assertions.assertThrows(StreamClosedException.class, () -> in.read(tmp));
+ Assertions.assertThrows(StreamClosedException.class, () -> in.read(tmp, 0, tmp.length));
}
// Missing closing chunk
@@ -161,9 +161,9 @@ public class TestChunkCoding {
final ByteArrayInputStream inputStream = new ByteArrayInputStream(s.getBytes(StandardCharsets.ISO_8859_1));
final ChunkedInputStream in = new ChunkedInputStream(inBuffer, inputStream);
final byte[] tmp = new byte[5];
- Assert.assertEquals(5, in.read(tmp));
- Assert.assertThrows(ConnectionClosedException.class, () -> in.read());
- Assert.assertThrows(ConnectionClosedException.class, () -> in.close());
+ Assertions.assertEquals(5, in.read(tmp));
+ Assertions.assertThrows(ConnectionClosedException.class, () -> in.read());
+ Assertions.assertThrows(ConnectionClosedException.class, () -> in.close());
}
// Truncated stream (missing closing CRLF)
@@ -174,8 +174,8 @@ public class TestChunkCoding {
final ByteArrayInputStream inputStream = new ByteArrayInputStream(s.getBytes(StandardCharsets.ISO_8859_1));
final ChunkedInputStream in = new ChunkedInputStream(inBuffer, inputStream);
final byte[] tmp = new byte[5];
- Assert.assertEquals(5, in.read(tmp));
- Assert.assertThrows(MalformedChunkCodingException.class, () -> in.read());
+ Assertions.assertEquals(5, in.read(tmp));
+ Assertions.assertThrows(MalformedChunkCodingException.class, () -> in.read());
in.close();
}
@@ -188,7 +188,7 @@ public class TestChunkCoding {
final ChunkedInputStream in = new ChunkedInputStream(inBuffer, inputStream);
final byte[] buffer = new byte[300];
final ByteArrayOutputStream out = new ByteArrayOutputStream();
- Assert.assertThrows(MalformedChunkCodingException.class, () -> {
+ Assertions.assertThrows(MalformedChunkCodingException.class, () -> {
int len;
while ((len = in.read(buffer)) > 0) {
out.write(buffer, 0, len);
@@ -204,7 +204,7 @@ public class TestChunkCoding {
final SessionInputBuffer inBuffer = new SessionInputBufferImpl(16);
final ByteArrayInputStream inputStream = new ByteArrayInputStream(s.getBytes(StandardCharsets.ISO_8859_1));
final ChunkedInputStream in = new ChunkedInputStream(inBuffer, inputStream);
- Assert.assertThrows(MalformedChunkCodingException.class, in::read);
+ Assertions.assertThrows(MalformedChunkCodingException.class, in::read);
in.close();
}
@@ -215,7 +215,7 @@ public class TestChunkCoding {
final SessionInputBuffer inBuffer = new SessionInputBufferImpl(16);
final ByteArrayInputStream inputStream = new ByteArrayInputStream(s.getBytes(StandardCharsets.ISO_8859_1));
final ChunkedInputStream in = new ChunkedInputStream(inBuffer, inputStream);
- Assert.assertThrows(MalformedChunkCodingException.class, in::read);
+ Assertions.assertThrows(MalformedChunkCodingException.class, in::read);
in.close();
}
@@ -226,7 +226,7 @@ public class TestChunkCoding {
final SessionInputBuffer inBuffer = new SessionInputBufferImpl(16);
final ByteArrayInputStream inputStream = new ByteArrayInputStream(s.getBytes(StandardCharsets.ISO_8859_1));
final ChunkedInputStream in = new ChunkedInputStream(inBuffer, inputStream);
- Assert.assertThrows(MalformedChunkCodingException.class, in::read);
+ Assertions.assertThrows(MalformedChunkCodingException.class, in::read);
in.close();
}
@@ -238,8 +238,8 @@ public class TestChunkCoding {
final ByteArrayInputStream inputStream = new ByteArrayInputStream(s.getBytes(StandardCharsets.ISO_8859_1));
final ChunkedInputStream in = new ChunkedInputStream(inBuffer, inputStream);
final byte[] buffer = new byte[300];
- Assert.assertEquals(2, in.read(buffer));
- Assert.assertThrows(MalformedChunkCodingException.class, () -> in.read(buffer));
+ Assertions.assertEquals(2, in.read(buffer));
+ Assertions.assertThrows(MalformedChunkCodingException.class, () -> in.read(buffer));
in.close();
}
@@ -251,7 +251,7 @@ public class TestChunkCoding {
final ByteArrayInputStream inputStream = new ByteArrayInputStream(s.getBytes(StandardCharsets.ISO_8859_1));
final ChunkedInputStream in = new ChunkedInputStream(inBuffer, inputStream);
in.read();
- Assert.assertThrows(MalformedChunkCodingException.class, in::read);
+ Assertions.assertThrows(MalformedChunkCodingException.class, in::read);
in.close();
}
@@ -261,7 +261,7 @@ public class TestChunkCoding {
final SessionInputBuffer inBuffer = new SessionInputBufferImpl(16);
final ByteArrayInputStream inputStream = new ByteArrayInputStream(s.getBytes(StandardCharsets.ISO_8859_1));
final ChunkedInputStream in = new ChunkedInputStream(inBuffer, inputStream);
- Assert.assertThrows(MalformedChunkCodingException.class, in::read);
+ Assertions.assertThrows(MalformedChunkCodingException.class, in::read);
}
@Test
@@ -276,7 +276,7 @@ public class TestChunkCoding {
while ((len = in.read(buffer)) > 0) {
out.write(buffer, 0, len);
}
- Assert.assertEquals(0, out.size());
+ Assertions.assertEquals(0, out.size());
in.close();
}
@@ -287,13 +287,13 @@ public class TestChunkCoding {
final ByteArrayInputStream inputStream1 = new ByteArrayInputStream(s.getBytes(StandardCharsets.ISO_8859_1));
final ChunkedInputStream in1 = new ChunkedInputStream(inBuffer1, inputStream1);
final byte[] buffer = new byte[300];
- Assert.assertEquals(5, in1.read(buffer));
+ Assertions.assertEquals(5, in1.read(buffer));
in1.close();
final SessionInputBuffer inBuffer2 = new SessionInputBufferImpl(16, 10);
final ByteArrayInputStream inputStream2 = new ByteArrayInputStream(s.getBytes(StandardCharsets.ISO_8859_1));
final ChunkedInputStream in2 = new ChunkedInputStream(inBuffer2, inputStream2);
- Assert.assertThrows(MessageConstraintException.class, () -> in2.read(buffer));
+ Assertions.assertThrows(MessageConstraintException.class, () -> in2.read(buffer));
}
@Test
@@ -303,8 +303,8 @@ public class TestChunkCoding {
final ChunkedOutputStream out = new ChunkedOutputStream(outbuffer, outputStream, 2048);
out.close();
out.close();
- Assert.assertThrows(IOException.class, () -> out.write(new byte[] {1,2,3}));
- Assert.assertThrows(IOException.class, () -> out.write(1));
+ Assertions.assertThrows(IOException.class, () -> out.write(new byte[] {1,2,3}));
+ Assertions.assertThrows(IOException.class, () -> out.write(1));
}
@Test
@@ -329,7 +329,7 @@ public class TestChunkCoding {
}
final String output = new String(result.toByteArray(), StandardCharsets.ISO_8859_1);
- Assert.assertEquals(input, output);
+ Assertions.assertEquals(input, output);
in.close();
}
@@ -346,7 +346,7 @@ public class TestChunkCoding {
out.close();
final String content = new String(outputStream.toByteArray(), StandardCharsets.US_ASCII);
- Assert.assertEquals("1\r\nx\r\n0\r\nE: \r\nY: Z\r\n\r\n", content);
+ Assertions.assertEquals("1\r\nx\r\n0\r\nE: \r\nY: Z\r\n\r\n", content);
}
@Test
@@ -362,7 +362,7 @@ public class TestChunkCoding {
out.close();
final String content = new String(outputStream.toByteArray(), StandardCharsets.US_ASCII);
- Assert.assertEquals("2\r\n12\r\n2\r\n34\r\n0\r\n\r\n", content);
+ Assertions.assertEquals("2\r\n12\r\n2\r\n34\r\n0\r\n\r\n", content);
}
@Test
@@ -375,7 +375,7 @@ public class TestChunkCoding {
out.close();
final String content = new String(outputStream.toByteArray(), StandardCharsets.US_ASCII);
- Assert.assertEquals("4\r\n1234\r\n0\r\n\r\n", content);
+ Assertions.assertEquals("4\r\n1234\r\n0\r\n\r\n", content);
}
@Test
@@ -388,7 +388,7 @@ public class TestChunkCoding {
out.close();
final String content = new String(outputStream.toByteArray(), StandardCharsets.US_ASCII);
- Assert.assertEquals("1\r\n1\r\n0\r\n\r\n", content);
+ Assertions.assertEquals("1\r\n1\r\n0\r\n\r\n", content);
}
@Test
@@ -414,8 +414,8 @@ public class TestChunkCoding {
timeouts++;
}
}
- Assert.assertEquals(20, bytesRead);
- Assert.assertEquals(2, timeouts);
+ Assertions.assertEquals(20, bytesRead);
+ Assertions.assertEquals(2, timeouts);
in.close();
}
@@ -442,8 +442,8 @@ public class TestChunkCoding {
timeouts++;
}
}
- Assert.assertEquals(20, bytesRead);
- Assert.assertEquals(5, timeouts);
+ Assertions.assertEquals(20, bytesRead);
+ Assertions.assertEquals(5, timeouts);
in.close();
}
@@ -462,7 +462,7 @@ public class TestChunkCoding {
}
final String result = new String(out.toByteArray(), StandardCharsets.ISO_8859_1);
- Assert.assertEquals("01234567", result);
+ Assertions.assertEquals("01234567", result);
}
}
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestContentLengthInputStream.java b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestContentLengthInputStream.java
index a0be3d2..22e7134 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestContentLengthInputStream.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestContentLengthInputStream.java
@@ -36,8 +36,8 @@ import java.nio.charset.StandardCharsets;
import org.apache.hc.core5.http.ConnectionClosedException;
import org.apache.hc.core5.http.StreamClosedException;
import org.apache.hc.core5.http.io.SessionInputBuffer;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestContentLengthInputStream {
@@ -56,7 +56,7 @@ public class TestContentLengthInputStream {
outputStream.write(buffer, 0, len);
final String result = new String(outputStream.toByteArray(), StandardCharsets.ISO_8859_1);
- Assert.assertEquals(result, "1234567890");
+ Assertions.assertEquals(result, "1234567890");
in.close();
}
@@ -65,16 +65,16 @@ public class TestContentLengthInputStream {
final ByteArrayInputStream inputStream1 = new ByteArrayInputStream(new byte[20]);
final SessionInputBuffer inBuffer1 = new SessionInputBufferImpl(16);
final InputStream in1 = new ContentLengthInputStream(inBuffer1, inputStream1, 10L);
- Assert.assertEquals(10, in1.skip(10));
- Assert.assertEquals(-1, in1.read());
+ Assertions.assertEquals(10, in1.skip(10));
+ Assertions.assertEquals(-1, in1.read());
in1.close();
final ByteArrayInputStream inputStream2 = new ByteArrayInputStream(new byte[20]);
final SessionInputBuffer inBuffer2 = new SessionInputBufferImpl(16);
final InputStream in2 = new ContentLengthInputStream(inBuffer2, inputStream2, 10L);
in2.read();
- Assert.assertEquals(9, in2.skip(10));
- Assert.assertEquals(-1, in2.read());
+ Assertions.assertEquals(9, in2.skip(10));
+ Assertions.assertEquals(-1, in2.read());
in2.close();
final ByteArrayInputStream inputStream3 = new ByteArrayInputStream(new byte[20]);
@@ -82,16 +82,16 @@ public class TestContentLengthInputStream {
final InputStream in3 = new ContentLengthInputStream(inBuffer3, inputStream3, 2L);
in3.read();
in3.read();
- Assert.assertTrue(in3.skip(10) <= 0);
- Assert.assertEquals(0, in3.skip(-1));
- Assert.assertEquals(-1, in3.read());
+ Assertions.assertTrue(in3.skip(10) <= 0);
+ Assertions.assertEquals(0, in3.skip(-1));
+ Assertions.assertEquals(-1, in3.read());
in3.close();
final ByteArrayInputStream inputStream4 = new ByteArrayInputStream(new byte[20]);
final SessionInputBuffer inBuffer4 = new SessionInputBufferImpl(16);
final InputStream in4 = new ContentLengthInputStream(inBuffer4, inputStream4, 10L);
- Assert.assertEquals(5,in4.skip(5));
- Assert.assertEquals(5, in4.read(new byte[20]));
+ Assertions.assertEquals(5,in4.skip(5));
+ Assertions.assertEquals(5, in4.read(new byte[20]));
in4.close();
}
@@ -100,9 +100,9 @@ public class TestContentLengthInputStream {
final ByteArrayInputStream inputStream = new ByteArrayInputStream(new byte[] {1, 2, 3});
final SessionInputBuffer inBuffer = new SessionInputBufferImpl(16);
final InputStream in = new ContentLengthInputStream(inBuffer, inputStream, 3L);
- Assert.assertEquals(0, in.available());
+ Assertions.assertEquals(0, in.available());
in.read();
- Assert.assertEquals(2, in.available());
+ Assertions.assertEquals(2, in.available());
in.close();
}
@@ -114,11 +114,11 @@ public class TestContentLengthInputStream {
final InputStream in = new ContentLengthInputStream(inBuffer, inputStream, 16L);
in.close();
in.close();
- Assert.assertThrows(StreamClosedException.class, in::read);
+ Assertions.assertThrows(StreamClosedException.class, in::read);
final byte[] tmp = new byte[10];
- Assert.assertThrows(StreamClosedException.class, () -> in.read(tmp));
- Assert.assertThrows(StreamClosedException.class, () -> in.read(tmp, 0, tmp.length));
- Assert.assertEquals('-', inBuffer.read(inputStream));
+ Assertions.assertThrows(StreamClosedException.class, () -> in.read(tmp));
+ Assertions.assertThrows(StreamClosedException.class, () -> in.read(tmp, 0, tmp.length));
+ Assertions.assertEquals('-', inBuffer.read(inputStream));
}
@Test
@@ -129,10 +129,10 @@ public class TestContentLengthInputStream {
final InputStream in = new ContentLengthInputStream(inBuffer, inputStream, 32L);
final byte[] tmp = new byte[32];
final int byteRead = in.read(tmp);
- Assert.assertEquals(16, byteRead);
- Assert.assertThrows(ConnectionClosedException.class, () -> in.read(tmp));
- Assert.assertThrows(ConnectionClosedException.class, () -> in.read());
- Assert.assertThrows(ConnectionClosedException.class, () -> in.close());
+ Assertions.assertEquals(16, byteRead);
+ Assertions.assertThrows(ConnectionClosedException.class, () -> in.read(tmp));
+ Assertions.assertThrows(ConnectionClosedException.class, () -> in.read());
+ Assertions.assertThrows(ConnectionClosedException.class, () -> in.close());
}
}
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestContentLengthOutputStream.java b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestContentLengthOutputStream.java
index a381013..4afd82e 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestContentLengthOutputStream.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestContentLengthOutputStream.java
@@ -32,8 +32,8 @@ import java.io.OutputStream;
import org.apache.hc.core5.http.StreamClosedException;
import org.apache.hc.core5.http.io.SessionOutputBuffer;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestContentLengthOutputStream {
@@ -54,7 +54,7 @@ public class TestContentLengthOutputStream {
out.flush();
out.close();
final byte[] data = outputStream.toByteArray();
- Assert.assertEquals(15, data.length);
+ Assertions.assertEquals(15, data.length);
}
@Test
@@ -65,8 +65,8 @@ public class TestContentLengthOutputStream {
out.close();
out.close();
final byte[] tmp = new byte[10];
- Assert.assertThrows(StreamClosedException.class, () -> out.write(tmp));
- Assert.assertThrows(StreamClosedException.class, () -> out.write(1));
+ Assertions.assertThrows(StreamClosedException.class, () -> out.write(tmp));
+ Assertions.assertThrows(StreamClosedException.class, () -> out.write(1));
}
}
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestDefaultBHttpClientConnection.java b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestDefaultBHttpClientConnection.java
index 15a61a6..12e3a23 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestDefaultBHttpClientConnection.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestDefaultBHttpClientConnection.java
@@ -44,15 +44,13 @@ import org.apache.hc.core5.http.impl.DefaultContentLengthStrategy;
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.BasicClassicHttpRequest;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.MockitoAnnotations;
-@RunWith(MockitoJUnitRunner.class)
public class TestDefaultBHttpClientConnection {
@Mock
@@ -60,8 +58,9 @@ public class TestDefaultBHttpClientConnection {
private DefaultBHttpClientConnection conn;
- @Before
+ @BeforeEach
public void prepareMocks() {
+ MockitoAnnotations.openMocks(this);
conn = new DefaultBHttpClientConnection(Http1Config.DEFAULT,
null, null,
DefaultContentLengthStrategy.INSTANCE,
@@ -72,8 +71,8 @@ public class TestDefaultBHttpClientConnection {
@Test
public void testBasics() throws Exception {
- Assert.assertFalse(conn.isOpen());
- Assert.assertEquals("[Not bound]", conn.toString());
+ Assertions.assertFalse(conn.isOpen());
+ Assertions.assertEquals("[Not bound]", conn.toString());
}
@Test
@@ -84,13 +83,13 @@ public class TestDefaultBHttpClientConnection {
conn.bind(socket);
- Assert.assertEquals(0, conn.getEndpointDetails().getResponseCount());
+ Assertions.assertEquals(0, conn.getEndpointDetails().getResponseCount());
final ClassicHttpResponse response = conn.receiveResponseHeader();
- Assert.assertNotNull(response);
- Assert.assertEquals(200, response.getCode());
- Assert.assertTrue(response.containsHeader("User-Agent"));
- Assert.assertEquals(1, conn.getEndpointDetails().getResponseCount());
+ Assertions.assertNotNull(response);
+ Assertions.assertEquals(200, response.getCode());
+ Assertions.assertTrue(response.containsHeader("User-Agent"));
+ Assertions.assertEquals(1, conn.getEndpointDetails().getResponseCount());
}
@Test
@@ -101,28 +100,28 @@ public class TestDefaultBHttpClientConnection {
conn.bind(socket);
- Assert.assertEquals(0, conn.getEndpointDetails().getResponseCount());
+ Assertions.assertEquals(0, conn.getEndpointDetails().getResponseCount());
final ClassicHttpResponse response = conn.receiveResponseHeader();
- Assert.assertNotNull(response);
- Assert.assertEquals(200, response.getCode());
- Assert.assertTrue(response.containsHeader("Server"));
- Assert.assertEquals(1, conn.getEndpointDetails().getResponseCount());
+ Assertions.assertNotNull(response);
+ Assertions.assertEquals(200, response.getCode());
+ Assertions.assertTrue(response.containsHeader("Server"));
+ Assertions.assertEquals(1, conn.getEndpointDetails().getResponseCount());
conn.receiveResponseEntity(response);
final HttpEntity entity = response.getEntity();
- Assert.assertNotNull(entity);
- Assert.assertEquals(-1, entity.getContentLength());
- Assert.assertEquals(1, conn.getEndpointDetails().getResponseCount());
+ Assertions.assertNotNull(entity);
+ Assertions.assertEquals(-1, entity.getContentLength());
+ Assertions.assertEquals(1, conn.getEndpointDetails().getResponseCount());
final InputStream content = entity.getContent();
- Assert.assertNotNull(content);
- Assert.assertEquals(3, content.available());
- Assert.assertEquals('1', content.read());
- Assert.assertEquals('2', content.read());
- Assert.assertEquals('3', content.read());
+ Assertions.assertNotNull(content);
+ Assertions.assertEquals(3, content.available());
+ Assertions.assertEquals('1', content.read());
+ Assertions.assertEquals('2', content.read());
+ Assertions.assertEquals('3', content.read());
}
@Test
@@ -133,24 +132,24 @@ public class TestDefaultBHttpClientConnection {
conn.bind(socket);
- Assert.assertEquals(0, conn.getEndpointDetails().getResponseCount());
+ Assertions.assertEquals(0, conn.getEndpointDetails().getResponseCount());
final ClassicHttpResponse response = conn.receiveResponseHeader();
- Assert.assertNotNull(response);
- Assert.assertEquals(200, response.getCode());
- Assert.assertTrue(response.containsHeader("Server"));
- Assert.assertEquals(1, conn.getEndpointDetails().getResponseCount());
+ Assertions.assertNotNull(response);
+ Assertions.assertEquals(200, response.getCode());
+ Assertions.assertTrue(response.containsHeader("Server"));
+ Assertions.assertEquals(1, conn.getEndpointDetails().getResponseCount());
conn.receiveResponseEntity(response);
final HttpEntity entity = response.getEntity();
- Assert.assertNotNull(entity);
- Assert.assertEquals(3, entity.getContentLength());
- Assert.assertEquals(1, conn.getEndpointDetails().getResponseCount());
+ Assertions.assertNotNull(entity);
+ Assertions.assertEquals(3, entity.getContentLength());
+ Assertions.assertEquals(1, conn.getEndpointDetails().getResponseCount());
final InputStream content = entity.getContent();
- Assert.assertNotNull(content);
- Assert.assertTrue(content instanceof ContentLengthInputStream);
+ Assertions.assertNotNull(content);
+ Assertions.assertTrue(content instanceof ContentLengthInputStream);
}
@Test
@@ -162,25 +161,25 @@ public class TestDefaultBHttpClientConnection {
conn.bind(socket);
- Assert.assertEquals(0, conn.getEndpointDetails().getResponseCount());
+ Assertions.assertEquals(0, conn.getEndpointDetails().getResponseCount());
final ClassicHttpResponse response = conn.receiveResponseHeader();
- Assert.assertNotNull(response);
- Assert.assertEquals(200, response.getCode());
- Assert.assertTrue(response.containsHeader("Server"));
- Assert.assertEquals(1, conn.getEndpointDetails().getResponseCount());
+ Assertions.assertNotNull(response);
+ Assertions.assertEquals(200, response.getCode());
+ Assertions.assertTrue(response.containsHeader("Server"));
+ Assertions.assertEquals(1, conn.getEndpointDetails().getResponseCount());
conn.receiveResponseEntity(response);
final HttpEntity entity = response.getEntity();
- Assert.assertNotNull(entity);
- Assert.assertEquals(-1, entity.getContentLength());
- Assert.assertTrue(entity.isChunked());
- Assert.assertEquals(1, conn.getEndpointDetails().getResponseCount());
+ Assertions.assertNotNull(entity);
+ Assertions.assertEquals(-1, entity.getContentLength());
+ Assertions.assertTrue(entity.isChunked());
+ Assertions.assertEquals(1, conn.getEndpointDetails().getResponseCount());
final InputStream content = entity.getContent();
- Assert.assertNotNull(content);
- Assert.assertTrue(content instanceof ChunkedInputStream);
+ Assertions.assertNotNull(content);
+ Assertions.assertTrue(content instanceof ChunkedInputStream);
}
@Test
@@ -191,16 +190,16 @@ public class TestDefaultBHttpClientConnection {
conn.bind(socket);
- Assert.assertEquals(0, conn.getEndpointDetails().getResponseCount());
+ Assertions.assertEquals(0, conn.getEndpointDetails().getResponseCount());
final ClassicHttpResponse response = conn.receiveResponseHeader();
- Assert.assertNotNull(response);
- Assert.assertEquals(200, response.getCode());
- Assert.assertTrue(response.containsHeader("Server"));
- Assert.assertEquals(1, conn.getEndpointDetails().getResponseCount());
+ Assertions.assertNotNull(response);
+ Assertions.assertEquals(200, response.getCode());
+ Assertions.assertTrue(response.containsHeader("Server"));
+ Assertions.assertEquals(1, conn.getEndpointDetails().getResponseCount());
- Assert.assertThrows(NotImplementedException.class, () ->
+ Assertions.assertThrows(NotImplementedException.class, () ->
conn.receiveResponseEntity(response));
}
@@ -212,22 +211,22 @@ public class TestDefaultBHttpClientConnection {
conn.bind(socket);
- Assert.assertEquals(0, conn.getEndpointDetails().getResponseCount());
+ Assertions.assertEquals(0, conn.getEndpointDetails().getResponseCount());
final ClassicHttpResponse response = conn.receiveResponseHeader();
- Assert.assertNotNull(response);
- Assert.assertEquals(200, response.getCode());
- Assert.assertTrue(response.containsHeader("Server"));
- Assert.assertEquals(1, conn.getEndpointDetails().getResponseCount());
+ Assertions.assertNotNull(response);
+ Assertions.assertEquals(200, response.getCode());
+ Assertions.assertTrue(response.containsHeader("Server"));
+ Assertions.assertEquals(1, conn.getEndpointDetails().getResponseCount());
conn.receiveResponseEntity(response);
final HttpEntity entity = response.getEntity();
- Assert.assertNotNull(entity);
+ Assertions.assertNotNull(entity);
final InputStream content = entity.getContent();
- Assert.assertNotNull(content);
- Assert.assertTrue(content instanceof IdentityInputStream);
+ Assertions.assertNotNull(content);
+ Assertions.assertTrue(content instanceof IdentityInputStream);
}
@Test
@@ -237,7 +236,7 @@ public class TestDefaultBHttpClientConnection {
conn.bind(socket);
- Assert.assertEquals(0, conn.getEndpointDetails().getRequestCount());
+ Assertions.assertEquals(0, conn.getEndpointDetails().getRequestCount());
final ClassicHttpRequest request = new BasicClassicHttpRequest(Method.GET, "/stuff");
request.addHeader("User-Agent", "test");
@@ -245,9 +244,9 @@ public class TestDefaultBHttpClientConnection {
conn.sendRequestHeader(request);
conn.flush();
- Assert.assertEquals(1, conn.getEndpointDetails().getRequestCount());
+ Assertions.assertEquals(1, conn.getEndpointDetails().getRequestCount());
final String s = new String(outStream.toByteArray(), StandardCharsets.US_ASCII);
- Assert.assertEquals("GET /stuff HTTP/1.1\r\nUser-Agent: test\r\n\r\n", s);
+ Assertions.assertEquals("GET /stuff HTTP/1.1\r\nUser-Agent: test\r\n\r\n", s);
}
@Test
@@ -257,7 +256,7 @@ public class TestDefaultBHttpClientConnection {
conn.bind(socket);
- Assert.assertEquals(0, conn.getEndpointDetails().getRequestCount());
+ Assertions.assertEquals(0, conn.getEndpointDetails().getRequestCount());
final ClassicHttpRequest request = new BasicClassicHttpRequest(Method.POST, "/stuff");
request.addHeader("User-Agent", "test");
@@ -268,9 +267,9 @@ public class TestDefaultBHttpClientConnection {
conn.sendRequestEntity(request);
conn.flush();
- Assert.assertEquals(1, conn.getEndpointDetails().getRequestCount());
+ Assertions.assertEquals(1, conn.getEndpointDetails().getRequestCount());
final String s = new String(outStream.toByteArray(), StandardCharsets.US_ASCII);
- Assert.assertEquals("POST /stuff HTTP/1.1\r\nUser-Agent: test\r\nContent-Length: 3\r\n\r\n123", s);
+ Assertions.assertEquals("POST /stuff HTTP/1.1\r\nUser-Agent: test\r\nContent-Length: 3\r\n\r\n123", s);
}
@Test
@@ -280,7 +279,7 @@ public class TestDefaultBHttpClientConnection {
conn.bind(socket);
- Assert.assertEquals(0, conn.getEndpointDetails().getRequestCount());
+ Assertions.assertEquals(0, conn.getEndpointDetails().getRequestCount());
final ClassicHttpRequest request = new BasicClassicHttpRequest(Method.POST, "/stuff");
request.addHeader("User-Agent", "test");
@@ -291,9 +290,9 @@ public class TestDefaultBHttpClientConnection {
conn.sendRequestEntity(request);
conn.flush();
- Assert.assertEquals(1, conn.getEndpointDetails().getRequestCount());
+ Assertions.assertEquals(1, conn.getEndpointDetails().getRequestCount());
final String s = new String(outStream.toByteArray(), StandardCharsets.US_ASCII);
- Assert.assertEquals("POST /stuff HTTP/1.1\r\nUser-Agent: test\r\nTransfer-Encoding: " +
+ Assertions.assertEquals("POST /stuff HTTP/1.1\r\nUser-Agent: test\r\nTransfer-Encoding: " +
"chunked\r\n\r\n3\r\n123\r\n0\r\n\r\n", s);
}
@@ -304,14 +303,14 @@ public class TestDefaultBHttpClientConnection {
conn.bind(socket);
- Assert.assertEquals(0, conn.getEndpointDetails().getRequestCount());
+ Assertions.assertEquals(0, conn.getEndpointDetails().getRequestCount());
final ClassicHttpRequest request = new BasicClassicHttpRequest(Method.POST, "/stuff");
request.addHeader("User-Agent", "test");
request.setEntity(new StringEntity("123", ContentType.TEXT_PLAIN));
conn.sendRequestHeader(request);
- Assert.assertThrows(LengthRequiredException.class, () ->
+ Assertions.assertThrows(LengthRequiredException.class, () ->
conn.sendRequestEntity(request));
}
@@ -322,7 +321,7 @@ public class TestDefaultBHttpClientConnection {
conn.bind(socket);
- Assert.assertEquals(0, conn.getEndpointDetails().getRequestCount());
+ Assertions.assertEquals(0, conn.getEndpointDetails().getRequestCount());
final ClassicHttpRequest request = new BasicClassicHttpRequest(Method.POST, "/stuff");
request.addHeader("User-Agent", "test");
@@ -331,9 +330,9 @@ public class TestDefaultBHttpClientConnection {
conn.sendRequestEntity(request);
conn.flush();
- Assert.assertEquals(1, conn.getEndpointDetails().getRequestCount());
+ Assertions.assertEquals(1, conn.getEndpointDetails().getRequestCount());
final String s = new String(outStream.toByteArray(), StandardCharsets.US_ASCII);
- Assert.assertEquals("POST /stuff HTTP/1.1\r\nUser-Agent: test\r\n\r\n", s);
+ Assertions.assertEquals("POST /stuff HTTP/1.1\r\nUser-Agent: test\r\n\r\n", s);
}
@Test
@@ -343,7 +342,7 @@ public class TestDefaultBHttpClientConnection {
conn.bind(socket);
- Assert.assertEquals(0, conn.getEndpointDetails().getRequestCount());
+ Assertions.assertEquals(0, conn.getEndpointDetails().getRequestCount());
final ClassicHttpRequest request = new BasicClassicHttpRequest(Method.POST, "/stuff");
request.addHeader("User-Agent", "test");
@@ -356,11 +355,11 @@ public class TestDefaultBHttpClientConnection {
conn.terminateRequest(request);
conn.flush();
- Assert.assertEquals(1, conn.getEndpointDetails().getRequestCount());
+ Assertions.assertEquals(1, conn.getEndpointDetails().getRequestCount());
final String s = new String(outStream.toByteArray(), StandardCharsets.US_ASCII);
- Assert.assertEquals("POST /stuff HTTP/1.1\r\nUser-Agent: test\r\nTransfer-Encoding: " +
+ Assertions.assertEquals("POST /stuff HTTP/1.1\r\nUser-Agent: test\r\nTransfer-Encoding: " +
"chunked\r\n\r\n0\r\n\r\n", s);
- Assert.assertTrue(conn.isConsistent());
+ Assertions.assertTrue(conn.isConsistent());
}
@Test
@@ -370,7 +369,7 @@ public class TestDefaultBHttpClientConnection {
conn.bind(socket);
- Assert.assertEquals(0, conn.getEndpointDetails().getRequestCount());
+ Assertions.assertEquals(0, conn.getEndpointDetails().getRequestCount());
final ClassicHttpRequest request = new BasicClassicHttpRequest(Method.POST, "/stuff");
request.addHeader("User-Agent", "test");
@@ -382,11 +381,11 @@ public class TestDefaultBHttpClientConnection {
conn.terminateRequest(request);
conn.flush();
- Assert.assertEquals(1, conn.getEndpointDetails().getRequestCount());
+ Assertions.assertEquals(1, conn.getEndpointDetails().getRequestCount());
final String s = new String(outStream.toByteArray(), StandardCharsets.US_ASCII);
- Assert.assertEquals("POST /stuff HTTP/1.1\r\nUser-Agent: test\r\nContent-Length: " +
+ Assertions.assertEquals("POST /stuff HTTP/1.1\r\nUser-Agent: test\r\nContent-Length: " +
"3\r\n\r\n123", s);
- Assert.assertTrue(conn.isConsistent());
+ Assertions.assertTrue(conn.isConsistent());
}
@Test
@@ -396,7 +395,7 @@ public class TestDefaultBHttpClientConnection {
conn.bind(socket);
- Assert.assertEquals(0, conn.getEndpointDetails().getRequestCount());
+ Assertions.assertEquals(0, conn.getEndpointDetails().getRequestCount());
final ClassicHttpRequest request = new BasicClassicHttpRequest(Method.POST, "/stuff");
request.addHeader("User-Agent", "test");
@@ -408,11 +407,11 @@ public class TestDefaultBHttpClientConnection {
conn.terminateRequest(request);
conn.flush();
- Assert.assertEquals(1, conn.getEndpointDetails().getRequestCount());
+ Assertions.assertEquals(1, conn.getEndpointDetails().getRequestCount());
final String s = new String(outStream.toByteArray(), StandardCharsets.US_ASCII);
- Assert.assertEquals("POST /stuff HTTP/1.1\r\nUser-Agent: test\r\nContent-Length: " +
+ Assertions.assertEquals("POST /stuff HTTP/1.1\r\nUser-Agent: test\r\nContent-Length: " +
"3000\r\n\r\n", s);
- Assert.assertFalse(conn.isConsistent());
+ Assertions.assertFalse(conn.isConsistent());
}
}
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestDefaultBHttpServerConnection.java b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestDefaultBHttpServerConnection.java
index 8b4c1db..743098a 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestDefaultBHttpServerConnection.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestDefaultBHttpServerConnection.java
@@ -43,15 +43,13 @@ import org.apache.hc.core5.http.config.Http1Config;
import org.apache.hc.core5.http.impl.DefaultContentLengthStrategy;
import org.apache.hc.core5.http.io.entity.StringEntity;
import org.apache.hc.core5.http.message.BasicClassicHttpResponse;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.MockitoAnnotations;
-@RunWith(MockitoJUnitRunner.class)
public class TestDefaultBHttpServerConnection {
@Mock
@@ -59,8 +57,9 @@ public class TestDefaultBHttpServerConnection {
private DefaultBHttpServerConnection conn;
- @Before
+ @BeforeEach
public void prepareMocks() {
+ MockitoAnnotations.openMocks(this);
conn = new DefaultBHttpServerConnection("http", Http1Config.DEFAULT,
null, null,
DefaultContentLengthStrategy.INSTANCE,
@@ -71,8 +70,8 @@ public class TestDefaultBHttpServerConnection {
@Test
public void testBasics() throws Exception {
- Assert.assertFalse(conn.isOpen());
- Assert.assertEquals("[Not bound]", conn.toString());
+ Assertions.assertFalse(conn.isOpen());
+ Assertions.assertEquals("[Not bound]", conn.toString());
}
@Test
@@ -83,14 +82,14 @@ public class TestDefaultBHttpServerConnection {
conn.bind(socket);
- Assert.assertEquals(0, conn.getEndpointDetails().getRequestCount());
+ Assertions.assertEquals(0, conn.getEndpointDetails().getRequestCount());
final ClassicHttpRequest request = conn.receiveRequestHeader();
- Assert.assertNotNull(request);
- Assert.assertEquals("/", request.getPath());
- Assert.assertEquals(Method.GET.name(), request.getMethod());
- Assert.assertTrue(request.containsHeader("User-Agent"));
- Assert.assertEquals(1, conn.getEndpointDetails().getRequestCount());
+ Assertions.assertNotNull(request);
+ Assertions.assertEquals("/", request.getPath());
+ Assertions.assertEquals(Method.GET.name(), request.getMethod());
+ Assertions.assertTrue(request.containsHeader("User-Agent"));
+ Assertions.assertEquals(1, conn.getEndpointDetails().getRequestCount());
}
@Test
@@ -101,26 +100,26 @@ public class TestDefaultBHttpServerConnection {
conn.bind(socket);
- Assert.assertEquals(0, conn.getEndpointDetails().getRequestCount());
+ Assertions.assertEquals(0, conn.getEndpointDetails().getRequestCount());
final ClassicHttpRequest request = conn.receiveRequestHeader();
- Assert.assertNotNull(request);
- Assert.assertEquals("/", request.getPath());
- Assert.assertEquals(Method.POST.name(), request.getMethod());
- Assert.assertTrue(request.containsHeader("User-Agent"));
- Assert.assertNull(request.getEntity());
- Assert.assertEquals(1, conn.getEndpointDetails().getRequestCount());
+ Assertions.assertNotNull(request);
+ Assertions.assertEquals("/", request.getPath());
+ Assertions.assertEquals(Method.POST.name(), request.getMethod());
+ Assertions.assertTrue(request.containsHeader("User-Agent"));
+ Assertions.assertNull(request.getEntity());
+ Assertions.assertEquals(1, conn.getEndpointDetails().getRequestCount());
conn.receiveRequestEntity(request);
final HttpEntity entity = request.getEntity();
- Assert.assertNotNull(entity);
- Assert.assertEquals(3, entity.getContentLength());
- Assert.assertEquals(1, conn.getEndpointDetails().getRequestCount());
+ Assertions.assertNotNull(entity);
+ Assertions.assertEquals(3, entity.getContentLength());
+ Assertions.assertEquals(1, conn.getEndpointDetails().getRequestCount());
final InputStream content = entity.getContent();
- Assert.assertNotNull(content);
- Assert.assertTrue(content instanceof ContentLengthInputStream);
... 16717 lines suppressed ...