Skip to content

Commit

Permalink
Enable back disabled tests
Browse files Browse the repository at this point in the history
Additionally, remove tests for cases,
that are not going to be fixed and
create replacement tests, if possible
  • Loading branch information
fedinskiy committed Oct 12, 2022
1 parent adb0b48 commit b125c98
Show file tree
Hide file tree
Showing 46 changed files with 245 additions and 229 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ public class OpenShiftWorkshopHeroesIT {

@Container(image = "${postgresql.13.image}", port = POSTGRESQL_PORT, expectedLog = "listening on IPv4 address")
static PostgresqlService database = new PostgresqlService()
//fixme https://github.com/quarkus-qe/quarkus-test-framework/issues/455
.withProperty("POSTGRES_USER", "user")
.withProperty("POSTGRES_PASSWORD", "user")
.withProperty("POSTGRES_DB", "mydb")
.withProperty("PGDATA", "/tmp/psql");

@GitRepositoryQuarkusApplication(repo = "https://github.com/quarkusio/quarkus-workshops.git", branch = "5bb433fb7a2c8d80dda88dac9dcabc50f7494dc3", contextDir = "quarkus-workshop-super-heroes/super-heroes/rest-heroes", mavenArgs = "-Dquarkus.package.type=uber-jar -DskipTests -Dquarkus.platform.group-id=${QUARKUS_PLATFORM_GROUP-ID} -Dquarkus.platform.version=${QUARKUS_VERSION}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
import io.restassured.RestAssured;

@OpenShiftScenario
// Helm is concerned just about image name, Native compilation is not relevant
@DisabledOnNative
@DisabledOnNative(reason = "Helm is only concerned with image name, Native compilation is not relevant")
public class OpenShiftHelmSimpleAppIT {

private static final Logger LOG = Logger.getLogger(OpenShiftHelmSimpleAppIT.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package io.quarkus.ts.http.hibernate.validator;

import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.containsString;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.apache.http.HttpStatus;

import io.restassured.http.ContentType;
import io.restassured.response.Response;
import io.restassured.response.ValidatableResponse;

public abstract class BaseResteasyIT {

Expand All @@ -22,33 +22,58 @@ public abstract class BaseResteasyIT {

private static final String EXPECTED_VALIDATOR_ERROR_MESSAGE = "numeric value out of bounds";

protected void assertBadRequestInJsonFormat(String path) {
assertBadRequestInJsonFormat(given().get(path));
protected static ResponseValidator validate(String path) {
return BaseResteasyIT.validate(given().get(path));
}

protected void assertBadRequestInJsonFormat(Response response) {
isBadRequest(response)
.contentType(ContentType.JSON)
.body("parameterViolations[0].message", containsString(EXPECTED_VALIDATOR_ERROR_MESSAGE));
protected static ResponseValidator validate(Response response) {
return new ResponseValidator(response);
}

protected void assertBadRequestInXmlFormat(Response response) {
isBadRequest(response)
.contentType(ContentType.XML)
.body("violationReport.parameterViolations.message", containsString(EXPECTED_VALIDATOR_ERROR_MESSAGE));
}
static class ResponseValidator {
final Response response;

protected void assertBadRequestInTextFormat(String path) {
assertBadRequestInTextFormat(given().get(path));
}
private ResponseValidator(Response response) {
this.response = response;
}

protected void assertBadRequestInTextFormat(Response response) {
isBadRequest(response)
.contentType(ContentType.TEXT)
.body(containsString(EXPECTED_VALIDATOR_ERROR_MESSAGE));
}
protected ResponseValidator isBadRequest() {
assertEquals(HttpStatus.SC_BAD_REQUEST, response.statusCode());
return this;
}

protected ResponseValidator hasReactiveJsonError() {
response.then().contentType(ContentType.JSON);
assertEquals(EXPECTED_VALIDATOR_ERROR_MESSAGE, response.body().jsonPath().getString("violations[0].message"));
return this;
}

protected ResponseValidator hasClassicJsonError() {
response.then().contentType(ContentType.JSON);
assertEquals(EXPECTED_VALIDATOR_ERROR_MESSAGE,
response.body().jsonPath().getString("parameterViolations[0].message"));
return this;
}

protected ResponseValidator hasReactiveXMLError() {
response.then().contentType(ContentType.XML);
assertEquals(EXPECTED_VALIDATOR_ERROR_MESSAGE,
response.body().xmlPath().getString("violationReport.violations.message"));
return this;
}

protected ResponseValidator hasClassicXMLError() {
response.then().contentType(ContentType.XML);
assertEquals(EXPECTED_VALIDATOR_ERROR_MESSAGE,
response.body().xmlPath().getString("violationReport.parameterViolations.message"));
return this;
}

private ValidatableResponse isBadRequest(Response response) {
return response.then().statusCode(HttpStatus.SC_BAD_REQUEST);
protected ResponseValidator hasTextError() {
response.then().contentType(ContentType.TEXT);
String body = response.body().asString();
assertTrue(body.contains(EXPECTED_VALIDATOR_ERROR_MESSAGE), body);
return this;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,32 @@ public class ResteasyClassicUsingJsonAndXmlIT extends BaseResteasyIT {
*/
@Test
public void validateDefaultMediaType() {
assertBadRequestInJsonFormat(CLASSIC_ENDPOINT_WITH_NO_PRODUCES);
validate(CLASSIC_ENDPOINT_WITH_NO_PRODUCES)
.isBadRequest()
.hasClassicJsonError();
}

@Test
public void validateMultipleMediaTypesUsingAcceptXml() {
Response response = given().accept(ContentType.XML).get(CLASSIC_ENDPOINT_WITH_MULTIPLE_PRODUCES);
assertBadRequestInXmlFormat(response);
validate(response)
.isBadRequest()
.hasClassicXMLError();
}

@Test
public void validateMultipleMediaTypesUsingAcceptJson() {
Response response = given().accept(ContentType.JSON).get(CLASSIC_ENDPOINT_WITH_MULTIPLE_PRODUCES);
assertBadRequestInJsonFormat(response);
validate(response)
.isBadRequest()
.hasClassicJsonError();
}

@Test
public void validateMultipleMediaTypesUsingAcceptText() {
Response response = given().accept(ContentType.TEXT).get(CLASSIC_ENDPOINT_WITH_MULTIPLE_PRODUCES);
assertBadRequestInTextFormat(response);
validate(response)
.isBadRequest()
.hasTextError();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public class ResteasyClassicUsingJsonIT extends BaseResteasyIT {

@Test
public void validateDefaultMediaType() {
assertBadRequestInJsonFormat(CLASSIC_ENDPOINT_WITH_NO_PRODUCES);
validate(CLASSIC_ENDPOINT_WITH_NO_PRODUCES)
.isBadRequest()
.hasClassicJsonError();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public class ResteasyClassicUsingTextIT extends BaseResteasyIT {

@Test
public void validateDefaultMediaType() {
assertBadRequestInTextFormat(CLASSIC_ENDPOINT_WITH_NO_PRODUCES);
validate(CLASSIC_ENDPOINT_WITH_NO_PRODUCES)
.isBadRequest()
.hasTextError();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,24 @@ public class ResteasyClassicUsingXmlIT extends BaseResteasyIT {
@Test
public void validateDefaultMediaType() {
// The default media type is TEXT which looks wrong for me, but it's how has been designed following the TCK standard.
assertBadRequestInTextFormat(CLASSIC_ENDPOINT_WITH_NO_PRODUCES);
validate(CLASSIC_ENDPOINT_WITH_NO_PRODUCES)
.isBadRequest()
.hasTextError();
}

@Test
public void validateMultipleMediaTypesUsingAcceptXml() {
Response response = given().accept(ContentType.XML).get(CLASSIC_ENDPOINT_WITH_MULTIPLE_PRODUCES);
assertBadRequestInXmlFormat(response);
validate(response)
.isBadRequest()
.hasClassicXMLError();
}

@Test
public void validateMultipleMediaTypesUsingAcceptText() {
Response response = given().accept(ContentType.TEXT).get(CLASSIC_ENDPOINT_WITH_MULTIPLE_PRODUCES);
assertBadRequestInTextFormat(response);
validate(response)
.isBadRequest()
.hasTextError();
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package io.quarkus.ts.http.hibernate.validator;

import static io.restassured.RestAssured.given;
import static org.hamcrest.CoreMatchers.containsString;

import org.apache.http.HttpStatus;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

Expand All @@ -13,7 +16,6 @@
import io.restassured.http.ContentType;
import io.restassured.response.Response;

@Disabled("Wrong MediaType resolution in Resteasy Reactive: https://github.com/quarkusio/quarkus/issues/20888")
@QuarkusScenario
public class ResteasyReactiveUsingJsonAndXmlIT extends BaseResteasyIT {

Expand All @@ -23,29 +25,45 @@ public class ResteasyReactiveUsingJsonAndXmlIT extends BaseResteasyIT {
})
static final RestService app = new RestService();

/**
* When JSON and XML library are present, default is JSON
*/
@Test
public void validateDefaultMediaType() {
assertBadRequestInJsonFormat(REACTIVE_ENDPOINT_WITH_NO_PRODUCES);
validate(REACTIVE_ENDPOINT_WITH_NO_PRODUCES)
.isBadRequest()
.hasTextError();
}

@Test
public void validateMultipleMediaTypesUsingAcceptXml() {
Response response = given().accept(ContentType.XML).get(REACTIVE_ENDPOINT_WITH_MULTIPLE_PRODUCES);
assertBadRequestInXmlFormat(response);
validate(response)
.isBadRequest()
.hasReactiveXMLError();
}

@Test
public void validateMultipleMediaTypesUsingAcceptJson() {
Response response = given().accept(ContentType.JSON).get(REACTIVE_ENDPOINT_WITH_MULTIPLE_PRODUCES);
assertBadRequestInJsonFormat(response);
validate(response)
.isBadRequest()
.hasReactiveJsonError();
}

@Test
public void validateMultipleMediaTypesUsingAcceptText() {
Response response = given().accept(ContentType.TEXT).get(REACTIVE_ENDPOINT_WITH_MULTIPLE_PRODUCES);
assertBadRequestInTextFormat(response);
validate(response)
.isBadRequest()
.hasTextError();
}

@Test
@Disabled("https://github.com/quarkusio/quarkus/issues/28421")
public void validateReturnValue() {
Response response = given()
.accept(ContentType.TEXT)
.get("/reactive/validate-response-uni/mouse");
Assertions.assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, //https://github.com/quarkusio/quarkus/issues/28422
response.statusCode());
response.then().body(containsString("response must have 3 characters"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import static io.restassured.RestAssured.given;

import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import io.quarkus.test.bootstrap.RestService;
Expand All @@ -14,7 +13,6 @@
import io.restassured.http.ContentType;
import io.restassured.response.Response;

@Disabled("Wrong MediaType resolution in Resteasy Reactive: https://github.com/quarkusio/quarkus/issues/20888")
@DisabledOnNative(reason = "Due to high native build execution time")
@QuarkusScenario
public class ResteasyReactiveUsingJsonIT extends BaseResteasyIT {
Expand All @@ -26,18 +24,24 @@ public class ResteasyReactiveUsingJsonIT extends BaseResteasyIT {

@Test
public void validateDefaultMediaType() {
assertBadRequestInJsonFormat(REACTIVE_ENDPOINT_WITH_NO_PRODUCES);
validate(REACTIVE_ENDPOINT_WITH_NO_PRODUCES)
.isBadRequest()
.hasTextError();
}

@Test
public void validateMultipleMediaTypesUsingAcceptJson() {
Response response = given().accept(ContentType.JSON).get(REACTIVE_ENDPOINT_WITH_MULTIPLE_PRODUCES);
assertBadRequestInJsonFormat(response);
validate(response)
.isBadRequest()
.hasReactiveJsonError();
}

@Test
public void validateMultipleMediaTypesUsingAcceptText() {
Response response = given().accept(ContentType.TEXT).get(REACTIVE_ENDPOINT_WITH_MULTIPLE_PRODUCES);
assertBadRequestInTextFormat(response);
validate(response)
.isBadRequest()
.hasTextError();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import io.quarkus.test.services.QuarkusApplication;
import io.quarkus.ts.http.hibernate.validator.sources.ReactiveResource;

@Disabled("Wrong MediaType resolution in Resteasy Reactive: https://github.com/quarkusio/quarkus/issues/20888")
@DisabledOnNative(reason = "Due to high native build execution time")
@QuarkusScenario
public class ResteasyReactiveUsingTextIT extends BaseResteasyIT {
Expand All @@ -21,7 +20,10 @@ public class ResteasyReactiveUsingTextIT extends BaseResteasyIT {
static final RestService app = new RestService();

@Test
@Disabled("https://github.com/quarkusio/quarkus/issues/28324")
public void validateDefaultMediaType() {
assertBadRequestInTextFormat(REACTIVE_ENDPOINT_WITH_NO_PRODUCES);
validate(REACTIVE_ENDPOINT_WITH_NO_PRODUCES)
.isBadRequest()
.hasTextError();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import io.restassured.http.ContentType;
import io.restassured.response.Response;

@Disabled("Wrong MediaType resolution in Resteasy Reactive: https://github.com/quarkusio/quarkus/issues/20888")
@DisabledOnNative(reason = "Due to high native build execution time")
@QuarkusScenario
public class ResteasyReactiveUsingXmlIT extends BaseResteasyIT {
Expand All @@ -25,20 +24,26 @@ public class ResteasyReactiveUsingXmlIT extends BaseResteasyIT {
static final RestService app = new RestService();

@Test
@Disabled("https://github.com/quarkusio/quarkus/issues/28324")
public void validateDefaultMediaType() {
// The default media type is TEXT which looks wrong for me, but it's how has been designed following the TCK standard.
assertBadRequestInTextFormat(REACTIVE_ENDPOINT_WITH_NO_PRODUCES);
validate(REACTIVE_ENDPOINT_WITH_NO_PRODUCES)
.isBadRequest()
.hasTextError();
}

@Test
public void validateMultipleMediaTypesUsingAcceptXml() {
Response response = given().accept(ContentType.XML).get(REACTIVE_ENDPOINT_WITH_MULTIPLE_PRODUCES);
assertBadRequestInXmlFormat(response);
validate(response)
.isBadRequest()
.hasReactiveXMLError();
}

@Test
public void validateMultipleMediaTypesUsingAcceptText() {
Response response = given().accept(ContentType.TEXT).get(REACTIVE_ENDPOINT_WITH_MULTIPLE_PRODUCES);
assertBadRequestInTextFormat(response);
validate(response)
.isBadRequest()
.hasTextError();
}
}
Loading

0 comments on commit b125c98

Please sign in to comment.