You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by sg...@apache.org on 2016/01/06 14:10:09 UTC
svn commit: r1723311 -
/commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/issues/Exec65Test.java
Author: sgoeschl
Date: Wed Jan 6 13:10:09 2016
New Revision: 1723311
URL: http://svn.apache.org/viewvc?rev=1723311&view=rev
Log:
[EXEC-65] Add test with plain vanilla "Runtime" usage to show that we can indeed kill the sleeping process
Modified:
commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/issues/Exec65Test.java
Modified: commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/issues/Exec65Test.java
URL: http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/issues/Exec65Test.java?rev=1723311&r1=1723310&r2=1723311&view=diff
==============================================================================
--- commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/issues/Exec65Test.java (original)
+++ commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/issues/Exec65Test.java Wed Jan 6 13:10:09 2016
@@ -22,6 +22,8 @@ import org.junit.Test;
import java.io.File;
+import static org.junit.Assert.assertTrue;
+
/**
* Test to show that watchdog can destroy 'sudo' and 'sleep'.
*
@@ -60,6 +62,21 @@ public class Exec65Test {
executor.execute(command);
}
+ @Test(timeout = 15000)
+ public void testExec65WithSleepUsingShellScriptAndRuntimeDirectly() throws Exception
+ {
+ Process process = Runtime.getRuntime().exec(TestUtil.resolveScriptForOS(testDir + "/sleep").getAbsolutePath());
+ Thread.sleep(3000);
+
+ process.destroy();
+
+ while(process.isAlive()) {
+ Thread.sleep(50);
+ }
+
+ assertTrue(process.exitValue() != 0);
+ }
+
/**
* Please note that this tests make assumptions about the environment. It assumes
* that user "root" exists and that the current user is not a "sudoer" already.
Re: svn commit: r1723311 - /commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/issues/Exec65Test.java
Posted by sebb <se...@gmail.com>.
On 6 January 2016 at 13:10, <sg...@apache.org> wrote:
> Author: sgoeschl
> Date: Wed Jan 6 13:10:09 2016
> New Revision: 1723311
>
> URL: http://svn.apache.org/viewvc?rev=1723311&view=rev
> Log:
> [EXEC-65] Add test with plain vanilla "Runtime" usage to show that we can indeed kill the sleeping process
-1 - please fix the missing Jaav method
> Modified:
> commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/issues/Exec65Test.java
>
> Modified: commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/issues/Exec65Test.java
> URL: http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/issues/Exec65Test.java?rev=1723311&r1=1723310&r2=1723311&view=diff
> ==============================================================================
> --- commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/issues/Exec65Test.java (original)
> +++ commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/issues/Exec65Test.java Wed Jan 6 13:10:09 2016
> @@ -22,6 +22,8 @@ import org.junit.Test;
>
> import java.io.File;
>
> +import static org.junit.Assert.assertTrue;
> +
> /**
> * Test to show that watchdog can destroy 'sudo' and 'sleep'.
> *
> @@ -60,6 +62,21 @@ public class Exec65Test {
> executor.execute(command);
> }
>
> + @Test(timeout = 15000)
> + public void testExec65WithSleepUsingShellScriptAndRuntimeDirectly() throws Exception
> + {
> + Process process = Runtime.getRuntime().exec(TestUtil.resolveScriptForOS(testDir + "/sleep").getAbsolutePath());
> + Thread.sleep(3000);
> +
> + process.destroy();
> +
> + while(process.isAlive()) {
This requires Java 8; EXEC currently targets 1.5 I think.
As this is a test case, I think it should not force a Java update.
> + Thread.sleep(50);
> + }
> +
> + assertTrue(process.exitValue() != 0);
> + }
> +
> /**
> * Please note that this tests make assumptions about the environment. It assumes
> * that user "root" exists and that the current user is not a "sudoer" already.
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org