Author: lcorneliussen
Date: Tue Jan  3 16:35:23 2012
New Revision: 1226854

URL: http://svn.apache.org/viewvc?rev=1226854&view=rev
Log:
[NPANDAY-509] CommandExecutor is confused with MSDeploy-style commandline 
switches starting with "-" and containing both ":" and "="

o  Added more test cases for defined quoting behaviour of command executors
o Started work on ArgUtils

Added:
    
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/ArgUtils.java
    
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/execution/CustomPlexusUtilsCommandline.java
   (contents, props changed)
      - copied, changed from r1226709, 
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/execution/CustomCommandline.java
    
incubator/npanday/trunk/components/dotnet-executable/src/test/groovy/npanday/executable/execution/QuotingAndEscapingBehaviourTest.groovy
Removed:
    
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/execution/CustomCommandline.java
Modified:
    
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/execution/CapturingLogOutputStream.java
    
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/execution/CommonsExecCommandExecutor.java
    
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/execution/PlexusUtilsCommandExecutor.java
    
incubator/npanday/trunk/components/dotnet-executable/src/test/groovy/npanday/executable/execution/CommandExecutorTest.groovy

Added: 
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/ArgUtils.java
URL: 
http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/ArgUtils.java?rev=1226854&view=auto
==============================================================================
--- 
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/ArgUtils.java
 (added)
+++ 
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/ArgUtils.java
 Tue Jan  3 16:35:23 2012
@@ -0,0 +1,67 @@
+/*
+ * 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.
+ */
+
+package npanday.executable;
+
+import org.apache.commons.exec.util.StringUtils;
+
+import java.io.File;
+
+/**
+ * Use this in combination with {@link 
npanday.executable.execution.CommonsExecCommandExecutor} configured
+ * in your executable-config.
+ *
+ * @author <a href="mailto:[email protected]";>Lars Corneliussen</a>
+ */
+public class ArgUtils
+{
+    /**
+     * Takes care of quoting individually per part. For example,
+     * if you pass <code>"/go:", new File("c:\\with space")</code>, it will 
yield
+     * <code>/go:"c:\with space"</code>
+     */
+    public static String combine( Object... objects )
+    {
+        StringBuilder command = new StringBuilder();
+        for ( Object item : objects )
+        {
+            if (item == null){
+                continue;
+            }
+
+            if ( item instanceof File )
+            {
+                command.append(
+                    StringUtils.quoteArgument(
+                        StringUtils.fixFileSeparatorChar( ( (File) item 
).getAbsolutePath() )
+                    )
+                );
+            }
+            else if ( item instanceof String )
+            {
+                command.append( StringUtils.quoteArgument( (String) item ) );
+            }
+            else{
+               command.append( StringUtils.quoteArgument( item.toString() ) );
+            }
+        }
+
+        return command.toString();
+    }
+}

Modified: 
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/execution/CapturingLogOutputStream.java
URL: 
http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/execution/CapturingLogOutputStream.java?rev=1226854&r1=1226853&r2=1226854&view=diff
==============================================================================
--- 
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/execution/CapturingLogOutputStream.java
 (original)
+++ 
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/execution/CapturingLogOutputStream.java
 Tue Jan  3 16:35:23 2012
@@ -24,7 +24,7 @@ import org.apache.commons.exec.LogOutput
 /**
  * Stream that captures and logs lines to a plexus logger.
  * Designed for anonymous implementation.
- *
+ * <p/>
  * Access the captured output through {@link #toString}.
  *
  * @author <a href="mailto:[email protected]";>Lars Corneliussen</a>
@@ -34,14 +34,27 @@ public abstract class CapturingLogOutput
 {
     private StringBuffer contents = new StringBuffer();
 
-    private String NEW_LINE = System.getProperty("line.separator");
+    private boolean isFirstLine = true;
 
-    @Override
-    protected final void processLine(String line, int level) {
-        processLine( line );
+    private String NEW_LINE = System.getProperty( "line.separator" );
 
+    @Override
+    protected final void processLine( String line, int level )
+    {
+        if ( !isFirstLine )
+        {
+            contents.append( NEW_LINE );
+        }
         contents.append( line );
-        contents.append( NEW_LINE );
+        isFirstLine = false;
+
+        handle( line );
+    }
+
+    @Override
+    protected final void processLine( String line )
+    {
+        super.processLine( line );
     }
 
     /**
@@ -49,7 +62,7 @@ public abstract class CapturingLogOutput
      *
      * @param line
      */
-    protected abstract void processLine( String line );
+    protected abstract void handle( String line );
 
     /**
      * Returns the captured output.

Modified: 
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/execution/CommonsExecCommandExecutor.java
URL: 
http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/execution/CommonsExecCommandExecutor.java?rev=1226854&r1=1226853&r2=1226854&view=diff
==============================================================================
--- 
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/execution/CommonsExecCommandExecutor.java
 (original)
+++ 
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/execution/CommonsExecCommandExecutor.java
 Tue Jan  3 16:35:23 2012
@@ -29,7 +29,6 @@ import org.apache.commons.exec.util.Stri
 
 import java.io.File;
 import java.io.IOException;
-import java.io.OutputStream;
 import java.util.List;
 
 import static com.google.common.collect.Lists.newArrayList;
@@ -44,11 +43,11 @@ public class CommonsExecCommandExecutor
 {
     private static final Joiner JOIN_ON_SPACE = Joiner.on( " " );
 
-    private OutputStream standardOutHandler;
+    private CapturingLogOutputStream standardOutHandler;
 
-    private OutputStream errorOutHandler;
+    private CapturingLogOutputStream errorOutHandler;
 
-    private int result;
+    private int result = -1;
 
     private boolean hasErrorOutput = false;
 
@@ -56,16 +55,15 @@ public class CommonsExecCommandExecutor
 
     private boolean hasLoggedStartInfo;
 
-    public CommonsExecCommandExecutor()
-    {
-        setupOutputHandlers();
-    }
-
     @Override
     public void executeCommand(
         String executable, List<String> commands, File workingDirectory, 
boolean failsOnErrorOutput ) throws
         ExecutionException
     {
+        setupOutputHandlers();
+        result = -1;
+        hasErrorOutput = false;
+
         // TODO: This is for Windows only; in context of NPANDAY-509
 
         /*
@@ -73,7 +71,7 @@ public class CommonsExecCommandExecutor
          * we can pass arguments like -x="a b" - which, in this case,
          * was required by MSDeploy.
          *
-         * Without cmd, using commons-exc or plexus-utils' cli, -x="a b" will
+         * Without cmd, using commons-exec or plexus-utils' cli, -x="a b" will
          * get quoted once more.
          *
          * Consideration: We could also exchange the  
DefaultExecutor.launcher; but it is private :/
@@ -90,10 +88,10 @@ public class CommonsExecCommandExecutor
 
         for ( String arg : commands )
         {
-            // NPANDAY-509: if an argument ends with " or ', we are quite sure,
+            // NPANDAY-509: if an argument contains " , we assume
             // quoting has been taken care of on the outside
-            final boolean endsWithQuote = arg.endsWith( "'" ) || arg.endsWith( 
"\"" );
-            final boolean handleQuoting = endsWithQuote ? false : true;
+            final boolean containsQuote = arg.contains( "\"" );
+            final boolean handleQuoting = containsQuote ? false : true;
 
             if ( handleQuoting )
             {
@@ -125,6 +123,8 @@ public class CommonsExecCommandExecutor
         }
         catch ( ExecuteException e )
         {
+            result = e.getExitValue();
+
             throw new ExecutionException(
                 "NPANDAY-125-002: Error occurred when executing " + 
commandLine.toString(), e
             );
@@ -148,17 +148,18 @@ public class CommonsExecCommandExecutor
     {
         standardOutHandler = new CapturingLogOutputStream()
         {
-            protected void processLine( String line )
+            @Override
+            protected void handle( String line )
             {
                 mayLogStartInfo();
-                getLogger().info( "| " + line );
+                getLogger().info( " | " + line );
             }
         };
 
         errorOutHandler = new CapturingLogOutputStream()
         {
             @Override
-            protected void processLine( String line )
+            protected void handle( String line )
             {
                 mayLogStartInfo();
                 getLogger().error( "| " + line );
@@ -171,7 +172,7 @@ public class CommonsExecCommandExecutor
     {
         if (!hasLoggedStartInfo)
         {
-            getLogger().info( "+--[ RUNNING: " + commandLine  + "]");
+            getLogger().info( " +--[ RUNNING: " + commandLine  + "]");
         }
         hasLoggedStartInfo = true;
     }
@@ -180,7 +181,7 @@ public class CommonsExecCommandExecutor
     {
         if (hasLoggedStartInfo)
         {
-           getLogger().info( "+--[ DONE" + (hasErrorOutput ? " WITH ERRORS" : 
"") + " ]" );
+           getLogger().info( " +--[ DONE" + (hasErrorOutput ? " WITH ERRORS" : 
"") + " ]" );
         }
     }
 

Copied: 
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/execution/CustomPlexusUtilsCommandline.java
 (from r1226709, 
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/execution/CustomCommandline.java)
URL: 
http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/execution/CustomPlexusUtilsCommandline.java?p2=incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/execution/CustomPlexusUtilsCommandline.java&p1=incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/execution/CustomCommandline.java&r1=1226709&r2=1226854&rev=1226854&view=diff
==============================================================================
--- 
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/execution/CustomCommandline.java
 (original)
+++ 
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/execution/CustomPlexusUtilsCommandline.java
 Tue Jan  3 16:35:23 2012
@@ -35,7 +35,7 @@ import java.util.Properties;
  * @author Shane Isbell
  * @author <a href="mailto:[email protected]";>Lars Corneliussen</a>
  */
-public class CustomCommandline
+public class CustomPlexusUtilsCommandline
     extends Commandline
 {
     protected Map envVars = Collections.synchronizedMap( new LinkedHashMap() );

Propchange: 
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/execution/CustomPlexusUtilsCommandline.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/execution/PlexusUtilsCommandExecutor.java
URL: 
http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/execution/PlexusUtilsCommandExecutor.java?rev=1226854&r1=1226853&r2=1226854&view=diff
==============================================================================
--- 
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/execution/PlexusUtilsCommandExecutor.java
 (original)
+++ 
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/execution/PlexusUtilsCommandExecutor.java
 Tue Jan  3 16:35:23 2012
@@ -65,7 +65,7 @@ public class PlexusUtilsCommandExecutor
         stdOut = new StandardStreamConsumer( getLogger() );
         stdErr = new ErrorStreamConsumer( getLogger() );
 
-        Commandline commandline = new CustomCommandline();
+        Commandline commandline = new CustomPlexusUtilsCommandline();
 
         // NPANDAY-409
         // On non-Windows platforms, such as Linux, "gmcs" not resolved

Modified: 
incubator/npanday/trunk/components/dotnet-executable/src/test/groovy/npanday/executable/execution/CommandExecutorTest.groovy
URL: 
http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/test/groovy/npanday/executable/execution/CommandExecutorTest.groovy?rev=1226854&r1=1226853&r2=1226854&view=diff
==============================================================================
--- 
incubator/npanday/trunk/components/dotnet-executable/src/test/groovy/npanday/executable/execution/CommandExecutorTest.groovy
 (original)
+++ 
incubator/npanday/trunk/components/dotnet-executable/src/test/groovy/npanday/executable/execution/CommandExecutorTest.groovy
 Tue Jan  3 16:35:23 2012
@@ -25,11 +25,14 @@ import npanday.executable.CommandExecuto
 import npanday.executable.ExecutionException
 import org.codehaus.plexus.logging.Logger
 import org.codehaus.plexus.logging.console.ConsoleLogger
-import org.codehaus.plexus.util.cli.Arg
-import org.codehaus.plexus.util.cli.Commandline
 import org.junit.Test
+import org.junit.internal.AssumptionViolatedException
+import org.junit.runner.RunWith
+import org.junit.runners.Parameterized
+import org.junit.runners.Parameterized.Parameters
 import static org.junit.Assert.*
 
+@RunWith(value = Parameterized.class)
 public class CommandExecutorTest
 {
     private static final String MKDIR = "mkdir";
@@ -38,49 +41,171 @@ public class CommandExecutorTest
 
     private List<String> params = new ArrayList<String>();
 
-    private CommandExecutor cmdExecutor;
+    private CommandExecutor cmd;
+    private String cmdHint;
 
-    public CommandExecutorTest()
+    @Parameters
+    public static Collection<Object[]> data()
     {
-        File f = new File( "test" );
-        parentPath = System.getProperty( "user.dir" ) + File.separator + 
"target" + File.separator + "test-resources";
+        Object[][] data = [
+                ["plexus_cli", new PlexusUtilsCommandExecutor()],
+                ["commons_exec", new CommonsExecCommandExecutor()]
+        ];
+        return Arrays.asList(data);
+    }
+
+    public CommandExecutorTest(String hint, CommandExecutor cmd)
+    {
+        cmdHint = hint;
+        println "Executing with " + hint
+        File f = new File("test");
+        parentPath = System.getProperty("user.dir") + File.separator + 
"target" + File.separator +
+                "test-resources";
 
-        File parentPathFile = new File( parentPath );
+        File parentPathFile = new File(parentPath);
         if ( !parentPathFile.exists() )
         {
             parentPathFile.mkdir();
         }
 
-        cmdExecutor = CommandExecutor.Factory.createDefaultCommmandExecutor();
-        cmdExecutor.setLogger( new ConsoleLogger( Logger.LEVEL_DEBUG, "Command 
Executor") );
+        this.cmd = cmd;
+        cmd.setLogger(new ConsoleLogger(Logger.LEVEL_DEBUG, "Command 
Executor"));
+    }
+
+    @Test
+    public void testSimpleCommandArg()
+    throws ExecutionException
+    {
+        testArgExpansion(["x"], "x");
     }
 
     @Test
-    public void testArgsWithFile()
-        throws ExecutionException
+    public void testCommandArgWithSpaces()
+    throws ExecutionException
     {
-        Commandline cli = new Commandline();
-        cli.setExecutable( "echo" );
-        final Arg arg = cli.createArg();
-        arg.setValue( "-x:y=" );
-        arg.setFile( new File("c:\te mp") );
-        cli.addArg( arg );
+        testArgExpansion(["a b"], '"a b\"');
+    }
 
+    @Test
+    public void testCommandArgWithEmbeddedSingleQuotes_middle()
+    throws ExecutionException
+    {
+        testArgExpansion(["a ' b"], '"a \' b"');
+    }
+
+    @Test
+    public void testCommandArgWithEmbeddedSingleQuotes_trailing()
+    throws ExecutionException
+    {
+        testArgExpansion(["a '"], [
+                         plexus_cli: '"a \'"'
+                         ]);
+    }
+
+    @Test
+    public void testCommandArgWithEmbeddedSingleQuotes_leading()
+    throws ExecutionException
+    {
+        testArgExpansion(["' a"], [
+                         plexus_cli: '"\' a"'
+                         ]);
+    }
+
+    @Test
+    public void testCommandArgWithEmbeddedSingleQuotes_surrounding()
+    throws ExecutionException
+    {
+        testArgExpansion(["' a '"], [
+                         plexus_cli: '"\' a \'"'
+                         ]);
+    }
+
+    @Test
+    public void testCommandArgWithEmbeddedDoubleQuotes_middle()
+    throws ExecutionException
+    {
+        testArgExpansion(['a " b'], [
+                         plexus_cli: '"a " b"'
+                         ]);
+    }
+
+    @Test
+    public void testCommandArgWithEmbeddedDoubleQuotes_trailing()
+    throws ExecutionException
+    {
+        testArgExpansion(['a "'], [
+                         plexus_cli: '"a ""'
+                         ]);
+    }
+
+    @Test
+    public void testCommandArgWithEmbeddedDoubleQuotes_leading()
+    throws ExecutionException
+    {
+        testArgExpansion(['" a'], [
+                         plexus_cli: '"" a"'
+                         ]);
+    }
+
+    @Test
+    public void testCommandArgWithEmbeddedDoubleQuotes_surrounding()
+    throws ExecutionException
+    {
+        testArgExpansion(['" a "'], [
+                         plexus_cli: '" a "'
+                         ]);
+    }
+
+    private def testArgExpansion(ArrayList<String> args, String expected)
+    {
+        cmd.executeCommand("echo", args)
+        assert cmd.result == 0
+        assert cmd.standardOut == expected
+    }
+
+    private def testArgExpansion(ArrayList<String> args, Map<String, String> 
expectedPerHint)
+    {
+        if ( !expectedPerHint.containsKey(cmdHint) )
+        {
+            cmd.executeCommand("echo", args)
+            throw new AssumptionViolatedException("Quoting behaviour undefined 
for '" + cmdHint + "'.\n"
+                                                          + args + " -> " + 
cmd.standardOut)
+        }
+
+        testArgExpansion(args, expectedPerHint[cmdHint])
+    }
+
+    @Test
+    public void testErrorWithReturnValue()
+    throws ExecutionException
+    {
+        // hopefully an executable named asdfasdf doesnt exist
+        try
+        {
+            cmd.executeCommand("asdfasdf", [])
+            fail("expected command to fail")
+        }
+        catch (ExecutionException)
+        {
+
+        }
+        println "Result is $cmd.result"
+        assert cmd.result != 0
     }
 
     @Test
     public void testParamWithNoSpaces()
-        throws ExecutionException
+    throws ExecutionException
     {
         String path = parentPath + File.separator + "sampledirectory";
 
         params.clear();
-        params.add( path );
+        params.add(path);
 
-        cmdExecutor.executeCommand( MKDIR, params );
-        File dir = new File( path );
+        cmd.executeCommand(MKDIR, params);
+        File dir = new File(path);
 
-        assertTrue( dir.exists() );
+        assertTrue(dir.exists());
 
         if ( dir.exists() )
         {
@@ -90,17 +215,17 @@ public class CommandExecutorTest
 
     @Test
     public void testParamWithSpaces()
-        throws ExecutionException
+    throws ExecutionException
     {
         String path = parentPath + File.separator + "sample directory";
 
         params.clear();
-        params.add( path );
+        params.add(path);
 
-        cmdExecutor.executeCommand( MKDIR, params );
-        File dir = new File( path );
+        cmd.executeCommand(MKDIR, params);
+        File dir = new File(path);
 
-        assertTrue( dir.exists() );
+        assertTrue(dir.exists());
 
         if ( dir.exists() )
         {
@@ -113,29 +238,28 @@ public class CommandExecutorTest
      test is related to NPANDAY-366
      */
     public void testTooLongCommandName()
-        throws ExecutionException
+    throws ExecutionException
     {
-           // we are only interested in exectuing this test
-           // on Windows, to catch the "Command line to long" issue for 
cmd.exe.
-           if (!isWindows())
-             return;
+        // we are only interested in exectuing this test
+        // on Windows, to catch the "Command line to long" issue for cmd.exe.
+        if ( !isWindows() ) return;
 
         params.clear();
 
-        cmdExecutor.setLogger( new ConsoleLogger( 0, null ) );
+        cmd.setLogger(new ConsoleLogger(0, null));
 
         try
         {
-            cmdExecutor.executeCommand( repeat( 'x', 260 ), params, null, 
false );
-            fail( "Expected the command to fail!" );
+            cmd.executeCommand(repeat('x', 260), params, null, false);
+            fail("Expected the command to fail!");
         }
-        catch ( ExecutionException e )
+        catch (ExecutionException e)
         {
-            System.out.println( cmdExecutor.toString() );
+            System.out.println(cmd.toString());
             // the message is language-specific, but better to ensure an error 
than
             // ignoring the test
             // assertEquals( "The input line is too long.", 
cmdExecutor.getStandardError() );
-            assertEquals( 1, cmdExecutor.getResult() );
+            assertEquals(1, cmd.getResult());
         }
     }
 
@@ -144,29 +268,28 @@ public class CommandExecutorTest
      test is related to NPANDAY-366
      */
     public void testTooLongCommandName_withSpace()
-        throws ExecutionException
+    throws ExecutionException
     {
-           // we are only interested in exectuing this test
-           // on Windows, to catch the "Command line to long" issue for 
cmd.exe.
-           if (!isWindows())
-             return;
+        // we are only interested in exectuing this test
+        // on Windows, to catch the "Command line to long" issue for cmd.exe.
+        if ( !isWindows() ) return;
 
         params.clear();
 
-        cmdExecutor.setLogger( new ConsoleLogger( 0, null ) );
+        cmd.setLogger(new ConsoleLogger(0, null));
 
         try
         {
-            cmdExecutor.executeCommand( "echo " + repeat( 'x', 255 ), params, 
null, false );
-            fail( "Expected the command to fail!" );
+            cmd.executeCommand("echo " + repeat('x', 255), params, null, 
false);
+            fail("Expected the command to fail!");
         }
-        catch ( ExecutionException e )
+        catch (ExecutionException e)
         {
-            System.out.println( cmdExecutor.toString() );
+            System.out.println(cmd.toString());
             // the message is language-specific, but better to ensure an error 
than
             // ignoring the test
             // assertEquals( "The input line is too long.", 
cmdExecutor.getStandardError() );
-            assertEquals( 1, cmdExecutor.getResult() );
+            assertEquals(1, cmd.getResult());
         }
     }
 
@@ -176,20 +299,20 @@ public class CommandExecutorTest
      test is related to NPANDAY-366
      */
     public void testLongCommand()
-        throws ExecutionException
+    throws ExecutionException
     {
         params.clear();
 
-        cmdExecutor.setLogger( new ConsoleLogger( 0, null ) );
-        params.add( repeat( 'a', 260 ) );
+        cmd.setLogger(new ConsoleLogger(0, null));
+        params.add(repeat('a', 260));
 
-        cmdExecutor.executeCommand( "echo", params, null, false );
-        System.out.println( cmdExecutor.toString() );
+        cmd.executeCommand("echo", params, null, false);
+        System.out.println(cmd.toString());
 
-        assertEquals( repeat( 'a', 260 ), cmdExecutor.getStandardOut() );
+        assertEquals(repeat('a', 260), cmd.getStandardOut());
     }
 
-    private static String repeat( String c, int i )
+    private static String repeat(String c, int i)
     {
         String tst = "";
         for ( int j = 0; j < i; j++ )

Added: 
incubator/npanday/trunk/components/dotnet-executable/src/test/groovy/npanday/executable/execution/QuotingAndEscapingBehaviourTest.groovy
URL: 
http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/test/groovy/npanday/executable/execution/QuotingAndEscapingBehaviourTest.groovy?rev=1226854&view=auto
==============================================================================
--- 
incubator/npanday/trunk/components/dotnet-executable/src/test/groovy/npanday/executable/execution/QuotingAndEscapingBehaviourTest.groovy
 (added)
+++ 
incubator/npanday/trunk/components/dotnet-executable/src/test/groovy/npanday/executable/execution/QuotingAndEscapingBehaviourTest.groovy
 Tue Jan  3 16:35:23 2012
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ */
+
+package npanday.executable.execution
+
+import org.junit.Test
+
+/**
+ * @author <a href="mailto:[email protected]";>Lars Corneliussen</a>
+ */
+class QuotingAndEscapingBehaviourTest
+{
+    @Test
+    void test()
+    {
+
+    }
+}


Reply via email to