Author: pradeepkth
Date: Fri Apr  2 06:27:05 2010
New Revision: 930174

URL: http://svn.apache.org/viewvc?rev=930174&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.6/CHANGES.txt
    hadoop/pig/branches/branch-0.6/test/org/apache/pig/test/TestPigContext.java
    hadoop/pig/branches/branch-0.6/test/org/apache/pig/test/TestPigServer.java
    hadoop/pig/branches/branch-0.6/test/org/apache/pig/test/Util.java

Modified: hadoop/pig/branches/branch-0.6/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/hadoop/pig/branches/branch-0.6/CHANGES.txt?rev=930174&r1=930173&r2=930174&view=diff
==============================================================================
--- hadoop/pig/branches/branch-0.6/CHANGES.txt (original)
+++ hadoop/pig/branches/branch-0.6/CHANGES.txt Fri Apr  2 06:27:05 2010
@@ -151,6 +151,9 @@ PIG-922: Logical optimizer: push up proj
 
 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-1239: PigContext.connect() should not create a jobClient and jobClient
 should be created on demand when needed (pradeepkth)
 

Modified: 
hadoop/pig/branches/branch-0.6/test/org/apache/pig/test/TestPigContext.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/branches/branch-0.6/test/org/apache/pig/test/TestPigContext.java?rev=930174&r1=930173&r2=930174&view=diff
==============================================================================
--- hadoop/pig/branches/branch-0.6/test/org/apache/pig/test/TestPigContext.java 
(original)
+++ hadoop/pig/branches/branch-0.6/test/org/apache/pig/test/TestPigContext.java 
Fri Apr  2 06:27:05 2010
@@ -146,12 +146,12 @@ 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";
-        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);
         

Modified: 
hadoop/pig/branches/branch-0.6/test/org/apache/pig/test/TestPigServer.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/branches/branch-0.6/test/org/apache/pig/test/TestPigServer.java?rev=930174&r1=930173&r2=930174&view=diff
==============================================================================
--- hadoop/pig/branches/branch-0.6/test/org/apache/pig/test/TestPigServer.java 
(original)
+++ hadoop/pig/branches/branch-0.6/test/org/apache/pig/test/TestPigServer.java 
Fri Apr  2 06:27:05 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.6/test/org/apache/pig/test/Util.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/branches/branch-0.6/test/org/apache/pig/test/Util.java?rev=930174&r1=930173&r2=930174&view=diff
==============================================================================
--- hadoop/pig/branches/branch-0.6/test/org/apache/pig/test/Util.java (original)
+++ hadoop/pig/branches/branch-0.6/test/org/apache/pig/test/Util.java Fri Apr  
2 06:27:05 2010
@@ -449,7 +449,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