commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sgoes...@apache.org
Subject svn commit: r999066 - in /commons/proper/exec/trunk/src/test: java/org/apache/commons/exec/TutorialTest.java scripts/acrord32.bat scripts/acrord32.sh
Date Mon, 20 Sep 2010 19:17:56 GMT
Author: sgoeschl
Date: Mon Sep 20 19:17:55 2010
New Revision: 999066

URL: http://svn.apache.org/viewvc?rev=999066&view=rev
Log:
The simulated printing takes now 10 instead of 3 seconds

Modified:
    commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/TutorialTest.java
    commons/proper/exec/trunk/src/test/scripts/acrord32.bat
    commons/proper/exec/trunk/src/test/scripts/acrord32.sh

Modified: commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/TutorialTest.java
URL: http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/TutorialTest.java?rev=999066&r1=999065&r2=999066&view=diff
==============================================================================
--- commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/TutorialTest.java (original)
+++ commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/TutorialTest.java Mon
Sep 20 19:17:55 2010
@@ -42,13 +42,16 @@ public class TutorialTest extends TestCa
 
     public void testTutorialExample() throws Exception {
 
+        long printJobTimeout = 15000;
+        boolean printInBackground = false;
         File pdfFile = new File("./pom.xml");
-        PrintResultFuture printResult;
+
+        PrintResultHandler printResult;
 
         try {
+            // printing takes around 10 seconds            
             System.out.println("[main] Preparing print job ...");
-            // printing takes around 3 seconds
-            printResult = print(pdfFile, 10000, true);
+            printResult = print(pdfFile, printJobTimeout, printInBackground);
             System.out.println("[main] Successfully sent the print job ...");
         }
         catch(Exception e) {
@@ -60,6 +63,7 @@ public class TutorialTest extends TestCa
         // come back to check the print result
         System.out.println("[main] Test is exiting but waiting for the print job to finish...");
         printResult.waitFor();
+        System.out.println("[main] The print job has finished ...");
     }
 
     /**
@@ -71,12 +75,12 @@ public class TutorialTest extends TestCa
      * @return a print result handler (implementing a future)
      * @throws IOException the test failed
      */
-    public PrintResultFuture print(File file, long printJobTimeout, boolean printInBackground)
+    public PrintResultHandler print(File file, long printJobTimeout, boolean printInBackground)
             throws IOException {
 
         int exitValue;
         ExecuteWatchdog watchdog = null;
-        PrintResultFuture resultFuture;
+        PrintResultHandler resultHandler;
 
         // build up the command line to using a 'java.io.File'
         HashMap map = new HashMap();
@@ -93,35 +97,35 @@ public class TutorialTest extends TestCa
         
         // create a watchdog if requested
         if(printJobTimeout > 0) {
-
             watchdog = new ExecuteWatchdog(printJobTimeout);
             executor.setWatchdog(watchdog);
         }
 
+        // pass a "ExecuteResultHandler" when doing background printing
         if(printInBackground) {
             System.out.println("[print] Executing non-blocking print job  ...");
-            resultFuture = new PrintResultFuture(watchdog);
-            executor.execute(commandLine, resultFuture);
+            resultHandler = new PrintResultHandler(watchdog);
+            executor.execute(commandLine, resultHandler);
         }
         else {
             System.out.println("[print] Executing blocking print job  ...");
             exitValue = executor.execute(commandLine);
-            resultFuture = new PrintResultFuture(exitValue);
+            resultHandler = new PrintResultHandler(exitValue);
         }
 
-        return resultFuture;
+        return resultHandler;
     }
 
-    private class PrintResultFuture extends DefaultExecuteResultHandler {
+    private class PrintResultHandler extends DefaultExecuteResultHandler {
 
         private ExecuteWatchdog watchdog;
 
-        public PrintResultFuture(ExecuteWatchdog watchdog)
+        public PrintResultHandler(ExecuteWatchdog watchdog)
         {
             this.watchdog = watchdog;
         }
 
-        public PrintResultFuture(int exitValue) {
+        public PrintResultHandler(int exitValue) {
             super.onProcessComplete(exitValue);
         }
         

Modified: commons/proper/exec/trunk/src/test/scripts/acrord32.bat
URL: http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/test/scripts/acrord32.bat?rev=999066&r1=999065&r2=999066&view=diff
==============================================================================
--- commons/proper/exec/trunk/src/test/scripts/acrord32.bat (original)
+++ commons/proper/exec/trunk/src/test/scripts/acrord32.bat Mon Sep 20 19:17:55 2010
@@ -16,6 +16,6 @@ REM See the License for the specific lan
 REM limitations under the License.
 
 echo "[acrord32] Printing the following document : '%3'"
-ping -n 3 -w 1000 127.0.0.1 > nul
+ping -n 10 -w 1000 127.0.0.1 > nul
 echo "[acrord32] Finished printing"
 exit 1

Modified: commons/proper/exec/trunk/src/test/scripts/acrord32.sh
URL: http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/test/scripts/acrord32.sh?rev=999066&r1=999065&r2=999066&view=diff
==============================================================================
--- commons/proper/exec/trunk/src/test/scripts/acrord32.sh (original)
+++ commons/proper/exec/trunk/src/test/scripts/acrord32.sh Mon Sep 20 19:17:55 2010
@@ -20,7 +20,10 @@
 # Simulate printing a PDF document
 
 echo "[acrord32] Printing the following document : '$3'"
-sleep 3
+for i in {1..10}
+do
+   sleep 1
+done
 echo "[acrord32] Finished printing"
 exit 1
 



Mime
View raw message