hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sp...@apache.org
Subject [36/50] [abbrv] hive git commit: HIVE-10696 : TestAddResource tests are non-portable (Hari Subramaniyan reviewed by Alexander Pivovarov, Thejas Nair)
Date Wed, 20 May 2015 16:01:55 GMT
HIVE-10696 : TestAddResource tests are non-portable (Hari Subramaniyan reviewed by Alexander
Pivovarov, Thejas Nair)


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

Branch: refs/heads/parquet
Commit: 5818a4a2054bafd78ecbfda0798ece1949d0d25d
Parents: 1b91dba
Author: Hari Subramaniyan <harisankar@apache.org>
Authored: Mon May 18 13:12:23 2015 -0700
Committer: Hari Subramaniyan <harisankar@apache.org>
Committed: Mon May 18 13:12:23 2015 -0700

----------------------------------------------------------------------
 .../hadoop/hive/ql/session/TestAddResource.java | 98 ++++++++++++--------
 1 file changed, 57 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/5818a4a2/ql/src/test/org/apache/hadoop/hive/ql/session/TestAddResource.java
----------------------------------------------------------------------
diff --git a/ql/src/test/org/apache/hadoop/hive/ql/session/TestAddResource.java b/ql/src/test/org/apache/hadoop/hive/ql/session/TestAddResource.java
index 6176b2d..1f07235 100644
--- a/ql/src/test/org/apache/hadoop/hive/ql/session/TestAddResource.java
+++ b/ql/src/test/org/apache/hadoop/hive/ql/session/TestAddResource.java
@@ -31,6 +31,7 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Set;
 
+import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hive.conf.HiveConf;
 import org.junit.After;
 import org.junit.Before;
@@ -38,6 +39,7 @@ import org.junit.Test;
 import org.mockito.Mockito;
 import org.apache.hadoop.hive.ql.session.SessionState.ResourceType;
 import org.apache.hadoop.hive.ql.session.SessionState;
+import org.apache.hadoop.util.Shell;
 
 import java.io.BufferedWriter;
 import java.io.FileWriter;
@@ -45,7 +47,7 @@ import java.io.FileWriter;
 
 public class TestAddResource {
 
-  private static final String TEST_JAR_DIR = System.getProperty("test.tmp.dir", ".") + "/";
+  private static final String TEST_JAR_DIR = System.getProperty("test.tmp.dir", ".") + File.pathSeparator;
   private HiveConf conf;
   private ResourceType t;
 
@@ -74,11 +76,11 @@ public class TestAddResource {
     // add all the dependencies to a list
     List<URI> list = new LinkedList<URI>();
     List<String> addList = new LinkedList<String>();
-    list.add(new URI(TEST_JAR_DIR + "testjar1.jar"));
-    list.add(new URI(TEST_JAR_DIR + "testjar2.jar"));
-    list.add(new URI(TEST_JAR_DIR + "testjar3.jar"));
-    list.add(new URI(TEST_JAR_DIR + "testjar4.jar"));
-    list.add(new URI(TEST_JAR_DIR + "testjar5.jar"));
+    list.add(createURI(TEST_JAR_DIR + "testjar1.jar"));
+    list.add(createURI(TEST_JAR_DIR + "testjar2.jar"));
+    list.add(createURI(TEST_JAR_DIR + "testjar3.jar"));
+    list.add(createURI(TEST_JAR_DIR + "testjar4.jar"));
+    list.add(createURI(TEST_JAR_DIR + "testjar5.jar"));
 
     //return all the dependency urls
     Mockito.when(ss.resolveAndDownload(t, query, false)).thenReturn(list);
@@ -87,7 +89,7 @@ public class TestAddResource {
     Set<String> dependencies = ss.list_resource(t, null);
     LinkedList<URI> actual = new LinkedList<URI>();
     for (String dependency : dependencies) {
-      actual.add(new URI(dependency));
+      actual.add(createURI(dependency));
     }
 
     // sort both the lists
@@ -109,11 +111,11 @@ public class TestAddResource {
 
     List<URI> list = new LinkedList<URI>();
     List<String> addList = new LinkedList<String>();
-    list.add(new URI(TEST_JAR_DIR + "testjar1.jar"));
-    list.add(new URI(TEST_JAR_DIR + "testjar2.jar"));
-    list.add(new URI(TEST_JAR_DIR + "testjar3.jar"));
-    list.add(new URI(TEST_JAR_DIR + "testjar4.jar"));
-    list.add(new URI(TEST_JAR_DIR + "testjar5.jar"));
+    list.add(createURI(TEST_JAR_DIR + "testjar1.jar"));
+    list.add(createURI(TEST_JAR_DIR + "testjar2.jar"));
+    list.add(createURI(TEST_JAR_DIR + "testjar3.jar"));
+    list.add(createURI(TEST_JAR_DIR + "testjar4.jar"));
+    list.add(createURI(TEST_JAR_DIR + "testjar5.jar"));
 
     Collections.sort(list);
 
@@ -125,7 +127,7 @@ public class TestAddResource {
     Set<String> dependencies = ss.list_resource(t, null);
     LinkedList<URI> actual = new LinkedList<URI>();
     for (String dependency : dependencies) {
-      actual.add(new URI(dependency));
+      actual.add(createURI(dependency));
     }
 
     Collections.sort(actual);
@@ -147,13 +149,13 @@ public class TestAddResource {
     // add dependencies for the jars
     List<URI> list1 = new LinkedList<URI>();
     List<URI> list2 = new LinkedList<URI>();
-    list1.add(new URI(TEST_JAR_DIR + "testjar1.jar"));
-    list1.add(new URI(TEST_JAR_DIR + "testjar2.jar"));
-    list1.add(new URI(TEST_JAR_DIR + "testjar3.jar"));
-    list1.add(new URI(TEST_JAR_DIR + "testjar4.jar"));
-    list2.add(new URI(TEST_JAR_DIR + "testjar5.jar"));
-    list2.add(new URI(TEST_JAR_DIR + "testjar3.jar"));
-    list2.add(new URI(TEST_JAR_DIR + "testjar4.jar"));
+    list1.add(createURI(TEST_JAR_DIR + "testjar1.jar"));
+    list1.add(createURI(TEST_JAR_DIR + "testjar2.jar"));
+    list1.add(createURI(TEST_JAR_DIR + "testjar3.jar"));
+    list1.add(createURI(TEST_JAR_DIR + "testjar4.jar"));
+    list2.add(createURI(TEST_JAR_DIR + "testjar5.jar"));
+    list2.add(createURI(TEST_JAR_DIR + "testjar3.jar"));
+    list2.add(createURI(TEST_JAR_DIR + "testjar4.jar"));
 
     Mockito.when(ss.resolveAndDownload(t, query1, false)).thenReturn(list1);
     Mockito.when(ss.resolveAndDownload(t, query2, false)).thenReturn(list2);
@@ -164,7 +166,7 @@ public class TestAddResource {
     Set<String> dependencies = ss.list_resource(t, null);
     LinkedList<URI> actual = new LinkedList<URI>();
     for (String dependency : dependencies) {
-      actual.add(new URI(dependency));
+      actual.add(createURI(dependency));
     }
     List<URI> expected = union(list1, list2);
 
@@ -176,6 +178,20 @@ public class TestAddResource {
 
   }
 
+  /**
+   * @param path
+   * @return URI corresponding to the path.
+   */
+  private static URI createURI(String path) throws URISyntaxException {
+    if (!Shell.WINDOWS) {
+      // If this is not windows shell, path better follow unix convention.
+      // Else, the below call will throw an URISyntaxException
+      return new URI(path);
+    } else {
+      return new Path(path).toUri();
+    }
+  }
+
   // Test when two jars are added with shared dependencies and one jar is deleted, the shared
dependencies should not be deleted
   @Test
   public void testDeleteJar() throws URISyntaxException, IOException {
@@ -187,13 +203,13 @@ public class TestAddResource {
     List<URI> list1 = new LinkedList<URI>();
     List<URI> list2 = new LinkedList<URI>();
     List<String> addList = new LinkedList<String>();
-    list1.add(new URI(TEST_JAR_DIR + "testjar1.jar"));
-    list1.add(new URI(TEST_JAR_DIR + "testjar2.jar"));
-    list1.add(new URI(TEST_JAR_DIR + "testjar3.jar"));
-    list1.add(new URI(TEST_JAR_DIR + "testjar4.jar"));
-    list2.add(new URI(TEST_JAR_DIR + "testjar5.jar"));
-    list2.add(new URI(TEST_JAR_DIR + "testjar3.jar"));
-    list2.add(new URI(TEST_JAR_DIR + "testjar4.jar"));
+    list1.add(createURI(TEST_JAR_DIR + "testjar1.jar"));
+    list1.add(createURI(TEST_JAR_DIR + "testjar2.jar"));
+    list1.add(createURI(TEST_JAR_DIR + "testjar3.jar"));
+    list1.add(createURI(TEST_JAR_DIR + "testjar4.jar"));
+    list2.add(createURI(TEST_JAR_DIR + "testjar5.jar"));
+    list2.add(createURI(TEST_JAR_DIR + "testjar3.jar"));
+    list2.add(createURI(TEST_JAR_DIR + "testjar4.jar"));
 
     Collections.sort(list1);
     Collections.sort(list2);
@@ -211,7 +227,7 @@ public class TestAddResource {
     Set<String> dependencies = ss.list_resource(t, null);
     LinkedList<URI> actual = new LinkedList<URI>();
     for (String dependency : dependencies) {
-      actual.add(new URI(dependency));
+      actual.add(createURI(dependency));
     }
     List<URI> expected = list2;
     Collections.sort(expected);
@@ -242,16 +258,16 @@ public class TestAddResource {
     List<URI> list2 = new LinkedList<URI>();
     List<URI> list3 = new LinkedList<URI>();
     List<String> addList = new LinkedList<String>();
-    list1.add(new URI(TEST_JAR_DIR + "testjar1.jar"));
-    list1.add(new URI(TEST_JAR_DIR + "testjar2.jar"));
-    list1.add(new URI(TEST_JAR_DIR + "testjar3.jar"));
-    list1.add(new URI(TEST_JAR_DIR + "testjar4.jar"));
-    list2.add(new URI(TEST_JAR_DIR + "testjar5.jar"));
-    list2.add(new URI(TEST_JAR_DIR + "testjar3.jar"));
-    list2.add(new URI(TEST_JAR_DIR + "testjar4.jar"));
-    list3.add(new URI(TEST_JAR_DIR + "testjar4.jar"));
-    list3.add(new URI(TEST_JAR_DIR + "testjar2.jar"));
-    list3.add(new URI(TEST_JAR_DIR + "testjar5.jar"));
+    list1.add(createURI(TEST_JAR_DIR + "testjar1.jar"));
+    list1.add(createURI(TEST_JAR_DIR + "testjar2.jar"));
+    list1.add(createURI(TEST_JAR_DIR + "testjar3.jar"));
+    list1.add(createURI(TEST_JAR_DIR + "testjar4.jar"));
+    list2.add(createURI(TEST_JAR_DIR + "testjar5.jar"));
+    list2.add(createURI(TEST_JAR_DIR + "testjar3.jar"));
+    list2.add(createURI(TEST_JAR_DIR + "testjar4.jar"));
+    list3.add(createURI(TEST_JAR_DIR + "testjar4.jar"));
+    list3.add(createURI(TEST_JAR_DIR + "testjar2.jar"));
+    list3.add(createURI(TEST_JAR_DIR + "testjar5.jar"));
 
     Collections.sort(list1);
     Collections.sort(list2);
@@ -273,7 +289,7 @@ public class TestAddResource {
     Set<String> dependencies = ss.list_resource(t, null);
     LinkedList<URI> actual = new LinkedList<URI>();
     for (String dependency : dependencies) {
-      actual.add(new URI(dependency));
+      actual.add(createURI(dependency));
     }
     List<URI> expected = union(list2, list3);
     Collections.sort(expected);
@@ -290,7 +306,7 @@ public class TestAddResource {
     dependencies = ss.list_resource(t, null);
     actual = new LinkedList<URI>();
     for (String dependency : dependencies) {
-      actual.add(new URI(dependency));
+      actual.add(createURI(dependency));
     }
     expected = new LinkedList<URI>(list3);
     Collections.sort(expected);


Mime
View raw message