Skip to content

Commit

Permalink
Finish test coverage for quarkusio/quarkus#41411
Browse files Browse the repository at this point in the history
  • Loading branch information
jedla97 committed Sep 3, 2024
1 parent 8e24f71 commit 3a3e9cb
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Object> multivaluedMap, OutputStream outputStream)
MediaType mediaType, MultivaluedMap<String, Object> multivaluedMap, OutputStream outputStream)
throws IOException, WebApplicationException {
final String content = "Headers response: " + customHeaderResponse.getContent();
outputStream.write(content.getBytes());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public Uni<Response> headersOverride() {
@GET
@Path("/no-accept")
@Produces(MediaType.TEXT_PLAIN)
public Uni<String> okHeaders() {
return Uni.createFrom().item("ok headers");
public Uni<Response> noAcceptHeaders() {
return Uni.createFrom().item(Response.ok(new CustomHeaderResponse("ok headers")).build());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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) {
Expand Down

0 comments on commit 3a3e9cb

Please sign in to comment.