From 5a198020bf9aaad9b4933bbe63d60703c85be630 Mon Sep 17 00:00:00 2001 From: Josef Smrcka Date: Thu, 9 Jun 2022 16:34:50 +0200 Subject: [PATCH] Rename and rearrange classes in spring-web module --- .../spring/web/reactive/MariaDBConstants.java | 9 +++++ .../ts/spring/web/reactive/MariaDBUtils.java | 6 ---- .../AbstractSpringWebQuteIT.java} | 4 +-- ...ceIT.java => AbstractSpringWebRestIT.java} | 24 ++----------- ...eIT.java => OpenShiftSpringWebQuteIT.java} | 11 +++--- ...eIT.java => OpenShiftSpringWebRestIT.java} | 11 +++--- .../{HomePageIT.java => SpringWebQuteIT.java} | 10 +++--- .../reactive/boostrap/SpringWebRestIT.java | 29 +++++++++++++++ ...T.java => AbstractSpringWebOpenApiIT.java} | 29 +++------------ ....java => OpenShiftSpringWebOpenApiIT.java} | 14 +++++--- .../reactive/openapi/SpringWebOpenApiIT.java | 35 +++++++++++++++++++ 11 files changed, 108 insertions(+), 74 deletions(-) create mode 100644 spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/MariaDBConstants.java delete mode 100644 spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/MariaDBUtils.java rename spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/{AbstractDbIT.java => boostrap/AbstractSpringWebQuteIT.java} (85%) rename spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/boostrap/{BookResourceIT.java => AbstractSpringWebRestIT.java} (82%) rename spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/boostrap/{OpenShiftHomePageIT.java => OpenShiftSpringWebQuteIT.java} (67%) rename spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/boostrap/{OpenShiftBookResourceIT.java => OpenShiftSpringWebRestIT.java} (71%) rename spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/boostrap/{HomePageIT.java => SpringWebQuteIT.java} (68%) create mode 100644 spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/boostrap/SpringWebRestIT.java rename spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/openapi/{OpenApiIT.java => AbstractSpringWebOpenApiIT.java} (60%) rename spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/openapi/{OpenShiftOpenApiIT.java => OpenShiftSpringWebOpenApiIT.java} (63%) create mode 100644 spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/openapi/SpringWebOpenApiIT.java diff --git a/spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/MariaDBConstants.java b/spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/MariaDBConstants.java new file mode 100644 index 000000000..708079745 --- /dev/null +++ b/spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/MariaDBConstants.java @@ -0,0 +1,9 @@ +package io.quarkus.ts.spring.web.reactive; + +public class MariaDBConstants { + public static final int PORT = 3306; + public static final String START_LOG_10 = "socket: '/run/mysqld/mysqld.sock' port: " + PORT; + public static final String START_LOG_105 = "Only MySQL server logs after this point"; + public static final String IMAGE_10 = "${mariadb.10.image}"; + public static final String IMAGE_105 = "${mariadb.105.image}"; +} diff --git a/spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/MariaDBUtils.java b/spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/MariaDBUtils.java deleted file mode 100644 index 7a480ce0a..000000000 --- a/spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/MariaDBUtils.java +++ /dev/null @@ -1,6 +0,0 @@ -package io.quarkus.ts.spring.web.reactive; - -public class MariaDBUtils { - public static final int PORT = 3306; - public static final String START_LOG = "socket: '/run/mysqld/mysqld.sock' port: " + PORT; -} diff --git a/spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/AbstractDbIT.java b/spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/boostrap/AbstractSpringWebQuteIT.java similarity index 85% rename from spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/AbstractDbIT.java rename to spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/boostrap/AbstractSpringWebQuteIT.java index bcde4da63..c99ea12a6 100644 --- a/spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/AbstractDbIT.java +++ b/spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/boostrap/AbstractSpringWebQuteIT.java @@ -1,4 +1,4 @@ -package io.quarkus.ts.spring.web.reactive; +package io.quarkus.ts.spring.web.reactive.boostrap; import org.hamcrest.CoreMatchers; import org.junit.jupiter.api.Test; @@ -7,7 +7,7 @@ import io.quarkus.test.bootstrap.RestService; import io.restassured.http.ContentType; -public abstract class AbstractDbIT { +public abstract class AbstractSpringWebQuteIT { private static final String APP_NAME = "Bootstrap Spring Boot"; diff --git a/spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/boostrap/BookResourceIT.java b/spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/boostrap/AbstractSpringWebRestIT.java similarity index 82% rename from spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/boostrap/BookResourceIT.java rename to spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/boostrap/AbstractSpringWebRestIT.java index 1979b5eb9..cf536b49b 100644 --- a/spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/boostrap/BookResourceIT.java +++ b/spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/boostrap/AbstractSpringWebRestIT.java @@ -11,29 +11,14 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; -import io.quarkus.test.bootstrap.MariaDbService; import io.quarkus.test.bootstrap.RestService; -import io.quarkus.test.scenarios.QuarkusScenario; -import io.quarkus.test.services.Container; -import io.quarkus.test.services.QuarkusApplication; -import io.quarkus.ts.spring.web.reactive.AbstractDbIT; -import io.quarkus.ts.spring.web.reactive.MariaDBUtils; import io.quarkus.ts.spring.web.reactive.boostrap.persistence.model.Book; import io.restassured.response.Response; -@QuarkusScenario -public class BookResourceIT extends AbstractDbIT { - +public abstract class AbstractSpringWebRestIT { private static final String API_ROOT = "/api/books"; - @Container(image = "${mariadb.10.image}", port = MariaDBUtils.PORT, expectedLog = MariaDBUtils.START_LOG) - static final MariaDbService database = new MariaDbService(); - - @QuarkusApplication - private static final RestService app = new RestService() - .withProperty("quarkus.datasource.username", database.getUser()) - .withProperty("quarkus.datasource.password", database.getPassword()) - .withProperty("quarkus.datasource.jdbc.url", database::getJdbcUrl); + protected abstract RestService getApp(); @Test public void whenGetAllBooks_thenOK() { @@ -141,9 +126,4 @@ private String createBookAsUri(Book book) { return API_ROOT + "/" + response.jsonPath() .get("id"); } - - @Override - public RestService getApp() { - return app; - } } diff --git a/spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/boostrap/OpenShiftHomePageIT.java b/spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/boostrap/OpenShiftSpringWebQuteIT.java similarity index 67% rename from spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/boostrap/OpenShiftHomePageIT.java rename to spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/boostrap/OpenShiftSpringWebQuteIT.java index 50e30a930..7c8c2c44b 100644 --- a/spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/boostrap/OpenShiftHomePageIT.java +++ b/spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/boostrap/OpenShiftSpringWebQuteIT.java @@ -1,18 +1,19 @@ package io.quarkus.ts.spring.web.reactive.boostrap; +import static io.quarkus.ts.spring.web.reactive.MariaDBConstants.IMAGE_105; +import static io.quarkus.ts.spring.web.reactive.MariaDBConstants.PORT; +import static io.quarkus.ts.spring.web.reactive.MariaDBConstants.START_LOG_105; + import io.quarkus.test.bootstrap.MariaDbService; import io.quarkus.test.bootstrap.RestService; import io.quarkus.test.scenarios.OpenShiftScenario; import io.quarkus.test.services.Container; import io.quarkus.test.services.QuarkusApplication; -import io.quarkus.ts.spring.web.reactive.AbstractDbIT; @OpenShiftScenario -public class OpenShiftHomePageIT extends AbstractDbIT { - - static final int MARIADB_PORT = 3306; +public class OpenShiftSpringWebQuteIT extends AbstractSpringWebQuteIT { - @Container(image = "${mariadb.105.image}", port = MARIADB_PORT, expectedLog = "Only MySQL server logs after this point") + @Container(image = IMAGE_105, port = PORT, expectedLog = START_LOG_105) static final MariaDbService database = new MariaDbService(); @QuarkusApplication diff --git a/spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/boostrap/OpenShiftBookResourceIT.java b/spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/boostrap/OpenShiftSpringWebRestIT.java similarity index 71% rename from spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/boostrap/OpenShiftBookResourceIT.java rename to spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/boostrap/OpenShiftSpringWebRestIT.java index edb8d4c39..a7d76d9c5 100644 --- a/spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/boostrap/OpenShiftBookResourceIT.java +++ b/spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/boostrap/OpenShiftSpringWebRestIT.java @@ -1,5 +1,9 @@ package io.quarkus.ts.spring.web.reactive.boostrap; +import static io.quarkus.ts.spring.web.reactive.MariaDBConstants.IMAGE_105; +import static io.quarkus.ts.spring.web.reactive.MariaDBConstants.PORT; +import static io.quarkus.ts.spring.web.reactive.MariaDBConstants.START_LOG_105; + import org.junit.jupiter.api.condition.EnabledIfSystemProperty; import io.quarkus.test.bootstrap.MariaDbService; @@ -7,15 +11,12 @@ import io.quarkus.test.scenarios.OpenShiftScenario; import io.quarkus.test.services.Container; import io.quarkus.test.services.QuarkusApplication; -import io.quarkus.ts.spring.web.reactive.AbstractDbIT; @OpenShiftScenario @EnabledIfSystemProperty(named = "ts.redhat.registry.enabled", matches = "true") -public class OpenShiftBookResourceIT extends AbstractDbIT { - - static final int MARIADB_PORT = 3306; +public class OpenShiftSpringWebRestIT extends AbstractSpringWebRestIT { - @Container(image = "${mariadb.105.image}", port = MARIADB_PORT, expectedLog = "Only MySQL server logs after this point") + @Container(image = IMAGE_105, port = PORT, expectedLog = START_LOG_105) static final MariaDbService database = new MariaDbService(); @QuarkusApplication diff --git a/spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/boostrap/HomePageIT.java b/spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/boostrap/SpringWebQuteIT.java similarity index 68% rename from spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/boostrap/HomePageIT.java rename to spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/boostrap/SpringWebQuteIT.java index 8afe45016..f607f886f 100644 --- a/spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/boostrap/HomePageIT.java +++ b/spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/boostrap/SpringWebQuteIT.java @@ -1,17 +1,19 @@ package io.quarkus.ts.spring.web.reactive.boostrap; +import static io.quarkus.ts.spring.web.reactive.MariaDBConstants.IMAGE_10; +import static io.quarkus.ts.spring.web.reactive.MariaDBConstants.PORT; +import static io.quarkus.ts.spring.web.reactive.MariaDBConstants.START_LOG_10; + import io.quarkus.test.bootstrap.MariaDbService; import io.quarkus.test.bootstrap.RestService; import io.quarkus.test.scenarios.QuarkusScenario; import io.quarkus.test.services.Container; import io.quarkus.test.services.QuarkusApplication; -import io.quarkus.ts.spring.web.reactive.AbstractDbIT; -import io.quarkus.ts.spring.web.reactive.MariaDBUtils; @QuarkusScenario -public class HomePageIT extends AbstractDbIT { +public class SpringWebQuteIT extends AbstractSpringWebQuteIT { - @Container(image = "${mariadb.10.image}", port = MariaDBUtils.PORT, expectedLog = MariaDBUtils.START_LOG) + @Container(image = IMAGE_10, port = PORT, expectedLog = START_LOG_10) static final MariaDbService database = new MariaDbService(); @QuarkusApplication diff --git a/spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/boostrap/SpringWebRestIT.java b/spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/boostrap/SpringWebRestIT.java new file mode 100644 index 000000000..ab89e54a3 --- /dev/null +++ b/spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/boostrap/SpringWebRestIT.java @@ -0,0 +1,29 @@ +package io.quarkus.ts.spring.web.reactive.boostrap; + +import static io.quarkus.ts.spring.web.reactive.MariaDBConstants.IMAGE_10; +import static io.quarkus.ts.spring.web.reactive.MariaDBConstants.PORT; +import static io.quarkus.ts.spring.web.reactive.MariaDBConstants.START_LOG_10; + +import io.quarkus.test.bootstrap.MariaDbService; +import io.quarkus.test.bootstrap.RestService; +import io.quarkus.test.scenarios.QuarkusScenario; +import io.quarkus.test.services.Container; +import io.quarkus.test.services.QuarkusApplication; + +@QuarkusScenario +public class SpringWebRestIT extends AbstractSpringWebRestIT { + + @Container(image = IMAGE_10, port = PORT, expectedLog = START_LOG_10) + static final MariaDbService database = new MariaDbService(); + + @QuarkusApplication + private static final RestService app = new RestService() + .withProperty("quarkus.datasource.username", database.getUser()) + .withProperty("quarkus.datasource.password", database.getPassword()) + .withProperty("quarkus.datasource.jdbc.url", database::getJdbcUrl); + + @Override + protected RestService getApp() { + return app; + } +} diff --git a/spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/openapi/OpenApiIT.java b/spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/openapi/AbstractSpringWebOpenApiIT.java similarity index 60% rename from spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/openapi/OpenApiIT.java rename to spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/openapi/AbstractSpringWebOpenApiIT.java index c4981afbc..d42b18254 100644 --- a/spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/openapi/OpenApiIT.java +++ b/spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/openapi/AbstractSpringWebOpenApiIT.java @@ -6,43 +6,21 @@ import org.apache.http.HttpStatus; import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.MethodOrderer; import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestMethodOrder; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvFileSource; -import io.quarkus.test.bootstrap.MariaDbService; import io.quarkus.test.bootstrap.RestService; -import io.quarkus.test.scenarios.QuarkusScenario; -import io.quarkus.test.services.Container; -import io.quarkus.test.services.QuarkusApplication; -import io.quarkus.ts.spring.web.reactive.AbstractDbIT; -import io.quarkus.ts.spring.web.reactive.MariaDBUtils; import io.restassured.response.Response; -@QuarkusScenario -@TestMethodOrder(MethodOrderer.OrderAnnotation.class) -public class OpenApiIT extends AbstractDbIT { +public abstract class AbstractSpringWebOpenApiIT { private static Response response; - @Container(image = "${mariadb.10.image}", port = MariaDBUtils.PORT, expectedLog = MariaDBUtils.START_LOG) - static final MariaDbService database = new MariaDbService(); - - @QuarkusApplication - private static final RestService app = new RestService() - .withProperty("quarkus.datasource.username", database.getUser()) - .withProperty("quarkus.datasource.password", database.getPassword()) - .withProperty("quarkus.datasource.jdbc.url", database::getJdbcUrl); - - @Override - public RestService getApp() { - return app; - } + protected abstract RestService getApp(); private void callOpenApiEndpoint() { - response = app.given().get("/q/openapi?format=JSON"); + response = getApp().given().get("/q/openapi?format=JSON"); } @Order(1) @@ -75,4 +53,5 @@ private void checkType(Stream jsonPathStream, String type) { Assertions.assertEquals(1, objectMap.keySet().size()); Assertions.assertEquals(type, objectMap.keySet().iterator().next()); } + } diff --git a/spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/openapi/OpenShiftOpenApiIT.java b/spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/openapi/OpenShiftSpringWebOpenApiIT.java similarity index 63% rename from spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/openapi/OpenShiftOpenApiIT.java rename to spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/openapi/OpenShiftSpringWebOpenApiIT.java index c2c6e6e76..b53f50506 100644 --- a/spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/openapi/OpenShiftOpenApiIT.java +++ b/spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/openapi/OpenShiftSpringWebOpenApiIT.java @@ -1,5 +1,11 @@ package io.quarkus.ts.spring.web.reactive.openapi; +import static io.quarkus.ts.spring.web.reactive.MariaDBConstants.IMAGE_105; +import static io.quarkus.ts.spring.web.reactive.MariaDBConstants.PORT; +import static io.quarkus.ts.spring.web.reactive.MariaDBConstants.START_LOG_105; + +import org.junit.jupiter.api.MethodOrderer; +import org.junit.jupiter.api.TestMethodOrder; import org.junit.jupiter.api.condition.EnabledIfSystemProperty; import io.quarkus.test.bootstrap.MariaDbService; @@ -7,15 +13,13 @@ import io.quarkus.test.scenarios.OpenShiftScenario; import io.quarkus.test.services.Container; import io.quarkus.test.services.QuarkusApplication; -import io.quarkus.ts.spring.web.reactive.AbstractDbIT; @OpenShiftScenario +@TestMethodOrder(MethodOrderer.OrderAnnotation.class) @EnabledIfSystemProperty(named = "ts.redhat.registry.enabled", matches = "true") -public class OpenShiftOpenApiIT extends AbstractDbIT { - - static final int MARIADB_PORT = 3306; +public class OpenShiftSpringWebOpenApiIT extends AbstractSpringWebOpenApiIT { - @Container(image = "${mariadb.105.image}", port = MARIADB_PORT, expectedLog = "Only MySQL server logs after this point") + @Container(image = IMAGE_105, port = PORT, expectedLog = START_LOG_105) static final MariaDbService database = new MariaDbService(); @QuarkusApplication diff --git a/spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/openapi/SpringWebOpenApiIT.java b/spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/openapi/SpringWebOpenApiIT.java new file mode 100644 index 000000000..455f06861 --- /dev/null +++ b/spring/spring-web/src/test/java/io/quarkus/ts/spring/web/reactive/openapi/SpringWebOpenApiIT.java @@ -0,0 +1,35 @@ +package io.quarkus.ts.spring.web.reactive.openapi; + +import static io.quarkus.ts.spring.web.reactive.MariaDBConstants.IMAGE_10; +import static io.quarkus.ts.spring.web.reactive.MariaDBConstants.PORT; +import static io.quarkus.ts.spring.web.reactive.MariaDBConstants.START_LOG_10; + +import org.junit.jupiter.api.MethodOrderer; +import org.junit.jupiter.api.TestMethodOrder; + +import io.quarkus.test.bootstrap.MariaDbService; +import io.quarkus.test.bootstrap.RestService; +import io.quarkus.test.scenarios.QuarkusScenario; +import io.quarkus.test.services.Container; +import io.quarkus.test.services.QuarkusApplication; +import io.restassured.response.Response; + +@QuarkusScenario +@TestMethodOrder(MethodOrderer.OrderAnnotation.class) +public class SpringWebOpenApiIT extends AbstractSpringWebOpenApiIT { + private static Response response; + + @Container(image = IMAGE_10, port = PORT, expectedLog = START_LOG_10) + static final MariaDbService database = new MariaDbService(); + + @QuarkusApplication + private static final RestService app = new RestService() + .withProperty("quarkus.datasource.username", database.getUser()) + .withProperty("quarkus.datasource.password", database.getPassword()) + .withProperty("quarkus.datasource.jdbc.url", database::getJdbcUrl); + + @Override + public RestService getApp() { + return app; + } +}