You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@metamodel.apache.org by to...@apache.org on 2014/10/10 16:36:39 UTC

git commit: METAMODEL-75: Added MongoDB to Travis.

Repository: incubator-metamodel
Updated Branches:
  refs/heads/METAMODEL-75 f48fb95ac -> 34523f753


METAMODEL-75: Added MongoDB to Travis.

Project: http://git-wip-us.apache.org/repos/asf/incubator-metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-metamodel/commit/34523f75
Tree: http://git-wip-us.apache.org/repos/asf/incubator-metamodel/tree/34523f75
Diff: http://git-wip-us.apache.org/repos/asf/incubator-metamodel/diff/34523f75

Branch: refs/heads/METAMODEL-75
Commit: 34523f75337591e4658577cfa5dabcb7402d966a
Parents: f48fb95
Author: tomaszguzialek <to...@humaninference.com>
Authored: Fri Oct 10 16:36:12 2014 +0200
Committer: tomaszguzialek <to...@humaninference.com>
Committed: Fri Oct 10 16:36:12 2014 +0200

----------------------------------------------------------------------
 .travis.yml                                     |  1 +
 .../metamodel/mongodb/MongoDbTestCase.java      | 55 +++++++++++++-------
 ...del-integrationtest-configuration.properties |  6 +--
 3 files changed, 40 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/34523f75/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index e4c647c..a9fbebc 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -6,6 +6,7 @@ jdk:
 
 services:
   - couchdb
+  - mongodb
   
 after_success:
   - mvn test

http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/34523f75/mongodb/src/test/java/org/apache/metamodel/mongodb/MongoDbTestCase.java
----------------------------------------------------------------------
diff --git a/mongodb/src/test/java/org/apache/metamodel/mongodb/MongoDbTestCase.java b/mongodb/src/test/java/org/apache/metamodel/mongodb/MongoDbTestCase.java
index 446f368..4b83398 100644
--- a/mongodb/src/test/java/org/apache/metamodel/mongodb/MongoDbTestCase.java
+++ b/mongodb/src/test/java/org/apache/metamodel/mongodb/MongoDbTestCase.java
@@ -19,7 +19,9 @@
 package org.apache.metamodel.mongodb;
 
 import java.io.File;
+import java.io.FileNotFoundException;
 import java.io.FileReader;
+import java.io.IOException;
 import java.util.Properties;
 
 import junit.framework.TestCase;
@@ -39,31 +41,46 @@ public abstract class MongoDbTestCase extends TestCase {
     protected void setUp() throws Exception {
         super.setUp();
 
-        Properties properties = new Properties();
         File file = new File(getPropertyFilePath());
         if (file.exists()) {
-            properties.load(new FileReader(file));
-            _hostname = properties.getProperty("mongodb.hostname");
-            
-            _databaseName = properties.getProperty("mongodb.databaseName");
-            if (_databaseName == null || _databaseName.isEmpty()) {
-                _databaseName = DEFAULT_TEST_DATABASE_NAME;
-            }
-            
-            _collectionName = properties.getProperty("mongodb.collectionName");
-            if (_collectionName == null || _collectionName.isEmpty()) {
-                _collectionName = DEFAULT_TEST_COLLECTION_NAME;
+            loadPropertyFile(file);
+        } else {
+            // Continuous integration case
+            if (System.getenv("CONTINUOUS_INTEGRATION") != null) {
+                File travisFile = new File("../travis-metamodel-integrationtest-configuration.properties");
+                if (travisFile.exists()) {
+                    loadPropertyFile(travisFile);
+                } else {
+                    _configured = false;
+                }
+            } else {
+                _configured = false;
             }
+        }
+    }
 
-            _configured = (_hostname != null && !_hostname.isEmpty());
+    private void loadPropertyFile(File file) throws FileNotFoundException, IOException {
+        Properties properties = new Properties();
+        properties.load(new FileReader(file));
+        _hostname = properties.getProperty("mongodb.hostname");
+        
+        _databaseName = properties.getProperty("mongodb.databaseName");
+        if (_databaseName == null || _databaseName.isEmpty()) {
+            _databaseName = DEFAULT_TEST_DATABASE_NAME;
+        }
+        
+        _collectionName = properties.getProperty("mongodb.collectionName");
+        if (_collectionName == null || _collectionName.isEmpty()) {
+            _collectionName = DEFAULT_TEST_COLLECTION_NAME;
+        }
 
-            if (_configured) {
-                System.out.println("Loaded MongoDB configuration. Hostname=" + _hostname + ", Collection="
-                        + _collectionName);
-            }
-        } else {
-            _configured = false;
+        _configured = (_hostname != null && !_hostname.isEmpty());
+
+        if (_configured) {
+            System.out.println("Loaded MongoDB configuration. Hostname=" + _hostname + ", Collection="
+                    + _collectionName);
         }
+        
     }
 
     private String getPropertyFilePath() {

http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/34523f75/travis-metamodel-integrationtest-configuration.properties
----------------------------------------------------------------------
diff --git a/travis-metamodel-integrationtest-configuration.properties b/travis-metamodel-integrationtest-configuration.properties
index 6d5c65e..7f69bed 100644
--- a/travis-metamodel-integrationtest-configuration.properties
+++ b/travis-metamodel-integrationtest-configuration.properties
@@ -18,9 +18,9 @@ couchdb.databaseName=metamodel_test_database
 # MongoDB module properties:
 # --------------------------
 
-#mongodb.hostname=localhost
-#mongodb.databaseName=metamodel_test
-#mongodb.collectionName=my_collection
+mongodb.hostname=localhost
+mongodb.databaseName=metamodel_test
+mongodb.collectionName=my_collection
 
 # ------------------------
 # HBase module properties: