svn commit: r1872432 - in /db/torque/torque4/trunk/torque-test: ./ src/test/java/org/apache/torque/ src/test/java/org/apache/torque/testcontainer/junit5/extension/ src/test/java/org/apache/torque/testcontainer/mysql/ src/test/java/org/apache/torque/tes...

[email protected]
Newsgroups gmane.comp.jakarta.turbine.torque.devel
Message-ID <[email protected]>
Author: gk
Date: Tue Jan  7 10:52:41 2020
New Revision: 1872432

URL: http://svn.apache.org/viewvc?rev=1872432&view=rev
Log:
- use log4j2-slf4j bridge in postgresql testcontainer, pom.xml
- fix Dockerfile postgrsql
- update Mysql dockerfile with init-idtable
- remove old DockerCallbackExtension, rename DockerCallbackExtension2
- separate database specific annotaton coupling from DockerCallbackExtension.
- add tests for postgresql (no JUNIT 5 support for suite, see on github issue junit5#744.
- update log4j2-test.xml

Added:
    db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerCallbackExtension.java
      - copied, changed from r1872431, db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerCallbackExtension2.java
    db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/postgresql/BeanConditionalContainerTest.java   (with props)
    db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/postgresql/ManagerConditionalContainerTest.java   (with props)
Removed:
    db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerCallbackExtension2.java
Modified:
    db/torque/torque4/trunk/torque-test/pom.xml
    db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/BaseDatabaseTestCase.java
    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/DockerCallbackMySQLExtension.java
    db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerCallbackPostgreSQLExtension.java
    db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/mysql/BeanConditionalContainerTest.java
    db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/mysql/DataContainerTest.java
    db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/mysql/ManagerConditionalContainerTest.java
    db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/postgresql/DataContainerTest.java
    db/torque/torque4/trunk/torque-test/src/test/profile/mysql/docker-resources/db/Dockerfile
    db/torque/torque4/trunk/torque-test/src/test/profile/postgresql/docker-resources/db/Dockerfile
    db/torque/torque4/trunk/torque-test/src/test/resources/log4j2-test.xml

Modified: db/torque/torque4/trunk/torque-test/pom.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/pom.xml?rev=1872432&r1=1872431&r2=1872432&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/pom.xml (original)
+++ db/torque/torque4/trunk/torque-test/pom.xml Tue Jan  7 10:52:41 2020
@@ -54,7 +54,7 @@
     <torque.test.hsqldb.version>2.3.1</torque.test.hsqldb.version><!-- 2.5.0 as of june 2019 -->
     <torque.test.mssql.version>1.2.7</torque.test.mssql.version>
     <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.log4j2.version>2.12.1</torque.test.log4j2.version>
     <torque.test.oracle.version>10.2.0.3.0</torque.test.oracle.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>
@@ -951,6 +951,7 @@
         <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 properties are used in docker profile only -->
         <docker.database.port>3306</docker.database.port>
         <docker.image.name>mysql</docker.image.name>
         <docker.image.version>${torque.test.mysql.version}</docker.image.version>
@@ -969,7 +970,7 @@
         <dependency>
           <groupId>org.apache.logging.log4j</groupId>
           <artifactId>log4j-slf4j-impl</artifactId>
-          <version>${torque.test.mysql.log4j2.version}</version>
+          <version>${torque.test.log4j2.version}</version>
           <scope>runtime</scope>
         </dependency>
          <dependency>
@@ -1150,6 +1151,7 @@
         <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 properties are used in docker profile only -->
         <docker.database.port>5432</docker.database.port>
         <docker.image.name>postgres</docker.image.name>
         <docker.image.version>${torque.test.postgres.version}</docker.image.version>
@@ -1164,6 +1166,12 @@
           <version>${torque.test.postgres.jdbc.version}</version>
           <scope>test</scope>
         </dependency>
+         <dependency>
+          <groupId>org.apache.logging.log4j</groupId>
+          <artifactId>log4j-slf4j-impl</artifactId>
+          <version>${torque.test.log4j2.version}</version>
+          <scope>runtime</scope>
+        </dependency>
         <dependency>
             <groupId>org.testcontainers</groupId>
             <artifactId>postgresql</artifactId>
@@ -1198,15 +1206,18 @@
       </build>
     </profile>
     <!--  
-    todo: add docker profiles for postgresql, ...
+    
+    todo: add docker profiles for more databases,...
+    
     mvn -Pmysql,docker-testcontainer,managers,beans clean test
+    
     be careful to run test with @DockerCallback:
     
     mvnDebug -Pmysql,docker-testcontainer,managers,beans clean test -Dtest=DataContainerTest#testLikeClauseEscaping
     
     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
-    
+        
     -->
     <profile>
       <id>docker-testcontainer</id>
@@ -1215,7 +1226,9 @@
       </activation>
       <build>
         <plugins>
-            <!-- requires a started docker host - starts database for sql-maven-plugin.
+            <!-- 
+            Build image:
+            requires a started docker host - starts database for sql-maven-plugin.
             caution: Cancelling the maven process before life cycle process-classes is reached, the docker has to be stopped manually, docker stop <id>.
             -->
             <plugin>
@@ -1369,6 +1382,8 @@
                      <include>**/testcontainer/${torque.test.profileDirectory}/**</include>
                 </includes>
                 <!--groups>DockerCallback</groups-->
+                 <forkCount>0</forkCount>
+                 <reuseForks>false</reuseForks>
               </configuration>
               <executions>
                 <execution>

Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/BaseDatabaseTestCase.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/BaseDatabaseTestCase.java?rev=1872432&r1=1872431&r2=1872432&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/BaseDatabaseTestCase.java (original)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/BaseDatabaseTestCase.java Tue Jan  7 10:52:41 2020
@@ -46,7 +46,6 @@ import org.apache.torque.util.CountHelpe
  * @author <a href="mailto:[email protected]">Scott Eade</a>
  * @version $Id$
  */
-//@HostCallback(adapterProfile ="mysql")
 @HostCallback
 public abstract class BaseDatabaseTestCase  
 {

Modified: 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/DockerCallback.java?rev=1872432&r1=1872431&r2=1872432&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/DockerCallback.java Tue Jan  7 10:52:41 2020
@@ -45,21 +45,19 @@ import org.testcontainers.junit.jupiter.
 @Inherited
 @Target( { ElementType.TYPE, ElementType.METHOD, ElementType.ANNOTATION_TYPE } )
 @Retention(RetentionPolicy.RUNTIME)
-@ExtendWith(DockerCallbackExtension.class)
+//@ExtendWith(DockerCallbackExtension.class)
 @ExtendWith(AdapterParameterResolver.class)
-//@EnabledIfEnvironmentVariable(named = "torque.callback", matches = "docker")
 public @interface DockerCallback {
     String value() default "";
     
     String adapterProfileFallback() default "hsqldb";
-    
+ 
     String customUrlKey() default "torque.dsfactory.bookstore.connection.url";
-    
+
     String targetConfigName() default "torqueuser";
-    
+
     String targetFileName() default "torque.usersettings.properties";
-    
+  
     boolean skipConfigurationCheck() default false;
     
-    
 }

Copied: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerCallbackExtension.java (from r1872431, db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerCallbackExtension2.java)
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerCallbackExtension.java?p2=db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerCallbackExtension.java&p1=db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerCallbackExtension2.java&r1=1872431&r2=1872432&rev=1872432&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerCallbackExtension2.java (original)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerCallbackExtension.java Tue Jan  7 10:52:41 2020
@@ -57,7 +57,7 @@ import org.junit.jupiter.api.extension.E
  *
  */
 
-public class DockerCallbackExtension2 /*extends DockerCallbackMySQLExtension*/ implements BeforeAllCallback, BeforeTestExecutionCallback, ExecutionCondition {
+public class DockerCallbackExtension implements BeforeAllCallback, BeforeTestExecutionCallback, ExecutionCondition {
 
     protected static final String DEFAULT_TEST_PROFILE_TORQUE4_TEST_XML = "src/test/profile/%s/Torque4Test.xml";
 
@@ -68,24 +68,24 @@ public class DockerCallbackExtension2 /*
     protected static int SERVICE_PORT = 3306;
     protected static Adapter defaultAdapter;
     
-    String adapterProfileFallback;
+    private String adapterProfileFallback;
     
-    String customUrlKey;
+    private String customUrlKey;
     
-    String targetConfigName;
+    private String targetConfigName;
     
-    String targetFileName;
+    private String targetFileName;
     
     boolean skipConfigurationCheck = false;
     
     protected static final ConditionEvaluationResult ENABLED_BY_DEFAULT = enabled(
             "DockerCallbackExtension is enabled by default - checking internal state only");
     
-    public DockerCallbackExtension2() {
+    public DockerCallbackExtension() {
      
     }
     
-    public DockerCallbackExtension2(String adapterProfileFallback)  {
+    public DockerCallbackExtension(String adapterProfileFallback)  {
         this.adapterProfileFallback =adapterProfileFallback;
     }
     
@@ -100,50 +100,38 @@ public class DockerCallbackExtension2 /*
     }
  
     /**
-     * calls first super{@link #beforeAll(ExtensionContext)}
+     * calls first super {@link #beforeAll(ExtensionContext)}
      * 
      * @see BeforeAll
      */
     public void beforeAll(ExtensionContext context) throws Exception {
         Annotation[] annots = context.getTestClass().get().getAnnotations();
+        log.info("found and get context.getElement(): {}", context.getElement());
         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();
+            if (annot instanceof DockerCallback) {
+                log.warn("using annotation: {}",annot);
+                setAdapterProfileFallback(getDockerCallback(annot).adapterProfileFallback());
+                setSkipConfigurationCheck(getDockerCallback(annot).skipConfigurationCheck());
+                setCustomUrlKey(getDockerCallback(annot).customUrlKey());
+                setTargetConfigName(getDockerCallback(annot).targetConfigName());
+                setTargetFileName(getDockerCallback(annot).targetFileName());
+                //torqueInit(context);
             }
-        }
-        //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;
+    public DockerCallback getDockerCallback(Annotation annot) {
+        return (DockerCallback)annot;
     }
     
+    
     @Override
     public void beforeTestExecution(ExtensionContext context) throws Exception {
         // log.info("starting call test context "+ context);
     }
     
-    protected void init(ExtensionContext context)
+    protected void torqueInit(ExtensionContext context)
             throws TorqueException, UnsupportedOperationException, IOException, InterruptedException {
 
         // TODO do resource filtering and read from properties
@@ -178,7 +166,7 @@ public class DockerCallbackExtension2 /*
         String jdbcConnectionString = (String) context.getStore(Namespace.GLOBAL).get("jdbcConnectionString");
         updateTorque(torqueConfBase, targetFileName, customUrlKey, jdbcConnectionString);
 
-        synchronized (DockerCallbackExtension2.class) {
+        synchronized (DockerCallbackExtension.class) {
             if (!Torque.isInit()) {
                 Torque.init(filePath);
             }
@@ -214,4 +202,44 @@ public class DockerCallbackExtension2 /*
         }
     }
 
+    public String getAdapterProfileFallback() {
+        return adapterProfileFallback;
+    }
+
+    public void setAdapterProfileFallback(String adapterProfileFallback) {
+        this.adapterProfileFallback = adapterProfileFallback;
+    }
+
+    public String getCustomUrlKey() {
+        return customUrlKey;
+    }
+
+    public void setCustomUrlKey(String customUrlKey) {
+        this.customUrlKey = customUrlKey;
+    }
+
+    public String getTargetConfigName() {
+        return targetConfigName;
+    }
+
+    public void setTargetConfigName(String targetConfigName) {
+        this.targetConfigName = targetConfigName;
+    }
+
+    public String getTargetFileName() {
+        return targetFileName;
+    }
+
+    public void setTargetFileName(String targetFileName) {
+        this.targetFileName = targetFileName;
+    }
+
+    public boolean isSkipConfigurationCheck() {
+        return skipConfigurationCheck;
+    }
+
+    public void setSkipConfigurationCheck(boolean skipConfigurationCheck) {
+        this.skipConfigurationCheck = skipConfigurationCheck;
+    }
+
 }

Modified: 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=1872432&r1=1872431&r2=1872432&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerCallbackMySQLExtension.java (original)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerCallbackMySQLExtension.java Tue Jan  7 10:52:41 2020
@@ -35,6 +35,7 @@ import org.junit.jupiter.api.extension.E
 import org.junit.jupiter.api.extension.ExtensionContext;
 import org.junit.jupiter.api.extension.ExtensionContext.Namespace;
 import org.testcontainers.containers.GenericContainer;
+import org.testcontainers.containers.output.Slf4jLogConsumer;
 import org.testcontainers.containers.wait.strategy.Wait;
 import org.testcontainers.images.builder.ImageFromDockerfile;
 import org.testcontainers.junit.jupiter.Container;
@@ -47,7 +48,7 @@ import org.testcontainers.junit.jupiter.
  *
  */
 @Testcontainers
-public class DockerCallbackMySQLExtension implements BeforeAllCallback, BeforeTestExecutionCallback, ExecutionCondition {
+public class DockerCallbackMySQLExtension extends DockerCallbackExtension implements BeforeAllCallback, BeforeTestExecutionCallback, ExecutionCondition {
 
     private static Logger log = LogManager.getLogger();
 
@@ -66,6 +67,7 @@ public class DockerCallbackMySQLExtensio
             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");
+                    //.withLogConsumer(new Slf4jLogConsumer(log));;
 
 
     public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) {
@@ -88,14 +90,23 @@ public class DockerCallbackMySQLExtensio
      * @see BeforeAll
      */
     public void beforeAll(ExtensionContext context) throws Exception {
+        Class<?> clazz = context.getRequiredTestClass();
+        log.warn("found and get annotation : {}", (Object[] )context.getRequiredTestClass().getAnnotations());
+        DockerMySQLCallback dockerCallback = clazz.getAnnotation(DockerMySQLCallback.class);
+        setSkipConfigurationCheck(dockerCallback.skipConfigurationCheck());
+        setCustomUrlKey(dockerCallback.customUrlKey());
+        setTargetConfigName(dockerCallback.targetConfigName());
+        setTargetFileName(dockerCallback.targetFileName());
+        setAdapterProfileFallback(dockerCallback.adapterProfileFallback());
+        
         // 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);
+        
+        torqueInit(context);
     }
 
 

Modified: 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=1872432&r1=1872431&r2=1872432&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerCallbackPostgreSQLExtension.java (original)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/junit5/extension/DockerCallbackPostgreSQLExtension.java Tue Jan  7 10:52:41 2020
@@ -24,8 +24,6 @@ import static org.junit.jupiter.api.exte
 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;
@@ -33,7 +31,9 @@ import org.junit.jupiter.api.extension.C
 import org.junit.jupiter.api.extension.ExecutionCondition;
 import org.junit.jupiter.api.extension.ExtensionContext;
 import org.junit.jupiter.api.extension.ExtensionContext.Namespace;
+import org.slf4j.LoggerFactory;
 import org.testcontainers.containers.GenericContainer;
+import org.testcontainers.containers.output.Slf4jLogConsumer;
 import org.testcontainers.containers.wait.strategy.Wait;
 import org.testcontainers.images.builder.ImageFromDockerfile;
 import org.testcontainers.junit.jupiter.Container;
@@ -46,10 +46,9 @@ import org.testcontainers.junit.jupiter.
  *
  */
 @Testcontainers
-public class DockerCallbackPostgreSQLExtension implements BeforeAllCallback, BeforeTestExecutionCallback, ExecutionCondition {
+public class DockerCallbackPostgreSQLExtension extends DockerCallbackExtension implements BeforeAllCallback, BeforeTestExecutionCallback, ExecutionCondition {
 
-
-    private static Logger log = LogManager.getLogger();
+    private static org.slf4j.Logger log = LoggerFactory.getLogger(DockerCallbackPostgreSQLExtension.class);
 
     private static int SERVICE_PORT = 5432;
     
@@ -65,7 +64,7 @@ public class DockerCallbackPostgreSQLExt
     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");
+                    .withEnv("POSTGRES_PASSWORD", "torque").withLogConsumer(new Slf4jLogConsumer(log));
     
     @Override
     public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) {
@@ -82,13 +81,32 @@ public class DockerCallbackPostgreSQLExt
     @Override
     public void beforeAll(ExtensionContext context) throws Exception {
         // log.info("starting call context "+ context);
-        dbInit(context);
+        Class<?> clazz = context.getRequiredTestClass();
+        log.warn("found and get annotation : {}", (Object[] )context.getRequiredTestClass().getAnnotations());
+        DockerPostGresCallback dockerCallback = clazz.getAnnotation(DockerPostGresCallback.class);
+        if (dockerCallback != null) {
+            log.warn("using annotation: {}",dockerCallback);
+            setSkipConfigurationCheck(dockerCallback.skipConfigurationCheck());
+            setCustomUrlKey(dockerCallback.customUrlKey());
+            setTargetConfigName(dockerCallback.targetConfigName());
+            setTargetFileName(dockerCallback.targetFileName());
+            setAdapterProfileFallback(dockerCallback.adapterProfileFallback());
+        } else {
+            super.beforeAll(context);
+        }
+        try {
+            dbInit(context);
+        } catch (Exception e) {
+            final String logs = DATABASE_CONTAINER.getLogs();
+            log.info("fetched container logs: {} ", logs);
+            throw e;
+        }
         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);
+        
+        torqueInit(context);   
     }
 
     @Override
@@ -98,15 +116,15 @@ public class DockerCallbackPostgreSQLExt
 
     private void dbInit(ExtensionContext context)
             throws TorqueException, UnsupportedOperationException, IOException, InterruptedException {
-        log.info("Starting from dockerfile: {}", DOCKERFILE);
+        log.info("Starting from dockerfile: {} with image name: {}", DOCKERFILE , DATABASE_CONTAINER.getDockerImageName() );
         // before torque init
         DATABASE_CONTAINER.setStartupAttempts(3);
         startDatabaseContainer();
-        
     }
 
     private static void startDatabaseContainer() {
         if (!DATABASE_CONTAINER.isRunning()) {
+            log.info("Waiting for running/ listening port..., binds: {}", DATABASE_CONTAINER.getBinds());
             DATABASE_CONTAINER.waitingFor(Wait.forListeningPort());
             DATABASE_CONTAINER.start();
         }

Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/mysql/BeanConditionalContainerTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/mysql/BeanConditionalContainerTest.java?rev=1872432&r1=1872431&r2=1872432&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/mysql/BeanConditionalContainerTest.java (original)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/mysql/BeanConditionalContainerTest.java Tue Jan  7 10:52:41 2020
@@ -20,9 +20,9 @@ package org.apache.torque.testcontainer.
  */
 
 import org.apache.torque.BeanTestConditional;
-import org.apache.torque.testcontainer.junit5.extension.DockerCallback;
+import org.apache.torque.testcontainer.junit5.extension.DockerMySQLCallback;
 
-@DockerCallback(adapterProfileFallback="mysql")
+@DockerMySQLCallback
 public class BeanConditionalContainerTest extends BeanTestConditional {
 
 }

Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/mysql/DataContainerTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/mysql/DataContainerTest.java?rev=1872432&r1=1872431&r2=1872432&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/mysql/DataContainerTest.java (original)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/mysql/DataContainerTest.java Tue Jan  7 10:52:41 2020
@@ -20,9 +20,7 @@ package org.apache.torque.testcontainer.
  */
 
 import org.apache.torque.DataTest;
-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.
@@ -33,10 +31,5 @@ import org.junit.jupiter.api.extension.R
 @DockerMySQLCallback
 public class DataContainerTest extends DataTest
 {
-    /**
-     * statically registered extensions are registered after extendwith extensions
-     */
-    @RegisterExtension
-    static DockerCallbackExtension2 dce = new DockerCallbackExtension2();
    
 }

Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/mysql/ManagerConditionalContainerTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/mysql/ManagerConditionalContainerTest.java?rev=1872432&r1=1872431&r2=1872432&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/mysql/ManagerConditionalContainerTest.java (original)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/mysql/ManagerConditionalContainerTest.java Tue Jan  7 10:52:41 2020
@@ -20,9 +20,10 @@ package org.apache.torque.testcontainer.
  */
 
 import org.apache.torque.ManagerTestConditional;
-import org.apache.torque.testcontainer.junit5.extension.DockerCallback;
+import org.apache.torque.testcontainer.junit5.extension.DockerMySQLCallback;
 
-@DockerCallback(adapterProfileFallback="mysql")
+@DockerMySQLCallback
 public class ManagerConditionalContainerTest extends ManagerTestConditional {
 
+
 }

Added: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/postgresql/BeanConditionalContainerTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/postgresql/BeanConditionalContainerTest.java?rev=1872432&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/postgresql/BeanConditionalContainerTest.java (added)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/postgresql/BeanConditionalContainerTest.java Tue Jan  7 10:52:41 2020
@@ -0,0 +1,28 @@
+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.BeanTestConditional;
+import org.apache.torque.testcontainer.junit5.extension.DockerPostGresCallback;
+
+@DockerPostGresCallback
+public class BeanConditionalContainerTest extends BeanTestConditional {
+
+}

Propchange: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/postgresql/BeanConditionalContainerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 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=1872432&r1=1872431&r2=1872432&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/postgresql/DataContainerTest.java (original)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/postgresql/DataContainerTest.java Tue Jan  7 10:52:41 2020
@@ -20,8 +20,8 @@ package org.apache.torque.testcontainer.
  */
 
 import org.apache.torque.DataTest;
-import org.apache.torque.testcontainer.junit5.extension.DockerCallbackExtension2;
-import org.apache.torque.testcontainer.junit5.extension.DockerPostGresCallback;
+import org.apache.torque.testcontainer.junit5.extension.DockerCallback;
+import org.apache.torque.testcontainer.junit5.extension.DockerCallbackPostgreSQLExtension;
 import org.junit.jupiter.api.extension.RegisterExtension;
 
 /**
@@ -30,13 +30,13 @@ import org.junit.jupiter.api.extension.R
  * @author <a href="mailto:[email protected]">Georg Kallidis</a>
  * @version $Id: DataTest.java 1869081 2019-10-28 16:17:11Z gk $
  */
-@DockerPostGresCallback
+@DockerCallback(adapterProfileFallback="postgresql")
 public class DataContainerTest extends DataTest
 {
     /**
      * statically registered extensions are registered after extendwith extensions
      */
     @RegisterExtension
-    static DockerCallbackExtension2 dce = new DockerCallbackExtension2();
+    static DockerCallbackPostgreSQLExtension dce = new DockerCallbackPostgreSQLExtension();
    
 }

Added: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/postgresql/ManagerConditionalContainerTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/postgresql/ManagerConditionalContainerTest.java?rev=1872432&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/postgresql/ManagerConditionalContainerTest.java (added)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/postgresql/ManagerConditionalContainerTest.java Tue Jan  7 10:52:41 2020
@@ -0,0 +1,30 @@
+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.ManagerTestConditional;
+import org.apache.torque.testcontainer.junit5.extension.DockerCallbackExtension;
+import org.apache.torque.testcontainer.junit5.extension.DockerPostGresCallback;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+@DockerPostGresCallback
+public class ManagerConditionalContainerTest extends ManagerTestConditional {
+
+}

Propchange: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/testcontainer/postgresql/ManagerConditionalContainerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/torque/torque4/trunk/torque-test/src/test/profile/mysql/docker-resources/db/Dockerfile
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/profile/mysql/docker-resources/db/Dockerfile?rev=1872432&r1=1872431&r2=1872432&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/profile/mysql/docker-resources/db/Dockerfile (original)
+++ db/torque/torque4/trunk/torque-test/src/test/profile/mysql/docker-resources/db/Dockerfile Tue Jan  7 10:52:41 2020
@@ -17,11 +17,15 @@
 
 FROM mysql:8.0.18
 
+COPY ./generated-sql-init /generated-sql-init
+# dependent sql should be name sorted after id-table-schema.sql
+# add what you need, avoid duplicate keys
+RUN cat /generated-sql-init/bookstore-schema-idtable-init.sql > /docker-entrypoint-initdb.d/id-table-sum-init.sql
 COPY [ "./generated-createddb-sql/*", "./generated-sql/*", "/docker-entrypoint-initdb.d/" ] 
 
 ENV MYSQL_DATABASE ${MYSQL_DATABASE} 
-ENV MYSQL_USER=${MYSQL_USER} 
-ENV MYSQL_PASSWORD=${MYSQL_PASSWORD} 
+ENV MYSQL_USER=${MYSQL_USER}
+ENV MYSQL_PASSWORD=${MYSQL_PASSWORD}
 ENV MYSQL_HOST=%
 
-ENV MYSQL_ROOT_PASSWORD=${MYSQL_PASSWORD}
+ENV MYSQL_ROOT_PASSWORD=${MYSQL_PASSWORD}
\ No newline at end of file

Modified: 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=1872432&r1=1872431&r2=1872432&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/profile/postgresql/docker-resources/db/Dockerfile (original)
+++ db/torque/torque4/trunk/torque-test/src/test/profile/postgresql/docker-resources/db/Dockerfile Tue Jan  7 10:52:41 2020
@@ -14,11 +14,14 @@
 # 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/" ] 
+COPY ./generated-sql-init /tmp-sql
+# dependent sql should be name sorted after id-table-schema.sql
+# add what you need, avoid duplicate keys
+RUN cat /tmp-sql/bookstore-schema-idtable-init.sql /tmp-sql/foreign-key-schema-idtable-init.sql /tmp-sql/test-schema-idtable-init.sql /tmp-sql/types-schema-idtable-init.sql > /docker-entrypoint-initdb.d/id-table-sum-init.sql
+COPY [ "./generated-sql/*", "/docker-entrypoint-initdb.d/" ]
 
-ENV POSTGRES_DB ${POSTGRES_DB} 
-ENV POSTGRES_USER=${POSTGRES_USER} 
-ENV POSTGRES_PASSWORD=${POSTGRES_PASSWORD} 
+ENV POSTGRES_DB=${POSTGRES_DB}
+ENV POSTGRES_USER=${POSTGRES_USER}
+ENV POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
\ No newline at end of file

Modified: db/torque/torque4/trunk/torque-test/src/test/resources/log4j2-test.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/resources/log4j2-test.xml?rev=1872432&r1=1872431&r2=1872432&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/resources/log4j2-test.xml (original)
+++ db/torque/torque4/trunk/torque-test/src/test/resources/log4j2-test.xml Tue Jan  7 10:52:41 2020
@@ -27,18 +27,34 @@
         </File>
     </Appenders>
     <Loggers>
-        <Logger name="org.apache.torque" additivity="false" level="INFO">
-            <AppenderRef ref="torque" level="INFO" />
-            <AppenderRef ref="console" level="INFO" />
-        </Logger>
         <!-- get queries: -->
         <Logger name="org.apache.torque.util" additivity="false" level="DEBUG">
             <AppenderRef ref="torque"/>
             <AppenderRef ref="console" level="INFO"/>
         </Logger> 
+        <Logger name="org.apache.torque.testcontainer" additivity="false" level="DEBUG">
+            <AppenderRef ref="torque" level="DEBUG" />
+            <AppenderRef ref="console" level="INFO"/>
+        </Logger>
+        <Logger name="org.apache.torque" additivity="false" level="INFO">
+            <AppenderRef ref="torque" level="INFO" />
+            <AppenderRef ref="console" level="INFO" />
+        </Logger>
         <Logger name="org.apache.commons.beanutils" additivity="false" level="WARN">
             <AppenderRef ref="console" />
         </Logger>
+        <Logger name="org.testcontainers" additivity="false" level="DEBUG">
+            <AppenderRef ref="torque" level="DEBUG" />
+            <AppenderRef ref="console" level="INFO"/>
+        </Logger>
+        <Logger name="org.apache.torque.generator.template.velocity" additivity="false" level="DEBUG">
+          <AppenderRef ref="torque" level="DEBUG"/>
+          <AppenderRef ref="console" level="INFO"/>
+        </Logger>
+        <Logger name="org.apache.velocity" additivity="false" level="DEBUG">
+            <AppenderRef ref="velocity" level="DEBUG"/>
+            <AppenderRef ref="console" level="DEBUG"/>
+        </Logger>
         <Root level="ERROR"><!-- log4j 1.2 has DEBUG -->
             <AppenderRef ref="console" />
             <AppenderRef ref="torque" />
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.