You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jv...@apache.org on 2009/03/28 17:17:30 UTC
svn commit: r759497 - in
/maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven:
AbstractCoreMavenComponentTest.java lifecycle/LifecycleExecutorTest.java
Author: jvanzyl
Date: Sat Mar 28 16:17:30 2009
New Revision: 759497
URL: http://svn.apache.org/viewvc?rev=759497&view=rev
Log:
o adding an abstract base class that i will use to test Maven, LifecycleExecutor, and PluginManager
o everything is going to use the MavenSession and i'll layer the execution requests so each component can be used and tested separately
Added:
maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/AbstractCoreMavenComponentTest.java (with props)
Modified:
maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorTest.java
Added: maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/AbstractCoreMavenComponentTest.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/AbstractCoreMavenComponentTest.java?rev=759497&view=auto
==============================================================================
--- maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/AbstractCoreMavenComponentTest.java (added)
+++ maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/AbstractCoreMavenComponentTest.java Sat Mar 28 16:17:30 2009
@@ -0,0 +1,106 @@
+package org.apache.maven;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.execution.DefaultMavenExecutionRequest;
+import org.apache.maven.execution.MavenExecutionRequest;
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.monitor.event.DefaultEventMonitor;
+import org.apache.maven.plugin.MavenPluginCollector;
+import org.apache.maven.plugin.MavenPluginDiscoverer;
+import org.apache.maven.plugin.MojoExecution;
+import org.apache.maven.plugin.PluginManager;
+import org.apache.maven.plugin.descriptor.MojoDescriptor;
+import org.apache.maven.plugin.descriptor.PluginDescriptor;
+import org.apache.maven.project.DefaultProjectBuilderConfiguration;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.MavenProjectBuilder;
+import org.apache.maven.project.ProjectBuilderConfiguration;
+import org.apache.maven.repository.RepositorySystem;
+import org.codehaus.plexus.ContainerConfiguration;
+import org.codehaus.plexus.PlexusTestCase;
+import org.codehaus.plexus.component.annotations.Requirement;
+import org.codehaus.plexus.logging.console.ConsoleLogger;
+import org.codehaus.plexus.util.FileUtils;
+
+public abstract class AbstractCoreMavenComponentTest
+ extends PlexusTestCase
+{
+ @Requirement
+ protected RepositorySystem repositorySystem;
+
+ @Requirement
+ protected MavenProjectBuilder projectBuilder;
+
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+ repositorySystem = lookup( RepositorySystem.class );
+ projectBuilder = lookup( MavenProjectBuilder.class );
+ }
+
+ abstract protected String getProjectsDirectory();
+
+ protected File getProject( String name )
+ throws Exception
+ {
+ File source = new File( new File( getBasedir(), getProjectsDirectory() ), name );
+ File target = new File( new File ( getBasedir(), "target" ), name );
+ if ( !target.exists() )
+ {
+ FileUtils.copyDirectoryStructure( source, target );
+ }
+ return new File( target, "pom.xml" );
+ }
+
+ /**
+ * We need to customize the standard Plexus container with the plugin discovery listener which
+ * is what looks for the META-INF/maven/plugin.xml resources that enter the system when a
+ * Maven plugin is loaded.
+ *
+ * We also need to customize the Plexus container with a standard plugin discovery listener
+ * which is the MavenPluginCollector. When a Maven plugin is discovered the MavenPluginCollector
+ * collects the plugin descriptors which are found.
+ */
+ protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration )
+ {
+ containerConfiguration.addComponentDiscoverer( new MavenPluginDiscoverer() );
+ containerConfiguration.addComponentDiscoveryListener( new MavenPluginCollector() );
+ }
+
+ // - remove the event monitor, just default or get rid of it
+ // layer the creation of a project builder configuration with a request, but this will need to be
+ // a Maven subclass because we don't want to couple maven to the project builder which we need to
+ // separate.
+ protected MavenSession createMavenSession( File pom )
+ throws Exception
+ {
+ ArtifactRepository localRepository = repositorySystem.createDefaultLocalRepository();
+ ArtifactRepository remoteRepository = repositorySystem.createDefaultRemoteRepository();
+
+ MavenExecutionRequest request = new DefaultMavenExecutionRequest()
+ .setProjectPresent( true )
+ .setPluginGroups( Arrays.asList( new String[] { "org.apache.maven.plugins" } ) )
+ .setLocalRepository( localRepository )
+ .setRemoteRepositories( Arrays.asList( remoteRepository ) )
+ .setGoals( Arrays.asList( new String[] { "package" } ) )
+ // This is wrong
+ .addEventMonitor( new DefaultEventMonitor( new ConsoleLogger( 0, "" ) ) )
+ .setProperties( new Properties() );
+
+ ProjectBuilderConfiguration configuration = new DefaultProjectBuilderConfiguration()
+ .setLocalRepository( localRepository )
+ .setRemoteRepositories( Arrays.asList( remoteRepository ) );
+
+ MavenProject project = projectBuilder.build( pom, configuration );
+
+ MavenSession session = new MavenSession( getContainer(), request, project );
+
+ return session;
+ }
+}
Propchange: maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/AbstractCoreMavenComponentTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/AbstractCoreMavenComponentTest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorTest.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorTest.java?rev=759497&r1=759496&r2=759497&view=diff
==============================================================================
--- maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorTest.java (original)
+++ maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorTest.java Sat Mar 28 16:17:30 2009
@@ -1,32 +1,15 @@
package org.apache.maven.lifecycle;
import java.io.File;
-import java.util.Arrays;
import java.util.List;
-import java.util.Properties;
import org.apache.maven.AbstractCoreMavenComponentTest;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.execution.DefaultMavenExecutionRequest;
-import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.execution.MavenSession;
-import org.apache.maven.monitor.event.DefaultEventMonitor;
-import org.apache.maven.plugin.MavenPluginCollector;
-import org.apache.maven.plugin.MavenPluginDiscoverer;
import org.apache.maven.plugin.MojoExecution;
import org.apache.maven.plugin.PluginManager;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
-import org.apache.maven.project.DefaultProjectBuilderConfiguration;
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.project.MavenProjectBuilder;
-import org.apache.maven.project.ProjectBuilderConfiguration;
-import org.apache.maven.repository.RepositorySystem;
-import org.codehaus.plexus.ContainerConfiguration;
-import org.codehaus.plexus.PlexusTestCase;
import org.codehaus.plexus.component.annotations.Requirement;
-import org.codehaus.plexus.logging.console.ConsoleLogger;
-import org.codehaus.plexus.util.FileUtils;
public class LifecycleExecutorTest
extends AbstractCoreMavenComponentTest
@@ -148,51 +131,5 @@
assertEquals( groupId, pd.getGroupId() );
assertEquals( artifactId, pd.getArtifactId() );
assertEquals( version, pd.getVersion() );
- }
-
- /**
- * We need to customize the standard Plexus container with the plugin discovery listener which
- * is what looks for the META-INF/maven/plugin.xml resources that enter the system when a
- * Maven plugin is loaded.
- *
- * We also need to customize the Plexus container with a standard plugin discovery listener
- * which is the MavenPluginCollector. When a Maven plugin is discovered the MavenPluginCollector
- * collects the plugin descriptors which are found.
- */
- protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration )
- {
- containerConfiguration.addComponentDiscoverer( new MavenPluginDiscoverer() );
- containerConfiguration.addComponentDiscoveryListener( new MavenPluginCollector() );
- }
-
- // - remove the event monitor, just default or get rid of it
- // layer the creation of a project builder configuration with a request, but this will need to be
- // a Maven subclass because we don't want to couple maven to the project builder which we need to
- // separate.
- protected MavenSession createMavenSession( File pom )
- throws Exception
- {
- ArtifactRepository localRepository = repositorySystem.createDefaultLocalRepository();
- ArtifactRepository remoteRepository = repositorySystem.createDefaultRemoteRepository();
-
- MavenExecutionRequest request = new DefaultMavenExecutionRequest()
- .setProjectPresent( true )
- .setPluginGroups( Arrays.asList( new String[] { "org.apache.maven.plugins" } ) )
- .setLocalRepository( localRepository )
- .setRemoteRepositories( Arrays.asList( remoteRepository ) )
- .setGoals( Arrays.asList( new String[] { "package" } ) )
- // This is wrong
- .addEventMonitor( new DefaultEventMonitor( new ConsoleLogger( 0, "" ) ) )
- .setProperties( new Properties() );
-
- ProjectBuilderConfiguration configuration = new DefaultProjectBuilderConfiguration()
- .setLocalRepository( localRepository )
- .setRemoteRepositories( Arrays.asList( remoteRepository ) );
-
- MavenProject project = projectBuilder.build( pom, configuration );
-
- MavenSession session = new MavenSession( getContainer(), request, project );
-
- return session;
- }
+ }
}