commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sgoes...@apache.org
Subject svn commit: r1031700 - in /commons/proper/exec/trunk/src: site/apt/tutorial.apt test/java/org/apache/commons/exec/TutorialTest.java
Date Fri, 05 Nov 2010 18:30:16 GMT
Author: sgoeschl
Date: Fri Nov  5 18:30:15 2010
New Revision: 1031700

URL: http://svn.apache.org/viewvc?rev=1031700&view=rev
Log:
Updated tutorial exampl

Modified:
    commons/proper/exec/trunk/src/site/apt/tutorial.apt
    commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/TutorialTest.java

Modified: commons/proper/exec/trunk/src/site/apt/tutorial.apt
URL: http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/site/apt/tutorial.apt?rev=1031700&r1=1031699&r2=1031700&view=diff
==============================================================================
--- commons/proper/exec/trunk/src/site/apt/tutorial.apt (original)
+++ commons/proper/exec/trunk/src/site/apt/tutorial.apt Fri Nov  5 18:30:15 2010
@@ -47,9 +47,9 @@ Apache Commons Exec
 
 +----------------------------------------------------------------------------
 String line = "AcroRd32.exe /p /h " + file.getAbsolutePath();
-CommandLine commandLine = CommandLine.parse(line);
+CommandLine cmdLine = CommandLine.parse(line);
 DefaultExecutor executor = new DefaultExecutor();
-int exitValue = executor.execute(commandLine);
+int exitValue = executor.execute(cmdLine);
 +----------------------------------------------------------------------------
 
   You successfully printed your first PDF document but at the end an exception is thrown
- what
@@ -59,10 +59,10 @@ int exitValue = executor.execute(command
 
 +----------------------------------------------------------------------------
 String line = "AcroRd32.exe /p /h " + file.getAbsolutePath();
-CommandLine commandLine = CommandLine.parse(line);
+CommandLine cmdLine = CommandLine.parse(line);
 DefaultExecutor executor = new DefaultExecutor();
 executor.setExitValue(1);
-int exitValue = executor.execute(commandLine);
+int exitValue = executor.execute(cmdLine);
 +----------------------------------------------------------------------------
 
 * To Watchdog Or Not To Watchdog
@@ -75,12 +75,12 @@ int exitValue = executor.execute(command
 
 +----------------------------------------------------------------------------
 String line = "AcroRd32.exe /p /h " + file.getAbsolutePath();
-CommandLine commandLine = CommandLine.parse(line);
+CommandLine cmdLine = CommandLine.parse(line);
 DefaultExecutor executor = new DefaultExecutor();
 executor.setExitValue(1);
 ExecuteWatchdog watchdog = new ExecuteWatchdog(60000);
 executor.setWatchdog(watchdog);
-int exitValue = executor.execute(commandLine);
+int exitValue = executor.execute(cmdLine);
 +----------------------------------------------------------------------------
 
 * Quoting Is Your Friend
@@ -101,12 +101,12 @@ int exitValue = executor.execute(command
   
 +----------------------------------------------------------------------------
 String line = "AcroRd32.exe /p /h \"" + file.getAbsolutePath() + "\"";
-CommandLine commandLine = CommandLine.parse(line);
+CommandLine cmdLine = CommandLine.parse(line);
 DefaultExecutor executor = new DefaultExecutor();
 executor.setExitValue(1);
 ExecuteWatchdog watchdog = new ExecuteWatchdog(60000);
 executor.setWatchdog(watchdog);
-int exitValue = executor.execute(commandLine);
+int exitValue = executor.execute(cmdLine);
 +----------------------------------------------------------------------------
 
 * Build the Command Line Incrementally
@@ -121,17 +121,17 @@ int exitValue = executor.execute(command
   
 +----------------------------------------------------------------------------
 Map map = new HashMap();
-map.put("file", new File("the_document_you_would_like_to_print"));
-CommandLine commandLine = CommandLine.parse("AcroRd32.exe");
-commandLine.addArgument("/p");
-commandLine.addArgument("/h");
-commandLine.addArgument("${file}");
-commandLine.setSubstitutionMap(map);
+map.put("file", new File("invoice.pdf"));
+CommandLine cmdLine = new CommandLine("AcroRd32.exe");
+cmdLine.addArgument("/p");
+cmdLine.addArgument("/h");
+cmdLine.addArgument("${file}");
+cmdLine.setSubstitutionMap(map);
 DefaultExecutor executor = new DefaultExecutor();
 executor.setExitValue(1);
 ExecuteWatchdog watchdog = new ExecuteWatchdog(60000);
 executor.setWatchdog(watchdog);
-int exitValue = executor.execute(commandLine);
+int exitValue = executor.execute(cmdLine);
 +----------------------------------------------------------------------------
 
   Please note that we are passing an 'java.io.File' instance for expanding
@@ -151,12 +151,12 @@ int exitValue = executor.execute(command
   offending exception or the process exit code.
 
 +----------------------------------------------------------------------------
-CommandLine commandLine = CommandLine.parse(this.acroRd32Script.getAbsolutePath());
-commandLine.addArgument("/p");
-commandLine.addArgument("/h");
-commandLine.addArgument("${file}");
+CommandLine cmdLine = new CommandLine("AcroRd32.exe");
+cmdLine.addArgument("/p");
+cmdLine.addArgument("/h");
+cmdLine.addArgument("${file}");
 HashMap map = new HashMap();
-map.put("file", "./pom.xml");
+map.put("file", new File("invoice.pdf"));
 commandLine.setSubstitutionMap(map);
 
 DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
@@ -164,9 +164,8 @@ DefaultExecuteResultHandler resultHandle
 ExecuteWatchdog watchdog = new ExecuteWatchdog(60*1000);
 Executor executor = new DefaultExecutor();
 executor.setExitValue(1);
-executor.setStreamHandler(new PumpStreamHandler());
 executor.setWatchdog(watchdog);
-executor.execute(commandLine, resultHandler);
+executor.execute(cmdLine, resultHandler);
 
 // some time later the result handler callback was invoked so we
 // can safely request the exit value

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=1031700&r1=1031699&r2=1031700&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 Fri
Nov  5 18:30:15 2010
@@ -23,6 +23,7 @@ import junit.framework.TestCase;
 import java.io.File;
 import java.io.IOException;
 import java.util.HashMap;
+import java.util.Map;
 
 /**
  * An example based on the tutorial where the user can can safely play with
@@ -83,7 +84,7 @@ public class TutorialTest extends TestCa
         PrintResultHandler resultHandler;
 
         // build up the command line to using a 'java.io.File'
-        HashMap map = new HashMap();
+        Map map = new HashMap();
         map.put("file", file);
         CommandLine commandLine = new CommandLine(acroRd32Script);
         commandLine.addArgument("/p");



Mime
View raw message