You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polygene.apache.org by pa...@apache.org on 2017/06/05 12:05:18 UTC

[2/6] polygene-java git commit: :extensions:entitystore-mongodb Docker based tests

:extensions:entitystore-mongodb Docker based tests


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

Branch: refs/heads/develop
Commit: d4b29ca37794ed493a7c966b9900b59414133ed1
Parents: acba972
Author: Paul Merlin <pa...@apache.org>
Authored: Mon Jun 5 12:37:53 2017 +0200
Committer: Paul Merlin <pa...@apache.org>
Committed: Mon Jun 5 12:37:53 2017 +0200

----------------------------------------------------------------------
 dependencies.gradle                                 |  1 +
 extensions/entitystore-mongodb/build.gradle         |  2 +-
 .../entitystore/mongodb/MongoDBEntityStoreTest.java | 15 ++++++---------
 .../mongodb/MongoDBEntityStoreWithCacheTest.java    | 15 ++++++---------
 .../src/main/docker/mongo/Dockerfile                | 16 ++++++++++++++++
 5 files changed, 30 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/polygene-java/blob/d4b29ca3/dependencies.gradle
----------------------------------------------------------------------
diff --git a/dependencies.gradle b/dependencies.gradle
index 159e569..d75e937 100644
--- a/dependencies.gradle
+++ b/dependencies.gradle
@@ -280,6 +280,7 @@ dependencies.dockerImagesVersions << [
   cassandra: 'cassandra:3.10',
   memcached: 'memcached:1.4.36-alpine',
   mariadb  : 'mariadb:10.1.21',
+  mongo    : 'mongo:3.5.8',
   postgres : 'postgres:9.6.2-alpine',
   redis    : 'redis:3.2.8-alpine',
   riak     : 'basho/riak-kv:ubuntu-2.2.3',

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/d4b29ca3/extensions/entitystore-mongodb/build.gradle
----------------------------------------------------------------------
diff --git a/extensions/entitystore-mongodb/build.gradle b/extensions/entitystore-mongodb/build.gradle
index 8ace38e..940db5a 100644
--- a/extensions/entitystore-mongodb/build.gradle
+++ b/extensions/entitystore-mongodb/build.gradle
@@ -32,7 +32,7 @@ dependencies {
 
   runtimeOnly polygene.core.runtime
 
-  testImplementation polygene.core.testsupport
+  testImplementation polygene.internals.testsupport
   testImplementation libraries.embed_mongo
 
   testRuntimeOnly libraries.logback

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/d4b29ca3/extensions/entitystore-mongodb/src/test/java/org/apache/polygene/entitystore/mongodb/MongoDBEntityStoreTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-mongodb/src/test/java/org/apache/polygene/entitystore/mongodb/MongoDBEntityStoreTest.java b/extensions/entitystore-mongodb/src/test/java/org/apache/polygene/entitystore/mongodb/MongoDBEntityStoreTest.java
index 4af9b7c..8a7876a 100644
--- a/extensions/entitystore-mongodb/src/test/java/org/apache/polygene/entitystore/mongodb/MongoDBEntityStoreTest.java
+++ b/extensions/entitystore-mongodb/src/test/java/org/apache/polygene/entitystore/mongodb/MongoDBEntityStoreTest.java
@@ -25,22 +25,17 @@ import org.apache.polygene.bootstrap.AssemblyException;
 import org.apache.polygene.bootstrap.ModuleAssembly;
 import org.apache.polygene.entitystore.mongodb.assembly.MongoDBEntityStoreAssembler;
 import org.apache.polygene.test.EntityTestAssembler;
+import org.apache.polygene.test.docker.DockerRule;
 import org.apache.polygene.test.entity.AbstractEntityStoreTest;
-import org.junit.BeforeClass;
-
-import static org.apache.polygene.test.util.Assume.assumeConnectivity;
+import org.junit.ClassRule;
 
 /**
  * Test the MongoDBEntityStoreService.
- * <p>Installing mongodb and starting it should suffice as the test use mongodb defaults: 127.0.0.1:27017</p>
  */
 public class MongoDBEntityStoreTest extends AbstractEntityStoreTest
 {
-    @BeforeClass
-    public static void beforeMongoMapEntityStoreTests()
-    {
-        assumeConnectivity( "localhost", 27017 );
-    }
+    @ClassRule
+    public static final DockerRule DOCKER = new DockerRule( "mongo", 27017 );
 
     @Override
     // START SNIPPET: assembly
@@ -61,6 +56,8 @@ public class MongoDBEntityStoreTest extends AbstractEntityStoreTest
         mongoConfig.writeConcern().set( MongoDBEntityStoreConfiguration.WriteConcern.MAJORITY );
         mongoConfig.database().set( "polygene:test" );
         mongoConfig.collection().set( "polygene:test:entities" );
+        mongoConfig.hostname().set( DOCKER.getDockerHost() );
+        mongoConfig.port().set( DOCKER.getExposedContainerPort( "27017/tcp" ) );
         // START SNIPPET: assembly
     }
 

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/d4b29ca3/extensions/entitystore-mongodb/src/test/java/org/apache/polygene/entitystore/mongodb/MongoDBEntityStoreWithCacheTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-mongodb/src/test/java/org/apache/polygene/entitystore/mongodb/MongoDBEntityStoreWithCacheTest.java b/extensions/entitystore-mongodb/src/test/java/org/apache/polygene/entitystore/mongodb/MongoDBEntityStoreWithCacheTest.java
index 4b63707..8fab686 100644
--- a/extensions/entitystore-mongodb/src/test/java/org/apache/polygene/entitystore/mongodb/MongoDBEntityStoreWithCacheTest.java
+++ b/extensions/entitystore-mongodb/src/test/java/org/apache/polygene/entitystore/mongodb/MongoDBEntityStoreWithCacheTest.java
@@ -26,22 +26,17 @@ import org.apache.polygene.bootstrap.ModuleAssembly;
 import org.apache.polygene.entitystore.mongodb.assembly.MongoDBEntityStoreAssembler;
 import org.apache.polygene.test.EntityTestAssembler;
 import org.apache.polygene.test.cache.AbstractEntityStoreWithCacheTest;
-import org.junit.BeforeClass;
-
-import static org.apache.polygene.test.util.Assume.assumeConnectivity;
+import org.apache.polygene.test.docker.DockerRule;
+import org.junit.ClassRule;
 
 /**
  * Test the MongoDBEntityStoreService usage with a CachePool.
- * <p>Installing mongodb and starting it should suffice as the test use mongodb defaults: 127.0.0.1:27017</p>
  */
 public class MongoDBEntityStoreWithCacheTest
     extends AbstractEntityStoreWithCacheTest
 {
-    @BeforeClass
-    public static void beforeRedisMapEntityStoreTests()
-    {
-        assumeConnectivity( "localhost", 27017 );
-    }
+    @ClassRule
+    public static final DockerRule DOCKER = new DockerRule( "mongo", 27017 );
 
     @Override
     public void assemble( ModuleAssembly module )
@@ -58,6 +53,8 @@ public class MongoDBEntityStoreWithCacheTest
         mongoConfig.writeConcern().set( MongoDBEntityStoreConfiguration.WriteConcern.MAJORITY );
         mongoConfig.database().set( "polygene:test" );
         mongoConfig.collection().set( "polygene:test:entities" );
+        mongoConfig.hostname().set( DOCKER.getDockerHost() );
+        mongoConfig.port().set( DOCKER.getExposedContainerPort( "27017/tcp" ) );
     }
 
     private Mongo mongo;

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/d4b29ca3/internals/testsupport-internal/src/main/docker/mongo/Dockerfile
----------------------------------------------------------------------
diff --git a/internals/testsupport-internal/src/main/docker/mongo/Dockerfile b/internals/testsupport-internal/src/main/docker/mongo/Dockerfile
new file mode 100644
index 0000000..8212526
--- /dev/null
+++ b/internals/testsupport-internal/src/main/docker/mongo/Dockerfile
@@ -0,0 +1,16 @@
+# 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 @mongo@