Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions httpcore5-h2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

package org.apache.hc.core5.http2.hpack;

import static org.hamcrest.MatcherAssert.assertThat;

import java.nio.ByteBuffer;
import java.nio.charset.Charset;
Expand All @@ -38,7 +37,6 @@
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.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -1073,10 +1071,10 @@ void testHeaderSizeLimit() throws Exception {
"123456789012345678901234567890123456789012345678901234567890")),
false);

assertThat(decoder.decodeHeaders(wrap(buf)).size(), CoreMatchers.equalTo(2));
Assertions.assertEquals(2, decoder.decodeHeaders(wrap(buf)).size());

decoder.setMaxListSize(1000000);
assertThat(decoder.decodeHeaders(wrap(buf)).size(), CoreMatchers.equalTo(2));
Assertions.assertEquals(2, decoder.decodeHeaders(wrap(buf)).size());

decoder.setMaxListSize(200);
Assertions.assertThrows(HeaderListConstraintException.class, () ->
Expand Down
5 changes: 0 additions & 5 deletions httpcore5-testing/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,6 @@
<artifactId>junit-platform-launcher</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,13 @@
*/
package org.apache.hc.core5.benchmark;

import static org.hamcrest.MatcherAssert.assertThat;

import org.junit.jupiter.api.Assertions;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.nio.charset.StandardCharsets;

import org.apache.hc.core5.http.HttpVersion;
import org.hamcrest.CoreMatchers;
import org.junit.jupiter.api.Test;

class ResultFormatterTest {
Expand All @@ -57,8 +56,7 @@ void testBasics() throws Exception {
50000000);
final ByteArrayOutputStream buf = new ByteArrayOutputStream();
ResultFormatter.print(new PrintStream(buf, true, StandardCharsets.US_ASCII.name()), results);
assertThat(new String(buf.toByteArray(), StandardCharsets.US_ASCII).replace("\r\n", "\n"),
CoreMatchers.equalTo(
Assertions.assertEquals(
"Server Software:\t\tTestServer/1.1\n" +
"Protocol version:\t\tHTTP/1.1\n" +
"Server Hostname:\t\tlocalhost\n" +
Expand All @@ -77,7 +75,7 @@ void testBasics() throws Exception {
"Time per request:\t\t0.850 [ms] (mean)\n" +
"Time per request:\t\t0.170 [ms] (mean, across all concurrent requests)\n" +
"Transfer rate:\t\t\t17,997.02 [Kbytes/sec] received\n"
));
, new String(buf.toByteArray(), StandardCharsets.US_ASCII).replace("\r\n", "\n"));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@

package org.apache.hc.core5.testing.classic;

import static org.hamcrest.MatcherAssert.assertThat;

import org.junit.jupiter.api.Assertions;
import java.nio.charset.StandardCharsets;
import java.util.Random;

Expand Down Expand Up @@ -61,7 +61,6 @@
import org.apache.hc.core5.testing.extension.classic.HttpRequesterResource;
import org.apache.hc.core5.testing.extension.classic.HttpServerResource;
import org.apache.hc.core5.util.Timeout;
import org.hamcrest.CoreMatchers;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

Expand Down Expand Up @@ -135,16 +134,16 @@ void testGetRequestAuthentication() throws Exception {
final HttpCoreContext context = HttpCoreContext.create();
final ClassicHttpRequest request1 = new BasicClassicHttpRequest(Method.GET, "/stuff");
try (final ClassicHttpResponse response1 = requester.execute(target, request1, TIMEOUT, context)) {
assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_UNAUTHORIZED));
Assertions.assertEquals(HttpStatus.SC_UNAUTHORIZED, response1.getCode());
final String body1 = EntityUtils.toString(response1.getEntity());
assertThat(body1, CoreMatchers.equalTo("You shall not pass!!!"));
Assertions.assertEquals("You shall not pass!!!", body1);
}
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)) {
assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
Assertions.assertEquals(HttpStatus.SC_OK, response2.getCode());
final String body1 = EntityUtils.toString(response2.getEntity());
assertThat(body1, CoreMatchers.equalTo(""));
Assertions.assertEquals("", body1);
}
}

Expand All @@ -163,17 +162,17 @@ void testPostRequestAuthentication() throws Exception {
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)) {
assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_UNAUTHORIZED));
Assertions.assertEquals(HttpStatus.SC_UNAUTHORIZED, response1.getCode());
final String body1 = EntityUtils.toString(response1.getEntity());
assertThat(body1, CoreMatchers.equalTo("You shall not pass!!!"));
Assertions.assertEquals("You shall not pass!!!", body1);
}
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)) {
assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
Assertions.assertEquals(HttpStatus.SC_OK, response2.getCode());
final String body1 = EntityUtils.toString(response2.getEntity());
assertThat(body1, CoreMatchers.equalTo(new String(stuff, StandardCharsets.US_ASCII)));
Assertions.assertEquals(new String(stuff, StandardCharsets.US_ASCII), body1);
}
}

Expand All @@ -193,18 +192,18 @@ void testPostRequestAuthenticationNoExpectContinue() throws Exception {
request1.setVersion(HttpVersion.HTTP_1_0);
request1.setEntity(new ByteArrayEntity(stuff, ContentType.TEXT_PLAIN));
try (final ClassicHttpResponse response1 = requester.execute(target, request1, TIMEOUT, context)) {
assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_UNAUTHORIZED));
Assertions.assertEquals(HttpStatus.SC_UNAUTHORIZED, response1.getCode());
final String body1 = EntityUtils.toString(response1.getEntity());
assertThat(body1, CoreMatchers.equalTo("You shall not pass!!!"));
Assertions.assertEquals("You shall not pass!!!", body1);
}
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)) {
assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
Assertions.assertEquals(HttpStatus.SC_OK, response2.getCode());
final String body1 = EntityUtils.toString(response2.getEntity());
assertThat(body1, CoreMatchers.equalTo(new String(stuff, StandardCharsets.US_ASCII)));
Assertions.assertEquals(new String(stuff, StandardCharsets.US_ASCII), body1);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

package org.apache.hc.core5.testing.classic;

import static org.hamcrest.MatcherAssert.assertThat;

import java.io.IOException;
import java.util.concurrent.CountDownLatch;
Expand All @@ -51,7 +50,6 @@
import org.apache.hc.core5.http.message.BasicClassicHttpRequest;
import org.apache.hc.core5.http.protocol.HttpCoreContext;
import org.apache.hc.core5.util.Timeout;
import org.hamcrest.CoreMatchers;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -79,23 +77,23 @@ void testSequentialRequests() throws Exception {
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)) {
assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
Assertions.assertEquals(HttpStatus.SC_OK, response1.getCode());
final String body1 = EntityUtils.toString(response1.getEntity());
assertThat(body1, CoreMatchers.equalTo("some stuff"));
Assertions.assertEquals("some stuff", body1);
}
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)) {
assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
Assertions.assertEquals(HttpStatus.SC_OK, response2.getCode());
final String body2 = EntityUtils.toString(response2.getEntity());
assertThat(body2, CoreMatchers.equalTo("some other stuff"));
Assertions.assertEquals("some other stuff", body2);
}
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)) {
assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
Assertions.assertEquals(HttpStatus.SC_OK, response3.getCode());
final String body3 = EntityUtils.toString(response3.getEntity());
assertThat(body3, CoreMatchers.equalTo("some more stuff"));
Assertions.assertEquals("some more stuff", body3);
}
}

Expand All @@ -109,23 +107,23 @@ void testSequentialRequestsNonPersistentConnection() throws Exception {
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)) {
assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
Assertions.assertEquals(HttpStatus.SC_OK, response1.getCode());
final String body1 = EntityUtils.toString(response1.getEntity());
assertThat(body1, CoreMatchers.equalTo("some stuff"));
Assertions.assertEquals("some stuff", body1);
}
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)) {
assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
Assertions.assertEquals(HttpStatus.SC_OK, response2.getCode());
final String body2 = EntityUtils.toString(response2.getEntity());
assertThat(body2, CoreMatchers.equalTo("some other stuff"));
Assertions.assertEquals("some other stuff", body2);
}
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)) {
assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
Assertions.assertEquals(HttpStatus.SC_OK, response3.getCode());
final String body3 = EntityUtils.toString(response3.getEntity());
assertThat(body3, CoreMatchers.equalTo("some more stuff"));
Assertions.assertEquals("some more stuff", body3);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@

package org.apache.hc.core5.testing.classic;

import static org.hamcrest.MatcherAssert.assertThat;

import org.junit.jupiter.api.Assertions;
import java.io.IOException;

import org.apache.hc.core5.http.ClassicHttpRequest;
Expand All @@ -53,7 +53,6 @@
import org.apache.hc.core5.testing.extension.classic.HttpRequesterResource;
import org.apache.hc.core5.testing.extension.classic.HttpServerResource;
import org.apache.hc.core5.util.Timeout;
import org.hamcrest.CoreMatchers;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

Expand Down Expand Up @@ -118,9 +117,9 @@ void testFilters() throws Exception {
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)) {
assertThat(response.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
Assertions.assertEquals(HttpStatus.SC_OK, response.getCode());
final Header testFilterHeader = response.getHeader("X-Test-Filter");
assertThat(testFilterHeader, CoreMatchers.notNullValue());
Assertions.assertNotNull(testFilterHeader);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

package org.apache.hc.core5.testing.classic;

import static org.hamcrest.MatcherAssert.assertThat;

import java.io.IOException;
import java.net.InetAddress;
Expand Down Expand Up @@ -59,7 +58,6 @@
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.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.AfterEachCallback;
Expand Down Expand Up @@ -138,16 +136,15 @@ void testTLSSuccess() throws Exception {
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)) {
assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
Assertions.assertEquals(HttpStatus.SC_OK, response1.getCode());
final String body1 = EntityUtils.toString(response1.getEntity());
assertThat(body1, CoreMatchers.equalTo("some stuff"));
Assertions.assertEquals("some stuff", body1);
}

final SSLSession sslSession = sslSessionRef.getAndSet(null);
final ProtocolVersion tlsVersion = TLS.parse(sslSession.getProtocol());
assertThat(tlsVersion.greaterEquals(TLS.V_1_2.getVersion()), CoreMatchers.equalTo(true));
assertThat(sslSession.getPeerPrincipal().getName(),
CoreMatchers.equalTo("CN=localhost,OU=Apache HttpComponents,O=Apache Software Foundation"));
Assertions.assertTrue(tlsVersion.greaterEquals(TLS.V_1_2.getVersion()));
Assertions.assertEquals("CN=localhost,OU=Apache HttpComponents,O=Apache Software Foundation", sslSession.getPeerPrincipal().getName());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

package org.apache.hc.core5.testing.compatibility.classic;

import static org.hamcrest.MatcherAssert.assertThat;

import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
Expand All @@ -51,7 +50,6 @@
import org.apache.hc.core5.testing.compatibility.TLSTestContexts;
import org.apache.hc.core5.testing.extension.classic.HttpRequesterResource;
import org.apache.hc.core5.util.Timeout;
import org.hamcrest.CoreMatchers;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
Expand Down Expand Up @@ -94,9 +92,9 @@ void test_sequential_requests() throws Exception {
.setHttpHost(target)
.build();
requester.execute(target, request, TIMEOUT, context, response -> {
assertThat(response.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
Assertions.assertEquals(HttpStatus.SC_OK, response.getCode());
final String body1 = EntityUtils.toString(response.getEntity());
assertThat(body1, CoreMatchers.equalTo(ContainerImages.AAA));
Assertions.assertEquals(ContainerImages.AAA, body1);
return null;
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@

package org.apache.hc.core5.testing.compatibility.classic;

import static org.hamcrest.MatcherAssert.assertThat;

import org.junit.jupiter.api.Assertions;
import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;
Expand All @@ -45,7 +45,6 @@
import org.apache.hc.core5.http.protocol.HttpCoreContext;
import org.apache.hc.core5.testing.extension.classic.HttpRequesterResource;
import org.apache.hc.core5.util.Timeout;
import org.hamcrest.CoreMatchers;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

Expand Down Expand Up @@ -112,7 +111,7 @@ void test_sequential_request_execution() throws Exception {
for (final ClassicHttpRequest request : requestMessages) {
final HttpCoreContext context = HttpCoreContext.create();
client.execute(target, request, TIMEOUT, context, response -> {
assertThat(response.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
Assertions.assertEquals(HttpStatus.SC_OK, response.getCode());
return null;
});
}
Expand Down
Loading
Loading