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 8d08dd1
Show file tree
Hide file tree
Showing 11 changed files with 8 additions and 99 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

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;

@Path("/headers")
Expand All @@ -15,13 +13,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 Down
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 @@ -16,15 +16,12 @@
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
public class HeadersIT {

@QuarkusApplication(classes = { PathSpecificHeadersResource.class,
HeadersMessageBodyWriter.class,
CustomHeaderResponse.class,
HeadersResource.class }, properties = "headers.properties")
static RestService app = new RestService();

Expand Down Expand Up @@ -96,19 +93,6 @@ void testPathSpecificHeaderRulesOrder() {
cacheControlMatches(response, "max-age=1");
}

@Test
@Tag("https://github.com/quarkusio/quarkus/pull/41411")
void testWithNoAcceptHeader() {
Header header = new Header("Accept", null);
given()
.when()
.header(header)
.get("/headers/no-accept")
.then()
.statusCode(200)
.body(is("Headers response: ok"));
}

private ValidatableResponse whenGet(String path) {
return given()
.get(path)
Expand Down

0 comments on commit 8d08dd1

Please sign in to comment.