Author: bentmann Date: Tue May 5 19:18:41 2009 New Revision: 771971 URL: http://svn.apache.org/viewvc?rev=771971&view=rev Log: o Decoupled POM tests from plugin mananger and repository system (these tests were originally written without merging of default configuration in mind)
Added: maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java (with props) maven/components/branches/MNG-2766/maven-core/src/test/resources/org/apache/maven/project/AbstractMavenProjectTestCase.xml (with props) maven/components/branches/MNG-2766/maven-core/src/test/resources/org/apache/maven/project/PomConstructionTest.xml (with props) maven/components/branches/MNG-2766/maven-core/src/test/resources/org/apache/maven/settings/ (with props) maven/components/branches/MNG-2766/maven-core/src/test/resources/org/apache/maven/settings/PomConstructionWithSettingsTest.xml (with props) Modified: maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/settings/PomConstructionWithSettingsTest.java Modified: maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java?rev=771971&r1=771970&r2=771971&view=diff ============================================================================== --- maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java (original) +++ maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java Tue May 5 19:18:41 2009 @@ -61,6 +61,12 @@ return projectBuilder; } + @Override + protected String getCustomConfigurationName() + { + return AbstractMavenProjectTestCase.class.getName().replace( '.', '/' ) + ".xml"; + } + // ---------------------------------------------------------------------- // Local repository // ---------------------------------------------------------------------- Added: maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java?rev=771971&view=auto ============================================================================== --- maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java (added) +++ maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java Tue May 5 19:18:41 2009 @@ -0,0 +1,81 @@ +package org.apache.maven.project; + +/* + * 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 java.util.Collections; +import java.util.List; +import java.util.Set; + +import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.execution.MavenSession; +import org.apache.maven.lifecycle.LifecycleExecutionException; +import org.apache.maven.lifecycle.LifecycleExecutor; +import org.apache.maven.model.Plugin; +import org.apache.maven.plugin.MojoExecution; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.codehaus.plexus.util.xml.Xpp3Dom; + +/** + * A stub implementation that assumes an empty lifecycle to bypass interaction with the plugin manager and to avoid + * plugin artifact resolution from repositories. + * + * @author Benjamin Bentmann + */ +public class EmptyLifecycleExecutor + implements LifecycleExecutor +{ + + public List<MojoExecution> calculateLifecyclePlan( String lifecyclePhase, MavenSession session ) + throws LifecycleExecutionException + { + return Collections.emptyList(); + } + + public void execute( MavenSession session ) + throws LifecycleExecutionException, MojoFailureException, MojoExecutionException + { + } + + public Xpp3Dom getDefaultPluginConfiguration( String groupId, String artifactId, String version, String goal, + MavenProject project, ArtifactRepository localRepository ) + throws LifecycleExecutionException + { + return null; + } + + public List<String> getLifecyclePhases() + { + return Collections.emptyList(); + } + + public Set<Plugin> getPluginsBoundByDefaultToAllLifecycles( String packaging ) + { + return Collections.emptySet(); + } + + public Set<Plugin> populateDefaultConfigurationForPlugins( Set<Plugin> plugins, MavenProject project, + ArtifactRepository localRepository ) + throws LifecycleExecutionException + { + return plugins; + } + +} Propchange: maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Modified: maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java?rev=771971&r1=771970&r2=771971&view=diff ============================================================================== --- maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java (original) +++ maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java Tue May 5 19:18:41 2009 @@ -1435,13 +1435,6 @@ PomTestWrapper pom = buildPom( "dependency-management-with-interpolation/sub" ); } - public void testMaven() - throws Exception - { - PomTestWrapper pom = buildPom( "maven/sub" ); - System.out.println(pom.getDomainModel().asString()); - } - private void assertPathSuffixEquals( String expected, Object actual ) { String a = actual.toString(); @@ -1454,40 +1447,41 @@ assertEquals( new File( value.toString() ).getPath(), value.toString() ); } - private PomTestWrapper buildPom( String pomPath, Properties properties) - throws Exception - { - File pomFile = new File( testDirectory , pomPath ); - if ( pomFile.isDirectory() ) - { - pomFile = new File( pomFile, "pom.xml" ); - } - ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration(); - config.setLocalRepository(new DefaultArtifactRepository("default", "", new DefaultRepositoryLayout())); - ProfileActivationContext pCtx = new ProfileActivationContext(null, true); - - config.setExecutionProperties(properties); - config.setGlobalProfileManager(new DefaultProfileManager(pCtx)); - return new PomTestWrapper( pomFile, mavenProjectBuilder.build( pomFile, config ) ); - } - private PomTestWrapper buildPom( String pomPath, String... profileIds ) throws Exception { - File pomFile = new File( testDirectory , pomPath ); + return buildPom( pomPath, null, profileIds ); + } + + private PomTestWrapper buildPom( String pomPath, Properties executionProperties, String... profileIds ) + throws Exception + { + File pomFile = new File( testDirectory, pomPath ); if ( pomFile.isDirectory() ) { pomFile = new File( pomFile, "pom.xml" ); } + ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration(); - config.setLocalRepository(new DefaultArtifactRepository("default", "", new DefaultRepositoryLayout())); - ProfileActivationContext pCtx = new ProfileActivationContext(null, true); + + String localRepoUrl = + System.getProperty( "maven.repo.local", System.getProperty( "user.home" ) + "/.m2/repository" ); + localRepoUrl = "file://" + localRepoUrl; + config.setLocalRepository( new DefaultArtifactRepository( "local", localRepoUrl, new DefaultRepositoryLayout() ) ); + + ProfileActivationContext pCtx = new ProfileActivationContext( null, true ); if ( profileIds != null ) { pCtx.setExplicitlyActiveProfileIds( Arrays.asList( profileIds ) ); } - config.setGlobalProfileManager(new DefaultProfileManager(pCtx)); + if ( executionProperties != null ) + { + config.setExecutionProperties( executionProperties ); + } + + config.setGlobalProfileManager( new DefaultProfileManager( pCtx ) ); + return new PomTestWrapper( pomFile, mavenProjectBuilder.build( pomFile, config ) ); } Modified: maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/settings/PomConstructionWithSettingsTest.java URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/settings/PomConstructionWithSettingsTest.java?rev=771971&r1=771970&r2=771971&view=diff ============================================================================== --- maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/settings/PomConstructionWithSettingsTest.java (original) +++ maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/settings/PomConstructionWithSettingsTest.java Tue May 5 19:18:41 2009 @@ -93,9 +93,14 @@ } ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration(); - config.setLocalRepository(new DefaultArtifactRepository("default", "", new DefaultRepositoryLayout())); + + String localRepoUrl = + System.getProperty( "maven.repo.local", System.getProperty( "user.home" ) + "/.m2/repository" ); + localRepoUrl = "file://" + localRepoUrl; + config.setLocalRepository( new DefaultArtifactRepository( "local", localRepoUrl, new DefaultRepositoryLayout() ) ); config.setGlobalProfileManager(profileManager); + return new PomTestWrapper( pomFile, mavenProjectBuilder.build( pomFile, config ) ); } Added: maven/components/branches/MNG-2766/maven-core/src/test/resources/org/apache/maven/project/AbstractMavenProjectTestCase.xml URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/test/resources/org/apache/maven/project/AbstractMavenProjectTestCase.xml?rev=771971&view=auto ============================================================================== --- maven/components/branches/MNG-2766/maven-core/src/test/resources/org/apache/maven/project/AbstractMavenProjectTestCase.xml (added) +++ maven/components/branches/MNG-2766/maven-core/src/test/resources/org/apache/maven/project/AbstractMavenProjectTestCase.xml Tue May 5 19:18:41 2009 @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<plexus> + <components> + <component> + <role>org.apache.maven.lifecycle.LifecycleExecutor</role> + <implementation>org.apache.maven.project.EmptyLifecycleExecutor</implementation> + </component> + </components> +</plexus> Propchange: maven/components/branches/MNG-2766/maven-core/src/test/resources/org/apache/maven/project/AbstractMavenProjectTestCase.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/components/branches/MNG-2766/maven-core/src/test/resources/org/apache/maven/project/AbstractMavenProjectTestCase.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/components/branches/MNG-2766/maven-core/src/test/resources/org/apache/maven/project/PomConstructionTest.xml URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/test/resources/org/apache/maven/project/PomConstructionTest.xml?rev=771971&view=auto ============================================================================== --- maven/components/branches/MNG-2766/maven-core/src/test/resources/org/apache/maven/project/PomConstructionTest.xml (added) +++ maven/components/branches/MNG-2766/maven-core/src/test/resources/org/apache/maven/project/PomConstructionTest.xml Tue May 5 19:18:41 2009 @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<plexus> + <components> + <component> + <role>org.apache.maven.lifecycle.LifecycleExecutor</role> + <implementation>org.apache.maven.project.EmptyLifecycleExecutor</implementation> + </component> + </components> +</plexus> Propchange: maven/components/branches/MNG-2766/maven-core/src/test/resources/org/apache/maven/project/PomConstructionTest.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/components/branches/MNG-2766/maven-core/src/test/resources/org/apache/maven/project/PomConstructionTest.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Propchange: maven/components/branches/MNG-2766/maven-core/src/test/resources/org/apache/maven/settings/ ------------------------------------------------------------------------------ bugtraq:label = Enter issue ID: Propchange: maven/components/branches/MNG-2766/maven-core/src/test/resources/org/apache/maven/settings/ ------------------------------------------------------------------------------ bugtraq:message = Issue id: %BUGID% Propchange: maven/components/branches/MNG-2766/maven-core/src/test/resources/org/apache/maven/settings/ ------------------------------------------------------------------------------ bugtraq:number = false Propchange: maven/components/branches/MNG-2766/maven-core/src/test/resources/org/apache/maven/settings/ ------------------------------------------------------------------------------ bugtraq:url = http://jira.codehaus.org/browse/%BUGID% Added: maven/components/branches/MNG-2766/maven-core/src/test/resources/org/apache/maven/settings/PomConstructionWithSettingsTest.xml URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/test/resources/org/apache/maven/settings/PomConstructionWithSettingsTest.xml?rev=771971&view=auto ============================================================================== --- maven/components/branches/MNG-2766/maven-core/src/test/resources/org/apache/maven/settings/PomConstructionWithSettingsTest.xml (added) +++ maven/components/branches/MNG-2766/maven-core/src/test/resources/org/apache/maven/settings/PomConstructionWithSettingsTest.xml Tue May 5 19:18:41 2009 @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<plexus> + <components> + <component> + <role>org.apache.maven.lifecycle.LifecycleExecutor</role> + <implementation>org.apache.maven.project.EmptyLifecycleExecutor</implementation> + </component> + </components> +</plexus> Propchange: maven/components/branches/MNG-2766/maven-core/src/test/resources/org/apache/maven/settings/PomConstructionWithSettingsTest.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/components/branches/MNG-2766/maven-core/src/test/resources/org/apache/maven/settings/PomConstructionWithSettingsTest.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision