diff --git a/bom/application/pom.xml b/bom/application/pom.xml index d3ec6b94a184d6..13e5b48ad5a848 100644 --- a/bom/application/pom.xml +++ b/bom/application/pom.xml @@ -1864,6 +1864,13 @@ quarkus-reactive-datasource-deployment ${project.version} + + io.quarkus + quarkus-reactive-datasource-deployment + ${project.version} + test + test-jar + io.quarkus quarkus-reactive-db2-client diff --git a/extensions/reactive-datasource/deployment/pom.xml b/extensions/reactive-datasource/deployment/pom.xml index 1933639060b016..241c34489d393c 100644 --- a/extensions/reactive-datasource/deployment/pom.xml +++ b/extensions/reactive-datasource/deployment/pom.xml @@ -30,6 +30,11 @@ quarkus-junit5-internal test + + io.rest-assured + rest-assured + test + @@ -46,6 +51,17 @@ + + org.apache.maven.plugins + maven-jar-plugin + + + + test-jar + + + + diff --git a/extensions/reactive-datasource/deployment/src/test/java/io/quarkus/reactive/datasource/ChangingCredentialsProviderBase.java b/extensions/reactive-datasource/deployment/src/test/java/io/quarkus/reactive/datasource/ChangingCredentialsProviderBase.java new file mode 100644 index 00000000000000..de9853d806bc39 --- /dev/null +++ b/extensions/reactive-datasource/deployment/src/test/java/io/quarkus/reactive/datasource/ChangingCredentialsProviderBase.java @@ -0,0 +1,38 @@ +package io.quarkus.reactive.datasource; + +import java.util.HashMap; +import java.util.Map; + +import org.jboss.logging.Logger; + +import io.quarkus.credentials.CredentialsProvider; + +public abstract class ChangingCredentialsProviderBase implements CredentialsProvider { + + private static final Logger log = Logger.getLogger(ChangingCredentialsProviderBase.class.getName()); + + private final String user2; + private final String password2; + + private volatile Map properties; + + protected ChangingCredentialsProviderBase(String user1, String password1, String user2, String password2) { + properties = new HashMap<>(); + properties.put(USER_PROPERTY_NAME, user1); + properties.put(PASSWORD_PROPERTY_NAME, password1); + this.user2 = user2; + this.password2 = password2; + } + + public void changeProperties() { + properties = new HashMap<>(); + properties.put(USER_PROPERTY_NAME, user2); + properties.put(PASSWORD_PROPERTY_NAME, password2); + } + + @Override + public Map getCredentials(String credentialsProviderName) { + log.info("credentials provider returning " + properties); + return properties; + } +} diff --git a/extensions/reactive-datasource/deployment/src/test/java/io/quarkus/reactive/datasource/ChangingCredentialsTestBase.java b/extensions/reactive-datasource/deployment/src/test/java/io/quarkus/reactive/datasource/ChangingCredentialsTestBase.java new file mode 100644 index 00000000000000..c264188fcaefd3 --- /dev/null +++ b/extensions/reactive-datasource/deployment/src/test/java/io/quarkus/reactive/datasource/ChangingCredentialsTestBase.java @@ -0,0 +1,36 @@ +package io.quarkus.reactive.datasource; + +import static io.restassured.RestAssured.given; +import static java.util.concurrent.TimeUnit.SECONDS; + +import org.hamcrest.CoreMatchers; +import org.junit.jupiter.api.Test; + +public abstract class ChangingCredentialsTestBase { + + private String user1; + private String user2; + + protected ChangingCredentialsTestBase(String user1, String user2) { + this.user1 = user1; + this.user2 = user2; + } + + @Test + public void testConnect() throws Exception { + given() + .when().get("/test") + .then() + .statusCode(200) + .body(CoreMatchers.equalTo(user1)); + + SECONDS.sleep(2); // sleep longer than pool idle connection timeout + + given() + .when().get("/test") + .then() + .statusCode(200) + .body(CoreMatchers.equalTo(user2)); + } + +} diff --git a/extensions/reactive-mssql-client/deployment/pom.xml b/extensions/reactive-mssql-client/deployment/pom.xml index a93562d95ffed8..4a9278d322a520 100644 --- a/extensions/reactive-mssql-client/deployment/pom.xml +++ b/extensions/reactive-mssql-client/deployment/pom.xml @@ -69,6 +69,12 @@ assertj-core test + + io.quarkus + quarkus-reactive-datasource-deployment + test + test-jar + diff --git a/extensions/reactive-mssql-client/deployment/src/test/java/io/quarkus/reactive/mssql/client/ChangingCredentialsProvider.java b/extensions/reactive-mssql-client/deployment/src/test/java/io/quarkus/reactive/mssql/client/ChangingCredentialsProvider.java index bdf840cde67479..9f2f5f83428e9a 100644 --- a/extensions/reactive-mssql-client/deployment/src/test/java/io/quarkus/reactive/mssql/client/ChangingCredentialsProvider.java +++ b/extensions/reactive-mssql-client/deployment/src/test/java/io/quarkus/reactive/mssql/client/ChangingCredentialsProvider.java @@ -1,36 +1,13 @@ package io.quarkus.reactive.mssql.client; -import java.util.HashMap; -import java.util.Map; - import jakarta.enterprise.context.ApplicationScoped; -import org.jboss.logging.Logger; - -import io.quarkus.credentials.CredentialsProvider; +import io.quarkus.reactive.datasource.ChangingCredentialsProviderBase; @ApplicationScoped -public class ChangingCredentialsProvider implements CredentialsProvider { - - private static final Logger log = Logger.getLogger(ChangingCredentialsProvider.class.getName()); - - private volatile Map properties; +public class ChangingCredentialsProvider extends ChangingCredentialsProviderBase { public ChangingCredentialsProvider() { - properties = new HashMap<>(); - properties.put(USER_PROPERTY_NAME, "sa"); - properties.put(PASSWORD_PROPERTY_NAME, "A_Str0ng_Required_Password"); - } - - public void changeProperties() { - properties = new HashMap<>(); - properties.put(USER_PROPERTY_NAME, "user2"); - properties.put(PASSWORD_PROPERTY_NAME, "user2_Has_A_Str0ng_Required_Password"); - } - - @Override - public Map getCredentials(String credentialsProviderName) { - log.info("credentials provider returning " + properties); - return properties; + super("sa", "A_Str0ng_Required_Password", "user2", "user2_Has_A_Str0ng_Required_Password"); } } diff --git a/extensions/reactive-mssql-client/deployment/src/test/java/io/quarkus/reactive/mssql/client/ChangingCredentialsTest.java b/extensions/reactive-mssql-client/deployment/src/test/java/io/quarkus/reactive/mssql/client/ChangingCredentialsTest.java index 4e9e3f17e8e647..9f9720b92a10c0 100644 --- a/extensions/reactive-mssql-client/deployment/src/test/java/io/quarkus/reactive/mssql/client/ChangingCredentialsTest.java +++ b/extensions/reactive-mssql-client/deployment/src/test/java/io/quarkus/reactive/mssql/client/ChangingCredentialsTest.java @@ -1,15 +1,11 @@ package io.quarkus.reactive.mssql.client; -import static io.restassured.RestAssured.given; -import static java.util.concurrent.TimeUnit.SECONDS; - -import org.hamcrest.CoreMatchers; -import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; +import io.quarkus.reactive.datasource.ChangingCredentialsTestBase; import io.quarkus.test.QuarkusUnitTest; -public class ChangingCredentialsTest { +public class ChangingCredentialsTest extends ChangingCredentialsTestBase { @RegisterExtension static final QuarkusUnitTest config = new QuarkusUnitTest() @@ -18,21 +14,7 @@ public class ChangingCredentialsTest { .addClass(ChangingCredentialsTestResource.class) .addAsResource("application-changing-credentials.properties", "application.properties")); - @Test - public void testConnect() throws Exception { - given() - .when().get("/test") - .then() - .statusCode(200) - .body(CoreMatchers.equalTo("dbo")); - - SECONDS.sleep(2); // sleep longer than pool idle connection timeout - - given() - .when().get("/test") - .then() - .statusCode(200) - .body(CoreMatchers.equalTo("user2")); + public ChangingCredentialsTest() { + super("dbo", "user2"); } - } diff --git a/extensions/reactive-mysql-client/deployment/pom.xml b/extensions/reactive-mysql-client/deployment/pom.xml index 65a588d4c143dc..e1cdb2d1939537 100644 --- a/extensions/reactive-mysql-client/deployment/pom.xml +++ b/extensions/reactive-mysql-client/deployment/pom.xml @@ -90,6 +90,12 @@ assertj-core test + + io.quarkus + quarkus-reactive-datasource-deployment + test + test-jar + diff --git a/extensions/reactive-mysql-client/deployment/src/test/java/io/quarkus/reactive/mysql/client/ChangingCredentialsProvider.java b/extensions/reactive-mysql-client/deployment/src/test/java/io/quarkus/reactive/mysql/client/ChangingCredentialsProvider.java index 528ae82c493d6a..90f9f7579ba8ea 100644 --- a/extensions/reactive-mysql-client/deployment/src/test/java/io/quarkus/reactive/mysql/client/ChangingCredentialsProvider.java +++ b/extensions/reactive-mysql-client/deployment/src/test/java/io/quarkus/reactive/mysql/client/ChangingCredentialsProvider.java @@ -1,36 +1,13 @@ package io.quarkus.reactive.mysql.client; -import java.util.HashMap; -import java.util.Map; - import jakarta.enterprise.context.ApplicationScoped; -import org.jboss.logging.Logger; - -import io.quarkus.credentials.CredentialsProvider; +import io.quarkus.reactive.datasource.ChangingCredentialsProviderBase; @ApplicationScoped -public class ChangingCredentialsProvider implements CredentialsProvider { - - private static final Logger log = Logger.getLogger(ChangingCredentialsProvider.class.getName()); - - private volatile Map properties; +public class ChangingCredentialsProvider extends ChangingCredentialsProviderBase { public ChangingCredentialsProvider() { - properties = new HashMap<>(); - properties.put(USER_PROPERTY_NAME, "hibernate_orm_test"); - properties.put(PASSWORD_PROPERTY_NAME, "hibernate_orm_test"); - } - - public void changeProperties() { - properties = new HashMap<>(); - properties.put(USER_PROPERTY_NAME, "user2"); - properties.put(PASSWORD_PROPERTY_NAME, "user2"); - } - - @Override - public Map getCredentials(String credentialsProviderName) { - log.info("credentials provider returning " + properties); - return properties; + super("hibernate_orm_test", "hibernate_orm_test", "user2", "user2"); } } diff --git a/extensions/reactive-mysql-client/deployment/src/test/java/io/quarkus/reactive/mysql/client/ChangingCredentialsTest.java b/extensions/reactive-mysql-client/deployment/src/test/java/io/quarkus/reactive/mysql/client/ChangingCredentialsTest.java index f992585ca3d9c9..c49cdffc296aa6 100644 --- a/extensions/reactive-mysql-client/deployment/src/test/java/io/quarkus/reactive/mysql/client/ChangingCredentialsTest.java +++ b/extensions/reactive-mysql-client/deployment/src/test/java/io/quarkus/reactive/mysql/client/ChangingCredentialsTest.java @@ -1,15 +1,11 @@ package io.quarkus.reactive.mysql.client; -import static io.restassured.RestAssured.given; -import static java.util.concurrent.TimeUnit.SECONDS; - -import org.hamcrest.CoreMatchers; -import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; +import io.quarkus.reactive.datasource.ChangingCredentialsTestBase; import io.quarkus.test.QuarkusUnitTest; -public class ChangingCredentialsTest { +public class ChangingCredentialsTest extends ChangingCredentialsTestBase { @RegisterExtension static final QuarkusUnitTest config = new QuarkusUnitTest() @@ -18,21 +14,7 @@ public class ChangingCredentialsTest { .addClass(ChangingCredentialsTestResource.class) .addAsResource("application-changing-credentials.properties", "application.properties")); - @Test - public void testConnect() throws Exception { - given() - .when().get("/test") - .then() - .statusCode(200) - .body(CoreMatchers.equalTo("hibernate_orm_test@%")); - - SECONDS.sleep(2); // sleep longer than pool idle connection timeout - - given() - .when().get("/test") - .then() - .statusCode(200) - .body(CoreMatchers.equalTo("user2@%")); + public ChangingCredentialsTest() { + super("hibernate_orm_test@%", "user2@%"); } - } diff --git a/extensions/reactive-oracle-client/deployment/pom.xml b/extensions/reactive-oracle-client/deployment/pom.xml index 9efdecc7d63675..c752d215467d84 100644 --- a/extensions/reactive-oracle-client/deployment/pom.xml +++ b/extensions/reactive-oracle-client/deployment/pom.xml @@ -73,6 +73,12 @@ assertj-core test + + io.quarkus + quarkus-reactive-datasource-deployment + test + test-jar + diff --git a/extensions/reactive-oracle-client/deployment/src/test/java/io/quarkus/reactive/oracle/client/ChangingCredentialsProvider.java b/extensions/reactive-oracle-client/deployment/src/test/java/io/quarkus/reactive/oracle/client/ChangingCredentialsProvider.java index bf9997072859d8..ca061fda7cfa70 100644 --- a/extensions/reactive-oracle-client/deployment/src/test/java/io/quarkus/reactive/oracle/client/ChangingCredentialsProvider.java +++ b/extensions/reactive-oracle-client/deployment/src/test/java/io/quarkus/reactive/oracle/client/ChangingCredentialsProvider.java @@ -1,36 +1,13 @@ package io.quarkus.reactive.oracle.client; -import java.util.HashMap; -import java.util.Map; - import jakarta.enterprise.context.ApplicationScoped; -import org.jboss.logging.Logger; - -import io.quarkus.credentials.CredentialsProvider; +import io.quarkus.reactive.datasource.ChangingCredentialsProviderBase; @ApplicationScoped -public class ChangingCredentialsProvider implements CredentialsProvider { - - private static final Logger log = Logger.getLogger(ChangingCredentialsProvider.class.getName()); - - private volatile Map properties; +public class ChangingCredentialsProvider extends ChangingCredentialsProviderBase { public ChangingCredentialsProvider() { - properties = new HashMap<>(); - properties.put(USER_PROPERTY_NAME, "SYSTEM"); - properties.put(PASSWORD_PROPERTY_NAME, "hibernate_orm_test"); - } - - public void changeProperties() { - properties = new HashMap<>(); - properties.put(USER_PROPERTY_NAME, "user2"); - properties.put(PASSWORD_PROPERTY_NAME, "user2"); - } - - @Override - public Map getCredentials(String credentialsProviderName) { - log.info("credentials provider returning " + properties); - return properties; + super("SYSTEM", "hibernate_orm_test", "user2", "user2"); } } diff --git a/extensions/reactive-oracle-client/deployment/src/test/java/io/quarkus/reactive/oracle/client/ChangingCredentialsTest.java b/extensions/reactive-oracle-client/deployment/src/test/java/io/quarkus/reactive/oracle/client/ChangingCredentialsTest.java index 68370486a6aa9f..e88bd42b2e1d17 100644 --- a/extensions/reactive-oracle-client/deployment/src/test/java/io/quarkus/reactive/oracle/client/ChangingCredentialsTest.java +++ b/extensions/reactive-oracle-client/deployment/src/test/java/io/quarkus/reactive/oracle/client/ChangingCredentialsTest.java @@ -1,15 +1,11 @@ package io.quarkus.reactive.oracle.client; -import static io.restassured.RestAssured.given; -import static java.util.concurrent.TimeUnit.SECONDS; - -import org.hamcrest.CoreMatchers; -import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; +import io.quarkus.reactive.datasource.ChangingCredentialsTestBase; import io.quarkus.test.QuarkusUnitTest; -public class ChangingCredentialsTest { +public class ChangingCredentialsTest extends ChangingCredentialsTestBase { @RegisterExtension static final QuarkusUnitTest config = new QuarkusUnitTest() @@ -18,21 +14,7 @@ public class ChangingCredentialsTest { .addClass(ChangingCredentialsTestResource.class) .addAsResource("application-changing-credentials.properties", "application.properties")); - @Test - public void testConnect() throws Exception { - given() - .when().get("/test") - .then() - .statusCode(200) - .body(CoreMatchers.equalTo("SYSTEM")); - - SECONDS.sleep(2); // sleep longer than pool idle connection timeout - - given() - .when().get("/test") - .then() - .statusCode(200) - .body(CoreMatchers.equalTo("USER2")); + public ChangingCredentialsTest() { + super("SYSTEM", "USER2"); } - } diff --git a/extensions/reactive-pg-client/deployment/pom.xml b/extensions/reactive-pg-client/deployment/pom.xml index c597628b9926ba..4280858ab9fa83 100644 --- a/extensions/reactive-pg-client/deployment/pom.xml +++ b/extensions/reactive-pg-client/deployment/pom.xml @@ -69,6 +69,12 @@ assertj-core test + + io.quarkus + quarkus-reactive-datasource-deployment + test + test-jar + diff --git a/extensions/reactive-pg-client/deployment/src/test/java/io/quarkus/reactive/pg/client/ChangingCredentialsProvider.java b/extensions/reactive-pg-client/deployment/src/test/java/io/quarkus/reactive/pg/client/ChangingCredentialsProvider.java index 659ffb7cf247f8..aff80b36856bf4 100644 --- a/extensions/reactive-pg-client/deployment/src/test/java/io/quarkus/reactive/pg/client/ChangingCredentialsProvider.java +++ b/extensions/reactive-pg-client/deployment/src/test/java/io/quarkus/reactive/pg/client/ChangingCredentialsProvider.java @@ -1,36 +1,13 @@ package io.quarkus.reactive.pg.client; -import java.util.HashMap; -import java.util.Map; - import jakarta.enterprise.context.ApplicationScoped; -import org.jboss.logging.Logger; - -import io.quarkus.credentials.CredentialsProvider; +import io.quarkus.reactive.datasource.ChangingCredentialsProviderBase; @ApplicationScoped -public class ChangingCredentialsProvider implements CredentialsProvider { - - private static final Logger log = Logger.getLogger(ChangingCredentialsProvider.class.getName()); - - private volatile Map properties; +public class ChangingCredentialsProvider extends ChangingCredentialsProviderBase { public ChangingCredentialsProvider() { - properties = new HashMap<>(); - properties.put(USER_PROPERTY_NAME, "hibernate_orm_test"); - properties.put(PASSWORD_PROPERTY_NAME, "hibernate_orm_test"); - } - - public void changeProperties() { - properties = new HashMap<>(); - properties.put(USER_PROPERTY_NAME, "user2"); - properties.put(PASSWORD_PROPERTY_NAME, "user2"); - } - - @Override - public Map getCredentials(String credentialsProviderName) { - log.info("credentials provider returning " + properties); - return properties; + super("hibernate_orm_test", "hibernate_orm_test", "user2", "user2"); } } diff --git a/extensions/reactive-pg-client/deployment/src/test/java/io/quarkus/reactive/pg/client/ChangingCredentialsTest.java b/extensions/reactive-pg-client/deployment/src/test/java/io/quarkus/reactive/pg/client/ChangingCredentialsTest.java index f63c90cf3ae406..10d145ab5c8569 100644 --- a/extensions/reactive-pg-client/deployment/src/test/java/io/quarkus/reactive/pg/client/ChangingCredentialsTest.java +++ b/extensions/reactive-pg-client/deployment/src/test/java/io/quarkus/reactive/pg/client/ChangingCredentialsTest.java @@ -1,15 +1,11 @@ package io.quarkus.reactive.pg.client; -import static io.restassured.RestAssured.given; -import static java.util.concurrent.TimeUnit.SECONDS; - -import org.hamcrest.CoreMatchers; -import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; +import io.quarkus.reactive.datasource.ChangingCredentialsTestBase; import io.quarkus.test.QuarkusUnitTest; -public class ChangingCredentialsTest { +public class ChangingCredentialsTest extends ChangingCredentialsTestBase { @RegisterExtension static final QuarkusUnitTest config = new QuarkusUnitTest() @@ -18,21 +14,7 @@ public class ChangingCredentialsTest { .addClass(ChangingCredentialsTestResource.class) .addAsResource("application-changing-credentials.properties", "application.properties")); - @Test - public void testConnect() throws Exception { - given() - .when().get("/test") - .then() - .statusCode(200) - .body(CoreMatchers.equalTo("hibernate_orm_test")); - - SECONDS.sleep(2); // sleep longer than pool idle connection timeout - - given() - .when().get("/test") - .then() - .statusCode(200) - .body(CoreMatchers.equalTo("user2")); + public ChangingCredentialsTest() { + super("hibernate_orm_test", "user2"); } - } diff --git a/extensions/reactive-pg-client/deployment/src/test/java/io/quarkus/reactive/pg/client/ChangingCredentialsTestResource.java b/extensions/reactive-pg-client/deployment/src/test/java/io/quarkus/reactive/pg/client/ChangingCredentialsTestResource.java index 20b789737dc17a..565361f1773eaa 100644 --- a/extensions/reactive-pg-client/deployment/src/test/java/io/quarkus/reactive/pg/client/ChangingCredentialsTestResource.java +++ b/extensions/reactive-pg-client/deployment/src/test/java/io/quarkus/reactive/pg/client/ChangingCredentialsTestResource.java @@ -2,8 +2,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -import io.smallrye.mutiny.Uni; -import io.vertx.mutiny.pgclient.PgPool; import jakarta.annotation.PostConstruct; import jakarta.inject.Inject; import jakarta.ws.rs.GET; @@ -12,6 +10,9 @@ import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.core.Response; +import io.smallrye.mutiny.Uni; +import io.vertx.mutiny.pgclient.PgPool; + @Path("/test") public class ChangingCredentialsTestResource {