continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From batkin...@apache.org
Subject svn commit: r1656286 - /continuum/trunk/continuum-api/src/test/java/org/apache/continuum/utils/shell/DefaultShellCommandHelperTest.java
Date Sun, 01 Feb 2015 12:26:26 GMT
Author: batkinson
Date: Sun Feb  1 12:26:25 2015
New Revision: 1656286

URL: http://svn.apache.org/r1656286
Log:
Test no longer relies on java being in user's path.

Modified:
    continuum/trunk/continuum-api/src/test/java/org/apache/continuum/utils/shell/DefaultShellCommandHelperTest.java

Modified: continuum/trunk/continuum-api/src/test/java/org/apache/continuum/utils/shell/DefaultShellCommandHelperTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/test/java/org/apache/continuum/utils/shell/DefaultShellCommandHelperTest.java?rev=1656286&r1=1656285&r2=1656286&view=diff
==============================================================================
--- continuum/trunk/continuum-api/src/test/java/org/apache/continuum/utils/shell/DefaultShellCommandHelperTest.java
(original)
+++ continuum/trunk/continuum-api/src/test/java/org/apache/continuum/utils/shell/DefaultShellCommandHelperTest.java
Sun Feb  1 12:26:25 2015
@@ -20,9 +20,14 @@ package org.apache.continuum.utils.shell
  */
 
 import junit.framework.TestCase;
+import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.io.File;
+import java.util.Arrays;
+import java.util.List;
+
 /**
  * @see org.apache.continuum.utils.shell.DefaultShellCommandHelper
  */
@@ -31,11 +36,20 @@ public class DefaultShellCommandHelperTe
 {
     private static final Logger log = LoggerFactory.getLogger( DefaultShellCommandHelper.class
);
 
-    DefaultShellCommandHelper helper;
+    private DefaultShellCommandHelper helper;
+
+    private String javaPath;
+
+    private String sleepClasspath;
 
     public void setUp()
     {
         helper = new DefaultShellCommandHelper();
+
+        List<String> javaPathComponents =
+            Arrays.asList( new String[] { System.getProperty( "java.home" ), "bin", "java"
} );
+        javaPath = StringUtils.join( javaPathComponents, File.separator );
+        sleepClasspath = System.getProperty( "sleepClasspath" );
     }
 
     public void tearDown()
@@ -83,7 +97,7 @@ public class DefaultShellCommandHelperTe
     {
         long virtualPid = 1, sleepMillis = 100;
         RunChecker checker = new RunChecker( helper, virtualPid, sleepMillis );
-        String[] cmdArgs = { "-cp", System.getProperty( "sleepClasspath" ), Sleep.class.getCanonicalName(),
"1" };
+        String[] cmdArgs = { "-cp", sleepClasspath, Sleep.class.getCanonicalName(), "1" };
 
         // Verify process isn't running initially
         checker.run();
@@ -93,7 +107,7 @@ public class DefaultShellCommandHelperTe
         Thread checkerThread = new Thread( checker );
         checkerThread.start();
 
-        helper.executeShellCommand( null, "java", cmdArgs, new LogOutputConsumer( log ),
virtualPid, null );
+        helper.executeShellCommand( null, javaPath, cmdArgs, new LogOutputConsumer( log ),
virtualPid, null );
         checkerThread.join();
         assertTrue( "Expected that command was running", checker.wasRunning );
 



Mime
View raw message