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 2008/04/07 10:59:40 UTC

svn commit: r645416 - in /commons/sandbox/exec/trunk: build.xml src/site/apt/tutorial.apt src/test/bin/ src/test/bin/testme.sh src/test/java/org/apache/commons/exec/DefaultExecutorTest.java src/test/java/org/apache/commons/exec/TestRunner.java

Author: sgoeschl
Date: Mon Apr  7 01:59:39 2008
New Revision: 645416

URL: http://svn.apache.org/viewvc?rev=645416&view=rev
Log:
Committing a few things I did a while ago

+) tutorial as a teaser to use commons-exec

+) ability to create a standalone test package to allow easy community testing

Added:
    commons/sandbox/exec/trunk/src/test/bin/
    commons/sandbox/exec/trunk/src/test/bin/testme.sh   (with props)
    commons/sandbox/exec/trunk/src/test/java/org/apache/commons/exec/TestRunner.java
Modified:
    commons/sandbox/exec/trunk/build.xml
    commons/sandbox/exec/trunk/src/site/apt/tutorial.apt
    commons/sandbox/exec/trunk/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java

Modified: commons/sandbox/exec/trunk/build.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/exec/trunk/build.xml?rev=645416&r1=645415&r2=645416&view=diff
==============================================================================
--- commons/sandbox/exec/trunk/build.xml (original)
+++ commons/sandbox/exec/trunk/build.xml Mon Apr  7 01:59:39 2008
@@ -20,14 +20,20 @@
 <project name="exec" default="jar" basedir=".">
 
   <property file="build.properties" />
+  <property name="maven.build.version" value="1.0-SNAPSHOT"/>
   <property name="maven.build.output" value="target/classes"/>
   <property name="maven.build.directory" value="target"/>
-  <property name="maven.build.final.name" value="exec-1.0-SNAPSHOT"/>
+  <property name="maven.build.final.name" value="exec-${maven.build.version}"/>
   <property name="maven.test.reports" value="${maven.build.directory}/test-reports"/>
   <property name="maven.test.output" value="target/test-classes"/>
   <property name="maven.repo.local" value="${user.home}/.m2/repository"/>
 
-  <path id="build.classpath"/>
+  <path id="build.classpath">
+    <!-- assume that we pick up the junit stuff from the repo - won't work on all boxes -->
+    <fileset dir="${maven.repo.local}/junit/junit/3.8.1">
+      <include name="junit-3.8.1.jar"/>
+    </fileset>
+  </path>
 
   <target name="clean" description="Clean the output directory">
     <delete dir="${maven.build.directory}"/>
@@ -35,7 +41,7 @@
 
   <target name="compile" description="Compile the code">
     <mkdir dir="${maven.build.output}"/>
-    <javac destdir="${maven.build.output}" excludes="**/package.html" debug="true" deprecation="true" optimize="false">
+    <javac destdir="${maven.build.output}" excludes="**/package.html" debug="true" deprecation="true" optimize="false" target="1.3">
       <src>
         <pathelement location="src/main/java"/>
       </src>
@@ -49,7 +55,7 @@
 
   <target name="compile-tests" depends="junit-present, compile" description="Compile the test code" if="junit.present">
     <mkdir dir="${maven.test.output}"/>
-    <javac destdir="${maven.test.output}" excludes="**/package.html" debug="true" deprecation="true" optimize="false">
+    <javac destdir="${maven.test.output}" excludes="**/package.html" debug="true" deprecation="true" optimize="false" target="1.3">
       <src>
         <pathelement location="src/test/java"/>
       </src>
@@ -88,8 +94,23 @@
 
   <target name="junit-present" depends="test-junit-present" unless="junit.present">
     <echo>================================= WARNING ================================</echo>
-    <echo> Junit isn't present in your $ANT_HOME/lib directory. Tests not executed. </echo>
+    <echo> JUnit isn't present in your classpath. Tests not executed. </echo>
     <echo>==========================================================================</echo>
   </target>
-
+  
+  <target name="test-zip" depends="compile, junit-present, compile-tests" description="Create a zip containing the test environment">
+    <mkdir dir="${maven.build.directory}/dist/lib"/>
+    <get src="http://repo1.maven.org/maven/junit/jars/junit-3.8.1.jar" dest="${maven.build.directory}/dist/lib/junit-3.8.1.jar"/>
+    <jar jarfile="${maven.build.directory}/dist/lib/exec-test-${maven.build.version}.jar" basedir="${maven.test.output}" excludes="**/package.html"/>
+    <jar jarfile="${maven.build.directory}/dist/lib/${maven.build.final.name}.jar" basedir="${maven.build.output}" excludes="**/package.html"/>
+    <copy todir="${maven.build.directory}/dist/src/test/scripts">
+      <fileset dir="${basedir}/src/test/scripts"/>
+    </copy>
+    <zip destfile="${maven.build.directory}/exec-${maven.build.version}.zip">
+      <fileset dir="${maven.build.directory}/dist">
+        <filename name="**/*.*"/>
+      </fileset>
+    </zip>
+  </target>
+  
 </project>

Modified: commons/sandbox/exec/trunk/src/site/apt/tutorial.apt
URL: http://svn.apache.org/viewvc/commons/sandbox/exec/trunk/src/site/apt/tutorial.apt?rev=645416&r1=645415&r2=645416&view=diff
==============================================================================
--- commons/sandbox/exec/trunk/src/site/apt/tutorial.apt (original)
+++ commons/sandbox/exec/trunk/src/site/apt/tutorial.apt Mon Apr  7 01:59:39 2008
@@ -43,33 +43,51 @@
   seems to be a good option.
 
   The command line under Windows should look like "AcroRd32.exe /p /h file" assuming that the
-  Acrobat Reader is fond in the path.
+  Acrobat Reader is found in the path.
 
-  CommandLine commandLine = CommandLine.parse("AcroRd32.exe /p /h /temp/document.pdf");
-  DefaultExecutor executor = new DefaultExecutor();
-  int exitValue = executor.execute(commandLine);
++----------------------------------------------------------------------------
+String line = "AcroRd32.exe /p /h " + file.getAbsolutePath()
+CommandLine commandLine = CommandLine.parse(line);
+DefaultExecutor executor = new DefaultExecutor();
+int exitValue = executor.execute(commandLine);
++----------------------------------------------------------------------------
 
   You successfuly printed your first PDF document but at the end an exception is thrown - what
   happpend? Mhhmm, Acrobat Reader returned an exit value of '1' on success which is usually
-  considered as an exection failure. So we have to tweak our code to fix this odd behaviour
+  considered as an execution failure. So we have to tweak our code to fix this odd behaviour
 
-  CommandLine commandLine = CommandLine.parse("AcroRd32.exe /p /h /temp/document.pdf");
-  DefaultExecutor executor = new DefaultExecutor();
-  executor.setExitValue(1);
-  int exitValue = executor.execute(commandLine);
++----------------------------------------------------------------------------
+String line = "AcroRd32.exe /p /h " + file.getAbsolutePath()
+CommandLine commandLine = CommandLine.parse(line);
+DefaultExecutor executor = new DefaultExecutor();
+executor.setExitValue(1);
+int exitValue = executor.execute(commandLine);
++----------------------------------------------------------------------------
 
-* To Exit Or Not To Exit
+* To Watchdog Or Not To Watchdog
 
   You happily printed a while but now your application blocks - your printing subprocess
   hangs for some obvious or not so obvious reasons. Starting is easy but what to do with a run-away
-  Acrobat Reader. Luckily commons-exec provides a watchdog doing the work for you and here is
+  Acrobat Reader?! Luckily commons-exec provides a watchdog doing the work for you and here is
   the improved code
 
-  CommandLine commandLine = CommandLine.parse("AcroRd32.exe /p /h /temp/document.pdf");
-  ExecuteWatchdog watchdog = new ExecuteWatchdog(printTimeout);
-  DefaultExecutor executor = new DefaultExecutor();
-  executor.setWatchdog(watchdog);
-  executor.setExitValue(1);
-  int exitValue = executor.execute(commandLine);
-
-
++----------------------------------------------------------------------------
+String line = "AcroRd32.exe /p /h " + file.getAbsolutePath()
+CommandLine commandLine = CommandLine.parse(line);
+ExecuteWatchdog watchdog = new ExecuteWatchdog(printTimeout);
+DefaultExecutor executor = new DefaultExecutor();
+executor.setWatchdog(watchdog);
+executor.setExitValue(1);
+int exitValue = executor.execute(commandLine);
++----------------------------------------------------------------------------
+
+* Quoting Is Your Friend
+
+  Well, the code worked for quite a while until a new customer complained that
+  no documents are printed. It took half a day to find out that the following file
+  "C:\Document And Settings\documents\432432.pdf" was not printable. Due to the
+  spaces and without further quoting the command line fell apart.
+
++----------------------------------------------------------------------------
+> AcroRd32.exe /p /h C:\Document And Settings\documents\432432.pdf
++----------------------------------------------------------------------------

Added: commons/sandbox/exec/trunk/src/test/bin/testme.sh
URL: http://svn.apache.org/viewvc/commons/sandbox/exec/trunk/src/test/bin/testme.sh?rev=645416&view=auto
==============================================================================
--- commons/sandbox/exec/trunk/src/test/bin/testme.sh (added)
+++ commons/sandbox/exec/trunk/src/test/bin/testme.sh Mon Apr  7 01:59:39 2008
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+$JAVA_HOME/bin/java -cp ./lib/junit-3.8.1.jar:./lib/exec-test-1.0-SNAPSHOT.jar:./lib/exec-1.0-SNAPSHOT.jar org.apache.commons.exec.TestRunner
\ No newline at end of file

Propchange: commons/sandbox/exec/trunk/src/test/bin/testme.sh
------------------------------------------------------------------------------
    svn:executable = *

Modified: commons/sandbox/exec/trunk/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/exec/trunk/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java?rev=645416&r1=645415&r2=645416&view=diff
==============================================================================
--- commons/sandbox/exec/trunk/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java (original)
+++ commons/sandbox/exec/trunk/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java Mon Apr  7 01:59:39 2008
@@ -295,6 +295,8 @@
      * Test the proper handling of ProcessDestroyer for an asynchronous process.
      * Since we do not terminate the process it will be terminated in the
      * ShutdownHookProcessDestroyer implementation
+     *
+     * xxx
      */
     public void testExecuteAsyncWithProcessDestroyer1() throws Exception {
 
@@ -316,6 +318,9 @@
       assertNotNull(exec.getProcessDestroyer());      
       assertTrue(processDestroyer.size() == 1);
       assertTrue(processDestroyer.isAddedAsShutdownHook() == true);
+
+      watchdog.destroyProcess();
+      assertTrue(watchdog.killedProcess());        
     }
 
     /**
@@ -323,7 +328,7 @@
      * Since we do not terminate the process it will be terminated in the
      * ShutdownHookProcessDestroyer implementation
      */
-    public void testExecuteAsyncWithProcessDestroyer2() throws Exception {
+    public void _testExecuteAsyncWithProcessDestroyer2() throws Exception {
 
       CommandLine cl = new CommandLine(foreverTestScript);
       MockExecuteResultHandler handler = new MockExecuteResultHandler();

Added: commons/sandbox/exec/trunk/src/test/java/org/apache/commons/exec/TestRunner.java
URL: http://svn.apache.org/viewvc/commons/sandbox/exec/trunk/src/test/java/org/apache/commons/exec/TestRunner.java?rev=645416&view=auto
==============================================================================
--- commons/sandbox/exec/trunk/src/test/java/org/apache/commons/exec/TestRunner.java (added)
+++ commons/sandbox/exec/trunk/src/test/java/org/apache/commons/exec/TestRunner.java Mon Apr  7 01:59:39 2008
@@ -0,0 +1,26 @@
+package org.apache.commons.exec;
+
+import junit.framework.*;
+
+import org.apache.commons.exec.environment.EnvironmentUtilTest;
+import org.apache.commons.exec.util.MapUtilTest;
+
+public class TestRunner extends TestCase {
+
+    public static Test suite() {
+        TestSuite suite = new TestSuite("TestRunner");
+        suite.addTestSuite(CommandLineTest.class);
+        suite.addTestSuite(DefaultExecutorTest.class);
+        suite.addTestSuite(EnvironmentUtilTest.class);
+        suite.addTestSuite(MapUtilTest.class);
+        suite.addTestSuite(TestUtilTest.class);
+        return suite;
+    }
+
+    public static void main(String[] args) {
+        Test test = TestRunner.suite();
+        junit.textui.TestRunner testRunner = new junit.textui.TestRunner(System.out);
+        TestResult testResult = testRunner.doRun(test);
+        return;
+    }
+}



Re: svn commit: r645416 - in /commons/sandbox/exec/trunk: build.xml src/site/apt/tutorial.apt src/test/bin/ src/test/bin/testme.sh src/test/java/org/apache/commons/exec/DefaultExecutorTest.java src/test/java/org/apache/commons/exec/TestRunner.java

Posted by sebb <se...@gmail.com>.
No, but I do have broadband ;-)

On 07/04/2008, Siegfried Goeschl <si...@it20one.at> wrote:
> Considering the swiftness of your response - can you be found at ApacheCon?
>
>  Siegfried Goeschl
>
>  sebb wrote:
>
> >
> > On 07/04/2008, sgoeschl@apache.org <sg...@apache.org> wrote:
> >
> >
> > > Author: sgoeschl
> > >  Date: Mon Apr  7 01:59:39 2008
> > >  New Revision: 645416
> > >
> > >  URL: http://svn.apache.org/viewvc?rev=645416&view=rev
> > >  Log:
> > >  Committing a few things I did a while ago
> > >
> > >  +) tutorial as a teaser to use commons-exec
> > >
> > >  +) ability to create a standalone test package to allow easy community
> testing
> > >
> > >  Added:
> > >    commons/sandbox/exec/trunk/src/test/bin/
> > >    commons/sandbox/exec/trunk/src/test/bin/testme.sh
> (with props)
> > >
> commons/sandbox/exec/trunk/src/test/java/org/apache/commons/exec/TestRunner.java
> > >
> > >
> >
> > Please set SVN eol-style for the new java file and the shell file
> >
> > You may need to update your svn settings.
> >
> >
> >
> > >  Modified:
> > >    commons/sandbox/exec/trunk/build.xml
> > >    commons/sandbox/exec/trunk/src/site/apt/tutorial.apt
> > >
> commons/sandbox/exec/trunk/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java
> > >
> > >  Modified: commons/sandbox/exec/trunk/build.xml
> > >  URL:
> http://svn.apache.org/viewvc/commons/sandbox/exec/trunk/build.xml?rev=645416&r1=645415&r2=645416&view=diff
> > >
> > >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> dev-unsubscribe@commons.apache.org
> > For additional commands, e-mail: dev-help@commons.apache.org
> >
> >
> >
> >
> >
>
> ---------------------------------------------------------------------
>  To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>  For additional commands, e-mail: dev-help@commons.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: svn commit: r645416 - in /commons/sandbox/exec/trunk: build.xml src/site/apt/tutorial.apt src/test/bin/ src/test/bin/testme.sh src/test/java/org/apache/commons/exec/DefaultExecutorTest.java src/test/java/org/apache/commons/exec/TestRunner.java

Posted by Siegfried Goeschl <si...@it20one.at>.
Considering the swiftness of your response - can you be found at ApacheCon?

Siegfried Goeschl

sebb wrote:
> On 07/04/2008, sgoeschl@apache.org <sg...@apache.org> wrote:
>   
>> Author: sgoeschl
>>  Date: Mon Apr  7 01:59:39 2008
>>  New Revision: 645416
>>
>>  URL: http://svn.apache.org/viewvc?rev=645416&view=rev
>>  Log:
>>  Committing a few things I did a while ago
>>
>>  +) tutorial as a teaser to use commons-exec
>>
>>  +) ability to create a standalone test package to allow easy community testing
>>
>>  Added:
>>     commons/sandbox/exec/trunk/src/test/bin/
>>     commons/sandbox/exec/trunk/src/test/bin/testme.sh   (with props)
>>     commons/sandbox/exec/trunk/src/test/java/org/apache/commons/exec/TestRunner.java
>>     
>
> Please set SVN eol-style for the new java file and the shell file
>
> You may need to update your svn settings.
>
>   
>>  Modified:
>>     commons/sandbox/exec/trunk/build.xml
>>     commons/sandbox/exec/trunk/src/site/apt/tutorial.apt
>>     commons/sandbox/exec/trunk/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java
>>
>>  Modified: commons/sandbox/exec/trunk/build.xml
>>  URL: http://svn.apache.org/viewvc/commons/sandbox/exec/trunk/build.xml?rev=645416&r1=645415&r2=645416&view=diff
>>     
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>
>
>   

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: svn commit: r645416 - in /commons/sandbox/exec/trunk: build.xml src/site/apt/tutorial.apt src/test/bin/ src/test/bin/testme.sh src/test/java/org/apache/commons/exec/DefaultExecutorTest.java src/test/java/org/apache/commons/exec/TestRunner.java

Posted by sebb <se...@gmail.com>.
On 07/04/2008, sgoeschl@apache.org <sg...@apache.org> wrote:
> Author: sgoeschl
>  Date: Mon Apr  7 01:59:39 2008
>  New Revision: 645416
>
>  URL: http://svn.apache.org/viewvc?rev=645416&view=rev
>  Log:
>  Committing a few things I did a while ago
>
>  +) tutorial as a teaser to use commons-exec
>
>  +) ability to create a standalone test package to allow easy community testing
>
>  Added:
>     commons/sandbox/exec/trunk/src/test/bin/
>     commons/sandbox/exec/trunk/src/test/bin/testme.sh   (with props)
>     commons/sandbox/exec/trunk/src/test/java/org/apache/commons/exec/TestRunner.java

Please set SVN eol-style for the new java file and the shell file

You may need to update your svn settings.

>  Modified:
>     commons/sandbox/exec/trunk/build.xml
>     commons/sandbox/exec/trunk/src/site/apt/tutorial.apt
>     commons/sandbox/exec/trunk/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java
>
>  Modified: commons/sandbox/exec/trunk/build.xml
>  URL: http://svn.apache.org/viewvc/commons/sandbox/exec/trunk/build.xml?rev=645416&r1=645415&r2=645416&view=diff

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org