You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by li...@apache.org on 2015/07/04 06:46:32 UTC

incubator-kylin git commit: minor, try fix ci ITJDBCDriverTest

Repository: incubator-kylin
Updated Branches:
  refs/heads/0.8 c5b1ab5c3 -> 96951f291


minor, try fix ci ITJDBCDriverTest


Project: http://git-wip-us.apache.org/repos/asf/incubator-kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-kylin/commit/96951f29
Tree: http://git-wip-us.apache.org/repos/asf/incubator-kylin/tree/96951f29
Diff: http://git-wip-us.apache.org/repos/asf/incubator-kylin/diff/96951f29

Branch: refs/heads/0.8
Commit: 96951f291c1387c72037e3b53c01fdd6cf8ee7af
Parents: c5b1ab5
Author: Yang Li <li...@apache.org>
Authored: Sat Jul 4 12:46:10 2015 +0800
Committer: Yang Li <li...@apache.org>
Committed: Sat Jul 4 12:46:10 2015 +0800

----------------------------------------------------------------------
 .../org/apache/kylin/jdbc/ITJDBCDriverTest.java | 36 ++++++++++++++------
 1 file changed, 25 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/96951f29/server/src/test/java/org/apache/kylin/jdbc/ITJDBCDriverTest.java
----------------------------------------------------------------------
diff --git a/server/src/test/java/org/apache/kylin/jdbc/ITJDBCDriverTest.java b/server/src/test/java/org/apache/kylin/jdbc/ITJDBCDriverTest.java
index 3286de0..08f5217 100644
--- a/server/src/test/java/org/apache/kylin/jdbc/ITJDBCDriverTest.java
+++ b/server/src/test/java/org/apache/kylin/jdbc/ITJDBCDriverTest.java
@@ -20,6 +20,7 @@
 package org.apache.kylin.jdbc;
 
 import com.google.common.collect.Lists;
+
 import org.apache.commons.io.FileUtils;
 import org.apache.kylin.common.util.HBaseMetadataTestCase;
 import org.eclipse.jetty.server.Server;
@@ -28,6 +29,7 @@ import org.junit.*;
 
 import java.io.File;
 import java.sql.*;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Properties;
 
@@ -36,15 +38,12 @@ import java.util.Properties;
 public class ITJDBCDriverTest extends HBaseMetadataTestCase {
 
     private static Server server = null;
-
-    private static String previousSpringProfile = null;
-
-    private static String SPRING_PROFILE_PROPERTY = "spring.profiles.active";
+    private static SystemPropertiesOverride sysPropsOverride = new SystemPropertiesOverride();
 
     @BeforeClass
     public static void beforeClass() throws Exception {
-        previousSpringProfile = System.getProperty(SPRING_PROFILE_PROPERTY);
-        System.setProperty(SPRING_PROFILE_PROPERTY, "testing");
+        sysPropsOverride.override("spring.profiles.active", "testing");
+        sysPropsOverride.override("catalina.home", "."); // resources/log4j.properties ref ${catalina.home}
         staticCreateTestMetadata();
         startJetty();
     }
@@ -53,11 +52,7 @@ public class ITJDBCDriverTest extends HBaseMetadataTestCase {
     public static void afterClass() throws Exception {
         stopJetty();
         staticCleanupTestMetadata();
-        if (previousSpringProfile == null) {
-            System.clearProperty(SPRING_PROFILE_PROPERTY);
-        } else {
-            System.setProperty(SPRING_PROFILE_PROPERTY, previousSpringProfile);
-        }
+        sysPropsOverride.restore();
     }
 
     protected static void stopJetty() throws Exception {
@@ -261,4 +256,23 @@ public class ITJDBCDriverTest extends HBaseMetadataTestCase {
 
     }
 
+    private static class SystemPropertiesOverride {
+        HashMap<String, String> backup = new HashMap<String, String>();
+        
+        public void override(String key, String value) {
+            backup.put(key, System.getProperty(key));
+            System.setProperty(key, value);
+        }
+        
+        public void restore() {
+            for (String key : backup.keySet()) {
+                String value = backup.get(key);
+                if (value == null)
+                    System.clearProperty(key);
+                else
+                    System.setProperty(key, value);
+            }
+            backup.clear();
+        }
+    }
 }