You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2009/04/26 17:01:06 UTC

svn commit: r768716 - /commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/CommandLineTest.java

Author: sebb
Date: Sun Apr 26 15:01:06 2009
New Revision: 768716

URL: http://svn.apache.org/viewvc?rev=768716&view=rev
Log:
setSubMap only needs to be called once
Add test to correspond with new Tutorial example

Modified:
    commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/CommandLineTest.java

Modified: commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/CommandLineTest.java
URL: http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/CommandLineTest.java?rev=768716&r1=768715&r2=768716&view=diff
==============================================================================
--- commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/CommandLineTest.java (original)
+++ commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/CommandLineTest.java Sun Apr 26 15:01:06 2009
@@ -353,9 +353,9 @@
 
         // build the command line
         cmdl = new CommandLine("${JAVA_HOME}\\bin\\java");
-        cmdl.addArguments("-class");
-        cmdl.addArguments("${appMainClass}");
-        cmdl.addArguments("${file}");
+        cmdl.addArgument("-class");
+        cmdl.addArgument("${appMainClass}");
+        cmdl.addArgument("${file}");
 
         // build the first command line
         substitutionMap.put("file", "C:\\Document And Settings\\documents\\432431.pdf");
@@ -363,7 +363,7 @@
         result = cmdl.toStrings();
 
         // verify the first command line
-        // please note - the executable argument is changed to using platform specific file sperator char
+        // please note - the executable argument is changed to using platform specific file separator char
         // whereas all other variable substitution are not touched
         assertEquals(StringUtils.fixFileSeparatorChar("C:\\Programme\\jdk1.5.0_12\\bin\\java"), result[0]);
         assertEquals("-class", result[1]);
@@ -381,7 +381,6 @@
 
         // build the second command line with updated parameters resulting in  a different command line
         substitutionMap.put("file", "C:\\Document And Settings\\documents\\432432.pdf");        
-        cmdl.setSubstitutionMap(substitutionMap);
         result = cmdl.toStrings();
         assertEquals(StringUtils.fixFileSeparatorChar("C:\\Programme\\jdk1.5.0_12\\bin\\java"), result[0]);
         assertEquals("-class", result[1]);
@@ -389,6 +388,21 @@
         assertEquals("C:\\Document And Settings\\documents\\432432.pdf", result[3]);                
     }
 
+    public void testCommandLineParsingWithExpansion3(){
+        CommandLine cmdl = CommandLine.parse("AcroRd32.exe");
+        cmdl.addArgument("/p");
+        cmdl.addArgument("/h");
+        cmdl.addArgument("${file}");
+        HashMap params = new HashMap();
+        params.put("file", "C:\\Document And Settings\\documents\\432432.pdf");
+        cmdl.setSubstitutionMap(params);
+        String[] result = cmdl.toStrings();
+        assertEquals("AcroRd32.exe", result[0]);
+        assertEquals("/p", result[1]);
+        assertEquals("/h", result[2]);
+        assertEquals("C:\\Document And Settings\\documents\\432432.pdf", result[3]);                
+        
+    }
     /**
      * Test the toString() method
      */