Skip to content

Commit

Permalink
build(deps): bump jakarta.ws.rs:jakarta.ws.rs-api from 3.1.0 to 4.0.0 (
Browse files Browse the repository at this point in the history
…#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] <support@github.com>

* New module to test jaxrs 4

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Marvin Froeder <velo.br@gmail.com>
  • Loading branch information
dependabot[bot] and velo authored May 8, 2024
1 parent a615958 commit eb10bc1
Show file tree
Hide file tree
Showing 15 changed files with 916 additions and 204 deletions.
4 changes: 2 additions & 2 deletions core/src/test/java/feign/RequestTemplateTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,8 @@ void fragmentShouldNotBeEncodedInTarget() {
@Test
void fragmentShouldBeExtractedWhenQueryParamsExist() {
RequestTemplate template =
new RequestTemplate().method(HttpMethod.GET).uri("/path?query=queryValue#fragment",
true);
new RequestTemplate().method(HttpMethod.GET).uri("/path?query=queryValue#fragment",
true);

assertThat(template.url()).isEqualTo("/path?query=queryValue#fragment");
assertThat(template.queryLine()).isEqualTo("?query=queryValue");
Expand Down
74 changes: 36 additions & 38 deletions fastjson2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,41 +14,39 @@
the License.
-->
<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">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.github.openfeign</groupId>
<artifactId>parent</artifactId>
<version>13.3-SNAPSHOT</version>
</parent>

<artifactId>feign-fastjson2</artifactId>
<name>Feign Fastjson2</name>
<description>Feign Fastjson2</description>

<properties>
<main.basedir>${project.basedir}/..</main.basedir>
</properties>

<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>feign-core</artifactId>
</dependency>

<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2</artifactId>
</dependency>

<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>feign-core</artifactId>
<type>test-jar</type>
<scope>test</scope>
</dependency>
</dependencies>
</project>
<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">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.github.openfeign</groupId>
<artifactId>parent</artifactId>
<version>13.3-SNAPSHOT</version>
</parent>

<artifactId>feign-fastjson2</artifactId>
<name>Feign Fastjson2</name>
<description>Feign Fastjson2</description>

<properties>
<main.basedir>${project.basedir}/..</main.basedir>
</properties>

<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>feign-core</artifactId>
</dependency>

<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2</artifactId>
</dependency>

<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>feign-core</artifactId>
<type>test-jar</type>
<scope>test</scope>
</dependency>
</dependencies>
</project>
10 changes: 10 additions & 0 deletions jaxrs2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@

<build>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.transformer</groupId>
<artifactId>org.eclipse.transformer.maven</artifactId>
Expand Down
16 changes: 10 additions & 6 deletions jaxrs2/src/main/java/feign/jaxrs2/JAXRS2Contract.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 The Feign Authors
* Copyright 2012-2024 The Feign Authors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
Expand All @@ -13,13 +13,17 @@
*/
package feign.jaxrs2;

import feign.jaxrs.JAXRSContract;
import javax.ws.rs.*;
import javax.ws.rs.container.Suspended;
import javax.ws.rs.core.Context;
import java.lang.reflect.Field;
import static feign.Util.checkState;
import static feign.Util.emptyToNull;
import java.lang.reflect.Field;
import javax.ws.rs.BeanParam;
import javax.ws.rs.FormParam;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.PathParam;
import javax.ws.rs.QueryParam;
import javax.ws.rs.container.Suspended;
import javax.ws.rs.core.Context;
import feign.jaxrs.JAXRSContract;

/**
* Please refer to the <a href="https://github.com/Netflix/feign/tree/master/feign-jaxrs2">Feign
Expand Down
9 changes: 7 additions & 2 deletions jaxrs2/src/main/java/feign/jaxrs2/JAXRSClient.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 The Feign Authors
* Copyright 2012-2024 The Feign Authors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
Expand All @@ -23,7 +23,12 @@
import java.util.stream.Collectors;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.*;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedHashMap;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Variant;
import feign.Client;
import feign.Request.Options;

Expand Down
162 changes: 162 additions & 0 deletions jaxrs2/src/test/java/feign/jaxrs2/AbstractJAXRSClientTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
/*
* Copyright 2012-2024 The Feign Authors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package feign.jaxrs2;

import static feign.Util.UTF_8;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assumptions.assumeFalse;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.Collections;
import org.assertj.core.data.MapEntry;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.Test;
import feign.Headers;
import feign.RequestLine;
import feign.Response;
import feign.Util;
import feign.assertj.MockWebServerAssertions;
import feign.client.AbstractClientTest;
import okhttp3.mockwebserver.MockResponse;

public abstract class AbstractJAXRSClientTest extends AbstractClientTest {

@Override
public void patch() throws Exception {
try {
super.patch();
} catch (final RuntimeException e) {
Assumptions.assumeFalse(false, "JaxRS client do not support PATCH requests");
}
}

@Override
public void noResponseBodyForPut() throws Exception {
try {
super.noResponseBodyForPut();
} catch (final IllegalStateException e) {
Assumptions.assumeFalse(false, "JaxRS client do not support empty bodies on PUT");
}
}

@Override
public void noResponseBodyForPatch() {
try {
super.noResponseBodyForPatch();
} catch (final IllegalStateException e) {
Assumptions.assumeFalse(false, "JaxRS client do not support PATCH requests");
}
}

@Override
@Test
public void reasonPhraseIsOptional() throws IOException, InterruptedException {
server.enqueue(new MockResponse().setStatus("HTTP/1.1 " + 200));

final TestInterface api = newBuilder()
.target(TestInterface.class, "http://localhost:" + server.getPort());

final Response response = api.post("foo");

assertThat(response.status()).isEqualTo(200);
// jaxrsclient is creating a reason when none is present
// assertThat(response.reason()).isNullOrEmpty();
}

@Override
@Test
public void parsesRequestAndResponse() throws IOException, InterruptedException {
server.enqueue(new MockResponse().setBody("foo").addHeader("Foo: Bar"));

final TestInterface api = newBuilder()
.target(TestInterface.class, "http://localhost:" + server.getPort());

final Response response = api.post("foo");

assertThat(response.status()).isEqualTo(200);
assertThat(response.reason()).isEqualTo("OK");
assertThat(response.headers())
.hasEntrySatisfying("Content-Length", value -> {
assertThat(value).contains("3");
}).hasEntrySatisfying("Foo", value -> {
assertThat(value).contains("Bar");
});
assertThat(response.body().asInputStream())
.hasSameContentAs(new ByteArrayInputStream("foo".getBytes(UTF_8)));

/* queries with no values are omitted from the uri. See RFC 6750 */
MockWebServerAssertions.assertThat(server.takeRequest()).hasMethod("POST")
.hasPath("/?foo=bar&foo=baz&qux")
.hasBody("foo");
}

@Test
void contentTypeWithoutCharset2() throws Exception {
server.enqueue(new MockResponse()
.setBody("AAAAAAAA"));
final JaxRSClientTestInterface api = newBuilder()
.target(JaxRSClientTestInterface.class, "http://localhost:" + server.getPort());

final Response response = api.getWithContentType();
// Response length should not be null
assertThat(Util.toString(response.body().asReader(UTF_8))).isEqualTo("AAAAAAAA");

MockWebServerAssertions.assertThat(server.takeRequest())
.hasHeaders(
MapEntry.entry("Accept", Collections.singletonList("text/plain")),
MapEntry.entry("Content-Type", Collections.singletonList("text/plain")))
.hasMethod("GET");
}

/*
* JaxRS does not support gzip and deflate compression out-of-the-box.
*/
@Override
public void canSupportGzip() throws Exception {
assumeFalse(false, "JaxRS client do not support gzip compression");
}

@Override
public void canSupportGzipOnError() throws Exception {
assumeFalse(false, "JaxRS client do not support gzip compression");
}

@Override
public void canSupportDeflate() throws Exception {
assumeFalse(false, "JaxRS client do not support deflate compression");
}

@Override
public void canSupportDeflateOnError() throws Exception {
assumeFalse(false, "JaxRS client do not support deflate compression");
}

@Override
public void canExceptCaseInsensitiveHeader() throws Exception {
assumeFalse(false, "JaxRS client do not support gzip compression");
}

public interface JaxRSClientTestInterface {

@RequestLine("GET /")
@Headers({"Accept: text/plain", "Content-Type: text/plain"})
Response getWithContentType();
}


@Override
public void veryLongResponseNullLength() {
assumeFalse(false, "JaxRS client hang if the response doesn't have a payload");
}
}
Loading

0 comments on commit eb10bc1

Please sign in to comment.