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] <[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]>
  • Loading branch information
dependabot[bot] and velo authored May 8, 2024
1 parent 3f47f84 commit 70f3d9a
Show file tree
Hide file tree
Showing 13 changed files with 862 additions and 147 deletions.
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
8 changes: 6 additions & 2 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 @@ -18,7 +18,11 @@

import feign.jaxrs.JAXRSContract;
import java.lang.reflect.Field;
import javax.ws.rs.*;
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;

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 @@ -25,7 +25,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;

/**
* This module directs Feign's http requests to javax.ws.rs.client.Client . Ex:
Expand Down
167 changes: 167 additions & 0 deletions jaxrs2/src/test/java/feign/jaxrs2/AbstractJAXRSClientTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
/*
* 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 feign.Headers;
import feign.RequestLine;
import feign.Response;
import feign.Util;
import feign.assertj.MockWebServerAssertions;
import feign.client.AbstractClientTest;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.Collections;
import okhttp3.mockwebserver.MockResponse;
import org.assertj.core.data.MapEntry;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.Test;

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 70f3d9a

Please sign in to comment.