From cfeee2b228ae4fb973ad8ce56eb24f63baf298f1 Mon Sep 17 00:00:00 2001 From: pair13 Date: Tue, 20 Jan 2009 12:10:04 -0600 Subject: [PATCH] Tim (on behalf of Luke & Kelly): made the file paths OS independent --- .../mojo/fitnesse/FitnesseAbstractMojo.java | 57 +++++++------- .../codehaus/mojo/fitnesse/FitnesseRunnerMojo.java | 81 +++++++++++--------- .../fitnesse/plexus/FCommandLineException.java | 2 +- .../mojo/fitnesse/plexus/FCommandLineUtils.java | 2 +- .../mojo/fitnesse/plexus/FCommandline.java | 22 +++--- .../mojo/fitnesse/FitnesseRunnerMojoTest.java | 9 +- 6 files changed, 93 insertions(+), 80 deletions(-) diff --git a/src/main/java/org/codehaus/mojo/fitnesse/FitnesseAbstractMojo.java b/src/main/java/org/codehaus/mojo/fitnesse/FitnesseAbstractMojo.java index f0243af..a945da1 100644 --- a/src/main/java/org/codehaus/mojo/fitnesse/FitnesseAbstractMojo.java +++ b/src/main/java/org/codehaus/mojo/fitnesse/FitnesseAbstractMojo.java @@ -17,6 +17,7 @@ package org.codehaus.mojo.fitnesse; import java.io.IOException; import java.io.InputStream; import java.io.Writer; +import java.io.File; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; @@ -30,7 +31,7 @@ import org.apache.maven.settings.Server; /** * Common class for all FitNesse Mojo. - * + * * @author pke */ public abstract class FitnesseAbstractMojo @@ -46,18 +47,18 @@ public abstract class FitnesseAbstractMojo * This is the list of FitNesse server pages.
A FitNesse tag is compose of the nested tags:
* <fitnesses>
* <fitnesse>
- * <pageName>This is the only required parameter, the name of + * <pageName>This is the only required parameter, the name of * the FitNesse page</pageName>
* <hostName>default is locahost</hostName>
* <port>: default is 80;</port>
- * <serverId>ServerId defined in your settings.xml, this allows to use credentials + * <serverId>ServerId defined in your settings.xml, this allows to use credentials * (basic athentification) for calling your FitNesse pages</serverId>
* <type>Override the default type of the page (Suite or Test).;</type>
* </fitnesse>
* ...
* </fitnesses>:
*
- * + * * @parameter * @required */ @@ -65,21 +66,21 @@ public abstract class FitnesseAbstractMojo /** * Fail the build if fitnesse pages have error. - * + * * @parameter default-value=false */ private boolean failOnError; /** * Date format for FitNesse page timestamp. - * + * * @parameter default-value="dd/MM/yyyy HH:mm" */ private String dateFormat; /** * List of the servers. - * + * * @parameter expression="${settings.servers}" * @required * @readonly @@ -87,7 +88,7 @@ public abstract class FitnesseAbstractMojo private List servers = new ArrayList(); /** - * @parameter expression="${project.build.directory}/fitnesse" + * @parameter expression="${project.build.directory}\\fitnesse" * @readonly * @required */ @@ -110,7 +111,7 @@ public abstract class FitnesseAbstractMojo /** * Check the Mojo configuration. - * + * * @throws MojoExecutionException When the configuration is invalid. */ void checkConfiguration() @@ -168,7 +169,7 @@ public abstract class FitnesseAbstractMojo /** * Accessor. - * + * * @param pFitnesses List the FitNesse resources to call or run. */ public void setFitnesses( List pFitnesses ) @@ -178,7 +179,7 @@ public abstract class FitnesseAbstractMojo /** * Accessor. - * + * * @param pPosition Index of the configuration. * @return The FitNesse server configuration. */ @@ -189,7 +190,7 @@ public abstract class FitnesseAbstractMojo /** * Accessor. - * + * * @return The FitNesse configuration size. */ protected int getFitnesseSize() @@ -199,7 +200,7 @@ public abstract class FitnesseAbstractMojo /** * Accessor. - * + * * @param pServerId The identifier of the server that required credentials. * @return The credentials to use for this server. * @throws MojoExecutionException If there isn't any credential for this server. @@ -228,7 +229,7 @@ public abstract class FitnesseAbstractMojo /** * Add new server credential configuration. - * + * * @param pServer The FitNesse server configuration. */ public void addServer( Server pServer ) @@ -238,7 +239,7 @@ public abstract class FitnesseAbstractMojo /** * Accessor. - * + * * @return True if the build must fail when FitNesse tests failed. */ public boolean isFailOnError() @@ -248,7 +249,7 @@ public abstract class FitnesseAbstractMojo /** * Accessor. - * + * * @param failOnError True if the build must fail when FitNesse tests failed. */ public void setFailOnError( boolean failOnError ) @@ -259,7 +260,7 @@ public abstract class FitnesseAbstractMojo /** * This method compute the FitNesse Html result page before saving it to file. It formats the page in a format * closer to maven site. - * + * * @param pIn The original file stream. * @param pOut The result file stream. * @param pOutputFileName The file name of the final result file. @@ -322,7 +323,7 @@ public abstract class FitnesseAbstractMojo /** * Get the image associated to the tests status. - * + * * @param pStatus The tests status. * @return The name of the image. * @throws MojoExecutionException If the status is invalid. @@ -350,7 +351,7 @@ public abstract class FitnesseAbstractMojo /** * Return the current time formated as string according to the specified format. - * + * * @return The string representation. */ protected String getCurrentTimeAsString() @@ -361,7 +362,7 @@ public abstract class FitnesseAbstractMojo /** * Accessor. - * + * * @param pDateFormat The date format to use when formating date. */ public void setDateFormat( String pDateFormat ) @@ -371,7 +372,7 @@ public abstract class FitnesseAbstractMojo /** * Accessor. - * + * * @return The date format to use when formating date. */ public String getDateFormat() @@ -381,7 +382,7 @@ public abstract class FitnesseAbstractMojo /** * Generate a temp file name for saving fitnesse result. - * + * * @param pServer The FitNesse configuration. * @return The file name. */ @@ -392,7 +393,7 @@ public abstract class FitnesseAbstractMojo /** * Give the final file name for saving fitnesse result. - * + * * @param pServer The FitNesse configuration. * @return The file name. */ @@ -403,7 +404,7 @@ public abstract class FitnesseAbstractMojo /** * Contract. - * + * * @param pServer The FitNesse server configuration. * @return The output file name. */ @@ -411,7 +412,7 @@ public abstract class FitnesseAbstractMojo /** * Contract. - * + * * @param pServer The FitNesse server configuration. * @return The output url. */ @@ -419,7 +420,7 @@ public abstract class FitnesseAbstractMojo /** * Generate the full final file name for saving fitnesse result. - * + * * @param pServer The FitNesse server configuration. * @param pPostfix The postfix extension to use when generating the full file name. * @param pExtension The file extension to use. @@ -427,8 +428,8 @@ public abstract class FitnesseAbstractMojo */ protected String getResultFileName( Fitnesse pServer, String pPostfix, String pExtension ) { - return this.workingDir + "/" + FITNESSE_RESULT_PREFIX + "_" + pServer.getHostName() + "_" - + pServer.getPageName() + pPostfix + "." + pExtension; + return this.workingDir + File.separator + FITNESSE_RESULT_PREFIX + "_" + pServer.getHostName() + "_" + + pServer.getPageName() + pPostfix + "." + pExtension; } } diff --git a/src/main/java/org/codehaus/mojo/fitnesse/FitnesseRunnerMojo.java b/src/main/java/org/codehaus/mojo/fitnesse/FitnesseRunnerMojo.java index 008d008..85c321a 100644 --- a/src/main/java/org/codehaus/mojo/fitnesse/FitnesseRunnerMojo.java +++ b/src/main/java/org/codehaus/mojo/fitnesse/FitnesseRunnerMojo.java @@ -54,10 +54,9 @@ import org.codehaus.mojo.fitnesse.runner.ClassPathBuilder; * This goal uses the fitnesse.runner.TestRunner class for calling a remote FitNesse web page and * executes the tests or suites locally into a forked JVM. It's possible to define several pages and/or * servers. - * + * * @goal run * @requiresDependencyResolution runtime - * @aggregator */ public class FitnesseRunnerMojo extends FitnesseAbstractMojo @@ -67,7 +66,7 @@ public class FitnesseRunnerMojo * value: "fitnesse" (default) or "maven".
With "fitnesse" mode, the classpath is downloaded from the FitNesse * server page. Then classpath of the plugin is appended (for providing the good FitNesse implementation).
* With "maven" mode the classpath is only defined with the one of the project (POM). - * + * * @parameter default-value="fitnesse" */ private String classPathProvider; @@ -89,7 +88,7 @@ public class FitnesseRunnerMojo *

* Note: This is passed by Maven and must not be configured by the user. *

- * + * * @parameter expression="${project}" * @readonly * @required @@ -105,7 +104,7 @@ public class FitnesseRunnerMojo * classpath size. For exemple the string * [E:/Maven/repository/org/springframework/spring-beans/1.2.8/spring-beans-1.2.8.jar] (81 chars) became * [lib/spring-beans-1.2.8.jar] (26 chars). That doesn't solve the problems but allows to use bigger classpath. - * + * * @parameter default-value="false" */ boolean copyDependencies; @@ -115,7 +114,7 @@ public class FitnesseRunnerMojo *

* Note: This is passed by Maven and must not be configured by the user. *

- * + * * @parameter expression="${plugin.artifacts}" * @readonly * @required @@ -124,7 +123,7 @@ public class FitnesseRunnerMojo /** * The set of dependencies required by the project - * + * * @parameter default-value="${project.dependencies}" * @required * @readonly @@ -140,7 +139,7 @@ public class FitnesseRunnerMojo /** * Artifact resolver used to find clovered artifacts (artifacts with a clover classifier). - * + * * @component role="org.apache.maven.artifact.resolver.ArtifactResolver" * @required * @readonly @@ -149,7 +148,7 @@ public class FitnesseRunnerMojo /** * Local maven repository. - * + * * @parameter expression="${localRepository}" * @required * @readonly @@ -179,35 +178,35 @@ public class FitnesseRunnerMojo /** * Java executable. - * + * * @parameter default-value="java" */ private String jdk; /** * Jvm arguments. - * + * * @parameter default-value="" */ private String jdkOpts; /** * Redirect FitNesse output into Maven2 log. - * + * * @parameter default-value=false */ private boolean displayOutput; /** * Run FitnesseRunner with debug option. - * + * * @parameter default-value="false" */ private boolean debug; /** * Fitnesse runner class. - * + * * @parameter default-value="fitnesse.runner.TestRunner" */ private String fitnesseRunnerClass; @@ -226,7 +225,7 @@ public class FitnesseRunnerMojo * </classPathSubstitutions>:
* * This parameter can only be use if param classPathProvider has fitnesse value. - * + * * @parameter */ private List classPathSubstitutions = new ArrayList(); @@ -241,13 +240,18 @@ public class FitnesseRunnerMojo /** * Main Mojo method. - * + * * @throws MojoExecutionException If the method can't be executed. * @throws MojoFailureException If there is fitnesse tests failures. */ public void execute() throws MojoExecutionException, MojoFailureException { + if (skippingTests()) { + getLog().info("Skipping fitnesse tests"); + return; + } + new File( this.workingDir ).mkdirs(); checkConfiguration(); @@ -269,9 +273,14 @@ public class FitnesseRunnerMojo } } + private boolean skippingTests() { + String skipTest = System.getProperty("maven.test.skip"); + return skipTest != null && "true".equalsIgnoreCase(skipTest); + } + /******************************************************************************************************************* * Change the fitnesse result page to a Maven site format. - * + * * @param pServer FitNesse server configuration. * @throws MojoExecutionException If the result page can't be found. */ @@ -327,7 +336,7 @@ public class FitnesseRunnerMojo * Get the classpath to use for running the fitnesse tests. The classpath is found using the fitnesse * path property or using Maven dependancies, according to the POM configuration. The classpath is * adapted to the local server configuration depending on the local folders. - * + * * @param tServer The FitNesse configuration. * @return The ClassPath to use. * @throws MojoExecutionException If the classpath can't be found. @@ -373,7 +382,7 @@ public class FitnesseRunnerMojo * the Command Line can't be longer than 8192 character. With that mecanism, the local path are shorter than the * full one. For example: "lib/myJar-1.0.jar" is shorter than "d:\maven\repo\com\myCompany\myJar\1.0\myJar-1.0.jar". * The method copy the jar and compute the new classpath using these local jars. - * + * * @param pClasspath The absolute classpath provided by Maven or FitNesse. * @return The new local classpath. * @throws MojoExecutionException If the classpath can't be found. @@ -428,7 +437,7 @@ public class FitnesseRunnerMojo /** * Get the Maven classpath using the POM dependencies. - * + * * @return The classpath. * @throws MojoExecutionException If the classpath can't be found. */ @@ -455,7 +464,7 @@ public class FitnesseRunnerMojo /** * Create the transitive classpath. - * + * * @return The dependent artifacts. * @throws MojoExecutionException If the classpath can't be found. */ @@ -502,7 +511,7 @@ public class FitnesseRunnerMojo /** * Call a Fitnesse server page. - * + * * @param pServer The Fitnesse configuration. * @throws MojoFailureException If a failure occurs. * @throws MojoExecutionException If an error occurs. @@ -517,7 +526,7 @@ public class FitnesseRunnerMojo /** * Run locally the FitNesse tests for one configuration. - * + * * @param pServer The FitNesse configuration. * @param pCmd The Command. * @throws MojoFailureException If the is a FitNesse failure. @@ -571,7 +580,7 @@ public class FitnesseRunnerMojo /** * Close reserved resources. - * + * * @param pInfoConsumer The resource to release. */ private void closeConsumer( FitnesseStreamConsumer pInfoConsumer ) @@ -589,7 +598,7 @@ public class FitnesseRunnerMojo /** * Get the error stream of the external Process. - * + * * @param pConsumer The resources associated to the external process. * @return The error stream. */ @@ -609,7 +618,7 @@ public class FitnesseRunnerMojo /** * Get the standard stream of the external Process. - * + * * @param pServer The FitNesse configuration. * @return The standard stream. */ @@ -669,7 +678,7 @@ public class FitnesseRunnerMojo /** * Create the Command object fot running the tests locally. - * + * * @param pServer The fitnesse configuration. * @param pClassPath The classpath. * @return A ready to use command object. @@ -716,7 +725,7 @@ public class FitnesseRunnerMojo /** * Accessor. - * + * * @param pFitnesseRunnerClass The main class fot running FitNesse. */ public void setFitnesseRunnerClass( String pFitnesseRunnerClass ) @@ -726,7 +735,7 @@ public class FitnesseRunnerMojo /** * Accessor. - * + * * @param pJdk The Jdk path. */ public void setJdk( String pJdk ) @@ -736,7 +745,7 @@ public class FitnesseRunnerMojo /** * Accessor. - * + * * @param pWorkingDir The working directory fot the fitnesse execution. */ public void setWorkingDir( String pWorkingDir ) @@ -746,7 +755,7 @@ public class FitnesseRunnerMojo /** * Accessor. - * + * * @param pDebug The debug level. */ void setDebug( boolean pDebug ) @@ -756,7 +765,7 @@ public class FitnesseRunnerMojo /** * Accessor. - * + * * @param pCmd The commandLine for running FitNesse. */ void setCmd( FCommandline pCmd ) @@ -766,7 +775,7 @@ public class FitnesseRunnerMojo /** * Accessor. - * + * * @param jdkOpts The Jsk options to use when runinng fitnesse tests. */ void setJdkOpts( String jdkOpts ) @@ -776,7 +785,7 @@ public class FitnesseRunnerMojo /** * Accessor. - * + * * @param pluginArtifacts The Maven resource. */ public void setPluginArtifacts( List pluginArtifacts ) @@ -786,7 +795,7 @@ public class FitnesseRunnerMojo /** * Resolve plugin artifacts. - * + * * @return The plugin. * @throws MojoExecutionException If the plun gin can't be found. */ @@ -820,7 +829,7 @@ public class FitnesseRunnerMojo /** * For testing purpose. Record plugin information for the {@link FitnesseRunnerMojo#resolvePlugin()}. - * + * * @param pGroupId The groupId of the plugin. * @param pArtifactId The artifactI of the plugin. * @param pVersion The version of the plugin. diff --git a/src/main/java/org/codehaus/mojo/fitnesse/plexus/FCommandLineException.java b/src/main/java/org/codehaus/mojo/fitnesse/plexus/FCommandLineException.java index 51aed17..c190ef0 100644 --- a/src/main/java/org/codehaus/mojo/fitnesse/plexus/FCommandLineException.java +++ b/src/main/java/org/codehaus/mojo/fitnesse/plexus/FCommandLineException.java @@ -26,7 +26,7 @@ package org.codehaus.mojo.fitnesse.plexus; /** * @author Trygve Laugstøl - * @version $Id$ + * @version $Id: FCommandLineException.java 6588 2008-03-28 12:22:57Z bentmann $ */ public class FCommandLineException extends Exception diff --git a/src/main/java/org/codehaus/mojo/fitnesse/plexus/FCommandLineUtils.java b/src/main/java/org/codehaus/mojo/fitnesse/plexus/FCommandLineUtils.java index 82bf14f..9982575 100644 --- a/src/main/java/org/codehaus/mojo/fitnesse/plexus/FCommandLineUtils.java +++ b/src/main/java/org/codehaus/mojo/fitnesse/plexus/FCommandLineUtils.java @@ -32,7 +32,7 @@ import org.codehaus.plexus.util.cli.StreamPumper; /** * @author Trygve Laugstøl - * @version $Id$ + * @version $Id: FCommandLineUtils.java 6588 2008-03-28 12:22:57Z bentmann $ */ public abstract class FCommandLineUtils { diff --git a/src/main/java/org/codehaus/mojo/fitnesse/plexus/FCommandline.java b/src/main/java/org/codehaus/mojo/fitnesse/plexus/FCommandline.java index 2e04307..44b1709 100644 --- a/src/main/java/org/codehaus/mojo/fitnesse/plexus/FCommandline.java +++ b/src/main/java/org/codehaus/mojo/fitnesse/plexus/FCommandline.java @@ -97,7 +97,7 @@ import java.util.Vector; * </someelement>
* The element someelement must provide a method createAcommandline which returns * an instance of this class. - * + * * @author thomas.haas@softwired-inc.com * @author Stefan Bodewig */ @@ -126,7 +126,8 @@ public class FCommandline public FCommandline( String toProcess ) { super(); - setDefaultShell(); + // We don't like your stinking shell -- Luke, Viktoriya & Kelly + //setDefaultShell(); String[] tmp = new String[0]; try { @@ -149,7 +150,8 @@ public class FCommandline public FCommandline() { super(); - setDefaultShell(); + // We don't like your stinking shell -- Luke, Viktoriya & Kelly + //setDefaultShell(); } /** @@ -162,7 +164,7 @@ public class FCommandline /** * Sets a single commandline argument. - * + * * @param value a single commandline argument. */ public void setValue( String value ) @@ -172,7 +174,7 @@ public class FCommandline /** * Line to split into several commandline arguments. - * + * * @param line line to split into several commandline arguments */ public void setLine( String line ) @@ -193,7 +195,7 @@ public class FCommandline /** * Sets a single commandline argument to the absolute filename of the given file. - * + * * @param value a single commandline argument. */ public void setFile( File value ) @@ -281,7 +283,7 @@ public class FCommandline * Each commandline object has at most one instance of the argument class. This method calls * this.createArgument(false). *

- * + * * @see #createArgument(boolean) * @return the argument object. */ @@ -295,7 +297,7 @@ public class FCommandline *

* Each commandline object has at most one instance of the argument class. *

- * + * * @param insertAtStart if true, the argument is inserted at the beginning of the list of args, otherwise it is * appended. */ @@ -357,7 +359,7 @@ public class FCommandline /** * Return the current list of environment variables or null if user doesn't have add any variable. - * + * * @todo return the list of proc env variables with user env variables if user add some var. */ public String[] getCurrentEnvironment() @@ -454,7 +456,7 @@ public class FCommandline * If the argument doesn't include spaces or quotes, return it as is. If it contains double quotes, use single * quotes - else surround the argument by double quotes. *

- * + * * @exception FCommandLineException if the argument contains both, single and double quotes. */ public static String quoteArgument( String argument ) diff --git a/src/test/java/org/codehaus/mojo/fitnesse/FitnesseRunnerMojoTest.java b/src/test/java/org/codehaus/mojo/fitnesse/FitnesseRunnerMojoTest.java index 49f6e43..71c6d57 100644 --- a/src/test/java/org/codehaus/mojo/fitnesse/FitnesseRunnerMojoTest.java +++ b/src/test/java/org/codehaus/mojo/fitnesse/FitnesseRunnerMojoTest.java @@ -106,7 +106,7 @@ public class FitnesseRunnerMojoTest mMojo.setClassPathProvider( "fitnesse" ); mMojo.setPluginArtifacts( new ArrayList() ); mMojo.setJdk( "java" ); - mMojo.setWorkingDir( "target/fitnesse" ); + mMojo.setWorkingDir( "target" + File.separator + "fitnesse" ); mMojo.setFitnesseRunnerClass( "fitnesse.runner.TestRunner" ); mMojo.setPluginArtifact( getArtifact() ); @@ -239,12 +239,12 @@ public class FitnesseRunnerMojoTest public void testPrepareCommandLine() throws MojoExecutionException { - assertEquals( "java -cp bidon.jar" + File.pathSeparatorChar + " fitnesse.runner.TestRunner -v -html " - + "target/fitnesse/fitnesseResult_localhost_MustBeDefinedByProject_tmp.html -nopath localhost 80 MustBeDefinedByProject", + + "target" + File.separator + "fitnesse" + File.separator + + "fitnesseResult_localhost_MustBeDefinedByProject_tmp.html -nopath localhost 80 MustBeDefinedByProject", mMojo.prepareCommandLine( mMojo.getFitnesse( 0 ), "bidon.jar" + File.pathSeparatorChar ).toString() ); mMojo.setDebug( true ); @@ -252,7 +252,8 @@ public class FitnesseRunnerMojoTest "java -cp bidon.jar" + File.pathSeparatorChar + " fitnesse.runner.TestRunner -v -debug " - + "-html target/fitnesse/fitnesseResult_localhost_MustBeDefinedByProject_tmp.html -nopath localhost 80 MustBeDefinedByProject", + + "-html target" + File.separator + "fitnesse" + File.separator + + "fitnesseResult_localhost_MustBeDefinedByProject_tmp.html -nopath localhost 80 MustBeDefinedByProject", mMojo.prepareCommandLine( mMojo.getFitnesse( 0 ), "bidon.jar" + File.pathSeparatorChar ).toString() ); } -- 1.6.0.4