diff --git a/.github/workflows/mvn.yml b/.github/workflows/mvn.yml
index 5c61e1f8..8bc29536 100644
--- a/.github/workflows/mvn.yml
+++ b/.github/workflows/mvn.yml
@@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-20.04, windows-2022, macos-12]
- java: [11, 17]
+ java: [11, 17, 19, 21]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
diff --git a/pom.xml b/pom.xml
index 13a567ab..c9d1a495 100644
--- a/pom.xml
+++ b/pom.xml
@@ -50,7 +50,8 @@ OF THE POSSIBILITY OF SUCH DAMAGE.
scm:git:github.com:jcabi/jcabi-http.git
- scm:git:github.com:jcabi/jcabi-http.git
+ scm:git:github.com:jcabi/jcabi-http.git
+
https://github.com/jcabi/jcabi-http
@@ -59,6 +60,11 @@ OF THE POSSIBILITY OF SUCH DAMAGE.
https://http.jcabi.com/
+
+
+ 1.14.5
+
+
com.jcabi
@@ -85,24 +91,6 @@ OF THE POSSIBILITY OF SUCH DAMAGE.
lombok
1.18.30
-
- org.slf4j
- slf4j-log4j12
- 2.0.9
- test
-
-
- log4j
- log4j
- 1.2.17
- test
-
-
- javax.validation
- validation-api
- 2.0.1.Final
- test
-
org.apache.commons
commons-lang3
@@ -116,13 +104,6 @@ OF THE POSSIBILITY OF SUCH DAMAGE.
provided
true
-
- javax.json
- javax.json-api
- 1.1.4
- provided
- true
-
com.google.guava
guava
@@ -132,29 +113,23 @@ OF THE POSSIBILITY OF SUCH DAMAGE.
+ @todo #171:30m Transitive dependencies for hamcrest 1.3 and junit 4
+ comes from this dependency.
+ 1) Upgrade jcabi-matchers to the same version of parent as jcabi-http.
+ 2) Replace hamcrest 1.3 with hamcrest 2.2 (?) from parent
+ 3) Replace junit 5 with junit 5
+ -->
com.jcabi
jcabi-matchers
1.6.0
provided
true
-
-
- org.hamcrest
- hamcrest-core
- 2.2
- provided
-
-
- org.hamcrest
- hamcrest-library
- 1.3
- provided
+
+
+ org.hamcrest
+ hamcrest-core
+
+
com.jcabi
@@ -170,31 +145,16 @@ OF THE POSSIBILITY OF SUCH DAMAGE.
test
- javax.xml.bind
- jaxb-api
- 2.3.1
- true
- provided
-
-
- javax.xml.bind
- jsr173_api
-
-
+ jakarta.xml.bind
+ jakarta.xml.bind-api
- javax.xml.bind
- jsr173_api
- 1.0
- true
- provided
+ jakarta.ws.rs
+ jakarta.ws.rs-api
- javax.ws.rs
- jsr311-api
- 1.1.1
- true
- provided
+ jakarta.json
+ jakarta.json-api
org.glassfish.grizzly
@@ -278,6 +238,12 @@ OF THE POSSIBILITY OF SUCH DAMAGE.
testcontainers
1.17.6
test
+
+
+ org.hamcrest
+ hamcrest-core
+
+
org.testcontainers
@@ -287,8 +253,7 @@ OF THE POSSIBILITY OF SUCH DAMAGE.
org.glassfish
- javax.json
- 1.1.4
+ jakarta.json
provided
@@ -297,9 +262,68 @@ OF THE POSSIBILITY OF SUCH DAMAGE.
1.2.25
provided
+
+
+ ch.qos.logback
+ logback-classic
+ 1.4.8
+
+
+ ch.qos.logback
+ logback-core
+ 1.4.8
+
+
+ org.slf4j
+ slf4j-api
+ 2.0.9
+
+
+ org.hamcrest
+ hamcrest
+ 2.2
+
+
+ org.mockito
+ mockito-core
+ 5.4.0
+ test
+
+
+ org.eclipse.parsson
+ parsson
+ 1.1.5
+ provided
+
+
+ net.bytebuddy
+ byte-buddy
+ ${byte-buddy.version}
+ runtime
+
+
+ org.objenesis
+ objenesis
+ 2.6
+ runtime
+
+
+ jakarta.platform
+ jakarta.jakartaee-bom
+ 10.0.0
+ import
+ pom
+
+
+ org.wildfly.bom
+ wildfly-jakartaee8-with-tools
+ 26.1.3.Final
+ pom
+ import
+
com.fasterxml.jackson
jackson-bom
@@ -321,10 +345,48 @@ OF THE POSSIBILITY OF SUCH DAMAGE.
pom
import
+
+ net.bytebuddy
+ byte-buddy-agent
+ ${byte-buddy.version}
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+
+ -javaagent:${project.basedir}/target/byte-buddy-agent-${byte-buddy.version}.jar
+
+
+
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+
+
+ copy
+ process-resources
+
+ copy
+
+
+
+
+ net.bytebuddy
+ byte-buddy-agent
+
+ ${project.build.directory}
+
+
+
+
+
+
+
maven-failsafe-plugin
diff --git a/src/main/java/com/jcabi/http/RequestBody.java b/src/main/java/com/jcabi/http/RequestBody.java
index f3d726a3..0ffddd94 100644
--- a/src/main/java/com/jcabi/http/RequestBody.java
+++ b/src/main/java/com/jcabi/http/RequestBody.java
@@ -30,9 +30,9 @@
package com.jcabi.http;
import com.jcabi.aspects.Immutable;
+import jakarta.json.JsonStructure;
import java.nio.charset.StandardCharsets;
import java.util.Map;
-import javax.json.JsonStructure;
/**
* Request body.
diff --git a/src/main/java/com/jcabi/http/request/BaseRequest.java b/src/main/java/com/jcabi/http/request/BaseRequest.java
index 2d8e62c1..49b47dd9 100644
--- a/src/main/java/com/jcabi/http/request/BaseRequest.java
+++ b/src/main/java/com/jcabi/http/request/BaseRequest.java
@@ -41,6 +41,10 @@
import com.jcabi.http.Wire;
import com.jcabi.immutable.Array;
import com.jcabi.log.Logger;
+import jakarta.json.Json;
+import jakarta.json.JsonStructure;
+import jakarta.ws.rs.core.HttpHeaders;
+import jakarta.ws.rs.core.UriBuilder;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -55,10 +59,6 @@
import java.util.Collection;
import java.util.LinkedList;
import java.util.Map;
-import javax.json.Json;
-import javax.json.JsonStructure;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.UriBuilder;
import lombok.EqualsAndHashCode;
/**
@@ -81,7 +81,8 @@
// first one, since maybe qulice is counting the methods in the inner
// classes too - if it doesn't, then it can be left.
//@checkstyle LineLength (1 line)
-@SuppressWarnings({"PMD.TooManyMethods", "PMD.GodClass", "PMD.ExcessiveImports"})
+@SuppressWarnings({"PMD.TooManyMethods", "PMD.GodClass",
+ "PMD.ExcessiveImports"})
public final class BaseRequest implements Request {
/**
@@ -159,9 +160,11 @@ public BaseRequest(final Wire wre, final String uri) {
* @param method HTTP method
* @param body HTTP request body
*/
- public BaseRequest(final Wire wre, final String uri,
+ public BaseRequest(
+ final Wire wre, final String uri,
final Iterable> headers,
- final String method, final byte[] body) {
+ final String method, final byte[] body
+ ) {
this(wre, uri, headers, method, body, 0, 0);
//@checkstyle ParameterNumber (15 lines)
}
@@ -176,10 +179,12 @@ public BaseRequest(final Wire wre, final String uri,
* @param cnct Connect timeout for http connection
* @param rdd Read timeout for http connection
*/
- public BaseRequest(final Wire wre, final String uri,
+ public BaseRequest(
+ final Wire wre, final String uri,
final Iterable> headers,
final String method, final byte[] body,
- final int cnct, final int rdd) {
+ final int cnct, final int rdd
+ ) {
this.wire = wre;
this.home = BaseRequest.createUri(uri).toString();
this.hdrs = new Array<>(headers);
diff --git a/src/main/java/com/jcabi/http/request/JdkRequest.java b/src/main/java/com/jcabi/http/request/JdkRequest.java
index 0762429d..68ae293e 100644
--- a/src/main/java/com/jcabi/http/request/JdkRequest.java
+++ b/src/main/java/com/jcabi/http/request/JdkRequest.java
@@ -44,6 +44,7 @@
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLConnection;
import java.util.Collection;
@@ -80,22 +81,15 @@ public final class JdkRequest implements Request {
private static final Wire WIRE = new Wire() {
// @checkstyle ParameterNumber (6 lines)
@Override
- public Response send(final Request req, final String home,
+ public Response send(
+ final Request req, final String home,
final String method,
final Collection> headers,
final InputStream content,
final int connect,
- final int read) throws IOException {
- final URLConnection raw = new URL(home).openConnection();
- if (!(raw instanceof HttpURLConnection)) {
- throw new IOException(
- String.format(
- "'%s' opens %s instead of expected HttpURLConnection",
- home, raw.getClass().getName()
- )
- );
- }
- final HttpURLConnection conn = HttpURLConnection.class.cast(raw);
+ final int read
+ ) throws IOException {
+ final HttpURLConnection conn = JdkRequest.openConnection(home);
try {
conn.setConnectTimeout(connect);
conn.setReadTimeout(read);
@@ -139,8 +133,10 @@ public Response send(final Request req, final String home,
* @param output The output stream to write to
* @throws IOException If an IO Exception occurs
*/
- private void writeFully(final InputStream content,
- final OutputStream output) throws IOException {
+ private void writeFully(
+ final InputStream content,
+ final OutputStream output
+ ) throws IOException {
// @checkstyle MagicNumber (1 line)
final byte[] buffer = new byte[8192];
for (int bytes = content.read(buffer); bytes != -1;
@@ -155,7 +151,8 @@ private void writeFully(final InputStream content,
* @return Headers
*/
private Array> headers(
- final Map> fields) {
+ final Map> fields
+ ) {
final Collection> headers =
new LinkedList<>();
for (final Map.Entry> field
@@ -280,8 +277,10 @@ public Response fetch(final InputStream stream) throws IOException {
}
@Override
- public Request through(final Class type,
- final Object... args) {
+ public Request through(
+ final Class type,
+ final Object... args
+ ) {
return this.base.through(type, args);
}
@@ -290,4 +289,33 @@ public Request through(final Wire wire) {
return this.base.through(wire);
}
+ /**
+ * Open HTTP connection.
+ * @param url URL.
+ * @return Connection.
+ * @throws IOException if unable to connect.
+ */
+ private static HttpURLConnection openConnection(
+ final String url
+ ) throws IOException {
+ final URLConnection raw;
+ try {
+ raw = new URI(url).toURL().openConnection();
+ } catch (final URISyntaxException | IllegalArgumentException ex) {
+ throw new IOException(
+ String.format("'%s' is incorrect", url),
+ ex
+ );
+ }
+ if (!(raw instanceof HttpURLConnection)) {
+ throw new IOException(
+ String.format(
+ "'%s' opens %s instead of expected HttpURLConnection",
+ url, raw.getClass().getName()
+ )
+ );
+ }
+ return HttpURLConnection.class.cast(raw);
+ }
+
}
diff --git a/src/main/java/com/jcabi/http/response/JsonResponse.java b/src/main/java/com/jcabi/http/response/JsonResponse.java
index abc031e9..7dfa5ec7 100644
--- a/src/main/java/com/jcabi/http/response/JsonResponse.java
+++ b/src/main/java/com/jcabi/http/response/JsonResponse.java
@@ -31,16 +31,16 @@
import com.jcabi.aspects.Immutable;
import com.jcabi.http.Response;
+import jakarta.json.Json;
+import jakarta.json.JsonArray;
+import jakarta.json.JsonObject;
+import jakarta.json.JsonReader;
+import jakarta.json.JsonStructure;
+import jakarta.json.stream.JsonParsingException;
import java.io.StringReader;
import java.nio.charset.StandardCharsets;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import javax.json.Json;
-import javax.json.JsonArray;
-import javax.json.JsonObject;
-import javax.json.JsonReader;
-import javax.json.JsonStructure;
-import javax.json.stream.JsonParsingException;
import lombok.EqualsAndHashCode;
/**
diff --git a/src/main/java/com/jcabi/http/response/RestResponse.java b/src/main/java/com/jcabi/http/response/RestResponse.java
index 85edbfb2..18eb1d9a 100644
--- a/src/main/java/com/jcabi/http/response/RestResponse.java
+++ b/src/main/java/com/jcabi/http/response/RestResponse.java
@@ -33,14 +33,14 @@
import com.jcabi.http.Request;
import com.jcabi.http.Response;
import com.jcabi.log.Logger;
+import jakarta.ws.rs.core.Cookie;
+import jakarta.ws.rs.core.HttpHeaders;
import java.net.HttpCookie;
import java.net.URI;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import javax.ws.rs.core.Cookie;
-import javax.ws.rs.core.HttpHeaders;
import lombok.EqualsAndHashCode;
import org.hamcrest.CustomMatcher;
import org.hamcrest.Matcher;
@@ -182,7 +182,7 @@ public RestResponse assertBinary(final Matcher matcher) {
*/
public RestResponse assertHeader(
final String name,
- final Matcher> matcher
+ final Matcher super Iterable> matcher
) {
Iterable values = this.headers().get(name);
if (values == null) {
@@ -293,13 +293,12 @@ public Cookie cookie(final String name) {
* @return Regular one
*/
private static Cookie cookie(final HttpCookie cookie) {
- return new Cookie(
- cookie.getName(),
- cookie.getValue(),
- cookie.getPath(),
- cookie.getDomain(),
- cookie.getVersion()
- );
+ return new Cookie.Builder(cookie.getName())
+ .value(cookie.getValue())
+ .domain(cookie.getDomain())
+ .version(cookie.getVersion())
+ .path(cookie.getPath())
+ .build();
}
/**
diff --git a/src/main/java/com/jcabi/http/wire/AutoRedirectingWire.java b/src/main/java/com/jcabi/http/wire/AutoRedirectingWire.java
index 5f9bacc7..9dacbe60 100644
--- a/src/main/java/com/jcabi/http/wire/AutoRedirectingWire.java
+++ b/src/main/java/com/jcabi/http/wire/AutoRedirectingWire.java
@@ -34,6 +34,7 @@
import com.jcabi.http.Request;
import com.jcabi.http.Response;
import com.jcabi.http.Wire;
+import jakarta.ws.rs.core.HttpHeaders;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
@@ -42,7 +43,6 @@
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
-import javax.ws.rs.core.HttpHeaders;
import lombok.EqualsAndHashCode;
import lombok.ToString;
diff --git a/src/main/java/com/jcabi/http/wire/BasicAuthWire.java b/src/main/java/com/jcabi/http/wire/BasicAuthWire.java
index 10f9fb05..412bb419 100644
--- a/src/main/java/com/jcabi/http/wire/BasicAuthWire.java
+++ b/src/main/java/com/jcabi/http/wire/BasicAuthWire.java
@@ -35,6 +35,8 @@
import com.jcabi.http.Response;
import com.jcabi.http.Wire;
import com.jcabi.log.Logger;
+import jakarta.ws.rs.core.HttpHeaders;
+import jakarta.xml.bind.DatatypeConverter;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
@@ -43,8 +45,6 @@
import java.util.Collection;
import java.util.LinkedList;
import java.util.Map;
-import javax.ws.rs.core.HttpHeaders;
-import javax.xml.bind.DatatypeConverter;
import lombok.EqualsAndHashCode;
import lombok.ToString;
diff --git a/src/main/java/com/jcabi/http/wire/CookieOptimizingWire.java b/src/main/java/com/jcabi/http/wire/CookieOptimizingWire.java
index edca35ae..34fd104b 100644
--- a/src/main/java/com/jcabi/http/wire/CookieOptimizingWire.java
+++ b/src/main/java/com/jcabi/http/wire/CookieOptimizingWire.java
@@ -34,6 +34,7 @@
import com.jcabi.http.Request;
import com.jcabi.http.Response;
import com.jcabi.http.Wire;
+import jakarta.ws.rs.core.HttpHeaders;
import java.io.IOException;
import java.io.InputStream;
import java.util.Collection;
@@ -41,7 +42,6 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
-import javax.ws.rs.core.HttpHeaders;
import lombok.EqualsAndHashCode;
import lombok.ToString;
diff --git a/src/main/java/com/jcabi/http/wire/ETagCachingWire.java b/src/main/java/com/jcabi/http/wire/ETagCachingWire.java
index c924abc1..70e6a3cf 100644
--- a/src/main/java/com/jcabi/http/wire/ETagCachingWire.java
+++ b/src/main/java/com/jcabi/http/wire/ETagCachingWire.java
@@ -31,7 +31,7 @@
import com.jcabi.aspects.Immutable;
import com.jcabi.http.Wire;
-import javax.ws.rs.core.HttpHeaders;
+import jakarta.ws.rs.core.HttpHeaders;
import lombok.ToString;
/**
diff --git a/src/main/java/com/jcabi/http/wire/FcCache.java b/src/main/java/com/jcabi/http/wire/FcCache.java
index b6e361fc..f5a60af5 100644
--- a/src/main/java/com/jcabi/http/wire/FcCache.java
+++ b/src/main/java/com/jcabi/http/wire/FcCache.java
@@ -37,6 +37,11 @@
import com.jcabi.http.request.DefaultResponse;
import com.jcabi.immutable.Array;
import com.jcabi.log.Logger;
+import jakarta.json.Json;
+import jakarta.json.JsonArrayBuilder;
+import jakarta.json.JsonObject;
+import jakarta.json.JsonObjectBuilder;
+import jakarta.json.JsonString;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
@@ -51,11 +56,6 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import javax.json.Json;
-import javax.json.JsonArrayBuilder;
-import javax.json.JsonObject;
-import javax.json.JsonObjectBuilder;
-import javax.json.JsonString;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.apache.commons.io.FileUtils;
diff --git a/src/main/java/com/jcabi/http/wire/LastModifiedCachingWire.java b/src/main/java/com/jcabi/http/wire/LastModifiedCachingWire.java
index 4d4b643a..80bc1be8 100644
--- a/src/main/java/com/jcabi/http/wire/LastModifiedCachingWire.java
+++ b/src/main/java/com/jcabi/http/wire/LastModifiedCachingWire.java
@@ -30,7 +30,7 @@
package com.jcabi.http.wire;
import com.jcabi.http.Wire;
-import javax.ws.rs.core.HttpHeaders;
+import jakarta.ws.rs.core.HttpHeaders;
import lombok.ToString;
/**
diff --git a/src/main/java/com/jcabi/http/wire/RetryWire.java b/src/main/java/com/jcabi/http/wire/RetryWire.java
index 0e6fe1e5..504b1dff 100644
--- a/src/main/java/com/jcabi/http/wire/RetryWire.java
+++ b/src/main/java/com/jcabi/http/wire/RetryWire.java
@@ -35,13 +35,13 @@
import com.jcabi.http.Response;
import com.jcabi.http.Wire;
import com.jcabi.log.Logger;
+import jakarta.ws.rs.core.UriBuilder;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URI;
import java.util.Collection;
import java.util.Map;
-import javax.ws.rs.core.UriBuilder;
import lombok.EqualsAndHashCode;
import lombok.ToString;
diff --git a/src/main/java/com/jcabi/http/wire/UserAgentWire.java b/src/main/java/com/jcabi/http/wire/UserAgentWire.java
index bf040329..8903f303 100644
--- a/src/main/java/com/jcabi/http/wire/UserAgentWire.java
+++ b/src/main/java/com/jcabi/http/wire/UserAgentWire.java
@@ -35,12 +35,12 @@
import com.jcabi.http.Response;
import com.jcabi.http.Wire;
import com.jcabi.manifests.Manifests;
+import jakarta.ws.rs.core.HttpHeaders;
import java.io.IOException;
import java.io.InputStream;
import java.util.Collection;
import java.util.LinkedList;
import java.util.Map;
-import javax.ws.rs.core.HttpHeaders;
import lombok.EqualsAndHashCode;
import lombok.RequiredArgsConstructor;
import lombok.ToString;
diff --git a/src/test/java/com/jcabi/http/RequestITCase.java b/src/test/java/com/jcabi/http/RequestITCase.java
index 4fd372b9..e745f66c 100644
--- a/src/test/java/com/jcabi/http/RequestITCase.java
+++ b/src/test/java/com/jcabi/http/RequestITCase.java
@@ -37,10 +37,10 @@
import com.jcabi.http.response.JsonResponse;
import com.jcabi.http.response.RestResponse;
import com.jcabi.http.response.XmlResponse;
+import jakarta.json.Json;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URI;
-import javax.json.Json;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Assertions;
diff --git a/src/test/java/com/jcabi/http/RequestITCaseTemplate.java b/src/test/java/com/jcabi/http/RequestITCaseTemplate.java
index 54114926..e11bb18d 100644
--- a/src/test/java/com/jcabi/http/RequestITCaseTemplate.java
+++ b/src/test/java/com/jcabi/http/RequestITCaseTemplate.java
@@ -38,14 +38,14 @@
import com.jcabi.http.wire.BasicAuthWire;
import com.jcabi.http.wire.CookieOptimizingWire;
import com.jcabi.xml.XML;
+import jakarta.json.Json;
+import jakarta.json.JsonObject;
+import jakarta.json.JsonValue;
+import jakarta.ws.rs.core.HttpHeaders;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URI;
import java.util.Locale;
-import javax.json.Json;
-import javax.json.JsonObject;
-import javax.json.JsonValue;
-import javax.ws.rs.core.HttpHeaders;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import org.hamcrest.MatcherAssert;
diff --git a/src/test/java/com/jcabi/http/RequestTest.java b/src/test/java/com/jcabi/http/RequestTest.java
index 6303dc9c..e712e3b0 100644
--- a/src/test/java/com/jcabi/http/RequestTest.java
+++ b/src/test/java/com/jcabi/http/RequestTest.java
@@ -39,15 +39,15 @@
import com.jcabi.http.response.XmlResponse;
import com.jcabi.http.wire.BasicAuthWire;
import com.jcabi.http.wire.UserAgentWire;
+import jakarta.ws.rs.core.HttpHeaders;
+import jakarta.ws.rs.core.MediaType;
+import jakarta.ws.rs.core.UriBuilder;
import java.io.ByteArrayInputStream;
import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.UriBuilder;
import org.glassfish.grizzly.http.server.Constants;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
diff --git a/src/test/java/com/jcabi/http/mock/MkContainerTest.java b/src/test/java/com/jcabi/http/mock/MkContainerTest.java
index e6c3864c..6224aa79 100644
--- a/src/test/java/com/jcabi/http/mock/MkContainerTest.java
+++ b/src/test/java/com/jcabi/http/mock/MkContainerTest.java
@@ -33,10 +33,10 @@
import com.jcabi.http.request.JdkRequest;
import com.jcabi.http.response.RestResponse;
import com.jcabi.http.wire.VerboseWire;
+import jakarta.ws.rs.HttpMethod;
+import jakarta.ws.rs.core.MediaType;
import java.net.HttpURLConnection;
import java.util.NoSuchElementException;
-import javax.ws.rs.HttpMethod;
-import javax.ws.rs.core.MediaType;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.hamcrest.core.IsAnything;
diff --git a/src/test/java/com/jcabi/http/request/BaseRequestTest.java b/src/test/java/com/jcabi/http/request/BaseRequestTest.java
index 69a16a8a..2d62e93f 100644
--- a/src/test/java/com/jcabi/http/request/BaseRequestTest.java
+++ b/src/test/java/com/jcabi/http/request/BaseRequestTest.java
@@ -35,10 +35,10 @@
import com.jcabi.http.mock.MkContainer;
import com.jcabi.http.mock.MkGrizzlyContainer;
import com.jcabi.immutable.ArrayMap;
+import jakarta.json.Json;
+import jakarta.ws.rs.core.HttpHeaders;
+import jakarta.ws.rs.core.MediaType;
import java.io.IOException;
-import javax.json.Json;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MediaType;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Assertions;
diff --git a/src/test/java/com/jcabi/http/request/FakeRequestTest.java b/src/test/java/com/jcabi/http/request/FakeRequestTest.java
index f67c3276..1659557f 100644
--- a/src/test/java/com/jcabi/http/request/FakeRequestTest.java
+++ b/src/test/java/com/jcabi/http/request/FakeRequestTest.java
@@ -31,12 +31,12 @@
import com.jcabi.http.Request;
import com.jcabi.http.response.RestResponse;
+import jakarta.ws.rs.core.HttpHeaders;
+import jakarta.ws.rs.core.MediaType;
import java.io.ByteArrayInputStream;
import java.net.HttpURLConnection;
import java.net.URI;
import java.nio.charset.StandardCharsets;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MediaType;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Assertions;
diff --git a/src/test/java/com/jcabi/http/request/JdkRequestITCase.java b/src/test/java/com/jcabi/http/request/JdkRequestITCase.java
index 114af4a5..4c485f26 100644
--- a/src/test/java/com/jcabi/http/request/JdkRequestITCase.java
+++ b/src/test/java/com/jcabi/http/request/JdkRequestITCase.java
@@ -30,10 +30,10 @@
package com.jcabi.http.request;
import com.jcabi.aspects.Tv;
+import jakarta.ws.rs.HttpMethod;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
-import javax.ws.rs.HttpMethod;
import org.apache.commons.lang3.StringUtils;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
@@ -88,7 +88,7 @@ void failsNoProtocolNoPort() {
final String uri = "localhost";
MatcherAssert.assertThat(
Assertions.assertThrows(
- MalformedURLException.class,
+ IOException.class,
new Executable() {
@Override
public void execute() throws Throwable {
@@ -98,7 +98,7 @@ public void execute() throws Throwable {
Matchers.hasProperty(
JdkRequestITCase.MESSAGE,
Matchers.allOf(
- Matchers.containsString("no protocol: "),
+ Matchers.containsString("is incorrect"),
Matchers.containsString(uri)
)
)
diff --git a/src/test/java/com/jcabi/http/response/JsonResponseTest.java b/src/test/java/com/jcabi/http/response/JsonResponseTest.java
index 6d3d6cf6..77c4fbe2 100644
--- a/src/test/java/com/jcabi/http/response/JsonResponseTest.java
+++ b/src/test/java/com/jcabi/http/response/JsonResponseTest.java
@@ -31,7 +31,7 @@
import com.jcabi.http.Response;
import com.jcabi.http.request.FakeRequest;
-import javax.json.stream.JsonParsingException;
+import jakarta.json.stream.JsonParsingException;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Assertions;
diff --git a/src/test/java/com/jcabi/http/response/RestResponseTest.java b/src/test/java/com/jcabi/http/response/RestResponseTest.java
index b2de0bac..6ff67bcb 100644
--- a/src/test/java/com/jcabi/http/response/RestResponseTest.java
+++ b/src/test/java/com/jcabi/http/response/RestResponseTest.java
@@ -31,9 +31,9 @@
import com.jcabi.http.Response;
import com.jcabi.http.request.FakeRequest;
+import jakarta.ws.rs.core.HttpHeaders;
import java.net.HttpURLConnection;
import java.net.URI;
-import javax.ws.rs.core.HttpHeaders;
import org.hamcrest.Matcher;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
diff --git a/src/test/java/com/jcabi/http/wire/AutoRedirectingWireTest.java b/src/test/java/com/jcabi/http/wire/AutoRedirectingWireTest.java
index d141ad9e..e1a06b90 100644
--- a/src/test/java/com/jcabi/http/wire/AutoRedirectingWireTest.java
+++ b/src/test/java/com/jcabi/http/wire/AutoRedirectingWireTest.java
@@ -36,7 +36,7 @@
import com.jcabi.http.mock.MkQuery;
import com.jcabi.http.request.JdkRequest;
import com.jcabi.http.response.RestResponse;
-import javax.ws.rs.core.HttpHeaders;
+import jakarta.ws.rs.core.HttpHeaders;
import org.apache.http.HttpStatus;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
diff --git a/src/test/java/com/jcabi/http/wire/BasicAuthWireTest.java b/src/test/java/com/jcabi/http/wire/BasicAuthWireTest.java
index 5e431376..8031898a 100644
--- a/src/test/java/com/jcabi/http/wire/BasicAuthWireTest.java
+++ b/src/test/java/com/jcabi/http/wire/BasicAuthWireTest.java
@@ -35,14 +35,14 @@
import com.jcabi.http.mock.MkQueryMatchers;
import com.jcabi.http.request.JdkRequest;
import com.jcabi.http.response.RestResponse;
+import jakarta.ws.rs.core.HttpHeaders;
+import jakarta.ws.rs.core.UriBuilder;
+import jakarta.xml.bind.DatatypeConverter;
import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import javax.net.ssl.HttpsURLConnection;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.UriBuilder;
-import javax.xml.bind.DatatypeConverter;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Assertions;
diff --git a/src/test/java/com/jcabi/http/wire/CookieOptimizingWireTest.java b/src/test/java/com/jcabi/http/wire/CookieOptimizingWireTest.java
index 0caf24c0..20e27338 100644
--- a/src/test/java/com/jcabi/http/wire/CookieOptimizingWireTest.java
+++ b/src/test/java/com/jcabi/http/wire/CookieOptimizingWireTest.java
@@ -35,8 +35,8 @@
import com.jcabi.http.mock.MkQuery;
import com.jcabi.http.request.JdkRequest;
import com.jcabi.http.response.RestResponse;
+import jakarta.ws.rs.core.HttpHeaders;
import java.net.HttpURLConnection;
-import javax.ws.rs.core.HttpHeaders;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Test;
diff --git a/src/test/java/com/jcabi/http/wire/ETagCachingWireTest.java b/src/test/java/com/jcabi/http/wire/ETagCachingWireTest.java
index a374f657..6c3f8a9a 100644
--- a/src/test/java/com/jcabi/http/wire/ETagCachingWireTest.java
+++ b/src/test/java/com/jcabi/http/wire/ETagCachingWireTest.java
@@ -35,9 +35,9 @@
import com.jcabi.http.mock.MkGrizzlyContainer;
import com.jcabi.http.request.JdkRequest;
import com.jcabi.http.response.RestResponse;
+import jakarta.ws.rs.core.HttpHeaders;
import java.io.IOException;
import java.net.HttpURLConnection;
-import javax.ws.rs.core.HttpHeaders;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Test;
diff --git a/src/test/java/com/jcabi/http/wire/LastModifiedCachingWireTest.java b/src/test/java/com/jcabi/http/wire/LastModifiedCachingWireTest.java
index d0eb1257..205e7110 100644
--- a/src/test/java/com/jcabi/http/wire/LastModifiedCachingWireTest.java
+++ b/src/test/java/com/jcabi/http/wire/LastModifiedCachingWireTest.java
@@ -37,10 +37,10 @@
import com.jcabi.http.mock.MkQuery;
import com.jcabi.http.request.JdkRequest;
import com.jcabi.http.response.RestResponse;
+import jakarta.ws.rs.core.HttpHeaders;
import java.net.HttpURLConnection;
import java.util.Collections;
import java.util.Map;
-import javax.ws.rs.core.HttpHeaders;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.MatcherAssert;
diff --git a/src/test/java/com/jcabi/http/wire/RetryWireTest.java b/src/test/java/com/jcabi/http/wire/RetryWireTest.java
index e8db8da4..e082071a 100644
--- a/src/test/java/com/jcabi/http/wire/RetryWireTest.java
+++ b/src/test/java/com/jcabi/http/wire/RetryWireTest.java
@@ -29,30 +29,32 @@
*/
package com.jcabi.http.wire;
+import ch.qos.logback.classic.Logger;
+import ch.qos.logback.classic.spi.ILoggingEvent;
+import ch.qos.logback.core.read.ListAppender;
import com.jcabi.http.mock.MkAnswer;
import com.jcabi.http.mock.MkContainer;
import com.jcabi.http.mock.MkGrizzlyContainer;
import com.jcabi.http.request.JdkRequest;
import com.jcabi.http.response.RestResponse;
-import java.io.StringWriter;
+import jakarta.ws.rs.core.UriBuilder;
import java.net.HttpURLConnection;
import java.net.URI;
-import javax.ws.rs.core.UriBuilder;
-import org.apache.log4j.Logger;
-import org.apache.log4j.SimpleLayout;
-import org.apache.log4j.WriterAppender;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Test;
+import org.slf4j.LoggerFactory;
/**
* Test case for {@link RetryWire}.
+ *
* @since 1.2
*/
public final class RetryWireTest {
/**
* RetryWire can make a few requests before giving up.
+ *
* @throws Exception If something goes wrong inside
*/
@Test
@@ -72,32 +74,37 @@ void makesMultipleRequests() throws Exception {
/**
* RetryWire should strip user info when logging URL.
+ *
* @throws Exception If something goes wrong inside
*/
@Test
void stripsUserInfoWhenLogging() throws Exception {
- final StringWriter writer = new StringWriter(
- );
- Logger.getLogger(RetryWire.class)
- .addAppender(new WriterAppender(new SimpleLayout(), writer));
- final MkContainer container = new MkGrizzlyContainer()
+ final Logger logger = (Logger) LoggerFactory.getLogger(RetryWire.class);
+ final ListAppender appender = new ListAppender<>();
+ appender.start();
+ logger.addAppender(appender);
+ try (MkContainer container = new MkGrizzlyContainer()
.next(new MkAnswer.Simple(HttpURLConnection.HTTP_INTERNAL_ERROR))
.next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK))
- .start();
- final URI home = container.home();
- new JdkRequest(UriBuilder.fromUri(home).userInfo("jeff:ffej").toString())
- .through(RetryWire.class)
- .fetch()
- .as(RestResponse.class)
- .assertStatus(HttpURLConnection.HTTP_OK);
- writer.flush();
- MatcherAssert.assertThat(
- writer.toString(),
- Matchers.containsString(
- String.format("GET %s (auth: j***j)", home)
- )
- );
- container.stop();
+ .start()) {
+ final URI home = container.home();
+ new JdkRequest(UriBuilder.fromUri(home).userInfo("jeff:ffej").toString())
+ .through(RetryWire.class)
+ .fetch()
+ .as(RestResponse.class)
+ .assertStatus(HttpURLConnection.HTTP_OK);
+ MatcherAssert.assertThat(
+ appender.list,
+ Matchers.hasItem(
+ Matchers.hasProperty(
+ "message",
+ Matchers.containsString(
+ String.format("GET %s (auth: j***j)", home)
+ )
+ )
+ )
+ );
+ }
}
}
diff --git a/src/test/java/com/jcabi/http/wire/UserAgentWireTest.java b/src/test/java/com/jcabi/http/wire/UserAgentWireTest.java
index 9d9813e7..6ed973e8 100644
--- a/src/test/java/com/jcabi/http/wire/UserAgentWireTest.java
+++ b/src/test/java/com/jcabi/http/wire/UserAgentWireTest.java
@@ -34,8 +34,8 @@
import com.jcabi.http.mock.MkGrizzlyContainer;
import com.jcabi.http.request.JdkRequest;
import com.jcabi.http.response.RestResponse;
+import jakarta.ws.rs.core.HttpHeaders;
import java.net.HttpURLConnection;
-import javax.ws.rs.core.HttpHeaders;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Test;
diff --git a/src/test/java/com/jcabi/http/wire/VerboseWireTest.java b/src/test/java/com/jcabi/http/wire/VerboseWireTest.java
index ad89387d..69d25c01 100644
--- a/src/test/java/com/jcabi/http/wire/VerboseWireTest.java
+++ b/src/test/java/com/jcabi/http/wire/VerboseWireTest.java
@@ -36,8 +36,8 @@
import com.jcabi.http.mock.MkQuery;
import com.jcabi.http.request.JdkRequest;
import com.jcabi.http.response.RestResponse;
+import jakarta.ws.rs.core.HttpHeaders;
import java.net.HttpURLConnection;
-import javax.ws.rs.core.HttpHeaders;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Test;