You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by vs...@apache.org on 2008/07/16 02:16:14 UTC
svn commit: r677115 - in
/maven/plugin-testing/trunk/maven-plugin-testing-tools/src:
main/java/org/apache/maven/shared/test/plugin/
test/java/org/apache/maven/shared/test/plugin/
Author: vsiveton
Date: Tue Jul 15 17:16:13 2008
New Revision: 677115
URL: http://svn.apache.org/viewvc?rev=677115&view=rev
Log:
o fixed javadoc
o push license header in the correct way
Modified:
maven/plugin-testing/trunk/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/BuildTool.java
maven/plugin-testing/trunk/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/ComponentTestTool.java
maven/plugin-testing/trunk/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/PluginTestTool.java
maven/plugin-testing/trunk/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/ProjectTool.java
maven/plugin-testing/trunk/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/RepositoryTool.java
maven/plugin-testing/trunk/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/TestToolsException.java
maven/plugin-testing/trunk/maven-plugin-testing-tools/src/test/java/org/apache/maven/shared/test/plugin/ProjectToolTest.java
maven/plugin-testing/trunk/maven-plugin-testing-tools/src/test/java/org/apache/maven/shared/test/plugin/RepositoryToolTest.java
Modified: maven/plugin-testing/trunk/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/BuildTool.java
URL: http://svn.apache.org/viewvc/maven/plugin-testing/trunk/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/BuildTool.java?rev=677115&r1=677114&r2=677115&view=diff
==============================================================================
--- maven/plugin-testing/trunk/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/BuildTool.java (original)
+++ maven/plugin-testing/trunk/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/BuildTool.java Tue Jul 15 17:16:13 2008
@@ -1,3 +1,5 @@
+package org.apache.maven.shared.test.plugin;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -16,7 +18,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.maven.shared.test.plugin;
import java.io.File;
import java.io.FileWriter;
@@ -39,14 +40,15 @@
/**
* Test-tool used to execute Maven builds in order to test plugin functionality.
- *
+ *
* @plexus.component role="org.apache.maven.shared.test.plugin.BuildTool" role-hint="default"
* @author jdcasey
- *
+ * @version $Id$
*/
public class BuildTool
implements Initializable, Disposable
{
+ /** Plexus role */
public static final String ROLE = BuildTool.class.getName();
private Invoker mavenInvoker;
@@ -55,14 +57,15 @@
* Build a standard InvocationRequest using the specified test-build POM, command-line properties,
* goals, and output logfile. Then, execute Maven using this standard request. Return the result
* of the invocation.
- *
+ *
* @param pom The test-build POM
- * @param properties command-line properties to fine-tune the test build, or test parameter
- * extraction from CLI properties
+ * @param properties command-line properties to fine-tune the test build, or test parameter
+ * extraction from CLI properties
* @param goals The list of goals and/or lifecycle phases to execute during this build
* @param buildLogFile The logfile used to capture build output
* @return The result of the Maven invocation, including exit value and any execution exceptions
* resulting from the Maven invocation.
+ * @throws TestToolsException if any
*/
public InvocationResult executeMaven( File pom, Properties properties, List goals, File buildLogFile )
throws TestToolsException
@@ -73,13 +76,14 @@
}
/**
- * Execute a test build using a customized InvocationRequest. Normally, this request would be
+ * Execute a test build using a customized InvocationRequest. Normally, this request would be
* created using the <code>createBasicInvocationRequest</code> method in this class.
- *
+ *
* @param request The customized InvocationRequest containing the configuration used to execute
* the current test build
* @return The result of the Maven invocation, containing exit value, along with any execution
* exceptions resulting from the [attempted] Maven invocation.
+ * @throws TestToolsException if any
*/
public InvocationResult executeMaven( InvocationRequest request )
throws TestToolsException
@@ -102,7 +106,7 @@
* Detect the location of the local Maven installation, and start up the MavenInvoker using that
* path. Detection uses the system property <code>maven.home</code>, and falls back to the shell
* environment variable <code>M2_HOME</code>.
- *
+ *
* @throws IOException in case the shell environment variables cannot be read
*/
private void startInvoker()
@@ -129,7 +133,7 @@
/**
* If we're logging output to a logfile using standard output handlers, make sure these are
* closed.
- *
+ *
* @param request
*/
private void closeHandlers( InvocationRequest request )
@@ -156,12 +160,12 @@
* directed. The resulting InvocationRequest can then be customized by the test class before
* being used to execute a test build. Both standard-out and standard-error will be directed
* to the specified log file.
- *
+ *
* @param pom The POM for the test build
* @param properties The command-line properties for use in this test build
* @param goals The goals and/or lifecycle phases to execute during the test build
* @param buildLogFile Location to which build output should be logged
- * @return The standardized InvocationRequest for the test build, ready for any necessary
+ * @return The standardized InvocationRequest for the test build, ready for any necessary
* customizations.
*/
public InvocationRequest createBasicInvocationRequest( File pom, Properties properties, List goals,
@@ -197,6 +201,7 @@
output = logFile;
}
+ /** {@inheritDoc} */
public void consumeLine( String line )
{
if ( writer == null )
@@ -228,12 +233,13 @@
{
IOUtil.close( writer );
}
-
}
/**
* Initialize this tool once it's been instantiated and composed, in order to start up the
* MavenInvoker instance.
+ *
+ * @throws InitializationException if any
*/
public void initialize()
throws InitializationException
@@ -246,16 +252,15 @@
{
throw new InitializationException( "Error detecting maven home.", e );
}
-
}
/**
- * Not currently used; when this API switches to use the Maven Embedder, it will be used to
+ * Not currently used; when this API switches to use the Maven Embedder, it will be used to
* shutdown the embedder and its associated container, to free up JVM memory.
*/
public void dispose()
{
- // TODO: When we switch to the embedder, use this to deallocate the MavenEmbedder, along
+ // TODO: When we switch to the embedder, use this to deallocate the MavenEmbedder, along
// with the PlexusContainer and ClassRealm that it wraps.
}
}
Modified: maven/plugin-testing/trunk/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/ComponentTestTool.java
URL: http://svn.apache.org/viewvc/maven/plugin-testing/trunk/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/ComponentTestTool.java?rev=677115&r1=677114&r2=677115&view=diff
==============================================================================
--- maven/plugin-testing/trunk/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/ComponentTestTool.java (original)
+++ maven/plugin-testing/trunk/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/ComponentTestTool.java Tue Jul 15 17:16:13 2008
@@ -1,3 +1,5 @@
+package org.apache.maven.shared.test.plugin;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -16,7 +18,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.maven.shared.test.plugin;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.FileUtils;
@@ -26,24 +27,25 @@
/**
* Test tool that provides a single point of access for staging a maven component artifact - along with its
- * POM lineage - into a clean test-time local repository. This involves modifying the component POM to
+ * POM lineage - into a clean test-time local repository. This involves modifying the component POM to
* provide a stable test-time version for test-build POMs to reference, then installing the component
* jar and associated POMs (including those ancestors that are reachable using <relativePath>)
* into the test local repository.
- *
+ *
* <p>
- * <b>WARNING:</b> Currently, the <code>RepositoryTool</code> will not
- * resolve parent POMs that exist <b>only</b> in your normal local repository, and are not reachable
- * using the relativePath element. This may result in failed test builds, as one or more of the
+ * <b>WARNING:</b> Currently, the <code>RepositoryTool</code> will not
+ * resolve parent POMs that exist <b>only</b> in your normal local repository, and are not reachable
+ * using the relativePath element. This may result in failed test builds, as one or more of the
* component's ancestor POMs cannot be resolved.
* </p>
- *
+ *
* @plexus.component role="org.apache.maven.shared.test.plugin.ComponentTestTool" role-hint="default"
* @author jdcasey
- *
+ * @version $Id$
*/
public class ComponentTestTool
{
+ /** Plexus role */
public static final String ROLE = ComponentTestTool.class.getName();
/**
@@ -60,10 +62,12 @@
* Stage the component, using a stable version, into a temporary local-repository directory that is
* generated by this method. When the component is staged, return the local repository base directory
* for use in test builds.
- *
+ *
+ * @param pomFile current POM file
* @param testVersion The test version for the component, used for reference in test-build POMs and
- * fully-qualified goals
+ * fully-qualified goals
* @return The base-directory location of the generated local repository
+ * @throws TestToolsException if any
*/
public File prepareComponentForIntegrationTesting( File pomFile, String testVersion )
throws TestToolsException
@@ -74,12 +78,14 @@
/**
* Stage the component, using a stable version, into a temporary local-repository directory that is
* generated by this method. When the component is staged, return the local repository base directory
- * for use in test builds. This method also skips unit testing during component jar production,
+ * for use in test builds. This method also skips unit testing during component jar production,
* since it is assumed that executing these tests would lead to a recursive test-and-build loop.
- *
+ *
+ * @param pomFile current POM file
* @param testVersion The test version for the component, used for reference in test-build POMs and
- * fully-qualified goals
+ * fully-qualified goals
* @return The base-directory location of the generated local repository
+ * @throws TestToolsException if any
*/
public File prepareComponentForUnitTestingWithMavenBuilds( File pomFile, String testVersion )
throws TestToolsException
@@ -88,14 +94,16 @@
}
/**
- * Stage the component, using a stable version, into the specified local-repository directory.
+ * Stage the component, using a stable version, into the specified local-repository directory.
* When the component is staged, return the local repository base directory for verification.
- *
+ *
+ * @param pomFile current POM file
* @param testVersion The test version for the component, used for reference in test-build POMs and
* fully-qualified goals
* @param localRepositoryDir The base-directory location of the test local repository, into which
* the component's test version should be staged.
* @return The base-directory location of the generated local repository
+ * @throws TestToolsException if any
*/
public File prepareComponentForIntegrationTesting( File pomFile, String testVersion, File localRepositoryDir )
throws TestToolsException
@@ -104,16 +112,18 @@
}
/**
- * Stage the component, using a stable version, into the specified local-repository directory.
- * When the component is staged, return the local repository base directory for verification. This
- * method also skips unit testing during component jar production, since it is assumed that
+ * Stage the component, using a stable version, into the specified local-repository directory.
+ * When the component is staged, return the local repository base directory for verification. This
+ * method also skips unit testing during component jar production, since it is assumed that
* executing these tests would lead to a recursive test-and-build loop.
- *
+ *
+ * @param pomFile current POM file
* @param testVersion The test version for the component, used for reference in test-build POMs and
- * fully-qualified goals
+ * fully-qualified goals
* @param localRepositoryDir The base-directory location of the test local repository, into which
- * the component's test version should be staged.
+ * the component's test version should be staged.
* @return The base-directory location of the generated local repository
+ * @throws TestToolsException if any
*/
public File prepareComponentForUnitTestingWithMavenBuilds( File pomFile, String testVersion, File localRepositoryDir )
throws TestToolsException
@@ -133,7 +143,7 @@
{
throw new TestToolsException( "Failed to stage component for testing.", e );
}
-
+
try
{
final File tmpDir = File.createTempFile( "component-IT-staging-project", "" );
@@ -144,7 +154,6 @@
Runtime.getRuntime().addShutdownHook( new Thread( new Runnable()
{
-
public void run()
{
try
@@ -167,7 +176,7 @@
}
File buildLog = new File( "target/test-build-logs/setup.build.log" );
-
+
buildLog.getParentFile().mkdirs();
File localRepoDir = localRepositoryDir;
@@ -178,10 +187,9 @@
}
MavenProject project = projectTool.packageProjectArtifact( pomFile, testVersion, skipUnitTests, buildLog );
-
+
repositoryTool.createLocalRepositoryFromComponentProject( project, new File( realProjectDir, "pom.xml" ), localRepoDir );
return localRepoDir;
}
-
}
Modified: maven/plugin-testing/trunk/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/PluginTestTool.java
URL: http://svn.apache.org/viewvc/maven/plugin-testing/trunk/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/PluginTestTool.java?rev=677115&r1=677114&r2=677115&view=diff
==============================================================================
--- maven/plugin-testing/trunk/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/PluginTestTool.java (original)
+++ maven/plugin-testing/trunk/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/PluginTestTool.java Tue Jul 15 17:16:13 2008
@@ -1,3 +1,5 @@
+package org.apache.maven.shared.test.plugin;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -16,7 +18,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.maven.shared.test.plugin;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.FileUtils;
@@ -26,24 +27,25 @@
/**
* Test tool that provides a single point of access for staging a plugin artifact - along with its
- * POM lineage - into a clean test-time local repository. This involves modifying the plugin POM to
+ * POM lineage - into a clean test-time local repository. This involves modifying the plugin POM to
* provide a stable test-time version for test-build POMs to reference, then installing the plugin
* jar and associated POMs (including those ancestors that are reachable using <relativePath>)
* into the test local repository.
- *
+ *
* <p>
- * <b>WARNING:</b> Currently, the <code>RepositoryTool</code> will not
- * resolve parent POMs that exist <b>only</b> in your normal local repository, and are not reachable
- * using the relativePath element. This may result in failed test builds, as one or more of the
+ * <b>WARNING:</b> Currently, the <code>RepositoryTool</code> will not
+ * resolve parent POMs that exist <b>only</b> in your normal local repository, and are not reachable
+ * using the relativePath element. This may result in failed test builds, as one or more of the
* plugin's ancestor POMs cannot be resolved.
* </p>
- *
+ *
* @plexus.component role="org.apache.maven.shared.test.plugin.PluginTestTool" role-hint="default"
* @author jdcasey
- *
+ * @version $Id$
*/
public class PluginTestTool
{
+ /** Plexus role */
public static final String ROLE = PluginTestTool.class.getName();
/**
@@ -60,10 +62,12 @@
* Stage the plugin, using a stable version, into a temporary local-repository directory that is
* generated by this method. When the plugin is staged, return the local repository base directory
* for use in test builds.
- *
+ *
+ * @param pomFile current POM file
* @param testVersion The test version for the plugin, used for reference in test-build POMs and
* fully-qualified goals
* @return The base-directory location of the generated local repository
+ * @throws TestToolsException if any
*/
public File preparePluginForIntegrationTesting( File pomFile, String testVersion )
throws TestToolsException
@@ -74,12 +78,14 @@
/**
* Stage the plugin, using a stable version, into a temporary local-repository directory that is
* generated by this method. When the plugin is staged, return the local repository base directory
- * for use in test builds. This method also skips unit testing during plugin jar production,
+ * for use in test builds. This method also skips unit testing during plugin jar production,
* since it is assumed that executing these tests would lead to a recursive test-and-build loop.
- *
+ *
+ * @param pomFile current POM file
* @param testVersion The test version for the plugin, used for reference in test-build POMs and
* fully-qualified goals
* @return The base-directory location of the generated local repository
+ * @throws TestToolsException if any
*/
public File preparePluginForUnitTestingWithMavenBuilds( File pomFile, String testVersion )
throws TestToolsException
@@ -88,14 +94,16 @@
}
/**
- * Stage the plugin, using a stable version, into the specified local-repository directory.
+ * Stage the plugin, using a stable version, into the specified local-repository directory.
* When the plugin is staged, return the local repository base directory for verification.
- *
+ *
+ * @param pomFile current POM file
* @param testVersion The test version for the plugin, used for reference in test-build POMs and
* fully-qualified goals
* @param localRepositoryDir The base-directory location of the test local repository, into which
* the plugin's test version should be staged.
* @return The base-directory location of the generated local repository
+ * @throws TestToolsException if any
*/
public File preparePluginForIntegrationTesting( File pomFile, String testVersion, File localRepositoryDir )
throws TestToolsException
@@ -104,16 +112,18 @@
}
/**
- * Stage the plugin, using a stable version, into the specified local-repository directory.
- * When the plugin is staged, return the local repository base directory for verification. This
- * method also skips unit testing during plugin jar production, since it is assumed that
+ * Stage the plugin, using a stable version, into the specified local-repository directory.
+ * When the plugin is staged, return the local repository base directory for verification. This
+ * method also skips unit testing during plugin jar production, since it is assumed that
* executing these tests would lead to a recursive test-and-build loop.
- *
+ *
+ * @param pomFile current POM file
* @param testVersion The test version for the plugin, used for reference in test-build POMs and
* fully-qualified goals
* @param localRepositoryDir The base-directory location of the test local repository, into which
* the plugin's test version should be staged.
* @return The base-directory location of the generated local repository
+ * @throws TestToolsException if any
*/
public File preparePluginForUnitTestingWithMavenBuilds( File pomFile, String testVersion, File localRepositoryDir )
throws TestToolsException
@@ -125,7 +135,7 @@
throws TestToolsException
{
File realProjectDir = pomFile.getParentFile();
-
+
try
{
realProjectDir = realProjectDir.getCanonicalFile();
@@ -134,7 +144,7 @@
{
throw new TestToolsException( "Failed to stage plugin for testing.", e );
}
-
+
try
{
final File tmpDir = File.createTempFile( "plugin-IT-staging-project", "" );
@@ -168,7 +178,7 @@
}
File buildLog = new File( "target/test-build-logs/setup.build.log" );
-
+
buildLog.getParentFile().mkdirs();
File localRepoDir = localRepositoryDir;
@@ -179,7 +189,7 @@
}
MavenProject project = projectTool.packageProjectArtifact( pomFile, testVersion, skipUnitTests, buildLog );
-
+
repositoryTool.createLocalRepositoryFromComponentProject( project, new File( realProjectDir, "pom.xml" ), localRepoDir );
return localRepoDir;
Modified: maven/plugin-testing/trunk/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/ProjectTool.java
URL: http://svn.apache.org/viewvc/maven/plugin-testing/trunk/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/ProjectTool.java?rev=677115&r1=677114&r2=677115&view=diff
==============================================================================
--- maven/plugin-testing/trunk/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/ProjectTool.java (original)
+++ maven/plugin-testing/trunk/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/ProjectTool.java Tue Jul 15 17:16:13 2008
@@ -1,3 +1,5 @@
+package org.apache.maven.shared.test.plugin;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -16,7 +18,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.maven.shared.test.plugin;
import java.io.File;
import java.io.IOException;
@@ -58,12 +59,14 @@
* Testing tool used to read MavenProject instances from pom.xml files, and to create plugin jar
* files (package phase of the normal build process) for distribution to a test local repository
* directory.
- *
+ *
* @plexus.component role="org.apache.maven.shared.test.plugin.ProjectTool" role-hint="default"
* @author jdcasey
+ * @version $Id$
*/
public class ProjectTool
{
+ /** Plexus role */
public static final String ROLE = ProjectTool.class.getName();
public static final String INTEGRATION_TEST_DEPLOYMENT_REPO_URL = "integration-test.deployment.repo.url";
@@ -95,6 +98,10 @@
/**
* Construct a MavenProject instance from the specified POM file.
+ *
+ * @param pomFile current POM file
+ * @return the Maven project from a file
+ * @throws TestToolsException if any
*/
public MavenProject readProject( File pomFile )
throws TestToolsException
@@ -105,6 +112,11 @@
/**
* Construct a MavenProject instance from the specified POM file, using the specified local
* repository directory to resolve ancestor POMs as needed.
+ *
+ * @param pomFile current POM file
+ * @param localRepositoryBasedir
+ * @return the Maven project from a file and a local repo
+ * @throws TestToolsException if any
*/
public MavenProject readProject( File pomFile, File localRepositoryBasedir )
throws TestToolsException
@@ -124,6 +136,10 @@
/**
* Construct a MavenProject instance from the specified POM file with dependencies.
+ *
+ * @param pomFile current POM file
+ * @return the Maven project with dependencies from a file
+ * @throws TestToolsException if any
*/
public MavenProject readProjectWithDependencies( File pomFile )
throws TestToolsException
@@ -134,6 +150,11 @@
/**
* Construct a MavenProject instance from the specified POM file with dependencies, using the specified local
* repository directory to resolve ancestor POMs as needed.
+ *
+ * @param pomFile current POM file
+ * @param localRepositoryBasedir
+ * @return the Maven project with dependencies from a file and a local repo
+ * @throws TestToolsException if any
*/
public MavenProject readProjectWithDependencies( File pomFile, File localRepositoryBasedir )
throws TestToolsException
@@ -160,22 +181,23 @@
}
/**
- * Run the plugin's Maven build up to the package phase, in order to produce a jar file for
+ * Run the plugin's Maven build up to the package phase, in order to produce a jar file for
* distribution to a test-time local repository. The testVersion parameter specifies the version
* to be used in the <version/> element of the plugin configuration, and also in fully
- * qualified, unambiguous goal invocations (as in
+ * qualified, unambiguous goal invocations (as in
* org.apache.maven.plugins:maven-eclipse-plugin:test:eclipse).
- *
+ *
* @param pomFile The plugin's POM
- * @param testVersion The version to use for testing this plugin. To promote test resiliency,
- * this version should remain unchanged, regardless of what plugin version is under
+ * @param testVersion The version to use for testing this plugin. To promote test resiliency,
+ * this version should remain unchanged, regardless of what plugin version is under
* development.
* @param skipUnitTests In cases where test builds occur during the unit-testing phase (usually
* a bad testing smell), the plugin jar must be produced <b>without</b> running unit tests.
* Otherwise, the testing process will result in a recursive loop of building a plugin jar and
* trying to unit test it during the build. In these cases, set this flag to <code>true</code>.
- * @return The resulting MavenProject, after the test version and skip flag (for unit tests)
+ * @return The resulting MavenProject, after the test version and skip flag (for unit tests)
* have been appropriately configured.
+ * @throws TestToolsException if any
*/
public MavenProject packageProjectArtifact( File pomFile, String testVersion, boolean skipUnitTests )
throws TestToolsException
@@ -184,24 +206,25 @@
}
/**
- * Run the plugin's Maven build up to the package phase, in order to produce a jar file for
+ * Run the plugin's Maven build up to the package phase, in order to produce a jar file for
* distribution to a test-time local repository. The testVersion parameter specifies the version
* to be used in the <version/> element of the plugin configuration, and also in fully
- * qualified, unambiguous goal invocations (as in
+ * qualified, unambiguous goal invocations (as in
* org.apache.maven.plugins:maven-eclipse-plugin:test:eclipse).
- *
+ *
* @param pomFile The plugin's POM
- * @param testVersion The version to use for testing this plugin. To promote test resiliency,
- * this version should remain unchanged, regardless of what plugin version is under
+ * @param testVersion The version to use for testing this plugin. To promote test resiliency,
+ * this version should remain unchanged, regardless of what plugin version is under
* development.
* @param skipUnitTests In cases where test builds occur during the unit-testing phase (usually
* a bad testing smell), the plugin jar must be produced <b>without</b> running unit tests.
* Otherwise, the testing process will result in a recursive loop of building a plugin jar and
* trying to unit test it during the build. In these cases, set this flag to <code>true</code>.
- * @param logFile The file to which build output should be logged, in order to allow later
+ * @param logFile The file to which build output should be logged, in order to allow later
* inspection in case this build fails.
- * @return The resulting MavenProject, after the test version and skip flag (for unit tests)
+ * @return The resulting MavenProject, after the test version and skip flag (for unit tests)
* have been appropriately configured.
+ * @throws TestToolsException if any
*/
public MavenProject packageProjectArtifact( File pomFile, String testVersion, boolean skipUnitTests, File logFile )
throws TestToolsException
@@ -248,11 +271,12 @@
* currently under test. If test builds will be executed from the unit-testing phase, also inject
* <skip>true</skip> into the configuration of the <code>maven-surefire-plugin</code>
* to allow production of a test-only version of the plugin jar without running unit tests.
- *
+ *
* @param pomFile The plugin POM
* @param testVersion The version that allows test builds to reference the plugin under test
* @param skipUnitTests If true, configure the surefire plugin to skip unit tests
* @return Information about mangled POM, including the temporary file to which it was written.
+ * @throws TestToolsException if any
*/
protected PomInfo manglePomForTesting( File pomFile, String testVersion, boolean skipUnitTests )
throws TestToolsException
@@ -268,11 +292,11 @@
Model model = null;
String finalName = null;
String buildDirectory = null;
-
+
try
{
reader = ReaderFactory.newXmlReader( input );
-
+
model = new MavenXpp3Reader().read( reader );
}
catch ( IOException e )
@@ -303,7 +327,7 @@
{
buildDirectory = "target";
}
-
+
buildDirectory = ( buildDirectory+File.separatorChar+"it-build-target" );
build.setDirectory( buildDirectory );
build.setOutputDirectory( buildDirectory+File.separatorChar+"classes" );
@@ -320,39 +344,39 @@
finalName = model.getArtifactId() + "-" + model.getVersion() + "." + ext;
}
-
+
DistributionManagement distMgmt = new DistributionManagement();
-
+
DeploymentRepository deployRepo = new DeploymentRepository();
-
+
deployRepo.setId( "integration-test.output" );
-
+
File tmpDir = FileUtils.createTempFile( "integration-test-repo", "", null );
String tmpUrl = tmpDir.toURL().toExternalForm();
-
+
deployRepo.setUrl( tmpUrl );
-
+
distMgmt.setRepository( deployRepo );
distMgmt.setSnapshotRepository( deployRepo );
-
+
Repository localAsRemote = new Repository();
localAsRemote.setId( "testing.mainLocalAsRemote" );
-
+
File localRepoDir = repositoryTool.findLocalRepositoryDirectory();
localAsRemote.setUrl( localRepoDir.toURL().toExternalForm() );
-
+
model.addRepository( localAsRemote );
model.addPluginRepository( localAsRemote );
-
+
Site site = new Site();
-
+
site.setId( "integration-test.output" );
site.setUrl( tmpUrl );
-
+
distMgmt.setSite( site );
-
+
model.setDistributionManagement( distMgmt );
-
+
model.addProperty( INTEGRATION_TEST_DEPLOYMENT_REPO_URL, tmpUrl );
if ( skipUnitTests )
@@ -420,10 +444,10 @@
private final String finalName;
private final String buildDirectory;
-
+
private final String buildOutputDirectory;
- PomInfo( File pomFile, String groupId, String artifactId, String version, String buildDirectory,
+ PomInfo( File pomFile, String groupId, String artifactId, String version, String buildDirectory,
String buildOutputDirectory, String finalName )
{
this.pomFile = pomFile;
@@ -449,7 +473,7 @@
{
return buildOutputDirectory;
}
-
+
String getFinalName()
{
return finalName;
@@ -460,7 +484,5 @@
return new File( buildDirectory + "/test-build-logs/" + groupId + "_" + artifactId + "_" + version
+ ".build.log" );
}
-
}
-
}
Modified: maven/plugin-testing/trunk/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/RepositoryTool.java
URL: http://svn.apache.org/viewvc/maven/plugin-testing/trunk/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/RepositoryTool.java?rev=677115&r1=677114&r2=677115&view=diff
==============================================================================
--- maven/plugin-testing/trunk/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/RepositoryTool.java (original)
+++ maven/plugin-testing/trunk/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/RepositoryTool.java Tue Jul 15 17:16:13 2008
@@ -1,3 +1,5 @@
+package org.apache.maven.shared.test.plugin;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -16,7 +18,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.maven.shared.test.plugin;
import java.io.File;
import java.io.IOException;
@@ -60,10 +61,12 @@
*
* @plexus.component role="org.apache.maven.shared.test.plugin.RepositoryTool" role-hint="default"
* @author jdcasey
+ * @version $Id$
*/
public class RepositoryTool
implements Contextualizable
{
+ /** Plexus role */
public static final String ROLE = RepositoryTool.class.getName();
/**
@@ -91,6 +94,9 @@
/**
* Lookup and return the location of the normal Maven local repository.
+ *
+ * @return the location of the normal Maven local repository.
+ * @throws TestToolsException if any
*/
public File findLocalRepositoryDirectory()
throws TestToolsException
@@ -108,20 +114,21 @@
{
throw new TestToolsException( "Error building Maven settings.", e );
}
-
+
if ( settings == null || settings.getLocalRepository() == null
|| settings.getLocalRepository().trim().length() < 1 )
{
return new File( System.getProperty( "user.home" ), ".m2/repository" );
}
- else
- {
- return new File( settings.getLocalRepository() );
- }
+
+ return new File( settings.getLocalRepository() );
}
/**
* Construct an ArtifactRepository instance that refers to the normal Maven local repository.
+ *
+ * @return an ArtifactRepository instance
+ * @throws TestToolsException if any
*/
public ArtifactRepository createLocalArtifactRepositoryInstance()
throws TestToolsException
@@ -133,7 +140,10 @@
/**
* Construct an ArtifactRepository instance that refers to the test-time Maven local repository.
+ *
* @param localRepositoryDirectory The location of the local repository to be used for test builds.
+ * @return an ArtifactRepository instance
+ * @throws TestToolsException if any
*/
public ArtifactRepository createLocalArtifactRepositoryInstance( File localRepositoryDirectory )
throws TestToolsException
@@ -157,7 +167,6 @@
{
throw new TestToolsException( "Error converting local repo directory to a URL.", e );
}
-
}
/**
@@ -172,19 +181,20 @@
* </p>
*
* @param project
+ * @param realPomFile
* @param targetLocalRepoBasedir
- * @throws TestToolsException
+ * @throws TestToolsException if any
*/
public void createLocalRepositoryFromComponentProject( MavenProject project, File realPomFile, File targetLocalRepoBasedir )
throws TestToolsException
{
Artifact artifact = project.getArtifact();
-
+
if ( "pom".equals( project.getPackaging() ) )
{
artifact.setFile( project.getFile() );
}
-
+
ArtifactRepository localRepository = createLocalArtifactRepositoryInstance( targetLocalRepoBasedir );
String localPath = localRepository.pathOf( artifact );
@@ -215,6 +225,7 @@
* @param realPomFile The real plugin POM; a starting point, but the POM is already installed,
* so we won't actually install this file, only use it to locate parents.
* @param localRepo The test-time local repository instance
+ * @throws TestToolsException if any
*/
private void installLocallyReachableAncestorPoms( File realPomFile, ArtifactRepository localRepo )
throws TestToolsException
@@ -311,11 +322,12 @@
* Retrieve the PlexusContainer instance used to instantiate this component. The container is
* used to retrieve the default ArtifactRepositoryLayout component, for use in constructing
* instances of ArtifactRepository that can be used to access local repositories.
+ *
+ * @see org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable#contextualize(org.codehaus.plexus.context.Context)
*/
public void contextualize( Context context )
throws ContextException
{
this.container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
}
-
}
Modified: maven/plugin-testing/trunk/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/TestToolsException.java
URL: http://svn.apache.org/viewvc/maven/plugin-testing/trunk/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/TestToolsException.java?rev=677115&r1=677114&r2=677115&view=diff
==============================================================================
--- maven/plugin-testing/trunk/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/TestToolsException.java (original)
+++ maven/plugin-testing/trunk/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/TestToolsException.java Tue Jul 15 17:16:13 2008
@@ -1,3 +1,5 @@
+package org.apache.maven.shared.test.plugin;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -16,22 +18,31 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.maven.shared.test.plugin;
+/**
+ * Wrap errors when Test Tools exception occurred.
+ *
+ * @version $Id$
+ */
public class TestToolsException
extends Exception
{
+ static final long serialVersionUID = -2578830270609952507L;
- private static final long serialVersionUID = 1L;
-
+ /**
+ * @param message given message
+ * @param cause given cause
+ */
public TestToolsException( String message, Throwable cause )
{
super( message, cause );
}
+ /**
+ * @param message a given message
+ */
public TestToolsException( String message )
{
super( message );
}
-
}
Modified: maven/plugin-testing/trunk/maven-plugin-testing-tools/src/test/java/org/apache/maven/shared/test/plugin/ProjectToolTest.java
URL: http://svn.apache.org/viewvc/maven/plugin-testing/trunk/maven-plugin-testing-tools/src/test/java/org/apache/maven/shared/test/plugin/ProjectToolTest.java?rev=677115&r1=677114&r2=677115&view=diff
==============================================================================
--- maven/plugin-testing/trunk/maven-plugin-testing-tools/src/test/java/org/apache/maven/shared/test/plugin/ProjectToolTest.java (original)
+++ maven/plugin-testing/trunk/maven-plugin-testing-tools/src/test/java/org/apache/maven/shared/test/plugin/ProjectToolTest.java Tue Jul 15 17:16:13 2008
@@ -1,3 +1,5 @@
+package org.apache.maven.shared.test.plugin;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -16,7 +18,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.maven.shared.test.plugin;
import java.io.File;
import java.util.Collection;
@@ -30,10 +31,12 @@
import org.codehaus.plexus.PlexusTestCase;
import org.codehaus.plexus.util.StringUtils;
+/**
+ * @version $Id$
+ */
public class ProjectToolTest
extends PlexusTestCase
{
-
public void testManglePomForTesting_ShouldPopulateOutDirAndFinalName()
throws Exception
{
@@ -58,10 +61,10 @@
MavenProject project = tool.packageProjectArtifact( pomFile, "test", true );
String expectedPath = "target/it-build-target/maven-plugin-testing-tools-test.jar";
-
+
// be nice with windows
String actualPath = StringUtils.replace( project.getArtifact().getFile().getPath(), "\\", "/" );
-
+
assertEquals( expectedPath, actualPath );
}
Modified: maven/plugin-testing/trunk/maven-plugin-testing-tools/src/test/java/org/apache/maven/shared/test/plugin/RepositoryToolTest.java
URL: http://svn.apache.org/viewvc/maven/plugin-testing/trunk/maven-plugin-testing-tools/src/test/java/org/apache/maven/shared/test/plugin/RepositoryToolTest.java?rev=677115&r1=677114&r2=677115&view=diff
==============================================================================
--- maven/plugin-testing/trunk/maven-plugin-testing-tools/src/test/java/org/apache/maven/shared/test/plugin/RepositoryToolTest.java (original)
+++ maven/plugin-testing/trunk/maven-plugin-testing-tools/src/test/java/org/apache/maven/shared/test/plugin/RepositoryToolTest.java Tue Jul 15 17:16:13 2008
@@ -1,3 +1,5 @@
+package org.apache.maven.shared.test.plugin;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -16,7 +18,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.maven.shared.test.plugin;
import java.io.File;
@@ -27,10 +28,12 @@
import org.apache.maven.shared.tools.easymock.TestFileManager;
import org.codehaus.plexus.PlexusTestCase;
+/**
+ * @version $Id$
+ */
public class RepositoryToolTest
extends PlexusTestCase
{
-
private TestFileManager fileManager;
public void setUp()
@@ -81,5 +84,4 @@
fileManager.assertFileContents( targetLocalRepoBasedir, "group/artifact/test/artifact-test.jar", jarContent );
}
-
}