diff options
Diffstat (limited to 'framework/src/maven/apache-maven-3.3.3/maven-core/src/test/java/org/apache/maven/lifecycle')
31 files changed, 0 insertions, 3085 deletions
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 ) ); - } -} |