Author: gk
Date: Fri Dec 20 15:17:46 2019
New Revision: 1871864
URL: http://svn.apache.org/viewvc?rev=1871864&view=rev
Log:
- clean up
- split up database specific extension and configuration adapter (no inheritance)
- TODO replace old extension with new, last only used in DataContainerTest.java for mysql
- update postgresql
- add and prepare postgresql docker profile (not yet running any tests)
Added:
db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerCallbackExtension2.java
- copied, changed from r1870878, db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerCallbackExtension.java
db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerCallbackMySQLExtension.java (with props)
db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerCallbackPostgreSQLExtension.java (with props)
db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerMySQLCallback.java
- copied, changed from r1870878, db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerCallback.java
db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerPostGresCallback.java (with props)
db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/mysql/
db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/mysql/BeanConditionalContainerTest.java
- copied, changed from r1870878, db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/BeanConditionalContainerTest.java
db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/mysql/DataContainerTest.java
- copied, changed from r1870878, db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/DataContainerTest.java
db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/mysql/ManagerConditionalContainerTest.java
- copied, changed from r1870878, db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/ManagerConditionalContainerTest.java
db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/postgresql/
db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/postgresql/DataContainerTest.java (with props)
db/torque/torque4/trunk/torque-test/src/test/profile/postgresql/Torque4Test.xml (with props)
db/torque/torque4/trunk/torque-test/src/test/profile/postgresql/docker-resources/
db/torque/torque4/trunk/torque-test/src/test/profile/postgresql/docker-resources/db/
db/torque/torque4/trunk/torque-test/src/test/profile/postgresql/docker-resources/db/.dockerignore
db/torque/torque4/trunk/torque-test/src/test/profile/postgresql/docker-resources/db/Dockerfile
db/torque/torque4/trunk/torque-test/src/test/profile/postgresql/docker-resources/docker-java.properties.template
db/torque/torque4/trunk/torque-test/src/test/profile/postgresql/docker-resources/testcontainers.properties (with props)
Removed:
db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/BeanConditionalContainerTest.java
db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/DataContainerTest.java
db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/ManagerConditionalContainerTest.java
Modified:
db/torque/torque4/trunk/torque-test/pom.xml
db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/junit5/extension/HostCallbackExtension.java
Modified: db/torque/torque4/trunk/torque-test/pom.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/pom.xml?rev=1871864&r1=1871863&r2=1871864&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/pom.xml (original)
+++ db/torque/torque4/trunk/torque-test/pom.xml Fri Dec 20 15:17:46 2019
@@ -56,8 +56,9 @@
<torque.test.mysql.version>8.0.18</torque.test.mysql.version><!-- 5.1.48 , 8.0.18-->
<torque.test.mysql.log4j2.version>2.12.1</torque.test.mysql.log4j2.version>
<torque.test.oracle.version>10.2.0.3.0</torque.test.oracle.version>
- <torque.test.postgres.version>9.1-901.jdbc4</torque.test.postgres.version>
- <torque.test.testcontainer.version>1.12.3</torque.test.testcontainer.version>
+ <torque.test.postgres.jdbc.version>42.2.9</torque.test.postgres.jdbc.version><!-- 9.1-901.jdbc4, -->
+ <torque.test.postgres.version>12.1</torque.test.postgres.version>
+ <torque.test.testcontainer.version>1.12.4</torque.test.testcontainer.version>
<!-- -->
<torque.test.idmethod>native</torque.test.idmethod>
</properties>
@@ -950,6 +951,13 @@
<torque.database.password>torque</torque.database.password>
<torque.database.shutdown.url>none</torque.database.shutdown.url>
<torque.database.shutdown.skip>true</torque.database.shutdown.skip>
+ <docker.database.port>3306</docker.database.port>
+ <docker.image.name>mysql</docker.image.name>
+ <docker.image.version>${torque.test.mysql.version}</docker.image.version>
+ <docker.env.MYSQL_ROOT_PASSWORD>${torque.database.password}</docker.env.MYSQL_ROOT_PASSWORD>
+ <docker.env.MYSQL_DATABASE>bookstore</docker.env.MYSQL_DATABASE>
+ <docker.env.MYSQL_USER>${torque.database.user}</docker.env.MYSQL_USER>
+ <docker.env.MYSQL_PASSWORD>${torque.database.password}</docker.env.MYSQL_PASSWORD>
</properties>
<dependencies>
<dependency>
@@ -964,6 +972,12 @@
<version>${torque.test.mysql.log4j2.version}</version>
<scope>runtime</scope>
</dependency>
+ <dependency>
+ <groupId>org.testcontainers</groupId>
+ <artifactId>mysql</artifactId>
+ <version>${torque.test.testcontainer.version}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
<plugins>
@@ -1136,14 +1150,26 @@
<torque.database.password>torque</torque.database.password>
<torque.database.shutdown.url>none</torque.database.shutdown.url>
<torque.database.shutdown.skip>true</torque.database.shutdown.skip>
+ <docker.database.port>5432</docker.database.port>
+ <docker.image.name>postgres</docker.image.name>
+ <docker.image.version>${torque.test.postgres.version}</docker.image.version>
+ <docker.env.POSTGRES_DB>bookstore</docker.env.POSTGRES_DB>
+ <docker.env.POSTGRES_USER>${torque.database.user}</docker.env.POSTGRES_USER>
+ <docker.env.POSTGRES_PASSWORD>${torque.database.password}</docker.env.POSTGRES_PASSWORD>
</properties>
<dependencies>
<dependency>
+ <groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
- <groupId>postgresql</groupId>
- <version>${torque.test.postgres.version}</version>
+ <version>${torque.test.postgres.jdbc.version}</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.testcontainers</groupId>
+ <artifactId>postgresql</artifactId>
+ <version>${torque.test.testcontainer.version}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
<plugins>
@@ -1152,9 +1178,9 @@
<artifactId>sql-maven-plugin</artifactId>
<dependencies>
<dependency>
- <artifactId>postgresql</artifactId>
- <groupId>postgresql</groupId>
- <version>${torque.test.postgres.version}</version>
+ <groupId>org.postgresql</groupId>
+ <artifactId>postgresql</artifactId>
+ <version>${torque.test.postgres.jdbc.version}</version>
</dependency>
</dependencies>
</plugin>
@@ -1162,9 +1188,9 @@
<artifactId>maven-antrun-plugin</artifactId>
<dependencies>
<dependency>
- <artifactId>postgresql</artifactId>
- <groupId>postgresql</groupId>
- <version>${torque.test.postgres.version}</version>
+ <groupId>org.postgresql</groupId>
+ <artifactId>postgresql</artifactId>
+ <version>${torque.test.postgres.jdbc.version}</version>
</dependency>
</dependencies>
</plugin>
@@ -1178,7 +1204,7 @@
mvnDebug -Pmysql,docker-testcontainer,managers,beans clean test -Dtest=DataContainerTest#testLikeClauseEscaping
- The following test call will fail, although database will be generated (prepare-mysql-databas) but docker is not initialized in the unit test as second step:
+ The following test call will fail, although database will be generated (prepare-..-database), but docker is not initialized in the unit test as second step:
mvnDebug -Pmysql,docker-testcontainer,managers,beans clean test -Dtest=DataTest#testLikeClauseEscaping
-->
@@ -1197,11 +1223,11 @@
<artifactId>docker-maven-plugin</artifactId>
<version>0.30.0</version>
<configuration>
- <filter>mysql:${torque.test.mysql.version}</filter>
+ <filter>${docker.image.name}:${docker.image.version}</filter>
</configuration>
<executions>
<execution>
- <id>prepare-mysql-database</id>
+ <id>prepare-${docker.image.name}-database</id>
<phase>initialize</phase>
<goals>
<goal>start</goal>
@@ -1210,19 +1236,14 @@
<!-- may set it here environment variables: dockerhost, .. -->
<images>
<image>
- <name>mysql:${torque.test.mysql.version}</name>
- <alias>mysql-generate-helper-database</alias>
+ <name>${docker.image.name}:${docker.image.version}</name>
+ <alias>${docker.image.name}-generate-helper-database</alias>
<run>
- <env>
- <MYSQL_ROOT_PASSWORD>${torque.database.password}</MYSQL_ROOT_PASSWORD>
- <MYSQL_DATABASE>bookstore</MYSQL_DATABASE>
- <MYSQL_USER>${torque.database.user}</MYSQL_USER>
- <MYSQL_PASSWORD>${torque.database.password}</MYSQL_PASSWORD>
- </env>
+ <!-- setting env in database profiles env.docker -->
<!-- this is too late for reading GLOBAL env DOCKER_HOST -> issue of the plugin? -->
<!--envPropertyFile>${project.basedir}/src/test/profile/mysql/docker-resources/docker-java.properties</envPropertyFile-->
<ports>
- <port>3306:3306</port>
+ <port>${docker.database.port}:${docker.database.port}</port>
</ports>
<!--wait>
<log>database system is ready to accept connections.</log>
@@ -1235,7 +1256,7 @@
</execution>
<!-- close this init generate sources database outside tests, before starting tests -->
<execution>
- <id>remove-mysql-database</id>
+ <id>remove-docker-database</id>
<phase>process-classes</phase>
<goals>
<goal>stop</goal>
@@ -1300,7 +1321,7 @@
<outputDirectory>${basedir}/target</outputDirectory>
<resources>
<resource>
- <directory>src/test/profile/mysql/docker-resources/db</directory>
+ <directory>src/test/profile/${torque.test.profileDirectory}/docker-resources/db</directory>
<filtering>false</filtering>
<includes>
<include>Dockerfile</include>
@@ -1320,7 +1341,7 @@
<outputDirectory>${basedir}/target/test-classes</outputDirectory>
<resources>
<resource>
- <directory>src/test/profile/mysql/docker-resources</directory>
+ <directory>src/test/profile/${torque.test.profileDirectory}/docker-resources</directory>
<filtering>false</filtering>
<includes>
<include>docker-java.properties</include>
@@ -1345,7 +1366,7 @@
<exclude>**/junit5/extension/**</exclude>
</excludes>
<includes>
- <include>**/testcontainer/**</include>
+ <include>**/testcontainer/${torque.test.profileDirectory}/**</include>
</includes>
<!--groups>DockerCallback</groups-->
</configuration>
@@ -1373,12 +1394,6 @@
<version>${torque.test.testcontainer.version}</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.testcontainers</groupId>
- <artifactId>mysql</artifactId>
- <version>${torque.test.testcontainer.version}</version>
- <scope>test</scope>
- </dependency>
</dependencies>
</profile>
Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/junit5/extension/HostCallbackExtension.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/junit5/extension/HostCallbackExtension.java?rev=1871864&r1=1871863&r2=1871864&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/junit5/extension/HostCallbackExtension.java (original)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/junit5/extension/HostCallbackExtension.java Fri Dec 20 15:17:46 2019
@@ -26,7 +26,6 @@ import org.apache.logging.log4j.LogManag
import org.apache.logging.log4j.Logger;
import org.apache.torque.Torque;
import org.apache.torque.adapter.Adapter;
-import org.apache.torque.testcontainer.junit5.extension.DockerCallbackExtension;
import org.junit.jupiter.api.extension.BeforeAllCallback;
import org.junit.jupiter.api.extension.ConditionEvaluationResult;
import org.junit.jupiter.api.extension.ExecutionCondition;
@@ -51,8 +50,6 @@ public class HostCallbackExtension imple
protected static Adapter defaultAdapter;
- public static Namespace NS = Namespace.create(DockerCallbackExtension.class);
-
public boolean skip = true;
private static final ConditionEvaluationResult ENABLED_BY_DEFAULT = enabled(
Copied: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerCallbackExtension2.java (from r1870878, db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerCallbackExtension.java)
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerCallbackExtension2.java?p2=db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerCallbackExtension2.java&p1=db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerCallbackExtension.java&r1=1870878&r2=1871864&rev=1871864&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerCallbackExtension.java (original)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerCallbackExtension2.java Fri Dec 20 15:17:46 2019
@@ -19,18 +19,19 @@ package org.apache.torque.testcontainer.
* specific language governing permissions and limitations
* under the License.
*/
-
-import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import static org.junit.jupiter.api.extension.ConditionEvaluationResult.enabled;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.lang.annotation.Annotation;
+import java.lang.annotation.AnnotationFormatError;
import java.nio.file.Path;
import java.nio.file.Paths;
import org.apache.commons.configuration2.CombinedConfiguration;
-import org.apache.commons.configuration2.Configuration;
import org.apache.commons.configuration2.PropertiesConfiguration;
import org.apache.commons.configuration2.builder.combined.CombinedConfigurationBuilder;
import org.apache.commons.configuration2.builder.fluent.Parameters;
@@ -41,54 +42,53 @@ import org.apache.logging.log4j.Logger;
import org.apache.torque.Torque;
import org.apache.torque.TorqueException;
import org.apache.torque.adapter.Adapter;
+import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.extension.BeforeAllCallback;
import org.junit.jupiter.api.extension.BeforeTestExecutionCallback;
import org.junit.jupiter.api.extension.ConditionEvaluationResult;
import org.junit.jupiter.api.extension.ExecutionCondition;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.jupiter.api.extension.ExtensionContext.Namespace;
-import org.testcontainers.containers.GenericContainer;
-import org.testcontainers.containers.wait.strategy.Wait;
-import org.testcontainers.images.builder.ImageFromDockerfile;
-import org.testcontainers.junit.jupiter.Container;
-import org.testcontainers.junit.jupiter.Testcontainers;
/**
- * Testcontainer configuration
+ * Docker Test configuration
*
* @author gk
*
*/
-@Testcontainers
-public class DockerCallbackExtension implements BeforeAllCallback, BeforeTestExecutionCallback, ExecutionCondition {
- private static final String DEFAULT_TEST_PROFILE_TORQUE4_TEST_XML = "src/test/profile/%s/Torque4Test.xml";
+public class DockerCallbackExtension2 /*extends DockerCallbackMySQLExtension*/ implements BeforeAllCallback, BeforeTestExecutionCallback, ExecutionCondition {
- private static final String TORQUE_WRAPPER_CONFIG_SYSTEM_PROPERTY = "torque.wrapper.configuration.file";
+ protected static final String DEFAULT_TEST_PROFILE_TORQUE4_TEST_XML = "src/test/profile/%s/Torque4Test.xml";
- // copied from src/test/profile/mysql/docker-resources/db/
- private static final String DOCKERFILE = "./target/Dockerfile";
+ protected static final String TORQUE_WRAPPER_CONFIG_SYSTEM_PROPERTY = "torque.wrapper.configuration.file";
private static Logger log = LogManager.getLogger();
- private static int SERVICE_PORT = 3306;
-
- private static String DATABASE_NAME = "bookstore";
-
+ protected static int SERVICE_PORT = 3306;
protected static Adapter defaultAdapter;
-
- public static Namespace NS = Namespace.create(DockerCallbackExtension.class);
-
- private static final ConditionEvaluationResult ENABLED_BY_DEFAULT = enabled(
+
+ String adapterProfileFallback;
+
+ String customUrlKey;
+
+ String targetConfigName;
+
+ String targetFileName;
+
+ boolean skipConfigurationCheck = false;
+
+ protected static final ConditionEvaluationResult ENABLED_BY_DEFAULT = enabled(
"DockerCallbackExtension is enabled by default - checking internal state only");
-
- @Container
- public static GenericContainer MY_SQL_CONTAINER = new GenericContainer<>(
- new ImageFromDockerfile().withDockerfile(new File(DOCKERFILE).toPath())).withExposedPorts(SERVICE_PORT)
- .withEnv("MYSQL_DATABASE", DATABASE_NAME).withEnv("MYSQL_USER", "torque")
- .withEnv("MYSQL_PASSWORD", "torque").withEnv("MYSQL_ROOT_PASSWORD", "torque");
-
- @Override
+
+ public DockerCallbackExtension2() {
+
+ }
+
+ public DockerCallbackExtension2(String adapterProfileFallback) {
+ this.adapterProfileFallback =adapterProfileFallback;
+ }
+
public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) {
String actual = System.getProperty("torque.callback");
if (actual == null) {
@@ -98,27 +98,54 @@ public class DockerCallbackExtension imp
}
return ENABLED_BY_DEFAULT;
}
-
- @Override
+
+ /**
+ * calls first super{@link #beforeAll(ExtensionContext)}
+ *
+ * @see BeforeAll
+ */
public void beforeAll(ExtensionContext context) throws Exception {
- // log.info("starting call context "+ context);
-
- init(context);
- context.getStore(NS).put("container", MY_SQL_CONTAINER);
- context.getStore(Namespace.GLOBAL).put("adapter", defaultAdapter);
+ Annotation[] annots = context.getTestClass().get().getAnnotations();
+ log.info("found and get context.getTestClass(): {}", context.getTestClass());
+ for (Annotation annot : annots) {
+ if (annot instanceof DockerMySQLCallback) {
+ log.warn("found and get: {}", DockerMySQLCallback.class);
+ skipConfigurationCheck = getDockerMySQLCallback(annot).skipConfigurationCheck();
+ customUrlKey = getDockerMySQLCallback(annot).customUrlKey();
+ targetConfigName = getDockerMySQLCallback(annot).targetConfigName();
+ targetFileName = getDockerMySQLCallback(annot).targetFileName();
+ adapterProfileFallback = getDockerMySQLCallback(annot).adapterProfileFallback();
+ } else if (annot instanceof DockerPostGresCallback) {
+ log.warn("found and get: {}", DockerPostGresCallback.class);
+ skipConfigurationCheck = getDockerPostGresCallback(annot).skipConfigurationCheck();
+ customUrlKey = getDockerPostGresCallback(annot).customUrlKey();
+ targetConfigName = getDockerPostGresCallback(annot).targetConfigName();
+ targetFileName = getDockerPostGresCallback(annot).targetFileName();
+ adapterProfileFallback = getDockerPostGresCallback(annot).adapterProfileFallback();
+ }
+ }
+ //Class<?> clazz = context.getRequiredTestClass();
+ //DockerMySQLCallback dockerCallback = clazz.getAnnotation(DockerMySQLCallback.class );
+ //Annotation dockerCallback = (Annotation) context.getStore(Namespace.GLOBAL).get("annotatedClass");
+ init(context);
+ }
+
+ public DockerMySQLCallback getDockerMySQLCallback(Annotation annot) {
+ return (DockerMySQLCallback)annot;
}
+ public DockerPostGresCallback getDockerPostGresCallback(Annotation annot) {
+ return (DockerPostGresCallback)annot;
+ }
+
@Override
public void beforeTestExecution(ExtensionContext context) throws Exception {
// log.info("starting call test context "+ context);
}
-
- private void init(ExtensionContext context)
+
+ protected void init(ExtensionContext context)
throws TorqueException, UnsupportedOperationException, IOException, InterruptedException {
- log.info("Starting from dockerfile: {}", DOCKERFILE);
- // before torque init
- MY_SQL_CONTAINER.setStartupAttempts(3);
- startDatabaseContainer();
+
// TODO do resource filtering and read from properties
String filePath = System.getProperty(TORQUE_WRAPPER_CONFIG_SYSTEM_PROPERTY);
if (filePath == null) {
@@ -130,10 +157,11 @@ public class DockerCallbackExtension imp
log.warn("Could not resolve system env/property: {}, using default: {}",
TORQUE_WRAPPER_CONFIG_SYSTEM_PROPERTY, filePath);
}
+ log.info("resolved filePath: {}", filePath);
File targetFile = new File(filePath);
Path torqueConfBase = Paths.get(targetFile.toURI()).getParent();
- if (!getSkipConfigurationCheck(context)) {
+ if (!skipConfigurationCheck ) {
CombinedConfigurationBuilder combinedBuilder = new CombinedConfigurationBuilder()
.configure(new Parameters().fileBased()
.setFileName(filePath)
@@ -141,64 +169,36 @@ public class DockerCallbackExtension imp
);
try {
CombinedConfiguration cc = combinedBuilder.getConfiguration();
- String targetConfigName = getTargetConfigName(context);
PropertiesConfiguration innerConfRef = (PropertiesConfiguration) cc.getConfiguration(targetConfigName);
assertTrue(innerConfRef != null, "Could not locate target configuration with config-namen: " + targetConfigName);
} catch (ConfigurationException e) {
log.error(e.getMessage(), e);
}
}
- String fileName = getTargetFileName(context);
- String customUrlKey = getCustomUrlKey(context);
- updateTorque(torqueConfBase, fileName, customUrlKey);
+ String jdbcConnectionString = (String) context.getStore(Namespace.GLOBAL).get("jdbcConnectionString");
+ updateTorque(torqueConfBase, targetFileName, customUrlKey, jdbcConnectionString);
- synchronized (DockerCallbackExtension.class) {
+ synchronized (DockerCallbackExtension2.class) {
if (!Torque.isInit()) {
Torque.init(filePath);
}
}
defaultAdapter = Torque.getDatabase(Torque.getDefaultDB()).getAdapter();
log.info("using adapter: {}", defaultAdapter);
+ context.getStore(Namespace.GLOBAL).put("adapter", defaultAdapter);
}
- private String getDefaultTestProfileFallback(ExtensionContext context) {
- Class<?> clazz = context.getRequiredTestClass();
- DockerCallback dockerCallback = clazz.getAnnotation(DockerCallback.class);
- String adapterProfile = dockerCallback.adapterProfileFallback();
- if (adapterProfile == null) {
- adapterProfile = "mysql";
+ private String getDefaultTestProfileFallback( ExtensionContext context ) {
+ if (adapterProfileFallback == null) {
+ throw new AnnotationFormatError("No profile is set. Set it in annotation DockerCallback with adapterProfileFallback" );
}
- return String.format(DEFAULT_TEST_PROFILE_TORQUE4_TEST_XML, adapterProfile);
- }
-
- private String getCustomUrlKey(ExtensionContext context) {
- Class<?> clazz = context.getRequiredTestClass();
- DockerCallback dockerCallback = clazz.getAnnotation(DockerCallback.class);
- return dockerCallback.customUrlKey();
- }
-
- private String getTargetConfigName(ExtensionContext context) {
- Class<?> clazz = context.getRequiredTestClass();
- DockerCallback dockerCallback = clazz.getAnnotation(DockerCallback.class);
- return dockerCallback.targetConfigName();
- }
-
- private String getTargetFileName(ExtensionContext context) {
- Class<?> clazz = context.getRequiredTestClass();
- DockerCallback dockerCallback = clazz.getAnnotation(DockerCallback.class);
- return dockerCallback.targetFileName();
+ return String.format(DEFAULT_TEST_PROFILE_TORQUE4_TEST_XML, adapterProfileFallback);
}
- private boolean getSkipConfigurationCheck(ExtensionContext context) {
- Class<?> clazz = context.getRequiredTestClass();
- DockerCallback dockerCallback = clazz.getAnnotation(DockerCallback.class);
- return dockerCallback.skipConfigurationCheck();
- }
-
- private static void updateTorque(Path torqueConfBase, String fileName, String customUrlKey) {
+
+ private void updateTorque(Path torqueConfBase, String fileName, String customUrlKey, String jdbcConnectionString) {
try {
- String jdbcConnectionString = generateJdbcUrl();
String customUrl = customUrlKey+"=" + jdbcConnectionString;
// override and set mapped port in url, which is known only at runtime.
File file = torqueConfBase.resolve(fileName).toFile();
@@ -214,33 +214,4 @@ public class DockerCallbackExtension imp
}
}
- private static void startDatabaseContainer() {
- if (!MY_SQL_CONTAINER.isRunning()) {
- MY_SQL_CONTAINER.waitingFor(Wait.forListeningPort());
- MY_SQL_CONTAINER.start();
- }
- }
-
- /**
- *
- * @returns the JDBC string with mapped port binding
- */
- private static String generateJdbcUrl() {
- startDatabaseContainer();
- if (!MY_SQL_CONTAINER.isRunning()) {
- throw new RuntimeException("Could not find RUNNING database container");
- }
-
- // MY_SQL_CONTAINER.withCreateContainerCmdModifier(modifier) //
- String serviceHost = MY_SQL_CONTAINER.getContainerIpAddress();
- Integer mappedPort = MY_SQL_CONTAINER.getMappedPort(SERVICE_PORT);// e.g. 32811
- log.info("generate jdbc url from {}, mapped Port: {}, bounded port: {}", serviceHost, mappedPort,
- MY_SQL_CONTAINER.getBoundPortNumbers());
-
- String targetJDBC = // genJDBC;
- String.format("jdbc:mysql://%s:%d/%s?loggerLevel=OFF", serviceHost, mappedPort, DATABASE_NAME);
- log.info("used connect url: {}", targetJDBC);
- return targetJDBC;
- }
-
}
Added: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerCallbackMySQLExtension.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerCallbackMySQLExtension.java?rev=1871864&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerCallbackMySQLExtension.java (added)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerCallbackMySQLExtension.java Fri Dec 20 15:17:46 2019
@@ -0,0 +1,124 @@
+package org.apache.torque.testcontainer.junit5.extension;
+
+
+import static org.junit.jupiter.api.extension.ConditionEvaluationResult.enabled;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.torque.TorqueException;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.extension.BeforeAllCallback;
+import org.junit.jupiter.api.extension.BeforeTestExecutionCallback;
+import org.junit.jupiter.api.extension.ConditionEvaluationResult;
+import org.junit.jupiter.api.extension.ExecutionCondition;
+import org.junit.jupiter.api.extension.ExtensionContext;
+import org.junit.jupiter.api.extension.ExtensionContext.Namespace;
+import org.testcontainers.containers.GenericContainer;
+import org.testcontainers.containers.wait.strategy.Wait;
+import org.testcontainers.images.builder.ImageFromDockerfile;
+import org.testcontainers.junit.jupiter.Container;
+import org.testcontainers.junit.jupiter.Testcontainers;
+
+/**
+ * Testcontainer configuration
+ *
+ * @author gk
+ *
+ */
+@Testcontainers
+public class DockerCallbackMySQLExtension implements BeforeAllCallback, BeforeTestExecutionCallback, ExecutionCondition {
+
+ private static Logger log = LogManager.getLogger();
+
+ private static int SERVICE_PORT = 3306;
+
+ protected static String DATABASE_NAME = "bookstore";
+
+ // copied from src/test/profile/mysql/docker-resources/db/
+ protected static final String DOCKERFILE = "./target/Dockerfile";
+
+ protected static final ConditionEvaluationResult ENABLED_BY_DEFAULT = enabled(
+ "DockerCallbackExtension is enabled by default - checking internal state only");
+
+ @Container
+ public static GenericContainer DATABASE_CONTAINER = new GenericContainer<>(
+ new ImageFromDockerfile().withDockerfile(new File(DOCKERFILE).toPath())).withExposedPorts(SERVICE_PORT)
+ .withEnv("MYSQL_DATABASE", DATABASE_NAME).withEnv("MYSQL_USER", "torque")
+ .withEnv("MYSQL_PASSWORD", "torque").withEnv("MYSQL_ROOT_PASSWORD", "torque");
+
+
+ public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) {
+ String actual = System.getProperty("torque.callback");
+ if (actual == null) {
+ actual = System.getenv("torque.callback");
+ }
+ if (actual != null && actual.matches("docker")) {
+ }
+ return ENABLED_BY_DEFAULT;
+ }
+
+ @Override
+ public void beforeTestExecution(ExtensionContext context) throws Exception {
+ // log.info("starting call test context "+ context);
+ }
+
+ /**
+ * Should be called first
+ * @see BeforeAll
+ */
+ public void beforeAll(ExtensionContext context) throws Exception {
+ // log.info("starting call context "+ context);
+ dbInit(context);
+ String jdbcConnectionString = generateJdbcUrl();
+ context.getStore(Namespace.GLOBAL).put("jdbcConnectionString", jdbcConnectionString);
+ context.getStore(Namespace.GLOBAL).put("container", DATABASE_CONTAINER);
+ Class<?> clazz = context.getRequiredTestClass();
+ DockerMySQLCallback dockerCallback = clazz.getAnnotation(DockerMySQLCallback.class );
+ context.getStore(Namespace.GLOBAL).put("annotatedClass", dockerCallback);
+ }
+
+
+ private void dbInit(ExtensionContext context)
+ throws TorqueException, UnsupportedOperationException, IOException, InterruptedException {
+ log.info("Starting from dockerfile: {}", DOCKERFILE);
+ // before torque init
+ DATABASE_CONTAINER.setStartupAttempts(3);
+ startDatabaseContainer();
+
+ }
+
+ private static void startDatabaseContainer() {
+ if (!DATABASE_CONTAINER.isRunning()) {
+ DATABASE_CONTAINER.waitingFor(Wait.forListeningPort());
+ DATABASE_CONTAINER.start();
+ }
+ if (!DATABASE_CONTAINER.isRunning()) {
+ throw new RuntimeException("Could not find RUNNING database container");
+ }
+ }
+
+ /**
+ *
+ * @returns the JDBC string with mapped port binding
+ */
+ private static String generateJdbcUrl() {
+ startDatabaseContainer();
+ if (!DATABASE_CONTAINER.isRunning()) {
+ throw new RuntimeException("Could not find RUNNING database container");
+ }
+ // MY_SQL_CONTAINER.withCreateContainerCmdModifier(modifier) //
+ String serviceHost = DATABASE_CONTAINER.getContainerIpAddress();
+ Integer mappedPort = DATABASE_CONTAINER.getMappedPort(SERVICE_PORT);// e.g. 32811
+ log.info("generate jdbc url from {}, mapped Port: {}, bounded port: {}", serviceHost, mappedPort,
+ DATABASE_CONTAINER.getBoundPortNumbers());
+
+ String targetJDBC = // genJDBC;
+ String.format("jdbc:mysql://%s:%d/%s?loggerLevel=OFF", serviceHost, mappedPort, DATABASE_NAME);
+ log.info("used connect url: {}", targetJDBC);
+ return targetJDBC;
+ }
+
+}
Propchange: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerCallbackMySQLExtension.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerCallbackPostgreSQLExtension.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerCallbackPostgreSQLExtension.java?rev=1871864&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerCallbackPostgreSQLExtension.java (added)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerCallbackPostgreSQLExtension.java Fri Dec 20 15:17:46 2019
@@ -0,0 +1,121 @@
+package org.apache.torque.testcontainer.junit5.extension;
+
+
+import static org.junit.jupiter.api.extension.ConditionEvaluationResult.enabled;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.torque.TorqueException;
+import org.junit.jupiter.api.extension.BeforeAllCallback;
+import org.junit.jupiter.api.extension.BeforeTestExecutionCallback;
+import org.junit.jupiter.api.extension.ConditionEvaluationResult;
+import org.junit.jupiter.api.extension.ExecutionCondition;
+import org.junit.jupiter.api.extension.ExtensionContext;
+import org.junit.jupiter.api.extension.ExtensionContext.Namespace;
+import org.testcontainers.containers.GenericContainer;
+import org.testcontainers.containers.wait.strategy.Wait;
+import org.testcontainers.images.builder.ImageFromDockerfile;
+import org.testcontainers.junit.jupiter.Container;
+import org.testcontainers.junit.jupiter.Testcontainers;
+
+/**
+ * Testcontainer configuration
+ *
+ * @author gk
+ *
+ */
+@Testcontainers
+public class DockerCallbackPostgreSQLExtension implements BeforeAllCallback, BeforeTestExecutionCallback, ExecutionCondition {
+
+
+ private static Logger log = LogManager.getLogger();
+
+ private static int SERVICE_PORT = 5432;
+
+ protected static String DATABASE_NAME = "bookstore";
+
+ // copied from src/test/profile/mysql/docker-resources/db/
+ protected static final String DOCKERFILE = "./target/Dockerfile";
+
+ private static final ConditionEvaluationResult ENABLED_BY_DEFAULT = enabled(
+ "DockerCallbackExtension is enabled by default - checking internal state only");
+
+ @Container
+ public static GenericContainer DATABASE_CONTAINER = new GenericContainer<>(
+ new ImageFromDockerfile().withDockerfile(new File(DOCKERFILE).toPath())).withExposedPorts(SERVICE_PORT)
+ .withEnv("POSTGRES_DB", DATABASE_NAME).withEnv("POSTGRES_USER", "torque")
+ .withEnv("POSTGRES_PASSWORD", "torque");
+
+ @Override
+ public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) {
+ String actual = System.getProperty("torque.callback");
+ if (actual == null) {
+ actual = System.getenv("torque.callback");
+ }
+ if (actual != null && actual.matches("docker")) {
+ }
+ return ENABLED_BY_DEFAULT;
+ }
+
+
+ @Override
+ public void beforeAll(ExtensionContext context) throws Exception {
+ // log.info("starting call context "+ context);
+ dbInit(context);
+ String jdbcConnectionString = generateJdbcUrl();
+ context.getStore(Namespace.GLOBAL).put("jdbcConnectionString", jdbcConnectionString);
+ context.getStore(Namespace.GLOBAL).put("container", DATABASE_CONTAINER);
+ Class<?> clazz = context.getRequiredTestClass();
+ DockerMySQLCallback dockerCallback = clazz.getAnnotation(DockerMySQLCallback.class );
+ context.getStore(Namespace.GLOBAL).put("annotatedClass", dockerCallback);
+ }
+
+ @Override
+ public void beforeTestExecution(ExtensionContext context) throws Exception {
+ // log.info("starting call test context "+ context);
+ }
+
+ private void dbInit(ExtensionContext context)
+ throws TorqueException, UnsupportedOperationException, IOException, InterruptedException {
+ log.info("Starting from dockerfile: {}", DOCKERFILE);
+ // before torque init
+ DATABASE_CONTAINER.setStartupAttempts(3);
+ startDatabaseContainer();
+
+ }
+
+ private static void startDatabaseContainer() {
+ if (!DATABASE_CONTAINER.isRunning()) {
+ DATABASE_CONTAINER.waitingFor(Wait.forListeningPort());
+ DATABASE_CONTAINER.start();
+ }
+ if (!DATABASE_CONTAINER.isRunning()) {
+ throw new RuntimeException("Could not find RUNNING database container");
+ }
+ }
+
+ /**
+ *
+ * @returns the JDBC string with mapped port binding
+ */
+ private static String generateJdbcUrl() {
+ startDatabaseContainer();
+ if (!DATABASE_CONTAINER.isRunning()) {
+ throw new RuntimeException("Could not find RUNNING database container");
+ }
+
+ String serviceHost = DATABASE_CONTAINER.getContainerIpAddress();
+ Integer mappedPort = DATABASE_CONTAINER.getMappedPort(SERVICE_PORT);// e.g. 32811
+ log.info("generate jdbc url from {}, mapped Port: {}, bounded port: {}", serviceHost, mappedPort,
+ DATABASE_CONTAINER.getBoundPortNumbers());
+
+ String targetJDBC = // genJDBC;
+ String.format("jdbc:postgresql://%s:%d/%s", serviceHost, mappedPort, DATABASE_NAME);
+ log.info("used connect url: {}", targetJDBC);
+ return targetJDBC;
+ }
+
+}
Propchange: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerCallbackPostgreSQLExtension.java
------------------------------------------------------------------------------
svn:eol-style = native
Copied: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerMySQLCallback.java (from r1870878, db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerCallback.java)
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerMySQLCallback.java?p2=db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerMySQLCallback.java&p1=db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerCallback.java&r1=1870878&r2=1871864&rev=1871864&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerCallback.java (original)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerMySQLCallback.java Fri Dec 20 15:17:46 2019
@@ -27,7 +27,7 @@ import java.lang.annotation.Target;
import org.apache.torque.junit5.extension.AdapterParameterResolver;
import org.junit.jupiter.api.Tag;
-
+import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.testcontainers.junit.jupiter.Testcontainers;
@@ -41,18 +41,19 @@ import org.testcontainers.junit.jupiter.
*
*/
// may have ParameterizedTest in test class -> Possible configuration error
-@Tag("DockerCallback")
+@Tag("DockerMySQLCallback")
@Inherited
+//@DockerCallback2(adapterProfileFallback="mysql")
@Target( { ElementType.TYPE, ElementType.METHOD, ElementType.ANNOTATION_TYPE } )
@Retention(RetentionPolicy.RUNTIME)
-@ExtendWith(DockerCallbackExtension.class)
@ExtendWith(AdapterParameterResolver.class)
-//@EnabledIfEnvironmentVariable(named = "torque.callback", matches = "docker")
-public @interface DockerCallback {
- String value() default "";
+@ExtendWith(DockerCallbackMySQLExtension.class)
+public @interface DockerMySQLCallback {
- String adapterProfileFallback() default "hsqldb";
+ String value() default "";
+ String adapterProfileFallback() default "mysql";
+
String customUrlKey() default "torque.dsfactory.bookstore.connection.url";
String targetConfigName() default "torqueuser";
@@ -61,5 +62,4 @@ public @interface DockerCallback {
boolean skipConfigurationCheck() default false;
-
}
Added: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerPostGresCallback.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerPostGresCallback.java?rev=1871864&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerPostGresCallback.java (added)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerPostGresCallback.java Fri Dec 20 15:17:46 2019
@@ -0,0 +1,65 @@
+package org.apache.torque.testcontainer.junit5.extension;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import org.apache.torque.junit5.extension.AdapterParameterResolver;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.testcontainers.junit.jupiter.Testcontainers;
+
+/**
+ * {@code @DockerCallback} is used to signal that the annotated test class or
+ * test method is using Docker {@link Testcontainers} and Torque initialized accordingly.
+ *
+ * It is currently enabled by overridign the default
+ *
+ * @author gkallidis
+ *
+ */
+// may have ParameterizedTest in test class -> Possible configuration error
+@Tag("DockerPostGresCallback")
+@Inherited
+//@DockerCallback2(adapterProfileFallback="mysql")
+@Target( { ElementType.TYPE, ElementType.METHOD, ElementType.ANNOTATION_TYPE } )
+@Retention(RetentionPolicy.RUNTIME)
+@ExtendWith(AdapterParameterResolver.class)
+@ExtendWith(DockerCallbackPostgreSQLExtension.class)
+public @interface DockerPostGresCallback {
+
+ String value() default "";
+
+ String adapterProfileFallback() default "postgresql";
+
+ String customUrlKey() default "torque.dsfactory.bookstore.connection.url";
+
+ String targetConfigName() default "torqueuser";
+
+ String targetFileName() default "torque.usersettings.properties";
+
+ boolean skipConfigurationCheck() default false;
+
+}
Propchange: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerPostGresCallback.java
------------------------------------------------------------------------------
svn:eol-style = native
Copied: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/mysql/BeanConditionalContainerTest.java (from r1870878, db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/BeanConditionalContainerTest.java)
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/mysql/BeanConditionalContainerTest.java?p2=db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/mysql/BeanConditionalContainerTest.java&p1=db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/BeanConditionalContainerTest.java&r1=1870878&r2=1871864&rev=1871864&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/BeanConditionalContainerTest.java (original)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/mysql/BeanConditionalContainerTest.java Fri Dec 20 15:17:46 2019
@@ -1,4 +1,4 @@
-package org.apache.torque.testcontainer;
+package org.apache.torque.testcontainer.mysql;
/*
* Licensed to the Apache Software Foundation (ASF) under one
Copied: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/mysql/DataContainerTest.java (from r1870878, db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/DataContainerTest.java)
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/mysql/DataContainerTest.java?p2=db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/mysql/DataContainerTest.java&p1=db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/DataContainerTest.java&r1=1870878&r2=1871864&rev=1871864&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/DataContainerTest.java (original)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/mysql/DataContainerTest.java Fri Dec 20 15:17:46 2019
@@ -1,4 +1,4 @@
-package org.apache.torque.testcontainer;
+package org.apache.torque.testcontainer.mysql;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -20,7 +20,9 @@ package org.apache.torque.testcontainer;
*/
import org.apache.torque.DataTest;
-import org.apache.torque.testcontainer.junit5.extension.DockerCallback;
+import org.apache.torque.testcontainer.junit5.extension.DockerCallbackExtension2;
+import org.apache.torque.testcontainer.junit5.extension.DockerMySQLCallback;
+import org.junit.jupiter.api.extension.RegisterExtension;
/**
* Docker adapter tests.
@@ -28,8 +30,13 @@ import org.apache.torque.testcontainer.j
* @author <a href="mailto:[email protected]">Georg Kallidis</a>
* @version $Id: DataTest.java 1869081 2019-10-28 16:17:11Z gk $
*/
-@DockerCallback(adapterProfileFallback="mysql")
+@DockerMySQLCallback
public class DataContainerTest extends DataTest
{
+ /**
+ * statically registered extensions are registered after extendwith extensions
+ */
+ @RegisterExtension
+ static DockerCallbackExtension2 dce = new DockerCallbackExtension2();
}
Copied: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/mysql/ManagerConditionalContainerTest.java (from r1870878, db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/ManagerConditionalContainerTest.java)
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/mysql/ManagerConditionalContainerTest.java?p2=db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/mysql/ManagerConditionalContainerTest.java&p1=db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/ManagerConditionalContainerTest.java&r1=1870878&r2=1871864&rev=1871864&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/ManagerConditionalContainerTest.java (original)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/mysql/ManagerConditionalContainerTest.java Fri Dec 20 15:17:46 2019
@@ -1,4 +1,4 @@
-package org.apache.torque.testcontainer;
+package org.apache.torque.testcontainer.mysql;
/*
* Licensed to the Apache Software Foundation (ASF) under one
Added: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/postgresql/DataContainerTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/postgresql/DataContainerTest.java?rev=1871864&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/postgresql/DataContainerTest.java (added)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/postgresql/DataContainerTest.java Fri Dec 20 15:17:46 2019
@@ -0,0 +1,42 @@
+package org.apache.torque.testcontainer.postgresql;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.torque.DataTest;
+import org.apache.torque.testcontainer.junit5.extension.DockerCallbackExtension2;
+import org.apache.torque.testcontainer.junit5.extension.DockerPostGresCallback;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+/**
+ * Docker adapter tests.
+ *
+ * @author <a href="mailto:[email protected]">Georg Kallidis</a>
+ * @version $Id: DataTest.java 1869081 2019-10-28 16:17:11Z gk $
+ */
+@DockerPostGresCallback
+public class DataContainerTest extends DataTest
+{
+ /**
+ * statically registered extensions are registered after extendwith extensions
+ */
+ @RegisterExtension
+ static DockerCallbackExtension2 dce = new DockerCallbackExtension2();
+
+}
Propchange: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/postgresql/DataContainerTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: db/torque/torque4/trunk/torque-test/src/test/profile/postgresql/Torque4Test.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/profile/postgresql/Torque4Test.xml?rev=1871864&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/profile/postgresql/Torque4Test.xml (added)
+++ db/torque/torque4/trunk/torque-test/src/test/profile/postgresql/Torque4Test.xml Fri Dec 20 15:17:46 2019
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<!-- from the docs: CombinedConfigurationBuilder takes care that properties defined in the first file (the user file) are found; other properties which the user has not changed will still be returned from the second file (the defaults file). -->
+
+<configuration>
+ <properties config-name="torqueuser" fileName="torque.usersettings.properties" config-optional="true" config-forceCreate="true"/>
+ <properties config-name="torque" fileName="Torque.properties" throwExceptionOnMissing="true"/>
+</configuration>
\ No newline at end of file
Propchange: db/torque/torque4/trunk/torque-test/src/test/profile/postgresql/Torque4Test.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: db/torque/torque4/trunk/torque-test/src/test/profile/postgresql/docker-resources/db/.dockerignore
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/profile/postgresql/docker-resources/db/.dockerignore?rev=1871864&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/profile/postgresql/docker-resources/db/.dockerignore (added)
+++ db/torque/torque4/trunk/torque-test/src/test/profile/postgresql/docker-resources/db/.dockerignore Fri Dec 20 15:17:46 2019
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+*/tmp*
+*/*/tmp*
+tmp?
\ No newline at end of file
Added: db/torque/torque4/trunk/torque-test/src/test/profile/postgresql/docker-resources/db/Dockerfile
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/profile/postgresql/docker-resources/db/Dockerfile?rev=1871864&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/profile/postgresql/docker-resources/db/Dockerfile (added)
+++ db/torque/torque4/trunk/torque-test/src/test/profile/postgresql/docker-resources/db/Dockerfile Fri Dec 20 15:17:46 2019
@@ -0,0 +1,24 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+FROM postgres:12.1
+
+COPY [ "./generated-createddb-sql/*", "./generated-sql/*", "/docker-entrypoint-initdb.d/" ]
+
+ENV POSTGRES_DB ${POSTGRES_DB}
+ENV POSTGRES_USER=${POSTGRES_USER}
+ENV POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
Added: db/torque/torque4/trunk/torque-test/src/test/profile/postgresql/docker-resources/docker-java.properties.template
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/profile/postgresql/docker-resources/docker-java.properties.template?rev=1871864&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/profile/postgresql/docker-resources/docker-java.properties.template (added)
+++ db/torque/torque4/trunk/torque-test/src/test/profile/postgresql/docker-resources/docker-java.properties.template Fri Dec 20 15:17:46 2019
@@ -0,0 +1,35 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# This file should contain the environment variables as
+# further info here: https://www.testcontainers.org/supported_docker_environment/
+
+# UNIX by default uses unix sockets
+#DOCKER_HOST=unix:///var/run/docker.sock
+# to override default
+#DOCKER_TLS_VERIFY=0
+
+# WINDOWS uses external network, use only secure connection
+# docker.io might use username and password encrypted in ~/.docker/config.json
+# use result of 'docker-machine env <nameOfVirtualMachine>'
+#DOCKER_TLS_VERIFY=1
+#DOCKER_HOST=tcp://<hostip>:2376
+#DOCKER_CERT_PATH=<path-to-cert>
+#DOCKER_MACHINE_NAME=nameofvirtualmachine (e.g. type virtualbox in Windows 7 or hyperv in Windows 10)
+#COMPOSE_CONVERT_WINDOWS_PATHS=true
+
+#api.version=1.39
Added: db/torque/torque4/trunk/torque-test/src/test/profile/postgresql/docker-resources/testcontainers.properties
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/profile/postgresql/docker-resources/testcontainers.properties?rev=1871864&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/profile/postgresql/docker-resources/testcontainers.properties (added)
+++ db/torque/torque4/trunk/torque-test/src/test/profile/postgresql/docker-resources/testcontainers.properties Fri Dec 20 15:17:46 2019
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# windows workaround, should have more than 2GB free disk space
+checks.disable = true
\ No newline at end of file
Propchange: db/torque/torque4/trunk/torque-test/src/test/profile/postgresql/docker-resources/testcontainers.properties
------------------------------------------------------------------------------
svn:eol-style = native
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.