commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sgoes...@apache.org
Subject svn commit: r608168 - /commons/sandbox/exec/trunk/src/main/java/org/apache/commons/exec/DefaultExecutor.java
Date Wed, 02 Jan 2008 18:20:59 GMT
Author: sgoeschl
Date: Wed Jan  2 10:20:58 2008
New Revision: 608168

URL: http://svn.apache.org/viewvc?rev=608168&view=rev
Log:
SANDBOX-62 Made DefaultExecutor.launch() protected to enable mocking

Modified:
    commons/sandbox/exec/trunk/src/main/java/org/apache/commons/exec/DefaultExecutor.java

Modified: commons/sandbox/exec/trunk/src/main/java/org/apache/commons/exec/DefaultExecutor.java
URL: http://svn.apache.org/viewvc/commons/sandbox/exec/trunk/src/main/java/org/apache/commons/exec/DefaultExecutor.java?rev=608168&r1=608167&r2=608168&view=diff
==============================================================================
--- commons/sandbox/exec/trunk/src/main/java/org/apache/commons/exec/DefaultExecutor.java
(original)
+++ commons/sandbox/exec/trunk/src/main/java/org/apache/commons/exec/DefaultExecutor.java
Wed Jan  2 10:20:58 2008
@@ -219,31 +219,6 @@
         }
     }
 
-
-    /**
-     * Close the streams belonging to the given Process.
-     *
-     * @param process
-     *            the <CODE>Process</CODE>.
-     */
-    private void closeStreams(final Process process) {
-        try {
-            process.getInputStream().close();
-        } catch (IOException eyeOhEx) {
-            // ignore error
-        }
-        try {
-            process.getOutputStream().close();
-        } catch (IOException eyeOhEx) {
-            // ignore error
-        }
-        try {
-            process.getErrorStream().close();
-        } catch (IOException eyeOhEx) {
-            // ignore error
-        }
-    }
-
     /**
      * Creates a process that runs a command.
      *
@@ -257,7 +232,7 @@
      * @throws IOException
      *             forwarded from the particular launcher used
      */
-    private Process launch(final CommandLine command, final Map env,
+    protected Process launch(final CommandLine command, final Map env,
             final File dir) throws IOException {
         CommandLauncher launcher = this.launcher;
 
@@ -270,11 +245,35 @@
         }
         return launcher.exec(command, env, dir);
     }
-    
+
+    /**
+     * Close the streams belonging to the given Process.
+     *
+     * @param process
+     *            the <CODE>Process</CODE>.
+     */
+    private void closeStreams(final Process process) {
+        try {
+            process.getInputStream().close();
+        } catch (IOException eyeOhEx) {
+            // ignore error
+        }
+        try {
+            process.getOutputStream().close();
+        } catch (IOException eyeOhEx) {
+            // ignore error
+        }
+        try {
+            process.getErrorStream().close();
+        } catch (IOException eyeOhEx) {
+            // ignore error
+        }
+    }
+
     private int executeInternal(final CommandLine command, final Map environment,
             final File dir, final ExecuteStreamHandler streams) throws IOException {
 
-        final Process process = launch(command, environment, dir);
+        final Process process = this.launch(command, environment, dir);
 
         try {
             streams.setProcessInputStream(process.getOutputStream());



Mime
View raw message