Author: pradeepkth
Date: Fri Apr  2 05:30:16 2010
New Revision: 930169

URL: http://svn.apache.org/viewvc?rev=930169&view=rev
Log:
PIG-1346: In unit tests Util.executeShellCommand relies on java commands being 
in the path and does not consider JAVA_HOME (pradeepkth)

Modified:
    hadoop/pig/branches/branch-0.7/CHANGES.txt
    hadoop/pig/branches/branch-0.7/test/org/apache/pig/test/TestLocal2.java
    hadoop/pig/branches/branch-0.7/test/org/apache/pig/test/TestPigContext.java
    hadoop/pig/branches/branch-0.7/test/org/apache/pig/test/TestPigServer.java
    hadoop/pig/branches/branch-0.7/test/org/apache/pig/test/Util.java

Modified: hadoop/pig/branches/branch-0.7/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/hadoop/pig/branches/branch-0.7/CHANGES.txt?rev=930169&r1=930168&r2=930169&view=diff
==============================================================================
--- hadoop/pig/branches/branch-0.7/CHANGES.txt (original)
+++ hadoop/pig/branches/branch-0.7/CHANGES.txt Fri Apr  2 05:30:16 2010
@@ -179,6 +179,9 @@ OPTIMIZATIONS
 
 BUG FIXES
 
+PIG-1346: In unit tests Util.executeShellCommand relies on java commands being
+in the path and does not consider JAVA_HOME (pradeepkth)
+
 PIG-1336: Optimize POStore serialized into JobConf (daijy)
 
 PIG-1335: UDFFinder should find LoadFunc used by POCast (daijy)

Modified: 
hadoop/pig/branches/branch-0.7/test/org/apache/pig/test/TestLocal2.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/branches/branch-0.7/test/org/apache/pig/test/TestLocal2.java?rev=930169&r1=930168&r2=930169&view=diff
==============================================================================
--- hadoop/pig/branches/branch-0.7/test/org/apache/pig/test/TestLocal2.java 
(original)
+++ hadoop/pig/branches/branch-0.7/test/org/apache/pig/test/TestLocal2.java Fri 
Apr  2 05:30:16 2010
@@ -235,7 +235,7 @@ public class TestLocal2 extends TestCase
         try {
             pigFile.createNewFile();
             int status,status2;
-            status = Util.executeShellCommand("java -cp "+ 
+            status = Util.executeJavaCommand("java -cp "+ 
                     System.getProperty("java.class.path") + 
                     "  org.apache.pig.Main -x local " + 
pigFile.getAbsolutePath() );
 
@@ -253,7 +253,7 @@ public class TestLocal2 extends TestCase
             PrintStream ps = new PrintStream(siteFile);
             ps.print(contents);
             ps.close();
-            status2 = Util.executeShellCommand("java -cp "+ 
+            status2 = Util.executeJavaCommand("java -cp "+ 
                     System.getProperty("java.class.path") + 
                     "  org.apache.pig.Main -x local " + 
pigFile.getAbsolutePath() );
             assertEquals( "Without a mapred-site.xml pig should just run", 0, 
status );

Modified: 
hadoop/pig/branches/branch-0.7/test/org/apache/pig/test/TestPigContext.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/branches/branch-0.7/test/org/apache/pig/test/TestPigContext.java?rev=930169&r1=930168&r2=930169&view=diff
==============================================================================
--- hadoop/pig/branches/branch-0.7/test/org/apache/pig/test/TestPigContext.java 
(original)
+++ hadoop/pig/branches/branch-0.7/test/org/apache/pig/test/TestPigContext.java 
Fri Apr  2 05:30:16 2010
@@ -144,13 +144,13 @@ public class TestPigContext extends Test
         
         // compile
         int status;
-        status = Util.executeShellCommand("javac -cp 
"+System.getProperty("java.class.path") + " " + udf1JavaSrc);
-        status = Util.executeShellCommand("javac -cp 
"+System.getProperty("java.class.path") + " " + udf2JavaSrc);
+        status = Util.executeJavaCommand("javac -cp 
"+System.getProperty("java.class.path") + " " + udf1JavaSrc);
+        status = Util.executeJavaCommand("javac -cp 
"+System.getProperty("java.class.path") + " " + udf2JavaSrc);
                 
         // generate jar file
         String jarName = "TestUDFJar.jar";
         String jarFile = tmpDir.getAbsolutePath() + FILE_SEPARATOR + jarName;
-        status = Util.executeShellCommand("jar -cf " + 
tmpDir.getAbsolutePath() + FILE_SEPARATOR + jarName + 
+        status = Util.executeJavaCommand("jar -cf " + tmpDir.getAbsolutePath() 
+ FILE_SEPARATOR + jarName + 
                               " -C " + tmpDir.getAbsolutePath() + " " + "com");
         assertTrue(status==0);
         Properties properties = cluster.getProperties();

Modified: 
hadoop/pig/branches/branch-0.7/test/org/apache/pig/test/TestPigServer.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/branches/branch-0.7/test/org/apache/pig/test/TestPigServer.java?rev=930169&r1=930168&r2=930169&view=diff
==============================================================================
--- hadoop/pig/branches/branch-0.7/test/org/apache/pig/test/TestPigServer.java 
(original)
+++ hadoop/pig/branches/branch-0.7/test/org/apache/pig/test/TestPigServer.java 
Fri Apr  2 05:30:16 2010
@@ -246,7 +246,7 @@ public class TestPigServer extends TestC
         
         // compile
         int status;
-        status = Util.executeShellCommand("javac " + dir + FILE_SEPARATOR + 
subDir +
+        status = Util.executeJavaCommand("javac " + dir + FILE_SEPARATOR + 
subDir +
                                FILE_SEPARATOR + className + ".java");
         assertTrue(status==0);
 
@@ -255,7 +255,7 @@ public class TestPigServer extends TestC
                   FILE_SEPARATOR + className + ".java")).delete();
 
         // generate jar file
-        status = Util.executeShellCommand("jar -cf " + dir + FILE_SEPARATOR + 
jarName + " " +
+        status = Util.executeJavaCommand("jar -cf " + dir + FILE_SEPARATOR + 
jarName + " " +
                               "-C " + dir + " " + subDir);
         assertTrue(status==0);
         

Modified: hadoop/pig/branches/branch-0.7/test/org/apache/pig/test/Util.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/branches/branch-0.7/test/org/apache/pig/test/Util.java?rev=930169&r1=930168&r2=930169&view=diff
==============================================================================
--- hadoop/pig/branches/branch-0.7/test/org/apache/pig/test/Util.java (original)
+++ hadoop/pig/branches/branch-0.7/test/org/apache/pig/test/Util.java Fri Apr  
2 05:30:16 2010
@@ -482,7 +482,12 @@ public class Util {
         pigServer.registerScript(f.getCanonicalPath());
     }
     
-    public static int executeShellCommand(String cmd) throws Exception {
+    public static int executeJavaCommand(String cmd) throws Exception {
+        String javaHome = System.getenv("JAVA_HOME");
+        if(javaHome != null) {
+            String fileSeparator = System.getProperty("file.separator");
+            cmd = javaHome + fileSeparator + "bin" + fileSeparator + cmd;
+        }
         Process cmdProc = Runtime.getRuntime().exec(cmd);
         
         cmdProc.waitFor();


Reply via email to