Author: pradeepkth
Date: Fri Apr  2 05:27:39 2010
New Revision: 930168

URL: http://svn.apache.org/viewvc?rev=930168&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/trunk/CHANGES.txt
    hadoop/pig/trunk/test/org/apache/pig/test/TestLocal2.java
    hadoop/pig/trunk/test/org/apache/pig/test/TestPigContext.java
    hadoop/pig/trunk/test/org/apache/pig/test/TestPigServer.java
    hadoop/pig/trunk/test/org/apache/pig/test/Util.java

Modified: hadoop/pig/trunk/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/CHANGES.txt?rev=930168&r1=930167&r2=930168&view=diff
==============================================================================
--- hadoop/pig/trunk/CHANGES.txt (original)
+++ hadoop/pig/trunk/CHANGES.txt Fri Apr  2 05:27:39 2010
@@ -39,6 +39,9 @@ BUG FIXES
 
 PIG-1313: PigServer leaks memory over time (billgraham via daijy)
 
+PIG-1346: In unit tests Util.executeShellCommand relies on java commands being
+in the path and does not consider JAVA_HOME (pradeepkth)
+
 Release 0.7.0 - Unreleased
 
 INCOMPATIBLE CHANGES

Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestLocal2.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestLocal2.java?rev=930168&r1=930167&r2=930168&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestLocal2.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestLocal2.java Fri Apr  2 
05:27:39 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/trunk/test/org/apache/pig/test/TestPigContext.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestPigContext.java?rev=930168&r1=930167&r2=930168&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestPigContext.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestPigContext.java Fri Apr  2 
05:27:39 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/trunk/test/org/apache/pig/test/TestPigServer.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestPigServer.java?rev=930168&r1=930167&r2=930168&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestPigServer.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestPigServer.java Fri Apr  2 
05:27:39 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/trunk/test/org/apache/pig/test/Util.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/Util.java?rev=930168&r1=930167&r2=930168&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/Util.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/Util.java Fri Apr  2 05:27:39 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