Author: lcorneliussen
Date: Thu Jan 5 07:42:34 2012
New Revision: 1227515
URL: http://svn.apache.org/viewvc?rev=1227515&view=rev
Log:
[NPANDAY-509] CMD line quoting: Remove unnecessary classes and test cases
o Still to be checked on !windows systems / bourne shell
Removed:
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/CommonsExecLogStreamHandler.java
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/execution/CustomPlexusUtilsCommandline.java
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/execution/PlexusUtilsCommandExecutor.java
Modified:
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/execution/ErrorStreamConsumer.java
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/execution/StandardStreamConsumer.java
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/DefaultNetExecutable.java
incubator/npanday/trunk/components/dotnet-executable/src/test/groovy/npanday/executable/execution/CommandExecutorTest.groovy
incubator/npanday/trunk/plugins/netplugins/NPanday.Plugin.Settings/javabinding/src/main/java/NPanday/Plugin/Settings/SettingsGeneratorMojo.java
Modified:
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/execution/ErrorStreamConsumer.java
URL:
http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/execution/ErrorStreamConsumer.java?rev=1227515&r1=1227514&r2=1227515&view=diff
==============================================================================
---
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/execution/ErrorStreamConsumer.java
(original)
+++
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/execution/ErrorStreamConsumer.java
Thu Jan 5 07:42:34 2012
@@ -59,7 +59,7 @@ class ErrorStreamConsumer
sbe.append( line );
if ( logger != null )
{
- logger.info( line );
+ logger.error( " | " + line );
}
error = true;
}
Modified:
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/execution/StandardStreamConsumer.java
URL:
http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/execution/StandardStreamConsumer.java?rev=1227515&r1=1227514&r2=1227515&view=diff
==============================================================================
---
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/execution/StandardStreamConsumer.java
(original)
+++
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/execution/StandardStreamConsumer.java
Thu Jan 5 07:42:34 2012
@@ -32,9 +32,6 @@ import org.codehaus.plexus.util.cli.Stre
class StandardStreamConsumer
implements StreamConsumer
{
-
- private DefaultConsumer consumer;
-
private StringBuffer sb = new StringBuffer();
private Logger logger;
@@ -45,7 +42,6 @@ class StandardStreamConsumer
Preconditions.checkArgument( logger != null, "logger must not be null"
);
this.logger = logger;
- consumer = new DefaultConsumer();
}
public void consumeLine( String line )
@@ -53,7 +49,7 @@ class StandardStreamConsumer
sb.append( line );
if ( logger != null )
{
- consumer.consumeLine( line );
+ logger.info( " | " + line );
}
}
Modified:
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/DefaultNetExecutable.java
URL:
http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/DefaultNetExecutable.java?rev=1227515&r1=1227514&r2=1227515&view=diff
==============================================================================
---
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/DefaultNetExecutable.java
(original)
+++
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/DefaultNetExecutable.java
Thu Jan 5 07:42:34 2012
@@ -1,96 +1,95 @@
-package npanday.executable.impl;
-
-/*
- * 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.
- */
-
-import npanday.NPandayContext;
-import npanday.PathUtil;
-import npanday.PlatformUnsupportedException;
-import npanday.executable.CommandExecutor;
-import npanday.executable.CommandFilter;
-import npanday.executable.ExecutableContext;
-import npanday.executable.ExecutionException;
-import npanday.executable.NetExecutable;
-import npanday.executable.execution.CommonsExecCommandExecutor;
-import npanday.vendor.Vendor;
-import org.codehaus.plexus.logging.Logger;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Properties;
-
-/**
- * Provides the default implementation of the net executable.
- *
- * @author Shane Isbell
- */
-public class DefaultNetExecutable
- implements NetExecutable
-{
-
- protected ExecutableContext executableContext;
-
- /**
- * A logger for writing log messages
- */
- protected Logger logger;
-
- private Collection<String> commands;
-
- private Properties configuration;
-
- public List<String> getCommands() throws ExecutionException,
PlatformUnsupportedException
- {
- // TODO: should it fail on unsupported commands?
- CommandFilter filter = executableContext.getCommandFilter();
- return Collections.unmodifiableList( filter.filter( commands ) );
- }
-
- public void execute() throws ExecutionException,
PlatformUnsupportedException
- {
- innerExecute();
- }
-
- public void innerExecute() throws ExecutionException,
PlatformUnsupportedException
- {
- List<String> commands = getCommands();
-
- CommandExecutor commandExecutor =
CommandExecutor.Factory.createDefaultCommmandExecutor((String)configuration.get(
"switchformats" ));
- commandExecutor.setLogger( logger );
- commandExecutor.executeCommand(
- PathUtil.getExecutable(
- executableContext.getExecutableName(),
executableContext.getProbingPaths(), logger
- ), commands, null, true
- );
- }
-
- public Vendor getVendor()
- {
- return executableContext.getVendor();
- }
-
- public void init( NPandayContext npandayContext, Properties properties )
- {
- configuration = properties;
- this.executableContext = (ExecutableContext) npandayContext;
- this.logger = executableContext.getLogger();
- commands = executableContext.getCommands();
- }
+package npanday.executable.impl;
+
+/*
+ * 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.
+ */
+
+import npanday.NPandayContext;
+import npanday.PathUtil;
+import npanday.PlatformUnsupportedException;
+import npanday.executable.CommandExecutor;
+import npanday.executable.CommandFilter;
+import npanday.executable.ExecutableContext;
+import npanday.executable.ExecutionException;
+import npanday.executable.NetExecutable;
+import npanday.vendor.Vendor;
+import org.codehaus.plexus.logging.Logger;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Properties;
+
+/**
+ * Provides the default implementation of the net executable.
+ *
+ * @author Shane Isbell
+ */
+public class DefaultNetExecutable
+ implements NetExecutable
+{
+
+ protected ExecutableContext executableContext;
+
+ /**
+ * A logger for writing log messages
+ */
+ protected Logger logger;
+
+ private Collection<String> commands;
+
+ private Properties configuration;
+
+ public List<String> getCommands() throws ExecutionException,
PlatformUnsupportedException
+ {
+ // TODO: should it fail on unsupported commands?
+ CommandFilter filter = executableContext.getCommandFilter();
+ return Collections.unmodifiableList( filter.filter( commands ) );
+ }
+
+ public void execute() throws ExecutionException,
PlatformUnsupportedException
+ {
+ innerExecute();
+ }
+
+ public void innerExecute() throws ExecutionException,
PlatformUnsupportedException
+ {
+ List<String> commands = getCommands();
+
+ CommandExecutor commandExecutor =
CommandExecutor.Factory.createDefaultCommmandExecutor((String)configuration.get(
"switchformats" ));
+ commandExecutor.setLogger( logger );
+ commandExecutor.executeCommand(
+ PathUtil.getExecutable(
+ executableContext.getExecutableName(),
executableContext.getProbingPaths(), logger
+ ), commands, null, true
+ );
+ }
+
+ public Vendor getVendor()
+ {
+ return executableContext.getVendor();
+ }
+
+ public void init( NPandayContext npandayContext, Properties properties )
+ {
+ configuration = properties;
+ this.executableContext = (ExecutableContext) npandayContext;
+ this.logger = executableContext.getLogger();
+ commands = executableContext.getCommands();
+ }
}
\ No newline at end of file
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=1227515&r1=1227514&r2=1227515&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
Thu Jan 5 07:42:34 2012
@@ -23,8 +23,8 @@ package npanday.executable.execution;
import npanday.executable.CommandExecutor
import npanday.executable.ExecutionException
-import npanday.executable.execution.quoting.PlexusNativeQuotingStrategy
import npanday.executable.execution.quoting.CustomSwitchAwareQuotingStrategy
+import npanday.executable.execution.quoting.PlexusNativeQuotingStrategy
import org.codehaus.plexus.logging.Logger
import org.codehaus.plexus.logging.console.ConsoleLogger
import org.codehaus.plexus.util.Os
@@ -50,16 +50,12 @@ public class CommandExecutorTest
@Parameters
public static Collection<Object[]> data()
{
- def osKey = Os.isFamily(Os.FAMILY_WINDOWS) ? "win_" : "x_";
+ def osKey = isWindows() ? "win_" : "x_";
Object[][] data = [
- [osKey + "npanday_old",
- new PlexusUtilsCommandExecutor()],
[osKey + "unified_simple_quoting",
new UnifiedShellCommandExecutor(new
PlexusNativeQuotingStrategy())],
[osKey + "unified_custom_quoting",
- new UnifiedShellCommandExecutor(new
CustomSwitchAwareQuotingStrategy())],
- [osKey + "commons_exec_experimental",
- new CommonsExecCommandExecutor()]
+ new UnifiedShellCommandExecutor(new
CustomSwitchAwareQuotingStrategy())]
];
return Arrays.asList(data);
}
@@ -108,7 +104,6 @@ public class CommandExecutorTest
throws ExecutionException
{
testArgExpansion(["a '"], [
- win_npanday_old: '"a \'"',
win_unified_simple_quoting: '"a \'"',
win_unified_custom_quoting: '"a \'"'
]);
@@ -119,7 +114,6 @@ public class CommandExecutorTest
throws ExecutionException
{
testArgExpansion(["' a"], [
- win_npanday_old: '"\' a"',
win_unified_simple_quoting: '"\' a"',
win_unified_custom_quoting: '"\' a"'
]);
@@ -130,7 +124,6 @@ public class CommandExecutorTest
throws ExecutionException
{
testArgExpansion(["' a '"], [
- win_npanday_old: '"\' a \'"',
win_unified_simple_quoting: '"\' a \'"',
win_unified_custom_quoting: '"\' a \'"'
]);
@@ -141,7 +134,6 @@ public class CommandExecutorTest
throws ExecutionException
{
testArgExpansion(['a " b'], [
- win_npanday_old: '"a " b"',
win_unified_simple_quoting: '"a \\" b"',
win_unified_custom_quoting: '"a \\" b"'
]);
@@ -152,7 +144,6 @@ public class CommandExecutorTest
throws ExecutionException
{
testArgExpansion(['a "'], [
- win_npanday_old: '"a ""',
win_unified_simple_quoting: '"a \\""',
win_unified_custom_quoting: '"a \\""'
]);
@@ -163,7 +154,6 @@ public class CommandExecutorTest
throws ExecutionException
{
testArgExpansion(['" a'], [
- win_npanday_old: '"" a"',
win_unified_simple_quoting: '"\\" a"',
win_unified_custom_quoting: '"\\" a"'
]);
@@ -174,7 +164,6 @@ public class CommandExecutorTest
throws ExecutionException
{
testArgExpansion(['" a "'], [
- win_npanday_old: '" a "',
win_unified_simple_quoting: '" a "', // if it yet is
quoted, it wont quote again
win_unified_custom_quoting: '"\\" a \\""' // but we
want it escaped and quoted again
]);
@@ -258,6 +247,10 @@ public class CommandExecutorTest
private def testArgExpansion(ArrayList<String> args, Map<String, String>
expectedPerHint)
{
+ if (!isWindows()){
+
+ }
+
if ( !expectedPerHint.containsKey(cmdHint) )
{
cmd.executeCommand("echo", args)
@@ -422,8 +415,6 @@ public class CommandExecutorTest
*/
private static boolean isWindows()
{
- String osName = System.getProperty("os.name");
- boolean isWin = (osName.toLowerCase().indexOf("win")) >= 0;
- return isWin;
+ return Os.isFamily(Os.FAMILY_WINDOWS);
}
}
\ No newline at end of file
Modified:
incubator/npanday/trunk/plugins/netplugins/NPanday.Plugin.Settings/javabinding/src/main/java/NPanday/Plugin/Settings/SettingsGeneratorMojo.java
URL:
http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/netplugins/NPanday.Plugin.Settings/javabinding/src/main/java/NPanday/Plugin/Settings/SettingsGeneratorMojo.java?rev=1227515&r1=1227514&r2=1227515&view=diff
==============================================================================
---
incubator/npanday/trunk/plugins/netplugins/NPanday.Plugin.Settings/javabinding/src/main/java/NPanday/Plugin/Settings/SettingsGeneratorMojo.java
(original)
+++
incubator/npanday/trunk/plugins/netplugins/NPanday.Plugin.Settings/javabinding/src/main/java/NPanday/Plugin/Settings/SettingsGeneratorMojo.java
Thu Jan 5 07:42:34 2012
@@ -262,6 +262,6 @@ public class SettingsGeneratorMojo
public void postExecute()
throws MojoExecutionException, MojoFailureException
{
- SettingsUtil.applyCustomSettings( getLog(), repositoryRegistry,
settingsPath );
+ SettingsUtil.applyCustomSettings( getLog(), repositoryRegistry,
settingsPath);
}
}