diff options
Diffstat (limited to 'framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java')
82 files changed, 0 insertions, 12078 deletions
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/AbstractCoreMavenComponentTestCase.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/AbstractCoreMavenComponentTestCase.java deleted file mode 100644 index 57d374fd..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/AbstractCoreMavenComponentTestCase.java +++ /dev/null @@ -1,360 +0,0 @@ -package org.apache.maven; - -/* - * 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.io.File; -import java.util.Arrays; -import java.util.List; -import java.util.Properties; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.InvalidRepositoryException; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.execution.DefaultMavenExecutionRequest; -import org.apache.maven.execution.DefaultMavenExecutionResult; -import org.apache.maven.execution.MavenExecutionRequest; -import org.apache.maven.execution.MavenSession; -import org.apache.maven.model.Build; -import org.apache.maven.model.Dependency; -import org.apache.maven.model.Exclusion; -import org.apache.maven.model.Model; -import org.apache.maven.model.Plugin; -import org.apache.maven.model.Repository; -import org.apache.maven.model.RepositoryPolicy; -import org.apache.maven.project.DefaultProjectBuildingRequest; -import org.apache.maven.project.MavenProject; -import org.apache.maven.project.ProjectBuildingRequest; -import org.apache.maven.repository.RepositorySystem; -import org.apache.maven.repository.internal.MavenRepositorySystemUtils; -import org.codehaus.plexus.ContainerConfiguration; -import org.codehaus.plexus.PlexusConstants; -import org.codehaus.plexus.PlexusTestCase; -import org.codehaus.plexus.component.annotations.Requirement; -import org.codehaus.plexus.util.FileUtils; -import org.eclipse.aether.DefaultRepositorySystemSession; -import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory; -import org.eclipse.aether.repository.LocalRepository; - -public abstract class AbstractCoreMavenComponentTestCase - extends PlexusTestCase -{ - @Requirement - protected RepositorySystem repositorySystem; - - @Requirement - protected org.apache.maven.project.ProjectBuilder projectBuilder; - - protected void setUp() - throws Exception - { - repositorySystem = lookup( RepositorySystem.class ); - projectBuilder = lookup( org.apache.maven.project.ProjectBuilder.class ); - } - - @Override - protected void tearDown() - throws Exception - { - repositorySystem = null; - projectBuilder = null; - super.tearDown(); - } - - 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 ); - FileUtils.copyDirectoryStructureIfModified( 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.setAutoWiring( true ).setClassPathScanning( PlexusConstants.SCANNING_INDEX ); - } - - protected MavenExecutionRequest createMavenExecutionRequest( File pom ) - throws Exception - { - MavenExecutionRequest request = new DefaultMavenExecutionRequest() - .setPom( pom ) - .setProjectPresent( true ) - .setShowErrors( true ) - .setPluginGroups( Arrays.asList( "org.apache.maven.plugins" ) ) - .setLocalRepository( getLocalRepository() ) - .setRemoteRepositories( getRemoteRepositories() ) - .setPluginArtifactRepositories( getPluginArtifactRepositories() ) - .setGoals( Arrays.asList( "package" ) ); - - return request; - } - - // 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 - { - return createMavenSession( pom, new Properties() ); - } - - protected MavenSession createMavenSession( File pom, Properties executionProperties ) - throws Exception - { - MavenExecutionRequest request = createMavenExecutionRequest( pom ); - - ProjectBuildingRequest configuration = new DefaultProjectBuildingRequest() - .setLocalRepository( request.getLocalRepository() ) - .setRemoteRepositories( request.getRemoteRepositories() ) - .setPluginArtifactRepositories( request.getPluginArtifactRepositories() ) - .setSystemProperties( executionProperties ); - - MavenProject project = null; - - if ( pom != null ) - { - project = projectBuilder.build( pom, configuration ).getProject(); - } - else - { - project = createStubMavenProject(); - project.setRemoteArtifactRepositories( request.getRemoteRepositories() ); - project.setPluginArtifactRepositories( request.getPluginArtifactRepositories() ); - } - - initRepoSession( configuration ); - - MavenSession session = - new MavenSession( getContainer(), configuration.getRepositorySession(), request, - new DefaultMavenExecutionResult() ); - session.setProjects( Arrays.asList( project ) ); - - return session; - } - - protected void initRepoSession( ProjectBuildingRequest request ) - throws Exception - { - File localRepoDir = new File( request.getLocalRepository().getBasedir() ); - LocalRepository localRepo = new LocalRepository( localRepoDir ); - DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession(); - session.setLocalRepositoryManager( new SimpleLocalRepositoryManagerFactory().newInstance( session, localRepo ) ); - request.setRepositorySession( session ); - } - - protected MavenProject createStubMavenProject() - { - Model model = new Model(); - model.setGroupId( "org.apache.maven.test" ); - model.setArtifactId( "maven-test" ); - model.setVersion( "1.0" ); - return new MavenProject( model ); - } - - protected List<ArtifactRepository> getRemoteRepositories() - throws InvalidRepositoryException - { - File repoDir = new File( getBasedir(), "src/test/remote-repo" ).getAbsoluteFile(); - - RepositoryPolicy policy = new RepositoryPolicy(); - policy.setEnabled( true ); - policy.setChecksumPolicy( "ignore" ); - policy.setUpdatePolicy( "always" ); - - Repository repository = new Repository(); - repository.setId( RepositorySystem.DEFAULT_REMOTE_REPO_ID ); - repository.setUrl( "file://" + repoDir.toURI().getPath() ); - repository.setReleases( policy ); - repository.setSnapshots( policy ); - - return Arrays.asList( repositorySystem.buildArtifactRepository( repository ) ); - } - - protected List<ArtifactRepository> getPluginArtifactRepositories() - throws InvalidRepositoryException - { - return getRemoteRepositories(); - } - - protected ArtifactRepository getLocalRepository() - throws InvalidRepositoryException - { - File repoDir = new File( getBasedir(), "target/local-repo" ).getAbsoluteFile(); - - return repositorySystem.createLocalRepository( repoDir ); - } - - protected class ProjectBuilder - { - private MavenProject project; - - public ProjectBuilder( MavenProject project ) - { - this.project = project; - } - - public ProjectBuilder( String groupId, String artifactId, String version ) - { - Model model = new Model(); - model.setModelVersion( "4.0.0" ); - model.setGroupId( groupId ); - model.setArtifactId( artifactId ); - model.setVersion( version ); - model.setBuild( new Build() ); - project = new MavenProject( model ); - } - - public ProjectBuilder setGroupId( String groupId ) - { - project.setGroupId( groupId ); - return this; - } - - public ProjectBuilder setArtifactId( String artifactId ) - { - project.setArtifactId( artifactId ); - return this; - } - - public ProjectBuilder setVersion( String version ) - { - project.setVersion( version ); - return this; - } - - // Dependencies - // - public ProjectBuilder addDependency( String groupId, String artifactId, String version, String scope ) - { - return addDependency( groupId, artifactId, version, scope, (Exclusion)null ); - } - - public ProjectBuilder addDependency( String groupId, String artifactId, String version, String scope, Exclusion exclusion ) - { - return addDependency( groupId, artifactId, version, scope, null, exclusion ); - } - - public ProjectBuilder addDependency( String groupId, String artifactId, String version, String scope, String systemPath ) - { - return addDependency( groupId, artifactId, version, scope, systemPath, null ); - } - - public ProjectBuilder addDependency( String groupId, String artifactId, String version, String scope, String systemPath, Exclusion exclusion ) - { - Dependency d = new Dependency(); - d.setGroupId( groupId ); - d.setArtifactId( artifactId ); - d.setVersion( version ); - d.setScope( scope ); - - if ( systemPath != null && scope.equals( Artifact.SCOPE_SYSTEM ) ) - { - d.setSystemPath( systemPath ); - } - - if ( exclusion != null ) - { - d.addExclusion( exclusion ); - } - - project.getDependencies().add( d ); - - return this; - } - - // Plugins - // - public ProjectBuilder addPlugin( Plugin plugin ) - { - project.getBuildPlugins().add( plugin ); - return this; - } - - public MavenProject get() - { - return project; - } - } - - protected class PluginBuilder - { - private Plugin plugin; - - public PluginBuilder( String groupId, String artifactId, String version ) - { - plugin = new Plugin(); - plugin.setGroupId( groupId ); - plugin.setArtifactId( artifactId ); - plugin.setVersion( version ); - } - - // Dependencies - // - public PluginBuilder addDependency( String groupId, String artifactId, String version, String scope, Exclusion exclusion ) - { - return addDependency( groupId, artifactId, version, scope, exclusion ); - } - - public PluginBuilder addDependency( String groupId, String artifactId, String version, String scope, String systemPath ) - { - return addDependency( groupId, artifactId, version, scope, systemPath, null ); - } - - public PluginBuilder addDependency( String groupId, String artifactId, String version, String scope, String systemPath, Exclusion exclusion ) - { - Dependency d = new Dependency(); - d.setGroupId( groupId ); - d.setArtifactId( artifactId ); - d.setVersion( version ); - d.setScope( scope ); - - if ( systemPath != null && scope.equals( Artifact.SCOPE_SYSTEM ) ) - { - d.setSystemPath( systemPath ); - } - - if ( exclusion != null ) - { - d.addExclusion( exclusion ); - } - - plugin.getDependencies().add( d ); - - return this; - } - - public Plugin get() - { - return plugin; - } - } -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/DefaultMavenTest.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/DefaultMavenTest.java deleted file mode 100644 index ab073a63..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/DefaultMavenTest.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.apache.maven; - -import org.apache.maven.execution.MavenExecutionRequest; -import org.apache.maven.execution.MavenExecutionResult; - -import static java.util.Arrays.asList; - -/* - * 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. - */ -public class DefaultMavenTest extends AbstractCoreMavenComponentTestCase{ - - public void testThatErrorDuringProjectDependencyGraphCreationAreStored() - throws Exception - { - Maven maven = getContainer().lookup( Maven.class ); - MavenExecutionRequest request = createMavenExecutionRequest( getProject( "cyclic-reference" ) ).setGoals( asList("validate") ); - - MavenExecutionResult result = maven.execute( request ); - - assertEquals( ProjectCycleException.class, result.getExceptions().get( 0 ).getClass() ); - } - - @Override - protected String getProjectsDirectory() - { - return "src/test/projects/default-maven"; - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/MavenLifecycleParticipantTest.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/MavenLifecycleParticipantTest.java deleted file mode 100644 index 17aeab31..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/MavenLifecycleParticipantTest.java +++ /dev/null @@ -1,173 +0,0 @@ -package org.apache.maven; - -/* - * 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.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.execution.MavenExecutionRequest; -import org.apache.maven.execution.MavenExecutionResult; -import org.apache.maven.execution.MavenSession; -import org.apache.maven.model.Dependency; -import org.apache.maven.project.MavenProject; -import org.codehaus.plexus.PlexusContainer; -import org.codehaus.plexus.component.repository.ComponentDescriptor; - -public class MavenLifecycleParticipantTest - extends AbstractCoreMavenComponentTestCase -{ - - private static final String INJECTED_ARTIFACT_ID = "injected"; - - public static class InjectDependencyLifecycleListener - extends AbstractMavenLifecycleParticipant - { - - @Override - public void afterProjectsRead( MavenSession session ) - { - MavenProject project = session.getProjects().get( 0 ); - - Dependency dependency = new Dependency(); - dependency.setArtifactId( INJECTED_ARTIFACT_ID ); - dependency.setGroupId( "foo" ); - dependency.setVersion( "1.2.3" ); - dependency.setScope( "system" ); - try - { - dependency.setSystemPath( new File( - "src/test/projects/lifecycle-executor/project-with-additional-lifecycle-elements/pom.xml" ).getCanonicalPath() ); - } - catch ( IOException e ) - { - throw new RuntimeException( e ); - } - - project.getModel().addDependency( dependency ); - } - - @Override - public void afterSessionStart( MavenSession session ) - { - session.getUserProperties().setProperty( "injected", "bar" ); - } - - } - - public static class InjectReactorDependency - extends AbstractMavenLifecycleParticipant - { - @Override - public void afterProjectsRead( MavenSession session ) - { - injectReactorDependency( session.getProjects(), "module-a", "module-b" ); - } - - private void injectReactorDependency( List<MavenProject> projects, String moduleFrom, String moduleTo ) - { - for ( MavenProject project : projects ) - { - if ( moduleFrom.equals( project.getArtifactId() ) ) - { - Dependency dependency = new Dependency(); - dependency.setArtifactId( moduleTo ); - dependency.setGroupId( project.getGroupId() ); - dependency.setVersion( project.getVersion() ); - - project.getModel().addDependency( dependency ); - } - } - } - } - - @Override - protected void setupContainer() - { - super.setupContainer(); - } - - @Override - protected String getProjectsDirectory() - { - return "src/test/projects/lifecycle-listener"; - } - - public void testDependencyInjection() - throws Exception - { - PlexusContainer container = getContainer(); - - ComponentDescriptor<? extends AbstractMavenLifecycleParticipant> cd = - new ComponentDescriptor<InjectDependencyLifecycleListener>( InjectDependencyLifecycleListener.class, - container.getContainerRealm() ); - cd.setRoleClass( AbstractMavenLifecycleParticipant.class ); - container.addComponentDescriptor( cd ); - - Maven maven = container.lookup( Maven.class ); - File pom = getProject( "lifecycle-listener-dependency-injection" ); - MavenExecutionRequest request = createMavenExecutionRequest( pom ); - request.setGoals( Arrays.asList( "validate" ) ); - MavenExecutionResult result = maven.execute( request ); - - assertFalse( result.getExceptions().toString(), result.hasExceptions() ); - - MavenProject project = result.getProject(); - - assertEquals( "bar", project.getProperties().getProperty( "foo" ) ); - - ArrayList<Artifact> artifacts = new ArrayList<Artifact>( project.getArtifacts() ); - - assertEquals( 1, artifacts.size() ); - assertEquals( INJECTED_ARTIFACT_ID, artifacts.get( 0 ).getArtifactId() ); - } - - public void testReactorDependencyInjection() - throws Exception - { - List<String> reactorOrder = - getReactorOrder( "lifecycle-participant-reactor-dependency-injection", InjectReactorDependency.class ); - assertEquals( Arrays.asList( "parent", "module-b", "module-a" ), reactorOrder ); - } - - private <T> List<String> getReactorOrder( String testProject, Class<T> participant ) - throws Exception - { - PlexusContainer container = getContainer(); - - ComponentDescriptor<T> cd = new ComponentDescriptor<T>( participant, container.getContainerRealm() ); - cd.setRoleClass( AbstractMavenLifecycleParticipant.class ); - container.addComponentDescriptor( cd ); - - Maven maven = container.lookup( Maven.class ); - File pom = getProject( testProject ); - MavenExecutionRequest request = createMavenExecutionRequest( pom ); - request.setGoals( Arrays.asList( "validate" ) ); - MavenExecutionResult result = maven.execute( request ); - - assertFalse( result.getExceptions().toString(), result.hasExceptions() ); - - List<String> order = new ArrayList<String>(); - for ( MavenProject project : result.getTopologicallySortedProjects() ) - { - order.add( project.getArtifactId() ); - } - return order; - } -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/MavenTest.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/MavenTest.java deleted file mode 100644 index 3e248604..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/MavenTest.java +++ /dev/null @@ -1,69 +0,0 @@ -package org.apache.maven; - -/* - * 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 org.apache.maven.exception.ExceptionHandler; -import org.codehaus.plexus.component.annotations.Requirement; - -public class MavenTest - extends AbstractCoreMavenComponentTestCase -{ - @Requirement - private Maven maven; - - @Requirement - private ExceptionHandler exceptionHandler; - - protected void setUp() - throws Exception - { - super.setUp(); - maven = lookup( Maven.class ); - exceptionHandler = lookup( ExceptionHandler.class ); - } - - @Override - protected void tearDown() - throws Exception - { - maven = null; - exceptionHandler = null; - super.tearDown(); - } - - protected String getProjectsDirectory() - { - return "src/test/projects/lifecycle-executor"; - } - - public void testLifecycleExecutionUsingADefaultLifecyclePhase() - throws Exception - { - /* - File pom = getProject( "project-with-additional-lifecycle-elements" ); - MavenExecutionRequest request = createMavenExecutionRequest( pom ); - MavenExecutionResult result = maven.execute( request ); - if ( result.hasExceptions() ) - { - ExceptionSummary es = exceptionHandler.handleException( result.getExceptions().get( 0 ) ); - System.out.println( es.getMessage() ); - es.getException().printStackTrace(); - fail( "Maven did not execute correctly." ); - } - */ - } -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/ProjectDependenciesResolverTest.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/ProjectDependenciesResolverTest.java deleted file mode 100644 index ca75c3f1..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/ProjectDependenciesResolverTest.java +++ /dev/null @@ -1,114 +0,0 @@ -package org.apache.maven; - -/* - * 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.io.File; -import java.util.Collections; -import java.util.List; -import java.util.Properties; -import java.util.Set; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.execution.MavenSession; -import org.apache.maven.project.MavenProject; -import org.codehaus.plexus.component.annotations.Requirement; - -public class ProjectDependenciesResolverTest - extends AbstractCoreMavenComponentTestCase -{ - @Requirement - private ProjectDependenciesResolver resolver; - - protected void setUp() - throws Exception - { - super.setUp(); - resolver = lookup( ProjectDependenciesResolver.class ); - } - - @Override - protected void tearDown() - throws Exception - { - resolver = null; - super.tearDown(); - } - - protected String getProjectsDirectory() - { - return "src/test/projects/project-dependencies-resolver"; - } - - /* - public void testExclusionsInDependencies() - throws Exception - { - MavenSession session = createMavenSession( null ); - MavenProject project = session.getCurrentProject(); - - Exclusion exclusion = new Exclusion(); - exclusion.setGroupId( "org.apache.maven.its" ); - exclusion.setArtifactId( "a" ); - - new ProjectBuilder( project ).addDependency( "org.apache.maven.its", "b", "0.1", Artifact.SCOPE_RUNTIME, - exclusion ); - - Set<Artifact> artifactDependencies = - resolver.resolve( project, Collections.singleton( Artifact.SCOPE_COMPILE ), session ); - assertEquals( 0, artifactDependencies.size() ); - - artifactDependencies = resolver.resolve( project, Collections.singleton( Artifact.SCOPE_RUNTIME ), session ); - assertEquals( 1, artifactDependencies.size() ); - assertEquals( "b", artifactDependencies.iterator().next().getArtifactId() ); - } - */ - - public void testSystemScopeDependencies() - throws Exception - { - MavenSession session = createMavenSession( null ); - MavenProject project = session.getCurrentProject(); - - new ProjectBuilder( project ) - .addDependency( "com.mycompany", "system-dependency", "1.0", Artifact.SCOPE_SYSTEM, new File( getBasedir(), "pom.xml" ).getAbsolutePath() ); - - Set<Artifact> artifactDependencies = - resolver.resolve( project, Collections.singleton( Artifact.SCOPE_COMPILE ), session ); - assertEquals( 1, artifactDependencies.size() ); - } - - public void testSystemScopeDependencyIsPresentInTheCompileClasspathElements() - throws Exception - { - File pom = getProject( "it0063" ); - - Properties eps = new Properties(); - eps.setProperty( "jre.home", new File( pom.getParentFile(), "jdk/jre" ).getPath() ); - - MavenSession session = createMavenSession( pom, eps ); - MavenProject project = session.getCurrentProject(); - - project.setArtifacts( resolver.resolve( project, Collections.singleton( Artifact.SCOPE_COMPILE ), session ) ); - - List<String> elements = project.getCompileClasspathElements(); - assertEquals( 2, elements.size() ); - - @SuppressWarnings( "deprecation" ) - List<Artifact> artifacts = project.getCompileArtifacts(); - assertEquals( 1, artifacts.size() ); - assertTrue( artifacts.get( 0 ).getFile().getName().endsWith( "tools.jar" ) ); - } -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/artifact/handler/ArtifactHandlerTest.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/artifact/handler/ArtifactHandlerTest.java deleted file mode 100644 index ac02e106..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/artifact/handler/ArtifactHandlerTest.java +++ /dev/null @@ -1,89 +0,0 @@ -package org.apache.maven.artifact.handler; - -/* - * 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.io.File; -import java.util.List; - -import org.codehaus.plexus.PlexusTestCase; -import org.codehaus.plexus.util.FileUtils; - -public class ArtifactHandlerTest - extends PlexusTestCase -{ - public void testAptConsistency() - throws Exception - { - File apt = getTestFile( "src/site/apt/artifact-handlers.apt" ); - - @SuppressWarnings( "unchecked" ) - List<String> lines = FileUtils.loadFile( apt ); - - for ( String line : lines ) - { - if ( line.startsWith( "||" ) ) - { - String[] cols = line.split( "\\|\\|" ); - String[] expected = - new String[] { "", "type", "extension", "packaging", "classifier", "language", "added to classpath", - "includesDependencies", "" }; - - int i = 0; - for ( String col : cols ) - { - assertEquals( "Wrong column header", expected[i++], col.trim() ); - } - } - else if ( line.startsWith( "|" ) ) - { - String[] cols = line.split( "\\|" ); - - String type = trimApt( cols[1] ); - String extension = trimApt( cols[2], type ); - String packaging = trimApt( cols[3], type ); - String classifier = trimApt( cols[4] ); - String language = trimApt( cols[5] ); - String addedToClasspath = trimApt( cols[6] ); - String includesDependencies = trimApt( cols[7] ); - - ArtifactHandler handler = lookup( ArtifactHandler.class, type ); - assertEquals( type + " extension", handler.getExtension(), extension ); - assertEquals( type + " packaging", handler.getPackaging(), packaging ); - assertEquals( type + " classifier", handler.getClassifier(), classifier ); - assertEquals( type + " language", handler.getLanguage(), language ); - assertEquals( type + " addedToClasspath", handler.isAddedToClasspath() ? "true" : null, addedToClasspath ); - assertEquals( type + " includesDependencies", handler.isIncludesDependencies() ? "true" : null, includesDependencies ); - } - } - } - - private String trimApt( String content, String type ) - { - String value = trimApt( content ); - return "= type".equals( value ) ? type : value; - } - - private String trimApt( String content ) - { - content = content.replace( '<', ' ' ).replace( '>', ' ' ).trim(); - - return ( content.length() == 0 ) ? null : content; - } -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/configuration/DefaultBeanConfiguratorTest.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/configuration/DefaultBeanConfiguratorTest.java deleted file mode 100644 index 33673e3b..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/configuration/DefaultBeanConfiguratorTest.java +++ /dev/null @@ -1,148 +0,0 @@ -package org.apache.maven.configuration; - -/* - * 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.io.File; -import java.io.IOException; -import java.io.StringReader; - -import org.codehaus.plexus.PlexusTestCase; -import org.codehaus.plexus.util.xml.Xpp3Dom; -import org.codehaus.plexus.util.xml.Xpp3DomBuilder; -import org.codehaus.plexus.util.xml.pull.XmlPullParserException; - -/** - * @author Benjamin Bentmann - */ -public class DefaultBeanConfiguratorTest - extends PlexusTestCase -{ - - private BeanConfigurator configurator; - - @Override - protected void setUp() - throws Exception - { - super.setUp(); - - configurator = lookup( BeanConfigurator.class ); - } - - @Override - protected void tearDown() - throws Exception - { - configurator = null; - - super.tearDown(); - } - - private Xpp3Dom toConfig( String xml ) - { - try - { - return Xpp3DomBuilder.build( new StringReader( "<configuration>" + xml + "</configuration>" ) ); - } - catch ( XmlPullParserException e ) - { - throw new IllegalArgumentException( e ); - } - catch ( IOException e ) - { - throw new IllegalArgumentException( e ); - } - } - - public void testMinimal() - throws BeanConfigurationException - { - SomeBean bean = new SomeBean(); - - Xpp3Dom config = toConfig( "<file>test</file>" ); - - DefaultBeanConfigurationRequest request = new DefaultBeanConfigurationRequest(); - request.setBean( bean ).setConfiguration( config ); - - configurator.configureBean( request ); - - assertEquals( new File( "test" ), bean.file ); - } - - public void testPreAndPostProcessing() - throws BeanConfigurationException - { - SomeBean bean = new SomeBean(); - - Xpp3Dom config = toConfig( "<file>${test}</file>" ); - - BeanConfigurationValuePreprocessor preprocessor = new BeanConfigurationValuePreprocessor() - { - public Object preprocessValue( String value, Class<?> type ) - throws BeanConfigurationException - { - if ( value != null && value.startsWith( "${" ) && value.endsWith( "}" ) ) - { - return value.substring( 2, value.length() - 1 ); - } - return value; - } - }; - - BeanConfigurationPathTranslator translator = new BeanConfigurationPathTranslator() - { - public File translatePath( File path ) - { - return new File( "base", path.getPath() ).getAbsoluteFile(); - } - }; - - DefaultBeanConfigurationRequest request = new DefaultBeanConfigurationRequest(); - request.setBean( bean ).setConfiguration( config ); - request.setValuePreprocessor( preprocessor ).setPathTranslator( translator ); - - configurator.configureBean( request ); - - assertEquals( new File( "base/test" ).getAbsoluteFile(), bean.file ); - } - - public void testChildConfigurationElement() - throws BeanConfigurationException - { - SomeBean bean = new SomeBean(); - - Xpp3Dom config = toConfig( "<wrapper><file>test</file></wrapper>" ); - - DefaultBeanConfigurationRequest request = new DefaultBeanConfigurationRequest(); - request.setBean( bean ).setConfiguration( config, "wrapper" ); - - configurator.configureBean( request ); - - assertEquals( new File( "test" ), bean.file ); - } - - static class SomeBean - { - - File file; - - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/exception/DefaultExceptionHandlerTest.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/exception/DefaultExceptionHandlerTest.java deleted file mode 100644 index 9727bdf8..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/exception/DefaultExceptionHandlerTest.java +++ /dev/null @@ -1,60 +0,0 @@ -package org.apache.maven.exception; - -/* - * 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.io.IOException; -import java.net.ConnectException; - -import org.apache.maven.plugin.MojoExecutionException; - -import junit.framework.TestCase; - -/** - * @author <a href="mailto:baerrach@apache.org">Barrie Treloar</a> - */ -public class DefaultExceptionHandlerTest - extends TestCase -{ - /** - * Running Maven under JDK7 may cause connection issues because IPv6 is used by default. - * <p> - * e.g running mvn site:run will cause Jetty to fail. - * </p> - * <p> - * The resolution is to add -Djava.net.preferIPv4Stack=true to the command line as documented in - * http://cwiki.apache.org/confluence/display/MAVEN/ConnectException - * </p> - */ - public void testJdk7ipv6() - { - ConnectException connEx = new ConnectException( "Connection refused: connect" ); - IOException ioEx = new IOException( "Unable to establish loopback connection" ); - ioEx.initCause( connEx ); - MojoExecutionException mojoEx = - new MojoExecutionException( "Error executing Jetty: Unable to establish loopback connection", ioEx ); - - ExceptionHandler exceptionHandler = new DefaultExceptionHandler(); - ExceptionSummary exceptionSummary = exceptionHandler.handleException( mojoEx ); - - String expectedReference = "http://cwiki.apache.org/confluence/display/MAVEN/ConnectException"; - assertEquals( expectedReference, exceptionSummary.getReference() ); - - } -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/execution/DefaultMavenExecutionRequestPopulatorTest.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/execution/DefaultMavenExecutionRequestPopulatorTest.java deleted file mode 100644 index 15a7a7b3..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/execution/DefaultMavenExecutionRequestPopulatorTest.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.apache.maven.execution; - -import java.util.List; - -import javax.inject.Inject; - -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.settings.Profile; -import org.apache.maven.settings.Repository; -import org.apache.maven.settings.Settings; -import org.eclipse.sisu.launch.InjectedTestCase; - -/* - * 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. - */ - -public class DefaultMavenExecutionRequestPopulatorTest - extends InjectedTestCase -{ - @Inject - MavenExecutionRequestPopulator testee; - - public void testPluginRepositoryInjection() - throws Exception - { - MavenExecutionRequest request = new DefaultMavenExecutionRequest(); - - Repository r = new Repository(); - r.setId( "test" ); - r.setUrl( "file:///test" ); - - Profile p = new Profile(); - p.setId( "test" ); - p.addPluginRepository( r ); - - Settings settings = new Settings(); - settings.addProfile( p ); - settings.addActiveProfile( p.getId() ); - - testee.populateFromSettings( request, settings ); - - List<ArtifactRepository> repositories = request.getPluginArtifactRepositories(); - assertEquals( 1, repositories.size() ); - assertEquals( r.getId(), repositories.get( 0 ).getId() ); - assertEquals( r.getUrl(), repositories.get( 0 ).getUrl() ); - } -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/execution/DefaultMavenExecutionTest.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/execution/DefaultMavenExecutionTest.java deleted file mode 100644 index fbb8b900..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/execution/DefaultMavenExecutionTest.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.apache.maven.execution; - -/* - * 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 org.apache.maven.project.MavenProject; - -import java.util.List; - -import junit.framework.TestCase; - -/** - * @author Benjamin Bentmann - */ -public class DefaultMavenExecutionTest - extends TestCase -{ - - public void testCopyDefault() - { - MavenExecutionRequest original = new DefaultMavenExecutionRequest(); - MavenExecutionRequest copy = DefaultMavenExecutionRequest.copy( original ); - assertNotNull( copy ); - assertNotSame( copy, original ); - } - - public void testResultWithNullTopologicallySortedProjectsIsEmptyList() - { - MavenExecutionResult result = new DefaultMavenExecutionResult(); - result.setTopologicallySortedProjects( null ); - List<MavenProject> projects = result.getTopologicallySortedProjects(); - assertNotNull( projects ); - assertTrue( projects.isEmpty() ); - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/execution/scope/internal/MojoExecutionScopeTest.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/execution/scope/internal/MojoExecutionScopeTest.java deleted file mode 100644 index a4eb354c..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/execution/scope/internal/MojoExecutionScopeTest.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * 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. - */ -package org.apache.maven.execution.scope.internal; - -import java.util.concurrent.atomic.AtomicInteger; - -import org.apache.maven.execution.MojoExecutionEvent; -import org.apache.maven.execution.scope.WeakMojoExecutionListener; -import org.apache.maven.plugin.MojoExecutionException; - -import junit.framework.TestCase; - -import com.google.inject.Key; -import com.google.inject.Provider; - -public class MojoExecutionScopeTest - extends TestCase -{ - public void testNestedEnter() - throws Exception - { - MojoExecutionScope scope = new MojoExecutionScope(); - - scope.enter(); - - Object o1 = new Object(); - scope.seed( Object.class, o1 ); - assertSame( o1, scope.scope( Key.get( Object.class ), null ).get() ); - - scope.enter(); - Object o2 = new Object(); - scope.seed( Object.class, o2 ); - assertSame( o2, scope.scope( Key.get( Object.class ), null ).get() ); - - scope.exit(); - assertSame( o1, scope.scope( Key.get( Object.class ), null ).get() ); - - scope.exit(); - - try - { - scope.exit(); - fail(); - } - catch ( IllegalStateException expected ) - { - } - } - - public void testMultiKeyInstance() - throws Exception - { - MojoExecutionScope scope = new MojoExecutionScope(); - scope.enter(); - - final AtomicInteger beforeExecution = new AtomicInteger(); - final AtomicInteger afterExecutionSuccess = new AtomicInteger(); - final AtomicInteger afterExecutionFailure = new AtomicInteger(); - final WeakMojoExecutionListener instance = new WeakMojoExecutionListener() - { - @Override - public void beforeMojoExecution( MojoExecutionEvent event ) - throws MojoExecutionException - { - beforeExecution.incrementAndGet(); - } - - @Override - public void afterMojoExecutionSuccess( MojoExecutionEvent event ) - throws MojoExecutionException - { - afterExecutionSuccess.incrementAndGet(); - } - - @Override - public void afterExecutionFailure( MojoExecutionEvent event ) - { - afterExecutionFailure.incrementAndGet(); - } - }; - assertSame( instance, scope.scope( Key.get( Object.class ), new Provider<Object>() - { - @Override - public Object get() - { - return instance; - } - } ).get() ); - assertSame( instance, - scope.scope( Key.get( WeakMojoExecutionListener.class ), new Provider<WeakMojoExecutionListener>() - { - @Override - public WeakMojoExecutionListener get() - { - return instance; - } - } ).get() ); - - final MojoExecutionEvent event = new MojoExecutionEvent( null, null, null, null ); - scope.beforeMojoExecution( event ); - scope.afterMojoExecutionSuccess( event ); - scope.afterExecutionFailure( event ); - - assertEquals( 1, beforeExecution.get() ); - assertEquals( 1, afterExecutionSuccess.get() ); - assertEquals( 1, afterExecutionFailure.get() ); - - scope.exit(); - } -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/graph/DefaultProjectDependencyGraphTest.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/graph/DefaultProjectDependencyGraphTest.java deleted file mode 100644 index e2caaeb1..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/graph/DefaultProjectDependencyGraphTest.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * 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. - */ -package org.apache.maven.graph; - -import junit.framework.TestCase; -import org.apache.maven.execution.ProjectDependencyGraph; -import org.apache.maven.model.Dependency; -import org.apache.maven.project.DuplicateProjectException; -import org.apache.maven.project.MavenProject; -import org.codehaus.plexus.util.dag.CycleDetectedException; - -import java.util.Arrays; -import java.util.List; - -/** - * @author Kristian Rosenvold - */ -public class DefaultProjectDependencyGraphTest - extends TestCase -{ - - private final MavenProject aProject = createA(); - - private final MavenProject depender1 = createProject( Arrays.asList( toDependency( aProject ) ), "depender1" ); - - private final MavenProject depender2 = createProject( Arrays.asList( toDependency( aProject ) ), "depender2" ); - - private final MavenProject depender3 = createProject( Arrays.asList( toDependency( aProject ) ), "depender3" ); - - private final MavenProject depender4 = - createProject( Arrays.asList( toDependency( aProject ), toDependency( depender3 ) ), "depender4" ); - - private final MavenProject transitiveOnly = - createProject( Arrays.asList( toDependency( depender3 ) ), "depender5" ); - - public void testGetSortedProjects() - throws DuplicateProjectException, CycleDetectedException - { - ProjectDependencyGraph graph = new DefaultProjectDependencyGraph( Arrays.asList( depender1, aProject ) ); - final List<MavenProject> sortedProjects = graph.getSortedProjects(); - assertEquals( aProject, sortedProjects.get( 0 ) ); - assertEquals( depender1, sortedProjects.get( 1 ) ); - } - - public void testVerifyExpectedParentStructure() - throws CycleDetectedException, DuplicateProjectException - { - // This test verifies the baseline structure used in susequent tests. If this fails, the rest will fail. - ProjectDependencyGraph graph = threeProjectsDependingOnASingle(); - final List<MavenProject> sortedProjects = graph.getSortedProjects(); - assertEquals( aProject, sortedProjects.get( 0 ) ); - assertEquals( depender1, sortedProjects.get( 1 ) ); - assertEquals( depender2, sortedProjects.get( 2 ) ); - assertEquals( depender3, sortedProjects.get( 3 ) ); - } - - public void testVerifyThatDownsteamProjectsComeInSortedOrder() - throws CycleDetectedException, DuplicateProjectException - { - final List<MavenProject> downstreamProjects = - threeProjectsDependingOnASingle().getDownstreamProjects( aProject, true ); - assertEquals( depender1, downstreamProjects.get( 0 ) ); - assertEquals( depender2, downstreamProjects.get( 1 ) ); - assertEquals( depender3, downstreamProjects.get( 2 ) ); - } - - public void testTransitivesInOrder() - throws CycleDetectedException, DuplicateProjectException - { - final ProjectDependencyGraph graph = - new DefaultProjectDependencyGraph( Arrays.asList( depender1, depender4, depender2, depender3, aProject ) ); - - final List<MavenProject> downstreamProjects = graph.getDownstreamProjects( aProject, true ); - assertEquals( depender1, downstreamProjects.get( 0 ) ); - assertEquals( depender3, downstreamProjects.get( 1 ) ); - assertEquals( depender4, downstreamProjects.get( 2 ) ); - assertEquals( depender2, downstreamProjects.get( 3 ) ); - } - - public void testNonTransitivesInOrder() - throws CycleDetectedException, DuplicateProjectException - { - final ProjectDependencyGraph graph = - new DefaultProjectDependencyGraph( Arrays.asList( depender1, depender4, depender2, depender3, aProject ) ); - - final List<MavenProject> downstreamProjects = graph.getDownstreamProjects( aProject, false ); - assertEquals( depender1, downstreamProjects.get( 0 ) ); - assertEquals( depender3, downstreamProjects.get( 1 ) ); - assertEquals( depender4, downstreamProjects.get( 2 ) ); - assertEquals( depender2, downstreamProjects.get( 3 ) ); - } - - public void testWithTranistiveOnly() - throws CycleDetectedException, DuplicateProjectException - { - final ProjectDependencyGraph graph = new DefaultProjectDependencyGraph( - Arrays.asList( depender1, transitiveOnly, depender2, depender3, aProject ) ); - - final List<MavenProject> downstreamProjects = graph.getDownstreamProjects( aProject, true ); - assertEquals( depender1, downstreamProjects.get( 0 ) ); - assertEquals( depender3, downstreamProjects.get( 1 ) ); - assertEquals( transitiveOnly, downstreamProjects.get( 2 ) ); - assertEquals( depender2, downstreamProjects.get( 3 ) ); - } - - public void testWithMissingTranistiveOnly() - throws CycleDetectedException, DuplicateProjectException - { - final ProjectDependencyGraph graph = new DefaultProjectDependencyGraph( - Arrays.asList( depender1, transitiveOnly, depender2, depender3, aProject ) ); - - final List<MavenProject> downstreamProjects = graph.getDownstreamProjects( aProject, false ); - assertEquals( depender1, downstreamProjects.get( 0 ) ); - assertEquals( depender3, downstreamProjects.get( 1 ) ); - assertEquals( depender2, downstreamProjects.get( 2 ) ); - } - - public void testGetUpstreamProjects() - throws CycleDetectedException, DuplicateProjectException - { - ProjectDependencyGraph graph = threeProjectsDependingOnASingle(); - final List<MavenProject> downstreamProjects = graph.getUpstreamProjects( depender1, true ); - assertEquals( aProject, downstreamProjects.get( 0 ) ); - } - - private ProjectDependencyGraph threeProjectsDependingOnASingle() - throws CycleDetectedException, DuplicateProjectException - { - return new DefaultProjectDependencyGraph( Arrays.asList( depender1, depender2, depender3, aProject ) ); - } - - private static MavenProject createA() - { - MavenProject result = new MavenProject(); - result.setGroupId( "org.apache" ); - result.setArtifactId( "A" ); - result.setVersion( "1.2" ); - return result; - } - - static Dependency toDependency( MavenProject mavenProject ) - { - final Dependency dependency = new Dependency(); - dependency.setArtifactId( mavenProject.getArtifactId() ); - dependency.setGroupId( mavenProject.getGroupId() ); - dependency.setVersion( mavenProject.getVersion() ); - return dependency; - } - - private static MavenProject createProject( List<Dependency> dependencies, String artifactId ) - { - MavenProject result = new MavenProject(); - result.setGroupId( "org.apache" ); - result.setArtifactId( artifactId ); - result.setVersion( "1.2" ); - result.setDependencies( dependencies ); - return result; - } - -}
\ No newline at end of file diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/DefaultLifecyclesTest.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/DefaultLifecyclesTest.java deleted file mode 100644 index 690532c7..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/DefaultLifecyclesTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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. - */ -package org.apache.maven.lifecycle; - -import org.codehaus.plexus.PlexusTestCase; -import org.codehaus.plexus.component.annotations.Requirement; - -import java.util.List; - -/** - * @author Kristian Rosenvold - */ - -public class DefaultLifecyclesTest - extends PlexusTestCase -{ - @Requirement - private DefaultLifecycles defaultLifeCycles; - - - protected void setUp() - throws Exception - { - super.setUp(); - defaultLifeCycles = lookup( DefaultLifecycles.class ); - } - - @Override - protected void tearDown() - throws Exception - { - defaultLifeCycles = null; - super.tearDown(); - } - - public void testLifecycle() - throws Exception - { - final List<Lifecycle> cycles = defaultLifeCycles.getLifeCycles(); - assertNotNull( cycles ); - final Lifecycle lifecycle = cycles.get( 0 ); - assertEquals( "default", lifecycle.getId() ); - assertEquals( 23, lifecycle.getPhases().size() ); - - } - -}
\ No newline at end of file diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/DelegatingMojoExecutionListener.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/DelegatingMojoExecutionListener.java deleted file mode 100644 index 873cc7da..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/DelegatingMojoExecutionListener.java +++ /dev/null @@ -1,75 +0,0 @@ -package org.apache.maven.lifecycle; - -/* - * 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.List; -import java.util.concurrent.CopyOnWriteArrayList; - -import javax.inject.Named; -import javax.inject.Singleton; - -import org.apache.maven.execution.MojoExecutionEvent; -import org.apache.maven.execution.MojoExecutionListener; -import org.apache.maven.plugin.MojoExecutionException; - -@Named -@Singleton -public class DelegatingMojoExecutionListener - implements MojoExecutionListener -{ - private final List<MojoExecutionListener> listeners = new CopyOnWriteArrayList<MojoExecutionListener>(); - - public void beforeMojoExecution( MojoExecutionEvent event ) - throws MojoExecutionException - { - for ( MojoExecutionListener listener : listeners ) - { - listener.beforeMojoExecution( event ); - } - } - - public void afterMojoExecutionSuccess( MojoExecutionEvent event ) - throws MojoExecutionException - { - for ( MojoExecutionListener listener : listeners ) - { - listener.afterMojoExecutionSuccess( event ); - } - } - - public void afterExecutionFailure( MojoExecutionEvent event ) - { - for ( MojoExecutionListener listener : listeners ) - { - listener.afterExecutionFailure( event ); - } - } - - public void addMojoExecutionListener( MojoExecutionListener listener ) - { - this.listeners.add( listener ); - } - - public void removeMojoExecutionListener( MojoExecutionListener listener ) - { - this.listeners.remove( listener ); - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/DelegatingProjectExecutionListener.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/DelegatingProjectExecutionListener.java deleted file mode 100644 index 233ae256..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/DelegatingProjectExecutionListener.java +++ /dev/null @@ -1,82 +0,0 @@ -package org.apache.maven.lifecycle; - -/* - * 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.List; -import java.util.concurrent.CopyOnWriteArrayList; - -import javax.inject.Named; -import javax.inject.Singleton; - -import org.apache.maven.execution.ProjectExecutionEvent; -import org.apache.maven.execution.ProjectExecutionListener; - -@Named -@Singleton -public class DelegatingProjectExecutionListener - implements ProjectExecutionListener -{ - private final List<ProjectExecutionListener> listeners = new CopyOnWriteArrayList<ProjectExecutionListener>(); - - public void beforeProjectExecution( ProjectExecutionEvent event ) - throws LifecycleExecutionException - { - for ( ProjectExecutionListener listener : listeners ) - { - listener.beforeProjectExecution( event ); - } - } - - public void beforeProjectLifecycleExecution( ProjectExecutionEvent event ) - throws LifecycleExecutionException - { - for ( ProjectExecutionListener listener : listeners ) - { - listener.beforeProjectLifecycleExecution( event ); - } - } - - public void afterProjectExecutionSuccess( ProjectExecutionEvent event ) - throws LifecycleExecutionException - { - for ( ProjectExecutionListener listener : listeners ) - { - listener.afterProjectExecutionSuccess( event ); - } - } - - public void afterProjectExecutionFailure( ProjectExecutionEvent event ) - { - for ( ProjectExecutionListener listener : listeners ) - { - listener.afterProjectExecutionFailure( event ); - } - } - - public void addProjectExecutionListener( ProjectExecutionListener listener ) - { - this.listeners.add( listener ); - } - - public void removeProjectExecutionListener( ProjectExecutionListener listener ) - { - this.listeners.remove( listener ); - } -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/EmptyLifecyclePluginAnalyzer.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/EmptyLifecyclePluginAnalyzer.java deleted file mode 100644 index f9bbb2ba..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/EmptyLifecyclePluginAnalyzer.java +++ /dev/null @@ -1,77 +0,0 @@ -package org.apache.maven.lifecycle; - -/* - * 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.LinkedHashSet; -import java.util.Set; - -import org.apache.maven.model.Plugin; -import org.apache.maven.model.PluginExecution; - -/** - * @author Benjamin Bentmann - */ -public class EmptyLifecyclePluginAnalyzer - implements LifeCyclePluginAnalyzer -{ - public Set<Plugin> getPluginsBoundByDefaultToAllLifecycles( String packaging ) - { - Set<Plugin> plugins; - - // NOTE: The upper-case packaging name is intentional, that's a special hinting mode used for certain tests - if ( "JAR".equals( packaging ) ) - { - plugins = new LinkedHashSet<Plugin>(); - - plugins.add( newPlugin( "maven-compiler-plugin", "compile", "testCompile" ) ); - plugins.add( newPlugin( "maven-resources-plugin", "resources", "testResources" ) ); - plugins.add( newPlugin( "maven-surefire-plugin", "test" ) ); - plugins.add( newPlugin( "maven-jar-plugin", "jar" ) ); - plugins.add( newPlugin( "maven-install-plugin", "install" ) ); - plugins.add( newPlugin( "maven-deploy-plugin", "deploy" ) ); - } - else - { - plugins = Collections.emptySet(); - } - - return plugins; - } - - private Plugin newPlugin( String artifactId, String... goals ) - { - Plugin plugin = new Plugin(); - - plugin.setGroupId( "org.apache.maven.plugins" ); - plugin.setArtifactId( artifactId ); - - for ( String goal : goals ) - { - PluginExecution pluginExecution = new PluginExecution(); - pluginExecution.setId( "default-" + goal ); - pluginExecution.addGoal( goal ); - plugin.addExecution( pluginExecution ); - } - - return plugin; - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorSubModulesTest.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorSubModulesTest.java deleted file mode 100644 index 01ebeac0..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorSubModulesTest.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * 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. - */ - - -package org.apache.maven.lifecycle; - -import org.apache.maven.AbstractCoreMavenComponentTestCase; -import org.apache.maven.exception.ExceptionHandler; -import org.apache.maven.lifecycle.internal.LifecycleDependencyResolver; -import org.apache.maven.lifecycle.internal.LifecycleExecutionPlanCalculator; -import org.apache.maven.lifecycle.internal.LifecycleModuleBuilder; -import org.apache.maven.lifecycle.internal.LifecycleTaskSegmentCalculator; -import org.apache.maven.lifecycle.internal.MojoExecutor; -import org.codehaus.plexus.component.annotations.Requirement; - -/** - * Just asserts that it's able to create those components. Handy when plexus gets a nervous breakdown. - * - * @author Kristian Rosenvold - */ - -public class LifecycleExecutorSubModulesTest - extends AbstractCoreMavenComponentTestCase -{ - @Requirement - private DefaultLifecycles defaultLifeCycles; - - @Requirement - private MojoExecutor mojoExecutor; - - @Requirement - private LifecycleModuleBuilder lifeCycleBuilder; - - @Requirement - private LifecycleDependencyResolver lifeCycleDependencyResolver; - - @Requirement - private LifecycleExecutionPlanCalculator lifeCycleExecutionPlanCalculator; - - @Requirement - private LifeCyclePluginAnalyzer lifeCyclePluginAnalyzer; - - @Requirement - private LifecycleTaskSegmentCalculator lifeCycleTaskSegmentCalculator; - - - protected void setUp() - throws Exception - { - super.setUp(); - defaultLifeCycles = lookup( DefaultLifecycles.class ); - mojoExecutor = lookup( MojoExecutor.class ); - lifeCycleBuilder = lookup( LifecycleModuleBuilder.class ); - lifeCycleDependencyResolver = lookup( LifecycleDependencyResolver.class ); - lifeCycleExecutionPlanCalculator = lookup( LifecycleExecutionPlanCalculator.class ); - lifeCyclePluginAnalyzer = lookup( LifeCyclePluginAnalyzer.class ); - lifeCycleTaskSegmentCalculator = lookup( LifecycleTaskSegmentCalculator.class ); - lookup( ExceptionHandler.class ); - } - - @Override - protected void tearDown() - throws Exception - { - defaultLifeCycles = null; - super.tearDown(); - } - - protected String getProjectsDirectory() - { - return "src/test/projects/lifecycle-executor"; - } - - public void testCrweation() - throws Exception - { - assertNotNull( defaultLifeCycles ); - assertNotNull( mojoExecutor ); - assertNotNull( lifeCycleBuilder ); - assertNotNull( lifeCycleDependencyResolver ); - assertNotNull( lifeCycleExecutionPlanCalculator ); - assertNotNull( lifeCyclePluginAnalyzer ); - assertNotNull( lifeCycleTaskSegmentCalculator ); - } - -}
\ No newline at end of file diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorTest.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorTest.java deleted file mode 100644 index 99b07e34..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorTest.java +++ /dev/null @@ -1,553 +0,0 @@ -package org.apache.maven.lifecycle; - -/* - * 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.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import org.apache.maven.AbstractCoreMavenComponentTestCase; -import org.apache.maven.exception.ExceptionHandler; -import org.apache.maven.execution.MavenSession; -import org.apache.maven.execution.MojoExecutionEvent; -import org.apache.maven.execution.MojoExecutionListener; -import org.apache.maven.execution.ProjectDependencyGraph; -import org.apache.maven.execution.ProjectExecutionEvent; -import org.apache.maven.execution.ProjectExecutionListener; -import org.apache.maven.lifecycle.internal.DefaultLifecycleTaskSegmentCalculator; -import org.apache.maven.lifecycle.internal.ExecutionPlanItem; -import org.apache.maven.lifecycle.internal.LifecycleExecutionPlanCalculator; -import org.apache.maven.lifecycle.internal.LifecycleTask; -import org.apache.maven.lifecycle.internal.LifecycleTaskSegmentCalculator; -import org.apache.maven.lifecycle.internal.MojoDescriptorCreator; -import org.apache.maven.lifecycle.internal.TaskSegment; -import org.apache.maven.model.Plugin; -import org.apache.maven.plugin.MojoExecution; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoNotFoundException; -import org.apache.maven.plugin.descriptor.MojoDescriptor; -import org.apache.maven.project.MavenProject; -import org.codehaus.plexus.component.annotations.Requirement; -import org.codehaus.plexus.util.xml.Xpp3Dom; - -public class LifecycleExecutorTest - extends AbstractCoreMavenComponentTestCase -{ - @Requirement - private DefaultLifecycleExecutor lifecycleExecutor; - - @Requirement - private DefaultLifecycleTaskSegmentCalculator lifeCycleTaskSegmentCalculator; - - @Requirement - private LifecycleExecutionPlanCalculator lifeCycleExecutionPlanCalculator; - - @Requirement - private MojoDescriptorCreator mojoDescriptorCreator; - - - protected void setUp() - throws Exception - { - super.setUp(); - lifecycleExecutor = (DefaultLifecycleExecutor) lookup( LifecycleExecutor.class ); - lifeCycleTaskSegmentCalculator = - (DefaultLifecycleTaskSegmentCalculator) lookup( LifecycleTaskSegmentCalculator.class ); - lifeCycleExecutionPlanCalculator = lookup( LifecycleExecutionPlanCalculator.class ); - mojoDescriptorCreator = lookup( MojoDescriptorCreator.class ); - lookup( ExceptionHandler.class ); - } - - @Override - protected void tearDown() - throws Exception - { - lifecycleExecutor = null; - super.tearDown(); - } - - protected String getProjectsDirectory() - { - return "src/test/projects/lifecycle-executor"; - } - - // ----------------------------------------------------------------------------------------------- - // Tests which exercise the lifecycle executor when it is dealing with default lifecycle phases. - // ----------------------------------------------------------------------------------------------- - - public void testCalculationOfBuildPlanWithIndividualTaskWherePluginIsSpecifiedInThePom() - throws Exception - { - // We are doing something like "mvn resources:resources" where no version is specified but this - // project we are working on has the version specified in the POM so the version should come from there. - File pom = getProject( "project-basic" ); - MavenSession session = createMavenSession( pom ); - assertEquals( "project-basic", session.getCurrentProject().getArtifactId() ); - assertEquals( "1.0", session.getCurrentProject().getVersion() ); - List<MojoExecution> executionPlan = getExecutions( calculateExecutionPlan( session, "resources:resources" ) ); - assertEquals( 1, executionPlan.size() ); - MojoExecution mojoExecution = executionPlan.get( 0 ); - assertNotNull( mojoExecution ); - assertEquals( "org.apache.maven.plugins", - mojoExecution.getMojoDescriptor().getPluginDescriptor().getGroupId() ); - assertEquals( "maven-resources-plugin", - mojoExecution.getMojoDescriptor().getPluginDescriptor().getArtifactId() ); - assertEquals( "0.1", mojoExecution.getMojoDescriptor().getPluginDescriptor().getVersion() ); - } - - public void testCalculationOfBuildPlanWithIndividualTaskOfTheCleanLifecycle() - throws Exception - { - // We are doing something like "mvn clean:clean" where no version is specified but this - // project we are working on has the version specified in the POM so the version should come from there. - File pom = getProject( "project-basic" ); - MavenSession session = createMavenSession( pom ); - assertEquals( "project-basic", session.getCurrentProject().getArtifactId() ); - assertEquals( "1.0", session.getCurrentProject().getVersion() ); - List<MojoExecution> executionPlan = getExecutions( calculateExecutionPlan( session, "clean" ) ); - assertEquals( 1, executionPlan.size() ); - MojoExecution mojoExecution = executionPlan.get( 0 ); - assertNotNull( mojoExecution ); - assertEquals( "org.apache.maven.plugins", - mojoExecution.getMojoDescriptor().getPluginDescriptor().getGroupId() ); - assertEquals( "maven-clean-plugin", mojoExecution.getMojoDescriptor().getPluginDescriptor().getArtifactId() ); - assertEquals( "0.1", mojoExecution.getMojoDescriptor().getPluginDescriptor().getVersion() ); - } - - public void testCalculationOfBuildPlanWithIndividualTaskOfTheCleanCleanGoal() - throws Exception - { - // We are doing something like "mvn clean:clean" where no version is specified but this - // project we are working on has the version specified in the POM so the version should come from there. - File pom = getProject( "project-basic" ); - MavenSession session = createMavenSession( pom ); - assertEquals( "project-basic", session.getCurrentProject().getArtifactId() ); - assertEquals( "1.0", session.getCurrentProject().getVersion() ); - List<MojoExecution> executionPlan = getExecutions( calculateExecutionPlan( session, "clean:clean" ) ); - assertEquals( 1, executionPlan.size() ); - MojoExecution mojoExecution = executionPlan.get( 0 ); - assertNotNull( mojoExecution ); - assertEquals( "org.apache.maven.plugins", - mojoExecution.getMojoDescriptor().getPluginDescriptor().getGroupId() ); - assertEquals( "maven-clean-plugin", mojoExecution.getMojoDescriptor().getPluginDescriptor().getArtifactId() ); - assertEquals( "0.1", mojoExecution.getMojoDescriptor().getPluginDescriptor().getVersion() ); - } - - List<MojoExecution> getExecutions( MavenExecutionPlan mavenExecutionPlan ) - { - List<MojoExecution> result = new ArrayList<MojoExecution>(); - for ( ExecutionPlanItem executionPlanItem : mavenExecutionPlan ) - { - result.add( executionPlanItem.getMojoExecution() ); - } - return result; - } - - // We need to take in multiple lifecycles - public void testCalculationOfBuildPlanTasksOfTheCleanLifecycleAndTheInstallLifecycle() - throws Exception - { - File pom = getProject( "project-with-additional-lifecycle-elements" ); - MavenSession session = createMavenSession( pom ); - assertEquals( "project-with-additional-lifecycle-elements", session.getCurrentProject().getArtifactId() ); - assertEquals( "1.0", session.getCurrentProject().getVersion() ); - List<MojoExecution> executionPlan = getExecutions( calculateExecutionPlan( session, "clean", "install" ) ); - - //[01] clean:clean - //[02] resources:resources - //[03] compiler:compile - //[04] it:generate-metadata - //[05] resources:testResources - //[06] compiler:testCompile - //[07] it:generate-test-metadata - //[08] surefire:test - //[09] jar:jar - //[10] install:install - // - assertEquals( 10, executionPlan.size() ); - - assertEquals( "clean:clean", executionPlan.get( 0 ).getMojoDescriptor().getFullGoalName() ); - assertEquals( "resources:resources", executionPlan.get( 1 ).getMojoDescriptor().getFullGoalName() ); - assertEquals( "compiler:compile", executionPlan.get( 2 ).getMojoDescriptor().getFullGoalName() ); - assertEquals( "it:generate-metadata", executionPlan.get( 3 ).getMojoDescriptor().getFullGoalName() ); - assertEquals( "resources:testResources", executionPlan.get( 4 ).getMojoDescriptor().getFullGoalName() ); - assertEquals( "compiler:testCompile", executionPlan.get( 5 ).getMojoDescriptor().getFullGoalName() ); - assertEquals( "it:generate-test-metadata", executionPlan.get( 6 ).getMojoDescriptor().getFullGoalName() ); - assertEquals( "surefire:test", executionPlan.get( 7 ).getMojoDescriptor().getFullGoalName() ); - assertEquals( "jar:jar", executionPlan.get( 8 ).getMojoDescriptor().getFullGoalName() ); - assertEquals( "install:install", executionPlan.get( 9 ).getMojoDescriptor().getFullGoalName() ); - } - - // We need to take in multiple lifecycles - public void testCalculationOfBuildPlanWithMultipleExecutionsOfModello() - throws Exception - { - File pom = getProject( "project-with-multiple-executions" ); - MavenSession session = createMavenSession( pom ); - assertEquals( "project-with-multiple-executions", session.getCurrentProject().getArtifactId() ); - assertEquals( "1.0.1", session.getCurrentProject().getVersion() ); - - MavenExecutionPlan plan = calculateExecutionPlan( session, "clean", "install" ); - - List<MojoExecution> executions = getExecutions( plan ); - - //[01] clean:clean - //[02] modello:xpp3-writer - //[03] modello:java - //[04] modello:xpp3-reader - //[05] modello:xpp3-writer - //[06] modello:java - //[07] modello:xpp3-reader - //[08] plugin:descriptor - //[09] resources:resources - //[10] compiler:compile - //[11] resources:testResources - //[12] compiler:testCompile - //[13] surefire:test - //[14] jar:jar - //[15] plugin:addPluginArtifactMetadata - //[16] install:install - // - - assertEquals( 16, executions.size() ); - - assertEquals( "clean:clean", executions.get( 0 ).getMojoDescriptor().getFullGoalName() ); - assertEquals( "it:xpp3-writer", executions.get( 1 ).getMojoDescriptor().getFullGoalName() ); - assertEquals( "it:java", executions.get( 2 ).getMojoDescriptor().getFullGoalName() ); - assertEquals( "it:xpp3-reader", executions.get( 3 ).getMojoDescriptor().getFullGoalName() ); - assertEquals( "it:xpp3-writer", executions.get( 4 ).getMojoDescriptor().getFullGoalName() ); - assertEquals( "it:java", executions.get( 5 ).getMojoDescriptor().getFullGoalName() ); - assertEquals( "it:xpp3-reader", executions.get( 6 ).getMojoDescriptor().getFullGoalName() ); - assertEquals( "resources:resources", executions.get( 7 ).getMojoDescriptor().getFullGoalName() ); - assertEquals( "compiler:compile", executions.get( 8 ).getMojoDescriptor().getFullGoalName() ); - assertEquals( "plugin:descriptor", executions.get( 9 ).getMojoDescriptor().getFullGoalName() ); - assertEquals( "resources:testResources", executions.get( 10 ).getMojoDescriptor().getFullGoalName() ); - assertEquals( "compiler:testCompile", executions.get( 11 ).getMojoDescriptor().getFullGoalName() ); - assertEquals( "surefire:test", executions.get( 12 ).getMojoDescriptor().getFullGoalName() ); - assertEquals( "jar:jar", executions.get( 13 ).getMojoDescriptor().getFullGoalName() ); - assertEquals( "plugin:addPluginArtifactMetadata", executions.get( 14 ).getMojoDescriptor().getFullGoalName() ); - assertEquals( "install:install", executions.get( 15 ).getMojoDescriptor().getFullGoalName() ); - - assertEquals( "src/main/mdo/remote-resources.mdo", - new MojoExecutionXPathContainer( executions.get( 1 ) ).getValue( - "configuration/models[1]/model" ) ); - assertEquals( "src/main/mdo/supplemental-model.mdo", - new MojoExecutionXPathContainer( executions.get( 4 ) ).getValue( - "configuration/models[1]/model" ) ); - } - - public void testLifecycleQueryingUsingADefaultLifecyclePhase() - throws Exception - { - File pom = getProject( "project-with-additional-lifecycle-elements" ); - MavenSession session = createMavenSession( pom ); - assertEquals( "project-with-additional-lifecycle-elements", session.getCurrentProject().getArtifactId() ); - assertEquals( "1.0", session.getCurrentProject().getVersion() ); - List<MojoExecution> executionPlan = getExecutions( calculateExecutionPlan( session, "package" ) ); - - //[01] resources:resources - //[02] compiler:compile - //[03] it:generate-metadata - //[04] resources:testResources - //[05] compiler:testCompile - //[06] plexus-component-metadata:generate-test-metadata - //[07] surefire:test - //[08] jar:jar - // - assertEquals( 8, executionPlan.size() ); - - assertEquals( "resources:resources", executionPlan.get( 0 ).getMojoDescriptor().getFullGoalName() ); - assertEquals( "compiler:compile", executionPlan.get( 1 ).getMojoDescriptor().getFullGoalName() ); - assertEquals( "it:generate-metadata", executionPlan.get( 2 ).getMojoDescriptor().getFullGoalName() ); - assertEquals( "resources:testResources", executionPlan.get( 3 ).getMojoDescriptor().getFullGoalName() ); - assertEquals( "compiler:testCompile", executionPlan.get( 4 ).getMojoDescriptor().getFullGoalName() ); - assertEquals( "it:generate-test-metadata", executionPlan.get( 5 ).getMojoDescriptor().getFullGoalName() ); - assertEquals( "surefire:test", executionPlan.get( 6 ).getMojoDescriptor().getFullGoalName() ); - assertEquals( "jar:jar", executionPlan.get( 7 ).getMojoDescriptor().getFullGoalName() ); - } - - public void testLifecyclePluginsRetrievalForDefaultLifecycle() - throws Exception - { - List<Plugin> plugins = - new ArrayList<Plugin>( lifecycleExecutor.getPluginsBoundByDefaultToAllLifecycles( "jar" ) ); - - assertEquals( 8, plugins.size() ); - } - - public void testPluginConfigurationCreation() - throws Exception - { - File pom = getProject( "project-with-additional-lifecycle-elements" ); - MavenSession session = createMavenSession( pom ); - MojoDescriptor mojoDescriptor = - mojoDescriptorCreator.getMojoDescriptor( "org.apache.maven.its.plugins:maven-it-plugin:0.1:java", session, - session.getCurrentProject() ); - Xpp3Dom dom = MojoDescriptorCreator.convert( mojoDescriptor ); - System.out.println( dom ); - } - - MavenExecutionPlan calculateExecutionPlan( MavenSession session, String... tasks ) - throws Exception - { - List<TaskSegment> taskSegments = - lifeCycleTaskSegmentCalculator.calculateTaskSegments( session, Arrays.asList( tasks ) ); - - TaskSegment mergedSegment = new TaskSegment( false ); - - for ( TaskSegment taskSegment : taskSegments ) - { - mergedSegment.getTasks().addAll( taskSegment.getTasks() ); - } - - return lifeCycleExecutionPlanCalculator.calculateExecutionPlan( session, session.getCurrentProject(), - mergedSegment.getTasks() ); - } - - public void testInvalidGoalName() - throws Exception - { - File pom = getProject( "project-basic" ); - MavenSession session = createMavenSession( pom ); - try - { - getExecutions( calculateExecutionPlan( session, "resources:" ) ); - fail( "expected a MojoNotFoundException" ); - } - catch ( MojoNotFoundException e ) - { - assertEquals( "", e.getGoal() ); - } - - try - { - getExecutions( calculateExecutionPlan( session, "org.apache.maven.plugins:maven-resources-plugin:0.1:resources:toomany" ) ); - fail( "expected a MojoNotFoundException" ); - } - catch ( MojoNotFoundException e ) - { - assertEquals( "resources:toomany", e.getGoal() ); - } - } - - - public void testPluginPrefixRetrieval() - throws Exception - { - File pom = getProject( "project-basic" ); - MavenSession session = createMavenSession( pom ); - Plugin plugin = mojoDescriptorCreator.findPluginForPrefix( "resources", session ); - assertEquals( "org.apache.maven.plugins", plugin.getGroupId() ); - assertEquals( "maven-resources-plugin", plugin.getArtifactId() ); - } - - // Prefixes - - public void testFindingPluginPrefixforCleanClean() - throws Exception - { - File pom = getProject( "project-basic" ); - MavenSession session = createMavenSession( pom ); - Plugin plugin = mojoDescriptorCreator.findPluginForPrefix( "clean", session ); - assertNotNull( plugin ); - } - - public void testSetupMojoExecution() - throws Exception - { - File pom = getProject( "mojo-configuration" ); - - MavenSession session = createMavenSession( pom ); - - LifecycleTask task = new LifecycleTask( "generate-sources" ); - MavenExecutionPlan executionPlan = - lifeCycleExecutionPlanCalculator.calculateExecutionPlan( session, session.getCurrentProject(), - Arrays.asList( (Object) task ), false ); - - MojoExecution execution = executionPlan.getMojoExecutions().get(0); - assertEquals(execution.toString(), "maven-it-plugin", execution.getArtifactId()); - assertNull(execution.getConfiguration()); - - lifeCycleExecutionPlanCalculator.setupMojoExecution( session, session.getCurrentProject(), execution ); - assertNotNull(execution.getConfiguration()); - assertEquals("1.0", execution.getConfiguration().getChild( "version" ).getAttribute( "default-value" )); - } - - public void testExecutionListeners() - throws Exception - { - final File pom = getProject( "project-basic" ); - final MavenSession session = createMavenSession( pom ); - session.setProjectDependencyGraph( new ProjectDependencyGraph() - { - public List<MavenProject> getUpstreamProjects( MavenProject project, boolean transitive ) - { - return Collections.emptyList(); - } - - public List<MavenProject> getSortedProjects() - { - return Collections.singletonList( session.getCurrentProject() ); - } - - public List<MavenProject> getDownstreamProjects( MavenProject project, boolean transitive ) - { - return Collections.emptyList(); - } - - public java.util.List<MavenProject> getAllSortedProjects() - { - return Collections.emptyList(); - } - } ); - - final List<String> log = new ArrayList<String>(); - - MojoExecutionListener mojoListener = new MojoExecutionListener() - { - public void beforeMojoExecution( MojoExecutionEvent event ) - throws MojoExecutionException - { - assertNotNull( event.getSession() ); - assertNotNull( event.getProject() ); - assertNotNull( event.getExecution() ); - assertNotNull( event.getMojo() ); - assertNull( event.getCause() ); - - log.add( "beforeMojoExecution " + event.getProject().getArtifactId() + ":" - + event.getExecution().getExecutionId() ); - } - - public void afterMojoExecutionSuccess( MojoExecutionEvent event ) - throws MojoExecutionException - { - assertNotNull( event.getSession() ); - assertNotNull( event.getProject() ); - assertNotNull( event.getExecution() ); - assertNotNull( event.getMojo() ); - assertNull( event.getCause() ); - - log.add( "afterMojoExecutionSuccess " + event.getProject().getArtifactId() + ":" - + event.getExecution().getExecutionId() ); - } - - public void afterExecutionFailure( MojoExecutionEvent event ) - { - assertNotNull( event.getSession() ); - assertNotNull( event.getProject() ); - assertNotNull( event.getExecution() ); - assertNotNull( event.getMojo() ); - assertNotNull( event.getCause() ); - - log.add( "afterExecutionFailure " + event.getProject().getArtifactId() + ":" - + event.getExecution().getExecutionId() ); - } - }; - ProjectExecutionListener projectListener = new ProjectExecutionListener() - { - public void beforeProjectExecution( ProjectExecutionEvent event ) - throws LifecycleExecutionException - { - assertNotNull( event.getSession() ); - assertNotNull( event.getProject() ); - assertNull( event.getExecutionPlan() ); - assertNull( event.getCause() ); - - log.add( "beforeProjectExecution " + event.getProject().getArtifactId() ); - } - - public void beforeProjectLifecycleExecution( ProjectExecutionEvent event ) - throws LifecycleExecutionException - { - assertNotNull( event.getSession() ); - assertNotNull( event.getProject() ); - assertNotNull( event.getExecutionPlan() ); - assertNull( event.getCause() ); - - log.add( "beforeProjectLifecycleExecution " + event.getProject().getArtifactId() ); - } - - public void afterProjectExecutionSuccess( ProjectExecutionEvent event ) - throws LifecycleExecutionException - { - assertNotNull( event.getSession() ); - assertNotNull( event.getProject() ); - assertNotNull( event.getExecutionPlan() ); - assertNull( event.getCause() ); - - log.add( "afterProjectExecutionSuccess " + event.getProject().getArtifactId() ); - } - - public void afterProjectExecutionFailure( ProjectExecutionEvent event ) - { - assertNotNull( event.getSession() ); - assertNotNull( event.getProject() ); - assertNull( event.getExecutionPlan() ); - assertNotNull( event.getCause() ); - - log.add( "afterProjectExecutionFailure " + event.getProject().getArtifactId() ); - } - }; - lookup( DelegatingProjectExecutionListener.class ).addProjectExecutionListener( projectListener ); - lookup( DelegatingMojoExecutionListener.class ).addMojoExecutionListener( mojoListener ); - - try - { - lifecycleExecutor.execute( session ); - } - finally - { - lookup( DelegatingProjectExecutionListener.class ).removeProjectExecutionListener( projectListener ); - lookup( DelegatingMojoExecutionListener.class ).removeMojoExecutionListener( mojoListener ); - } - - List<String> expectedLog = Arrays.asList( "beforeProjectExecution project-basic", // - "beforeProjectLifecycleExecution project-basic", // - "beforeMojoExecution project-basic:default-resources", // - "afterMojoExecutionSuccess project-basic:default-resources", // - "beforeMojoExecution project-basic:default-compile", // - "afterMojoExecutionSuccess project-basic:default-compile", // - "beforeMojoExecution project-basic:default-testResources", // - "afterMojoExecutionSuccess project-basic:default-testResources", // - "beforeMojoExecution project-basic:default-testCompile", // - "afterMojoExecutionSuccess project-basic:default-testCompile", // - "beforeMojoExecution project-basic:default-test", // - "afterMojoExecutionSuccess project-basic:default-test", // - "beforeMojoExecution project-basic:default-jar", // - "afterMojoExecutionSuccess project-basic:default-jar", // - "afterProjectExecutionSuccess project-basic" // - ); - - assertEventLog( expectedLog, log ); - } - - private static void assertEventLog( List<String> expectedList, List<String> actualList ) - { - assertEquals( toString( expectedList ), toString( actualList ) ); - } - - private static String toString( List<String> lines ) - { - StringBuilder sb = new StringBuilder(); - for ( String line : lines ) - { - sb.append( line ).append( '\n' ); - } - return sb.toString(); - } -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/MavenExecutionPlanTest.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/MavenExecutionPlanTest.java deleted file mode 100644 index 4901a65d..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/MavenExecutionPlanTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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. - */ - -package org.apache.maven.lifecycle; - -import junit.framework.TestCase; - -import org.apache.maven.lifecycle.internal.ExecutionPlanItem; -import org.apache.maven.lifecycle.internal.stub.DefaultLifecyclesStub; -import org.apache.maven.lifecycle.internal.stub.LifecycleExecutionPlanCalculatorStub; -import org.apache.maven.model.Plugin; - -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -/** - * @author Kristian Rosenvold - */ -public class MavenExecutionPlanTest - extends TestCase -{ - - public void testFindLastInPhase() - throws Exception - { - MavenExecutionPlan plan = LifecycleExecutionPlanCalculatorStub.getProjectAExceutionPlan(); - - ExecutionPlanItem expected = plan.findLastInPhase( "package" ); - ExecutionPlanItem beerPhase = plan.findLastInPhase( "BEER" ); // Beer comes straight after package in stub - assertEquals( expected, beerPhase ); - assertNotNull( expected ); - } - - public void testThreadSafeMojos() - throws Exception - { - MavenExecutionPlan plan = LifecycleExecutionPlanCalculatorStub.getProjectAExceutionPlan(); - final Set<Plugin> unSafePlugins = plan.getNonThreadSafePlugins(); - // There is only a single threadsafe plugin here... - assertEquals( plan.size() - 1, unSafePlugins.size() ); - - } - - - public void testFindLastWhenFirst() - throws Exception - { - MavenExecutionPlan plan = LifecycleExecutionPlanCalculatorStub.getProjectAExceutionPlan(); - - ExecutionPlanItem beerPhase = plan.findLastInPhase( - LifecycleExecutionPlanCalculatorStub.VALIDATE.getPhase() ); // Beer comes straight after package in stub - assertNull( beerPhase ); - } - - public void testFindLastInPhaseMisc() - throws Exception - { - MavenExecutionPlan plan = LifecycleExecutionPlanCalculatorStub.getProjectAExceutionPlan(); - - assertNull( plan.findLastInPhase( "pacXkage" ) ); - // Beer comes straight after package in stub, much like real life. - assertNotNull( plan.findLastInPhase( LifecycleExecutionPlanCalculatorStub.INITIALIZE.getPhase() ) ); - } -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/MojoExecutionXPathContainer.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/MojoExecutionXPathContainer.java deleted file mode 100644 index 6244cc91..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/MojoExecutionXPathContainer.java +++ /dev/null @@ -1,72 +0,0 @@ -package org.apache.maven.lifecycle; - -/* - * 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.io.IOException; -import java.util.Iterator; - -import org.apache.commons.jxpath.JXPathContext; -import org.apache.commons.jxpath.JXPathNotFoundException; -import org.apache.commons.jxpath.ri.JXPathContextReferenceImpl; -import org.apache.maven.plugin.MojoExecution; -import org.apache.maven.project.harness.Xpp3DomPointerFactory; - -public class MojoExecutionXPathContainer -{ - private JXPathContext context; - - static - { - JXPathContextReferenceImpl.addNodePointerFactory( new Xpp3DomPointerFactory() ); - } - - public MojoExecutionXPathContainer( MojoExecution mojoExecution ) - throws IOException - { - context = JXPathContext.newContext( mojoExecution ); - } - - public Iterator<?> getIteratorForXPathExpression( String expression ) - { - return context.iterate( expression ); - } - - public boolean containsXPathExpression( String expression ) - { - return context.getValue( expression ) != null; - } - - public Object getValue( String expression ) - { - try - { - return context.getValue( expression ); - } - catch ( JXPathNotFoundException e ) - { - return null; - } - } - - public boolean xPathExpressionEqualsValue( String expression, String value ) - { - return context.getValue( expression ) != null && context.getValue( expression ).equals( value ); - } -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/BuildListCalculatorTest.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/BuildListCalculatorTest.java deleted file mode 100644 index a0039832..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/BuildListCalculatorTest.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.apache.maven.lifecycle.internal; - -/* - * 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 junit.framework.TestCase; -import org.apache.maven.execution.MavenSession; -import org.apache.maven.lifecycle.internal.stub.LifecycleTaskSegmentCalculatorStub; -import org.apache.maven.lifecycle.internal.stub.ProjectDependencyGraphStub; - -import java.util.List; - -public class BuildListCalculatorTest - extends TestCase -{ - - public void testCalculateProjectBuilds() - throws Exception - { - LifecycleTaskSegmentCalculator lifecycleTaskSegmentCalculator = getTaskSegmentCalculator(); - BuildListCalculator buildListCalculator = new BuildListCalculator(); - final MavenSession session = ProjectDependencyGraphStub.getMavenSession(); - List<TaskSegment> taskSegments = lifecycleTaskSegmentCalculator.calculateTaskSegments( session ); - final ProjectBuildList buildList = buildListCalculator.calculateProjectBuilds( session, taskSegments ); - final ProjectBuildList segments = buildList.getByTaskSegment( taskSegments.get( 0 ) ); - assertEquals( "Stub data contains 3 segments", 3, taskSegments.size() ); - assertEquals( "Stub data contains 6 items", 6, segments.size() ); - final ProjectSegment build = segments.get( 0 ); - assertNotNull( build ); - } - - private static LifecycleTaskSegmentCalculator getTaskSegmentCalculator() - { - return new LifecycleTaskSegmentCalculatorStub(); - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/BuilderCommonTest.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/BuilderCommonTest.java deleted file mode 100644 index 6f896d85..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/BuilderCommonTest.java +++ /dev/null @@ -1,76 +0,0 @@ -package org.apache.maven.lifecycle.internal; - -/* - * 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 junit.framework.TestCase; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.execution.MavenSession; -import org.apache.maven.lifecycle.MavenExecutionPlan; -import org.apache.maven.lifecycle.internal.builder.BuilderCommon; -import org.apache.maven.lifecycle.internal.stub.LifecycleExecutionPlanCalculatorStub; -import org.apache.maven.lifecycle.internal.stub.LoggerStub; -import org.apache.maven.lifecycle.internal.stub.ProjectDependencyGraphStub; - -import java.util.HashSet; - -/** - * @author Kristian Rosenvold - */ -public class BuilderCommonTest - extends TestCase -{ - public void testResolveBuildPlan() - throws Exception - { - MavenSession original = ProjectDependencyGraphStub.getMavenSession(); - - final TaskSegment taskSegment1 = new TaskSegment( false ); - final MavenSession session1 = original.clone(); - session1.setCurrentProject( ProjectDependencyGraphStub.A ); - - final BuilderCommon builderCommon = getBuilderCommon(); - final MavenExecutionPlan plan = - builderCommon.resolveBuildPlan( session1, ProjectDependencyGraphStub.A, taskSegment1, - new HashSet<Artifact>() ); - assertEquals( LifecycleExecutionPlanCalculatorStub.getProjectAExceutionPlan().size(), plan.size() ); - - } - - - public void testHandleBuildError() - throws Exception - { - } - - public void testAttachToThread() - throws Exception - { - } - - public void testGetKey() - throws Exception - { - } - - public static BuilderCommon getBuilderCommon() - { - final LifecycleDebugLogger logger = new LifecycleDebugLogger( new LoggerStub() ); - return new BuilderCommon( logger, new LifecycleExecutionPlanCalculatorStub(), - new LoggerStub() ); - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/ConcurrencyDependencyGraphTest.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/ConcurrencyDependencyGraphTest.java deleted file mode 100644 index 9ab06011..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/ConcurrencyDependencyGraphTest.java +++ /dev/null @@ -1,94 +0,0 @@ -package org.apache.maven.lifecycle.internal; - -/* - * 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 org.apache.maven.execution.MavenSession; -import org.apache.maven.execution.ProjectDependencyGraph; -import org.apache.maven.lifecycle.LifecycleNotFoundException; -import org.apache.maven.lifecycle.LifecyclePhaseNotFoundException; -import org.apache.maven.lifecycle.internal.builder.multithreaded.ConcurrencyDependencyGraph; -import org.apache.maven.lifecycle.internal.stub.ProjectDependencyGraphStub; -import org.apache.maven.plugin.InvalidPluginDescriptorException; -import org.apache.maven.plugin.MojoNotFoundException; -import org.apache.maven.plugin.PluginDescriptorParsingException; -import org.apache.maven.plugin.PluginNotFoundException; -import org.apache.maven.plugin.PluginResolutionException; -import org.apache.maven.plugin.prefix.NoPluginFoundForPrefixException; -import org.apache.maven.plugin.version.PluginVersionResolutionException; -import org.apache.maven.project.MavenProject; - -import java.util.List; - -import static org.apache.maven.lifecycle.internal.stub.ProjectDependencyGraphStub.*; - -/** - * @author Kristian Rosenvold - */ -public class ConcurrencyDependencyGraphTest - extends junit.framework.TestCase -{ - public void testConcurrencyGraphPrimaryVersion() - throws InvalidPluginDescriptorException, PluginVersionResolutionException, PluginDescriptorParsingException, - NoPluginFoundForPrefixException, MojoNotFoundException, PluginNotFoundException, PluginResolutionException, - LifecyclePhaseNotFoundException, LifecycleNotFoundException - { - ProjectDependencyGraph dependencyGraph = new ProjectDependencyGraphStub(); - final MavenSession session = ProjectDependencyGraphStub.getMavenSession(); - - ConcurrencyDependencyGraph graph = - new ConcurrencyDependencyGraph( getProjectBuildList( session ), dependencyGraph ); - - final List<MavenProject> projectBuilds = graph.getRootSchedulableBuilds(); - assertEquals( 1, projectBuilds.size() ); - assertEquals( A, projectBuilds.get( 0 ) ); - - final List<MavenProject> subsequent = graph.markAsFinished( A ); - assertEquals( 2, subsequent.size() ); - assertEquals( ProjectDependencyGraphStub.B, subsequent.get( 0 ) ); - assertEquals( C, subsequent.get( 1 ) ); - - final List<MavenProject> bDescendants = graph.markAsFinished( B ); - assertEquals( 1, bDescendants.size() ); - assertEquals( Y, bDescendants.get( 0 ) ); - - final List<MavenProject> cDescendants = graph.markAsFinished( C ); - assertEquals( 2, cDescendants.size() ); - assertEquals( X, cDescendants.get( 0 ) ); - assertEquals( Z, cDescendants.get( 1 ) ); - } - - public void testConcurrencyGraphDifferentCompletionOrder() - throws InvalidPluginDescriptorException, PluginVersionResolutionException, PluginDescriptorParsingException, - NoPluginFoundForPrefixException, MojoNotFoundException, PluginNotFoundException, PluginResolutionException, - LifecyclePhaseNotFoundException, LifecycleNotFoundException - { - ProjectDependencyGraph dependencyGraph = new ProjectDependencyGraphStub(); - final MavenSession session = ProjectDependencyGraphStub.getMavenSession(); - ConcurrencyDependencyGraph graph = - new ConcurrencyDependencyGraph( getProjectBuildList( session ), dependencyGraph ); - - graph.markAsFinished( A ); - final List<MavenProject> cDescendants = graph.markAsFinished( C ); - assertEquals( 1, cDescendants.size() ); - assertEquals( Z, cDescendants.get( 0 ) ); - - final List<MavenProject> bDescendants = graph.markAsFinished( B ); - assertEquals( 2, bDescendants.size() ); - assertEquals( X, bDescendants.get( 0 ) ); - assertEquals( Y, bDescendants.get( 1 ) ); - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/LifecycleExecutionPlanCalculatorTest.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/LifecycleExecutionPlanCalculatorTest.java deleted file mode 100644 index a9af5668..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/LifecycleExecutionPlanCalculatorTest.java +++ /dev/null @@ -1,82 +0,0 @@ -package org.apache.maven.lifecycle.internal; - -/* - * 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 org.apache.maven.AbstractCoreMavenComponentTestCase; -import org.apache.maven.execution.MavenSession; -import org.apache.maven.lifecycle.MavenExecutionPlan; -import org.apache.maven.lifecycle.internal.stub.BuildPluginManagerStub; -import org.apache.maven.lifecycle.internal.stub.DefaultLifecyclesStub; -import org.apache.maven.lifecycle.internal.stub.PluginPrefixResolverStub; -import org.apache.maven.lifecycle.internal.stub.PluginVersionResolverStub; -import org.apache.maven.lifecycle.internal.stub.ProjectDependencyGraphStub; - -/** - * @author Kristian Rosenvold> - */ -public class LifecycleExecutionPlanCalculatorTest - extends AbstractCoreMavenComponentTestCase -{ - - public void testCalculateExecutionPlanWithGoalTasks() - throws Exception - { - MojoDescriptorCreator mojoDescriptorCreator = createMojoDescriptorCreator(); - LifecycleExecutionPlanCalculator lifecycleExecutionPlanCalculator = - createExecutionPlaceCalculator( mojoDescriptorCreator ); - - final GoalTask goalTask1 = new GoalTask( "compiler:compile" ); - final GoalTask goalTask2 = new GoalTask( "surefire:test" ); - final TaskSegment taskSegment1 = new TaskSegment( false, goalTask1, goalTask2 ); - final MavenSession session1 = ProjectDependencyGraphStub.getMavenSession( ProjectDependencyGraphStub.A ); - - MavenExecutionPlan executionPlan = - lifecycleExecutionPlanCalculator.calculateExecutionPlan( session1, ProjectDependencyGraphStub.A, - taskSegment1.getTasks() ); - assertEquals( 2, executionPlan.size() ); - - final GoalTask goalTask3 = new GoalTask( "surefire:test" ); - final TaskSegment taskSegment2 = new TaskSegment( false, goalTask1, goalTask2, goalTask3 ); - MavenExecutionPlan executionPlan2 = - lifecycleExecutionPlanCalculator.calculateExecutionPlan( session1, ProjectDependencyGraphStub.A, - taskSegment2.getTasks() ); - assertEquals( 3, executionPlan2.size() ); - } - - // Maybe also make one with LifeCycleTasks - - public static LifecycleExecutionPlanCalculator createExecutionPlaceCalculator( MojoDescriptorCreator mojoDescriptorCreator ) - { - LifecyclePluginResolver lifecyclePluginResolver = new LifecyclePluginResolver( new PluginVersionResolverStub() ); - return new DefaultLifecycleExecutionPlanCalculator( new BuildPluginManagerStub(), - DefaultLifecyclesStub.createDefaultLifecycles(), - mojoDescriptorCreator, lifecyclePluginResolver ); - } - - public static MojoDescriptorCreator createMojoDescriptorCreator() - { - return new MojoDescriptorCreator( new PluginVersionResolverStub(), new BuildPluginManagerStub(), - new PluginPrefixResolverStub(), - new LifecyclePluginResolver( new PluginVersionResolverStub() ) ); - } - - @Override - protected String getProjectsDirectory() - { - return "src/test/projects/lifecycle-executor"; - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/LifecycleTaskSegmentCalculatorImplTest.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/LifecycleTaskSegmentCalculatorImplTest.java deleted file mode 100644 index 5db316f8..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/LifecycleTaskSegmentCalculatorImplTest.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.apache.maven.lifecycle.internal; - -/* - * 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 junit.framework.TestCase; -import org.apache.maven.execution.MavenSession; -import org.apache.maven.lifecycle.internal.stub.LifecycleTaskSegmentCalculatorStub; -import org.apache.maven.lifecycle.internal.stub.ProjectDependencyGraphStub; - -import java.util.List; - -/** - * @author Kristian Rosenvold - */ -public class LifecycleTaskSegmentCalculatorImplTest - extends TestCase -{ - public void testCalculateProjectBuilds() - throws Exception - { - LifecycleTaskSegmentCalculator lifecycleTaskSegmentCalculator = getTaskSegmentCalculator(); - BuildListCalculator buildListCalculator = new BuildListCalculator(); - final MavenSession session = ProjectDependencyGraphStub.getMavenSession(); - List<TaskSegment> taskSegments = lifecycleTaskSegmentCalculator.calculateTaskSegments( session ); - - final ProjectBuildList buildList = buildListCalculator.calculateProjectBuilds( session, taskSegments ); - final ProjectBuildList segments = buildList.getByTaskSegment( taskSegments.get( 0 ) ); - assertEquals( "Stub data contains 3 segments", 3, taskSegments.size() ); - assertEquals( "Stub data contains 6 items", 6, segments.size() ); - final ProjectSegment build = segments.get( 0 ); - assertNotNull( build ); - } - - private static LifecycleTaskSegmentCalculator getTaskSegmentCalculator() - { - return new LifecycleTaskSegmentCalculatorStub(); - } - - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/PhaseRecorderTest.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/PhaseRecorderTest.java deleted file mode 100644 index f3d6422c..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/PhaseRecorderTest.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.apache.maven.lifecycle.internal; - -/* - * 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 junit.framework.TestCase; - -import org.apache.maven.lifecycle.MavenExecutionPlan; -import org.apache.maven.lifecycle.internal.stub.LifecycleExecutionPlanCalculatorStub; -import org.apache.maven.lifecycle.internal.stub.ProjectDependencyGraphStub; -import org.apache.maven.plugin.MojoExecution; - -import java.util.List; - -/** - * @author Kristian Rosenvold - */ -public class PhaseRecorderTest extends TestCase -{ - public void testObserveExecution() throws Exception { - PhaseRecorder phaseRecorder = new PhaseRecorder( ProjectDependencyGraphStub.A); - MavenExecutionPlan plan = LifecycleExecutionPlanCalculatorStub.getProjectAExceutionPlan(); - final List<MojoExecution> executions = plan.getMojoExecutions(); - - final MojoExecution mojoExecution1 = executions.get( 0 ); - final MojoExecution mojoExecution2 = executions.get( 1 ); - phaseRecorder.observeExecution( mojoExecution1 ); - - assertTrue( ProjectDependencyGraphStub.A.hasLifecyclePhase( mojoExecution1.getLifecyclePhase() )); - assertFalse( ProjectDependencyGraphStub.A.hasLifecyclePhase( mojoExecution2.getLifecyclePhase() )); - - assertFalse( phaseRecorder.isDifferentPhase( mojoExecution1)); - assertTrue( phaseRecorder.isDifferentPhase( mojoExecution2)); - - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/ProjectBuildListTest.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/ProjectBuildListTest.java deleted file mode 100644 index 047ef9fe..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/ProjectBuildListTest.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.apache.maven.lifecycle.internal; - -/* - * 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 junit.framework.TestCase; -import org.apache.maven.execution.MavenSession; -import org.apache.maven.lifecycle.internal.stub.ProjectDependencyGraphStub; - -/** - * @author Kristian Rosenvold - */ -public class ProjectBuildListTest - extends TestCase -{ - - public void testGetByTaskSegment() - throws Exception - { - final MavenSession session = ProjectDependencyGraphStub.getMavenSession(); - ProjectBuildList projectBuildList = ProjectDependencyGraphStub.getProjectBuildList( session ); - TaskSegment taskSegment = projectBuildList.get( 0 ).getTaskSegment(); - assertTrue( "This test assumes there are at least 6 elements in projectBuilds", projectBuildList.size() >= 6 ); - - final ProjectBuildList byTaskSegment = projectBuildList.getByTaskSegment( taskSegment ); - assertEquals( projectBuildList.size(), - byTaskSegment.size() ); // Todo: Make multiple segments on projectBuildList - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/builder/multithreaded/ThreadOutputMuxerTest.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/builder/multithreaded/ThreadOutputMuxerTest.java deleted file mode 100644 index dc75a947..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/builder/multithreaded/ThreadOutputMuxerTest.java +++ /dev/null @@ -1,167 +0,0 @@ -package org.apache.maven.lifecycle.internal.builder.multithreaded; - -/* - * 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 junit.framework.TestCase; - -import org.apache.maven.execution.MavenSession; -import org.apache.maven.lifecycle.LifecycleNotFoundException; -import org.apache.maven.lifecycle.LifecyclePhaseNotFoundException; -import org.apache.maven.lifecycle.internal.ProjectBuildList; -import org.apache.maven.lifecycle.internal.ProjectSegment; -import org.apache.maven.lifecycle.internal.builder.multithreaded.ThreadOutputMuxer; -import org.apache.maven.lifecycle.internal.stub.ProjectDependencyGraphStub; -import org.apache.maven.plugin.InvalidPluginDescriptorException; -import org.apache.maven.plugin.MojoNotFoundException; -import org.apache.maven.plugin.PluginDescriptorParsingException; -import org.apache.maven.plugin.PluginNotFoundException; -import org.apache.maven.plugin.PluginResolutionException; -import org.apache.maven.plugin.prefix.NoPluginFoundForPrefixException; -import org.apache.maven.plugin.version.PluginVersionResolutionException; - -import java.io.ByteArrayOutputStream; -import java.io.PrintStream; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; -import java.util.concurrent.Callable; -import java.util.concurrent.CompletionService; -import java.util.concurrent.ExecutorCompletionService; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; - -/** - * @author Kristian Rosenvold - */ -public class ThreadOutputMuxerTest - extends TestCase -{ - - final String paid = "Paid"; - - final String in = "In"; - - final String full = "Full"; - - public void testSingleThreaded() - throws Exception - { - ProjectBuildList src = getProjectBuildList(); - ProjectBuildList projectBuildList = - new ProjectBuildList( Arrays.asList( src.get( 0 ), src.get( 1 ), src.get( 2 ) ) ); - - ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); - PrintStream systemOut = new PrintStream( byteArrayOutputStream ); - ThreadOutputMuxer threadOutputMuxer = new ThreadOutputMuxer( projectBuildList, systemOut ); - - threadOutputMuxer.associateThreadWithProjectSegment( projectBuildList.get( 0 ) ); - System.out.print( paid ); // No, this does not print to system.out. It's part of the test - assertEquals( paid.length(), byteArrayOutputStream.size() ); - threadOutputMuxer.associateThreadWithProjectSegment( projectBuildList.get( 1 ) ); - System.out.print( in ); // No, this does not print to system.out. It's part of the test - assertEquals( paid.length(), byteArrayOutputStream.size() ); - threadOutputMuxer.associateThreadWithProjectSegment( projectBuildList.get( 2 ) ); - System.out.print( full ); // No, this does not print to system.out. It's part of the test - assertEquals( paid.length(), byteArrayOutputStream.size() ); - - threadOutputMuxer.setThisModuleComplete( projectBuildList.get( 0 ) ); - threadOutputMuxer.setThisModuleComplete( projectBuildList.get( 1 ) ); - threadOutputMuxer.setThisModuleComplete( projectBuildList.get( 2 ) ); - threadOutputMuxer.close(); - assertEquals( ( paid + in + full ).length(), byteArrayOutputStream.size() ); - } - - public void testMultiThreaded() - throws Exception - { - ProjectBuildList projectBuildList = getProjectBuildList(); - - ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); - PrintStream systemOut = new PrintStream( byteArrayOutputStream ); - final ThreadOutputMuxer threadOutputMuxer = new ThreadOutputMuxer( projectBuildList, systemOut ); - - final List<String> stringList = - Arrays.asList( "Thinkin", "of", "a", "master", "plan", "Cuz", "ain’t", "nuthin", "but", "sweat", "inside", - "my", "hand" ); - Iterator<String> lyrics = stringList.iterator(); - - ExecutorService executor = Executors.newFixedThreadPool( 10 ); - CompletionService<ProjectSegment> service = new ExecutorCompletionService<ProjectSegment>( executor ); - - List<Future<ProjectSegment>> futures = new ArrayList<Future<ProjectSegment>>(); - for ( ProjectSegment projectBuild : projectBuildList ) - { - final Future<ProjectSegment> buildFuture = - service.submit( new Outputter( threadOutputMuxer, projectBuild, lyrics.next() ) ); - futures.add( buildFuture ); - } - - for ( Future<ProjectSegment> future : futures ) - { - future.get(); - } - int expectedLength = 0; - for ( int i = 0; i < projectBuildList.size(); i++ ) - { - expectedLength += stringList.get( i ).length(); - } - - threadOutputMuxer.close(); - final byte[] bytes = byteArrayOutputStream.toByteArray(); - String result = new String( bytes ); - assertEquals( result, expectedLength, bytes.length ); - - - } - - class Outputter - implements Callable<ProjectSegment> - { - private final ThreadOutputMuxer threadOutputMuxer; - - private final ProjectSegment item; - - private final String response; - - Outputter( ThreadOutputMuxer threadOutputMuxer, ProjectSegment item, String response ) - { - this.threadOutputMuxer = threadOutputMuxer; - this.item = item; - this.response = response; - } - - public ProjectSegment call() - throws Exception - { - threadOutputMuxer.associateThreadWithProjectSegment( item ); - System.out.print( response ); - threadOutputMuxer.setThisModuleComplete( item ); - return item; - } - } - - - private ProjectBuildList getProjectBuildList() - throws InvalidPluginDescriptorException, PluginVersionResolutionException, PluginDescriptorParsingException, - NoPluginFoundForPrefixException, MojoNotFoundException, PluginNotFoundException, PluginResolutionException, - LifecyclePhaseNotFoundException, LifecycleNotFoundException - { - final MavenSession session = ProjectDependencyGraphStub.getMavenSession(); - return ProjectDependencyGraphStub.getProjectBuildList( session ); - } -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/AboutTheStubs.html b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/AboutTheStubs.html deleted file mode 100644 index 8ad74b96..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/AboutTheStubs.html +++ /dev/null @@ -1,55 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" - "http://www.w3.org/TR/html4/loose.dtd"> -<!-- -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. ---> - -<html> -<head> - <title>About these stubs</title> -</head> -<body> -<h2>Design</h2> -These stubs can be thought of as hand-coded mock obects. They allow unit tests to test only specific -aspects of a component while ignoring others. - -These stubs form an internally consistent data-set that is not expected to change. They are -used to test the individual components in the lifecycle with data that has expected characteristics -and can be asserted as desired. - -You can change/extend these stubs, and tests should not be breaking too much, since most tests -assert using expected values from the stubs. Normally, when you try to use data from the stubs that -have not been properly populated, you'll get a nullpointer in your test and you then have to -identify which stub creates that specific piece of data. - -The most important stubs are: -LifecycleExecutionPlanCalculatorStub -ProjectDependencyGraphStub - -Since they define the primary structure of the project/build. - -The stubs define three top-level targets that are defined in LifecycleTaskSegmentCalculatorStub; -clean, aggr and install. "aggr" is an aggregating task while clean and install are lifecyclephases. -There will be three items in the task list for this dataset. - -The stubs also exist at different "levels", where one test might wire stubs into a specific live implementation. -In the next test that same "live implementation" will be used in a stub version instead. - -Not all live services have stubs, but can be added as needed. -</body> -</html>
\ No newline at end of file diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/BuildPluginManagerStub.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/BuildPluginManagerStub.java deleted file mode 100644 index 133bcb3a..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/BuildPluginManagerStub.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.apache.maven.lifecycle.internal.stub; - -/* - * 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.List; - -import org.apache.maven.execution.MavenSession; -import org.apache.maven.model.Plugin; -import org.apache.maven.plugin.BuildPluginManager; -import org.apache.maven.plugin.MojoExecution; -import org.apache.maven.plugin.descriptor.MojoDescriptor; -import org.apache.maven.plugin.descriptor.PluginDescriptor; -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.eclipse.aether.RepositorySystemSession; -import org.eclipse.aether.repository.RemoteRepository; - -/** - * @author Kristian Rosenvold - */ -public class BuildPluginManagerStub - implements BuildPluginManager -{ - - public PluginDescriptor loadPlugin( Plugin plugin, List<RemoteRepository> repositories, RepositorySystemSession session ) - { - return null; - } - - public MojoDescriptor getMojoDescriptor( Plugin plugin, String goal, List<RemoteRepository> repositories, - RepositorySystemSession session ) - { - return MojoExecutorStub.createMojoDescriptor( plugin.getKey() ); - } - - public ClassRealm getPluginRealm( MavenSession session, PluginDescriptor pluginDescriptor ) - { - return null; - } - - public void executeMojo( MavenSession session, MojoExecution execution ) - { - } -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/CompletionServiceStub.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/CompletionServiceStub.java deleted file mode 100644 index 10a113e9..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/CompletionServiceStub.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * 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. - */ - -package org.apache.maven.lifecycle.internal.stub; - -import org.apache.maven.lifecycle.internal.ProjectSegment; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.concurrent.Callable; -import java.util.concurrent.CompletionService; -import java.util.concurrent.Future; -import java.util.concurrent.FutureTask; -import java.util.concurrent.TimeUnit; - -/** - * @author Kristian Rosenvold - */ -public class CompletionServiceStub - implements CompletionService<ProjectSegment> -{ - List<FutureTask<ProjectSegment>> projectBuildFutureTasks = - Collections.synchronizedList( new ArrayList<FutureTask<ProjectSegment>>() ); - - final boolean finishImmediately; - - - public int size() - { - return projectBuildFutureTasks.size(); - } - - public CompletionServiceStub( boolean finishImmediately ) - { - this.finishImmediately = finishImmediately; - } - - public Future<ProjectSegment> submit( Callable<ProjectSegment> task ) - { - FutureTask<ProjectSegment> projectBuildFutureTask = new FutureTask<ProjectSegment>( task ); - projectBuildFutureTasks.add( projectBuildFutureTask ); - if ( finishImmediately ) - { - projectBuildFutureTask.run(); - } - return projectBuildFutureTask; - } - - public Future<ProjectSegment> submit( Runnable task, ProjectSegment result ) - { - FutureTask<ProjectSegment> projectBuildFutureTask = new FutureTask<ProjectSegment>( task, result ); - projectBuildFutureTasks.add( projectBuildFutureTask ); - if ( finishImmediately ) - { - projectBuildFutureTask.run(); - } - return projectBuildFutureTask; - } - - public Future<ProjectSegment> take() - throws InterruptedException - { - return null; - } - - public Future<ProjectSegment> poll() - { - return null; - } - - public Future<ProjectSegment> poll( long timeout, TimeUnit unit ) - throws InterruptedException - { - return null; - } -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/DefaultLifecyclesStub.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/DefaultLifecyclesStub.java deleted file mode 100644 index b366953a..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/DefaultLifecyclesStub.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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. - */ - -package org.apache.maven.lifecycle.internal.stub; - -import org.apache.maven.lifecycle.DefaultLifecycles; -import org.apache.maven.lifecycle.Lifecycle; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import static org.apache.maven.lifecycle.internal.stub.LifecycleExecutionPlanCalculatorStub.*; - -/** - * @author Kristian Rosenvold - */ - -public class DefaultLifecyclesStub -{ - public static DefaultLifecycles createDefaultLifecycles() - { - - List<String> stubDefaultCycle = - Arrays.asList( VALIDATE.getPhase(), INITIALIZE.getPhase(), PROCESS_RESOURCES.getPhase(), COMPILE.getPhase(), - TEST.getPhase(), PROCESS_TEST_RESOURCES.getPhase(), PACKAGE.getPhase(), "BEER", - INSTALL.getPhase() ); - - // The two phases below are really for future expansion, some would say they lack a drink - // The point being that they do not really have to match the "real" stuff, - List<String> stubCleanCycle = Arrays.asList( PRE_CLEAN.getPhase(), CLEAN.getPhase(), POST_CLEAN.getPhase() ); - - List<String> stubSiteCycle = - Arrays.asList( PRE_SITE.getPhase(), SITE.getPhase(), POST_SITE.getPhase(), SITE_DEPLOY.getPhase() ); - - @SuppressWarnings( "unchecked" ) - Iterator<List<String>> lcs = Arrays.asList( stubDefaultCycle, stubCleanCycle, stubSiteCycle ).iterator(); - - Map<String, Lifecycle> lifeCycles = new HashMap<String, Lifecycle>(); - for ( String s : DefaultLifecycles.STANDARD_LIFECYCLES ) - { - final Lifecycle lifecycle = new Lifecycle( s, lcs.next(), null ); - lifeCycles.put( s, lifecycle ); - - } - return new DefaultLifecycles( lifeCycles, new LoggerStub() ); - } - -}
\ No newline at end of file diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/ExecutionEventCatapultStub.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/ExecutionEventCatapultStub.java deleted file mode 100644 index e47ec611..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/ExecutionEventCatapultStub.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.apache.maven.lifecycle.internal.stub; - -/* - * 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 org.apache.maven.execution.MavenSession; -import org.apache.maven.execution.ExecutionEvent.Type; -import org.apache.maven.lifecycle.internal.ExecutionEventCatapult; -import org.apache.maven.plugin.MojoExecution; - -/** - * @author Benjamin Bentmann - */ -public class ExecutionEventCatapultStub - implements ExecutionEventCatapult -{ - - public void fire( Type eventType, MavenSession session, MojoExecution mojoExecution ) - { - } - - public void fire( Type eventType, MavenSession session, MojoExecution mojoExecution, Exception exception ) - { - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/LifeCyclePluginAnalyzerStub.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/LifeCyclePluginAnalyzerStub.java deleted file mode 100644 index 930f5e93..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/LifeCyclePluginAnalyzerStub.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * 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. - */ - -package org.apache.maven.lifecycle.internal.stub; - -import org.apache.maven.lifecycle.LifeCyclePluginAnalyzer; -import org.apache.maven.model.Plugin; -import org.apache.maven.model.PluginExecution; - -import java.util.Collections; -import java.util.LinkedHashSet; -import java.util.Set; - -/** - * @author Kristian Rosenvold - */ -public class LifeCyclePluginAnalyzerStub - implements LifeCyclePluginAnalyzer -{ - public Set<Plugin> getPluginsBoundByDefaultToAllLifecycles( String packaging ) - { - Set<Plugin> plugins; - - // NOTE: The upper-case packaging name is intentional, that's a special hinting mode used for certain tests - if ( "JAR".equals( packaging ) ) - { - plugins = new LinkedHashSet<Plugin>(); - - plugins.add( newPlugin( "maven-compiler-plugin", "compile", "testCompile" ) ); - plugins.add( newPlugin( "maven-resources-plugin", "resources", "testResources" ) ); - plugins.add( newPlugin( "maven-surefire-plugin", "test" ) ); - plugins.add( newPlugin( "maven-jar-plugin", "jar" ) ); - plugins.add( newPlugin( "maven-install-plugin", "install" ) ); - plugins.add( newPlugin( "maven-deploy-plugin", "deploy" ) ); - } - else - { - plugins = Collections.emptySet(); - } - - return plugins; - } - - private Plugin newPlugin( String artifactId, String... goals ) - { - Plugin plugin = new Plugin(); - - plugin.setGroupId( "org.apache.maven.plugins" ); - plugin.setArtifactId( artifactId ); - - for ( String goal : goals ) - { - PluginExecution pluginExecution = new PluginExecution(); - pluginExecution.setId( "default-" + goal ); - pluginExecution.addGoal( goal ); - plugin.addExecution( pluginExecution ); - } - - return plugin; - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/LifecycleExecutionPlanCalculatorStub.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/LifecycleExecutionPlanCalculatorStub.java deleted file mode 100644 index cd33a353..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/LifecycleExecutionPlanCalculatorStub.java +++ /dev/null @@ -1,231 +0,0 @@ -/* - * 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. - */ - -package org.apache.maven.lifecycle.internal.stub; - -import org.apache.maven.execution.MavenSession; -import org.apache.maven.lifecycle.LifecycleNotFoundException; -import org.apache.maven.lifecycle.LifecyclePhaseNotFoundException; -import org.apache.maven.lifecycle.MavenExecutionPlan; -import org.apache.maven.lifecycle.internal.ExecutionPlanItem; -import org.apache.maven.lifecycle.internal.LifecycleExecutionPlanCalculator; -import org.apache.maven.lifecycle.internal.ProjectBuildList; -import org.apache.maven.lifecycle.internal.ProjectSegment; -import org.apache.maven.model.Plugin; -import org.apache.maven.plugin.InvalidPluginDescriptorException; -import org.apache.maven.plugin.MojoExecution; -import org.apache.maven.plugin.MojoNotFoundException; -import org.apache.maven.plugin.PluginDescriptorParsingException; -import org.apache.maven.plugin.PluginNotFoundException; -import org.apache.maven.plugin.PluginResolutionException; -import org.apache.maven.plugin.descriptor.MojoDescriptor; -import org.apache.maven.plugin.descriptor.PluginDescriptor; -import org.apache.maven.plugin.prefix.NoPluginFoundForPrefixException; -import org.apache.maven.plugin.version.PluginVersionResolutionException; -import org.apache.maven.project.MavenProject; -import org.codehaus.plexus.util.xml.Xpp3Dom; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -/** - * @author Kristian Rosenvold - */ -public class LifecycleExecutionPlanCalculatorStub - implements LifecycleExecutionPlanCalculator -{ - // clean - - public final static MojoDescriptor PRE_CLEAN = createMojoDescriptor( "pre-clean" ); - - public final static MojoDescriptor CLEAN = createMojoDescriptor( "clean" ); - - public final static MojoDescriptor POST_CLEAN = createMojoDescriptor( "post-clean" ); - - // default (or at least some of them) - - public final static MojoDescriptor VALIDATE = createMojoDescriptor( "validate" ); - - public final static MojoDescriptor INITIALIZE = createMojoDescriptor( "initialize" ); - - public final static MojoDescriptor TEST_COMPILE = createMojoDescriptor( "test-compile" ); - - public final static MojoDescriptor PROCESS_TEST_RESOURCES = createMojoDescriptor( "process-test-resources" ); - - public final static MojoDescriptor PROCESS_RESOURCES = createMojoDescriptor( "process-resources" ); - - public final static MojoDescriptor COMPILE = createMojoDescriptor( "compile", true ); - - public final static MojoDescriptor TEST = createMojoDescriptor( "test" ); - - public final static MojoDescriptor PACKAGE = createMojoDescriptor( "package" ); - - public final static MojoDescriptor INSTALL = createMojoDescriptor( "install" ); - - // site - - public final static MojoDescriptor PRE_SITE = createMojoDescriptor( "pre-site" ); - - public final static MojoDescriptor SITE = createMojoDescriptor( "site" ); - - public final static MojoDescriptor POST_SITE = createMojoDescriptor( "post-site" ); - - public final static MojoDescriptor SITE_DEPLOY = createMojoDescriptor( "site-deploy" ); - - - public int getNumberOfExceutions( ProjectBuildList projectBuildList ) - throws InvalidPluginDescriptorException, PluginVersionResolutionException, PluginDescriptorParsingException, - NoPluginFoundForPrefixException, MojoNotFoundException, PluginNotFoundException, PluginResolutionException, - LifecyclePhaseNotFoundException, LifecycleNotFoundException - { - int result = 0; - for ( ProjectSegment projectBuild : projectBuildList ) - { - MavenExecutionPlan plan = calculateExecutionPlan( projectBuild.getSession(), projectBuild.getProject(), - projectBuild.getTaskSegment().getTasks() ); - result += plan.size(); - } - return result; - } - - public void calculateForkedExecutions( MojoExecution mojoExecution, MavenSession session ) - throws MojoNotFoundException, PluginNotFoundException, PluginResolutionException, - PluginDescriptorParsingException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException, - LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginVersionResolutionException - { - // Maybe do something ? - } - - public MavenExecutionPlan calculateExecutionPlan( MavenSession session, MavenProject project, List<Object> tasks, - boolean setup ) - throws PluginNotFoundException, PluginResolutionException, LifecyclePhaseNotFoundException, - PluginDescriptorParsingException, MojoNotFoundException, InvalidPluginDescriptorException, - NoPluginFoundForPrefixException, LifecycleNotFoundException, PluginVersionResolutionException - { - if ( project.equals( ProjectDependencyGraphStub.A ) ) - { - return getProjectAExceutionPlan(); - } - if ( project.equals( ProjectDependencyGraphStub.B ) ) - { - return getProjectBExecutionPlan(); - } - // The remaining are basically "for future expansion" - List<MojoExecution> me = new ArrayList<MojoExecution>(); - me.add( createMojoExecution( "resources", "default-resources", PROCESS_RESOURCES ) ); - me.add( createMojoExecution( "compile", "default-compile", COMPILE ) ); - return createExecutionPlan( project, me ); - } - - public MavenExecutionPlan calculateExecutionPlan( MavenSession session, MavenProject project, List<Object> tasks ) - throws PluginNotFoundException, PluginResolutionException, LifecyclePhaseNotFoundException, - PluginDescriptorParsingException, MojoNotFoundException, InvalidPluginDescriptorException, - NoPluginFoundForPrefixException, LifecycleNotFoundException, PluginVersionResolutionException - { - return calculateExecutionPlan( session, project, tasks, true ); - } - - public void setupMojoExecution( MavenSession session, MavenProject project, MojoExecution mojoExecution ) - throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, - MojoNotFoundException, InvalidPluginDescriptorException, NoPluginFoundForPrefixException, - LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginVersionResolutionException - { - } - - public static MavenExecutionPlan getProjectAExceutionPlan() - throws PluginNotFoundException, PluginResolutionException, LifecyclePhaseNotFoundException, - PluginDescriptorParsingException, MojoNotFoundException, InvalidPluginDescriptorException, - NoPluginFoundForPrefixException, LifecycleNotFoundException, PluginVersionResolutionException - { - List<MojoExecution> me = new ArrayList<MojoExecution>(); - me.add( createMojoExecution( "initialize", "default-initialize", INITIALIZE ) ); - me.add( createMojoExecution( "resources", "default-resources", PROCESS_RESOURCES ) ); - me.add( createMojoExecution( "compile", "default-compile", COMPILE ) ); - me.add( createMojoExecution( "testResources", "default-testResources", PROCESS_TEST_RESOURCES ) ); - me.add( createMojoExecution( "testCompile", "default-testCompile", TEST_COMPILE ) ); - me.add( createMojoExecution( "test", "default-test", TEST ) ); - me.add( createMojoExecution( "war", "default-war", PACKAGE ) ); - me.add( createMojoExecution( "install", "default-install", INSTALL ) ); - return createExecutionPlan( ProjectDependencyGraphStub.A.getExecutionProject(), me ); - } - - public static MavenExecutionPlan getProjectBExecutionPlan() - throws PluginNotFoundException, PluginResolutionException, LifecyclePhaseNotFoundException, - PluginDescriptorParsingException, MojoNotFoundException, InvalidPluginDescriptorException, - NoPluginFoundForPrefixException, LifecycleNotFoundException, PluginVersionResolutionException - { - List<MojoExecution> me = new ArrayList<MojoExecution>(); - me.add( createMojoExecution( "enforce", "enforce-versions", VALIDATE ) ); - me.add( createMojoExecution( "resources", "default-resources", PROCESS_RESOURCES ) ); - me.add( createMojoExecution( "compile", "default-compile", COMPILE ) ); - me.add( createMojoExecution( "testResources", "default-testResources", PROCESS_TEST_RESOURCES ) ); - me.add( createMojoExecution( "testCompile", "default-testCompile", TEST_COMPILE ) ); - me.add( createMojoExecution( "test", "default-test", TEST ) ); - return createExecutionPlan( ProjectDependencyGraphStub.B.getExecutionProject(), me ); - } - - - private static MavenExecutionPlan createExecutionPlan( MavenProject project, List<MojoExecution> mojoExecutions ) - throws InvalidPluginDescriptorException, PluginVersionResolutionException, PluginDescriptorParsingException, - NoPluginFoundForPrefixException, MojoNotFoundException, PluginNotFoundException, PluginResolutionException, - LifecyclePhaseNotFoundException, LifecycleNotFoundException - { - final List<ExecutionPlanItem> planItemList = - ExecutionPlanItem.createExecutionPlanItems( project, mojoExecutions ); - return new MavenExecutionPlan( planItemList, DefaultLifecyclesStub.createDefaultLifecycles() ); - } - - private static MojoExecution createMojoExecution( String goal, String executionId, MojoDescriptor mojoDescriptor ) - { - final Plugin plugin = mojoDescriptor.getPluginDescriptor().getPlugin(); - MojoExecution result = new MojoExecution( plugin, goal, executionId ); - result.setConfiguration( new Xpp3Dom( executionId + "-" + goal ) ); - result.setMojoDescriptor( mojoDescriptor ); - result.setLifecyclePhase( mojoDescriptor.getPhase() ); - - return result; - - } - - public static MojoDescriptor createMojoDescriptor( String phaseName ) - { - return createMojoDescriptor( phaseName, false ); - } - - public static MojoDescriptor createMojoDescriptor( String phaseName, boolean threadSafe ) - { - final MojoDescriptor mojoDescriptor = new MojoDescriptor(); - mojoDescriptor.setPhase( phaseName ); - final PluginDescriptor descriptor = new PluginDescriptor(); - Plugin plugin = new Plugin(); - plugin.setArtifactId( "org.apache.maven.test.MavenExecutionPlan" ); - plugin.setGroupId( "stub-plugin-" + phaseName ); - descriptor.setPlugin( plugin ); - descriptor.setArtifactId( "artifact." + phaseName ); - mojoDescriptor.setPluginDescriptor( descriptor ); - mojoDescriptor.setThreadSafe( threadSafe ); - return mojoDescriptor; - } - - - public static Set<String> getScopes() - { - return new HashSet<String>( Arrays.asList( "compile" ) ); - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/LifecycleTaskSegmentCalculatorStub.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/LifecycleTaskSegmentCalculatorStub.java deleted file mode 100644 index 695d66dd..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/LifecycleTaskSegmentCalculatorStub.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * 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. - */ - -package org.apache.maven.lifecycle.internal.stub; - -import org.apache.maven.execution.MavenSession; -import org.apache.maven.lifecycle.internal.GoalTask; -import org.apache.maven.lifecycle.internal.LifecycleTask; -import org.apache.maven.lifecycle.internal.DefaultLifecycleTaskSegmentCalculator; -import org.apache.maven.lifecycle.internal.TaskSegment; -import org.apache.maven.plugin.InvalidPluginDescriptorException; -import org.apache.maven.plugin.MojoNotFoundException; -import org.apache.maven.plugin.PluginDescriptorParsingException; -import org.apache.maven.plugin.PluginNotFoundException; -import org.apache.maven.plugin.PluginResolutionException; -import org.apache.maven.plugin.prefix.NoPluginFoundForPrefixException; -import org.apache.maven.plugin.version.PluginVersionResolutionException; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author Kristian Rosenvold - */ -public class LifecycleTaskSegmentCalculatorStub - extends DefaultLifecycleTaskSegmentCalculator -{ - public static final String clean = "clean"; - - public static final String aggr = "aggr"; - - public static final String install = "install"; - - - public List<TaskSegment> calculateTaskSegments( MavenSession session, List<String> tasks ) - throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, - MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException, - PluginVersionResolutionException - { - List<TaskSegment> taskSegments = new ArrayList<TaskSegment>( tasks.size() ); - - TaskSegment currentSegment = null; - - for ( String task : tasks ) - { - if ( aggr.equals( task ) ) - { - boolean aggregating = true; - - if ( currentSegment == null || currentSegment.isAggregating() != aggregating ) - { - currentSegment = new TaskSegment( aggregating ); - taskSegments.add( currentSegment ); - } - - currentSegment.getTasks().add( new GoalTask( task ) ); - } - else - { - // lifecycle phase - if ( currentSegment == null || currentSegment.isAggregating() ) - { - currentSegment = new TaskSegment( false ); - taskSegments.add( currentSegment ); - } - currentSegment.getTasks().add( new LifecycleTask( task ) ); - } - } - - return taskSegments; - } - - public boolean requiresProject( MavenSession session ) - { - return true; - } -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/LoggerStub.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/LoggerStub.java deleted file mode 100644 index 00bb3cfa..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/LoggerStub.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * 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. - */ - -package org.apache.maven.lifecycle.internal.stub; - -import org.codehaus.plexus.logging.Logger; - -/** - * @author Kristian Rosenvold - */ -public class LoggerStub - implements Logger -{ - public void debug( String s ) - { - } - - public void debug( String s, Throwable throwable ) - { - } - - public boolean isDebugEnabled() - { - return true; - } - - public void info( String s ) - { - } - - public void info( String s, Throwable throwable ) - { - } - - public boolean isInfoEnabled() - { - return true; - } - - public void warn( String s ) - { - } - - public void warn( String s, Throwable throwable ) - { - } - - public boolean isWarnEnabled() - { - return true; - } - - public void error( String s ) - { - } - - public void error( String s, Throwable throwable ) - { - } - - public boolean isErrorEnabled() - { - return true; - } - - public void fatalError( String s ) - { - } - - public void fatalError( String s, Throwable throwable ) - { - } - - public boolean isFatalErrorEnabled() - { - return true; - } - - public Logger getChildLogger( String s ) - { - return null; - } - - public int getThreshold() - { - return 0; - } - - public void setThreshold( int i ) - { - - } - - public String getName() - { - return "StubLogger"; - } -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/MojoExecutorStub.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/MojoExecutorStub.java deleted file mode 100644 index a8572ffc..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/MojoExecutorStub.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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. - */ - -package org.apache.maven.lifecycle.internal.stub; - -import org.apache.maven.execution.MavenSession; -import org.apache.maven.lifecycle.LifecycleExecutionException; -import org.apache.maven.lifecycle.internal.DependencyContext; -import org.apache.maven.lifecycle.internal.MojoExecutor; -import org.apache.maven.lifecycle.internal.PhaseRecorder; -import org.apache.maven.lifecycle.internal.ProjectIndex; -import org.apache.maven.plugin.MojoExecution; -import org.apache.maven.plugin.descriptor.MojoDescriptor; -import org.apache.maven.plugin.descriptor.PluginDescriptor; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * @author Kristian Rosenvold - */ -public class MojoExecutorStub - extends MojoExecutor -{ // This is being lazy instead of making interface - - public List<MojoExecution> executions = Collections.synchronizedList( new ArrayList<MojoExecution>() ); - - @Override - public void execute( MavenSession session, MojoExecution mojoExecution, ProjectIndex projectIndex, - DependencyContext dependencyContext, PhaseRecorder phaseRecorder ) - throws LifecycleExecutionException - { - executions.add( mojoExecution ); - } - - @Override - public void execute( MavenSession session, List<MojoExecution> mojoExecutions, ProjectIndex projectIndex ) - throws LifecycleExecutionException - { - for ( MojoExecution mojoExecution : mojoExecutions ) - { - executions.add( mojoExecution ); - } - } - - - public static MojoDescriptor createMojoDescriptor( String mojoDescription ) - { - final PluginDescriptor descriptor = new PluginDescriptor(); - descriptor.setArtifactId( mojoDescription ); - final MojoDescriptor mojoDescriptor = new MojoDescriptor(); - mojoDescriptor.setDescription( mojoDescription ); - mojoDescriptor.setPluginDescriptor( descriptor ); - return mojoDescriptor; - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/PluginPrefixResolverStub.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/PluginPrefixResolverStub.java deleted file mode 100644 index a4b54e98..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/PluginPrefixResolverStub.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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. - */ - -package org.apache.maven.lifecycle.internal.stub; - -import org.apache.maven.plugin.prefix.NoPluginFoundForPrefixException; -import org.apache.maven.plugin.prefix.PluginPrefixRequest; -import org.apache.maven.plugin.prefix.PluginPrefixResolver; -import org.apache.maven.plugin.prefix.PluginPrefixResult; -import org.eclipse.aether.repository.ArtifactRepository; - -/** - * @author Kristian Rosenvold - */ - -public class PluginPrefixResolverStub - implements PluginPrefixResolver -{ - public PluginPrefixResult resolve( PluginPrefixRequest request ) - throws NoPluginFoundForPrefixException - { - return new PluginPrefixResult() - { - public String getGroupId() - { - return "com.foobar"; - } - - public String getArtifactId() - { - return "bazbaz"; - } - - public ArtifactRepository getRepository() - { - return null; - } - }; - } -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/PluginVersionResolverStub.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/PluginVersionResolverStub.java deleted file mode 100644 index c79658e8..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/PluginVersionResolverStub.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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. - */ - -package org.apache.maven.lifecycle.internal.stub; - -import org.apache.maven.plugin.version.PluginVersionRequest; -import org.apache.maven.plugin.version.PluginVersionResolutionException; -import org.apache.maven.plugin.version.PluginVersionResolver; -import org.apache.maven.plugin.version.PluginVersionResult; -import org.eclipse.aether.repository.ArtifactRepository; - -/** - * @author Kristian Rosenvold - */ - -public class PluginVersionResolverStub - implements PluginVersionResolver -{ - - public PluginVersionResult resolve( PluginVersionRequest request ) - throws PluginVersionResolutionException - { - return new PluginVersionResult() - { - public String getVersion() - { - return "0.42"; - } - - public ArtifactRepository getRepository() - { - return null; - } - }; - } -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/ProjectDependenciesResolverStub.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/ProjectDependenciesResolverStub.java deleted file mode 100644 index 4147b36c..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/ProjectDependenciesResolverStub.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * 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. - */ - -package org.apache.maven.lifecycle.internal.stub; - -import org.apache.maven.ProjectDependenciesResolver; -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.resolver.ArtifactNotFoundException; -import org.apache.maven.artifact.resolver.ArtifactResolutionException; -import org.apache.maven.execution.MavenSession; -import org.apache.maven.project.DependencyResolutionException; -import org.apache.maven.project.DependencyResolutionRequest; -import org.apache.maven.project.DependencyResolutionResult; -import org.apache.maven.project.MavenProject; -import org.eclipse.aether.graph.DefaultDependencyNode; -import org.eclipse.aether.graph.Dependency; -import org.eclipse.aether.graph.DependencyNode; - -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -/** - * @author Kristian Rosenvold - */ -public class ProjectDependenciesResolverStub - implements ProjectDependenciesResolver, org.apache.maven.project.ProjectDependenciesResolver -{ - public Set<Artifact> resolve( MavenProject project, Collection<String> scopesToResolve, MavenSession session ) - throws ArtifactResolutionException, ArtifactNotFoundException - { - return new HashSet<Artifact>(); - } - - public Set<Artifact> resolve( MavenProject project, Collection<String> scopesToCollect, - Collection<String> scopesToResolve, MavenSession session ) - throws ArtifactResolutionException, ArtifactNotFoundException - { - return new HashSet<Artifact>(); - } - - public Set<Artifact> resolve( Collection<? extends MavenProject> projects, Collection<String> scopes, - MavenSession session ) - throws ArtifactResolutionException, ArtifactNotFoundException - { - return new HashSet<Artifact>(); - } - - public Set<Artifact> resolve( MavenProject project, Collection<String> scopesToCollect, - Collection<String> scopesToResolve, MavenSession session, - Set<Artifact> ignoreableArtifacts ) - throws ArtifactResolutionException, ArtifactNotFoundException - { - return new HashSet<Artifact>(); - } - - public DependencyResolutionResult resolve( DependencyResolutionRequest request ) - throws DependencyResolutionException - { - return new DependencyResolutionResult() - { - - public List<Dependency> getUnresolvedDependencies() - { - return Collections.emptyList(); - } - - public List<Dependency> getResolvedDependencies() - { - return Collections.emptyList(); - } - - public List<Exception> getResolutionErrors( Dependency dependency ) - { - return Collections.emptyList(); - } - - public DependencyNode getDependencyGraph() - { - return new DefaultDependencyNode( (Dependency) null ); - } - - public List<Dependency> getDependencies() - { - return Collections.emptyList(); - } - - public List<Exception> getCollectionErrors() - { - return Collections.emptyList(); - } - }; - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/ProjectDependencyGraphStub.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/ProjectDependencyGraphStub.java deleted file mode 100644 index 38e9fcad..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/ProjectDependencyGraphStub.java +++ /dev/null @@ -1,227 +0,0 @@ -/* - * 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. - */ - -package org.apache.maven.lifecycle.internal.stub; - -import org.apache.maven.execution.AbstractExecutionListener; -import org.apache.maven.execution.DefaultMavenExecutionRequest; -import org.apache.maven.execution.DefaultMavenExecutionResult; -import org.apache.maven.execution.MavenExecutionRequest; -import org.apache.maven.execution.MavenSession; -import org.apache.maven.execution.ProjectDependencyGraph; -import org.apache.maven.lifecycle.LifecycleNotFoundException; -import org.apache.maven.lifecycle.LifecyclePhaseNotFoundException; -import org.apache.maven.lifecycle.internal.GoalTask; -import org.apache.maven.lifecycle.internal.ProjectBuildList; -import org.apache.maven.lifecycle.internal.ProjectSegment; -import org.apache.maven.lifecycle.internal.TaskSegment; -import org.apache.maven.plugin.InvalidPluginDescriptorException; -import org.apache.maven.plugin.MojoNotFoundException; -import org.apache.maven.plugin.PluginDescriptorParsingException; -import org.apache.maven.plugin.PluginNotFoundException; -import org.apache.maven.plugin.PluginResolutionException; -import org.apache.maven.plugin.prefix.NoPluginFoundForPrefixException; -import org.apache.maven.plugin.version.PluginVersionResolutionException; -import org.apache.maven.project.MavenProject; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -/** - * A stub dependency graph that is custom made for testing concurrent build graph evaluations. - * <p/> - * Implements a graph as follows: - * A has no dependencies - * B depends on A - * C depends on A - * X depends on B & C - * Y depends on B - * Z depends on C - * - * @author Kristian Rosenvold - */ -public class ProjectDependencyGraphStub - implements ProjectDependencyGraph -{ - public static final MavenProject A = new MavenProject(); - - public static final MavenProject B = new MavenProject(); - - public static final MavenProject C = new MavenProject(); - - public static final MavenProject X = new MavenProject(); - - public static final MavenProject Y = new MavenProject(); - - public static final MavenProject Z = new MavenProject(); - - public static final MavenProject UNKNOWN = new MavenProject(); - - static - { - A.setArtifactId( "A" ); - B.setArtifactId( "B" ); - C.setArtifactId( "C" ); - X.setArtifactId( "X" ); - Y.setArtifactId( "Y" ); - Z.setArtifactId( "Z" ); - } - - // This should probably be moved to a separate stub - - public static ProjectBuildList getProjectBuildList( MavenSession session ) - throws InvalidPluginDescriptorException, PluginVersionResolutionException, PluginDescriptorParsingException, - NoPluginFoundForPrefixException, MojoNotFoundException, PluginNotFoundException, PluginResolutionException, - LifecyclePhaseNotFoundException, LifecycleNotFoundException - { - final List<ProjectSegment> list = getProjectBuilds( session ); - return new ProjectBuildList( list ); - - } - - public static List<ProjectSegment> getProjectBuilds( MavenSession session ) - throws InvalidPluginDescriptorException, PluginVersionResolutionException, PluginDescriptorParsingException, - NoPluginFoundForPrefixException, PluginNotFoundException, MojoNotFoundException, PluginResolutionException, - LifecyclePhaseNotFoundException, LifecycleNotFoundException - { - List<ProjectSegment> projectBuilds = new ArrayList<ProjectSegment>(); - - TaskSegment segment = createTaskSegment(); - projectBuilds.add( createProjectBuild( A, session, segment ) ); - projectBuilds.add( createProjectBuild( B, session, segment ) ); - projectBuilds.add( createProjectBuild( C, session, segment ) ); - projectBuilds.add( createProjectBuild( X, session, segment ) ); - projectBuilds.add( createProjectBuild( Y, session, segment ) ); - projectBuilds.add( createProjectBuild( Z, session, segment ) ); - return projectBuilds; - } - - private static ProjectSegment createProjectBuild( MavenProject project, MavenSession session, - TaskSegment taskSegment ) - throws InvalidPluginDescriptorException, PluginVersionResolutionException, PluginDescriptorParsingException, - NoPluginFoundForPrefixException, MojoNotFoundException, PluginNotFoundException, PluginResolutionException, - LifecyclePhaseNotFoundException, LifecycleNotFoundException - { - final MavenSession session1 = session.clone(); - return new ProjectSegment( project, taskSegment, session1 ); - } - - - private static TaskSegment createTaskSegment() - { - TaskSegment result = new TaskSegment( false ); - result.getTasks().add( new GoalTask( "t1" ) ); - result.getTasks().add( new GoalTask( "t2" ) ); - return result; - } - - class Dependency - { - MavenProject dependant; - - MavenProject dependency; - - Dependency( MavenProject dependant, MavenProject dependency ) - { - this.dependant = dependant; - this.dependency = dependency; - } - - void addIfDownstream( MavenProject mavenProject, List<MavenProject> result ) - { - if ( dependency == mavenProject ) - { - result.add( dependant ); - } - } - - void addIfUpstreamOf( MavenProject mavenProject, List<MavenProject> result ) - { - if ( dependant == mavenProject ) - { - result.add( dependency ); // All projects are the statics from this class - } - } - } - - private List<Dependency> getDependencies() - { - List<Dependency> dependencies = new ArrayList<Dependency>(); - dependencies.add( new Dependency( B, A ) ); - dependencies.add( new Dependency( C, A ) ); - dependencies.add( new Dependency( X, B ) ); - dependencies.add( new Dependency( X, C ) ); - dependencies.add( new Dependency( Y, B ) ); - dependencies.add( new Dependency( Z, C ) ); - return dependencies; - } - - public List<MavenProject> getSortedProjects() - { - return Arrays.asList( A, B, C, X, Y, Z ); // I'm not entirely sure about the order but this shold do... - } - - public List<MavenProject> getDownstreamProjects( MavenProject project, boolean transitive ) - { - if ( transitive ) - { - throw new RuntimeException( "Not implemented yet" ); - } - List<MavenProject> result = new ArrayList<MavenProject>(); - for ( Dependency dependency : getDependencies() ) - { - dependency.addIfDownstream( project, result ); - } - return result; - } - - public List<MavenProject> getUpstreamProjects( MavenProject project, boolean transitive ) - { - /* if ( transitive ) - { - throw new RuntimeException( "Not implemented yet" ); - }*/ - List<MavenProject> result = new ArrayList<MavenProject>(); - final List<Dependency> dependencies = getDependencies(); - for ( Dependency dependency : dependencies ) - { - dependency.addIfUpstreamOf( project, result ); - } - return result; - } - - public static MavenSession getMavenSession( MavenProject mavenProject ) - { - final MavenSession session = getMavenSession(); - session.setCurrentProject( mavenProject ); - return session; - } - - public static MavenSession getMavenSession() - { - final DefaultMavenExecutionResult defaultMavenExecutionResult = new DefaultMavenExecutionResult(); - MavenExecutionRequest mavenExecutionRequest = new DefaultMavenExecutionRequest(); - mavenExecutionRequest.setExecutionListener( new AbstractExecutionListener() ); - mavenExecutionRequest.setGoals( Arrays.asList( "clean", "aggr", "install" ) ); - mavenExecutionRequest.setDegreeOfConcurrency( 1 ); - final MavenSession session = new MavenSession( null, null, mavenExecutionRequest, defaultMavenExecutionResult ); - final ProjectDependencyGraphStub dependencyGraphStub = new ProjectDependencyGraphStub(); - session.setProjectDependencyGraph( dependencyGraphStub ); - session.setProjects( dependencyGraphStub.getSortedProjects() ); - return session; - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/ProjectDependencyGraphStubTest.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/ProjectDependencyGraphStubTest.java deleted file mode 100644 index 8c605723..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/ProjectDependencyGraphStubTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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. - */ - -package org.apache.maven.lifecycle.internal.stub; - -import junit.framework.TestCase; -import org.apache.maven.project.MavenProject; - -import java.util.List; - - -/** - * Tests the stub. Yeah, I know. - * - * @author Kristian Rosenvold - */ - -public class ProjectDependencyGraphStubTest - extends TestCase -{ - public void testADependencies() - { - ProjectDependencyGraphStub stub = new ProjectDependencyGraphStub(); - final List<MavenProject> mavenProjects = stub.getUpstreamProjects( ProjectDependencyGraphStub.A, false ); - assertEquals( 0, mavenProjects.size() ); - } - - public void testBDepenencies( ProjectDependencyGraphStub stub ) - { - final List<MavenProject> bProjects = stub.getUpstreamProjects( ProjectDependencyGraphStub.B, false ); - assertEquals( 1, bProjects.size() ); - assertTrue( bProjects.contains( ProjectDependencyGraphStub.A ) ); - } - - public void testCDepenencies( ProjectDependencyGraphStub stub ) - { - final List<MavenProject> cProjects = stub.getUpstreamProjects( ProjectDependencyGraphStub.C, false ); - assertEquals( 1, cProjects.size() ); - assertTrue( cProjects.contains( ProjectDependencyGraphStub.C ) ); - } - - public void testXDepenencies( ProjectDependencyGraphStub stub ) - { - final List<MavenProject> cProjects = stub.getUpstreamProjects( ProjectDependencyGraphStub.X, false ); - assertEquals( 2, cProjects.size() ); - assertTrue( cProjects.contains( ProjectDependencyGraphStub.C ) ); - assertTrue( cProjects.contains( ProjectDependencyGraphStub.B ) ); - } -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/plugin/PluginManagerTest.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/plugin/PluginManagerTest.java deleted file mode 100644 index 025e7725..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/plugin/PluginManagerTest.java +++ /dev/null @@ -1,342 +0,0 @@ -package org.apache.maven.plugin; - -/* - * 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.List; - -import org.apache.maven.AbstractCoreMavenComponentTestCase; -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.repository.DefaultRepositoryRequest; -import org.apache.maven.artifact.repository.RepositoryRequest; -import org.apache.maven.execution.MavenSession; -import org.apache.maven.model.Plugin; -import org.apache.maven.plugin.descriptor.MojoDescriptor; -import org.apache.maven.plugin.descriptor.PluginDescriptor; -import org.apache.maven.project.MavenProject; -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.annotations.Requirement; -import org.codehaus.plexus.component.repository.ComponentDescriptor; - -public class PluginManagerTest - extends AbstractCoreMavenComponentTestCase -{ - @Requirement - private DefaultBuildPluginManager pluginManager; - - protected void setUp() - throws Exception - { - super.setUp(); - pluginManager = (DefaultBuildPluginManager) lookup( BuildPluginManager.class ); - } - - @Override - protected void tearDown() - throws Exception - { - pluginManager = null; - super.tearDown(); - } - - protected String getProjectsDirectory() - { - return "src/test/projects/plugin-manager"; - } - - public void testPluginLoading() - throws Exception - { - MavenSession session = createMavenSession( null ); - Plugin plugin = new Plugin(); - plugin.setGroupId( "org.apache.maven.its.plugins" ); - plugin.setArtifactId( "maven-it-plugin" ); - plugin.setVersion( "0.1" ); - PluginDescriptor pluginDescriptor = - pluginManager.loadPlugin( plugin, session.getCurrentProject().getRemotePluginRepositories(), - session.getRepositorySession() ); - assertNotNull( pluginDescriptor ); - } - - public void testMojoDescriptorRetrieval() - throws Exception - { - MavenSession session = createMavenSession( null ); - String goal = "it"; - Plugin plugin = new Plugin(); - plugin.setGroupId( "org.apache.maven.its.plugins" ); - plugin.setArtifactId( "maven-it-plugin" ); - plugin.setVersion( "0.1" ); - - MojoDescriptor mojoDescriptor = - pluginManager.getMojoDescriptor( plugin, goal, session.getCurrentProject().getRemotePluginRepositories(), - session.getRepositorySession() ); - assertNotNull( mojoDescriptor ); - assertEquals( goal, mojoDescriptor.getGoal() ); - // igorf: plugin realm comes later - // assertNotNull( mojoDescriptor.getRealm() ); - - PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor(); - assertNotNull( pluginDescriptor ); - assertEquals( "org.apache.maven.its.plugins", pluginDescriptor.getGroupId() ); - assertEquals( "maven-it-plugin", pluginDescriptor.getArtifactId() ); - assertEquals( "0.1", pluginDescriptor.getVersion() ); - } - - // ----------------------------------------------------------------------------------------------- - // Tests which exercise the lifecycle executor when it is dealing with individual goals. - // ----------------------------------------------------------------------------------------------- - - //TODO: These two tests display a lack of symmetry with respect to the input which is a free form string and the - // mojo descriptor which comes back. All the free form parsing needs to be done somewhere else, this is - // really the function of the CLI, and then the pre-processing of that output still needs to be fed into - // a hinting process which helps flesh out the full specification of the plugin. The plugin manager should - // only deal in concrete terms -- all version finding mumbo jumbo is a customization to base functionality - // the plugin manager provides. - - public void testRemoteResourcesPlugin() - throws Exception - { - //TODO: turn an equivalent back on when the RR plugin is released. - - /* - - This will not work until the RR plugin is released to get rid of the binding to the reporting exception which is a mistake. - - This happpens after removing the reporting API from the core: - - java.lang.NoClassDefFoundError: org/apache/maven/reporting/MavenReportException - - MavenSession session = createMavenSession( getProject( "project-with-inheritance" ) ); - String goal = "process"; - - Plugin plugin = new Plugin(); - plugin.setGroupId( "org.apache.maven.plugins" ); - plugin.setArtifactId( "maven-remote-resources-plugin" ); - plugin.setVersion( "1.0-beta-2" ); - - MojoDescriptor mojoDescriptor = pluginManager.getMojoDescriptor( plugin, goal, session.getCurrentProject(), session.getLocalRepository() ); - assertPluginDescriptor( mojoDescriptor, "org.apache.maven.plugins", "maven-remote-resources-plugin", "1.0-beta-2" ); - MojoExecution mojoExecution = new MojoExecution( mojoDescriptor ); - pluginManager.executeMojo( session, mojoExecution ); - */ - } - - //TODO: this will be the basis of the customizable lifecycle execution so need to figure this out quickly. - public void testSurefirePlugin() - throws Exception - { - /* - MavenSession session = createMavenSession( getProject( "project-with-inheritance" ) ); - String goal = "test"; - - Plugin plugin = new Plugin(); - plugin.setGroupId( "org.apache.maven.plugins" ); - plugin.setArtifactId( "maven-surefire-plugin" ); - plugin.setVersion( "2.4.2" ); - - // The project has already been fully interpolated so getting the raw mojoDescriptor is not going to have the processes configuration. - MojoDescriptor mojoDescriptor = pluginManager.getMojoDescriptor( plugin, goal, session.getLocalRepository(), session.getCurrentProject().getPluginArtifactRepositories() ); - assertPluginDescriptor( mojoDescriptor, "org.apache.maven.plugins", "maven-surefire-plugin", "2.4.2" ); - - System.out.println( session.getCurrentProject().getBuild().getPluginsAsMap() ); - - Xpp3Dom configuration = (Xpp3Dom) session.getCurrentProject().getBuild().getPluginsAsMap().get( plugin.getKey() ).getExecutions().get( 0 ).getConfiguration(); - MojoExecution mojoExecution = new MojoExecution( mojoDescriptor, configuration ); - pluginManager.executeMojo( session, mojoExecution ); - */ - } - - public void testMojoConfigurationIsMergedCorrectly() - throws Exception - { - } - - /** - * The case where the user wants to specify an alternate version of the underlying tool. Common case - * is in the Antlr plugin which comes bundled with a version of Antlr but the user often times needs - * to use a specific version. We need to make sure the version that they specify takes precedence. - */ - public void testMojoWhereInternallyStatedDependencyIsOverriddenByProject() - throws Exception - { - } - - /** - * The case where you have a plugin in the current build that you want to be used on projects in - * the current build. - */ - public void testMojoThatIsPresentInTheCurrentBuild() - throws Exception - { - } - - /** - * This is the case where the Mojo wants to execute on every project and then do something at the end - * with the results of each project. - */ - public void testAggregatorMojo() - throws Exception - { - } - - /** - * This is the case where a Mojo needs the lifecycle run to a certain phase before it can do - * anything useful. - */ - public void testMojoThatRequiresExecutionToAGivenPhaseBeforeExecutingItself() - throws Exception - { - } - - // test that mojo which does not require dependency resolution trigger no downloading of dependencies - - // test interpolation of basedir values in mojo configuration - - // test a build where projects use different versions of the same plugin - - public void testThatPluginDependencyThatHasSystemScopeIsResolved() - throws Exception - { - /* - File systemPath = new File( getBasedir(), "pom.xml" ); - - Plugin plugin = new PluginBuilder( "org.apache.maven", "project-test", "1.0" ) - .addDependency( "org.apache.maven", "system-dependency", "1.0", Artifact.SCOPE_SYSTEM, systemPath.getAbsolutePath() ) - .get(); - - MavenProject pluginProject = new ProjectBuilder( "org.apache.maven", "project-test", "1.0" ) - .addPlugin( plugin ) - .addDependency( "junit", "junit", "3.8.1", Artifact.SCOPE_COMPILE ) - .get(); - - // i'm making this artifact which is assumed to come from a pom in the metadata processor, then it tries to create a POM artifact - // and parse it for the dependencies and it blows up. - // - // we need to pass this through as is so it doesn't get parsed again. - Artifact pluginArtifact = new ProjectArtifact( pluginProject ); - - Set<Artifact> artifacts = pluginManager.getPluginArtifacts( pluginArtifact, plugin, getLocalRepository(), getPluginArtifactRepositories() ); - System.out.println( artifacts ); - */ - - MavenSession session = createMavenSession( getProject( "project-contributing-system-scope-plugin-dep" ) ); - MavenProject project = session.getCurrentProject(); - Plugin plugin = project.getPlugin( "org.apache.maven.its.plugins:maven-it-plugin" ); - - RepositoryRequest repositoryRequest = new DefaultRepositoryRequest(); - repositoryRequest.setLocalRepository( getLocalRepository() ); - repositoryRequest.setRemoteRepositories( getPluginArtifactRepositories() ); - - PluginDescriptor pluginDescriptor = - pluginManager.loadPlugin( plugin, session.getCurrentProject().getRemotePluginRepositories(), - session.getRepositorySession() ); - pluginManager.getPluginRealm( session, pluginDescriptor ); - List<Artifact> artifacts = pluginDescriptor.getArtifacts(); - - for ( Artifact a : artifacts ) - { - if ( a.getGroupId().equals( "org.apache.maven.its.mng3586" ) && a.getArtifactId().equals( "tools" ) ) - { - // The system scoped dependencies will be present in the classloader for the plugin - return; - } - } - - fail( "Can't find the system scoped dependency in the plugin artifacts." ); - } - - // ----------------------------------------------------------------------------------------------- - // Testing help - // ----------------------------------------------------------------------------------------------- - - protected void assertPluginDescriptor( MojoDescriptor mojoDescriptor, String groupId, String artifactId, String version ) - { - assertNotNull( mojoDescriptor ); - PluginDescriptor pd = mojoDescriptor.getPluginDescriptor(); - assertNotNull( pd ); - assertEquals( groupId, pd.getGroupId() ); - assertEquals( artifactId, pd.getArtifactId() ); - assertEquals( version, pd.getVersion() ); - } - - public void testPluginRealmCache() - throws Exception - { - RepositoryRequest repositoryRequest = new DefaultRepositoryRequest(); - repositoryRequest.setLocalRepository( getLocalRepository() ); - repositoryRequest.setRemoteRepositories( getPluginArtifactRepositories() ); - - // prime realm cache - MavenSession session = createMavenSession( getProject( "project-contributing-system-scope-plugin-dep" ) ); - MavenProject project = session.getCurrentProject(); - Plugin plugin = project.getPlugin( "org.apache.maven.its.plugins:maven-it-plugin" ); - - PluginDescriptor pluginDescriptor = - pluginManager.loadPlugin( plugin, session.getCurrentProject().getRemotePluginRepositories(), - session.getRepositorySession() ); - pluginManager.getPluginRealm( session, pluginDescriptor ); - - assertEquals( 1, pluginDescriptor.getDependencies().size() ); - - for ( ComponentDescriptor<?> descriptor : pluginDescriptor.getComponents() ) - { - assertNotNull( descriptor.getRealm() ); - assertNotNull( descriptor.getImplementationClass() ); - } - - // reload plugin realm from cache - session = createMavenSession( getProject( "project-contributing-system-scope-plugin-dep" ) ); - project = session.getCurrentProject(); - plugin = project.getPlugin( "org.apache.maven.its.plugins:maven-it-plugin" ); - - pluginDescriptor = - pluginManager.loadPlugin( plugin, session.getCurrentProject().getRemotePluginRepositories(), - session.getRepositorySession() ); - pluginManager.getPluginRealm( session, pluginDescriptor ); - - assertEquals( 1, pluginDescriptor.getDependencies().size() ); - - for ( ComponentDescriptor<?> descriptor : pluginDescriptor.getComponents() ) - { - assertNotNull( descriptor.getRealm() ); - assertNotNull( descriptor.getImplementationClass() ); - } - } - - public void testBuildExtensionsPluginLoading() - throws Exception - { - RepositoryRequest repositoryRequest = new DefaultRepositoryRequest(); - repositoryRequest.setLocalRepository( getLocalRepository() ); - repositoryRequest.setRemoteRepositories( getPluginArtifactRepositories() ); - - // prime realm cache - MavenSession session = createMavenSession( getProject( "project-with-build-extensions-plugin" ) ); - MavenProject project = session.getCurrentProject(); - Plugin plugin = project.getPlugin( "org.apache.maven.its.plugins:maven-it-plugin" ); - - PluginDescriptor pluginDescriptor = - pluginManager.loadPlugin( plugin, session.getCurrentProject().getRemotePluginRepositories(), - session.getRepositorySession() ); - ClassRealm pluginRealm = pluginManager.getPluginRealm( session, pluginDescriptor ); - - assertEquals(pluginRealm, pluginDescriptor.getComponents().get(0).getRealm()); - } -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExceptionTest.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExceptionTest.java deleted file mode 100644 index ead7ae2e..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExceptionTest.java +++ /dev/null @@ -1,164 +0,0 @@ -package org.apache.maven.plugin; - -/* - * 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 org.apache.maven.plugin.descriptor.MojoDescriptor; -import org.apache.maven.plugin.descriptor.Parameter; -import org.apache.maven.plugin.descriptor.PluginDescriptor; - -import junit.framework.TestCase; - -/** - * MNG-3131 - * - * @author Robert Scholte - * - */ -public class PluginParameterExceptionTest - extends TestCase -{ - - public void testMissingRequiredStringArrayTypeParameter() - { - MojoDescriptor mojoDescriptor = new MojoDescriptor(); - mojoDescriptor.setGoal( "goal" ); - PluginDescriptor pluginDescriptor = new PluginDescriptor(); - pluginDescriptor.setGoalPrefix( "goalPrefix" ); - pluginDescriptor.setArtifactId( "artifactId" ); - mojoDescriptor.setPluginDescriptor( pluginDescriptor ); - - Parameter parameter = new Parameter(); - parameter.setType( "java.lang.String[]" ); - parameter.setName( "toAddresses" ); - - parameter.setRequired( true ); - - PluginParameterException exception = - new PluginParameterException( mojoDescriptor, Collections.singletonList( parameter ) ); - - assertEquals( "One or more required plugin parameters are invalid/missing for 'goalPrefix:goal'\n" + - "\n" + - "[0] Inside the definition for plugin 'artifactId', specify the following:\n" + - "\n" + - "<configuration>\n" + - " ...\n" + - " <toAddresses>\n" + - " <item>VALUE</item>\n" + - " </toAddresses>\n" + - "</configuration>.\n", exception.buildDiagnosticMessage() ); - } - - public void testMissingRequiredCollectionTypeParameter() - { - MojoDescriptor mojoDescriptor = new MojoDescriptor(); - mojoDescriptor.setGoal( "goal" ); - PluginDescriptor pluginDescriptor = new PluginDescriptor(); - pluginDescriptor.setGoalPrefix( "goalPrefix" ); - pluginDescriptor.setArtifactId( "artifactId" ); - mojoDescriptor.setPluginDescriptor( pluginDescriptor ); - - Parameter parameter = new Parameter(); - parameter.setType( "java.util.List" ); - parameter.setName( "toAddresses" ); - - parameter.setRequired( true ); - - PluginParameterException exception = - new PluginParameterException( mojoDescriptor, Collections.singletonList( parameter ) ); - - assertEquals( "One or more required plugin parameters are invalid/missing for 'goalPrefix:goal'\n" + - "\n" + - "[0] Inside the definition for plugin 'artifactId', specify the following:\n" + - "\n" + - "<configuration>\n" + - " ...\n" + - " <toAddresses>\n" + - " <item>VALUE</item>\n" + - " </toAddresses>\n" + - "</configuration>.\n", exception.buildDiagnosticMessage() ); - } - - public void testMissingRequiredMapTypeParameter() - { - MojoDescriptor mojoDescriptor = new MojoDescriptor(); - mojoDescriptor.setGoal( "goal" ); - PluginDescriptor pluginDescriptor = new PluginDescriptor(); - pluginDescriptor.setGoalPrefix( "goalPrefix" ); - pluginDescriptor.setArtifactId( "artifactId" ); - mojoDescriptor.setPluginDescriptor( pluginDescriptor ); - - Parameter parameter = new Parameter(); - parameter.setType( "java.util.Map" ); - parameter.setName( "toAddresses" ); - - parameter.setRequired( true ); - - PluginParameterException exception = - new PluginParameterException( mojoDescriptor, Collections.singletonList( parameter ) ); - - assertEquals( "One or more required plugin parameters are invalid/missing for 'goalPrefix:goal'\n" + - "\n" + - "[0] Inside the definition for plugin 'artifactId', specify the following:\n" + - "\n" + - "<configuration>\n" + - " ...\n" + - " <toAddresses>\n" + - " <KEY>VALUE</KEY>\n" + - " </toAddresses>\n" + - "</configuration>.\n", exception.buildDiagnosticMessage() ); - } - - public void testMissingRequiredPropertiesTypeParameter() - { - MojoDescriptor mojoDescriptor = new MojoDescriptor(); - mojoDescriptor.setGoal( "goal" ); - PluginDescriptor pluginDescriptor = new PluginDescriptor(); - pluginDescriptor.setGoalPrefix( "goalPrefix" ); - pluginDescriptor.setArtifactId( "artifactId" ); - mojoDescriptor.setPluginDescriptor( pluginDescriptor ); - - Parameter parameter = new Parameter(); - parameter.setType( "java.util.Properties" ); - parameter.setName( "toAddresses" ); - - parameter.setRequired( true ); - - PluginParameterException exception = - new PluginParameterException( mojoDescriptor, Collections.singletonList( parameter ) ); - - assertEquals( "One or more required plugin parameters are invalid/missing for 'goalPrefix:goal'\n" + - "\n" + - "[0] Inside the definition for plugin 'artifactId', specify the following:\n" + - "\n" + - "<configuration>\n" + - " ...\n" + - " <toAddresses>\n" + - " <property>\n" + - " <name>KEY</name>\n" + - " <value>VALUE</value>\n" + - " </property>\n" + - " </toAddresses>\n" + - "</configuration>.\n", exception.buildDiagnosticMessage() ); - } - - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java deleted file mode 100644 index 5f6744c9..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java +++ /dev/null @@ -1,447 +0,0 @@ -package org.apache.maven.plugin; - -/* - * 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.io.File; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Properties; - -import org.apache.maven.AbstractCoreMavenComponentTestCase; -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.ArtifactUtils; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.execution.DefaultMavenExecutionRequest; -import org.apache.maven.execution.DefaultMavenExecutionResult; -import org.apache.maven.execution.MavenExecutionRequest; -import org.apache.maven.execution.MavenSession; -import org.apache.maven.model.Build; -import org.apache.maven.model.Dependency; -import org.apache.maven.model.Model; -import org.apache.maven.plugin.descriptor.MojoDescriptor; -import org.apache.maven.plugin.descriptor.PluginDescriptor; -import org.apache.maven.project.DuplicateProjectException; -import org.apache.maven.project.MavenProject; -import org.apache.maven.repository.RepositorySystem; -import org.codehaus.plexus.MutablePlexusContainer; -import org.codehaus.plexus.PlexusContainer; -import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; -import org.codehaus.plexus.util.dag.CycleDetectedException; - -/** - * @author Jason van Zyl - */ -public class PluginParameterExpressionEvaluatorTest - extends AbstractCoreMavenComponentTestCase -{ - private static final String FS = System.getProperty( "file.separator" ); - - private RepositorySystem factory; - - public void setUp() - throws Exception - { - super.setUp(); - factory = lookup( RepositorySystem.class ); - } - - @Override - protected void tearDown() - throws Exception - { - factory = null; - super.tearDown(); - } - - public void testPluginDescriptorExpressionReference() - throws Exception - { - MojoExecution exec = newMojoExecution(); - - MavenSession session = newMavenSession(); - - Object result = new PluginParameterExpressionEvaluator( session, exec ).evaluate( "${plugin}" ); - - System.out.println( "Result: " + result ); - - assertSame( "${plugin} expression does not return plugin descriptor.", - exec.getMojoDescriptor().getPluginDescriptor(), - result ); - } - - public void testPluginArtifactsExpressionReference() - throws Exception - { - MojoExecution exec = newMojoExecution(); - - Artifact depArtifact = createArtifact( "group", "artifact", "1" ); - - List<Artifact> deps = new ArrayList<Artifact>(); - deps.add( depArtifact ); - - exec.getMojoDescriptor().getPluginDescriptor().setArtifacts( deps ); - - MavenSession session = newMavenSession(); - - @SuppressWarnings( "unchecked" ) - List<Artifact> depResults = - (List<Artifact>) new PluginParameterExpressionEvaluator( session, exec ).evaluate( "${plugin.artifacts}" ); - - System.out.println( "Result: " + depResults ); - - assertNotNull( depResults ); - assertEquals( 1, depResults.size() ); - assertSame( "dependency artifact is wrong.", depArtifact, depResults.get( 0 ) ); - } - - public void testPluginArtifactMapExpressionReference() - throws Exception - { - MojoExecution exec = newMojoExecution(); - - Artifact depArtifact = createArtifact( "group", "artifact", "1" ); - - List<Artifact> deps = new ArrayList<Artifact>(); - deps.add( depArtifact ); - - exec.getMojoDescriptor().getPluginDescriptor().setArtifacts( deps ); - - MavenSession session = newMavenSession(); - - @SuppressWarnings( "unchecked" ) - Map<String, Artifact> depResults = - (Map<String, Artifact>) new PluginParameterExpressionEvaluator( session, exec ).evaluate( "${plugin.artifactMap}" ); - - System.out.println( "Result: " + depResults ); - - assertNotNull( depResults ); - assertEquals( 1, depResults.size() ); - assertSame( "dependency artifact is wrong.", - depArtifact, - depResults.get( ArtifactUtils.versionlessKey( depArtifact ) ) ); - } - - public void testPluginArtifactIdExpressionReference() - throws Exception - { - MojoExecution exec = newMojoExecution(); - - MavenSession session = newMavenSession(); - - Object result = new PluginParameterExpressionEvaluator( session, exec ).evaluate( "${plugin.artifactId}" ); - - System.out.println( "Result: " + result ); - - assertSame( "${plugin.artifactId} expression does not return plugin descriptor's artifactId.", - exec.getMojoDescriptor().getPluginDescriptor().getArtifactId(), - result ); - } - - public void testValueExtractionWithAPomValueContainingAPath() - throws Exception - { - String expected = getTestFile( "target/test-classes/target/classes" ).getCanonicalPath(); - - Build build = new Build(); - build.setDirectory( expected.substring( 0, expected.length() - "/classes".length() ) ); - - Model model = new Model(); - model.setBuild( build ); - - MavenProject project = new MavenProject( model ); - project.setFile( new File( "pom.xml" ).getCanonicalFile() ); - - ExpressionEvaluator expressionEvaluator = createExpressionEvaluator( project, null, new Properties() ); - - Object value = expressionEvaluator.evaluate( "${project.build.directory}/classes" ); - String actual = new File( value.toString() ).getCanonicalPath(); - - assertEquals( expected, actual ); - } - - public void testEscapedVariablePassthrough() - throws Exception - { - String var = "${var}"; - - Model model = new Model(); - model.setVersion( "1" ); - - MavenProject project = new MavenProject( model ); - - ExpressionEvaluator ee = createExpressionEvaluator( project, null, new Properties() ); - - Object value = ee.evaluate( "$" + var ); - - assertEquals( var, value ); - } - - public void testEscapedVariablePassthroughInLargerExpression() - throws Exception - { - String var = "${var}"; - String key = var + " with version: ${project.version}"; - - Model model = new Model(); - model.setVersion( "1" ); - - MavenProject project = new MavenProject( model ); - - ExpressionEvaluator ee = createExpressionEvaluator( project, null, new Properties() ); - - Object value = ee.evaluate( "$" + key ); - - assertEquals( "${var} with version: 1", value ); - } - - public void testMultipleSubExpressionsInLargerExpression() - throws Exception - { - String key = "${project.artifactId} with version: ${project.version}"; - - Model model = new Model(); - model.setArtifactId( "test" ); - model.setVersion( "1" ); - - MavenProject project = new MavenProject( model ); - - ExpressionEvaluator ee = createExpressionEvaluator( project, null, new Properties() ); - - Object value = ee.evaluate( key ); - - assertEquals( "test with version: 1", value ); - } - - public void testMissingPOMPropertyRefInLargerExpression() - throws Exception - { - String expr = "/path/to/someproject-${baseVersion}"; - - MavenProject project = new MavenProject( new Model() ); - - ExpressionEvaluator ee = createExpressionEvaluator( project, null, new Properties() ); - - Object value = ee.evaluate( expr ); - - assertEquals( expr, value ); - } - - public void testPOMPropertyExtractionWithMissingProject_WithDotNotation() - throws Exception - { - String key = "m2.name"; - String checkValue = "value"; - - Properties properties = new Properties(); - properties.setProperty( key, checkValue ); - - Model model = new Model(); - model.setProperties( properties ); - - MavenProject project = new MavenProject( model ); - - ExpressionEvaluator ee = createExpressionEvaluator( project, null, new Properties() ); - - Object value = ee.evaluate( "${" + key + "}" ); - - assertEquals( checkValue, value ); - } - - public void testBasedirExtractionWithMissingProject() - throws Exception - { - ExpressionEvaluator ee = createExpressionEvaluator( null, null, new Properties() ); - - Object value = ee.evaluate( "${basedir}" ); - - assertEquals( System.getProperty( "user.dir" ), value ); - } - - public void testValueExtractionFromSystemPropertiesWithMissingProject() - throws Exception - { - String sysprop = "PPEET_sysprop1"; - - Properties executionProperties = new Properties(); - - if ( executionProperties.getProperty( sysprop ) == null ) - { - executionProperties.setProperty( sysprop, "value" ); - } - - ExpressionEvaluator ee = createExpressionEvaluator( null, null, executionProperties ); - - Object value = ee.evaluate( "${" + sysprop + "}" ); - - assertEquals( "value", value ); - } - - public void testValueExtractionFromSystemPropertiesWithMissingProject_WithDotNotation() - throws Exception - { - String sysprop = "PPEET.sysprop2"; - - Properties executionProperties = new Properties(); - - if ( executionProperties.getProperty( sysprop ) == null ) - { - executionProperties.setProperty( sysprop, "value" ); - } - - ExpressionEvaluator ee = createExpressionEvaluator( null, null, executionProperties ); - - Object value = ee.evaluate( "${" + sysprop + "}" ); - - assertEquals( "value", value ); - } - - @SuppressWarnings( "deprecation" ) - private static MavenSession createSession( PlexusContainer container, ArtifactRepository repo, Properties properties ) - throws CycleDetectedException, DuplicateProjectException - { - MavenExecutionRequest request = new DefaultMavenExecutionRequest() - .setSystemProperties( properties ) - .setGoals( Collections.<String>emptyList() ) - .setBaseDirectory( new File( "" ) ) - .setLocalRepository( repo ); - - return new MavenSession( container, request, new DefaultMavenExecutionResult(), Collections.<MavenProject>emptyList() ); - } - - public void testLocalRepositoryExtraction() - throws Exception - { - ExpressionEvaluator expressionEvaluator = - createExpressionEvaluator( createDefaultProject(), null, new Properties() ); - Object value = expressionEvaluator.evaluate( "${localRepository}" ); - - assertEquals( "local", ( (ArtifactRepository) value ).getId() ); - } - - public void testTwoExpressions() - throws Exception - { - Build build = new Build(); - build.setDirectory( "expected-directory" ); - build.setFinalName( "expected-finalName" ); - - Model model = new Model(); - model.setBuild( build ); - - ExpressionEvaluator expressionEvaluator = - createExpressionEvaluator( new MavenProject( model ), null, new Properties() ); - - Object value = expressionEvaluator.evaluate( "${project.build.directory}" + FS + "${project.build.finalName}" ); - - assertEquals( "expected-directory" + File.separatorChar + "expected-finalName", value ); - } - - public void testShouldExtractPluginArtifacts() - throws Exception - { - PluginDescriptor pd = new PluginDescriptor(); - - Artifact artifact = createArtifact( "testGroup", "testArtifact", "1.0" ); - - pd.setArtifacts( Collections.singletonList( artifact ) ); - - ExpressionEvaluator ee = createExpressionEvaluator( createDefaultProject(), pd, new Properties() ); - - Object value = ee.evaluate( "${plugin.artifacts}" ); - - assertTrue( value instanceof List ); - - @SuppressWarnings( "unchecked" ) - List<Artifact> artifacts = (List<Artifact>) value; - - assertEquals( 1, artifacts.size() ); - - Artifact result = artifacts.get( 0 ); - - assertEquals( "testGroup", result.getGroupId() ); - } - - private MavenProject createDefaultProject() - { - return new MavenProject( new Model() ); - } - - private ExpressionEvaluator createExpressionEvaluator( MavenProject project, PluginDescriptor pluginDescriptor, Properties executionProperties ) - throws Exception - { - ArtifactRepository repo = factory.createDefaultLocalRepository(); - - MutablePlexusContainer container = (MutablePlexusContainer) getContainer(); - MavenSession session = createSession( container, repo, executionProperties ); - session.setCurrentProject( project ); - - MojoDescriptor mojo = new MojoDescriptor(); - mojo.setPluginDescriptor( pluginDescriptor ); - mojo.setGoal( "goal" ); - - MojoExecution mojoExecution = new MojoExecution( mojo ); - - return new PluginParameterExpressionEvaluator( session, mojoExecution ); - } - - protected Artifact createArtifact( String groupId, String artifactId, String version ) - throws Exception - { - Dependency dependency = new Dependency(); - dependency.setGroupId( groupId ); - dependency.setArtifactId( artifactId ); - dependency.setVersion( version ); - dependency.setType( "jar" ); - dependency.setScope( "compile" ); - - return factory.createDependencyArtifact( dependency ); - } - - private MojoExecution newMojoExecution() - { - PluginDescriptor pd = new PluginDescriptor(); - pd.setArtifactId( "my-plugin" ); - pd.setGroupId( "org.myco.plugins" ); - pd.setVersion( "1" ); - - MojoDescriptor md = new MojoDescriptor(); - md.setPluginDescriptor( pd ); - - pd.addComponentDescriptor( md ); - - return new MojoExecution( md ); - } - - private MavenSession newMavenSession() - throws Exception - { - return createMavenSession( null ); - } - - @Override - protected String getProjectsDirectory() - { - // TODO Auto-generated method stub - return null; - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/plugin/internal/DefaultLegacySupportTest.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/plugin/internal/DefaultLegacySupportTest.java deleted file mode 100644 index d350770c..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/plugin/internal/DefaultLegacySupportTest.java +++ /dev/null @@ -1,74 +0,0 @@ -package org.apache.maven.plugin.internal; -/* - * 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 junit.framework.TestCase; -import org.apache.maven.execution.DefaultMavenExecutionRequest; -import org.apache.maven.execution.MavenExecutionRequest; -import org.apache.maven.execution.MavenSession; - -import java.util.concurrent.CountDownLatch; - -/** - * @author Kristian Rosenvold - */ -public class DefaultLegacySupportTest extends TestCase { - final CountDownLatch latch = new CountDownLatch(1); - final DefaultLegacySupport defaultLegacySupport = new DefaultLegacySupport(); - - public void testSetSession() throws Exception { - - MavenExecutionRequest mavenExecutionRequest = new DefaultMavenExecutionRequest(); - MavenSession m1 = new MavenSession(null, null, mavenExecutionRequest, null); - defaultLegacySupport.setSession(m1); - - MyRunnable myRunnable = new MyRunnable(); - Thread thread = new Thread(myRunnable); - thread.start(); - - MavenSession m2 = new MavenSession(null, null, mavenExecutionRequest, null); - defaultLegacySupport.setSession(m2); - latch.countDown(); - thread.join(); - assertNull( myRunnable.getSession()); - } - - - class MyRunnable implements Runnable { - - private volatile MavenSession session; - - public void run() { - try - { - latch.await(); - } - catch (InterruptedException ingore) - { - // Test may fail if we get interrupted - } - session = defaultLegacySupport.getSession(); - } - - public MavenSession getSession() { - return session; - } - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java deleted file mode 100644 index 73bdbcae..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java +++ /dev/null @@ -1,189 +0,0 @@ -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.io.File; -import java.io.FileNotFoundException; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; -import java.util.Arrays; - -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; -import org.apache.maven.model.building.ModelBuildingException; -import org.apache.maven.model.building.ModelProblem; -import org.apache.maven.repository.RepositorySystem; -import org.apache.maven.repository.internal.MavenRepositorySystemUtils; -import org.codehaus.plexus.ContainerConfiguration; -import org.codehaus.plexus.PlexusConstants; -import org.codehaus.plexus.PlexusTestCase; -import org.eclipse.aether.DefaultRepositorySystemSession; - -/** - * @author Jason van Zyl - */ -public abstract class AbstractMavenProjectTestCase - extends PlexusTestCase -{ - protected ProjectBuilder projectBuilder; - - protected RepositorySystem repositorySystem; - - @Override - protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration ) - { - super.customizeContainerConfiguration( containerConfiguration ); - containerConfiguration.setAutoWiring( true ); - containerConfiguration.setClassPathScanning( PlexusConstants.SCANNING_INDEX ); - } - - protected void setUp() - throws Exception - { - super.setUp(); - - if ( getContainer().hasComponent( ProjectBuilder.class, "test" ) ) - { - projectBuilder = lookup( ProjectBuilder.class, "test" ); - } - else - { - // default over to the main project builder... - projectBuilder = lookup( ProjectBuilder.class ); - } - - repositorySystem = lookup( RepositorySystem.class ); - } - - @Override - protected void tearDown() - throws Exception - { - projectBuilder = null; - - super.tearDown(); - } - - protected ProjectBuilder getProjectBuilder() - { - return projectBuilder; - } - - @Override - protected String getCustomConfigurationName() - { - String name = AbstractMavenProjectTestCase.class.getName().replace( '.', '/' ) + ".xml"; - System.out.println( name ); - return name; - } - - // ---------------------------------------------------------------------- - // Local repository - // ---------------------------------------------------------------------- - - protected File getLocalRepositoryPath() - throws FileNotFoundException, URISyntaxException - { - File markerFile = getFileForClasspathResource( "local-repo/marker.txt" ); - - return markerFile.getAbsoluteFile().getParentFile(); - } - - protected static File getFileForClasspathResource( String resource ) - throws FileNotFoundException - { - ClassLoader cloader = Thread.currentThread().getContextClassLoader(); - - URL resourceUrl = cloader.getResource( resource ); - - if ( resourceUrl == null ) - { - throw new FileNotFoundException( "Unable to find: " + resource ); - } - - return new File( URI.create( resourceUrl.toString().replaceAll( " ", "%20" ) ) ); - } - - protected ArtifactRepository getLocalRepository() - throws Exception - { - ArtifactRepositoryLayout repoLayout = lookup( ArtifactRepositoryLayout.class, "legacy" ); - - ArtifactRepository r = repositorySystem.createArtifactRepository( "local", "file://" + getLocalRepositoryPath().getAbsolutePath(), repoLayout, null, null ); - - return r; - } - - // ---------------------------------------------------------------------- - // Project building - // ---------------------------------------------------------------------- - - protected MavenProject getProjectWithDependencies( File pom ) - throws Exception - { - ProjectBuildingRequest configuration = newBuildingRequest(); - configuration.setRemoteRepositories( Arrays.asList( new ArtifactRepository[] {} ) ); - configuration.setProcessPlugins( false ); - configuration.setResolveDependencies( true ); - - try - { - return projectBuilder.build( pom, configuration ).getProject(); - } - catch ( Exception e ) - { - Throwable cause = e.getCause(); - if ( cause instanceof ModelBuildingException ) - { - String message = "In: " + pom + "\n\n"; - for ( ModelProblem problem : ( (ModelBuildingException) cause ).getProblems() ) - { - message += problem + "\n"; - } - System.out.println( message ); - } - - throw e; - } - } - - protected MavenProject getProject( File pom ) - throws Exception - { - ProjectBuildingRequest configuration = newBuildingRequest(); - - return projectBuilder.build( pom, configuration ).getProject(); - } - - protected ProjectBuildingRequest newBuildingRequest() - throws Exception - { - ProjectBuildingRequest configuration = new DefaultProjectBuildingRequest(); - configuration.setLocalRepository( getLocalRepository() ); - initRepoSession( configuration ); - return configuration; - } - - protected void initRepoSession( ProjectBuildingRequest request ) - { - File localRepo = new File( request.getLocalRepository().getBasedir() ); - DefaultRepositorySystemSession repoSession = MavenRepositorySystemUtils.newSession(); - repoSession.setLocalRepositoryManager( new LegacyLocalRepositoryManager( localRepo ) ); - request.setRepositorySession( repoSession ); - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/DefaultMavenProjectBuilderTest.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/DefaultMavenProjectBuilderTest.java deleted file mode 100644 index 13c32abb..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/DefaultMavenProjectBuilderTest.java +++ /dev/null @@ -1,193 +0,0 @@ -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.io.File; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; -import org.codehaus.plexus.util.FileUtils; - -public class DefaultMavenProjectBuilderTest - extends AbstractMavenProjectTestCase -{ - - private List<File> filesToDelete = new ArrayList<File>(); - - private File localRepoDir; - - @Override - public void setUp() - throws Exception - { - super.setUp(); - - projectBuilder = lookup( ProjectBuilder.class ); - - localRepoDir = new File( System.getProperty( "java.io.tmpdir" ), "local-repo." + System.currentTimeMillis() ); - localRepoDir.mkdirs(); - - filesToDelete.add( localRepoDir ); - } - - @Override - public void tearDown() - throws Exception - { - super.tearDown(); - - if ( !filesToDelete.isEmpty() ) - { - for ( File file : filesToDelete ) - { - if ( file.exists() ) - { - if ( file.isDirectory() ) - { - FileUtils.deleteDirectory( file ); - } - else - { - file.delete(); - } - } - } - } - } - - protected MavenProject getProject( Artifact pom, boolean allowStub ) - throws Exception - { - ProjectBuildingRequest configuration = new DefaultProjectBuildingRequest(); - configuration.setLocalRepository( getLocalRepository() ); - initRepoSession( configuration ); - - return projectBuilder.build( pom, allowStub, configuration ).getProject(); - } - - /** - * Check that we can build ok from the middle pom of a (parent,child,grandchild) heirarchy - * @throws Exception - */ - public void testBuildFromMiddlePom() throws Exception - { - File f1 = getTestFile( "src/test/resources/projects/grandchild-check/child/pom.xml"); - File f2 = getTestFile( "src/test/resources/projects/grandchild-check/child/grandchild/pom.xml"); - - getProject( f1 ); - - // it's the building of the grandchild project, having already cached the child project - // (but not the parent project), which causes the problem. - getProject( f2 ); - } - - public void testDuplicatePluginDefinitionsMerged() - throws Exception - { - File f1 = getTestFile( "src/test/resources/projects/duplicate-plugins-merged-pom.xml" ); - - MavenProject project = getProject( f1 ); - assertEquals( 2, project.getBuildPlugins().get( 0 ).getDependencies().size() ); - assertEquals( 2, project.getBuildPlugins().get( 0 ).getExecutions().size() ); - assertEquals( "first", project.getBuildPlugins().get( 0 ).getExecutions().get( 0 ).getId() ); - } - - public void testBuildStubModelForMissingRemotePom() - throws Exception - { - Artifact pom = repositorySystem.createProjectArtifact( "org.apache.maven.its", "missing", "0.1" ); - MavenProject project = getProject( pom, true ); - - assertNotNull( project.getArtifactId() ); - - assertNotNull( project.getRemoteArtifactRepositories() ); - assertFalse( project.getRemoteArtifactRepositories().isEmpty() ); - - assertNotNull( project.getPluginArtifactRepositories() ); - assertFalse( project.getPluginArtifactRepositories().isEmpty() ); - - assertNull( project.getParent() ); - assertNull( project.getParentArtifact() ); - - assertFalse( project.isExecutionRoot() ); - } - - @Override - protected ArtifactRepository getLocalRepository() - throws Exception - { - ArtifactRepositoryLayout repoLayout = lookup( ArtifactRepositoryLayout.class, "default" ); - ArtifactRepository r = - repositorySystem.createArtifactRepository( "local", "file://" + localRepoDir.getAbsolutePath(), repoLayout, - null, null ); - return r; - } - - public void xtestLoop() - throws Exception - { - while ( true ) - { - File f1 = getTestFile( "src/test/resources/projects/duplicate-plugins-merged-pom.xml" ); - getProject( f1 ); - } - } - - public void testPartialResultUponBadDependencyDeclaration() - throws Exception - { - File pomFile = getTestFile( "src/test/resources/projects/bad-dependency.xml" ); - - try - { - ProjectBuildingRequest request = newBuildingRequest(); - request.setProcessPlugins( false ); - request.setResolveDependencies( true ); - projectBuilder.build( pomFile, request ); - fail( "Project building did not fail despite invalid POM" ); - } - catch ( ProjectBuildingException e ) - { - List<ProjectBuildingResult> results = e.getResults(); - assertNotNull( results ); - assertEquals( 1, results.size() ); - ProjectBuildingResult result = results.get( 0 ); - assertNotNull( result ); - assertNotNull( result.getProject() ); - assertEquals( 1, result.getProblems().size() ); - assertEquals( 1, result.getProject().getArtifacts().size() ); - assertNotNull( result.getDependencyResolutionResult() ); - } - } - - public void testImportScopePomResolvesFromPropertyBasedRepository() - throws Exception - { - File pomFile = getTestFile( "src/test/resources/projects/import-scope-pom-resolves-from-property-based-repository.xml" ); - ProjectBuildingRequest request = newBuildingRequest(); - request.setProcessPlugins( false ); - request.setResolveDependencies( true ); - projectBuilder.build( pomFile, request ); - } -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java deleted file mode 100644 index 8ff912fb..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java +++ /dev/null @@ -1,109 +0,0 @@ -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.LinkedHashSet; -import java.util.List; -import java.util.Set; - -import org.apache.maven.execution.MavenSession; -import org.apache.maven.lifecycle.LifecycleExecutor; -import org.apache.maven.lifecycle.MavenExecutionPlan; -import org.apache.maven.model.Plugin; -import org.apache.maven.model.PluginExecution; -import org.apache.maven.plugin.MojoExecution; - -/** - * 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 MavenExecutionPlan calculateExecutionPlan( MavenSession session, String... tasks ) - { - return new MavenExecutionPlan( null, null ); - } - - public MavenExecutionPlan calculateExecutionPlan( MavenSession session, boolean setup, String... tasks ) - { - return new MavenExecutionPlan( null, null ); - } - - public void execute( MavenSession session ) - { - } - - public Set<Plugin> getPluginsBoundByDefaultToAllLifecycles( String packaging ) - { - Set<Plugin> plugins; - - // NOTE: The upper-case packaging name is intentional, that's a special hinting mode used for certain tests - if ( "JAR".equals( packaging ) ) - { - plugins = new LinkedHashSet<Plugin>(); - - plugins.add( newPlugin( "maven-compiler-plugin", "compile", "testCompile" ) ); - plugins.add( newPlugin( "maven-resources-plugin", "resources", "testResources" ) ); - plugins.add( newPlugin( "maven-surefire-plugin", "test" ) ); - plugins.add( newPlugin( "maven-jar-plugin", "jar" ) ); - plugins.add( newPlugin( "maven-install-plugin", "install" ) ); - plugins.add( newPlugin( "maven-deploy-plugin", "deploy" ) ); - } - else - { - plugins = Collections.emptySet(); - } - - return plugins; - } - - private Plugin newPlugin( String artifactId, String... goals ) - { - Plugin plugin = new Plugin(); - - plugin.setGroupId( "org.apache.maven.plugins" ); - plugin.setArtifactId( artifactId ); - - for ( String goal : goals ) - { - PluginExecution pluginExecution = new PluginExecution(); - pluginExecution.setId( "default-" + goal ); - pluginExecution.addGoal( goal ); - plugin.addExecution( pluginExecution ); - } - - return plugin; - } - - public void calculateForkedExecutions( MojoExecution mojoExecution, MavenSession session ) - { - } - - public List<MavenProject> executeForkedExecutions( MojoExecution mojoExecution, MavenSession session ) - { - return Collections.emptyList(); - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/EmptyProjectBuildingHelper.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/EmptyProjectBuildingHelper.java deleted file mode 100644 index 21e37f1f..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/EmptyProjectBuildingHelper.java +++ /dev/null @@ -1,62 +0,0 @@ -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.ArrayList; -import java.util.List; - -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.model.Model; -import org.apache.maven.model.Repository; - -/** - * A stub implementation to bypass artifact resolution from repositories. - * - * @author Benjamin Bentmann - */ -public class EmptyProjectBuildingHelper - implements ProjectBuildingHelper -{ - - public List<ArtifactRepository> createArtifactRepositories( List<Repository> pomRepositories, - List<ArtifactRepository> externalRepositories, - ProjectBuildingRequest request ) - { - if ( externalRepositories != null ) - { - return externalRepositories; - } - else - { - return new ArrayList<ArtifactRepository>(); - } - } - - public ProjectRealmCache.CacheRecord createProjectRealm( MavenProject proejct, - Model model, ProjectBuildingRequest request ) - { - return new ProjectRealmCache.CacheRecord( null, null ); - } - - public void selectProjectRealm( MavenProject project ) - { - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/ExtensionDescriptorBuilderTest.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/ExtensionDescriptorBuilderTest.java deleted file mode 100644 index 68727013..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/ExtensionDescriptorBuilderTest.java +++ /dev/null @@ -1,101 +0,0 @@ -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.io.ByteArrayInputStream; -import java.io.InputStream; -import java.io.UnsupportedEncodingException; -import java.util.Arrays; - -import junit.framework.TestCase; - -/** - * Tests {@link ExtensionDescriptorBuilder}. - * - * @author Benjamin Bentmann - */ -public class ExtensionDescriptorBuilderTest - extends TestCase -{ - - private ExtensionDescriptorBuilder builder; - - @Override - protected void setUp() - throws Exception - { - super.setUp(); - - builder = new ExtensionDescriptorBuilder(); - } - - @Override - protected void tearDown() - throws Exception - { - builder = null; - - super.tearDown(); - } - - private InputStream toStream( String xml ) - { - try - { - return new ByteArrayInputStream( xml.getBytes( "UTF-8" ) ); - } - catch ( UnsupportedEncodingException e ) - { - throw new IllegalStateException( e ); - } - } - - public void testEmptyDescriptor() - throws Exception - { - String xml = "<extension></extension>"; - - ExtensionDescriptor ed = builder.build( toStream( xml ) ); - - assertNotNull( ed ); - assertNotNull( ed.getExportedPackages() ); - assertTrue( ed.getExportedPackages().isEmpty() ); - assertNotNull( ed.getExportedArtifacts() ); - assertTrue( ed.getExportedArtifacts().isEmpty() ); - } - - public void testCompleteDescriptor() - throws Exception - { - String xml = - "<?xml version='1.0' encoding='UTF-8'?>" + "<extension>" + "<exportedPackages>" - + "<exportedPackage>a</exportedPackage>" + "<exportedPackage>b</exportedPackage>" - + "<exportedPackage>c</exportedPackage>" + "</exportedPackages>" + "<exportedArtifacts>" - + "<exportedArtifact>x</exportedArtifact>" + "<exportedArtifact>y</exportedArtifact>" - + "<exportedArtifact> z </exportedArtifact>" + "</exportedArtifacts>" + "</extension>"; - - ExtensionDescriptor ed = builder.build( toStream( xml ) ); - - assertNotNull( ed ); - assertEquals( Arrays.asList( "a", "b", "c" ), ed.getExportedPackages() ); - assertEquals( Arrays.asList( "x", "y", "z" ), ed.getExportedArtifacts() ); - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/LegacyLocalRepositoryManager.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/LegacyLocalRepositoryManager.java deleted file mode 100644 index 52fdd804..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/LegacyLocalRepositoryManager.java +++ /dev/null @@ -1,192 +0,0 @@ -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.io.File; - -import org.eclipse.aether.RepositorySystemSession; -import org.eclipse.aether.artifact.Artifact; -import org.eclipse.aether.metadata.Metadata; -import org.eclipse.aether.repository.LocalArtifactRegistration; -import org.eclipse.aether.repository.LocalArtifactRequest; -import org.eclipse.aether.repository.LocalArtifactResult; -import org.eclipse.aether.repository.LocalMetadataRegistration; -import org.eclipse.aether.repository.LocalMetadataRequest; -import org.eclipse.aether.repository.LocalMetadataResult; -import org.eclipse.aether.repository.LocalRepository; -import org.eclipse.aether.repository.LocalRepositoryManager; -import org.eclipse.aether.repository.RemoteRepository; - -/** - * @author Benjamin Bentmann - */ -public class LegacyLocalRepositoryManager - implements LocalRepositoryManager -{ - - private final LocalRepository repository; - - public LegacyLocalRepositoryManager( File basedir ) - { - this.repository = new LocalRepository( basedir.getAbsoluteFile(), "legacy" ); - } - - public LocalRepository getRepository() - { - return repository; - } - - public String getPathForLocalArtifact( Artifact artifact ) - { - StringBuilder path = new StringBuilder( 128 ); - - path.append( artifact.getGroupId() ).append( '/' ); - - path.append( artifact.getExtension() ).append( 's' ).append( '/' ); - - path.append( artifact.getArtifactId() ).append( '-' ).append( artifact.getVersion() ); - - if ( artifact.getClassifier().length() > 0 ) - { - path.append( '-' ).append( artifact.getClassifier() ); - } - - path.append( '.' ).append( artifact.getExtension() ); - - return path.toString(); - } - - public String getPathForRemoteArtifact( Artifact artifact, RemoteRepository repository, String context ) - { - return getPathForLocalArtifact( artifact ); - } - - public String getPathForLocalMetadata( Metadata metadata ) - { - return getPath( metadata, "local" ); - } - - public String getPathForRemoteMetadata( Metadata metadata, RemoteRepository repository, String context ) - { - return getPath( metadata, getRepositoryKey( repository, context ) ); - } - - String getRepositoryKey( RemoteRepository repository, String context ) - { - return repository.getId(); - } - - private String getPath( Metadata metadata, String repositoryKey ) - { - StringBuilder path = new StringBuilder( 128 ); - - if ( metadata.getGroupId().length() > 0 ) - { - path.append( metadata.getGroupId().replace( '.', '/' ) ).append( '/' ); - - if ( metadata.getArtifactId().length() > 0 ) - { - path.append( metadata.getArtifactId() ).append( '/' ); - - if ( metadata.getVersion().length() > 0 ) - { - path.append( metadata.getVersion() ).append( '/' ); - } - } - } - - path.append( insertRepositoryKey( metadata.getType(), repositoryKey ) ); - - return path.toString(); - } - - private String insertRepositoryKey( String filename, String repositoryKey ) - { - String result; - int idx = filename.indexOf( '.' ); - if ( idx < 0 ) - { - result = filename + '-' + repositoryKey; - } - else - { - result = filename.substring( 0, idx ) + '-' + repositoryKey + filename.substring( idx ); - } - return result; - } - - public LocalArtifactResult find( RepositorySystemSession session, LocalArtifactRequest request ) - { - String path = getPathForLocalArtifact( request.getArtifact() ); - File file = new File( getRepository().getBasedir(), path ); - - LocalArtifactResult result = new LocalArtifactResult( request ); - if ( file.isFile() ) - { - result.setFile( file ); - result.setAvailable( true ); - } - - return result; - } - - public void add( RepositorySystemSession session, LocalArtifactRegistration request ) - { - // noop - } - - public LocalMetadataResult find( RepositorySystemSession session, LocalMetadataRequest request ) - { - LocalMetadataResult result = new LocalMetadataResult( request ); - - String path; - - Metadata metadata = request.getMetadata(); - String context = request.getContext(); - RemoteRepository remote = request.getRepository(); - - if ( remote != null ) - { - path = getPathForRemoteMetadata( metadata, remote, context ); - } - else - { - path = getPathForLocalMetadata( metadata ); - } - - File file = new File( getRepository().getBasedir(), path ); - if ( file.isFile() ) - { - result.setFile( file ); - } - - return result; - } - - public void add( RepositorySystemSession session, LocalMetadataRegistration request ) - { - // noop - } - - public String toString() - { - return String.valueOf( getRepository() ); - } -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/MavenProjectTest.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/MavenProjectTest.java deleted file mode 100644 index 0c5cd07d..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/MavenProjectTest.java +++ /dev/null @@ -1,197 +0,0 @@ -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.io.File; -import java.io.IOException; -import java.util.List; -import java.util.Map; -import java.util.concurrent.atomic.AtomicInteger; - -import org.apache.maven.lifecycle.internal.stub.LoggerStub; -import org.apache.maven.model.DependencyManagement; -import org.apache.maven.model.Model; -import org.apache.maven.model.Parent; -import org.apache.maven.model.Profile; - -public class MavenProjectTest - extends AbstractMavenProjectTestCase -{ - - public void testShouldInterpretChildPathAdjustmentBasedOnModulePaths() - throws IOException - { - Model parentModel = new Model(); - parentModel.addModule( "../child" ); - - MavenProject parentProject = new MavenProject( parentModel ); - - Model childModel = new Model(); - childModel.setArtifactId( "artifact" ); - - MavenProject childProject = new MavenProject( childModel ); - - File childFile = - new File( System.getProperty( "java.io.tmpdir" ), "maven-project-tests" + System.currentTimeMillis() - + "/child/pom.xml" ); - - childProject.setFile( childFile ); - - String adjustment = parentProject.getModulePathAdjustment( childProject ); - - assertNotNull( adjustment ); - - assertEquals( "..", adjustment ); - } - - public void testIdentityProtoInheritance() - { - Parent parent = new Parent(); - - parent.setGroupId( "test-group" ); - parent.setVersion( "1000" ); - parent.setArtifactId( "test-artifact" ); - - Model model = new Model(); - - model.setParent( parent ); - model.setArtifactId( "real-artifact" ); - - MavenProject project = new MavenProject( model ); - - assertEquals( "groupId proto-inheritance failed.", "test-group", project.getGroupId() ); - assertEquals( "artifactId is masked.", "real-artifact", project.getArtifactId() ); - assertEquals( "version proto-inheritance failed.", "1000", project.getVersion() ); - - // draw the NPE. - project.getId(); - } - - public void testEmptyConstructor() - { - MavenProject project = new MavenProject(); - - assertEquals( MavenProject.EMPTY_PROJECT_GROUP_ID + ":" + MavenProject.EMPTY_PROJECT_ARTIFACT_ID + ":jar:" - + MavenProject.EMPTY_PROJECT_VERSION, project.getId() ); - } - - public void testClone() - throws Exception - { - File f = getFileForClasspathResource( "canonical-pom.xml" ); - MavenProject projectToClone = getProject( f ); - - MavenProject clonedProject = projectToClone.clone(); - assertEquals( "maven-core", clonedProject.getArtifactId() ); - Map<?, ?> clonedMap = clonedProject.getManagedVersionMap(); - assertNotNull( "ManagedVersionMap not copied", clonedMap ); - assertTrue( "ManagedVersionMap is not empty", clonedMap.isEmpty() ); - } - - public void testCloneWithDependencyManagement() - throws Exception - { - File f = getFileForClasspathResource( "dependencyManagement-pom.xml" ); - MavenProject projectToClone = getProjectWithDependencies( f ); - DependencyManagement dep = projectToClone.getDependencyManagement(); - assertNotNull( "No dependencyManagement", dep ); - List<?> list = dep.getDependencies(); - assertNotNull( "No dependencies", list ); - assertTrue( "Empty dependency list", !list.isEmpty() ); - - Map<?, ?> map = projectToClone.getManagedVersionMap(); - assertNotNull( "No ManagedVersionMap", map ); - assertTrue( "ManagedVersionMap is empty", !map.isEmpty() ); - - MavenProject clonedProject = projectToClone.clone(); - assertEquals( "maven-core", clonedProject.getArtifactId() ); - Map<?, ?> clonedMap = clonedProject.getManagedVersionMap(); - assertNotNull( "ManagedVersionMap not copied", clonedMap ); - assertTrue( "ManagedVersionMap is empty", !clonedMap.isEmpty() ); - assertTrue( "ManagedVersionMap does not contain test key", - clonedMap.containsKey( "maven-test:maven-test-b:jar" ) ); - } - - public void testGetModulePathAdjustment() - throws IOException - { - Model moduleModel = new Model(); - - MavenProject module = new MavenProject( moduleModel ); - module.setFile( new File( "module-dir/pom.xml" ) ); - - Model parentModel = new Model(); - parentModel.addModule( "../module-dir" ); - - MavenProject parent = new MavenProject( parentModel ); - parent.setFile( new File( "parent-dir/pom.xml" ) ); - - String pathAdjustment = parent.getModulePathAdjustment( module ); - - assertEquals( "..", pathAdjustment ); - } - - public void testCloneWithDistributionManagement() - throws Exception - { - - File f = getFileForClasspathResource( "distributionManagement-pom.xml" ); - MavenProject projectToClone = getProject( f ); - - MavenProject clonedProject = projectToClone.clone(); - assertNotNull( "clonedProject - distributionManagement", clonedProject.getDistributionManagementArtifactRepository() ); - } - - public void testCloneWithActiveProfile() - throws Exception - { - - File f = getFileForClasspathResource( "withActiveByDefaultProfile-pom.xml" ); - MavenProject projectToClone = getProject( f ); - List<Profile> activeProfilesOrig = projectToClone.getActiveProfiles(); - - assertEquals( "Expecting 1 active profile", 1, activeProfilesOrig.size() ); - - MavenProject clonedProject = projectToClone.clone(); - - List<Profile> activeProfilesClone = clonedProject.getActiveProfiles(); - - assertEquals( "Expecting 1 active profile", 1, activeProfilesClone.size() ); - - assertNotSame( "The list of active profiles should have been cloned too but is same", activeProfilesOrig, - activeProfilesClone ); - } - - public void testUndefinedOutputDirectory() - throws Exception - { - MavenProject p = new MavenProject(); - assertNoNulls( p.getCompileClasspathElements() ); - assertNoNulls( p.getSystemClasspathElements() ); - assertNoNulls( p.getRuntimeClasspathElements() ); - assertNoNulls( p.getTestClasspathElements() ); - } - - private void assertNoNulls( List<String> elements ) - { - assertFalse( elements.contains( null ) ); - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java deleted file mode 100644 index f17539b1..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java +++ /dev/null @@ -1,1878 +0,0 @@ -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.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.Properties; - -import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; -import org.apache.maven.model.Plugin; -import org.apache.maven.model.PluginExecution; -import org.apache.maven.model.building.ModelBuildingRequest; -import org.apache.maven.project.harness.PomTestWrapper; -import org.apache.maven.repository.RepositorySystem; -import org.apache.maven.repository.internal.MavenRepositorySystemUtils; -import org.codehaus.plexus.ContainerConfiguration; -import org.codehaus.plexus.PlexusConstants; -import org.codehaus.plexus.PlexusTestCase; -import org.eclipse.aether.DefaultRepositorySystemSession; -import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory; -import org.eclipse.aether.repository.LocalRepository; - -public class PomConstructionTest - extends PlexusTestCase -{ - private static String BASE_DIR = "src/test"; - - private static String BASE_POM_DIR = BASE_DIR + "/resources-project-builder"; - - private static String BASE_MIXIN_DIR = BASE_DIR + "/resources-mixins"; - - private DefaultProjectBuilder projectBuilder; - - private RepositorySystem repositorySystem; - - private File testDirectory; - - @Override - protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration ) - { - super.customizeContainerConfiguration( containerConfiguration ); - containerConfiguration.setAutoWiring( true ); - containerConfiguration.setClassPathScanning( PlexusConstants.SCANNING_INDEX ); - } - - protected void setUp() - throws Exception - { - testDirectory = new File( getBasedir(), BASE_POM_DIR ); - new File( getBasedir(), BASE_MIXIN_DIR ); - projectBuilder = (DefaultProjectBuilder) lookup( ProjectBuilder.class ); - repositorySystem = lookup( RepositorySystem.class ); - } - - @Override - protected void tearDown() - throws Exception - { - projectBuilder = null; - - super.tearDown(); - } - - /** - * Will throw exception if url is empty. MNG-4050 - * - * @throws Exception - */ - - public void testEmptyUrl() - throws Exception - { - buildPom( "empty-distMng-repo-url" ); - } - - /** - * Tests that modules is not overriden by profile - * - * @throws Exception - */ - /* MNG-786*/ - public void testProfileModules() - throws Exception - { - PomTestWrapper pom = buildPom( "profile-module", "a" ); - assertEquals( "test-prop", pom.getValue( "properties[1]/b" ) );// verifies profile applied - assertEquals( 4, ( (List<?>) pom.getValue( "modules" ) ).size() ); - assertEquals( "module-2", pom.getValue( "modules[1]" ) ); - assertEquals( "module-1", pom.getValue( "modules[2]" ) ); - assertEquals( "module-3", pom.getValue( "modules[3]" ) ); - assertEquals( "module-4", pom.getValue( "modules[4]" ) ); - } - - /** - * Will throw exception if doesn't find parent(s) in build - * - * @throws Exception - */ - public void testParentInheritance() - throws Exception - { - buildPom( "parent-inheritance/sub" ); - } - - /*MNG-3995*/ - public void testExecutionConfigurationJoin() - throws Exception - { - PomTestWrapper pom = buildPom( "execution-configuration-join" ); - assertEquals( 2, ( (List<?>) pom.getValue( "build/plugins[1]/executions[1]/configuration[1]/fileset[1]" ) ).size() ); - } - - /*MNG-3803*/ - public void testPluginConfigProperties() - throws Exception - { - PomTestWrapper pom = buildPom( "plugin-config-properties" ); - assertEquals( "my.property", pom.getValue( "build/plugins[1]/configuration[1]/systemProperties[1]/property[1]/name" ) ); - } - - /*MNG-3900*/ - public void testProfilePropertiesInterpolation() - throws Exception - { - PomTestWrapper pom = buildPom( "profile-properties-interpolation", "interpolation-profile" ); - assertEquals( "PASSED", pom.getValue( "properties[1]/test" ) ); - assertEquals( "PASSED", pom.getValue( "properties[1]/property" ) ); - } - - - // Some better conventions for the test poms needs to be created and each of these tests - // that represent a verification of a specification item needs to be a couple lines at most. - // The expressions help a lot, but we need a clean to pick up a directory of POMs, automatically load - // them into a resolver, create the expression to extract the data to validate the Model, and the URI - // to validate the properties. We also need a way to navigate from the Tex specification documents to - // the test in question and vice versa. A little Eclipse plugin would do the trick. - public void testThatExecutionsWithoutIdsAreMergedAndTheChildWins() - throws Exception - { - PomTestWrapper tester = buildPom( "micromailer" ); - assertModelEquals( tester, "child-descriptor", "build/plugins[1]/executions[1]/goals[1]" ); - } - - /*MNG- - public void testDependencyScope() - throws Exception - { - PomTestWrapper pom = buildPom( "dependency-scope/sub" ); - - } - - /*MNG- 4010*/ - public void testDuplicateExclusionsDependency() - throws Exception - { - PomTestWrapper pom = buildPom( "duplicate-exclusions-dependency/sub" ); - assertEquals( 1, ( (List<?>) pom.getValue( "dependencies[1]/exclusions" ) ).size() ); - - } - - /*MNG- 4008*/ - public void testMultipleFilters() - throws Exception - { - PomTestWrapper pom = buildPom( "multiple-filters" ); - assertEquals( 4, ( (List<?>) pom.getValue( "build/filters" ) ).size() ); - - } - - /** MNG-4005: postponed to 3.1 - public void testValidationErrorUponNonUniqueDependencyKey() - throws Exception - { - try - { - buildPom( "unique-dependency-key/deps" ); - fail( "Non-unique dependency keys did not cause validation error" ); - } - catch ( ProjectBuildingException e ) - { - // expected - } - } - - public void testValidationErrorUponNonUniqueDependencyManagementKey() - throws Exception - { - try - { - buildPom( "unique-dependency-key/dep-mngt" ); - fail( "Non-unique dependency keys did not cause validation error" ); - } - catch ( ProjectBuildingException e ) - { - // expected - } - } - - public void testValidationErrorUponNonUniqueDependencyKeyInProfile() - throws Exception - { - try - { - buildPom( "unique-dependency-key/deps-in-profile" ); - fail( "Non-unique dependency keys did not cause validation error" ); - } - catch ( ProjectBuildingException e ) - { - // expected - } - } - - public void testValidationErrorUponNonUniqueDependencyManagementKeyInProfile() - throws Exception - { - try - { - buildPom( "unique-dependency-key/dep-mngt-in-profile" ); - fail( "Non-unique dependency keys did not cause validation error" ); - } - catch ( ProjectBuildingException e ) - { - // expected - } - } - */ - - public void testDuplicateDependenciesCauseLastDeclarationToBePickedInLenientMode() - throws Exception - { - PomTestWrapper pom = buildPom( "unique-dependency-key/deps", true, null ); - assertEquals( 1, ( (List<?>) pom.getValue( "dependencies" ) ).size() ); - assertEquals( "0.2", pom.getValue( "dependencies[1]/version" ) ); - } - - /* MNG-3567*/ - public void testParentInterpolation() - throws Exception - { - PomTestWrapper pom = buildPom( "parent-interpolation/sub" ); - pom = new PomTestWrapper( pom.getMavenProject().getParent() ); - assertEquals( "1.3.0-SNAPSHOT", pom.getValue( "build/plugins[1]/version" ) ); - } - -/* - public void testMaven() - throws Exception - { - PomTestWrapper pom = buildPomFromMavenProject( "maven-build/sub/pom.xml", null ); - - for( String s: pom.getMavenProject().getTestClasspathElements() ) - { - System.out.println( s ); - } - - } - */ - - /* MNG-3567*/ - public void testPluginManagementInherited() - throws Exception - { - PomTestWrapper pom = buildPom( "pluginmanagement-inherited/sub" ); - assertEquals( "1.0-alpha-21", pom.getValue( "build/plugins[1]/version" ) ); - } - - /* MNG-2174*/ - public void testPluginManagementDependencies() - throws Exception - { - PomTestWrapper pom = buildPom( "plugin-management-dependencies/sub", "test" ); - assertEquals( "1.0-alpha-21", pom.getValue( "build/plugins[1]/version" ) ); - assertEquals( "1.0", pom.getValue( "build/plugins[1]/dependencies[1]/version" ) ); - } - - - /* MNG-3877*/ - public void testReportingInterpolation() - throws Exception - { - PomTestWrapper pom = buildPom( "reporting-interpolation" ); - assertEquals( createPath( Arrays.asList( System.getProperty( "user.dir" ), "src", "test", - "resources-project-builder", "reporting-interpolation", "target", - "site" ) ), pom.getValue( "reporting/outputDirectory" ) ); - } - - - public void testPluginOrder() - throws Exception - { - PomTestWrapper pom = buildPom( "plugin-order" ); - assertEquals( "plexus-component-metadata", pom.getValue( "build/plugins[1]/artifactId" ) ); - assertEquals( "maven-surefire-plugin", pom.getValue( "build/plugins[2]/artifactId" ) ); - } - - public void testErroneousJoiningOfDifferentPluginsWithEqualDependencies() - throws Exception - { - PomTestWrapper pom = buildPom( "equal-plugin-deps" ); - assertEquals( "maven-it-plugin-a", pom.getValue( "build/plugins[1]/artifactId" ) ); - assertEquals( 1, ( (List<?>) pom.getValue( "build/plugins[1]/dependencies" ) ).size() ); - assertEquals( "maven-it-plugin-b", pom.getValue( "build/plugins[2]/artifactId" ) ); - assertEquals( 1, ( (List<?>) pom.getValue( "build/plugins[1]/dependencies" ) ).size() ); - } - - /** MNG-3821 */ - public void testErroneousJoiningOfDifferentPluginsWithEqualExecutionIds() - throws Exception - { - PomTestWrapper pom = buildPom( "equal-plugin-exec-ids" ); - assertEquals( "maven-it-plugin-a", pom.getValue( "build/plugins[1]/artifactId" ) ); - assertEquals( 1, ( (List<?>) pom.getValue( "build/plugins[1]/executions" ) ).size() ); - assertEquals( "maven-it-plugin-b", pom.getValue( "build/plugins[2]/artifactId" ) ); - assertEquals( 1, ( (List<?>) pom.getValue( "build/plugins[1]/executions" ) ).size() ); - assertEquals( "maven-it-plugin-a", pom.getValue( "reporting/plugins[1]/artifactId" ) ); - assertEquals( 1, ( (List<?>) pom.getValue( "reporting/plugins[1]/reportSets" ) ).size() ); - assertEquals( "maven-it-plugin-b", pom.getValue( "reporting/plugins[2]/artifactId" ) ); - assertEquals( 1, ( (List<?>) pom.getValue( "reporting/plugins[1]/reportSets" ) ).size() ); - } - - /** MNG-3998 */ - public void testExecutionConfiguration() - throws Exception - { - PomTestWrapper pom = buildPom( "execution-configuration" ); - assertEquals( 2, ( (List<?>) pom.getValue( "build/plugins[1]/executions" ) ).size() ); - assertEquals( "src/main/mdo/nexus.xml", - ( pom.getValue( "build/plugins[1]/executions[1]/configuration[1]/model" ) ) ); - assertEquals( "src/main/mdo/security.xml", - ( pom.getValue( "build/plugins[1]/executions[2]/configuration[1]/model" ) ) ); - } - - /* - public void testPluginConfigDuplicate() - throws Exception -{ - PomTestWrapper pom = buildPom( "plugin-config-duplicate/dup" ); -} -*/ - - - public void testSingleConfigurationInheritance() - throws Exception - { - PomTestWrapper pom = buildPom( "single-configuration-inheritance" ); - - assertEquals( 2, ( (List<?>) pom.getValue( "build/plugins[1]/executions[1]/configuration[1]/rules" ) ).size() ); - assertEquals( "2.0.6", - pom.getValue( "build/plugins[1]/executions[1]/configuration[1]/rules[1]/requireMavenVersion[1]/version" ) ); - assertEquals( "[1.4,)", - pom.getValue( "build/plugins[1]/executions[1]/configuration[1]/rules[1]/requireJavaVersion[1]/version" ) ); - } - - public void testConfigWithPluginManagement() - throws Exception - { - PomTestWrapper pom = buildPom( "config-with-plugin-mng" ); - assertEquals( 2, ( (List<?>) pom.getValue( "build/plugins[1]/executions" ) ).size() ); - assertEquals( "src/main/mdo/security.xml", pom.getValue( "build/plugins[1]/executions[2]/configuration[1]/model" ) ); - assertEquals( "1.0.8", pom.getValue( "build/plugins[1]/executions[1]/configuration[1]/version" ) ); - } - - /** MNG-3965 */ - public void testExecutionConfigurationSubcollections() - throws Exception - { - PomTestWrapper pom = buildPom( "execution-configuration-subcollections" ); - assertEquals( 2, ( (List<?>) pom.getValue( "build/plugins[1]/executions[1]/configuration[1]/rules[1]/bannedDependencies" ) ).size() ); - } - - /** MNG-3985 */ - public void testMultipleRepositories() - throws Exception - { - PomTestWrapper pom = buildPom( "multiple-repos/sub" ); - assertEquals( 3, ( (List<?>) pom.getValue( "repositories" ) ).size() ); - } - - /** MNG-3965 */ - public void testMultipleExecutionIds() - throws Exception - { - PomTestWrapper pom = buildPom( "dual-execution-ids/sub" ); - assertEquals( 1, ( (List<?>) pom.getValue( "build/plugins[1]/executions" ) ).size() ); - } - - /** MNG-3997 */ - public void testConsecutiveEmptyElements() - throws Exception - { - buildPom( "consecutive_empty_elements" ); - } - - public void testOrderOfGoalsFromPluginExecutionWithoutPluginManagement() - throws Exception - { - PomTestWrapper pom = buildPom( "plugin-exec-goals-order/wo-plugin-mngt" ); - assertEquals( 5, ( (List<?>) pom.getValue( "build/plugins[1]/executions[1]/goals" ) ).size() ); - assertEquals( "b", pom.getValue( "build/plugins[1]/executions[1]/goals[1]" ) ); - assertEquals( "a", pom.getValue( "build/plugins[1]/executions[1]/goals[2]" ) ); - assertEquals( "d", pom.getValue( "build/plugins[1]/executions[1]/goals[3]" ) ); - assertEquals( "c", pom.getValue( "build/plugins[1]/executions[1]/goals[4]" ) ); - assertEquals( "e", pom.getValue( "build/plugins[1]/executions[1]/goals[5]" ) ); - } - - /* MNG-3886*/ - public void testOrderOfGoalsFromPluginExecutionWithPluginManagement() - throws Exception - { - PomTestWrapper pom = buildPom( "plugin-exec-goals-order/w-plugin-mngt" ); - assertEquals( 5, ( (List<?>) pom.getValue( "build/plugins[1]/executions[1]/goals" ) ).size() ); - assertEquals( "b", pom.getValue( "build/plugins[1]/executions[1]/goals[1]" ) ); - assertEquals( "a", pom.getValue( "build/plugins[1]/executions[1]/goals[2]" ) ); - assertEquals( "d", pom.getValue( "build/plugins[1]/executions[1]/goals[3]" ) ); - assertEquals( "c", pom.getValue( "build/plugins[1]/executions[1]/goals[4]" ) ); - assertEquals( "e", pom.getValue( "build/plugins[1]/executions[1]/goals[5]" ) ); - } - - public void testOrderOfPluginExecutionsWithoutPluginManagement() - throws Exception - { - PomTestWrapper pom = buildPom( "plugin-exec-order/wo-plugin-mngt" ); - assertEquals( 5, ( (List<?>) pom.getValue( "build/plugins[1]/executions" ) ).size() ); - assertEquals( "b", pom.getValue( "build/plugins[1]/executions[1]/id" ) ); - assertEquals( "a", pom.getValue( "build/plugins[1]/executions[2]/id" ) ); - assertEquals( "d", pom.getValue( "build/plugins[1]/executions[3]/id" ) ); - assertEquals( "c", pom.getValue( "build/plugins[1]/executions[4]/id" ) ); - assertEquals( "e", pom.getValue( "build/plugins[1]/executions[5]/id" ) ); - } - - /* MNG-3887 */ - public void testOrderOfPluginExecutionsWithPluginManagement() - throws Exception - { - PomTestWrapper pom = buildPom( "plugin-exec-order/w-plugin-mngt" ); - assertEquals( 5, ( (List<?>) pom.getValue( "build/plugins[1]/executions" ) ).size() ); - assertEquals( "b", pom.getValue( "build/plugins[1]/executions[1]/id" ) ); - assertEquals( "a", pom.getValue( "build/plugins[1]/executions[2]/id" ) ); - assertEquals( "d", pom.getValue( "build/plugins[1]/executions[3]/id" ) ); - assertEquals( "c", pom.getValue( "build/plugins[1]/executions[4]/id" ) ); - assertEquals( "e", pom.getValue( "build/plugins[1]/executions[5]/id" ) ); - } - - public void testMergeOfPluginExecutionsWhenChildInheritsPluginVersion() - throws Exception - { - PomTestWrapper pom = buildPom( "plugin-exec-merging-wo-version/sub" ); - assertEquals( 4, ( (List<?>) pom.getValue( "build/plugins[1]/executions" ) ).size() ); - } - - /* MNG-3943*/ - public void testMergeOfPluginExecutionsWhenChildAndParentUseDifferentPluginVersions() - throws Exception - { - PomTestWrapper pom = buildPom( "plugin-exec-merging-version-insensitive/sub" ); - assertEquals( 4, ( (List<?>) pom.getValue( "build/plugins[1]/executions" ) ).size() ); - } - - - public void testInterpolationWithXmlMarkup() - throws Exception - { - PomTestWrapper pom = buildPom( "xml-markup-interpolation" ); - assertEquals( "<?xml version='1.0'?>Tom&Jerry", pom.getValue( "properties/xmlTest" ) ); - } - - /* MNG-3925 */ - public void testOrderOfMergedPluginExecutionsWithoutPluginManagement() - throws Exception - { - PomTestWrapper pom = buildPom( "merged-plugin-exec-order/wo-plugin-mngt/sub" ); - assertEquals( 5, ( (List<?>) pom.getValue( "build/plugins[1]/executions" ) ).size() ); - assertEquals( "parent-1", pom.getValue( "build/plugins[1]/executions[1]/goals[1]" ) ); - assertEquals( "parent-2", pom.getValue( "build/plugins[1]/executions[2]/goals[1]" ) ); - assertEquals( "child-default", pom.getValue( "build/plugins[1]/executions[3]/goals[1]" ) ); - assertEquals( "child-1", pom.getValue( "build/plugins[1]/executions[4]/goals[1]" ) ); - assertEquals( "child-2", pom.getValue( "build/plugins[1]/executions[5]/goals[1]" ) ); - } - - public void testOrderOfMergedPluginExecutionsWithPluginManagement() - throws Exception - { - PomTestWrapper pom = buildPom( "merged-plugin-exec-order/w-plugin-mngt/sub" ); - assertEquals( 5, ( (List<?>) pom.getValue( "build/plugins[1]/executions" ) ).size() ); - assertEquals( "parent-1", pom.getValue( "build/plugins[1]/executions[1]/goals[1]" ) ); - assertEquals( "parent-2", pom.getValue( "build/plugins[1]/executions[2]/goals[1]" ) ); - assertEquals( "child-default", pom.getValue( "build/plugins[1]/executions[3]/goals[1]" ) ); - assertEquals( "child-1", pom.getValue( "build/plugins[1]/executions[4]/goals[1]" ) ); - assertEquals( "child-2", pom.getValue( "build/plugins[1]/executions[5]/goals[1]" ) ); - } - - /* MNG-3984*/ - public void testDifferentContainersWithSameId() - throws Exception - { - PomTestWrapper pom = buildPom( "join-different-containers-same-id" ); - assertEquals( 1, ( (List<?>) pom.getValue( "build/plugins[1]/executions[1]/goals" ) ).size() ); - assertEquals( 1, ( (List<?>) pom.getValue( "build/pluginManagement/plugins[@artifactId='maven-it-plugin-b']/executions[1]/goals" ) ).size() ); - } - - /* MNG-3937*/ - public void testOrderOfMergedPluginExecutionGoalsWithoutPluginManagement() - throws Exception - { - PomTestWrapper pom = buildPom( "merged-plugin-exec-goals-order/wo-plugin-mngt/sub" ); - - assertEquals( 5, ( (List<?>) pom.getValue( "build/plugins[1]/executions[1]/goals" ) ).size() ); - assertEquals( "child-a", pom.getValue( "build/plugins[1]/executions[1]/goals[1]" ) ); - assertEquals( "merged", pom.getValue( "build/plugins[1]/executions[1]/goals[2]" ) ); - assertEquals( "child-b", pom.getValue( "build/plugins[1]/executions[1]/goals[3]" ) ); - assertEquals( "parent-b", pom.getValue( "build/plugins[1]/executions[1]/goals[4]" ) ); - assertEquals( "parent-a", pom.getValue( "build/plugins[1]/executions[1]/goals[5]" ) ); - } - - public void testOrderOfMergedPluginExecutionGoalsWithPluginManagement() - throws Exception - { - PomTestWrapper pom = buildPom( "merged-plugin-exec-goals-order/w-plugin-mngt/sub" ); - assertEquals( 5, ( (List<?>) pom.getValue( "build/plugins[1]/executions[1]/goals" ) ).size() ); - assertEquals( "child-a", pom.getValue( "build/plugins[1]/executions[1]/goals[1]" ) ); - assertEquals( "merged", pom.getValue( "build/plugins[1]/executions[1]/goals[2]" ) ); - assertEquals( "child-b", pom.getValue( "build/plugins[1]/executions[1]/goals[3]" ) ); - assertEquals( "parent-b", pom.getValue( "build/plugins[1]/executions[1]/goals[4]" ) ); - assertEquals( "parent-a", pom.getValue( "build/plugins[1]/executions[1]/goals[5]" ) ); - } - - /*MNG-3938*/ - public void testOverridingOfInheritedPluginExecutionsWithoutPluginManagement() - throws Exception - { - PomTestWrapper pom = buildPom( "plugin-exec-merging/wo-plugin-mngt/sub" ); - assertEquals( 2, ( (List<?>) pom.getValue( "build/plugins[1]/executions" ) ).size() ); - assertEquals( "child-default", pom.getValue( "build/plugins[1]/executions[@id='default']/phase" ) ); - assertEquals( "child-non-default", pom.getValue( "build/plugins[1]/executions[@id='non-default']/phase" ) ); - } - - /* MNG-3938 */ - public void testOverridingOfInheritedPluginExecutionsWithPluginManagement() - throws Exception - { - PomTestWrapper pom = buildPom( "plugin-exec-merging/w-plugin-mngt/sub" ); - assertEquals( 2, ( (List<?>) pom.getValue( "build/plugins[1]/executions" ) ).size() ); - assertEquals( "child-default", pom.getValue( "build/plugins[1]/executions[@id='default']/phase" ) ); - assertEquals( "child-non-default", pom.getValue( "build/plugins[1]/executions[@id='non-default']/phase" ) ); - } - - - /* MNG-3906*/ - public void testOrderOfMergedPluginDependenciesWithoutPluginManagement() - throws Exception - { - PomTestWrapper pom = buildPom( "merged-plugin-class-path-order/wo-plugin-mngt/sub" ); - - assertEquals( 5, ( (List<?>) pom.getValue( "build/plugins[1]/dependencies" ) ).size() ); - assertNotNull( pom.getValue( "build/plugins[1]/dependencies[1]" ) ); - assertEquals( "c", pom.getValue( "build/plugins[1]/dependencies[1]/artifactId" ) ); - assertEquals( "1", pom.getValue( "build/plugins[1]/dependencies[1]/version" ) ); - assertEquals( "a", pom.getValue( "build/plugins[1]/dependencies[2]/artifactId" ) ); - assertEquals( "2", pom.getValue( "build/plugins[1]/dependencies[2]/version" ) ); - assertEquals( "b", pom.getValue( "build/plugins[1]/dependencies[3]/artifactId" ) ); - assertEquals( "1", pom.getValue( "build/plugins[1]/dependencies[3]/version" ) ); - assertEquals( "e", pom.getValue( "build/plugins[1]/dependencies[4]/artifactId" ) ); - assertEquals( "1", pom.getValue( "build/plugins[1]/dependencies[4]/version" ) ); - assertEquals( "d", pom.getValue( "build/plugins[1]/dependencies[5]/artifactId" ) ); - assertEquals( "1", pom.getValue( "build/plugins[1]/dependencies[5]/version" ) ); - } - - public void testOrderOfMergedPluginDependenciesWithPluginManagement() - throws Exception - { - PomTestWrapper pom = buildPom( "merged-plugin-class-path-order/w-plugin-mngt/sub" ); - assertEquals( 5, ( (List<?>) pom.getValue( "build/plugins[1]/dependencies" ) ).size() ); - assertEquals( "c", pom.getValue( "build/plugins[1]/dependencies[1]/artifactId" ) ); - assertEquals( "1", pom.getValue( "build/plugins[1]/dependencies[1]/version" ) ); - assertEquals( "a", pom.getValue( "build/plugins[1]/dependencies[2]/artifactId" ) ); - assertEquals( "2", pom.getValue( "build/plugins[1]/dependencies[2]/version" ) ); - assertEquals( "b", pom.getValue( "build/plugins[1]/dependencies[3]/artifactId" ) ); - assertEquals( "1", pom.getValue( "build/plugins[1]/dependencies[3]/version" ) ); - assertEquals( "e", pom.getValue( "build/plugins[1]/dependencies[4]/artifactId" ) ); - assertEquals( "1", pom.getValue( "build/plugins[1]/dependencies[4]/version" ) ); - assertEquals( "d", pom.getValue( "build/plugins[1]/dependencies[5]/artifactId" ) ); - assertEquals( "1", pom.getValue( "build/plugins[1]/dependencies[5]/version" ) ); - } - - public void testInterpolationOfNestedBuildDirectories() - throws Exception - { - PomTestWrapper pom = buildPom( "nested-build-dir-interpolation" ); - assertEquals( new File( pom.getBasedir(), "target/classes/dir0" ), - new File( (String) pom.getValue( "properties/dir0" ) ) ); - assertEquals( new File( pom.getBasedir(), "src/test/dir1" ), - new File( (String) pom.getValue( "properties/dir1" ) ) ); - assertEquals( new File( pom.getBasedir(), "target/site/dir2" ), - new File( (String) pom.getValue( "properties/dir2" ) ) ); - } - - public void testAppendArtifactIdOfChildToInheritedUrls() - throws Exception - { - PomTestWrapper pom = buildPom( "url-inheritance/sub" ); - assertEquals( "http://parent.url/child", pom.getValue( "url" ) ); - assertEquals( "http://parent.url/org", pom.getValue( "organization/url" ) ); - assertEquals( "http://parent.url/license.txt", pom.getValue( "licenses[1]/url" ) ); - assertEquals( "http://parent.url/viewvc/child", pom.getValue( "scm/url" ) ); - assertEquals( "http://parent.url/scm/child", pom.getValue( "scm/connection" ) ); - assertEquals( "https://parent.url/scm/child", pom.getValue( "scm/developerConnection" ) ); - assertEquals( "http://parent.url/issues", pom.getValue( "issueManagement/url" ) ); - assertEquals( "http://parent.url/ci", pom.getValue( "ciManagement/url" ) ); - assertEquals( "http://parent.url/dist", pom.getValue( "distributionManagement/repository/url" ) ); - assertEquals( "http://parent.url/snaps", pom.getValue( "distributionManagement/snapshotRepository/url" ) ); - assertEquals( "http://parent.url/site/child", pom.getValue( "distributionManagement/site/url" ) ); - assertEquals( "http://parent.url/download", pom.getValue( "distributionManagement/downloadUrl" ) ); - } - - /* MNG-3846*/ - public void testAppendArtifactIdOfParentAndChildToInheritedUrls() - throws Exception - { - PomTestWrapper pom = buildPom( "url-inheritance/another-parent/sub" ); - assertEquals( "http://parent.url/ap/child", pom.getValue( "url" ) ); - assertEquals( "http://parent.url/org", pom.getValue( "organization/url" ) ); - assertEquals( "http://parent.url/license.txt", pom.getValue( "licenses[1]/url" ) ); - assertEquals( "http://parent.url/viewvc/ap/child", pom.getValue( "scm/url" ) ); - assertEquals( "http://parent.url/scm/ap/child", pom.getValue( "scm/connection" ) ); - assertEquals( "https://parent.url/scm/ap/child", pom.getValue( "scm/developerConnection" ) ); - assertEquals( "http://parent.url/issues", pom.getValue( "issueManagement/url" ) ); - assertEquals( "http://parent.url/ci", pom.getValue( "ciManagement/url" ) ); - assertEquals( "http://parent.url/dist", pom.getValue( "distributionManagement/repository/url" ) ); - assertEquals( "http://parent.url/snaps", pom.getValue( "distributionManagement/snapshotRepository/url" ) ); - assertEquals( "http://parent.url/site/ap/child", pom.getValue( "distributionManagement/site/url" ) ); - assertEquals( "http://parent.url/download", pom.getValue( "distributionManagement/downloadUrl" ) ); - } - //*/ - - public void testNonInheritedElementsInSubtreesOverriddenByChild() - throws Exception - { - PomTestWrapper pom = buildPom( "limited-inheritance/child" ); - assertEquals( null, pom.getValue( "organization/url" ) ); - assertEquals( null, pom.getValue( "issueManagement/system" ) ); - assertEquals( 0, ( (List<?>) pom.getValue( "ciManagement/notifiers" ) ).size() ); - assertEquals( "child-distros", pom.getValue( "distributionManagement/repository/id" ) ); - assertEquals( "ssh://child.url/distros", pom.getValue( "distributionManagement/repository/url" ) ); - assertEquals( null, pom.getValue( "distributionManagement/repository/name" ) ); - assertEquals( true, pom.getValue( "distributionManagement/repository/uniqueVersion" ) ); - assertEquals( "default", pom.getValue( "distributionManagement/repository/layout" ) ); - assertEquals( "child-snaps", pom.getValue( "distributionManagement/snapshotRepository/id" ) ); - assertEquals( "ssh://child.url/snaps", pom.getValue( "distributionManagement/snapshotRepository/url" ) ); - assertEquals( null, pom.getValue( "distributionManagement/snapshotRepository/name" ) ); - assertEquals( true, pom.getValue( "distributionManagement/snapshotRepository/uniqueVersion" ) ); - assertEquals( "default", pom.getValue( "distributionManagement/snapshotRepository/layout" ) ); - assertEquals( "child-site", pom.getValue( "distributionManagement/site/id" ) ); - assertEquals( "scp://child.url/site", pom.getValue( "distributionManagement/site/url" ) ); - assertEquals( null, pom.getValue( "distributionManagement/site/name" ) ); - } - - public void testXmlTextCoalescing() - throws Exception - { - PomTestWrapper pom = buildPom( "xml-coalesce-text" ); - assertEquals( "A Test Project Property", pom.getValue( "properties/prop0" ) ); - assertEquals( "That's a test!", pom.getValue( "properties/prop1" ) ); - assertEquals( 32 * 1024, - pom.getValue( "properties/prop2" ).toString().trim().replaceAll( "[\n\r]", "" ).length() ); - } - - public void testFullInterpolationOfNestedExpressions() - throws Exception - { - PomTestWrapper pom = buildPom( "full-interpolation" ); - for ( int i = 0; i < 24; i++ ) - { - String index = ( ( i < 10 ) ? "0" : "" ) + i; - assertEquals( "PASSED", pom.getValue( "properties/property" + index ) ); - } - } - - public void testInterpolationOfLegacyExpressionsThatDontIncludeTheProjectPrefix() - throws Exception - { - PomTestWrapper pom = buildPom( "unprefixed-expression-interpolation/child" ); - - assertEquals( pom.getBasedir(), new File( pom.getValue( "properties/projectDir" ).toString() ) ); - - assertEquals( "org.apache.maven.its.mng3831.child", pom.getValue( "properties/projectGroupId" ) ); - assertEquals( "child", pom.getValue( "properties/projectArtifactId" ) ); - assertEquals( "2.0-alpha-1", pom.getValue( "properties/projectVersion" ) ); - assertEquals( "jar", pom.getValue( "properties/projectPackaging" ) ); - - assertEquals( "child-name", pom.getValue( "properties/projectName" ) ); - assertEquals( "child-desc", pom.getValue( "properties/projectDesc" ) ); - assertEquals( "http://child.org/", pom.getValue( "properties/projectUrl" ) ); - assertEquals( "2008", pom.getValue( "properties/projectYear" ) ); - assertEquals( "child-org-name", pom.getValue( "properties/projectOrgName" ) ); - - assertEquals( "2.0.0", pom.getValue( "properties/projectPrereqMvn" ) ); - assertEquals( "http://scm.org/", pom.getValue( "properties/projectScmUrl" ) ); - assertEquals( "http://issue.org/", pom.getValue( "properties/projectIssueUrl" ) ); - assertEquals( "http://ci.org/", pom.getValue( "properties/projectCiUrl" ) ); - assertEquals( "child-dist-repo", pom.getValue( "properties/projectDistRepoName" ) ); - assertEquals( "http://dist.org/", pom.getValue( "properties/projectDistRepoUrl" ) ); - assertEquals( "http://site.org/", pom.getValue( "properties/projectDistSiteUrl" ) ); - - assertEquals( "org.apache.maven.its.mng3831", pom.getValue( "properties/parentGroupId" ) ); - assertEquals( "parent", pom.getValue( "properties/parentArtifactId" ) ); - assertEquals( "1.0", pom.getValue( "properties/parentVersion" ) ); - - assertTrue( pom.getValue( "properties/projectBuildOut" ).toString().endsWith( "bin" ) ); - assertTrue( pom.getValue( "properties/projectSiteOut" ).toString().endsWith( "doc" ) ); - } - - public void testInterpolationWithBasedirAlignedDirectories() - throws Exception - { - PomTestWrapper pom = buildPom( "basedir-aligned-interpolation" ); - assertEquals( new File( pom.getBasedir(), "src/main/java" ), - new File( pom.getValue( "properties/buildMainSrc" ).toString() ) ); - assertEquals( new File( pom.getBasedir(), "src/test/java" ), - new File( pom.getValue( "properties/buildTestSrc" ).toString() ) ); - assertEquals( new File( pom.getBasedir(), "src/main/scripts" ), - new File( pom.getValue( "properties/buildScriptSrc" ).toString() ) ); - assertEquals( new File( pom.getBasedir(), "target" ), - new File( pom.getValue( "properties/buildOut" ).toString() ) ); - assertEquals( new File( pom.getBasedir(), "target/classes" ), - new File( pom.getValue( "properties/buildMainOut" ).toString() ) ); - assertEquals( new File( pom.getBasedir(), "target/test-classes" ), - new File( pom.getValue( "properties/buildTestOut" ).toString() ) ); - assertEquals( new File( pom.getBasedir(), "target/site" ), - new File( pom.getValue( "properties/siteOut" ).toString() ) ); - } - - /* MNG-3944*/ - public void testInterpolationOfBasedirInPomWithUnusualName() - throws Exception - { - PomTestWrapper pom = buildPom( "basedir-interpolation/pom-with-unusual-name.xml" ); - assertEquals( pom.getBasedir(), new File( pom.getValue( "properties/prop0" ).toString() ) ); - assertEquals( pom.getBasedir(), new File( pom.getValue( "properties/prop1" ).toString() ) ); - } - - /* MNG-3979 */ - public void testJoiningOfContainersWhenChildHasEmptyElements() - throws Exception - { - PomTestWrapper pom = buildPom( "id-container-joining-with-empty-elements/sub" ); - assertNotNull( pom ); - } - - public void testOrderOfPluginConfigurationElementsWithoutPluginManagement() - throws Exception - { - PomTestWrapper pom = buildPom( "plugin-config-order/wo-plugin-mngt" ); - assertEquals( "one", pom.getValue( "build/plugins[1]/configuration/stringParams/stringParam[1]" ) ); - assertEquals( "two", pom.getValue( "build/plugins[1]/configuration/stringParams/stringParam[2]" ) ); - assertEquals( "three", pom.getValue( "build/plugins[1]/configuration/stringParams/stringParam[3]" ) ); - assertEquals( "four", pom.getValue( "build/plugins[1]/configuration/stringParams/stringParam[4]" ) ); - } - - /* MNG-3827*/ - public void testOrderOfPluginConfigurationElementsWithPluginManagement() - throws Exception - { - PomTestWrapper pom = buildPom( "plugin-config-order/w-plugin-mngt" ); - assertEquals( "one", pom.getValue( "build/plugins[1]/configuration/stringParams/stringParam[1]" ) ); - assertEquals( "two", pom.getValue( "build/plugins[1]/configuration/stringParams/stringParam[2]" ) ); - assertEquals( "three", pom.getValue( "build/plugins[1]/configuration/stringParams/stringParam[3]" ) ); - assertEquals( "four", pom.getValue( "build/plugins[1]/configuration/stringParams/stringParam[4]" ) ); - } - - public void testOrderOfPluginExecutionConfigurationElementsWithoutPluginManagement() - throws Exception - { - PomTestWrapper pom = buildPom( "plugin-exec-config-order/wo-plugin-mngt" ); - String prefix = "build/plugins[1]/executions[1]/configuration/"; - assertEquals( "one", pom.getValue( prefix + "stringParams/stringParam[1]" ) ); - assertEquals( "two", pom.getValue( prefix + "stringParams/stringParam[2]" ) ); - assertEquals( "three", pom.getValue( prefix + "stringParams/stringParam[3]" ) ); - assertEquals( "four", pom.getValue( prefix + "stringParams/stringParam[4]" ) ); - assertEquals( "key1", pom.getValue( prefix + "propertiesParam/property[1]/name" ) ); - assertEquals( "key2", pom.getValue( prefix + "propertiesParam/property[2]/name" ) ); - } - - /* MNG-3864*/ - public void testOrderOfPluginExecutionConfigurationElementsWithPluginManagement() - throws Exception - { - PomTestWrapper pom = buildPom( "plugin-exec-config-order/w-plugin-mngt" ); - String prefix = "build/plugins[1]/executions[1]/configuration/"; - assertEquals( "one", pom.getValue( prefix + "stringParams/stringParam[1]" ) ); - assertEquals( "two", pom.getValue( prefix + "stringParams/stringParam[2]" ) ); - assertEquals( "three", pom.getValue( prefix + "stringParams/stringParam[3]" ) ); - assertEquals( "four", pom.getValue( prefix + "stringParams/stringParam[4]" ) ); - assertEquals( "key1", pom.getValue( prefix + "propertiesParam/property[1]/name" ) ); - assertEquals( "key2", pom.getValue( prefix + "propertiesParam/property[2]/name" ) ); - } - - /* MNG-3836*/ - public void testMergeOfInheritedPluginConfiguration() - throws Exception - { - PomTestWrapper pom = buildPom( "plugin-config-merging/child" ); - - String prefix = "build/plugins[1]/configuration/"; - assertEquals( "PASSED", pom.getValue( prefix + "propertiesFile" ) ); - assertEquals( "PASSED", pom.getValue( prefix + "parent" ) ); - assertEquals( "PASSED-1", pom.getValue( prefix + "stringParams/stringParam[1]" ) ); - assertEquals( "PASSED-3", pom.getValue( prefix + "stringParams/stringParam[2]" ) ); - assertEquals( "PASSED-2", pom.getValue( prefix + "stringParams/stringParam[3]" ) ); - assertEquals( "PASSED-4", pom.getValue( prefix + "stringParams/stringParam[4]" ) ); - assertEquals( "PASSED-1", pom.getValue( prefix + "listParam/listParam[1]" ) ); - assertEquals( "PASSED-3", pom.getValue( prefix + "listParam/listParam[2]" ) ); - assertEquals( "PASSED-2", pom.getValue( prefix + "listParam/listParam[3]" ) ); - assertEquals( "PASSED-4", pom.getValue( prefix + "listParam/listParam[4]" ) ); - } - - /* MNG-2591 */ - public void testAppendOfInheritedPluginConfigurationWithNoProfile() - throws Exception - { - testAppendOfInheritedPluginConfiguration( "no-profile" ); - } - - /* MNG-2591*/ - public void testAppendOfInheritedPluginConfigurationWithActiveProfile() - throws Exception - { - testAppendOfInheritedPluginConfiguration( "with-profile" ); - } - - private void testAppendOfInheritedPluginConfiguration( String test ) - throws Exception - { - PomTestWrapper pom = buildPom( "plugin-config-append/" + test + "/subproject" ); - String prefix = "build/plugins[1]/configuration/"; - assertEquals( "PARENT-1", pom.getValue( prefix + "stringParams/stringParam[1]" ) ); - assertEquals( "PARENT-3", pom.getValue( prefix + "stringParams/stringParam[2]" ) ); - assertEquals( "PARENT-2", pom.getValue( prefix + "stringParams/stringParam[3]" ) ); - assertEquals( "PARENT-4", pom.getValue( prefix + "stringParams/stringParam[4]" ) ); - assertEquals( "CHILD-1", pom.getValue( prefix + "stringParams/stringParam[5]" ) ); - assertEquals( "CHILD-3", pom.getValue( prefix + "stringParams/stringParam[6]" ) ); - assertEquals( "CHILD-2", pom.getValue( prefix + "stringParams/stringParam[7]" ) ); - assertEquals( "CHILD-4", pom.getValue( prefix + "stringParams/stringParam[8]" ) ); - assertEquals( null, pom.getValue( prefix + "stringParams/stringParam[9]" ) ); - assertEquals( "PARENT-1", pom.getValue( prefix + "listParam/listParam[1]" ) ); - assertEquals( "PARENT-3", pom.getValue( prefix + "listParam/listParam[2]" ) ); - assertEquals( "PARENT-2", pom.getValue( prefix + "listParam/listParam[3]" ) ); - assertEquals( "PARENT-4", pom.getValue( prefix + "listParam/listParam[4]" ) ); - assertEquals( "CHILD-1", pom.getValue( prefix + "listParam/listParam[5]" ) ); - assertEquals( "CHILD-3", pom.getValue( prefix + "listParam/listParam[6]" ) ); - assertEquals( "CHILD-2", pom.getValue( prefix + "listParam/listParam[7]" ) ); - assertEquals( "CHILD-4", pom.getValue( prefix + "listParam/listParam[8]" ) ); - assertEquals( null, pom.getValue( prefix + "listParam/listParam[9]" ) ); - } - - /* MNG-4000 */ - public void testMultiplePluginExecutionsWithAndWithoutIdsWithoutPluginManagement() - throws Exception - { - PomTestWrapper pom = buildPom( "plugin-exec-w-and-wo-id/wo-plugin-mngt" ); - assertEquals( 2, ( (List<?>) pom.getValue( "build/plugins[1]/executions" ) ).size() ); - assertEquals( "log-string", pom.getValue( "build/plugins[1]/executions[1]/goals[1]" ) ); - assertEquals( "log-string", pom.getValue( "build/plugins[1]/executions[2]/goals[1]" ) ); - } - - public void testMultiplePluginExecutionsWithAndWithoutIdsWithPluginManagement() - throws Exception - { - PomTestWrapper pom = buildPom( "plugin-exec-w-and-wo-id/w-plugin-mngt" ); - assertEquals( 2, ( (List<?>) pom.getValue( "build/plugins[1]/executions" ) ).size() ); - assertEquals( "log-string", pom.getValue( "build/plugins[1]/executions[1]/goals[1]" ) ); - assertEquals( "log-string", pom.getValue( "build/plugins[1]/executions[2]/goals[1]" ) ); - } - - public void testDependencyOrderWithoutPluginManagement() - throws Exception - { - PomTestWrapper pom = buildPom( "dependency-order/wo-plugin-mngt" ); - assertEquals( 4, ( (List<?>) pom.getValue( "dependencies" ) ).size() ); - assertEquals( "a", pom.getValue( "dependencies[1]/artifactId" ) ); - assertEquals( "c", pom.getValue( "dependencies[2]/artifactId" ) ); - assertEquals( "b", pom.getValue( "dependencies[3]/artifactId" ) ); - assertEquals( "d", pom.getValue( "dependencies[4]/artifactId" ) ); - } - - public void testDependencyOrderWithPluginManagement() - throws Exception - { - PomTestWrapper pom = buildPom( "dependency-order/w-plugin-mngt" ); - assertEquals( 4, ( (List<?>) pom.getValue( "dependencies" ) ).size() ); - assertEquals( "a", pom.getValue( "dependencies[1]/artifactId" ) ); - assertEquals( "c", pom.getValue( "dependencies[2]/artifactId" ) ); - assertEquals( "b", pom.getValue( "dependencies[3]/artifactId" ) ); - assertEquals( "d", pom.getValue( "dependencies[4]/artifactId" ) ); - } - - public void testBuildDirectoriesUsePlatformSpecificFileSeparator() - throws Exception - { - PomTestWrapper pom = buildPom( "platform-file-separator" ); - assertPathWithNormalizedFileSeparators( pom.getValue( "build/directory" ) ); - assertPathWithNormalizedFileSeparators( pom.getValue( "build/outputDirectory" ) ); - assertPathWithNormalizedFileSeparators( pom.getValue( "build/testOutputDirectory" ) ); - assertPathWithNormalizedFileSeparators( pom.getValue( "build/sourceDirectory" ) ); - assertPathWithNormalizedFileSeparators( pom.getValue( "build/testSourceDirectory" ) ); - assertPathWithNormalizedFileSeparators( pom.getValue( "build/resources[1]/directory" ) ); - assertPathWithNormalizedFileSeparators( pom.getValue( "build/testResources[1]/directory" ) ); - assertPathWithNormalizedFileSeparators( pom.getValue( "build/filters[1]" ) ); - assertPathWithNormalizedFileSeparators( pom.getValue( "reporting/outputDirectory" ) ); - } - - /* MNG-4008 */ - public void testMergedFilterOrder() - throws Exception - { - PomTestWrapper pom = buildPom( "merged-filter-order/sub" ); - - assertEquals( 7, ( (List<?>) pom.getValue( "build/filters" ) ).size() ); - assertTrue( pom.getValue( "build/filters[1]" ).toString().endsWith( "child-a.properties" ) ); - assertTrue( pom.getValue( "build/filters[2]" ).toString().endsWith( "child-c.properties" ) ); - assertTrue( pom.getValue( "build/filters[3]" ).toString().endsWith( "child-b.properties" ) ); - assertTrue( pom.getValue( "build/filters[4]" ).toString().endsWith( "child-d.properties" ) ); - assertTrue( pom.getValue( "build/filters[5]" ).toString().endsWith( "parent-c.properties" ) ); - assertTrue( pom.getValue( "build/filters[6]" ).toString().endsWith( "parent-b.properties" ) ); - assertTrue( pom.getValue( "build/filters[7]" ).toString().endsWith( "parent-d.properties" ) ); - } - - /** MNG-4027*/ - public void testProfileInjectedDependencies() - throws Exception - { - PomTestWrapper pom = buildPom( "profile-injected-dependencies" ); - assertEquals( 4, ( (List<?>) pom.getValue( "dependencies" ) ).size() ); - assertEquals( "a", pom.getValue( "dependencies[1]/artifactId" ) ); - assertEquals( "c", pom.getValue( "dependencies[2]/artifactId" ) ); - assertEquals( "b", pom.getValue( "dependencies[3]/artifactId" ) ); - assertEquals( "d", pom.getValue( "dependencies[4]/artifactId" ) ); - } - - /** IT-0021*/ - public void testProfileDependenciesMultipleProfiles() - throws Exception - { - PomTestWrapper pom = buildPom( "profile-dependencies-multiple-profiles", "profile-1", "profile-2" ); - assertEquals(2, ( (List<?>) pom.getValue( "dependencies" ) ).size() ); - } - - public void testDependencyInheritance() - throws Exception - { - PomTestWrapper pom = buildPom( "dependency-inheritance/sub" ); - assertEquals( 1, ( (List<?>) pom.getValue( "dependencies" ) ).size() ); - assertEquals( "4.4", pom.getValue( "dependencies[1]/version" ) ); - } - - /** MNG-4034 */ - public void testManagedProfileDependency() - throws Exception - { - PomTestWrapper pom = this.buildPom( "managed-profile-dependency/sub", "maven-core-it" ); - assertEquals( 1, ( (List<?>) pom.getValue( "dependencies" ) ).size() ); - assertEquals( "org.apache.maven.its", pom.getValue( "dependencies[1]/groupId" ) ); - assertEquals( "maven-core-it-support", pom.getValue( "dependencies[1]/artifactId" ) ); - assertEquals( "1.3", pom.getValue( "dependencies[1]/version" ) ); - assertEquals( "runtime", pom.getValue( "dependencies[1]/scope" ) ); - assertEquals( 1, ( (List<?>) pom.getValue( "dependencies[1]/exclusions" ) ).size() ); - assertEquals( "commons-lang", pom.getValue( "dependencies[1]/exclusions[1]/groupId" ) ); - } - - /** MNG-4040 */ - public void testProfileModuleInheritance() - throws Exception - { - PomTestWrapper pom = this.buildPom( "profile-module-inheritance/sub", "dist" ); - assertEquals( 0, ( (List<?>) pom.getValue( "modules" ) ).size() ); - } - - /** MNG-3621 */ - public void testUncPath() - throws Exception - { - PomTestWrapper pom = this.buildPom( "unc-path/sub" ); - assertEquals( "file:////host/site/test-child", pom.getValue( "distributionManagement/site/url" ) ); - } - - /** MNG-2006 */ - public void testUrlAppendWithChildPathAdjustment() - throws Exception - { - PomTestWrapper pom = this.buildPom( "url-append/child" ); - assertEquals( "http://project.url/child", pom.getValue( "url" ) ); - assertEquals( "http://viewvc.project.url/child", pom.getValue( "scm/url" ) ); - assertEquals( "http://scm.project.url/child", pom.getValue( "scm/connection" ) ); - assertEquals( "https://scm.project.url/child", pom.getValue( "scm/developerConnection" ) ); - assertEquals( "http://site.project.url/child", pom.getValue( "distributionManagement/site/url" ) ); - } - - /** MNG-0479 */ - public void testRepoInheritance() - throws Exception - { - PomTestWrapper pom = this.buildPom( "repo-inheritance" ); - assertEquals( 1, ( (List<?>) pom.getValue( "repositories" ) ).size() ); - assertEquals( "it0043", pom.getValue( "repositories[1]/name" ) ); - } - - public void testEmptyScm() - throws Exception - { - PomTestWrapper pom = this.buildPom( "empty-scm" ); - assertNull( pom.getValue( "scm" ) ); - } - - public void testPluginConfigurationUsingAttributesWithoutPluginManagement() - throws Exception - { - PomTestWrapper pom = buildPom( "plugin-config-attributes/wo-plugin-mngt" ); - assertEquals( "src", pom.getValue( "build/plugins[1]/configuration/domParam/copy/@todir" ) ); - assertEquals( "true", pom.getValue( "build/plugins[1]/configuration/domParam/copy/@overwrite" ) ); - assertEquals( "target", pom.getValue( "build/plugins[1]/configuration/domParam/copy/fileset/@dir" ) ); - assertEquals( null, pom.getValue( "build/plugins[1]/configuration/domParam/copy/fileset/@todir" ) ); - assertEquals( null, pom.getValue( "build/plugins[1]/configuration/domParam/copy/fileset/@overwrite" ) ); - } - - /** MNG-4053*/ - public void testPluginConfigurationUsingAttributesWithPluginManagement() - throws Exception - { - PomTestWrapper pom = buildPom( "plugin-config-attributes/w-plugin-mngt" ); - assertEquals( "src", pom.getValue( "build/plugins[1]/configuration/domParam/copy/@todir" ) ); - assertEquals( "true", pom.getValue( "build/plugins[1]/configuration/domParam/copy/@overwrite" ) ); - assertEquals( "target", pom.getValue( "build/plugins[1]/configuration/domParam/copy/fileset/@dir" ) ); - assertEquals( null, pom.getValue( "build/plugins[1]/configuration/domParam/copy/fileset/@todir" ) ); - assertEquals( null, pom.getValue( "build/plugins[1]/configuration/domParam/copy/fileset/@overwrite" ) ); - } - - public void testPluginConfigurationUsingAttributesWithPluginManagementAndProfile() - throws Exception - { - PomTestWrapper pom = buildPom( "plugin-config-attributes/w-profile", "maven-core-it" ); - assertEquals( "src", pom.getValue( "build/plugins[1]/configuration/domParam/copy/@todir" ) ); - assertEquals( "true", pom.getValue( "build/plugins[1]/configuration/domParam/copy/@overwrite" ) ); - assertEquals( "target", pom.getValue( "build/plugins[1]/configuration/domParam/copy/fileset/@dir" ) ); - assertEquals( null, pom.getValue( "build/plugins[1]/configuration/domParam/copy/fileset/@todir" ) ); - assertEquals( null, pom.getValue( "build/plugins[1]/configuration/domParam/copy/fileset/@overwrite" ) ); - } - - public void testPomEncoding() - throws Exception - { - PomTestWrapper pom = buildPom( "pom-encoding/utf-8" ); - assertEquals( "TEST-CHARS: \u00DF\u0131\u03A3\u042F\u05D0\u20AC", pom.getValue( "description" ) ); - pom = buildPom( "pom-encoding/latin-1" ); - assertEquals( "TEST-CHARS: \u00C4\u00D6\u00DC\u00E4\u00F6\u00FC\u00DF", pom.getValue( "description" ) ); - } - - /* MNG-4070 */ - public void testXmlWhitespaceHandling() - throws Exception - { - PomTestWrapper pom = buildPom( "xml-whitespace/sub" ); - assertEquals( "org.apache.maven.its.mng4070", pom.getValue( "groupId" ) ); - } - - /* MNG-3760*/ - public void testInterpolationOfBaseUrl() - throws Exception - { - PomTestWrapper pom = buildPom( "baseurl-interpolation/pom.xml" ); - assertEquals( pom.getBasedir().toURI().toString(), pom.getValue( "properties/prop1" ).toString() ); - } - - /* MNG-3811*/ - public void testReportingPluginConfig() - throws Exception - { - PomTestWrapper pom = buildPom( "reporting-plugin-config/sub" ); - - assertEquals( 3, ( (List<?>) pom.getValue( "reporting/plugins[1]/configuration/stringParams" ) ).size() ); - assertEquals( "parentParam", pom.getValue( "reporting/plugins[1]/configuration/stringParams[1]/stringParam[1]" ) ); - assertEquals( "childParam", pom.getValue( "reporting/plugins[1]/configuration/stringParams[1]/stringParam[2]" ) ); - assertEquals( " preserve space ", pom.getValue( "reporting/plugins[1]/configuration/stringParams[1]/stringParam[3]" ) ); - assertEquals( "true", pom.getValue( "reporting/plugins[1]/configuration/booleanParam" ) ); - } - - public void testPropertiesNoDuplication() - throws Exception - { - PomTestWrapper pom = buildPom( "properties-no-duplication/sub" ); - assertEquals( 1, ( (Properties) pom.getValue( "properties" ) ).size() ); - assertEquals( "child", pom.getValue( "properties/pomProfile" ) ); - } - - public void testPomInheritance() - throws Exception - { - PomTestWrapper pom = buildPom( "pom-inheritance/sub" ); - assertEquals( "parent-description", pom.getValue( "description" ) ); - assertEquals( "jar", pom.getValue( "packaging" ) ); - } - - public void testCompleteModelWithoutParent() - throws Exception - { - PomTestWrapper pom = buildPom( "complete-model/wo-parent" ); - - testCompleteModel( pom ); - } - - public void testCompleteModelWithParent() - throws Exception - { - PomTestWrapper pom = buildPom( "complete-model/w-parent/sub" ); - - testCompleteModel( pom ); - } - - private void testCompleteModel( PomTestWrapper pom ) - throws Exception - { - assertEquals( "4.0.0", pom.getValue( "modelVersion" ) ); - - assertEquals( "org.apache.maven.its.mng", pom.getValue( "groupId" ) ); - assertEquals( "test", pom.getValue( "artifactId" ) ); - assertEquals( "0.2", pom.getValue( "version" ) ); - assertEquals( "pom", pom.getValue( "packaging" ) ); - - assertEquals( "project-name", pom.getValue( "name" ) ); - assertEquals( "project-description", pom.getValue( "description" ) ); - assertEquals( "http://project.url/", pom.getValue( "url" ) ); - assertEquals( "2009", pom.getValue( "inceptionYear" ) ); - - assertEquals( "project-org", pom.getValue( "organization/name" ) ); - assertEquals( "http://project-org.url/", pom.getValue( "organization/url" ) ); - - assertEquals( 1, ( (List<?>) pom.getValue( "licenses" ) ).size() ); - assertEquals( "project-license", pom.getValue( "licenses[1]/name" ) ); - assertEquals( "http://project.url/license", pom.getValue( "licenses[1]/url" ) ); - assertEquals( "repo", pom.getValue( "licenses[1]/distribution" ) ); - assertEquals( "free", pom.getValue( "licenses[1]/comments" ) ); - - assertEquals( 1, ( (List<?>) pom.getValue( "developers" ) ).size() ); - assertEquals( "dev", pom.getValue( "developers[1]/id" ) ); - assertEquals( "project-developer", pom.getValue( "developers[1]/name" ) ); - assertEquals( "developer@", pom.getValue( "developers[1]/email" ) ); - assertEquals( "http://developer", pom.getValue( "developers[1]/url" ) ); - assertEquals( "developer", pom.getValue( "developers[1]/organization" ) ); - assertEquals( "http://devel.org", pom.getValue( "developers[1]/organizationUrl" ) ); - assertEquals( "-1", pom.getValue( "developers[1]/timezone" ) ); - assertEquals( "yes", pom.getValue( "developers[1]/properties/developer" ) ); - assertEquals( 1, ( (List<?>) pom.getValue( "developers[1]/roles" ) ).size() ); - assertEquals( "devel", pom.getValue( "developers[1]/roles[1]" ) ); - - assertEquals( 1, ( (List<?>) pom.getValue( "contributors" ) ).size() ); - assertEquals( "project-contributor", pom.getValue( "contributors[1]/name" ) ); - assertEquals( "contributor@", pom.getValue( "contributors[1]/email" ) ); - assertEquals( "http://contributor", pom.getValue( "contributors[1]/url" ) ); - assertEquals( "contributor", pom.getValue( "contributors[1]/organization" ) ); - assertEquals( "http://contrib.org", pom.getValue( "contributors[1]/organizationUrl" ) ); - assertEquals( "+1", pom.getValue( "contributors[1]/timezone" ) ); - assertEquals( "yes", pom.getValue( "contributors[1]/properties/contributor" ) ); - assertEquals( 1, ( (List<?>) pom.getValue( "contributors[1]/roles" ) ).size() ); - assertEquals( "contrib", pom.getValue( "contributors[1]/roles[1]" ) ); - - assertEquals( 1, ( (List<?>) pom.getValue( "mailingLists" ) ).size() ); - assertEquals( "project-mailing-list", pom.getValue( "mailingLists[1]/name" ) ); - assertEquals( "subscribe@", pom.getValue( "mailingLists[1]/subscribe" ) ); - assertEquals( "unsubscribe@", pom.getValue( "mailingLists[1]/unsubscribe" ) ); - assertEquals( "post@", pom.getValue( "mailingLists[1]/post" ) ); - assertEquals( "mail-archive", pom.getValue( "mailingLists[1]/archive" ) ); - assertEquals( 1, ( (List<?>) pom.getValue( "mailingLists[1]/otherArchives" ) ).size() ); - assertEquals( "other-archive", pom.getValue( "mailingLists[1]/otherArchives[1]" ) ); - - assertEquals( "2.0.1", pom.getValue( "prerequisites/maven" ) ); - - assertEquals( "http://project.url/trunk", pom.getValue( "scm/url" ) ); - assertEquals( "http://project.url/scm", pom.getValue( "scm/connection" ) ); - assertEquals( "https://project.url/scm", pom.getValue( "scm/developerConnection" ) ); - assertEquals( "TAG", pom.getValue( "scm/tag" ) ); - - assertEquals( "issues", pom.getValue( "issueManagement/system" ) ); - assertEquals( "http://project.url/issues", pom.getValue( "issueManagement/url" ) ); - - assertEquals( "ci", pom.getValue( "ciManagement/system" ) ); - assertEquals( "http://project.url/ci", pom.getValue( "ciManagement/url" ) ); - assertEquals( 1, ( (List<?>) pom.getValue( "ciManagement/notifiers" ) ).size() ); - assertEquals( "irc", pom.getValue( "ciManagement/notifiers[1]/type" ) ); - assertEquals( "ci@", pom.getValue( "ciManagement/notifiers[1]/address" ) ); - assertEquals( Boolean.TRUE, pom.getValue( "ciManagement/notifiers[1]/sendOnError" ) ); - assertEquals( Boolean.FALSE, pom.getValue( "ciManagement/notifiers[1]/sendOnFailure" ) ); - assertEquals( Boolean.FALSE, pom.getValue( "ciManagement/notifiers[1]/sendOnWarning" ) ); - assertEquals( Boolean.FALSE, pom.getValue( "ciManagement/notifiers[1]/sendOnSuccess" ) ); - assertEquals( "ci", pom.getValue( "ciManagement/notifiers[1]/configuration/ciProp" ) ); - - assertEquals( "project.distros", pom.getValue( "distributionManagement/repository/id" ) ); - assertEquals( "distros", pom.getValue( "distributionManagement/repository/name" ) ); - assertEquals( "http://project.url/dist", pom.getValue( "distributionManagement/repository/url" ) ); - assertEquals( Boolean.TRUE, pom.getValue( "distributionManagement/repository/uniqueVersion" ) ); - - assertEquals( "project.snaps", pom.getValue( "distributionManagement/snapshotRepository/id" ) ); - assertEquals( "snaps", pom.getValue( "distributionManagement/snapshotRepository/name" ) ); - assertEquals( "http://project.url/snaps", pom.getValue( "distributionManagement/snapshotRepository/url" ) ); - assertEquals( Boolean.FALSE, pom.getValue( "distributionManagement/snapshotRepository/uniqueVersion" ) ); - - assertEquals( "project.site", pom.getValue( "distributionManagement/site/id" ) ); - assertEquals( "docs", pom.getValue( "distributionManagement/site/name" ) ); - assertEquals( "http://project.url/site", pom.getValue( "distributionManagement/site/url" ) ); - - assertEquals( "http://project.url/download", pom.getValue( "distributionManagement/downloadUrl" ) ); - assertEquals( "reloc-gid", pom.getValue( "distributionManagement/relocation/groupId" ) ); - assertEquals( "reloc-aid", pom.getValue( "distributionManagement/relocation/artifactId" ) ); - assertEquals( "reloc-version", pom.getValue( "distributionManagement/relocation/version" ) ); - assertEquals( "project-reloc-msg", pom.getValue( "distributionManagement/relocation/message" ) ); - - assertEquals( 1, ( (List<?>) pom.getValue( "modules" ) ).size() ); - assertEquals( "sub", pom.getValue( "modules[1]" ) ); - - assertEquals( 1, ( (Map<?, ?>) pom.getValue( "properties" ) ).size() ); - assertEquals( "project-property", pom.getValue( "properties[1]/itProperty" ) ); - - assertEquals( 1, ( (List<?>) pom.getValue( "dependencyManagement/dependencies" ) ).size() ); - assertEquals( "org.apache.maven.its", pom.getValue( "dependencyManagement/dependencies[1]/groupId" ) ); - assertEquals( "managed-dep", pom.getValue( "dependencyManagement/dependencies[1]/artifactId" ) ); - assertEquals( "0.1", pom.getValue( "dependencyManagement/dependencies[1]/version" ) ); - assertEquals( "war", pom.getValue( "dependencyManagement/dependencies[1]/type" ) ); - assertEquals( "runtime", pom.getValue( "dependencyManagement/dependencies[1]/scope" ) ); - assertEquals( Boolean.FALSE, pom.getValue( "dependencyManagement/dependencies[1]/optional" ) ); - assertEquals( 1, ( (List<?>) pom.getValue( "dependencyManagement/dependencies[1]/exclusions" ) ).size() ); - assertEquals( "org.apache.maven.its", - pom.getValue( "dependencyManagement/dependencies[1]/exclusions[1]/groupId" ) ); - assertEquals( "excluded-managed-dep", - pom.getValue( "dependencyManagement/dependencies[1]/exclusions[1]/artifactId" ) ); - - assertEquals( 1, ( (List<?>) pom.getValue( "dependencies" ) ).size() ); - assertEquals( "org.apache.maven.its", pom.getValue( "dependencies[1]/groupId" ) ); - assertEquals( "dep", pom.getValue( "dependencies[1]/artifactId" ) ); - assertEquals( "0.2", pom.getValue( "dependencies[1]/version" ) ); - assertEquals( "ejb", pom.getValue( "dependencies[1]/type" ) ); - assertEquals( "test", pom.getValue( "dependencies[1]/scope" ) ); - assertEquals( Boolean.TRUE, pom.getValue( "dependencies[1]/optional" ) ); - assertEquals( 1, ( (List<?>) pom.getValue( "dependencies[1]/exclusions" ) ).size() ); - assertEquals( "org.apache.maven.its", pom.getValue( "dependencies[1]/exclusions[1]/groupId" ) ); - assertEquals( "excluded-dep", pom.getValue( "dependencies[1]/exclusions[1]/artifactId" ) ); - - assertEquals( 2, ( (List<?>) pom.getValue( "repositories" ) ).size() ); - assertEquals( "project-remote-repo", pom.getValue( "repositories[1]/id" ) ); - assertEquals( "http://project.url/remote", pom.getValue( "repositories[1]/url" ) ); - assertEquals( "repo", pom.getValue( "repositories[1]/name" ) ); - assertEquals( RepositorySystem.DEFAULT_REMOTE_REPO_ID, pom.getValue( "repositories[2]/id" ) ); - assertEquals( RepositorySystem.DEFAULT_REMOTE_REPO_URL, pom.getValue( "repositories[2]/url" ) ); - - assertEquals( "test", pom.getValue( "build/defaultGoal" ) ); - assertEquals( "coreit", pom.getValue( "build/finalName" ) ); - - assertPathSuffixEquals( "build", pom.getValue( "build/directory" ) ); - assertPathSuffixEquals( "build/main", pom.getValue( "build/outputDirectory" ) ); - assertPathSuffixEquals( "build/test", pom.getValue( "build/testOutputDirectory" ) ); - assertPathSuffixEquals( "sources/main", pom.getValue( "build/sourceDirectory" ) ); - assertPathSuffixEquals( "sources/test", pom.getValue( "build/testSourceDirectory" ) ); - assertPathSuffixEquals( "sources/scripts", pom.getValue( "build/scriptSourceDirectory" ) ); - - assertEquals( 1, ( (List<?>) pom.getValue( "build/filters" ) ).size() ); - assertPathSuffixEquals( "src/main/filter/it.properties", pom.getValue( "build/filters[1]" ) ); - - assertEquals( 1, ( (List<?>) pom.getValue( "build/resources" ) ).size() ); - assertPathSuffixEquals( "res/main", pom.getValue( "build/resources[1]/directory" ) ); - assertPathSuffixEquals( "main", pom.getValue( "build/resources[1]/targetPath" ) ); - assertEquals( Boolean.TRUE, pom.getValue( "build/resources[1]/filtering" ) ); - assertEquals( 1, ( (List<?>) pom.getValue( "build/resources[1]/includes" ) ).size() ); - assertPathSuffixEquals( "main.included", pom.getValue( "build/resources[1]/includes[1]" ) ); - assertEquals( 1, ( (List<?>) pom.getValue( "build/resources[1]/excludes" ) ).size() ); - assertPathSuffixEquals( "main.excluded", pom.getValue( "build/resources[1]/excludes[1]" ) ); - - assertEquals( 1, ( (List<?>) pom.getValue( "build/testResources" ) ).size() ); - assertPathSuffixEquals( "res/test", pom.getValue( "build/testResources[1]/directory" ) ); - assertPathSuffixEquals( "test", pom.getValue( "build/testResources[1]/targetPath" ) ); - assertEquals( Boolean.TRUE, pom.getValue( "build/testResources[1]/filtering" ) ); - assertEquals( 1, ( (List<?>) pom.getValue( "build/testResources[1]/includes" ) ).size() ); - assertPathSuffixEquals( "test.included", pom.getValue( "build/testResources[1]/includes[1]" ) ); - assertEquals( 1, ( (List<?>) pom.getValue( "build/testResources[1]/excludes" ) ).size() ); - assertPathSuffixEquals( "test.excluded", pom.getValue( "build/testResources[1]/excludes[1]" ) ); - - assertEquals( 1, ( (List<?>) pom.getValue( "build/extensions" ) ).size() ); - assertEquals( "org.apache.maven.its.ext", pom.getValue( "build/extensions[1]/groupId" ) ); - assertEquals( "ext", pom.getValue( "build/extensions[1]/artifactId" ) ); - assertEquals( "3.0", pom.getValue( "build/extensions[1]/version" ) ); - - assertEquals( 1, ( (List<?>) pom.getValue( "build/plugins" ) ).size() ); - assertEquals( "org.apache.maven.its.plugins", pom.getValue( "build/plugins[1]/groupId" ) ); - assertEquals( "maven-it-plugin-build", pom.getValue( "build/plugins[1]/artifactId" ) ); - assertEquals( "2.1-SNAPSHOT", pom.getValue( "build/plugins[1]/version" ) ); - assertEquals( "test.properties", pom.getValue( "build/plugins[1]/configuration/outputFile" ) ); - assertEquals( 1, ( (List<?>) pom.getValue( "build/plugins[1]/executions" ) ).size() ); - assertEquals( "test", pom.getValue( "build/plugins[1]/executions[1]/id" ) ); - assertEquals( "validate", pom.getValue( "build/plugins[1]/executions[1]/phase" ) ); - assertEquals( "pom.properties", pom.getValue( "build/plugins[1]/executions[1]/configuration/outputFile" ) ); - assertEquals( 1, ( (List<?>) pom.getValue( "build/plugins[1]/executions[1]/goals" ) ).size() ); - assertEquals( "eval", pom.getValue( "build/plugins[1]/executions[1]/goals[1]" ) ); - assertEquals( 1, ( (List<?>) pom.getValue( "build/plugins[1]/dependencies" ) ).size() ); - assertEquals( "org.apache.maven.its", pom.getValue( "build/plugins[1]/dependencies[1]/groupId" ) ); - assertEquals( "build-plugin-dep", pom.getValue( "build/plugins[1]/dependencies[1]/artifactId" ) ); - assertEquals( "0.3", pom.getValue( "build/plugins[1]/dependencies[1]/version" ) ); - assertEquals( "zip", pom.getValue( "build/plugins[1]/dependencies[1]/type" ) ); - assertEquals( 1, ( (List<?>) pom.getValue( "build/plugins[1]/dependencies[1]/exclusions" ) ).size() ); - assertEquals( "org.apache.maven.its", pom.getValue( "build/plugins[1]/dependencies[1]/exclusions[1]/groupId" ) ); - assertEquals( "excluded-build-plugin-dep", - pom.getValue( "build/plugins[1]/dependencies[1]/exclusions[1]/artifactId" ) ); - - assertEquals( Boolean.TRUE, pom.getValue( "reporting/excludeDefaults" ) ); - assertPathSuffixEquals( "docs", pom.getValue( "reporting/outputDirectory" ) ); - - assertEquals( 1, ( (List<?>) pom.getValue( "reporting/plugins" ) ).size() ); - assertEquals( "org.apache.maven.its.plugins", pom.getValue( "reporting/plugins[1]/groupId" ) ); - assertEquals( "maven-it-plugin-reporting", pom.getValue( "reporting/plugins[1]/artifactId" ) ); - assertEquals( "2.0-SNAPSHOT", pom.getValue( "reporting/plugins[1]/version" ) ); - assertEquals( "test.html", pom.getValue( "reporting/plugins[1]/configuration/outputFile" ) ); - assertEquals( 1, ( (List<?>) pom.getValue( "reporting/plugins[1]/reportSets" ) ).size() ); - assertEquals( "it", pom.getValue( "reporting/plugins[1]/reportSets[1]/id" ) ); - assertEquals( "index.html", pom.getValue( "reporting/plugins[1]/reportSets[1]/configuration/outputFile" ) ); - assertEquals( 1, ( (List<?>) pom.getValue( "reporting/plugins[1]/reportSets[1]/reports" ) ).size() ); - assertEquals( "run", pom.getValue( "reporting/plugins[1]/reportSets[1]/reports[1]" ) ); - } - - /* MNG-2309*/ - - public void testProfileInjectionOrder() - throws Exception - { - PomTestWrapper pom = - buildPom( "profile-injection-order", "pom-a", "pom-b", "pom-e", "pom-c", "pom-d" ); - assertEquals( "e", pom.getValue( "properties[1]/pomProperty" ) ); - } - - public void testPropertiesInheritance() - throws Exception - { - PomTestWrapper pom = buildPom( "properties-inheritance/sub" ); - assertEquals( "parent-property", pom.getValue( "properties/parentProperty" ) ); - assertEquals( "child-property", pom.getValue( "properties/childProperty" ) ); - assertEquals( "child-override", pom.getValue( "properties/overriddenProperty" ) ); - } - - /* MNG-4102*/ - public void testInheritedPropertiesInterpolatedWithValuesFromChildWithoutProfiles() - throws Exception - { - PomTestWrapper pom = buildPom( "inherited-properties-interpolation/no-profile/sub" ); - - assertEquals( "CHILD", pom.getValue( "properties/overridden" ) ); - assertEquals( "CHILD", pom.getValue( "properties/interpolated" ) ); - } - - /* MNG-4102 */ - public void testInheritedPropertiesInterpolatedWithValuesFromChildWithActiveProfiles() - throws Exception - { - PomTestWrapper pom = buildPom( "inherited-properties-interpolation/active-profile/sub" ); - - assertEquals( 1, pom.getMavenProject().getModel().getProfiles().size() ); - - buildPom( "inherited-properties-interpolation/active-profile/sub", "it-parent", "it-child" ); - assertEquals( "CHILD", pom.getValue( "properties/overridden" ) ); - assertEquals( "CHILD", pom.getValue( "properties/interpolated" ) ); - } - - /* MNG-3545 */ - public void testProfileDefaultActivation() - throws Exception - { - PomTestWrapper pom = buildPom( "profile-default-deactivation", "profile4" ); - assertEquals( 1, pom.getMavenProject().getActiveProfiles().size() ); - assertEquals( 1, ( (List<?>) pom.getValue( "build/plugins" ) ).size() ); - assertEquals( "2.1", pom.getValue( "build/plugins[1]/version" ) ); - } - - /* MNG-1995 */ - public void testBooleanInterpolation() - throws Exception - { - PomTestWrapper pom = buildPom( "boolean-interpolation" ); - assertTrue ((Boolean) pom.getValue( "repositories[1]/releases/enabled" ) ); - assertTrue((Boolean) pom.getValue( "build/resources[1]/filtering" ) ); - } - - - /* MNG-3899 */ - public void testBuildExtensionInheritance() - throws Exception - { - PomTestWrapper pom = buildPom( "build-extension-inheritance/sub" ); - assertEquals( 3, ( (List<?>) pom.getValue( "build/extensions" ) ).size() ); - assertEquals( "b", pom.getValue( "build/extensions[1]/artifactId" ) ); - assertEquals( "a", pom.getValue( "build/extensions[2]/artifactId" ) ); - assertEquals( "0.2", pom.getValue( "build/extensions[2]/version" ) ); - assertEquals( "c", pom.getValue( "build/extensions[3]/artifactId" ) ); - } - - /*MNG-1957*/ - public void testJdkActivation() - throws Exception - { - Properties props = new Properties(); - props.put( "java.version", "1.5.0_15" ); - - PomTestWrapper pom = buildPom( "jdk-activation", props ); - assertEquals( 3, pom.getMavenProject().getActiveProfiles().size() ); - assertEquals( "PASSED", pom.getValue( "properties/jdkProperty3" ) ); - assertEquals( "PASSED", pom.getValue( "properties/jdkProperty2" ) ); - assertEquals( "PASSED", pom.getValue( "properties/jdkProperty1" ) ); - } - - /* MNG-2174 */ - public void testProfilePluginMngDependencies() - throws Exception - { - PomTestWrapper pom = buildPom( "profile-plugin-mng-dependencies/sub", "maven-core-it" ); - assertEquals( "a", pom.getValue( "build/plugins[1]/dependencies[1]/artifactId" ) ); - } - - /** MNG-4116 */ - public void testPercentEncodedUrlsMustNotBeDecoded() - throws Exception - { - PomTestWrapper pom = this.buildPom( "url-no-decoding" ); - assertEquals( "http://maven.apache.org/spacy%20path", pom.getValue( "url" ) ); - assertEquals( "http://svn.apache.org/viewvc/spacy%20path", pom.getValue( "scm/url" ) ); - assertEquals( "scm:svn:svn+ssh://svn.apache.org/spacy%20path", pom.getValue( "scm/connection" ) ); - assertEquals( "scm:svn:svn+ssh://svn.apache.org/spacy%20path", pom.getValue( "scm/developerConnection" ) ); - assertEquals( "http://issues.apache.org/spacy%20path", pom.getValue( "issueManagement/url" ) ); - assertEquals( "http://ci.apache.org/spacy%20path", pom.getValue( "ciManagement/url" ) ); - assertEquals( "scm:svn:svn+ssh://dist.apache.org/spacy%20path", - pom.getValue( "distributionManagement/repository/url" ) ); - assertEquals( "scm:svn:svn+ssh://snap.apache.org/spacy%20path", - pom.getValue( "distributionManagement/snapshotRepository/url" ) ); - assertEquals( "scm:svn:svn+ssh://site.apache.org/spacy%20path", - pom.getValue( "distributionManagement/site/url" ) ); - } - - public void testPluginManagementInheritance() - throws Exception - { - PomTestWrapper pom = this.buildPom( "plugin-management-inheritance" ); - assertEquals( "0.1-stub-SNAPSHOT", - pom.getValue( "build/pluginManagement/plugins[@artifactId='maven-compiler-plugin']/version" ) ); - } - - public void testProfilePlugins() - throws Exception - { - PomTestWrapper pom = this.buildPom( "profile-plugins", "standard" ); - assertEquals( 2, ( (List<?>) pom.getValue( "build/plugins" ) ).size() ); - assertEquals( "maven-assembly2-plugin", pom.getValue( "build/plugins[2]/artifactId" ) ); - } - - public void testPluginInheritanceSimple() - throws Exception - { - PomTestWrapper pom = this.buildPom( "plugin-inheritance-simple/sub" ); - assertEquals( 2, ( (List<?>) pom.getValue( "build/plugins" ) ).size() ); - } - - public void testPluginManagementDuplicate() - throws Exception - { - PomTestWrapper pom = this.buildPom( "plugin-management-duplicate/sub" ); - assertEquals( 12, ( (List<?>) pom.getValue( "build/pluginManagement/plugins" ) ).size() ); - } - - public void testDistributionManagement() - throws Exception - { - PomTestWrapper pom = this.buildPom( "distribution-management" ); - assertEquals( "legacy", pom.getValue( "distributionManagement/repository/layout" ) ); - } - - public void testDependencyScopeInheritance() - throws Exception - { - PomTestWrapper pom = buildPom( "dependency-scope-inheritance/sub" ); - String scope = (String) pom.getValue( "dependencies[1]/scope" ); - assertEquals( "compile", scope ); - } - - public void testDependencyScope() - throws Exception - { - buildPom( "dependency-scope/sub" ); - } - - //This will fail on a validation error if incorrect - public void testDependencyManagementWithInterpolation() - throws Exception - { - buildPom( "dependency-management-with-interpolation/sub" ); - } - - public void testInterpolationWithSystemProperty() - throws Exception - { - Properties sysProps = new Properties(); - sysProps.setProperty( "system.property", "PASSED" ); - PomTestWrapper pom = buildPom( "sytem-property-interpolation", sysProps ); - assertEquals( "PASSED", pom.getValue( "name" ) ); - } - - /* MNG-4129 */ - public void testPluginExecutionInheritanceWhenChildDoesNotDeclarePlugin() - throws Exception - { - PomTestWrapper pom = buildPom( "plugin-exec-inheritance/wo-merge" ); - @SuppressWarnings( "unchecked" ) - List<PluginExecution> executions = - (List<PluginExecution>) pom.getValue( "build/pluginsAsMap[@name='org.apache.maven.its.plugins:maven-it-plugin-log-file']/executions" ); - assertEquals( 1, executions.size() ); - assertEquals( "inherited-execution", executions.get( 0 ).getId() ); - } - - public void testPluginExecutionInheritanceWhenChildDoesDeclarePluginAsWell() - throws Exception - { - PomTestWrapper pom = buildPom( "plugin-exec-inheritance/w-merge" ); - @SuppressWarnings( "unchecked" ) - List<PluginExecution> executions = - (List<PluginExecution>) pom.getValue( "build/pluginsAsMap[@name='org.apache.maven.its.plugins:maven-it-plugin-log-file']/executions" ); - assertEquals( 1, executions.size() ); - assertEquals( "inherited-execution", executions.get( 0 ).getId() ); - } - - /* MNG-4193 */ - public void testValidationErrorUponNonUniqueArtifactRepositoryId() - throws Exception - { - try - { - buildPom( "unique-repo-id/artifact-repo" ); - fail( "Non-unique repository ids did not cause validation error" ); - } - catch ( ProjectBuildingException e ) - { - // expected - } - } - - /* MNG-4193 */ - public void testValidationErrorUponNonUniquePluginRepositoryId() - throws Exception - { - try - { - buildPom( "unique-repo-id/plugin-repo" ); - fail( "Non-unique repository ids did not cause validation error" ); - } - catch ( ProjectBuildingException e ) - { - // expected - } - } - - /* MNG-4193 */ - public void testValidationErrorUponNonUniqueArtifactRepositoryIdInProfile() - throws Exception - { - try - { - buildPom( "unique-repo-id/artifact-repo-in-profile" ); - fail( "Non-unique repository ids did not cause validation error" ); - } - catch ( ProjectBuildingException e ) - { - // expected - } - } - - /* MNG-4193 */ - public void testValidationErrorUponNonUniquePluginRepositoryIdInProfile() - throws Exception - { - try - { - buildPom( "unique-repo-id/plugin-repo-in-profile" ); - fail( "Non-unique repository ids did not cause validation error" ); - } - catch ( ProjectBuildingException e ) - { - // expected - } - } - - /** MNG-3843 */ - public void testPrerequisitesAreNotInherited() - throws Exception - { - PomTestWrapper pom = buildPom( "prerequisites-inheritance/child" ); - assertSame( null, pom.getValue( "prerequisites" ) ); - } - - public void testLicensesAreInheritedButNotAggregated() - throws Exception - { - PomTestWrapper pom = buildPom( "licenses-inheritance/child-2" ); - assertEquals( 1, ( (List<?>) pom.getValue( "licenses" ) ).size() ); - assertEquals( "child-license", pom.getValue( "licenses[1]/name" ) ); - assertEquals( "http://child.url/license", pom.getValue( "licenses[1]/url" ) ); - } - - public void testDevelopersAreInheritedButNotAggregated() - throws Exception - { - PomTestWrapper pom = buildPom( "developers-inheritance/child-2" ); - assertEquals( 1, ( (List<?>) pom.getValue( "developers" ) ).size() ); - assertEquals( "child-developer", pom.getValue( "developers[1]/name" ) ); - } - - public void testContributorsAreInheritedButNotAggregated() - throws Exception - { - PomTestWrapper pom = buildPom( "contributors-inheritance/child-2" ); - assertEquals( 1, ( (List<?>) pom.getValue( "contributors" ) ).size() ); - assertEquals( "child-contributor", pom.getValue( "contributors[1]/name" ) ); - } - - public void testMailingListsAreInheritedButNotAggregated() - throws Exception - { - PomTestWrapper pom = buildPom( "mailing-lists-inheritance/child-2" ); - assertEquals( 1, ( (List<?>) pom.getValue( "mailingLists" ) ).size() ); - assertEquals( "child-mailing-list", pom.getValue( "mailingLists[1]/name" ) ); - } - - public void testPluginInheritanceOrder() - throws Exception - { - PomTestWrapper pom = buildPom( "plugin-inheritance-order/child" ); - - assertEquals( "maven-it-plugin-log-file", pom.getValue( "build/plugins[1]/artifactId" ) ); - assertEquals( "maven-it-plugin-expression", pom.getValue( "build/plugins[2]/artifactId" ) ); - assertEquals( "maven-it-plugin-configuration", pom.getValue( "build/plugins[3]/artifactId" ) ); - - assertEquals( "maven-it-plugin-log-file", pom.getValue( "reporting/plugins[1]/artifactId" ) ); - assertEquals( "maven-it-plugin-expression", pom.getValue( "reporting/plugins[2]/artifactId" ) ); - assertEquals( "maven-it-plugin-configuration", pom.getValue( "reporting/plugins[3]/artifactId" ) ); - } - - public void testCliPropsDominateProjectPropsDuringInterpolation() - throws Exception - { - Properties props = new Properties(); - props.setProperty( "testProperty", "PASSED" ); - PomTestWrapper pom = buildPom( "interpolation-cli-wins", props ); - - assertEquals( "PASSED", pom.getValue( "properties/interpolatedProperty" ) ); - } - - public void testParentPomPackagingMustBePom() - throws Exception - { - try - { - buildPom( "parent-pom-packaging/sub" ); - fail( "Wrong packaging of parent POM was not rejected" ); - } - catch ( ProjectBuildingException e ) - { - // expected - } - } - - /** MNG-522, MNG-3018 */ - public void testManagedPluginConfigurationAppliesToImplicitPluginsIntroducedByPackaging() - throws Exception - { - PomTestWrapper pom = buildPom( "plugin-management-for-implicit-plugin/child" ); - assertEquals( "passed.txt", - pom.getValue( "build/plugins[@artifactId='maven-resources-plugin']/configuration/pathname" ) ); - assertEquals( "passed.txt", - pom.getValue( "build/plugins[@artifactId='maven-it-plugin-log-file']/configuration/logFile" ) ); - } - - public void testDefaultPluginsExecutionContributedByPackagingExecuteBeforeUserDefinedExecutions() - throws Exception - { - PomTestWrapper pom = buildPom( "plugin-exec-order-and-default-exec" ); - @SuppressWarnings( "unchecked" ) - List<PluginExecution> executions = - (List<PluginExecution>) pom.getValue( "build/plugins[@artifactId='maven-resources-plugin']/executions" ); - assertNotNull( executions ); - assertEquals( 4, executions.size() ); - assertEquals( "default-resources", executions.get( 0 ).getId() ); - assertEquals( "default-testResources", executions.get( 1 ).getId() ); - assertEquals( "test-1", executions.get( 2 ).getId() ); - assertEquals( "test-2", executions.get( 3 ).getId() ); - } - - public void testPluginDeclarationsRetainPomOrderAfterInjectionOfDefaultPlugins() - throws Exception - { - PomTestWrapper pom = buildPom( "plugin-exec-order-with-lifecycle" ); - @SuppressWarnings( "unchecked" ) - List<Plugin> plugins = (List<Plugin>) pom.getValue( "build/plugins" ); - int resourcesPlugin = -1; - int customPlugin = -1; - for ( int i = 0; i < plugins.size(); i++ ) - { - Plugin plugin = plugins.get( i ); - if ( "maven-resources-plugin".equals( plugin.getArtifactId() ) ) - { - assertTrue( resourcesPlugin < 0 ); - resourcesPlugin = i; - } - else if ( "maven-it-plugin-log-file".equals( plugin.getArtifactId() ) ) - { - assertTrue( customPlugin < 0 ); - customPlugin = i; - } - } - assertTrue( plugins.toString(), customPlugin == resourcesPlugin - 1 ); - } - - /** MNG-4415 */ - public void testPluginOrderAfterMergingWithInheritedPlugins() - throws Exception - { - PomTestWrapper pom = buildPom( "plugin-inheritance-merge-order/sub" ); - - List<String> expected = new ArrayList<String>(); - expected.add( "maven-it-plugin-error" ); - expected.add( "maven-it-plugin-configuration" ); - expected.add( "maven-it-plugin-dependency-resolution" ); - expected.add( "maven-it-plugin-packaging" ); - expected.add( "maven-it-plugin-log-file" ); - expected.add( "maven-it-plugin-expression" ); - expected.add( "maven-it-plugin-fork" ); - expected.add( "maven-it-plugin-touch" ); - - List<String> actual = new ArrayList<String>(); - @SuppressWarnings( "unchecked" ) - List<Plugin> plugins = (List<Plugin>) pom.getValue( "build/plugins" ); - for ( Plugin plugin : plugins ) - { - actual.add( plugin.getArtifactId() ); - } - - actual.retainAll( expected ); - - assertEquals( actual, expected ); - } - - /** MNG-4416 */ - public void testPluginOrderAfterMergingWithInjectedPlugins() - throws Exception - { - PomTestWrapper pom = buildPom( "plugin-injection-merge-order" ); - - List<String> expected = new ArrayList<String>(); - expected.add( "maven-it-plugin-error" ); - expected.add( "maven-it-plugin-configuration" ); - expected.add( "maven-it-plugin-dependency-resolution" ); - expected.add( "maven-it-plugin-packaging" ); - expected.add( "maven-it-plugin-log-file" ); - expected.add( "maven-it-plugin-expression" ); - expected.add( "maven-it-plugin-fork" ); - expected.add( "maven-it-plugin-touch" ); - - List<String> actual = new ArrayList<String>(); - @SuppressWarnings( "unchecked" ) - List<Plugin> plugins = (List<Plugin>) pom.getValue( "build/plugins" ); - for ( Plugin plugin : plugins ) - { - actual.add( plugin.getArtifactId() ); - } - - actual.retainAll( expected ); - - assertEquals( actual, expected ); - } - - public void testProjectArtifactIdIsNotInheritedButMandatory() - throws Exception - { - try - { - buildPom( "artifact-id-inheritance/child" ); - fail( "Missing artifactId did not cause validation error" ); - } - catch ( ProjectBuildingException e ) - { - // expected - } - } - - private void assertPathSuffixEquals( String expected, Object actual ) - { - String a = actual.toString(); - a = a.substring( a.length() - expected.length() ).replace( '\\', '/' ); - assertEquals( expected, a ); - } - - private void assertPathWithNormalizedFileSeparators( Object value ) - { - assertEquals( new File( value.toString() ).getPath(), value.toString() ); - } - - private PomTestWrapper buildPom( String pomPath, String... profileIds ) - throws Exception - { - return buildPom( pomPath, null, profileIds ); - } - - private PomTestWrapper buildPom( String pomPath, Properties executionProperties, String... profileIds ) - throws Exception - { - return buildPom( pomPath, false, executionProperties, profileIds ); - } - - private PomTestWrapper buildPom( String pomPath, boolean lenientValidation, Properties executionProperties, - String... profileIds ) - throws Exception - { - File pomFile = new File( testDirectory, pomPath ); - if ( pomFile.isDirectory() ) - { - pomFile = new File( pomFile, "pom.xml" ); - } - - ProjectBuildingRequest config = new DefaultProjectBuildingRequest(); - - String localRepoUrl = - System.getProperty( "maven.repo.local", System.getProperty( "user.home" ) + "/.m2/repository" ); - localRepoUrl = "file://" + localRepoUrl; - config.setLocalRepository( repositorySystem.createArtifactRepository( "local", localRepoUrl, new DefaultRepositoryLayout(), null, null ) ); - config.setActiveProfileIds( Arrays.asList( profileIds ) ); - config.setSystemProperties( executionProperties ); - config.setUserProperties( executionProperties ); - config.setValidationLevel( lenientValidation ? ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_2_0 - : ModelBuildingRequest.VALIDATION_LEVEL_STRICT ); - - DefaultRepositorySystemSession repoSession = MavenRepositorySystemUtils.newSession(); - LocalRepository localRepo = new LocalRepository( config.getLocalRepository().getBasedir() ); - repoSession.setLocalRepositoryManager( new SimpleLocalRepositoryManagerFactory().newInstance( repoSession, localRepo ) ); - config.setRepositorySession( repoSession ); - - return new PomTestWrapper( pomFile, projectBuilder.build( pomFile, config ).getProject() ); - } - - protected void assertModelEquals( PomTestWrapper pom, Object expected, String expression ) - { - assertEquals( expected, pom.getValue( expression ) ); - } - - private static String createPath( List<String> elements ) - { - StringBuilder buffer = new StringBuilder( 256 ); - for ( String s : elements ) - { - buffer.append( s ).append( File.separator ); - } - return buffer.toString().substring( 0, buffer.toString().length() - 1 ); - } -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/ProjectBuilderTest.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/ProjectBuilderTest.java deleted file mode 100644 index 5511cb1a..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/ProjectBuilderTest.java +++ /dev/null @@ -1,87 +0,0 @@ -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.io.File; -import java.util.Properties; - -import org.apache.maven.AbstractCoreMavenComponentTestCase; -import org.apache.maven.execution.MavenSession; -import org.apache.maven.model.building.FileModelSource; -import org.apache.maven.model.building.ModelSource; - -public class ProjectBuilderTest - extends AbstractCoreMavenComponentTestCase -{ - protected String getProjectsDirectory() - { - return "src/test/projects/project-builder"; - } - - public void testSystemScopeDependencyIsPresentInTheCompileClasspathElements() - throws Exception - { - File pom = getProject( "it0063" ); - - Properties eps = new Properties(); - eps.setProperty( "jre.home", new File( pom.getParentFile(), "jdk/jre" ).getPath() ); - - MavenSession session = createMavenSession( pom, eps ); - MavenProject project = session.getCurrentProject(); - - // Here we will actually not have any artifacts because the ProjectDependenciesResolver is not involved here. So - // right now it's not valid to ask for artifacts unless plugins require the artifacts. - - project.getCompileClasspathElements(); - } - - public void testBuildFromModelSource() - throws Exception - { - File pomFile = new File( "src/test/resources/projects/modelsource/module01/pom.xml" ); - MavenSession mavenSession = createMavenSession( pomFile ); - ProjectBuildingRequest configuration = new DefaultProjectBuildingRequest(); - configuration.setRepositorySession( mavenSession.getRepositorySession() ); - ModelSource modelSource = new FileModelSource( pomFile ); - ProjectBuildingResult result = - lookup( org.apache.maven.project.ProjectBuilder.class ).build( modelSource, configuration ); - - assertNotNull( result.getProject().getParentFile() ); - } - - public void testVersionlessManagedDependency() - throws Exception - { - File pomFile = new File( "src/test/resources/projects/versionless-managed-dependency.xml" ); - MavenSession mavenSession = createMavenSession( null ); - ProjectBuildingRequest configuration = new DefaultProjectBuildingRequest(); - configuration.setRepositorySession( mavenSession.getRepositorySession() ); - - try - { - lookup( org.apache.maven.project.ProjectBuilder.class ).build( pomFile, configuration ); - fail(); - } - catch ( ProjectBuildingException e ) - { - // this is expected - } - } -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/ProjectSorterTest.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/ProjectSorterTest.java deleted file mode 100644 index 5cb45279..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/ProjectSorterTest.java +++ /dev/null @@ -1,363 +0,0 @@ -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.ArrayList; -import java.util.Collections; -import java.util.List; - -import junit.framework.TestCase; - -import org.apache.maven.model.Build; -import org.apache.maven.model.Dependency; -import org.apache.maven.model.Extension; -import org.apache.maven.model.Model; -import org.apache.maven.model.Parent; -import org.apache.maven.model.Plugin; -import org.apache.maven.model.PluginManagement; -import org.codehaus.plexus.util.dag.CycleDetectedException; - -/** - * Test sorting projects by dependencies. - * - * @author <a href="mailto:brett@apache.org">Brett Porter</a> - */ -public class ProjectSorterTest - extends TestCase -{ - - private Parent createParent( MavenProject project ) - { - return createParent( project.getGroupId(), project.getArtifactId(), project.getVersion() ); - } - - private Parent createParent( String groupId, String artifactId, String version ) - { - Parent plugin = new Parent(); - plugin.setGroupId( groupId ); - plugin.setArtifactId( artifactId ); - plugin.setVersion( version ); - return plugin; - } - - private Dependency createDependency( MavenProject project ) - { - return createDependency( project.getGroupId(), project.getArtifactId(), project.getVersion() ); - } - - private Dependency createDependency( String groupId, String artifactId, String version ) - { - Dependency depdendency = new Dependency(); - depdendency.setGroupId( groupId ); - depdendency.setArtifactId( artifactId ); - depdendency.setVersion( version ); - return depdendency; - } - - private Plugin createPlugin( MavenProject project ) - { - return createPlugin( project.getGroupId(), project.getArtifactId(), project.getVersion() ); - } - - private Plugin createPlugin( String groupId, String artifactId, String version ) - { - Plugin plugin = new Plugin(); - plugin.setGroupId( groupId ); - plugin.setArtifactId( artifactId ); - plugin.setVersion( version ); - return plugin; - } - - private Extension createExtension( String groupId, String artifactId, String version ) - { - Extension extension = new Extension(); - extension.setGroupId( groupId ); - extension.setArtifactId( artifactId ); - extension.setVersion( version ); - return extension; - } - - private static MavenProject createProject( String groupId, String artifactId, String version ) - { - Model model = new Model(); - model.setGroupId( groupId ); - model.setArtifactId( artifactId ); - model.setVersion( version ); - model.setBuild( new Build() ); - return new MavenProject( model ); - } - - public void testShouldNotFailWhenPluginDepReferencesCurrentProject() - throws CycleDetectedException, DuplicateProjectException - { - MavenProject project = createProject( "group", "artifact", "1.0" ); - - Build build = project.getModel().getBuild(); - - Plugin plugin = createPlugin( "other.group", "other-artifact", "1.0" ); - - Dependency dep = createDependency( "group", "artifact", "1.0" ); - - plugin.addDependency( dep ); - - build.addPlugin( plugin ); - - new ProjectSorter( Collections.singletonList( project ) ); - } - - public void testShouldNotFailWhenManagedPluginDepReferencesCurrentProject() - throws CycleDetectedException, DuplicateProjectException - { - MavenProject project = createProject( "group", "artifact", "1.0" ); - - Build build = project.getModel().getBuild(); - - PluginManagement pMgmt = new PluginManagement(); - - Plugin plugin = createPlugin( "other.group", "other-artifact", "1.0" ); - - Dependency dep = createDependency( "group", "artifact", "1.0" ); - - plugin.addDependency( dep ); - - pMgmt.addPlugin( plugin ); - - build.setPluginManagement( pMgmt ); - - new ProjectSorter( Collections.singletonList( project ) ); - } - - public void testShouldNotFailWhenProjectReferencesNonExistentProject() - throws CycleDetectedException, DuplicateProjectException - { - MavenProject project = createProject( "group", "artifact", "1.0" ); - - Build build = project.getModel().getBuild(); - - Extension extension = createExtension( "other.group", "other-artifact", "1.0" ); - - build.addExtension( extension ); - - new ProjectSorter( Collections.singletonList( project ) ); - } - - public void testMatchingArtifactIdsDifferentGroupIds() - throws CycleDetectedException, DuplicateProjectException - { - List<MavenProject> projects = new ArrayList<MavenProject>(); - MavenProject project1 = createProject( "groupId1", "artifactId", "1.0" ); - projects.add( project1 ); - MavenProject project2 = createProject( "groupId2", "artifactId", "1.0" ); - projects.add( project2 ); - project1.getDependencies().add( createDependency( project2 ) ); - - projects = new ProjectSorter( projects ).getSortedProjects(); - - assertEquals( project2, projects.get( 0 ) ); - assertEquals( project1, projects.get( 1 ) ); - } - - public void testMatchingGroupIdsDifferentArtifactIds() - throws CycleDetectedException, DuplicateProjectException - { - List<MavenProject> projects = new ArrayList<MavenProject>(); - MavenProject project1 = createProject( "groupId", "artifactId1", "1.0" ); - projects.add( project1 ); - MavenProject project2 = createProject( "groupId", "artifactId2", "1.0" ); - projects.add( project2 ); - project1.getDependencies().add( createDependency( project2 ) ); - - projects = new ProjectSorter( projects ).getSortedProjects(); - - assertEquals( project2, projects.get( 0 ) ); - assertEquals( project1, projects.get( 1 ) ); - } - - public void testMatchingIdsAndVersions() - throws CycleDetectedException - { - List<MavenProject> projects = new ArrayList<MavenProject>(); - MavenProject project1 = createProject( "groupId", "artifactId", "1.0" ); - projects.add( project1 ); - MavenProject project2 = createProject( "groupId", "artifactId", "1.0" ); - projects.add( project2 ); - - try - { - projects = new ProjectSorter( projects ).getSortedProjects(); - fail( "Duplicate projects should fail" ); - } - catch ( DuplicateProjectException e ) - { - // expected - assertTrue( true ); - } - } - - public void testMatchingIdsAndDifferentVersions() - throws CycleDetectedException, DuplicateProjectException - { - List<MavenProject> projects = new ArrayList<MavenProject>(); - MavenProject project1 = createProject( "groupId", "artifactId", "1.0" ); - projects.add( project1 ); - MavenProject project2 = createProject( "groupId", "artifactId", "2.0" ); - projects.add( project2 ); - - projects = new ProjectSorter( projects ).getSortedProjects(); - assertEquals( project1, projects.get( 0 ) ); - assertEquals( project2, projects.get( 1 ) ); - } - - public void testPluginDependenciesInfluenceSorting() - throws Exception - { - List<MavenProject> projects = new ArrayList<MavenProject>(); - - MavenProject parentProject = createProject( "groupId", "parent", "1.0" ); - projects.add( parentProject ); - - MavenProject declaringProject = createProject( "groupId", "declarer", "1.0" ); - declaringProject.setParent( parentProject ); - declaringProject.getModel().setParent( createParent( parentProject ) ); - projects.add( declaringProject ); - - MavenProject pluginLevelDepProject = createProject( "groupId", "plugin-level-dep", "1.0" ); - pluginLevelDepProject.setParent( parentProject ); - pluginLevelDepProject.getModel().setParent( createParent( parentProject ) ); - projects.add( pluginLevelDepProject ); - - MavenProject pluginProject = createProject( "groupId", "plugin", "1.0" ); - pluginProject.setParent( parentProject ); - pluginProject.getModel().setParent( createParent( parentProject ) ); - projects.add( pluginProject ); - - Plugin plugin = createPlugin( pluginProject ); - - plugin.addDependency( createDependency( pluginLevelDepProject ) ); - - Build build = declaringProject.getModel().getBuild(); - - build.addPlugin( plugin ); - - projects = new ProjectSorter( projects ).getSortedProjects(); - - assertEquals( parentProject, projects.get( 0 ) ); - - // the order of these two is non-deterministic, based on when they're added to the reactor. - assertTrue( projects.contains( pluginProject ) ); - assertTrue( projects.contains( pluginLevelDepProject ) ); - - // the declaring project MUST be listed after the plugin and its plugin-level dep, though. - assertEquals( declaringProject, projects.get( 3 ) ); - } - - public void testPluginDependenciesInfluenceSorting_DeclarationInParent() - throws Exception - { - List<MavenProject> projects = new ArrayList<MavenProject>(); - - MavenProject parentProject = createProject( "groupId", "parent-declarer", "1.0" ); - projects.add( parentProject ); - - MavenProject pluginProject = createProject( "groupId", "plugin", "1.0" ); - pluginProject.setParent( parentProject ); - pluginProject.getModel().setParent( createParent( parentProject ) ); - projects.add( pluginProject ); - - MavenProject pluginLevelDepProject = createProject( "groupId", "plugin-level-dep", "1.0" ); - pluginLevelDepProject.setParent( parentProject ); - pluginLevelDepProject.getModel().setParent( createParent( parentProject ) ); - projects.add( pluginLevelDepProject ); - - Plugin plugin = createPlugin( pluginProject ); - - plugin.addDependency( createDependency( pluginLevelDepProject ) ); - - Build build = parentProject.getModel().getBuild(); - - build.addPlugin( plugin ); - - projects = new ProjectSorter( projects ).getSortedProjects(); - - System.out.println( projects ); - - assertEquals( parentProject, projects.get( 0 ) ); - - // the order of these two is non-deterministic, based on when they're added to the reactor. - assertTrue( projects.contains( pluginProject ) ); - assertTrue( projects.contains( pluginLevelDepProject ) ); - } - - public void testPluginVersionsAreConsidered() - throws Exception - { - List<MavenProject> projects = new ArrayList<MavenProject>(); - - MavenProject pluginProjectA = createProject( "group", "plugin-a", "2.0-SNAPSHOT" ); - projects.add( pluginProjectA ); - pluginProjectA.getModel().getBuild().addPlugin( createPlugin( "group", "plugin-b", "1.0" ) ); - - MavenProject pluginProjectB = createProject( "group", "plugin-b", "2.0-SNAPSHOT" ); - projects.add( pluginProjectB ); - pluginProjectB.getModel().getBuild().addPlugin( createPlugin( "group", "plugin-a", "1.0" ) ); - - projects = new ProjectSorter( projects ).getSortedProjects(); - - assertTrue( projects.contains( pluginProjectA ) ); - assertTrue( projects.contains( pluginProjectB ) ); - } - - public void testDependencyPrecedesProjectThatUsesSpecificDependencyVersion() - throws Exception - { - List<MavenProject> projects = new ArrayList<MavenProject>(); - - MavenProject usingProject = createProject( "group", "project", "1.0" ); - projects.add( usingProject ); - usingProject.getModel().addDependency( createDependency( "group", "dependency", "1.0" ) ); - - MavenProject pluginProject = createProject( "group", "dependency", "1.0" ); - projects.add( pluginProject ); - - projects = new ProjectSorter( projects ).getSortedProjects(); - - assertEquals( pluginProject, projects.get( 0 ) ); - assertEquals( usingProject, projects.get( 1 ) ); - } - - public void testDependencyPrecedesProjectThatUsesUnresolvedDependencyVersion() - throws Exception - { - List<MavenProject> projects = new ArrayList<MavenProject>(); - - MavenProject usingProject = createProject( "group", "project", "1.0" ); - projects.add( usingProject ); - usingProject.getModel().addDependency( createDependency( "group", "dependency", "[1.0,)" ) ); - - MavenProject pluginProject = createProject( "group", "dependency", "1.0" ); - projects.add( pluginProject ); - - projects = new ProjectSorter( projects ).getSortedProjects(); - - assertEquals( pluginProject, projects.get( 0 ) ); - assertEquals( usingProject, projects.get( 1 ) ); - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/TestMetadataSource.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/TestMetadataSource.java deleted file mode 100644 index 67c0037b..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/TestMetadataSource.java +++ /dev/null @@ -1,51 +0,0 @@ -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.List; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; -import org.apache.maven.artifact.metadata.ResolutionGroup; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.project.artifact.MavenMetadataSource; -import org.codehaus.plexus.component.annotations.Component; - -@SuppressWarnings( "deprecation" ) -@Component( role = ArtifactMetadataSource.class, hint = "classpath" ) -public class TestMetadataSource - extends MavenMetadataSource -{ - @Override - public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, - List<ArtifactRepository> remoteRepositories ) - throws ArtifactMetadataRetrievalException - { - ResolutionGroup rg = super.retrieve( artifact, localRepository, remoteRepositories ); - - for ( Artifact a : rg.getArtifacts() ) - { - a.setResolved( true ); - } - - return rg; - } -}
\ No newline at end of file diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/artifact/DefaultMavenMetadataCacheTest.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/artifact/DefaultMavenMetadataCacheTest.java deleted file mode 100644 index 6b103b2c..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/artifact/DefaultMavenMetadataCacheTest.java +++ /dev/null @@ -1,81 +0,0 @@ -package org.apache.maven.project.artifact; - -/* - * 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.Arrays; -import java.util.Collections; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.resolver.filter.ExcludesArtifactFilter; -import org.apache.maven.project.artifact.DefaultMavenMetadataCache.CacheKey; -import org.apache.maven.repository.DelegatingLocalArtifactRepository; -import org.apache.maven.repository.RepositorySystem; -import org.codehaus.plexus.PlexusTestCase; - -/** - * @author Igor Fedorenko - */ -public class DefaultMavenMetadataCacheTest - extends PlexusTestCase -{ - private RepositorySystem repositorySystem; - - protected void setUp() - throws Exception - { - super.setUp(); - repositorySystem = lookup( RepositorySystem.class ); - } - - @Override - protected void tearDown() - throws Exception - { - repositorySystem = null; - super.tearDown(); - } - - public void testCacheKey() - throws Exception - { - Artifact a1 = repositorySystem.createArtifact( "testGroup", "testArtifact", "1.2.3", "jar" ); - @SuppressWarnings( "deprecation" ) - ArtifactRepository lr1 = new DelegatingLocalArtifactRepository( repositorySystem.createDefaultLocalRepository() ); - ArtifactRepository rr1 = repositorySystem.createDefaultRemoteRepository(); - a1.setDependencyFilter( new ExcludesArtifactFilter( Arrays.asList( "foo" ) ) ); - - Artifact a2 = repositorySystem.createArtifact( "testGroup", "testArtifact", "1.2.3", "jar" ); - @SuppressWarnings( "deprecation" ) - ArtifactRepository lr2 = new DelegatingLocalArtifactRepository( repositorySystem.createDefaultLocalRepository() ); - ArtifactRepository rr2 = repositorySystem.createDefaultRemoteRepository(); - a2.setDependencyFilter( new ExcludesArtifactFilter( Arrays.asList( "foo" ) ) ); - - // sanity checks - assertNotSame( a1, a2 ); - assertNotSame( lr1, lr2 ); - assertNotSame( rr1, rr2 ); - - CacheKey k1 = new CacheKey( a1, false, lr1, Collections.singletonList( rr1 ) ); - CacheKey k2 = new CacheKey( a2, false, lr2, Collections.singletonList( rr2 ) ); - - assertEquals(k1.hashCode(), k2.hashCode()); - } -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/artifact/MavenMetadataSourceTest.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/artifact/MavenMetadataSourceTest.java deleted file mode 100644 index 9c770da9..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/artifact/MavenMetadataSourceTest.java +++ /dev/null @@ -1,183 +0,0 @@ -package org.apache.maven.project.artifact; - -/* - * 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 org.apache.maven.repository.RepositorySystem; -import org.codehaus.plexus.PlexusTestCase; - -public class MavenMetadataSourceTest - extends PlexusTestCase -{ - private RepositorySystem repositorySystem; - - protected void setUp() - throws Exception - { - super.setUp(); - repositorySystem = lookup( RepositorySystem.class ); - } - - @Override - protected void tearDown() - throws Exception - { - repositorySystem = null; - super.tearDown(); - } - - public void testShouldNotCarryExclusionsOverFromDependencyToDependency() - throws Exception - { - /* - Dependency dep1 = new Dependency(); - dep1.setGroupId( "test" ); - dep1.setArtifactId( "test-artifact" ); - dep1.setVersion( "1" ); - dep1.setType( "jar" ); - - Exclusion exc = new Exclusion(); - exc.setGroupId( "test" ); - exc.setArtifactId( "test-artifact3" ); - - dep1.addExclusion( exc ); - - Dependency dep2 = new Dependency(); - dep2.setGroupId( "test" ); - dep2.setArtifactId( "test-artifact2" ); - dep2.setVersion( "1" ); - dep2.setType( "jar" ); - - List deps = new ArrayList(); - deps.add( dep1 ); - deps.add( dep2 ); - - ArtifactFactory factory = lookup( ArtifactFactory.class ); - - ArtifactFilter dependencyFilter = new ScopeArtifactFilter( Artifact.SCOPE_COMPILE ); - - MavenProject project = new MavenProject( new Model() ); - - Set result = project.createArtifacts( dependencyFilter ); - - for ( Iterator it = result.iterator(); it.hasNext(); ) - { - Artifact artifact = ( Artifact ) it.next(); - - if ( "test-artifact2".equals( artifact.getArtifactId() ) ) - { - ArtifactFilter filter = artifact.getDependencyFilter(); - - assertSame( dependencyFilter, filter ); - } - } - */ - } - - //TODO: restore these if it makes sense - /* - public void testShouldUseCompileScopeIfDependencyScopeEmpty() - throws Exception - { - String groupId = "org.apache.maven"; - String artifactId = "maven-model"; - - Dependency dep = new Dependency(); - - dep.setGroupId( groupId ); - dep.setArtifactId( artifactId ); - dep.setVersion( "2.0-alpha-3" ); - - Model model = new Model(); - - model.addDependency( dep ); - - MavenProject project = new MavenProject( model, repositorySystem ); - - project.setArtifacts( project.createArtifacts( null ) ); - - String key = ArtifactUtils.versionlessKey( groupId, artifactId ); - - Map artifactMap = project.getArtifactMap(); - - assertNotNull( "artifact-map should not be null.", artifactMap ); - assertEquals( "artifact-map should contain 1 element.", 1, artifactMap.size() ); - - Artifact artifact = (Artifact) artifactMap.get( key ); - - assertNotNull( "dependency artifact not found in map.", artifact ); - assertEquals( "dependency artifact has wrong scope.", Artifact.SCOPE_COMPILE, artifact.getScope() ); - - //check for back-propagation of default scope. - assertEquals( "default scope NOT back-propagated to dependency.", Artifact.SCOPE_COMPILE, dep.getScope() ); - } - - public void testShouldUseInjectedTestScopeFromDependencyManagement() - throws Exception - { - String groupId = "org.apache.maven"; - String artifactId = "maven-model"; - - Dependency dep = new Dependency(); - - dep.setGroupId( groupId ); - dep.setArtifactId( artifactId ); - dep.setVersion( "2.0-alpha-3" ); - - Model model = new Model(); - - model.addDependency( dep ); - - Dependency mgd = new Dependency(); - mgd.setGroupId( groupId ); - mgd.setArtifactId( artifactId ); - mgd.setScope( Artifact.SCOPE_TEST ); - - DependencyManagement depMgmt = new DependencyManagement(); - - depMgmt.addDependency( mgd ); - - model.setDependencyManagement( depMgmt ); - - MavenProject project = new MavenProject( model, repositorySystem ); - - TestModelDefaultsInjector injector = new TestModelDefaultsInjector(); - - injector.injectDefaults( model ); - - project.setArtifacts( project.createArtifacts( null ) ); - - String key = ArtifactUtils.versionlessKey( groupId, artifactId ); - - Map artifactMap = project.getArtifactMap(); - - assertNotNull( "artifact-map should not be null.", artifactMap ); - assertEquals( "artifact-map should contain 1 element.", 1, artifactMap.size() ); - - Artifact artifact = (Artifact) artifactMap.get( key ); - - assertNotNull( "dependency artifact not found in map.", artifact ); - assertEquals( "dependency artifact has wrong scope.", Artifact.SCOPE_TEST, artifact.getScope() ); - - //check for back-propagation of default scope. - assertEquals( "default scope NOT back-propagated to dependency.", Artifact.SCOPE_TEST, dep.getScope() ); - } - */ - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/canonical/CanonicalProjectBuilderTest.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/canonical/CanonicalProjectBuilderTest.java deleted file mode 100644 index 8b6454da..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/canonical/CanonicalProjectBuilderTest.java +++ /dev/null @@ -1,101 +0,0 @@ -package org.apache.maven.project.canonical; - -/* - * 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.io.File; -import java.util.List; - -import org.apache.maven.model.Plugin; -import org.apache.maven.model.PluginExecution; -import org.apache.maven.project.AbstractMavenProjectTestCase; -import org.apache.maven.project.MavenProject; -import org.codehaus.plexus.util.xml.Xpp3Dom; - -/** - * @author Jason van Zyl - */ -public class CanonicalProjectBuilderTest - extends AbstractMavenProjectTestCase -{ - public void testProjectBuilder() - throws Exception - { - File f = getFileForClasspathResource( "canonical-pom.xml" ); - - MavenProject project = getProject( f ); - - // ---------------------------------------------------------------------- - // Top-level elements - // ---------------------------------------------------------------------- - - assertEquals( "4.0.0", project.getModelVersion() ); - - // ---------------------------------------------------------------------- - // Plugins - // ---------------------------------------------------------------------- - - List<Plugin> plugins = project.getBuildPlugins(); - - // Plugin0 [plexus] - - String key = "org.apache.maven.plugins:maven-plexus-plugin"; - - Plugin plugin = null; - for ( Plugin check : plugins ) - { - if ( key.equals( check.getKey() ) ) - { - plugin = check; - break; - } - } - - assertNotNull( plugin ); - - assertEquals( "1.0", plugin.getVersion() ); - - Xpp3Dom configuration = (Xpp3Dom) plugin.getConfiguration(); - - assertEquals( "src/conf/plexus.conf", configuration.getChild( "plexusConfiguration" ).getValue() ); - - assertEquals( "src/conf/plexus.properties", - configuration.getChild( "plexusConfigurationPropertiesFile" ).getValue() ); - - assertEquals( "Continuum", configuration.getChild( "plexusApplicationName" ).getValue() ); - - // ---------------------------------------------------------------------- - // Goal specific configuration - // ---------------------------------------------------------------------- - - List<PluginExecution> executions = plugin.getExecutions(); - - PluginExecution execution = executions.get( 0 ); - - String g0 = execution.getGoals().get( 0 ); - - assertEquals( "plexus:runtime", g0 ); - - configuration = (Xpp3Dom) execution.getConfiguration(); - - assertEquals( "ContinuumPro", configuration.getChild( "plexusApplicationName" ).getValue() ); - - // Plugin1 [antlr] - } -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/harness/PomTestWrapper.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/harness/PomTestWrapper.java deleted file mode 100644 index c204140a..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/harness/PomTestWrapper.java +++ /dev/null @@ -1,121 +0,0 @@ -package org.apache.maven.project.harness; - -/* - * 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.io.File; -import java.util.Iterator; - -import org.apache.commons.jxpath.JXPathContext; -import org.apache.commons.jxpath.JXPathNotFoundException; -import org.apache.commons.jxpath.ri.JXPathContextReferenceImpl; -import org.apache.maven.project.MavenProject; - -public class PomTestWrapper -{ - - private File pomFile; - - private JXPathContext context; - - private MavenProject mavenProject; - - static - { - JXPathContextReferenceImpl.addNodePointerFactory( new Xpp3DomPointerFactory() ); - } - - public PomTestWrapper( File pomFile, MavenProject mavenProject ) - { - if ( mavenProject == null ) - { - throw new IllegalArgumentException( "mavenProject: null" ); - } - this.mavenProject = mavenProject; - this.pomFile = pomFile; - context = JXPathContext.newContext( mavenProject.getModel() ); - } - - public PomTestWrapper( MavenProject mavenProject ) - { - if ( mavenProject == null ) - { - throw new IllegalArgumentException( "mavenProject: null" ); - } - this.mavenProject = mavenProject; - context = JXPathContext.newContext( mavenProject.getModel() ); - } - - public MavenProject getMavenProject() - { - return mavenProject; - } - - public File getBasedir() - { - return ( pomFile != null ) ? pomFile.getParentFile() : null; - } - - public void setValueOnModel( String expression, Object value ) - { - context.setValue( expression, value ); - } - - /* - public int containerCountForUri( String uri ) - throws IOException - { - if ( uri == null || uri.trim().equals( "" ) ) - { - throw new IllegalArgumentException( "uri: null or empty" ); - } - ModelDataSource source = new DefaultModelDataSource(); - source.init( domainModel.getModelProperties(), null ); - return source.queryFor( uri ).size(); - } - */ - - public Iterator<?> getIteratorForXPathExpression( String expression ) - { - return context.iterate( expression ); - } - - public boolean containsXPathExpression( String expression ) - { - return context.getValue( expression ) != null; - } - - public Object getValue( String expression ) - { - try - { - return context.getValue( expression ); - } - catch ( JXPathNotFoundException e ) - { - return null; - } - } - - public boolean xPathExpressionEqualsValue( String expression, String value ) - { - return context.getValue( expression ) != null && context.getValue( expression ).equals( value ); - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/harness/Xpp3DomAttributeIterator.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/harness/Xpp3DomAttributeIterator.java deleted file mode 100644 index 2811a848..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/harness/Xpp3DomAttributeIterator.java +++ /dev/null @@ -1,89 +0,0 @@ -package org.apache.maven.project.harness; - -/* - * 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.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -import org.apache.commons.jxpath.ri.QName; -import org.apache.commons.jxpath.ri.model.NodeIterator; -import org.apache.commons.jxpath.ri.model.NodePointer; -import org.codehaus.plexus.util.xml.Xpp3Dom; - -/** - * An attribute iterator for JXPath to support <code>Xpp3Dom</code>. - * - * @author Benjamin Bentmann - */ -class Xpp3DomAttributeIterator - implements NodeIterator -{ - - private NodePointer parent; - - private Xpp3Dom node; - - private List<Map.Entry<String, String>> attributes; - - private Map.Entry<String, String> attribute; - - private int position; - - public Xpp3DomAttributeIterator( NodePointer parent, QName qname ) - { - this.parent = parent; - this.node = (Xpp3Dom) parent.getNode(); - - Map<String, String> map = new LinkedHashMap<String, String>(); - for ( String name : this.node.getAttributeNames() ) - { - if ( name.equals( qname.getName() ) || "*".equals( qname.getName() ) ) - { - String value = this.node.getAttribute( name ); - map.put( name, value ); - } - } - this.attributes = new ArrayList<Map.Entry<String, String>>( map.entrySet() ); - } - - public NodePointer getNodePointer() - { - if ( position == 0 ) - { - setPosition( 1 ); - } - return ( attribute == null ) ? null : new Xpp3DomAttributePointer( parent, attribute ); - } - - public int getPosition() - { - return position; - } - - public boolean setPosition( int position ) - { - this.position = position; - attribute = ( position > 0 && position <= attributes.size() ) ? attributes.get( position - 1 ) : null; - return attribute != null; - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/harness/Xpp3DomAttributePointer.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/harness/Xpp3DomAttributePointer.java deleted file mode 100644 index 04514b18..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/harness/Xpp3DomAttributePointer.java +++ /dev/null @@ -1,105 +0,0 @@ -package org.apache.maven.project.harness; - -/* - * 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.Map; - -import org.apache.commons.jxpath.ri.QName; -import org.apache.commons.jxpath.ri.model.NodePointer; - -/** - * An attribute pointer for JXPath to support <code>Xpp3Dom</code>. - * - * @author Benjamin Bentmann - */ -class Xpp3DomAttributePointer - extends NodePointer -{ - - private Map.Entry<String, String> attrib; - - public Xpp3DomAttributePointer( NodePointer parent, Map.Entry<String, String> attrib ) - { - super( parent ); - this.attrib = attrib; - } - - @Override - public int compareChildNodePointers( NodePointer pointer1, NodePointer pointer2 ) - { - // should never happen because attributes have no children - return 0; - } - - @Override - public Object getValue() - { - return attrib.getValue(); - } - - @Override - public Object getBaseValue() - { - return attrib; - } - - @Override - public Object getImmediateNode() - { - return attrib; - } - - @Override - public int getLength() - { - return 1; - } - - @Override - public QName getName() - { - return new QName( null, attrib.getKey() ); - } - - @Override - public boolean isActual() - { - return true; - } - - @Override - public boolean isCollection() - { - return false; - } - - @Override - public boolean isLeaf() - { - return true; - } - - @Override - public void setValue( Object value ) - { - throw new UnsupportedOperationException(); - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/harness/Xpp3DomNodeIterator.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/harness/Xpp3DomNodeIterator.java deleted file mode 100644 index 796a5ca0..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/harness/Xpp3DomNodeIterator.java +++ /dev/null @@ -1,161 +0,0 @@ -package org.apache.maven.project.harness; - -/* - * 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.ArrayList; -import java.util.List; - -import org.apache.commons.jxpath.ri.Compiler; -import org.apache.commons.jxpath.ri.compiler.NodeNameTest; -import org.apache.commons.jxpath.ri.compiler.NodeTest; -import org.apache.commons.jxpath.ri.compiler.NodeTypeTest; -import org.apache.commons.jxpath.ri.model.NodeIterator; -import org.apache.commons.jxpath.ri.model.NodePointer; -import org.codehaus.plexus.util.StringUtils; -import org.codehaus.plexus.util.xml.Xpp3Dom; - -/** - * A node iterator for JXPath to support <code>Xpp3Dom</code>. - * - * @author Benjamin Bentmann - */ -class Xpp3DomNodeIterator - implements NodeIterator -{ - - private NodePointer parent; - - private NodeTest test; - - private Xpp3Dom node; - - private Xpp3Dom[] children; - - private List<Xpp3Dom> filteredChildren = new ArrayList<Xpp3Dom>(); - - private int filteredIndex; - - private Xpp3Dom child; - - private int position; - - public Xpp3DomNodeIterator( NodePointer parent, NodeTest test, boolean reverse, NodePointer startWith ) - { - this.parent = parent; - this.node = (Xpp3Dom) parent.getNode(); - this.children = this.node.getChildren(); - if ( startWith != null ) - { - Xpp3Dom startWithNode = (Xpp3Dom) startWith.getNode(); - for ( ; filteredIndex < children.length; filteredIndex++ ) - { - if ( startWithNode.equals( children[filteredIndex] ) ) - { - filteredIndex++; - break; - } - } - } - this.test = test; - if ( reverse ) - { - throw new UnsupportedOperationException(); - } - } - - public NodePointer getNodePointer() - { - if ( position == 0 ) - { - setPosition( 1 ); - } - return ( child == null ) ? null : new Xpp3DomNodePointer( parent, child ); - } - - public int getPosition() - { - return position; - } - - public boolean setPosition( int position ) - { - this.position = position; - filterChildren( position ); - child = ( position > 0 && position <= filteredChildren.size() ) ? filteredChildren.get( position - 1 ) : null; - return child != null; - } - - private void filterChildren( int position ) - { - for ( ; position > filteredChildren.size() && filteredIndex < children.length; filteredIndex++ ) - { - Xpp3Dom child = children[filteredIndex]; - if ( testNode( child ) ) - { - filteredChildren.add( child ); - } - } - } - - private boolean testNode( Xpp3Dom node ) - { - if ( test == null ) - { - return true; - } - if ( test instanceof NodeNameTest ) - { - String nodeName = node.getName(); - if ( StringUtils.isEmpty( nodeName ) ) - { - return false; - } - - NodeNameTest nodeNameTest = (NodeNameTest) test; - String namespaceURI = nodeNameTest.getNamespaceURI(); - boolean wildcard = nodeNameTest.isWildcard(); - String testName = nodeNameTest.getNodeName().getName(); - String testPrefix = nodeNameTest.getNodeName().getPrefix(); - if ( wildcard && testPrefix == null ) - { - return true; - } - if ( wildcard || testName.equals( nodeName ) ) - { - return StringUtils.isEmpty( namespaceURI ) || StringUtils.isEmpty( testPrefix ); - } - return false; - } - if ( test instanceof NodeTypeTest ) - { - switch ( ( (NodeTypeTest) test ).getNodeType() ) - { - case Compiler.NODE_TYPE_NODE: - return true; - case Compiler.NODE_TYPE_TEXT: - return node.getValue() != null; - default: - return false; - } - } - return false; - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/harness/Xpp3DomNodePointer.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/harness/Xpp3DomNodePointer.java deleted file mode 100644 index f93bd892..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/harness/Xpp3DomNodePointer.java +++ /dev/null @@ -1,155 +0,0 @@ -package org.apache.maven.project.harness; - -/* - * 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.ArrayList; -import java.util.List; - -import org.apache.commons.jxpath.ri.QName; -import org.apache.commons.jxpath.ri.compiler.NodeTest; -import org.apache.commons.jxpath.ri.model.NodeIterator; -import org.apache.commons.jxpath.ri.model.NodePointer; -import org.codehaus.plexus.util.xml.Xpp3Dom; - -/** - * A node pointer for JXPath to support <code>Xpp3Dom</code>. - * - * @author Benjamin Bentmann - */ -class Xpp3DomNodePointer - extends NodePointer -{ - - private Xpp3Dom node; - - public Xpp3DomNodePointer( Xpp3Dom node ) - { - super( null ); - this.node = node; - } - - public Xpp3DomNodePointer( NodePointer parent, Xpp3Dom node ) - { - super( parent ); - this.node = node; - } - - @Override - public int compareChildNodePointers( NodePointer pointer1, NodePointer pointer2 ) - { - Xpp3Dom node1 = (Xpp3Dom) pointer1.getBaseValue(); - Xpp3Dom node2 = (Xpp3Dom) pointer2.getBaseValue(); - if ( node1 == node2 ) - { - return 0; - } - for ( int i = 0; i < node.getChildCount(); i++ ) - { - Xpp3Dom child = node.getChild( i ); - if ( child == node1 ) - { - return -1; - } - if ( child == node2 ) - { - return 1; - } - } - return 0; - } - - @Override - public Object getValue() - { - return getValue( node ); - } - - private static Object getValue( Xpp3Dom node ) - { - if ( node.getValue() != null ) - { - return node.getValue(); - } - else - { - List<Object> children = new ArrayList<Object>(); - for ( int i = 0; i < node.getChildCount(); i++ ) - { - children.add( getValue( node.getChild( i ) ) ); - } - return children; - } - } - - @Override - public Object getBaseValue() - { - return node; - } - - @Override - public Object getImmediateNode() - { - return node; - } - - @Override - public int getLength() - { - return 1; - } - - @Override - public QName getName() - { - return new QName( null, node.getName() ); - } - - @Override - public boolean isCollection() - { - return false; - } - - @Override - public boolean isLeaf() - { - return node.getChildCount() <= 0; - } - - @Override - public void setValue( Object value ) - { - throw new UnsupportedOperationException(); - } - - @Override - public NodeIterator childIterator( NodeTest test, boolean reverse, NodePointer startWith ) - { - return new Xpp3DomNodeIterator( this, test, reverse, startWith ); - } - - @Override - public NodeIterator attributeIterator( QName qname ) - { - return new Xpp3DomAttributeIterator( this, qname ); - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/harness/Xpp3DomPointerFactory.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/harness/Xpp3DomPointerFactory.java deleted file mode 100644 index 28c0f8ff..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/project/harness/Xpp3DomPointerFactory.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.apache.maven.project.harness; - -/* - * 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.Locale; - -import org.apache.commons.jxpath.ri.QName; -import org.apache.commons.jxpath.ri.model.NodePointer; -import org.apache.commons.jxpath.ri.model.NodePointerFactory; -import org.codehaus.plexus.util.xml.Xpp3Dom; - -/** - * A node pointer factory for JXPath to support <code>Xpp3Dom</code>. - * - * @author Benjamin Bentmann - */ -public class Xpp3DomPointerFactory - implements NodePointerFactory -{ - - public int getOrder() - { - return 200; - } - - public NodePointer createNodePointer( QName name, Object object, Locale locale ) - { - if ( object instanceof Xpp3Dom ) - { - return new Xpp3DomNodePointer( (Xpp3Dom) object ); - } - return null; - } - - public NodePointer createNodePointer( NodePointer parent, QName name, Object object ) - { - if ( object instanceof Xpp3Dom ) - { - return new Xpp3DomNodePointer( parent, (Xpp3Dom) object ); - } - return null; - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/repository/LegacyRepositoryLayout.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/repository/LegacyRepositoryLayout.java deleted file mode 100644 index 77a6baef..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/repository/LegacyRepositoryLayout.java +++ /dev/null @@ -1,89 +0,0 @@ -package org.apache.maven.repository; - -/* - * 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 org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.handler.ArtifactHandler; -import org.apache.maven.artifact.metadata.ArtifactMetadata; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; -import org.codehaus.plexus.component.annotations.Component; - -/** - * @author jdcasey - */ -@Component(role=ArtifactRepositoryLayout.class, hint="legacy") -public class LegacyRepositoryLayout - implements ArtifactRepositoryLayout -{ - private static final String PATH_SEPARATOR = "/"; - - public String getId() - { - return "legacy"; - } - - public String pathOf( Artifact artifact ) - { - ArtifactHandler artifactHandler = artifact.getArtifactHandler(); - - StringBuilder path = new StringBuilder( 128 ); - - path.append( artifact.getGroupId() ).append( '/' ); - path.append( artifactHandler.getDirectory() ).append( '/' ); - path.append( artifact.getArtifactId() ).append( '-' ).append( artifact.getVersion() ); - - if ( artifact.hasClassifier() ) - { - path.append( '-' ).append( artifact.getClassifier() ); - } - - if ( artifactHandler.getExtension() != null && artifactHandler.getExtension().length() > 0 ) - { - path.append( '.' ).append( artifactHandler.getExtension() ); - } - - return path.toString(); - } - - public String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, - ArtifactRepository repository ) - { - return pathOfRepositoryMetadata( metadata, metadata.getLocalFilename( repository ) ); - } - - private String pathOfRepositoryMetadata( ArtifactMetadata metadata, - String filename ) - { - StringBuilder path = new StringBuilder( 128 ); - - path.append( metadata.getGroupId() ).append( PATH_SEPARATOR ).append( "poms" ).append( PATH_SEPARATOR ); - - path.append( filename ); - - return path.toString(); - } - - public String pathOfRemoteRepositoryMetadata( ArtifactMetadata metadata ) - { - return pathOfRepositoryMetadata( metadata, metadata.getRemoteFilename() ); - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/repository/TestArtifactHandler.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/repository/TestArtifactHandler.java deleted file mode 100644 index db1fecb5..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/repository/TestArtifactHandler.java +++ /dev/null @@ -1,83 +0,0 @@ -package org.apache.maven.repository; - -/* - * 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 org.apache.maven.artifact.handler.ArtifactHandler; - -/** - * Assists unit testing. - * - * @author Benjamin Bentmann - */ -class TestArtifactHandler - implements ArtifactHandler -{ - - private String type; - - private String extension; - - public TestArtifactHandler( String type ) - { - this( type, type ); - } - - public TestArtifactHandler( String type, String extension ) - { - this.type = type; - this.extension = extension; - } - - public String getClassifier() - { - return null; - } - - public String getDirectory() - { - return getPackaging() + "s"; - } - - public String getExtension() - { - return extension; - } - - public String getLanguage() - { - return "java"; - } - - public String getPackaging() - { - return type; - } - - public boolean isAddedToClasspath() - { - return true; - } - - public boolean isIncludesDependencies() - { - return false; - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/repository/TestRepositoryConnector.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/repository/TestRepositoryConnector.java deleted file mode 100644 index 91ace4f1..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/repository/TestRepositoryConnector.java +++ /dev/null @@ -1,123 +0,0 @@ -package org.apache.maven.repository; - -/* - * 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.io.File; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.Collection; - -import org.codehaus.plexus.util.FileUtils; -import org.eclipse.aether.artifact.Artifact; -import org.eclipse.aether.repository.RemoteRepository; -import org.eclipse.aether.spi.connector.ArtifactDownload; -import org.eclipse.aether.spi.connector.ArtifactUpload; -import org.eclipse.aether.spi.connector.MetadataDownload; -import org.eclipse.aether.spi.connector.MetadataUpload; -import org.eclipse.aether.spi.connector.RepositoryConnector; -import org.eclipse.aether.transfer.ArtifactNotFoundException; -import org.eclipse.aether.transfer.ArtifactTransferException; - -/** - * @author Benjamin Bentmann - */ -public class TestRepositoryConnector - implements RepositoryConnector -{ - - private RemoteRepository repository; - - private File basedir; - - public TestRepositoryConnector( RemoteRepository repository ) - { - this.repository = repository; - try - { - basedir = FileUtils.toFile( new URL( repository.getUrl() ) ); - } - catch ( MalformedURLException e ) - { - throw new IllegalStateException( e ); - } - } - - public void close() - { - } - - public void get( Collection<? extends ArtifactDownload> artifactDownloads, - Collection<? extends MetadataDownload> metadataDownloads ) - { - if ( artifactDownloads != null ) - { - for ( ArtifactDownload download : artifactDownloads ) - { - File remoteFile = new File( basedir, path( download.getArtifact() ) ); - try - { - FileUtils.copyFile( remoteFile, download.getFile() ); - } - catch ( IOException e ) - { - if ( !remoteFile.exists() ) - { - download.setException( new ArtifactNotFoundException( download.getArtifact(), repository ) ); - } - else - { - download.setException( new ArtifactTransferException( download.getArtifact(), repository, e ) ); - } - } - } - } - } - - private String path( Artifact artifact ) - { - StringBuilder path = new StringBuilder( 128 ); - - path.append( artifact.getGroupId().replace( '.', '/' ) ).append( '/' ); - - path.append( artifact.getArtifactId() ).append( '/' ); - - path.append( artifact.getBaseVersion() ).append( '/' ); - - path.append( artifact.getArtifactId() ).append( '-' ).append( artifact.getVersion() ); - - if ( artifact.getClassifier().length() > 0 ) - { - path.append( '-' ).append( artifact.getClassifier() ); - } - - path.append( '.' ).append( artifact.getExtension() ); - - return path.toString(); - } - - public void put( Collection<? extends ArtifactUpload> artifactUploads, - Collection<? extends MetadataUpload> metadataUploads ) - { - // TODO Auto-generated method stub - - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/repository/TestRepositoryConnectorFactory.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/repository/TestRepositoryConnectorFactory.java deleted file mode 100644 index 17fd43f9..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/repository/TestRepositoryConnectorFactory.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.apache.maven.repository; - -/* - * 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 org.codehaus.plexus.component.annotations.Component; -import org.eclipse.aether.RepositorySystemSession; -import org.eclipse.aether.repository.RemoteRepository; -import org.eclipse.aether.spi.connector.RepositoryConnector; -import org.eclipse.aether.spi.connector.RepositoryConnectorFactory; -import org.eclipse.aether.transfer.NoRepositoryConnectorException; - -/** - * @author Benjamin Bentmann - */ -@Component( role = RepositoryConnectorFactory.class, hint = "test" ) -public class TestRepositoryConnectorFactory - implements RepositoryConnectorFactory -{ - - public RepositoryConnector newInstance( RepositorySystemSession session, RemoteRepository repository ) - throws NoRepositoryConnectorException - { - return new TestRepositoryConnector( repository ); - } - - public float getPriority() - { - return 0; - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/repository/TestRepositorySystem.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/repository/TestRepositorySystem.java deleted file mode 100644 index c4afc7a9..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/repository/TestRepositorySystem.java +++ /dev/null @@ -1,329 +0,0 @@ -package org.apache.maven.repository; - -/* - * 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.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.DefaultArtifact; -import org.apache.maven.artifact.InvalidRepositoryException; -import org.apache.maven.artifact.factory.ArtifactFactory; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; -import org.apache.maven.artifact.repository.MavenArtifactRepository; -import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; -import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; -import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; -import org.apache.maven.artifact.resolver.ArtifactResolutionResult; -import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; -import org.apache.maven.artifact.versioning.VersionRange; -import org.apache.maven.model.Dependency; -import org.apache.maven.model.Model; -import org.apache.maven.model.Plugin; -import org.apache.maven.model.Repository; -import org.apache.maven.model.io.ModelReader; -import org.apache.maven.project.artifact.ArtifactWithDependencies; -import org.apache.maven.settings.Mirror; -import org.apache.maven.settings.Proxy; -import org.apache.maven.settings.Server; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.annotations.Requirement; -import org.codehaus.plexus.util.FileUtils; -import org.codehaus.plexus.util.StringUtils; -import org.eclipse.aether.RepositorySystemSession; - -/** - * @author Benjamin Bentmann - */ -@Component( role = RepositorySystem.class ) -public class TestRepositorySystem - implements RepositorySystem -{ - - @Requirement - private ModelReader modelReader; - - @Requirement - private ArtifactFactory artifactFactory; - - public ArtifactRepository buildArtifactRepository( Repository repository ) - throws InvalidRepositoryException - { - return new MavenArtifactRepository( repository.getId(), repository.getUrl(), new DefaultRepositoryLayout(), - new ArtifactRepositoryPolicy(), new ArtifactRepositoryPolicy() ); - } - - public Artifact createArtifact( String groupId, String artifactId, String version, String packaging ) - { - return createArtifact( groupId, artifactId, version, null, packaging ); - } - - public Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type ) - { - return new DefaultArtifact( groupId, artifactId, version, scope, type, null, new TestArtifactHandler( type ) ); - } - - public ArtifactRepository createArtifactRepository( String id, String url, - ArtifactRepositoryLayout repositoryLayout, - ArtifactRepositoryPolicy snapshots, - ArtifactRepositoryPolicy releases ) - { - return new MavenArtifactRepository( id, url, repositoryLayout, snapshots, releases ); - } - - public Artifact createArtifactWithClassifier( String groupId, String artifactId, String version, String type, - String classifier ) - { - return new DefaultArtifact( groupId, artifactId, version, null, type, classifier, - new TestArtifactHandler( type ) ); - } - - public ArtifactRepository createDefaultLocalRepository() - throws InvalidRepositoryException - { - return createLocalRepository( new File( System.getProperty( "basedir", "" ), "target/local-repo" ).getAbsoluteFile() ); - } - - public ArtifactRepository createDefaultRemoteRepository() - throws InvalidRepositoryException - { - return new MavenArtifactRepository( DEFAULT_REMOTE_REPO_ID, "file://" - + new File( System.getProperty( "basedir", "" ), "src/test/remote-repo" ).toURI().getPath(), - new DefaultRepositoryLayout(), new ArtifactRepositoryPolicy(), - new ArtifactRepositoryPolicy() ); - } - - public Artifact createDependencyArtifact( Dependency dependency ) - { - Artifact artifact = - new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion(), - dependency.getScope(), dependency.getType(), dependency.getClassifier(), - new TestArtifactHandler( dependency.getType() ) ); - - if ( Artifact.SCOPE_SYSTEM.equals( dependency.getScope() ) ) - { - artifact.setFile( new File( dependency.getSystemPath() ) ); - artifact.setResolved( true ); - } - - return artifact; - } - - public ArtifactRepository createLocalRepository( File localRepository ) - throws InvalidRepositoryException - { - return new MavenArtifactRepository( DEFAULT_LOCAL_REPO_ID, "file://" + localRepository.toURI().getPath(), - new DefaultRepositoryLayout(), new ArtifactRepositoryPolicy(), - new ArtifactRepositoryPolicy() ); - } - - public Artifact createPluginArtifact( Plugin plugin ) - { - VersionRange versionRange; - try - { - String version = plugin.getVersion(); - if ( StringUtils.isEmpty( version ) ) - { - version = "RELEASE"; - } - versionRange = VersionRange.createFromVersionSpec( version ); - } - catch ( InvalidVersionSpecificationException e ) - { - return null; - } - - return artifactFactory.createPluginArtifact( plugin.getGroupId(), plugin.getArtifactId(), versionRange ); - } - - public Artifact createProjectArtifact( String groupId, String artifactId, String version ) - { - return createArtifact( groupId, artifactId, version, "pom" ); - } - - public List<ArtifactRepository> getEffectiveRepositories( List<ArtifactRepository> repositories ) - { - return repositories; - } - - public Mirror getMirror( ArtifactRepository repository, List<Mirror> mirrors ) - { - return null; - } - - public void injectAuthentication( List<ArtifactRepository> repositories, List<Server> servers ) - { - } - - public void injectMirror( List<ArtifactRepository> repositories, List<Mirror> mirrors ) - { - } - - public void injectProxy( List<ArtifactRepository> repositories, List<Proxy> proxies ) - { - } - - public void publish( ArtifactRepository repository, File source, String remotePath, - ArtifactTransferListener transferListener ) - throws ArtifactTransferFailedException - { - // TODO Auto-generated method stub - - } - - public ArtifactResolutionResult resolve( ArtifactResolutionRequest request ) - { - ArtifactResolutionResult result = new ArtifactResolutionResult(); - - if ( request.isResolveRoot() ) - { - try - { - resolve( request.getArtifact(), request ); - result.addArtifact( request.getArtifact() ); - } - catch ( IOException e ) - { - result.addMissingArtifact( request.getArtifact() ); - } - } - - if ( request.isResolveTransitively() ) - { - Map<String, Artifact> artifacts = new LinkedHashMap<String, Artifact>(); - - if ( request.getArtifactDependencies() != null ) - { - for ( Artifact artifact : request.getArtifactDependencies() ) - { - artifacts.put( artifact.getDependencyConflictId(), artifact ); - } - } - - List<Dependency> dependencies = new ArrayList<Dependency>(); - if ( request.getArtifact() instanceof ArtifactWithDependencies ) - { - dependencies = ( (ArtifactWithDependencies) request.getArtifact() ).getDependencies(); - } - else - { - Artifact pomArtifact = - createProjectArtifact( request.getArtifact().getGroupId(), request.getArtifact().getArtifactId(), - request.getArtifact().getVersion() ); - File pomFile = - new File( request.getLocalRepository().getBasedir(), - request.getLocalRepository().pathOf( pomArtifact ) ); - - try - { - Model model = modelReader.read( pomFile, null ); - - dependencies = model.getDependencies(); - } - catch ( IOException e ) - { - e.printStackTrace(); - } - } - - for ( Dependency dependency : dependencies ) - { - Artifact artifact = createDependencyArtifact( dependency ); - if ( !artifacts.containsKey( artifact.getDependencyConflictId() ) ) - { - artifacts.put( artifact.getDependencyConflictId(), artifact ); - } - } - - for ( Artifact artifact : artifacts.values() ) - { - try - { - resolve( artifact, request ); - result.addArtifact( artifact ); - } - catch ( IOException e ) - { - result.addMissingArtifact( artifact ); - } - } - } - - return result; - } - - private void resolve( Artifact artifact, ArtifactResolutionRequest request ) - throws IOException - { - if ( Artifact.SCOPE_SYSTEM.equals( artifact.getScope() ) ) - { - return; - } - - ArtifactRepository localRepo = request.getLocalRepository(); - - File localFile = new File( localRepo.getBasedir(), localRepo.pathOf( artifact ) ); - - artifact.setFile( localFile ); - - if ( !localFile.exists() ) - { - if ( request.getRemoteRepositories().isEmpty() ) - { - throw new IOException( localFile + " does not exist and no remote repositories are configured" ); - } - - ArtifactRepository remoteRepo = request.getRemoteRepositories().get( 0 ); - - File remoteFile = new File( remoteRepo.getBasedir(), remoteRepo.pathOf( artifact ) ); - - FileUtils.copyFile( remoteFile, localFile ); - } - - artifact.setResolved( true ); - } - - public void retrieve( ArtifactRepository repository, File destination, String remotePath, - ArtifactTransferListener transferListener ) - throws ArtifactTransferFailedException, ArtifactDoesNotExistException - { - // TODO Auto-generated method stub - - } - - public void injectMirror( RepositorySystemSession session, List<ArtifactRepository> repositories ) - { - } - - public void injectProxy( RepositorySystemSession session, List<ArtifactRepository> repositories ) - { - } - - public void injectAuthentication( RepositorySystemSession session, List<ArtifactRepository> repositories ) - { - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/rtinfo/internal/DefaultRuntimeInformationTest.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/rtinfo/internal/DefaultRuntimeInformationTest.java deleted file mode 100644 index 71be9284..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/rtinfo/internal/DefaultRuntimeInformationTest.java +++ /dev/null @@ -1,81 +0,0 @@ -package org.apache.maven.rtinfo.internal; - -/* - * 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 org.apache.maven.rtinfo.RuntimeInformation; -import org.codehaus.plexus.PlexusTestCase; - -public class DefaultRuntimeInformationTest - extends PlexusTestCase -{ - - public void testGetMavenVersion() - throws Exception - { - RuntimeInformation rtInfo = lookup( RuntimeInformation.class ); - - String mavenVersion = rtInfo.getMavenVersion(); - assertNotNull( mavenVersion ); - assertTrue( mavenVersion.length() > 0 ); - } - - public void testIsMavenVersion() - throws Exception - { - RuntimeInformation rtInfo = lookup( RuntimeInformation.class ); - - assertTrue( rtInfo.isMavenVersion( "2.0" ) ); - assertFalse( rtInfo.isMavenVersion( "9.9" ) ); - - assertTrue( rtInfo.isMavenVersion( "[2.0.11,2.1.0),[3.0,)" ) ); - assertFalse( rtInfo.isMavenVersion( "[9.0,)" ) ); - - try - { - rtInfo.isMavenVersion( "[3.0," ); - fail( "Bad version range wasn't rejected" ); - } - catch ( IllegalArgumentException e ) - { - assertTrue( true ); - } - - try - { - rtInfo.isMavenVersion( "" ); - fail( "Bad version range wasn't rejected" ); - } - catch ( IllegalArgumentException e ) - { - assertTrue( true ); - } - - try - { - rtInfo.isMavenVersion( null ); - fail( "Bad version range wasn't rejected" ); - } - catch ( IllegalArgumentException e ) - { - assertTrue( true ); - } - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/settings/PomConstructionWithSettingsTest.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/settings/PomConstructionWithSettingsTest.java deleted file mode 100644 index 5c166868..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/settings/PomConstructionWithSettingsTest.java +++ /dev/null @@ -1,159 +0,0 @@ -package org.apache.maven.settings; - -/* - * 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.io.File; -import java.io.IOException; -import java.io.Reader; - -import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; -import org.apache.maven.model.Profile; -import org.apache.maven.project.DefaultProjectBuilder; -import org.apache.maven.project.DefaultProjectBuildingRequest; -import org.apache.maven.project.ProjectBuilder; -import org.apache.maven.project.ProjectBuildingRequest; -import org.apache.maven.project.harness.PomTestWrapper; -import org.apache.maven.repository.RepositorySystem; -import org.apache.maven.repository.internal.MavenRepositorySystemUtils; -import org.apache.maven.settings.io.xpp3.SettingsXpp3Reader; -import org.codehaus.plexus.ContainerConfiguration; -import org.codehaus.plexus.PlexusConstants; -import org.codehaus.plexus.PlexusTestCase; -import org.codehaus.plexus.util.IOUtil; -import org.codehaus.plexus.util.ReaderFactory; -import org.codehaus.plexus.util.xml.pull.XmlPullParserException; -import org.eclipse.aether.DefaultRepositorySystemSession; -import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory; -import org.eclipse.aether.repository.LocalRepository; - -public class PomConstructionWithSettingsTest - extends PlexusTestCase -{ - private static final String BASE_DIR = "src/test"; - - private static final String BASE_POM_DIR = BASE_DIR + "/resources-settings"; - - private DefaultProjectBuilder projectBuilder; - - private RepositorySystem repositorySystem; - - private File testDirectory; - - @Override - protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration ) - { - super.customizeContainerConfiguration( containerConfiguration ); - containerConfiguration.setAutoWiring( true ); - containerConfiguration.setClassPathScanning( PlexusConstants.SCANNING_INDEX ); - } - - protected void setUp() - throws Exception - { - testDirectory = new File( getBasedir(), BASE_POM_DIR ); - projectBuilder = (DefaultProjectBuilder) lookup( ProjectBuilder.class ); - repositorySystem = lookup( RepositorySystem.class ); - } - - @Override - protected void tearDown() - throws Exception - { - projectBuilder = null; - - super.tearDown(); - } - - public void testSettingsNoPom() throws Exception - { - PomTestWrapper pom = buildPom( "settings-no-pom" ); - assertEquals( "local-profile-prop-value", pom.getValue( "properties/local-profile-prop" ) ); - } - - /**MNG-4107 */ - public void testPomAndSettingsInterpolation() throws Exception - { - PomTestWrapper pom = buildPom( "test-pom-and-settings-interpolation" ); - assertEquals( "applied", pom.getValue( "properties/settingsProfile" ) ); - assertEquals( "applied", pom.getValue( "properties/pomProfile" ) ); - assertEquals( "settings", pom.getValue( "properties/pomVsSettings" ) ); - assertEquals( "settings", pom.getValue( "properties/pomVsSettingsInterpolated" ) ); - } - - /**MNG-4107 */ - public void testRepositories() throws Exception - { - PomTestWrapper pom = buildPom( "repositories" ); - assertEquals( "maven-core-it-0", pom.getValue( "repositories[1]/id" ) ); - } - - private PomTestWrapper buildPom( String pomPath ) - throws Exception - { - File pomFile = new File( testDirectory + File.separator + pomPath, "pom.xml" ); - File settingsFile = new File( testDirectory + File.separator + pomPath, "settings.xml" ); - Settings settings = readSettingsFile( settingsFile ); - - ProjectBuildingRequest config = new DefaultProjectBuildingRequest(); - - for ( org.apache.maven.settings.Profile rawProfile : settings.getProfiles() ) - { - Profile profile = SettingsUtils.convertFromSettingsProfile( rawProfile ); - config.addProfile( profile ); - } - - String localRepoUrl = - System.getProperty( "maven.repo.local", System.getProperty( "user.home" ) + "/.m2/repository" ); - localRepoUrl = "file://" + localRepoUrl; - config.setLocalRepository( repositorySystem.createArtifactRepository( "local", localRepoUrl, - new DefaultRepositoryLayout(), null, null ) ); - config.setActiveProfileIds( settings.getActiveProfiles() ); - - DefaultRepositorySystemSession repoSession = MavenRepositorySystemUtils.newSession(); - LocalRepository localRepo = new LocalRepository( config.getLocalRepository().getBasedir() ); - repoSession.setLocalRepositoryManager( new SimpleLocalRepositoryManagerFactory().newInstance( repoSession, localRepo ) ); - config.setRepositorySession( repoSession ); - - return new PomTestWrapper( pomFile, projectBuilder.build( pomFile, config ).getProject() ); - } - - private static Settings readSettingsFile( File settingsFile ) - throws IOException, XmlPullParserException - { - Settings settings = null; - - Reader reader = null; - - try - { - reader = ReaderFactory.newXmlReader( settingsFile ); - - SettingsXpp3Reader modelReader = new SettingsXpp3Reader(); - - settings = modelReader.read( reader ); - } - finally - { - IOUtil.close( reader ); - } - - return settings; - } -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/settings/SettingsUtilsTest.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/settings/SettingsUtilsTest.java deleted file mode 100644 index f2231b3f..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/settings/SettingsUtilsTest.java +++ /dev/null @@ -1,126 +0,0 @@ -package org.apache.maven.settings; - -/* - * 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 junit.framework.TestCase; - -import java.util.ArrayList; -import java.util.List; -import java.util.Properties; -import java.util.Random; - -public class SettingsUtilsTest - extends TestCase -{ - - public void testShouldAppendRecessivePluginGroupIds() - { - Settings dominant = new Settings(); - dominant.addPluginGroup( "org.apache.maven.plugins" ); - dominant.addPluginGroup( "org.codehaus.modello" ); - - Settings recessive = new Settings(); - recessive.addPluginGroup( "org.codehaus.plexus" ); - - SettingsUtils.merge( dominant, recessive, Settings.GLOBAL_LEVEL ); - - List<String> pluginGroups = dominant.getPluginGroups(); - - assertNotNull( pluginGroups ); - assertEquals( 3, pluginGroups.size() ); - assertEquals( "org.apache.maven.plugins", pluginGroups.get( 0 ) ); - assertEquals( "org.codehaus.modello", pluginGroups.get( 1 ) ); - assertEquals( "org.codehaus.plexus", pluginGroups.get( 2 ) ); - } - - public void testRoundTripProfiles() - { - Random entropy = new Random(); - Profile p = new Profile(); - p.setId( "id" + Long.toHexString( entropy.nextLong() ) ); - Activation a = new Activation(); - a.setActiveByDefault( entropy.nextBoolean() ); - a.setJdk( "jdk" + Long.toHexString( entropy.nextLong() ) ); - ActivationFile af = new ActivationFile(); - af.setExists( "exists" + Long.toHexString( entropy.nextLong() ) ); - af.setMissing( "missing" + Long.toHexString( entropy.nextLong() ) ); - a.setFile( af ); - ActivationProperty ap = new ActivationProperty(); - ap.setName( "name" + Long.toHexString( entropy.nextLong() ) ); - ap.setValue( "value" + Long.toHexString( entropy.nextLong() ) ); - a.setProperty( ap ); - ActivationOS ao = new ActivationOS(); - ao.setArch( "arch" + Long.toHexString( entropy.nextLong() ) ); - ao.setFamily( "family" + Long.toHexString( entropy.nextLong() ) ); - ao.setName( "name" + Long.toHexString( entropy.nextLong() ) ); - ao.setVersion( "version" + Long.toHexString( entropy.nextLong() ) ); - a.setOs( ao ); - p.setActivation( a ); - Properties props = new Properties(); - int count = entropy.nextInt( 10 ); - for ( int i = 0; i < count; i++ ) - { - props.setProperty( "name" + Long.toHexString( entropy.nextLong() ), - "value" + Long.toHexString( entropy.nextLong() ) ); - } - p.setProperties( props ); - count = entropy.nextInt( 3 ); - List<Repository> repos = new ArrayList<Repository>(); - for ( int i = 0; i < count; i++ ) - { - Repository r = new Repository(); - r.setId( "id" + Long.toHexString( entropy.nextLong() ) ); - r.setName( "name" + Long.toHexString( entropy.nextLong() ) ); - r.setUrl( "url" + Long.toHexString( entropy.nextLong() ) ); - repos.add( r ); - } - p.setRepositories( repos ); - count = entropy.nextInt( 3 ); - repos = new ArrayList<Repository>(); - for ( int i = 0; i < count; i++ ) - { - Repository r = new Repository(); - r.setId( "id" + Long.toHexString( entropy.nextLong() ) ); - r.setName( "name" + Long.toHexString( entropy.nextLong() ) ); - r.setUrl( "url" + Long.toHexString( entropy.nextLong() ) ); - repos.add( r ); - } - p.setPluginRepositories( repos ); - - Profile clone = SettingsUtils.convertToSettingsProfile( SettingsUtils.convertFromSettingsProfile( p ) ); - - assertEquals( p.getId(), clone.getId() ); - assertEquals( p.getActivation().getJdk(), clone.getActivation().getJdk() ); - assertEquals( p.getActivation().getFile().getExists(), clone.getActivation().getFile().getExists() ); - assertEquals( p.getActivation().getFile().getMissing(), clone.getActivation().getFile().getMissing() ); - assertEquals( p.getActivation().getProperty().getName(), clone.getActivation().getProperty().getName() ); - assertEquals( p.getActivation().getProperty().getValue(), clone.getActivation().getProperty().getValue() ); - assertEquals( p.getActivation().getOs().getArch(), clone.getActivation().getOs().getArch() ); - assertEquals( p.getActivation().getOs().getFamily(), clone.getActivation().getOs().getFamily() ); - assertEquals( p.getActivation().getOs().getName(), clone.getActivation().getOs().getName() ); - assertEquals( p.getActivation().getOs().getVersion(), clone.getActivation().getOs().getVersion() ); - assertEquals( p.getProperties(), clone.getProperties() ); - assertEquals( p.getRepositories().size(), clone.getRepositories().size() ); - // TODO deep compare the lists - assertEquals( p.getPluginRepositories().size(), clone.getPluginRepositories().size() ); - // TODO deep compare the lists - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/toolchain/DefaultToolchainManagerPrivateTest.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/toolchain/DefaultToolchainManagerPrivateTest.java deleted file mode 100644 index 28a13bb2..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/toolchain/DefaultToolchainManagerPrivateTest.java +++ /dev/null @@ -1,166 +0,0 @@ -package org.apache.maven.toolchain; - -/* - * 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 static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; -import static org.mockito.Matchers.anyString; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.maven.execution.DefaultMavenExecutionRequest; -import org.apache.maven.execution.MavenExecutionRequest; -import org.apache.maven.execution.MavenSession; -import org.apache.maven.toolchain.model.ToolchainModel; -import org.codehaus.plexus.logging.Logger; -import org.junit.Before; -import org.junit.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - -public class DefaultToolchainManagerPrivateTest -{ - // Mocks to inject into toolchainManager - @Mock - private Logger logger; - - @InjectMocks - private DefaultToolchainManagerPrivate toolchainManager; - - @Mock - private ToolchainFactory toolchainFactory_basicType; - - @Mock - private ToolchainFactory toolchainFactory_rareType; - - @Before - public void setUp() - { - toolchainManager = new DefaultToolchainManagerPrivate(); - - MockitoAnnotations.initMocks( this ); - - toolchainManager.factories = new HashMap<String, ToolchainFactory>(); - toolchainManager.factories.put( "basic", toolchainFactory_basicType ); - toolchainManager.factories.put( "rare", toolchainFactory_rareType ); - } - - @Test - public void testToolchainsForAvailableType() - throws Exception - { - // prepare - MavenSession session = mock( MavenSession.class ); - MavenExecutionRequest req = new DefaultMavenExecutionRequest(); - when( session.getRequest() ).thenReturn( req ); - - ToolchainPrivate basicToolchain = mock( ToolchainPrivate.class ); - when( toolchainFactory_basicType.createDefaultToolchain() ).thenReturn( basicToolchain ); - ToolchainPrivate rareToolchain = mock( ToolchainPrivate.class ); - when( toolchainFactory_rareType.createDefaultToolchain() ).thenReturn( rareToolchain ); - - // execute - ToolchainPrivate[] toolchains = toolchainManager.getToolchainsForType( "basic", session ); - - // verify - verify( logger, never() ).error( anyString() ); - assertEquals( 1, toolchains.length ); - } - - @Test - public void testToolchainsForUnknownType() - throws Exception - { - // prepare - MavenSession session = mock( MavenSession.class ); - MavenExecutionRequest req = new DefaultMavenExecutionRequest(); - when( session.getRequest() ).thenReturn( req ); - - ToolchainPrivate basicToolchain = mock( ToolchainPrivate.class ); - when( toolchainFactory_basicType.createDefaultToolchain() ).thenReturn( basicToolchain ); - ToolchainPrivate rareToolchain = mock( ToolchainPrivate.class ); - when( toolchainFactory_rareType.createDefaultToolchain() ).thenReturn( rareToolchain ); - - // execute - ToolchainPrivate[] toolchains = toolchainManager.getToolchainsForType( "unknown", session ); - - // verify - verify( logger ).error( "Missing toolchain factory for type: unknown. Possibly caused by misconfigured project." ); - assertEquals( 0, toolchains.length ); - } - - @Test - public void testToolchainsForConfiguredType() - throws Exception - { - // prepare - MavenSession session = mock( MavenSession.class ); - MavenExecutionRequest req = new DefaultMavenExecutionRequest(); - when( session.getRequest() ).thenReturn( req ); - Map<String, List<ToolchainModel>> groupedToolchains = new HashMap<String, List<ToolchainModel>>(); - req.setToolchains( groupedToolchains ); - - List<ToolchainModel> basicToolchains = new ArrayList<ToolchainModel>(); - ToolchainModel basicToolchainModel = new ToolchainModel(); - basicToolchainModel.setType( "basic" ); - basicToolchains.add( basicToolchainModel ); - basicToolchains.add( basicToolchainModel ); - groupedToolchains.put( "basic", basicToolchains ); - - List<ToolchainModel> rareToolchains = new ArrayList<ToolchainModel>(); - ToolchainModel rareToolchainModel = new ToolchainModel(); - rareToolchainModel.setType( "rare" ); - rareToolchains.add( rareToolchainModel ); - groupedToolchains.put( "rare", rareToolchains ); - - // execute - ToolchainPrivate[] toolchains = toolchainManager.getToolchainsForType( "basic", session ); - - // verify - verify( logger, never() ).error( anyString() ); - assertEquals( 2, toolchains.length ); - } - - @SuppressWarnings( "unchecked" ) - @Test( expected = MisconfiguredToolchainException.class ) - public void testMisconfiguredToolchain() - throws Exception - { - // prepare - MavenSession session = mock( MavenSession.class ); - MavenExecutionRequest req = new DefaultMavenExecutionRequest(); - when( session.getRequest() ).thenReturn( req ); - when(toolchainFactory_basicType.createDefaultToolchain()).thenThrow( MisconfiguredToolchainException.class ); - - // execute - toolchainManager.getToolchainsForType( "basic", session ); - - // verify - fail( "Should exit with a MisconfiguredToolchainException" ); - } -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/toolchain/DefaultToolchainManagerTest.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/toolchain/DefaultToolchainManagerTest.java deleted file mode 100644 index d464502f..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/toolchain/DefaultToolchainManagerTest.java +++ /dev/null @@ -1,153 +0,0 @@ -package org.apache.maven.toolchain; - -/* - * 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 static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.anyMap; -import static org.mockito.Matchers.isA; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.maven.execution.DefaultMavenExecutionRequest; -import org.apache.maven.execution.MavenExecutionRequest; -import org.apache.maven.execution.MavenSession; -import org.apache.maven.toolchain.model.ToolchainModel; -import org.codehaus.plexus.logging.Logger; -import org.junit.Before; -import org.junit.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - -public class DefaultToolchainManagerTest -{ - // Mocks to inject into toolchainManager - @Mock - private Logger logger; - - @InjectMocks - private DefaultToolchainManager toolchainManager; - - @Mock - private ToolchainFactory toolchainFactory_basicType; - - @Mock - private ToolchainFactory toolchainFactory_rareType; - - @Before - public void onSetup() throws Exception - { - toolchainManager = new DefaultToolchainManager(); - - MockitoAnnotations.initMocks( this ); - - toolchainManager.factories = new HashMap<String, ToolchainFactory>(); - toolchainManager.factories.put( "basic", toolchainFactory_basicType ); - toolchainManager.factories.put( "rare", toolchainFactory_rareType ); - } - - @Test - public void testNoModels() - { - MavenSession session = mock( MavenSession.class ); - MavenExecutionRequest executionRequest = new DefaultMavenExecutionRequest(); - when( session.getRequest() ).thenReturn( executionRequest ); - - List<Toolchain> toolchains = toolchainManager.getToolchains( session, "unknown", null ); - - assertEquals( 0, toolchains.size() ); - } - - @Test - public void testModelNoFactory() - { - MavenSession session = mock( MavenSession.class ); - MavenExecutionRequest executionRequest = new DefaultMavenExecutionRequest(); - Map<String, List<ToolchainModel>> toolchainModels = new HashMap<String, List<ToolchainModel>>(); - toolchainModels.put( "unknown", Collections.singletonList( new ToolchainModel() ) ); - executionRequest.setToolchains( toolchainModels ); - when( session.getRequest() ).thenReturn( executionRequest ); - - List<Toolchain> toolchains = toolchainManager.getToolchains( session, "unknown", null ); - - assertEquals( 0, toolchains.size() ); - verify( logger ).error( "Missing toolchain factory for type: unknown. Possibly caused by misconfigured project." ); - } - - @Test - public void testModelAndFactory() - { - MavenSession session = mock( MavenSession.class ); - MavenExecutionRequest executionRequest = new DefaultMavenExecutionRequest(); - Map<String, List<ToolchainModel>> toolchainModels = new HashMap<String, List<ToolchainModel>>(); - toolchainModels.put( "basic", Arrays.asList( new ToolchainModel(), new ToolchainModel() ) ); - toolchainModels.put( "rare", Collections.singletonList( new ToolchainModel() ) ); - executionRequest.setToolchains( toolchainModels ); - when( session.getRequest() ).thenReturn( executionRequest ); - - List<Toolchain> toolchains = toolchainManager.getToolchains( session, "rare", null ); - - assertEquals( 1, toolchains.size() ); - } - - @Test - public void testModelsAndFactory() - { - MavenSession session = mock( MavenSession.class ); - MavenExecutionRequest executionRequest = new DefaultMavenExecutionRequest(); - Map<String, List<ToolchainModel>> toolchainModels = new HashMap<String, List<ToolchainModel>>(); - toolchainModels.put( "basic", Arrays.asList( new ToolchainModel(), new ToolchainModel() ) ); - toolchainModels.put( "rare", Collections.singletonList( new ToolchainModel() ) ); - executionRequest.setToolchains( toolchainModels ); - when( session.getRequest() ).thenReturn( executionRequest ); - - List<Toolchain> toolchains = toolchainManager.getToolchains( session, "basic", null ); - - assertEquals( 2, toolchains.size() ); - } - - @Test - public void testRequirements() - throws Exception - { - MavenSession session = mock( MavenSession.class ); - MavenExecutionRequest executionRequest = new DefaultMavenExecutionRequest(); - Map<String, List<ToolchainModel>> toolchainModels = new HashMap<String, List<ToolchainModel>>(); - toolchainModels.put( "basic", Arrays.asList( new ToolchainModel(), new ToolchainModel() ) ); - toolchainModels.put( "rare", Collections.singletonList( new ToolchainModel() ) ); - executionRequest.setToolchains( toolchainModels ); - when( session.getRequest() ).thenReturn( executionRequest ); - ToolchainPrivate basicPrivate = mock( ToolchainPrivate.class ); - when( basicPrivate.matchesRequirements( anyMap() ) ).thenReturn( false ).thenReturn( true ); - when( toolchainFactory_basicType.createToolchain( isA( ToolchainModel.class ) ) ).thenReturn( basicPrivate ); - - List<Toolchain> toolchains = - toolchainManager.getToolchains( session, "basic", Collections.singletonMap( "key", "value" ) ); - - assertEquals( 1, toolchains.size() ); - } -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/toolchain/DefaultToolchainTest.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/toolchain/DefaultToolchainTest.java deleted file mode 100644 index 3bba8177..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/toolchain/DefaultToolchainTest.java +++ /dev/null @@ -1,158 +0,0 @@ -package org.apache.maven.toolchain; - -/* - * 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 static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.verify; - -import java.io.InputStream; -import java.util.Collections; - -import org.apache.maven.toolchain.java.DefaultJavaToolChain; -import org.apache.maven.toolchain.model.PersistedToolchains; -import org.apache.maven.toolchain.model.ToolchainModel; -import org.apache.maven.toolchain.model.io.xpp3.MavenToolchainsXpp3Reader; -import org.codehaus.plexus.logging.Logger; -import org.codehaus.plexus.util.IOUtil; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - -public class DefaultToolchainTest -{ - @Mock - private Logger logger; - - private MavenToolchainsXpp3Reader reader = new MavenToolchainsXpp3Reader(); - - @Before - public void setUp() throws Exception - { - MockitoAnnotations.initMocks( this ); - } - - private DefaultToolchain newDefaultToolchain( ToolchainModel model ) - { - return new DefaultToolchain( model, logger ) - { - @Override - public String findTool( String toolName ) - { - return null; - } - }; - } - - private DefaultToolchain newDefaultToolchain( ToolchainModel model, String type ) - { - return new DefaultToolchain( model, type, logger ) - { - @Override - public String findTool( String toolName ) - { - return null; - } - }; - } - - @Test - public void testGetModel() - { - ToolchainModel model = new ToolchainModel(); - DefaultToolchain toolchain = newDefaultToolchain( model ); - assertEquals( model, toolchain.getModel() ); - } - - @Test - public void testGetType() - { - ToolchainModel model = new ToolchainModel(); - DefaultToolchain toolchain = newDefaultToolchain( model, "TYPE" ); - assertEquals( "TYPE", toolchain.getType() ); - - model.setType( "MODEL_TYPE" ); - toolchain = newDefaultToolchain( model ); - assertEquals( "MODEL_TYPE", toolchain.getType() ); - } - - @Test - public void testGetLogger() - { - ToolchainModel model = new ToolchainModel(); - DefaultToolchain toolchain = newDefaultToolchain( model ); - assertEquals( logger, toolchain.getLog() ); - } - - @Test - public void testMissingRequirementProperty() - { - ToolchainModel model = new ToolchainModel(); - model.setType( "TYPE" ); - DefaultToolchain toolchain = newDefaultToolchain( model ); - - assertFalse( toolchain.matchesRequirements( Collections.singletonMap( "name", "John Doe" ) ) ); - verify( logger ).debug( "Toolchain type:TYPE{} is missing required property: name" ); - } - - - @Test - public void testNonMatchingRequirementProperty() - { - ToolchainModel model = new ToolchainModel(); - model.setType( "TYPE" ); - DefaultToolchain toolchain = newDefaultToolchain( model ); - toolchain.addProvideToken( "name", RequirementMatcherFactory.createExactMatcher( "Jane Doe" ) ); - - assertFalse( toolchain.matchesRequirements( Collections.singletonMap( "name", "John Doe" ) ) ); - verify( logger ).debug( "Toolchain type:TYPE{name = Jane Doe} doesn't match required property: name" ); - } - - - @Test - public void testEquals() throws Exception - { - InputStream jdksIS = null; - InputStream jdksExtraIS = null; - try - { - jdksIS = ToolchainModel.class.getResourceAsStream( "toolchains-jdks.xml" ); - jdksExtraIS = ToolchainModel.class.getResourceAsStream( "toolchains-jdks-extra.xml" ); - - PersistedToolchains jdks = reader.read( jdksIS ); - PersistedToolchains jdksExtra = reader.read( jdksExtraIS ); - - DefaultToolchain tc1 = new DefaultJavaToolChain( jdks.getToolchains().get( 0 ), null ); - DefaultToolchain tc2 = new DefaultJavaToolChain( jdksExtra.getToolchains().get( 0 ), null ); - - assertTrue( tc1.equals( tc1 ) ); - assertFalse( tc1.equals( tc2 ) ); - assertFalse( tc2.equals( tc1 ) ); - assertTrue( tc2.equals( tc2 ) ); - } - finally - { - IOUtil.close( jdksIS ); - IOUtil.close( jdksExtraIS ); - } - } -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/toolchain/RequirementMatcherFactoryTest.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/toolchain/RequirementMatcherFactoryTest.java deleted file mode 100644 index c102b11f..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/toolchain/RequirementMatcherFactoryTest.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * 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. - */ - -package org.apache.maven.toolchain; - -import junit.framework.TestCase; - -/** - * - * @author mkleint - */ -public class RequirementMatcherFactoryTest - extends TestCase -{ - - public RequirementMatcherFactoryTest( String testName ) - { - super( testName ); - } - - /** - * Test of createExactMatcher method, of class RequirementMatcherFactory. - */ - public void testCreateExactMatcher() - { - RequirementMatcher matcher; - matcher = RequirementMatcherFactory.createExactMatcher( "foo" ); - assertFalse( matcher.matches( "bar" ) ); - assertFalse( matcher.matches( "foobar" ) ); - assertFalse( matcher.matches( "foob" ) ); - assertTrue( matcher.matches( "foo" ) ); - } - - /** - * Test of createVersionMatcher method, of class RequirementMatcherFactory. - */ - public void testCreateVersionMatcher() - { - RequirementMatcher matcher; - matcher = RequirementMatcherFactory.createVersionMatcher( "1.5.2" ); - assertFalse( matcher.matches( "1.5" ) ); - assertTrue( matcher.matches( "1.5.2" ) ); - assertFalse( matcher.matches( "[1.4,1.5)" ) ); - assertFalse( matcher.matches( "[1.5,1.5.2)" ) ); - assertFalse( matcher.matches( "(1.5.2,1.6)" ) ); - assertTrue( matcher.matches( "(1.4,1.5.2]" ) ); - assertTrue( matcher.matches( "(1.5,)" ) ); - assertEquals( "1.5.2", matcher.toString() ); - - // Ensure it is not printed as 1.5.0 - matcher = RequirementMatcherFactory.createVersionMatcher( "1.5" ); - assertEquals( "1.5", matcher.toString() ); - - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/toolchain/building/DefaultToolchainsBuilderTest.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/toolchain/building/DefaultToolchainsBuilderTest.java deleted file mode 100644 index 80fca094..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/toolchain/building/DefaultToolchainsBuilderTest.java +++ /dev/null @@ -1,185 +0,0 @@ -package org.apache.maven.toolchain.building; - -/* - * 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 static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyMap; -import static org.mockito.Mockito.when; - -import java.io.IOException; -import java.io.InputStream; - -import org.apache.maven.building.StringSource; -import org.apache.maven.toolchain.io.ToolchainsParseException; -import org.apache.maven.toolchain.io.ToolchainsReader; -import org.apache.maven.toolchain.model.PersistedToolchains; -import org.apache.maven.toolchain.model.ToolchainModel; -import org.junit.Before; -import org.junit.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - -public class DefaultToolchainsBuilderTest -{ - private static final String LS = System.getProperty( "line.separator" ); - - @Mock - private ToolchainsReader toolchainsReader; - - @InjectMocks - private DefaultToolchainsBuilder toolchainBuilder = new DefaultToolchainsBuilder(); - - @Before - public void onSetup() - { - MockitoAnnotations.initMocks( this ); - } - - @Test - public void testBuildEmptyRequest() - throws Exception - { - ToolchainsBuildingRequest request = new DefaultToolchainsBuildingRequest(); - ToolchainsBuildingResult result = toolchainBuilder.build( request ); - assertNotNull( result.getEffectiveToolchains() ); - assertNotNull( result.getProblems() ); - assertEquals( 0, result.getProblems().size() ); - } - - @Test - public void testBuildRequestWithUserToolchains() - throws Exception - { - ToolchainsBuildingRequest request = new DefaultToolchainsBuildingRequest(); - request.setUserToolchainsSource( new StringSource( "" ) ); - - PersistedToolchains userResult = new PersistedToolchains(); - ToolchainModel toolchain = new ToolchainModel(); - toolchain.setType( "TYPE" ); - toolchain.addProvide( "key", "user_value" ); - userResult.addToolchain( toolchain ); - when( toolchainsReader.read( any( InputStream.class ), anyMap() ) ).thenReturn( userResult ); - - ToolchainsBuildingResult result = toolchainBuilder.build( request ); - assertNotNull( result.getEffectiveToolchains() ); - assertEquals( 1, result.getEffectiveToolchains().getToolchains().size() ); - assertEquals( "TYPE", result.getEffectiveToolchains().getToolchains().get(0).getType() ); - assertEquals( "user_value", result.getEffectiveToolchains().getToolchains().get(0).getProvides().getProperty( "key" ) ); - assertNotNull( result.getProblems() ); - assertEquals( 0, result.getProblems().size() ); - } - - @Test - public void testBuildRequestWithGlobalToolchains() - throws Exception - { - ToolchainsBuildingRequest request = new DefaultToolchainsBuildingRequest(); - request.setGlobalToolchainsSource( new StringSource( "" ) ); - - PersistedToolchains globalResult = new PersistedToolchains(); - ToolchainModel toolchain = new ToolchainModel(); - toolchain.setType( "TYPE" ); - toolchain.addProvide( "key", "global_value" ); - globalResult.addToolchain( toolchain ); - when( toolchainsReader.read( any( InputStream.class ), anyMap() ) ).thenReturn( globalResult ); - - ToolchainsBuildingResult result = toolchainBuilder.build( request ); - assertNotNull( result.getEffectiveToolchains() ); - assertEquals( 1, result.getEffectiveToolchains().getToolchains().size() ); - assertEquals( "TYPE", result.getEffectiveToolchains().getToolchains().get(0).getType() ); - assertEquals( "global_value", result.getEffectiveToolchains().getToolchains().get(0).getProvides().getProperty( "key" ) ); - assertNotNull( result.getProblems() ); - assertEquals( 0, result.getProblems().size() ); - } - - @Test - public void testBuildRequestWithBothToolchains() - throws Exception - { - ToolchainsBuildingRequest request = new DefaultToolchainsBuildingRequest(); - request.setGlobalToolchainsSource( new StringSource( "" ) ); - request.setUserToolchainsSource( new StringSource( "" ) ); - - PersistedToolchains userResult = new PersistedToolchains(); - ToolchainModel userToolchain = new ToolchainModel(); - userToolchain.setType( "TYPE" ); - userToolchain.addProvide( "key", "user_value" ); - userResult.addToolchain( userToolchain ); - - PersistedToolchains globalResult = new PersistedToolchains(); - ToolchainModel globalToolchain = new ToolchainModel(); - globalToolchain.setType( "TYPE" ); - globalToolchain.addProvide( "key", "global_value" ); - globalResult.addToolchain( globalToolchain ); - when( toolchainsReader.read( any( InputStream.class ), anyMap() ) ).thenReturn( globalResult ).thenReturn( userResult ); - - ToolchainsBuildingResult result = toolchainBuilder.build( request ); - assertNotNull( result.getEffectiveToolchains() ); - assertEquals( 2, result.getEffectiveToolchains().getToolchains().size() ); - assertEquals( "TYPE", result.getEffectiveToolchains().getToolchains().get(0).getType() ); - assertEquals( "user_value", result.getEffectiveToolchains().getToolchains().get(0).getProvides().getProperty( "key" ) ); - assertEquals( "TYPE", result.getEffectiveToolchains().getToolchains().get(1).getType() ); - assertEquals( "global_value", result.getEffectiveToolchains().getToolchains().get(1).getProvides().getProperty( "key" ) ); - assertNotNull( result.getProblems() ); - assertEquals( 0, result.getProblems().size() ); - } - - @Test - public void testStrictToolchainsParseException() throws Exception - { - ToolchainsBuildingRequest request = new DefaultToolchainsBuildingRequest(); - request.setGlobalToolchainsSource( new StringSource( "" ) ); - ToolchainsParseException parseException = new ToolchainsParseException( "MESSAGE", 4, 2 ); - when( toolchainsReader.read( any( InputStream.class ), anyMap() ) ).thenThrow( parseException ); - - try - { - toolchainBuilder.build( request ); - } - catch ( ToolchainsBuildingException e ) - { - assertEquals( "1 problem was encountered while building the effective toolchains" + LS + - "[FATAL] Non-parseable toolchains (memory): MESSAGE @ line 4, column 2" + LS, e.getMessage() ); - } - } - - @Test - public void testIOException() throws Exception - { - ToolchainsBuildingRequest request = new DefaultToolchainsBuildingRequest(); - request.setGlobalToolchainsSource( new StringSource( "", "LOCATION" ) ); - IOException ioException = new IOException( "MESSAGE" ); - when( toolchainsReader.read( any( InputStream.class ), anyMap() ) ).thenThrow( ioException ); - - try - { - toolchainBuilder.build( request ); - } - catch ( ToolchainsBuildingException e ) - { - assertEquals( "1 problem was encountered while building the effective toolchains" + LS + - "[FATAL] Non-readable toolchains LOCATION: MESSAGE" + LS, e.getMessage() ); - } - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/toolchain/building/ToolchainsBuildingExceptionTest.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/toolchain/building/ToolchainsBuildingExceptionTest.java deleted file mode 100644 index bf745c2a..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/toolchain/building/ToolchainsBuildingExceptionTest.java +++ /dev/null @@ -1,73 +0,0 @@ -package org.apache.maven.toolchain.building; - -/* - * 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 static org.junit.Assert.assertEquals; - -import java.util.Collections; - -import org.apache.maven.building.Problem; -import org.apache.maven.building.ProblemCollector; -import org.apache.maven.building.ProblemCollectorFactory; -import org.junit.Test; - -public class ToolchainsBuildingExceptionTest -{ - private static final String LS = System.getProperty( "line.separator" ); - - @Test - public void testNoProblems() - { - ToolchainsBuildingException e = new ToolchainsBuildingException( Collections.<Problem>emptyList() ); - assertEquals( "0 problems were encountered while building the effective toolchains" + LS, e.getMessage() ); - } - - @Test - public void testOneProblem() - { - ProblemCollector problemCollector = ProblemCollectorFactory.newInstance( null ); - problemCollector.add( Problem.Severity.ERROR, "MESSAGE", 3, 5, new Exception() ); - ToolchainsBuildingException e = new ToolchainsBuildingException( problemCollector.getProblems() ); - assertEquals( "1 problem was encountered while building the effective toolchains" + LS + - "[ERROR] MESSAGE @ line 3, column 5" + LS, e.getMessage() ); - } - - @Test - public void testUnknownPositionAndSource() - { - ProblemCollector problemCollector = ProblemCollectorFactory.newInstance( null ); - problemCollector.add( Problem.Severity.ERROR, "MESSAGE", -1, -1, new Exception() ); - ToolchainsBuildingException e = new ToolchainsBuildingException( problemCollector.getProblems() ); - assertEquals( "1 problem was encountered while building the effective toolchains" + LS + - "[ERROR] MESSAGE" + LS, e.getMessage() ); - } - - @Test - public void testUnknownPosition() - { - ProblemCollector problemCollector = ProblemCollectorFactory.newInstance( null ); - problemCollector.setSource( "SOURCE" ); - problemCollector.add( Problem.Severity.ERROR, "MESSAGE", -1, -1, new Exception() ); - ToolchainsBuildingException e = new ToolchainsBuildingException( problemCollector.getProblems() ); - assertEquals( "1 problem was encountered while building the effective toolchains" + LS + - "[ERROR] MESSAGE @ SOURCE" + LS, e.getMessage() ); - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/toolchain/merge/MavenToolchainMergerTest.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/toolchain/merge/MavenToolchainMergerTest.java deleted file mode 100644 index 9183e175..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/toolchain/merge/MavenToolchainMergerTest.java +++ /dev/null @@ -1,176 +0,0 @@ -package org.apache.maven.toolchain.merge; - -/* - * 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 static org.junit.Assert.assertEquals; - -import java.io.InputStream; - -import org.apache.maven.toolchain.model.PersistedToolchains; -import org.apache.maven.toolchain.model.ToolchainModel; -import org.apache.maven.toolchain.model.TrackableBase; -import org.apache.maven.toolchain.model.io.xpp3.MavenToolchainsXpp3Reader; -import org.codehaus.plexus.util.IOUtil; -import org.codehaus.plexus.util.xml.Xpp3Dom; -import org.junit.Test; - -public class MavenToolchainMergerTest -{ - private MavenToolchainMerger merger = new MavenToolchainMerger(); - - private MavenToolchainsXpp3Reader reader = new MavenToolchainsXpp3Reader(); - - @Test - public void testMergeNulls() - { - merger.merge( null, null, null ); - - PersistedToolchains pt = new PersistedToolchains(); - merger.merge( pt, null, null ); - merger.merge( null, pt, null ); - } - - @Test - public void testMergeJdk() throws Exception - { - InputStream isDominant = null; - InputStream isRecessive = null; - try - { - isDominant = ToolchainModel.class.getResourceAsStream( "toolchains-jdks.xml" ); - isRecessive = ToolchainModel.class.getResourceAsStream( "toolchains-jdks.xml" ); - - PersistedToolchains dominant = reader.read( isDominant ); - PersistedToolchains recessive = reader.read( isRecessive ); - assertEquals( 2, dominant.getToolchains().size() ); - - merger.merge( dominant, recessive, TrackableBase.USER_LEVEL ); - assertEquals( 2, dominant.getToolchains().size() ); - } - finally - { - IOUtil.close( isDominant ); - } - } - - @Test - public void testMergeJdkExtra() throws Exception - { - InputStream jdksIS = null; - InputStream jdksExtraIS = null; - try - { - jdksIS = ToolchainModel.class.getResourceAsStream( "toolchains-jdks.xml" ); - jdksExtraIS = ToolchainModel.class.getResourceAsStream( "toolchains-jdks-extra.xml" ); - - PersistedToolchains jdks = reader.read( jdksIS ); - PersistedToolchains jdksExtra = reader.read( jdksExtraIS ); - assertEquals( 2, jdks.getToolchains().size() ); - - merger.merge( jdks, jdksExtra, TrackableBase.USER_LEVEL ); - assertEquals( 4, jdks.getToolchains().size() ); - assertEquals( 2, jdksExtra.getToolchains().size() ); - } - finally - { - IOUtil.close( jdksIS ); - IOUtil.close( jdksExtraIS ); - } - - try - { - jdksIS = ToolchainModel.class.getResourceAsStream( "toolchains-jdks.xml" ); - jdksExtraIS = ToolchainModel.class.getResourceAsStream( "toolchains-jdks-extra.xml" ); - - PersistedToolchains jdks = reader.read( jdksIS ); - PersistedToolchains jdksExtra = reader.read( jdksExtraIS ); - assertEquals( 2, jdks.getToolchains().size() ); - - // switch dominant with reccessive - merger.merge( jdksExtra, jdks, TrackableBase.USER_LEVEL ); - assertEquals( 4, jdksExtra.getToolchains().size() ); - assertEquals( 2, jdks.getToolchains().size() ); - } - finally - { - IOUtil.close( jdksIS ); - IOUtil.close( jdksExtraIS ); - } - } - - @Test - public void testMergeJdkExtend() throws Exception - { - InputStream jdksIS = null; - InputStream jdksExtendIS = null; - try - { - jdksIS = ToolchainModel.class.getResourceAsStream( "toolchains-jdks.xml" ); - jdksExtendIS = ToolchainModel.class.getResourceAsStream( "toolchains-jdks-extend.xml" ); - - PersistedToolchains jdks = reader.read( jdksIS ); - PersistedToolchains jdksExtend = reader.read( jdksExtendIS ); - assertEquals( 2, jdks.getToolchains().size() ); - - merger.merge( jdks, jdksExtend, TrackableBase.USER_LEVEL ); - assertEquals( 2, jdks.getToolchains().size() ); - Xpp3Dom config0 = (Xpp3Dom) jdks.getToolchains().get( 0 ).getConfiguration(); - assertEquals( "lib/tools.jar", config0.getChild( "toolsJar" ).getValue() ); - assertEquals( 2, config0.getChildCount() ); - Xpp3Dom config1 = (Xpp3Dom) jdks.getToolchains().get( 1 ).getConfiguration(); - assertEquals( 2, config1.getChildCount() ); - assertEquals( "lib/classes.jar", config1.getChild( "toolsJar" ).getValue() ); - assertEquals( 2, jdksExtend.getToolchains().size() ); - } - finally - { - IOUtil.close( jdksIS ); - IOUtil.close( jdksExtendIS ); - } - - try - { - jdksIS = ToolchainModel.class.getResourceAsStream( "toolchains-jdks.xml" ); - jdksExtendIS = ToolchainModel.class.getResourceAsStream( "toolchains-jdks-extend.xml" ); - - PersistedToolchains jdks = reader.read( jdksIS ); - PersistedToolchains jdksExtend = reader.read( jdksExtendIS ); - assertEquals( 2, jdks.getToolchains().size() ); - - // switch dominant with reccessive - merger.merge( jdksExtend, jdks, TrackableBase.USER_LEVEL ); - assertEquals( 2, jdksExtend.getToolchains().size() ); - Xpp3Dom config0 = (Xpp3Dom) jdksExtend.getToolchains().get( 0 ).getConfiguration(); - assertEquals( "lib/tools.jar", config0.getChild( "toolsJar" ).getValue() ); - assertEquals( 2, config0.getChildCount() ); - Xpp3Dom config1 = (Xpp3Dom) jdksExtend.getToolchains().get( 1 ).getConfiguration(); - assertEquals( 2, config1.getChildCount() ); - assertEquals( "lib/classes.jar", config1.getChild( "toolsJar" ).getValue() ); - assertEquals( 2, jdks.getToolchains().size() ); - } - finally - { - IOUtil.close( jdksIS ); - IOUtil.close( jdksExtendIS ); - } - - } - -} |