From 3a3e9cb6d26c43d4c41e27a5bf4b4a4d4cd6805e Mon Sep 17 00:00:00 2001 From: Jakub Jedlicka Date: Mon, 2 Sep 2024 20:04:51 +0200 Subject: [PATCH] Finish test coverage for quarkusio/quarkus#41411 --- .../advanced/reactive/HeadersMessageBodyWriter.java | 2 +- .../ts/http/advanced/reactive/HeadersResource.java | 4 ++-- .../reactive/BaseHttpAdvancedReactiveIT.java | 7 +------ .../reactive/DevModeGrpcIntegrationReactiveIT.java | 7 +------ .../ts/http/advanced/reactive/HeadersIT.java | 4 +--- .../quarkus/ts/http/advanced/HeadersResource.java | 13 ++++++------- .../ts/http/advanced/BaseHttpAdvancedIT.java | 8 +------- .../ts/http/advanced/DevModeGrpcIntegrationIT.java | 7 +------ .../java/io/quarkus/ts/http/advanced/HeadersIT.java | 6 ++++-- 9 files changed, 18 insertions(+), 40 deletions(-) diff --git a/http/http-advanced-reactive/src/main/java/io/quarkus/ts/http/advanced/reactive/HeadersMessageBodyWriter.java b/http/http-advanced-reactive/src/main/java/io/quarkus/ts/http/advanced/reactive/HeadersMessageBodyWriter.java index 3e78f71a87..ef06597671 100644 --- a/http/http-advanced-reactive/src/main/java/io/quarkus/ts/http/advanced/reactive/HeadersMessageBodyWriter.java +++ b/http/http-advanced-reactive/src/main/java/io/quarkus/ts/http/advanced/reactive/HeadersMessageBodyWriter.java @@ -21,7 +21,7 @@ public boolean isWriteable(Class aClass, Type type, Annotation[] annotations, Me @Override public void writeTo(CustomHeaderResponse customHeaderResponse, Class aClass, Type type, Annotation[] annotations, - MediaType mediaType, MultivaluedMap multivaluedMap, OutputStream outputStream) + MediaType mediaType, MultivaluedMap multivaluedMap, OutputStream outputStream) throws IOException, WebApplicationException { final String content = "Headers response: " + customHeaderResponse.getContent(); outputStream.write(content.getBytes()); diff --git a/http/http-advanced-reactive/src/main/java/io/quarkus/ts/http/advanced/reactive/HeadersResource.java b/http/http-advanced-reactive/src/main/java/io/quarkus/ts/http/advanced/reactive/HeadersResource.java index bdf5fd0344..38544b37d1 100644 --- a/http/http-advanced-reactive/src/main/java/io/quarkus/ts/http/advanced/reactive/HeadersResource.java +++ b/http/http-advanced-reactive/src/main/java/io/quarkus/ts/http/advanced/reactive/HeadersResource.java @@ -33,8 +33,8 @@ public Uni headersOverride() { @GET @Path("/no-accept") @Produces(MediaType.TEXT_PLAIN) - public Uni okHeaders() { - return Uni.createFrom().item("ok headers"); + public Uni noAcceptHeaders() { + return Uni.createFrom().item(Response.ok(new CustomHeaderResponse("ok headers")).build()); } } diff --git a/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/BaseHttpAdvancedReactiveIT.java b/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/BaseHttpAdvancedReactiveIT.java index df954181bd..fd8f9168a4 100644 --- a/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/BaseHttpAdvancedReactiveIT.java +++ b/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/BaseHttpAdvancedReactiveIT.java @@ -98,12 +98,7 @@ public void httpServer() { @Test @DisplayName("GRPC Server test") public void testGrpc() { - getApp().given() - .when() - .get("/api/grpc/trinity") - .then() - .statusCode(SC_OK) - .body(is("Hello trinity")); + getApp().given().when().get("/api/grpc/trinity").then().statusCode(SC_OK).body(is("Hello trinity")); } @Test diff --git a/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/DevModeGrpcIntegrationReactiveIT.java b/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/DevModeGrpcIntegrationReactiveIT.java index 364a000554..9517aae895 100644 --- a/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/DevModeGrpcIntegrationReactiveIT.java +++ b/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/DevModeGrpcIntegrationReactiveIT.java @@ -70,12 +70,7 @@ public void testGrpcAsClient() throws ExecutionException, InterruptedException { @Test public void testGrpcViaRest() { - app.given() - .when() - .get("/api/grpc/trinity") - .then() - .statusCode(HttpStatus.SC_OK) - .body(is("Hello trinity")); + app.given().when().get("/api/grpc/trinity").then().statusCode(HttpStatus.SC_OK).body(is("Hello trinity")); } @Test diff --git a/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/HeadersIT.java b/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/HeadersIT.java index 1b158412df..1633ec1a61 100644 --- a/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/HeadersIT.java +++ b/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/HeadersIT.java @@ -10,14 +10,13 @@ import java.util.List; -import io.restassured.http.Header; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import io.quarkus.test.bootstrap.RestService; import io.quarkus.test.scenarios.QuarkusScenario; import io.quarkus.test.services.QuarkusApplication; +import io.restassured.http.Header; import io.restassured.response.ValidatableResponse; @QuarkusScenario @@ -104,7 +103,6 @@ private ValidatableResponse whenGet(String path) { .body(is("ok")); } - @Disabled("https://github.com/quarkusio/quarkus/issues/42854") @Test @Tag("https://github.com/quarkusio/quarkus/pull/41411") void testWithNoAcceptHeader() { diff --git a/http/http-advanced/src/main/java/io/quarkus/ts/http/advanced/HeadersResource.java b/http/http-advanced/src/main/java/io/quarkus/ts/http/advanced/HeadersResource.java index e9cf956b86..8ce1d1b973 100644 --- a/http/http-advanced/src/main/java/io/quarkus/ts/http/advanced/HeadersResource.java +++ b/http/http-advanced/src/main/java/io/quarkus/ts/http/advanced/HeadersResource.java @@ -15,13 +15,6 @@ public String headers() { return "ok"; } - @GET - @Path("/no-accept") - @Produces(MediaType.TEXT_PLAIN) - public CustomHeaderResponse noAcceptheaders() { - return new CustomHeaderResponse("ok"); - } - @GET @Path("/pragma") public String pragmaHeaderMustBeSet() { @@ -34,4 +27,10 @@ public Response headersOverride() { return Response.ok("ok").header("foo", "abc").build(); } + @GET + @Path("/no-accept") + @Produces(MediaType.TEXT_PLAIN) + public Response noAcceptHeaders() { + return Response.ok(new CustomHeaderResponse("ok headers")).build(); + } } diff --git a/http/http-advanced/src/test/java/io/quarkus/ts/http/advanced/BaseHttpAdvancedIT.java b/http/http-advanced/src/test/java/io/quarkus/ts/http/advanced/BaseHttpAdvancedIT.java index 4f34bb95dc..df22cdc50f 100644 --- a/http/http-advanced/src/test/java/io/quarkus/ts/http/advanced/BaseHttpAdvancedIT.java +++ b/http/http-advanced/src/test/java/io/quarkus/ts/http/advanced/BaseHttpAdvancedIT.java @@ -111,13 +111,7 @@ public void clientHostAddress(TestInfo testInfo) { @Test @DisplayName("GRPC Server test") public void testGrpc() { - getApp() - .given() - .when() - .get("/api/grpc/trinity") - .then() - .statusCode(HttpStatus.SC_OK) - .body(is("Hello trinity")); + getApp().given().when().get("/api/grpc/trinity").then().statusCode(HttpStatus.SC_OK).body(is("Hello trinity")); } @Test diff --git a/http/http-advanced/src/test/java/io/quarkus/ts/http/advanced/DevModeGrpcIntegrationIT.java b/http/http-advanced/src/test/java/io/quarkus/ts/http/advanced/DevModeGrpcIntegrationIT.java index cf0581de07..7a3d5b3230 100644 --- a/http/http-advanced/src/test/java/io/quarkus/ts/http/advanced/DevModeGrpcIntegrationIT.java +++ b/http/http-advanced/src/test/java/io/quarkus/ts/http/advanced/DevModeGrpcIntegrationIT.java @@ -68,12 +68,7 @@ public void testGrpcAsClient() { @Test public void testGrpcViaRest() { - app.given() - .when() - .get("/api/grpc/trinity") - .then() - .statusCode(HttpStatus.SC_OK) - .body(is("Hello trinity")); + app.given().when().get("/api/grpc/trinity").then().statusCode(HttpStatus.SC_OK).body(is("Hello trinity")); } @Test diff --git a/http/http-advanced/src/test/java/io/quarkus/ts/http/advanced/HeadersIT.java b/http/http-advanced/src/test/java/io/quarkus/ts/http/advanced/HeadersIT.java index 8f928d0ad8..8449bc0e6c 100644 --- a/http/http-advanced/src/test/java/io/quarkus/ts/http/advanced/HeadersIT.java +++ b/http/http-advanced/src/test/java/io/quarkus/ts/http/advanced/HeadersIT.java @@ -96,8 +96,10 @@ void testPathSpecificHeaderRulesOrder() { cacheControlMatches(response, "max-age=1"); } + /** + * Coverage for https://github.com/quarkusio/quarkus/issues/41354 in RestEasy classic + */ @Test - @Tag("https://github.com/quarkusio/quarkus/pull/41411") void testWithNoAcceptHeader() { Header header = new Header("Accept", null); given() @@ -106,7 +108,7 @@ void testWithNoAcceptHeader() { .get("/headers/no-accept") .then() .statusCode(200) - .body(is("Headers response: ok")); + .body(is("Headers response: ok headers")); } private ValidatableResponse whenGet(String path) {