Repository: phoenix
Updated Branches:
  refs/heads/master 6098d7bd0 -> e9f895f69


PHOENIX-1036 Fix flapping ContextClassloaderIT (SamarthJain)


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

Branch: refs/heads/master
Commit: e9f895f692511c698402f62d82e880e7da1c3596
Parents: 6098d7b
Author: Mujtaba <mujt...@apache.org>
Authored: Wed Jun 11 15:43:31 2014 -0700
Committer: Mujtaba <mujt...@apache.org>
Committed: Wed Jun 11 15:43:31 2014 -0700

----------------------------------------------------------------------
 .../phoenix/end2end/ContextClassloaderIT.java   | 44 ++++++++++++++------
 1 file changed, 31 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/e9f895f6/phoenix-core/src/it/java/org/apache/phoenix/end2end/ContextClassloaderIT.java
----------------------------------------------------------------------
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ContextClassloaderIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ContextClassloaderIT.java
index 9756249..1cd8ee0 100644
--- 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ContextClassloaderIT.java
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ContextClassloaderIT.java
@@ -17,6 +17,14 @@
  */
 package org.apache.phoenix.end2end;
 
+import static org.apache.phoenix.util.PhoenixRuntime.JDBC_PROTOCOL;
+import static org.apache.phoenix.util.PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR;
+import static org.apache.phoenix.util.PhoenixRuntime.JDBC_PROTOCOL_TERMINATOR;
+import static 
org.apache.phoenix.util.PhoenixRuntime.PHOENIX_TEST_DRIVER_URL_PARAM;
+import static org.apache.phoenix.util.TestUtil.LOCALHOST;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
 import java.io.File;
 import java.net.URL;
 import java.net.URLClassLoader;
@@ -26,31 +34,37 @@ import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
 
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.HBaseConfiguration;
 import org.apache.hadoop.hbase.HBaseTestingUtility;
+import org.apache.phoenix.jdbc.PhoenixTestDriver;
+import org.apache.phoenix.query.BaseTest;
 import org.apache.phoenix.query.QueryServices;
-import org.apache.phoenix.util.ConfigUtil;
+import org.apache.phoenix.util.ReadOnlyProps;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
 @Category(NeedsOwnMiniClusterTest.class)
-public class ContextClassloaderIT  {
+public class ContextClassloaderIT  extends BaseTest {
 
     private static HBaseTestingUtility hbaseTestUtil;
+    private static PhoenixTestDriver driver;
     private static ClassLoader badContextClassloader;
 
     @BeforeClass
     public static void setUpBeforeClass() throws Exception {
-        hbaseTestUtil = new HBaseTestingUtility();
-        
ConfigUtil.setReplicationConfigIfAbsent(hbaseTestUtil.getConfiguration());
-        
hbaseTestUtil.getConfiguration().setInt(QueryServices.MASTER_INFO_PORT_ATTRIB, 
-1);
-        
hbaseTestUtil.getConfiguration().setInt(QueryServices.REGIONSERVER_INFO_PORT_ATTRIB,
 -1);
+        Configuration conf = HBaseConfiguration.create();
+        setUpConfigForMiniCluster(conf);
+        hbaseTestUtil = new HBaseTestingUtility(conf);
         hbaseTestUtil.startMiniCluster();
-        Connection conn = DriverManager.getConnection(getUrl());
+        String clientPort = 
hbaseTestUtil.getConfiguration().get(QueryServices.ZOOKEEPER_PORT_ATTRIB);
+        String url = JDBC_PROTOCOL + JDBC_PROTOCOL_SEPARATOR + LOCALHOST + 
JDBC_PROTOCOL_SEPARATOR + clientPort
+                + JDBC_PROTOCOL_TERMINATOR + PHOENIX_TEST_DRIVER_URL_PARAM;
+        driver = initAndRegisterDriver(url, ReadOnlyProps.EMPTY_PROPS);
+        
+        Connection conn = DriverManager.getConnection(url);
         Statement stmt = conn.createStatement();
         stmt.execute("CREATE TABLE test (ID INTEGER NOT NULL PRIMARY KEY, NAME 
VARCHAR)");
         stmt.execute("UPSERT INTO test VALUES (1, 'name1')");
@@ -63,12 +77,16 @@ public class ContextClassloaderIT  {
     }
 
     private static String getUrl() {
-        return "jdbc:phoenix:localhost:" + 
hbaseTestUtil.getZkCluster().getClientPort();
+        return "jdbc:phoenix:localhost:" + 
hbaseTestUtil.getZkCluster().getClientPort() + ";test=true";
     }
 
     @AfterClass
-    public static void tearDownAfterClass() throws Exception {
-        hbaseTestUtil.shutdownMiniCluster();
+    public static void tearDown() throws Exception {
+        try {
+            destroyDriver(driver);
+        } finally {
+            hbaseTestUtil.shutdownMiniCluster();
+        }
     }
 
     @Test

Reply via email to