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 2010/06/04 11:18:27 UTC

svn commit: r951335 - /commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java

Author: sgoeschl
Date: Fri Jun  4 09:18:26 2010
New Revision: 951335

URL: http://svn.apache.org/viewvc?rev=951335&view=rev
Log:
[EXEC-42] Make sure that the tutorial tests run on platforms I can test

Modified:
    commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java

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=951335&r1=951334&r2=951335&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 Fri Jun  4 09:18:26 2010
@@ -572,56 +572,57 @@ public class DefaultExecutorTest extends
         final long timeout1 = 5*1000;
         final long timeout2 = 8*1000;
 
-        // build up the command line
-        CommandLine commandLine = CommandLine.parse(this.acroRd32Script.getAbsolutePath());
-        commandLine.addArgument("/p");
-        commandLine.addArgument("/h");
-        commandLine.addArgument("${file}");
-        HashMap map = new HashMap();
-        map.put("file", "./pom.xml");
-        commandLine.setSubstitutionMap(map);
-
-        // asynchronous execution is defined by using a 'resultHander'
-        DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler() {
-            public void onProcessComplete(int exitValue) {
-                super.onProcessComplete(exitValue);
-                System.out.println("[resultHandler] The print process has exited with the following value: " + exitValue);
-            }
-            public void onProcessFailed(ExecuteException e) {
-                super.onProcessFailed(e);
-                System.err.println("[resultHandler] The print process was not successfully executed due to : " + e.getMessage());
-            }
-        };
-
-        ExecuteWatchdog watchdog = new ExecuteWatchdog(timeout1);
-
-        // execute the asynchronous process and consider '1' as success
-        Executor executor = new DefaultExecutor();
-        executor.setExitValue(1);
-        executor.setStreamHandler(new PumpStreamHandler());
-        executor.setWatchdog(watchdog);
-        executor.execute(commandLine, resultHandler);
-
-        // wait for some time (longer than the timeout for the watchdog to avoid race conditions)
-        Thread.sleep(timeout2);
- 
-        if(resultHandler.hasResult()) {
-            if(resultHandler.getException() != null) {
-                System.err.println("[application] The document was NOT successfully printed");
-            }
-            else {
-                System.out.println("[application] The document was successfully printed");
-            }
-        }
-        else {
-            if(watchdog.killedProcess()) {
-                System.err.println("[application] The print process was killed by the watchdog");
+        if(OS.isFamilyUnix() || OS.isFamilyWindows())
+        {
+            // build up the command line
+            CommandLine commandLine = CommandLine.parse(this.acroRd32Script.getAbsolutePath());
+            commandLine.addArgument("/p");
+            commandLine.addArgument("/h");
+            commandLine.addArgument("${file}");
+            HashMap map = new HashMap();
+            map.put("file", "./pom.xml");
+            commandLine.setSubstitutionMap(map);
+
+            // asynchronous execution is defined by using a 'resultHander'
+            DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler() {
+                public void onProcessComplete(int exitValue) {
+                    super.onProcessComplete(exitValue);
+                    System.out.println("[resultHandler] The print process has exited with the following value: " + exitValue);
+                }
+                public void onProcessFailed(ExecuteException e) {
+                    super.onProcessFailed(e);
+                    System.err.println("[resultHandler] The print process was not successfully executed due to : " + e.getMessage());
+                }
+            };
+
+            ExecuteWatchdog watchdog = new ExecuteWatchdog(timeout1);
+
+            // execute the asynchronous process and consider '1' as success
+            Executor executor = new DefaultExecutor();
+            executor.setExitValue(1);
+            executor.setStreamHandler(new PumpStreamHandler());
+            executor.setWatchdog(watchdog);
+            executor.execute(commandLine, resultHandler);
+
+            // wait for some time (longer than the timeout for the watchdog to avoid race conditions)
+            Thread.sleep(timeout2);
+
+            if(resultHandler.hasResult()) {
+                if(resultHandler.getException() != null) {
+                    System.err.println("[application] The document was NOT successfully printed");
+                }
+                else {
+                    System.out.println("[application] The document was successfully printed");
+                }
             }
             else {
-                System.err.println("[application] The print process is still running");
+                if(watchdog.killedProcess()) {
+                    System.err.println("[application] The print process was killed by the watchdog");
+                }
+                else {
+                    System.err.println("[application] The print process is still running");
+                }
             }
         }
-
-
     }
 }