Author: sgoeschl
Date: Thu Mar 4 18:03:14 2010
New Revision: 919098
URL: http://svn.apache.org/viewvc?rev=919098&view=rev
Log:
Adding a generic test case to print out the command line arguments for Unix and
(hopefully) Windows
Added:
commons/proper/exec/trunk/src/test/scripts/printargs.bat
commons/proper/exec/trunk/src/test/scripts/printargs.sh (with props)
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=919098&r1=919097&r2=919098&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
Thu Mar 4 18:03:14 2010
@@ -39,10 +39,11 @@
private File nonExistingTestScript = TestUtil.resolveScriptForOS(testDir +
"/grmpffffff");
private File redirectScript = TestUtil.resolveScriptForOS(testDir +
"/redirect");
private File exec41Script = TestUtil.resolveScriptForOS(testDir +
"/exec41");
+ private File printArgsScript = TestUtil.resolveScriptForOS(testDir +
"/printargs");
// Get suitable exit codes for the OS
private static final int SUCCESS_STATUS; // test script successful exit
code
- private static final int ERROR_STATUS; // test script error exit ccode
+ private static final int ERROR_STATUS; // test script error exit code
static{
int statuses[] = TestUtil.getTestScriptCodesForOS();
SUCCESS_STATUS=statuses[0];
@@ -473,4 +474,18 @@
assertTrue("The process was not killed by the watchdog",
watchdog.killedProcess());
// assertTrue("The process was not properly killed because it took " +
duration + " ms to execute", duration < 5*1000);
}
+
+ /**
+ * A generic test case to print the command line arguments to 'printargs'
script to solve
+ * even more command line puzzles.
+ */
+ public void testExecuteWithComplexArguments() throws Exception {
+ CommandLine cl = new CommandLine(printArgsScript);
+ cl.addArgument("gdal_translate");
+
cl.addArgument("HDF5:\"/home/kk/grass/data/4404.he5\"://HDFEOS/GRIDS/OMI_Column_Amount_O3/Data_Fields/ColumnAmountO3/home/kk/4.tif",
false);
+ DefaultExecutor executor = new DefaultExecutor();
+ int exitValue = executor.execute(cl);
+ assertFalse(exec.isFailure(exitValue));
+ }
+
}
Added: commons/proper/exec/trunk/src/test/scripts/printargs.bat
URL:
http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/test/scripts/printargs.bat?rev=919098&view=auto
==============================================================================
--- commons/proper/exec/trunk/src/test/scripts/printargs.bat (added)
+++ commons/proper/exec/trunk/src/test/scripts/printargs.bat Thu Mar 4
18:03:14 2010
@@ -0,0 +1,24 @@
+...@echo OFF
+
+REM Licensed to the Apache Software Foundation (ASF) under one or more
+REM contributor license agreements. See the NOTICE file distributed with
+REM this work for additional information regarding copyright ownership.
+REM The ASF licenses this file to You under the Apache License, Version 2.0
+REM (the "License"); you may not use this file except in compliance with
+REM the License. You may obtain a copy of the License at
+REM
+REM http://www.apache.org/licenses/LICENSE-2.0
+REM
+REM Unless required by applicable law or agreed to in writing, software
+REM distributed under the License is distributed on an "AS IS" BASIS,
+REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+REM See the License for the specific language governing permissions and
+REM limitations under the License.
+
+:Loop
+IF "%1"=="" GOTO Continue
+ ECHO "%1"
+SHIFT
+GOTO Loop
+:Continue
+
Added: commons/proper/exec/trunk/src/test/scripts/printargs.sh
URL:
http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/test/scripts/printargs.sh?rev=919098&view=auto
==============================================================================
--- commons/proper/exec/trunk/src/test/scripts/printargs.sh (added)
+++ commons/proper/exec/trunk/src/test/scripts/printargs.sh Thu Mar 4 18:03:14
2010
@@ -0,0 +1,27 @@
+#!/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.
+#
+
+# Helper script to print out the command line arguments
+
+while [ $# -gt 0 ]
+do
+ echo "$1"
+ shift
+done
+
Propchange: commons/proper/exec/trunk/src/test/scripts/printargs.sh
------------------------------------------------------------------------------
svn:executable = *