Author: sgoeschl
Date: Mon May 31 22:16:39 2010
New Revision: 949877
URL: http://svn.apache.org/viewvc?rev=949877&view=rev
Log:
Renaming 'MockExecuteResultHandler' to 'DefaultExecuteResultHandler' and move it from test
code to production code.
Added:
commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/DefaultExecuteResultHandler.java
- copied, changed from r949832, commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/MockExecuteResultHandler.java
Removed:
commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/MockExecuteResultHandler.java
Modified:
commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/ExecuteResultHandler.java
commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java
Copied: commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/DefaultExecuteResultHandler.java
(from r949832, commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/MockExecuteResultHandler.java)
URL: http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/DefaultExecuteResultHandler.java?p2=commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/DefaultExecuteResultHandler.java&p1=commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/MockExecuteResultHandler.java&r1=949832&r2=949877&rev=949877&view=diff
==============================================================================
--- commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/MockExecuteResultHandler.java
(original)
+++ commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/DefaultExecuteResultHandler.java
Mon May 31 22:16:39 2010
@@ -18,19 +18,26 @@
package org.apache.commons.exec;
-public class MockExecuteResultHandler implements ExecuteResultHandler {
+/**
+ * A default implementation of 'ExecuteResultHandler' used for asynchronous
+ * process handling.
+ */
+public class DefaultExecuteResultHandler implements ExecuteResultHandler {
+ /** The exit value of the finished process */
private int exitValue;
+
+ /** Any offending exception */
private ExecuteException exception;
-
- /* (non-Javadoc)
+
+ /**
* @see org.apache.commons.exec.ExecuteResultHandler#onProcessComplete(int)
*/
public void onProcessComplete(int exitValue) {
this.exitValue = exitValue;
}
- /* (non-Javadoc)
+ /**
* @see org.apache.commons.exec.ExecuteResultHandler#onProcessFailed(org.apache.commons.exec.ExecuteException)
*/
public void onProcessFailed(ExecuteException e) {
@@ -51,5 +58,4 @@ public class MockExecuteResultHandler im
public int getExitValue() {
return exitValue;
}
-
-}
+}
\ No newline at end of file
Modified: commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/ExecuteResultHandler.java
URL: http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/ExecuteResultHandler.java?rev=949877&r1=949876&r2=949877&view=diff
==============================================================================
--- commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/ExecuteResultHandler.java
(original)
+++ commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/ExecuteResultHandler.java
Mon May 31 22:16:39 2010
@@ -26,14 +26,14 @@ package org.apache.commons.exec;
public interface ExecuteResultHandler {
/**
- * The asynchronous exection completed.
+ * The asynchronous execution completed.
*
- * @param exitValue the exit value of the subprocess
+ * @param exitValue the exit value of the sub-process
*/
void onProcessComplete(int exitValue);
/**
- * The asynchronous exection failed.
+ * The asynchronous execution failed.
*
* @param e the <code>ExecuteException</code> containing the root cause
*/
Modified: commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java?rev=949877&r1=949876&r2=949877&view=diff
==============================================================================
--- commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java
(original)
+++ commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java
Mon May 31 22:16:39 2010
@@ -125,7 +125,7 @@ public class DefaultExecutorTest extends
public void testExecuteAsync() throws Exception {
CommandLine cl = new CommandLine(testScript);
- MockExecuteResultHandler handler = new MockExecuteResultHandler();
+ DefaultExecuteResultHandler handler = new DefaultExecuteResultHandler();
exec.execute(cl, handler);
@@ -139,7 +139,7 @@ public class DefaultExecutorTest extends
public void testExecuteAsyncWithError() throws Exception {
CommandLine cl = new CommandLine(errorTestScript);
- MockExecuteResultHandler handler = new MockExecuteResultHandler();
+ DefaultExecuteResultHandler handler = new DefaultExecuteResultHandler();
exec.execute(cl, handler);
@@ -161,7 +161,7 @@ public class DefaultExecutorTest extends
CommandLine cl = new CommandLine(foreverTestScript);
ExecuteWatchdog watchdog = new ExecuteWatchdog(Integer.MAX_VALUE);
exec.setWatchdog(watchdog);
- MockExecuteResultHandler handler = new MockExecuteResultHandler();
+ DefaultExecuteResultHandler handler = new DefaultExecuteResultHandler();
exec.execute(cl, handler);
// wait for script to run
Thread.sleep(2000);
@@ -182,7 +182,7 @@ public class DefaultExecutorTest extends
CommandLine cl = new CommandLine(foreverTestScript);
ExecuteWatchdog watchdog = new ExecuteWatchdog(3000);
exec.setWatchdog(watchdog);
- MockExecuteResultHandler handler = new MockExecuteResultHandler();
+ DefaultExecuteResultHandler handler = new DefaultExecuteResultHandler();
exec.execute(cl, handler);
// wait for script to be terminated by the watchdog
Thread.sleep(6000);
@@ -247,7 +247,7 @@ public class DefaultExecutorTest extends
*/
public void testExecuteAsyncWithNonExistingApplication() throws Exception {
CommandLine cl = new CommandLine(nonExistingTestScript);
- MockExecuteResultHandler handler = new MockExecuteResultHandler();
+ DefaultExecuteResultHandler handler = new DefaultExecuteResultHandler();
exec.execute(cl, handler);
Thread.sleep(2000);
assertNotNull(handler.getException());
@@ -334,7 +334,7 @@ public class DefaultExecutorTest extends
public void testExecuteAsyncWithProcessDestroyer() throws Exception {
CommandLine cl = new CommandLine(foreverTestScript);
- MockExecuteResultHandler handler = new MockExecuteResultHandler();
+ DefaultExecuteResultHandler handler = new DefaultExecuteResultHandler();
ShutdownHookProcessDestroyer processDestroyer = new ShutdownHookProcessDestroyer();
ExecuteWatchdog watchdog = new ExecuteWatchdog(Integer.MAX_VALUE);
@@ -535,19 +535,19 @@ public class DefaultExecutorTest extends
public void testExec44() throws Exception {
CommandLine cl = new CommandLine(foreverTestScript);
- MockExecuteResultHandler handler = new MockExecuteResultHandler();
+ DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
ExecuteWatchdog watchdog = new ExecuteWatchdog(ExecuteWatchdog.INFINITE_TIMEOUT);
exec.setWatchdog(watchdog);
- exec.execute(cl, handler);
+ exec.execute(cl, resultHandler);
// wait for script to run
Thread.sleep(5000);
- assertTrue(watchdog.isWatching());
+ assertTrue("The watchdog is watching the process", watchdog.isWatching());
// terminate it
watchdog.destroyProcess();
- assertTrue(watchdog.killedProcess());
- assertFalse(watchdog.isWatching());
+ assertTrue("The watchdog has killed the process", watchdog.killedProcess());
+ assertFalse("The watchdog is no longer watching any process", watchdog.isWatching());
}
}
|