Skip to content

Commit eb10bc1

Browse files
build(deps): bump jakarta.ws.rs:jakarta.ws.rs-api from 3.1.0 to 4.0.0 (#2402)
* build(deps): bump jakarta.ws.rs:jakarta.ws.rs-api from 3.1.0 to 4.0.0 Bumps jakarta.ws.rs:jakarta.ws.rs-api from 3.1.0 to 4.0.0. --- updated-dependencies: - dependency-name: jakarta.ws.rs:jakarta.ws.rs-api dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> * New module to test jaxrs 4 --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Marvin Froeder <[email protected]>
1 parent a615958 commit eb10bc1

File tree

15 files changed

+916
-204
lines changed

15 files changed

+916
-204
lines changed

core/src/test/java/feign/RequestTemplateTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,8 +465,8 @@ void fragmentShouldNotBeEncodedInTarget() {
465465
@Test
466466
void fragmentShouldBeExtractedWhenQueryParamsExist() {
467467
RequestTemplate template =
468-
new RequestTemplate().method(HttpMethod.GET).uri("/path?query=queryValue#fragment",
469-
true);
468+
new RequestTemplate().method(HttpMethod.GET).uri("/path?query=queryValue#fragment",
469+
true);
470470

471471
assertThat(template.url()).isEqualTo("/path?query=queryValue#fragment");
472472
assertThat(template.queryLine()).isEqualTo("?query=queryValue");

fastjson2/pom.xml

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -14,41 +14,39 @@
1414
the License.
1515
1616
-->
17-
<project xmlns="http://maven.apache.org/POM/4.0.0"
18-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
20-
<modelVersion>4.0.0</modelVersion>
21-
22-
<parent>
23-
<groupId>io.github.openfeign</groupId>
24-
<artifactId>parent</artifactId>
25-
<version>13.3-SNAPSHOT</version>
26-
</parent>
27-
28-
<artifactId>feign-fastjson2</artifactId>
29-
<name>Feign Fastjson2</name>
30-
<description>Feign Fastjson2</description>
31-
32-
<properties>
33-
<main.basedir>${project.basedir}/..</main.basedir>
34-
</properties>
35-
36-
<dependencies>
37-
<dependency>
38-
<groupId>${project.groupId}</groupId>
39-
<artifactId>feign-core</artifactId>
40-
</dependency>
41-
42-
<dependency>
43-
<groupId>com.alibaba.fastjson2</groupId>
44-
<artifactId>fastjson2</artifactId>
45-
</dependency>
46-
47-
<dependency>
48-
<groupId>${project.groupId}</groupId>
49-
<artifactId>feign-core</artifactId>
50-
<type>test-jar</type>
51-
<scope>test</scope>
52-
</dependency>
53-
</dependencies>
54-
</project>
17+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
18+
<modelVersion>4.0.0</modelVersion>
19+
20+
<parent>
21+
<groupId>io.github.openfeign</groupId>
22+
<artifactId>parent</artifactId>
23+
<version>13.3-SNAPSHOT</version>
24+
</parent>
25+
26+
<artifactId>feign-fastjson2</artifactId>
27+
<name>Feign Fastjson2</name>
28+
<description>Feign Fastjson2</description>
29+
30+
<properties>
31+
<main.basedir>${project.basedir}/..</main.basedir>
32+
</properties>
33+
34+
<dependencies>
35+
<dependency>
36+
<groupId>${project.groupId}</groupId>
37+
<artifactId>feign-core</artifactId>
38+
</dependency>
39+
40+
<dependency>
41+
<groupId>com.alibaba.fastjson2</groupId>
42+
<artifactId>fastjson2</artifactId>
43+
</dependency>
44+
45+
<dependency>
46+
<groupId>${project.groupId}</groupId>
47+
<artifactId>feign-core</artifactId>
48+
<type>test-jar</type>
49+
<scope>test</scope>
50+
</dependency>
51+
</dependencies>
52+
</project>

jaxrs2/pom.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,16 @@
105105

106106
<build>
107107
<plugins>
108+
<plugin>
109+
<artifactId>maven-jar-plugin</artifactId>
110+
<executions>
111+
<execution>
112+
<goals>
113+
<goal>test-jar</goal>
114+
</goals>
115+
</execution>
116+
</executions>
117+
</plugin>
108118
<plugin>
109119
<groupId>org.eclipse.transformer</groupId>
110120
<artifactId>org.eclipse.transformer.maven</artifactId>

jaxrs2/src/main/java/feign/jaxrs2/JAXRS2Contract.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 The Feign Authors
2+
* Copyright 2012-2024 The Feign Authors
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
55
* in compliance with the License. You may obtain a copy of the License at
@@ -13,13 +13,17 @@
1313
*/
1414
package feign.jaxrs2;
1515

16-
import feign.jaxrs.JAXRSContract;
17-
import javax.ws.rs.*;
18-
import javax.ws.rs.container.Suspended;
19-
import javax.ws.rs.core.Context;
20-
import java.lang.reflect.Field;
2116
import static feign.Util.checkState;
2217
import static feign.Util.emptyToNull;
18+
import java.lang.reflect.Field;
19+
import javax.ws.rs.BeanParam;
20+
import javax.ws.rs.FormParam;
21+
import javax.ws.rs.HeaderParam;
22+
import javax.ws.rs.PathParam;
23+
import javax.ws.rs.QueryParam;
24+
import javax.ws.rs.container.Suspended;
25+
import javax.ws.rs.core.Context;
26+
import feign.jaxrs.JAXRSContract;
2327

2428
/**
2529
* Please refer to the <a href="https://github.com/Netflix/feign/tree/master/feign-jaxrs2">Feign

jaxrs2/src/main/java/feign/jaxrs2/JAXRSClient.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 The Feign Authors
2+
* Copyright 2012-2024 The Feign Authors
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
55
* in compliance with the License. You may obtain a copy of the License at
@@ -23,7 +23,12 @@
2323
import java.util.stream.Collectors;
2424
import javax.ws.rs.client.ClientBuilder;
2525
import javax.ws.rs.client.Entity;
26-
import javax.ws.rs.core.*;
26+
import javax.ws.rs.core.HttpHeaders;
27+
import javax.ws.rs.core.MediaType;
28+
import javax.ws.rs.core.MultivaluedHashMap;
29+
import javax.ws.rs.core.MultivaluedMap;
30+
import javax.ws.rs.core.Response;
31+
import javax.ws.rs.core.Variant;
2732
import feign.Client;
2833
import feign.Request.Options;
2934

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
/*
2+
* Copyright 2012-2024 The Feign Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5+
* in compliance with the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License
10+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11+
* or implied. See the License for the specific language governing permissions and limitations under
12+
* the License.
13+
*/
14+
package feign.jaxrs2;
15+
16+
import static feign.Util.UTF_8;
17+
import static org.assertj.core.api.Assertions.assertThat;
18+
import static org.junit.jupiter.api.Assumptions.assumeFalse;
19+
import java.io.ByteArrayInputStream;
20+
import java.io.IOException;
21+
import java.util.Collections;
22+
import org.assertj.core.data.MapEntry;
23+
import org.junit.jupiter.api.Assumptions;
24+
import org.junit.jupiter.api.Test;
25+
import feign.Headers;
26+
import feign.RequestLine;
27+
import feign.Response;
28+
import feign.Util;
29+
import feign.assertj.MockWebServerAssertions;
30+
import feign.client.AbstractClientTest;
31+
import okhttp3.mockwebserver.MockResponse;
32+
33+
public abstract class AbstractJAXRSClientTest extends AbstractClientTest {
34+
35+
@Override
36+
public void patch() throws Exception {
37+
try {
38+
super.patch();
39+
} catch (final RuntimeException e) {
40+
Assumptions.assumeFalse(false, "JaxRS client do not support PATCH requests");
41+
}
42+
}
43+
44+
@Override
45+
public void noResponseBodyForPut() throws Exception {
46+
try {
47+
super.noResponseBodyForPut();
48+
} catch (final IllegalStateException e) {
49+
Assumptions.assumeFalse(false, "JaxRS client do not support empty bodies on PUT");
50+
}
51+
}
52+
53+
@Override
54+
public void noResponseBodyForPatch() {
55+
try {
56+
super.noResponseBodyForPatch();
57+
} catch (final IllegalStateException e) {
58+
Assumptions.assumeFalse(false, "JaxRS client do not support PATCH requests");
59+
}
60+
}
61+
62+
@Override
63+
@Test
64+
public void reasonPhraseIsOptional() throws IOException, InterruptedException {
65+
server.enqueue(new MockResponse().setStatus("HTTP/1.1 " + 200));
66+
67+
final TestInterface api = newBuilder()
68+
.target(TestInterface.class, "http://localhost:" + server.getPort());
69+
70+
final Response response = api.post("foo");
71+
72+
assertThat(response.status()).isEqualTo(200);
73+
// jaxrsclient is creating a reason when none is present
74+
// assertThat(response.reason()).isNullOrEmpty();
75+
}
76+
77+
@Override
78+
@Test
79+
public void parsesRequestAndResponse() throws IOException, InterruptedException {
80+
server.enqueue(new MockResponse().setBody("foo").addHeader("Foo: Bar"));
81+
82+
final TestInterface api = newBuilder()
83+
.target(TestInterface.class, "http://localhost:" + server.getPort());
84+
85+
final Response response = api.post("foo");
86+
87+
assertThat(response.status()).isEqualTo(200);
88+
assertThat(response.reason()).isEqualTo("OK");
89+
assertThat(response.headers())
90+
.hasEntrySatisfying("Content-Length", value -> {
91+
assertThat(value).contains("3");
92+
}).hasEntrySatisfying("Foo", value -> {
93+
assertThat(value).contains("Bar");
94+
});
95+
assertThat(response.body().asInputStream())
96+
.hasSameContentAs(new ByteArrayInputStream("foo".getBytes(UTF_8)));
97+
98+
/* queries with no values are omitted from the uri. See RFC 6750 */
99+
MockWebServerAssertions.assertThat(server.takeRequest()).hasMethod("POST")
100+
.hasPath("/?foo=bar&foo=baz&qux")
101+
.hasBody("foo");
102+
}
103+
104+
@Test
105+
void contentTypeWithoutCharset2() throws Exception {
106+
server.enqueue(new MockResponse()
107+
.setBody("AAAAAAAA"));
108+
final JaxRSClientTestInterface api = newBuilder()
109+
.target(JaxRSClientTestInterface.class, "http://localhost:" + server.getPort());
110+
111+
final Response response = api.getWithContentType();
112+
// Response length should not be null
113+
assertThat(Util.toString(response.body().asReader(UTF_8))).isEqualTo("AAAAAAAA");
114+
115+
MockWebServerAssertions.assertThat(server.takeRequest())
116+
.hasHeaders(
117+
MapEntry.entry("Accept", Collections.singletonList("text/plain")),
118+
MapEntry.entry("Content-Type", Collections.singletonList("text/plain")))
119+
.hasMethod("GET");
120+
}
121+
122+
/*
123+
* JaxRS does not support gzip and deflate compression out-of-the-box.
124+
*/
125+
@Override
126+
public void canSupportGzip() throws Exception {
127+
assumeFalse(false, "JaxRS client do not support gzip compression");
128+
}
129+
130+
@Override
131+
public void canSupportGzipOnError() throws Exception {
132+
assumeFalse(false, "JaxRS client do not support gzip compression");
133+
}
134+
135+
@Override
136+
public void canSupportDeflate() throws Exception {
137+
assumeFalse(false, "JaxRS client do not support deflate compression");
138+
}
139+
140+
@Override
141+
public void canSupportDeflateOnError() throws Exception {
142+
assumeFalse(false, "JaxRS client do not support deflate compression");
143+
}
144+
145+
@Override
146+
public void canExceptCaseInsensitiveHeader() throws Exception {
147+
assumeFalse(false, "JaxRS client do not support gzip compression");
148+
}
149+
150+
public interface JaxRSClientTestInterface {
151+
152+
@RequestLine("GET /")
153+
@Headers({"Accept: text/plain", "Content-Type: text/plain"})
154+
Response getWithContentType();
155+
}
156+
157+
158+
@Override
159+
public void veryLongResponseNullLength() {
160+
assumeFalse(false, "JaxRS client hang if the response doesn't have a payload");
161+
}
162+
}

0 commit comments

Comments
 (0)