Skip to content

Commit

Permalink
Rename and rearrange classes in spring-web module
Browse files Browse the repository at this point in the history
  • Loading branch information
jsmrcka committed Jun 9, 2022
1 parent d2d335f commit 5a19802
Show file tree
Hide file tree
Showing 11 changed files with 108 additions and 74 deletions.
Original file line number Diff line number Diff line change
@@ -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}";
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -141,9 +126,4 @@ private String createBookAsUri(Book book) {
return API_ROOT + "/" + response.jsonPath()
.get("id");
}

@Override
public RestService getApp() {
return app;
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
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;
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
@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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -75,4 +53,5 @@ private void checkType(Stream<String> jsonPathStream, String type) {
Assertions.assertEquals(1, objectMap.keySet().size());
Assertions.assertEquals(type, objectMap.keySet().iterator().next());
}

}
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
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;
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
@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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}

0 comments on commit 5a19802

Please sign in to comment.