[apex-core] branch master updated: APEXCORE-817 Specifying full path for the java command line programs

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[apex-core] branch master updated: APEXCORE-817 Specifying full path for the java command line programs

vrozov
This is an automated email from the ASF dual-hosted git repository.

vrozov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apex-core.git


The following commit(s) were added to refs/heads/master by this push:
     new 819026e  APEXCORE-817 Specifying full path for the java command line programs
819026e is described below

commit 819026eca63806b774fee85f7d2ebd9784a015d9
Author: Pramod Immaneni <[hidden email]>
AuthorDate: Mon Jun 18 13:38:02 2018 -0700

    APEXCORE-817 Specifying full path for the java command line programs
---
 .../com/datatorrent/stram/StramLocalClusterTest.java     | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/engine/src/test/java/com/datatorrent/stram/StramLocalClusterTest.java b/engine/src/test/java/com/datatorrent/stram/StramLocalClusterTest.java
index 56641f8..fd475c8 100644
--- a/engine/src/test/java/com/datatorrent/stram/StramLocalClusterTest.java
+++ b/engine/src/test/java/com/datatorrent/stram/StramLocalClusterTest.java
@@ -60,7 +60,7 @@ import com.datatorrent.stram.plan.logical.LogicalPlan;
 import com.datatorrent.stram.plan.physical.PTOperator;
 import com.datatorrent.stram.support.ManualScheduledExecutorService;
 import com.datatorrent.stram.support.StramTestSupport;
-
+import com.datatorrent.stram.util.VersionInfo;
 
 public class StramLocalClusterTest
 {
@@ -381,14 +381,18 @@ public class StramLocalClusterTest
     String sourceDir = "src/test/resources/dynamicJar/";
     String destDir = testMeta.getPath();
 
+    // The compiled java class should be loadable by the current java runtime hence setting the compile target version
+    // to be the same
+    String binLocation = getJavaBinLocation();
+
     Process p = Runtime.getRuntime()
-        .exec(new String[] {"javac", "-d", destDir, sourceDir + pojoClassName + ".java"}, null, null);
+        .exec(new String[] {binLocation + "javac", "-d", destDir, sourceDir + pojoClassName + ".java"}, null, null);
     IOUtils.copy(p.getInputStream(), System.out);
     IOUtils.copy(p.getErrorStream(), System.err);
     Assert.assertEquals(0, p.waitFor());
 
     p = Runtime.getRuntime()
-        .exec(new String[] {"jar", "-cf", pojoClassName + ".jar", pojoClassName + ".class"}, null, new File(destDir));
+        .exec(new String[] {binLocation + "jar", "-cf", pojoClassName + ".jar", pojoClassName + ".class"}, null, new File(destDir));
     IOUtils.copy(p.getInputStream(), System.out);
     IOUtils.copy(p.getErrorStream(), System.err);
     Assert.assertEquals(0, p.waitFor());
@@ -396,6 +400,12 @@ public class StramLocalClusterTest
     return new File(destDir, pojoClassName + ".jar").getAbsolutePath();
   }
 
+  private String getJavaBinLocation()
+  {
+    String javaHome = System.getProperty("java.home");
+    return VersionInfo.compare(System.getProperty("java.version"), "1.9") < 0 ? javaHome + "/../bin/" : javaHome + "/bin/";
+  }
+
   @Test
   public void testAppPath() throws Exception
   {