polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From paulmer...@apache.org
Subject [1/7] polygene-java git commit: POLYGENE-221 integration test PostgreSQL Index/Query using Docker
Date Mon, 09 Jan 2017 17:57:19 GMT
Repository: polygene-java
Updated Branches:
  refs/heads/develop 6f23e5549 -> 0bfa4627b


POLYGENE-221 integration test PostgreSQL Index/Query using Docker


Project: http://git-wip-us.apache.org/repos/asf/polygene-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/polygene-java/commit/0bfa4627
Tree: http://git-wip-us.apache.org/repos/asf/polygene-java/tree/0bfa4627
Diff: http://git-wip-us.apache.org/repos/asf/polygene-java/diff/0bfa4627

Branch: refs/heads/develop
Commit: 0bfa4627b5519f3470b3ace23f34a888288b6ade
Parents: aed1688
Author: Paul Merlin <paulmerlin@apache.org>
Authored: Mon Jan 9 18:55:05 2017 +0100
Committer: Paul Merlin <paulmerlin@apache.org>
Committed: Mon Jan 9 18:56:58 2017 +0100

----------------------------------------------------------------------
 extensions/indexing-sql/build.gradle            |  2 +-
 .../postgresql/PostgreSQLComplexQueryTest.java  | 16 +++++++-------
 .../postgresql/PostgreSQLDBIntegrityTest.java   | 22 +++++++++-----------
 .../postgresql/PostgreSQLEntityFinderTest.java  | 14 ++++++-------
 .../sql/postgresql/PostgreSQLQueryTest.java     | 20 ++++++++----------
 .../index/sql/postgresql/SQLTestHelper.java     | 17 ++++++++-------
 .../resources/postgres-datasource.properties    |  2 +-
 7 files changed, 44 insertions(+), 49 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/polygene-java/blob/0bfa4627/extensions/indexing-sql/build.gradle
----------------------------------------------------------------------
diff --git a/extensions/indexing-sql/build.gradle b/extensions/indexing-sql/build.gradle
index 7a3ac86..ec67169 100644
--- a/extensions/indexing-sql/build.gradle
+++ b/extensions/indexing-sql/build.gradle
@@ -35,7 +35,7 @@ dependencies {
 
   runtime polygene.core.runtime
 
-  testCompile polygene.core.testsupport
+  testCompile polygene.internals.testsupport
   testCompile polygene.library( 'sql-dbcp' )
 
   testRuntime libraries.logback

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/0bfa4627/extensions/indexing-sql/src/test/java/org/apache/polygene/index/sql/postgresql/PostgreSQLComplexQueryTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-sql/src/test/java/org/apache/polygene/index/sql/postgresql/PostgreSQLComplexQueryTest.java
b/extensions/indexing-sql/src/test/java/org/apache/polygene/index/sql/postgresql/PostgreSQLComplexQueryTest.java
index 32fb3c4..74d8e63 100644
--- a/extensions/indexing-sql/src/test/java/org/apache/polygene/index/sql/postgresql/PostgreSQLComplexQueryTest.java
+++ b/extensions/indexing-sql/src/test/java/org/apache/polygene/index/sql/postgresql/PostgreSQLComplexQueryTest.java
@@ -19,28 +19,26 @@
  */
 package org.apache.polygene.index.sql.postgresql;
 
-import org.junit.BeforeClass;
 import org.apache.polygene.bootstrap.AssemblyException;
 import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.test.internal.DockerRule;
 import org.apache.polygene.test.indexing.AbstractComplexQueryTest;
-
-import static org.apache.polygene.test.util.Assume.assumeConnectivity;
+import org.junit.ClassRule;
 
 public class PostgreSQLComplexQueryTest
     extends AbstractComplexQueryTest
 {
-    @BeforeClass
-    public static void beforePostgreSQLQueryTests()
-    {
-        assumeConnectivity( "localhost", 5432 );
-    }
+    @ClassRule
+    public static final DockerRule DOCKER = new DockerRule( "postgres", 5432 );
 
     @Override
     public void assemble( ModuleAssembly mainModule )
         throws AssemblyException
     {
         super.assemble( mainModule );
-        SQLTestHelper.assembleWithMemoryEntityStore( mainModule );
+        String host = DOCKER.getDockerHost();
+        int port = DOCKER.getExposedContainerPort( "5432/tcp" );
+        SQLTestHelper.assembleWithMemoryEntityStore( mainModule, host, port );
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/0bfa4627/extensions/indexing-sql/src/test/java/org/apache/polygene/index/sql/postgresql/PostgreSQLDBIntegrityTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-sql/src/test/java/org/apache/polygene/index/sql/postgresql/PostgreSQLDBIntegrityTest.java
b/extensions/indexing-sql/src/test/java/org/apache/polygene/index/sql/postgresql/PostgreSQLDBIntegrityTest.java
index 54d6570..627c8df 100644
--- a/extensions/indexing-sql/src/test/java/org/apache/polygene/index/sql/postgresql/PostgreSQLDBIntegrityTest.java
+++ b/extensions/indexing-sql/src/test/java/org/apache/polygene/index/sql/postgresql/PostgreSQLDBIntegrityTest.java
@@ -21,10 +21,6 @@ package org.apache.polygene.index.sql.postgresql;
 
 import java.sql.Connection;
 import javax.sql.DataSource;
-import org.apache.polygene.test.AbstractPolygeneTest;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
 import org.apache.polygene.api.common.UseDefaults;
 import org.apache.polygene.api.entity.EntityComposite;
 import org.apache.polygene.api.property.Property;
@@ -36,21 +32,21 @@ import org.apache.polygene.index.sql.support.common.DBNames;
 import org.apache.polygene.index.sql.support.common.GenericDatabaseExplorer;
 import org.apache.polygene.index.sql.support.common.GenericDatabaseExplorer.DatabaseProcessorAdapter;
 import org.apache.polygene.index.sql.support.postgresql.PostgreSQLAppStartup;
+import org.apache.polygene.test.internal.DockerRule;
 import org.apache.polygene.library.sql.common.SQLConfiguration;
 import org.apache.polygene.library.sql.common.SQLUtil;
+import org.apache.polygene.test.AbstractPolygeneTest;
+import org.junit.Assert;
+import org.junit.ClassRule;
+import org.junit.Test;
 import org.sql.generation.api.vendor.PostgreSQLVendor;
 import org.sql.generation.api.vendor.SQLVendorProvider;
 
-import static org.apache.polygene.test.util.Assume.assumeConnectivity;
-
 public class PostgreSQLDBIntegrityTest
     extends AbstractPolygeneTest
 {
-    @BeforeClass
-    public static void beforePostgreSQLQueryTests()
-    {
-        assumeConnectivity( "localhost", 5432 );
-    }
+    @ClassRule
+    public static final DockerRule DOCKER = new DockerRule( "postgres", 5432 );
 
     public static interface TestEntity
         extends EntityComposite
@@ -66,7 +62,9 @@ public class PostgreSQLDBIntegrityTest
     public void assemble( ModuleAssembly module )
         throws AssemblyException
     {
-        SQLTestHelper.assembleWithMemoryEntityStore( module );
+        String host = DOCKER.getDockerHost();
+        int port = DOCKER.getExposedContainerPort( "5432/tcp" );
+        SQLTestHelper.assembleWithMemoryEntityStore( module, host, port );
         module.entities( TestEntity.class );
     }
 

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/0bfa4627/extensions/indexing-sql/src/test/java/org/apache/polygene/index/sql/postgresql/PostgreSQLEntityFinderTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-sql/src/test/java/org/apache/polygene/index/sql/postgresql/PostgreSQLEntityFinderTest.java
b/extensions/indexing-sql/src/test/java/org/apache/polygene/index/sql/postgresql/PostgreSQLEntityFinderTest.java
index 05c3aa1..90a4db9 100644
--- a/extensions/indexing-sql/src/test/java/org/apache/polygene/index/sql/postgresql/PostgreSQLEntityFinderTest.java
+++ b/extensions/indexing-sql/src/test/java/org/apache/polygene/index/sql/postgresql/PostgreSQLEntityFinderTest.java
@@ -19,28 +19,28 @@
  */
 package org.apache.polygene.index.sql.postgresql;
 
-import org.junit.BeforeClass;
+import org.apache.polygene.test.internal.DockerRule;
 import org.apache.polygene.bootstrap.AssemblyException;
 import org.apache.polygene.bootstrap.ModuleAssembly;
 import org.apache.polygene.test.indexing.AbstractEntityFinderTest;
+import org.junit.ClassRule;
 
 import static org.apache.polygene.test.util.Assume.assumeConnectivity;
 
 public class PostgreSQLEntityFinderTest
     extends AbstractEntityFinderTest
 {
-    @BeforeClass
-    public static void beforePostgreSQLQueryTests()
-    {
-        assumeConnectivity( "localhost", 5432 );
-    }
+    @ClassRule
+    public static final DockerRule DOCKER = new DockerRule( "postgres", 5432 );
 
     @Override
     public void assemble( ModuleAssembly mainModule )
         throws AssemblyException
     {
         super.assemble( mainModule );
-        SQLTestHelper.assembleWithMemoryEntityStore( mainModule );
+        String host = DOCKER.getDockerHost();
+        int port = DOCKER.getExposedContainerPort( "5432/tcp" );
+        SQLTestHelper.assembleWithMemoryEntityStore( mainModule, host, port );
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/0bfa4627/extensions/indexing-sql/src/test/java/org/apache/polygene/index/sql/postgresql/PostgreSQLQueryTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-sql/src/test/java/org/apache/polygene/index/sql/postgresql/PostgreSQLQueryTest.java
b/extensions/indexing-sql/src/test/java/org/apache/polygene/index/sql/postgresql/PostgreSQLQueryTest.java
index 379416f..3a4caa6 100644
--- a/extensions/indexing-sql/src/test/java/org/apache/polygene/index/sql/postgresql/PostgreSQLQueryTest.java
+++ b/extensions/indexing-sql/src/test/java/org/apache/polygene/index/sql/postgresql/PostgreSQLQueryTest.java
@@ -19,14 +19,13 @@
  */
 package org.apache.polygene.index.sql.postgresql;
 
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
 import org.apache.polygene.bootstrap.AssemblyException;
 import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.test.internal.DockerRule;
 import org.apache.polygene.test.indexing.AbstractQueryTest;
-
-import static org.apache.polygene.test.util.Assume.assumeConnectivity;
+import org.junit.ClassRule;
+import org.junit.Ignore;
+import org.junit.Test;
 
 /**
  * PostgreSQL Query Tests.
@@ -36,18 +35,17 @@ import static org.apache.polygene.test.util.Assume.assumeConnectivity;
 public class PostgreSQLQueryTest
     extends AbstractQueryTest
 {
-    @BeforeClass
-    public static void beforePostgreSQLQueryTests()
-    {
-        assumeConnectivity( "localhost", 5432 );
-    }
+    @ClassRule
+    public static final DockerRule DOCKER = new DockerRule( "postgres", 5432 );
 
     @Override
     public void assemble( ModuleAssembly mainModule )
         throws AssemblyException
     {
         super.assemble( mainModule );
-        SQLTestHelper.assembleWithMemoryEntityStore( mainModule );
+        String host = DOCKER.getDockerHost();
+        int port = DOCKER.getExposedContainerPort( "5432/tcp" );
+        SQLTestHelper.assembleWithMemoryEntityStore( mainModule, host, port );
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/0bfa4627/extensions/indexing-sql/src/test/java/org/apache/polygene/index/sql/postgresql/SQLTestHelper.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-sql/src/test/java/org/apache/polygene/index/sql/postgresql/SQLTestHelper.java
b/extensions/indexing-sql/src/test/java/org/apache/polygene/index/sql/postgresql/SQLTestHelper.java
index f477573..be5727d 100644
--- a/extensions/indexing-sql/src/test/java/org/apache/polygene/index/sql/postgresql/SQLTestHelper.java
+++ b/extensions/indexing-sql/src/test/java/org/apache/polygene/index/sql/postgresql/SQLTestHelper.java
@@ -22,6 +22,7 @@ package org.apache.polygene.index.sql.postgresql;
 import java.sql.Connection;
 import javax.sql.DataSource;
 import org.apache.polygene.api.service.ServiceFinder;
+import org.apache.polygene.library.sql.datasource.DataSourceConfiguration;
 import org.junit.Assume;
 import org.apache.polygene.api.common.Visibility;
 import org.apache.polygene.bootstrap.AssemblyException;
@@ -35,21 +36,18 @@ import org.apache.polygene.library.sql.common.SQLUtil;
 import org.apache.polygene.library.sql.dbcp.DBCPDataSourceServiceAssembler;
 import org.apache.polygene.test.EntityTestAssembler;
 
-public class SQLTestHelper
+class SQLTestHelper
 {
-
-    public static final String SEPARATE_MODULE_NAME = "actual_module";
-
-    public static void assembleWithMemoryEntityStore( ModuleAssembly mainModule )
+    static void assembleWithMemoryEntityStore( ModuleAssembly mainModule, String host, int
port )
         throws AssemblyException
     {
         // EntityStore
         new EntityTestAssembler().visibleIn( Visibility.application ).assemble( mainModule
);
 
-        doCommonAssembling( mainModule );
+        doCommonAssembling( mainModule, host, port );
     }
 
-    protected static void doCommonAssembling( ModuleAssembly mainModule )
+    private static void doCommonAssembling( ModuleAssembly mainModule, String host, int port
)
         throws AssemblyException
     {
         ModuleAssembly config = mainModule.layer().module( "config" );
@@ -78,6 +76,9 @@ public class SQLTestHelper
             assemble( mainModule );
         // END SNIPPET: assembly
 
+        config.forMixin( DataSourceConfiguration.class ).declareDefaults()
+              .url().set( "jdbc:postgresql://" + host + ":" + port + "/jdbc_test_db" );
+
         // Always re-build schema in test scenarios because of possibly different app structure
in
         // various tests
         mainModule.services( RebuildingStrategy.class ).
@@ -92,7 +93,7 @@ public class SQLTestHelper
             visibleIn( Visibility.layer );
     }
 
-    public static void setUpTest( ServiceFinder serviceFinder )
+    static void setUpTest( ServiceFinder serviceFinder )
     {
         Connection connection = null;
         try

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/0bfa4627/extensions/indexing-sql/src/test/resources/postgres-datasource.properties
----------------------------------------------------------------------
diff --git a/extensions/indexing-sql/src/test/resources/postgres-datasource.properties b/extensions/indexing-sql/src/test/resources/postgres-datasource.properties
index ea16c45..1766e3e 100644
--- a/extensions/indexing-sql/src/test/resources/postgres-datasource.properties
+++ b/extensions/indexing-sql/src/test/resources/postgres-datasource.properties
@@ -19,7 +19,7 @@
 #
 
 enabled=true
-url=jdbc:postgresql://localhost:5432/jdbc_test_db
+#url=jdbc:postgresql://localhost:5432/jdbc_test_db
 driver=org.postgresql.Driver
 username=jdbc_test_login
 password=password


Mime
View raw message