Author: jvanzyl Date: Wed Mar 25 15:40:52 2009 New Revision: 758309 URL: http://svn.apache.org/viewvc?rev=758309&view=rev Log: o finished a pattern for the testing of lifecycles, now it's time to create tests for the plugin manager and default maven component
Added: maven/components/branches/MNG-2766/maven-core/src/test/projects/lifecycle-executor/project-with-inheritance/ Removed: maven/components/branches/MNG-2766/maven-core/src/test/repository-projects/ Modified: maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorTest.java 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=758309&r1=758308&r2=758309&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 Wed Mar 25 15:40:52 2009 @@ -41,26 +41,38 @@ @Requirement private DefaultLifecycleExecutor lifecycleExecutor; - - File pom; - File targetPom; protected void setUp() throws Exception { + // Components projectBuilder = lookup( MavenProjectBuilder.class ); repositorySystem = lookup( RepositorySystem.class ); pluginManager = lookup( PluginManager.class ); lifecycleExecutor = (DefaultLifecycleExecutor) lookup( LifecycleExecutor.class ); - targetPom = new File( getBasedir(), "target/lifecycle-executor/pom-plugin.xml" ); + } - if ( !targetPom.exists() ) + protected String getProjectsDirectory() + { + return "src/test/projects/lifecycle-executor"; + } + + 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() ) { - pom = new File( getBasedir(), "src/test/pom.xml" ); - FileUtils.copyFile( pom, targetPom ); + FileUtils.copyDirectoryStructure( source, target ); } + return new File( target, "pom.xml" ); } - + + // ----------------------------------------------------------------------------------------------- + // + // ----------------------------------------------------------------------------------------------- + public void testLifecyclePhases() { assertNotNull( lifecycleExecutor.getLifecyclePhases() ); @@ -73,18 +85,10 @@ public void testLifecycleQueryingUsingADefaultLifecyclePhase() throws Exception { - // This stuff all needs to be reduced, reduced, reduced - String base = "projects/lifecycle-executor/project-with-additional-lifecycle-elements"; - File sourceDirectory = new File( getBasedir(), "src/test/" + base ); - File targetDirectory = new File( getBasedir(), "target/" + base ); - FileUtils.copyDirectoryStructure( sourceDirectory, targetDirectory ); - File targetPom = new File( targetDirectory, "pom.xml" ); - MavenSession session = createMavenSession( targetPom ); + File pom = getProject( "project-with-additional-lifecycle-elements" ); + MavenSession session = createMavenSession( pom ); assertEquals( "project-with-additional-lifecycle-elements", session.getCurrentProject().getArtifactId() ); assertEquals( "1.0-SNAPSHOT", session.getCurrentProject().getVersion() ); - // So this is wrong if we already have the session, which contains a request, which in turn contains - // the goals we are trying to run - List<MojoDescriptor> lifecyclePlan = lifecycleExecutor.calculateLifecyclePlan( "package", session ); // resources:resources @@ -109,12 +113,8 @@ public void testLifecycleExecutionUsingADefaultLifecyclePhase() throws Exception { - String base = "projects/lifecycle-executor/project-with-additional-lifecycle-elements"; - File sourceDirectory = new File( getBasedir(), "src/test/" + base ); - File targetDirectory = new File( getBasedir(), "target/" + base ); - FileUtils.copyDirectoryStructure( sourceDirectory, targetDirectory ); - File targetPom = new File( targetDirectory, "pom.xml" ); - MavenSession session = createMavenSession( targetPom ); + File pom = getProject( "project-with-additional-lifecycle-elements" ); + MavenSession session = createMavenSession( pom ); assertEquals( "project-with-additional-lifecycle-elements", session.getCurrentProject().getArtifactId() ); assertEquals( "1.0-SNAPSHOT", session.getCurrentProject().getVersion() ); lifecycleExecutor.execute( session ); @@ -134,7 +134,7 @@ public void testRemoteResourcesPlugin() throws Exception { - MavenSession session = createMavenSession( targetPom ); + MavenSession session = createMavenSession( getProject( "project-with-inheritance" ) ); String pluginArtifactId = "remote-resources"; String goal = "process"; MojoDescriptor mojoDescriptor = lifecycleExecutor.getMojoDescriptor( pluginArtifactId + ":" + goal, session, session.getCurrentProject() ); @@ -146,7 +146,7 @@ public void testSurefirePlugin() throws Exception { - MavenSession session = createMavenSession( targetPom ); + MavenSession session = createMavenSession( getProject( "project-with-inheritance" ) ); String pluginArtifactId = "surefire"; String goal = "test"; MojoDescriptor mojoDescriptor = lifecycleExecutor.getMojoDescriptor( pluginArtifactId + ":" + goal, session, session.getCurrentProject() );