mirror of https://github.com/apache/maven.git
parent
a0c1bf3c04
commit
b877445cb9
|
@ -131,6 +131,11 @@ under the License.
|
|||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-jxpath</groupId>
|
||||
<artifactId>commons-jxpath</artifactId>
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.apache.maven;
|
|||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
|
@ -45,37 +46,39 @@ import org.apache.maven.project.ProjectBuildingRequest;
|
|||
import org.apache.maven.repository.RepositorySystem;
|
||||
import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
|
||||
import org.codehaus.plexus.ContainerConfiguration;
|
||||
import org.codehaus.plexus.DefaultPlexusContainer;
|
||||
import org.codehaus.plexus.PlexusConstants;
|
||||
import org.codehaus.plexus.PlexusTestCase;
|
||||
import org.codehaus.plexus.component.annotations.Requirement;
|
||||
import org.codehaus.plexus.util.FileUtils;
|
||||
import org.eclipse.aether.DefaultRepositorySystemSession;
|
||||
import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory;
|
||||
import org.eclipse.aether.repository.LocalRepository;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public abstract class AbstractCoreMavenComponentTestCase
|
||||
extends PlexusTestCase
|
||||
{
|
||||
@Requirement
|
||||
@Inject
|
||||
protected RepositorySystem repositorySystem;
|
||||
|
||||
@Requirement
|
||||
@Inject
|
||||
protected org.apache.maven.project.ProjectBuilder projectBuilder;
|
||||
|
||||
protected void setUp()
|
||||
throws Exception
|
||||
@Override
|
||||
protected void setUp() throws Exception
|
||||
{
|
||||
repositorySystem = lookup( RepositorySystem.class );
|
||||
projectBuilder = lookup( org.apache.maven.project.ProjectBuilder.class );
|
||||
super.setUp();
|
||||
getContainer();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown()
|
||||
throws Exception
|
||||
protected synchronized void setupContainer()
|
||||
{
|
||||
repositorySystem = null;
|
||||
projectBuilder = null;
|
||||
super.tearDown();
|
||||
super.setupContainer();
|
||||
|
||||
( (DefaultPlexusContainer) getContainer() ).addPlexusInjector( Collections.emptyList(),
|
||||
binder -> binder.requestInjection( this ) );
|
||||
}
|
||||
|
||||
abstract protected String getProjectsDirectory();
|
||||
|
|
|
@ -1,17 +1,5 @@
|
|||
package org.apache.maven;
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.DefaultArtifact;
|
||||
import org.apache.maven.execution.MavenExecutionRequest;
|
||||
import org.apache.maven.execution.MavenExecutionResult;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.MavenProjectHelper;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
|
@ -30,14 +18,31 @@ import static java.util.Arrays.asList;
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.DefaultArtifact;
|
||||
import org.apache.maven.execution.MavenExecutionRequest;
|
||||
import org.apache.maven.execution.MavenExecutionResult;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.MavenProjectHelper;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
public class DefaultMavenTest
|
||||
extends AbstractCoreMavenComponentTestCase
|
||||
{
|
||||
|
||||
@Inject
|
||||
private Maven maven;
|
||||
|
||||
public void testThatErrorDuringProjectDependencyGraphCreationAreStored()
|
||||
throws Exception
|
||||
{
|
||||
Maven maven = getContainer().lookup( Maven.class );
|
||||
MavenExecutionRequest request = createMavenExecutionRequest( getProject( "cyclic-reference" ) ).setGoals( asList("validate") );
|
||||
|
||||
MavenExecutionResult result = maven.execute( request );
|
||||
|
|
|
@ -17,32 +17,31 @@ package org.apache.maven;
|
|||
|
||||
|
||||
import org.apache.maven.exception.ExceptionHandler;
|
||||
import org.codehaus.plexus.component.annotations.Requirement;
|
||||
import org.apache.maven.exception.ExceptionSummary;
|
||||
import org.apache.maven.execution.MavenExecutionRequest;
|
||||
import org.apache.maven.execution.MavenExecutionResult;
|
||||
import org.codehaus.plexus.DefaultPlexusContainer;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
|
||||
public class MavenTest
|
||||
extends AbstractCoreMavenComponentTestCase
|
||||
{
|
||||
@Requirement
|
||||
@Inject
|
||||
private Maven maven;
|
||||
|
||||
@Requirement
|
||||
@Inject
|
||||
private ExceptionHandler exceptionHandler;
|
||||
|
||||
protected void setUp()
|
||||
throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
maven = lookup( Maven.class );
|
||||
exceptionHandler = lookup( ExceptionHandler.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown()
|
||||
throws Exception
|
||||
protected synchronized void setupContainer()
|
||||
{
|
||||
maven = null;
|
||||
exceptionHandler = null;
|
||||
super.tearDown();
|
||||
super.setupContainer();
|
||||
|
||||
( (DefaultPlexusContainer) getContainer() ).addPlexusInjector( Collections.emptyList(),
|
||||
binder -> binder.requestInjection( this ) );
|
||||
}
|
||||
|
||||
protected String getProjectsDirectory()
|
||||
|
|
|
@ -27,29 +27,15 @@ import java.util.Set;
|
|||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.execution.MavenSession;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.codehaus.plexus.component.annotations.Requirement;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class ProjectDependenciesResolverTest
|
||||
extends AbstractCoreMavenComponentTestCase
|
||||
{
|
||||
@Requirement
|
||||
@Inject
|
||||
private ProjectDependenciesResolver resolver;
|
||||
|
||||
protected void setUp()
|
||||
throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
resolver = lookup( ProjectDependenciesResolver.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown()
|
||||
throws Exception
|
||||
{
|
||||
resolver = null;
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
protected String getProjectsDirectory()
|
||||
{
|
||||
return "src/test/projects/project-dependencies-resolver";
|
||||
|
|
|
@ -27,9 +27,13 @@ import java.util.List;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
import org.codehaus.plexus.ContainerConfiguration;
|
||||
import org.codehaus.plexus.DefaultPlexusContainer;
|
||||
import org.codehaus.plexus.PlexusConstants;
|
||||
import org.codehaus.plexus.PlexusTestCase;
|
||||
import org.codehaus.plexus.component.annotations.Requirement;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Kristian Rosenvold
|
||||
|
@ -38,7 +42,7 @@ import org.codehaus.plexus.component.annotations.Requirement;
|
|||
public class DefaultLifecyclesTest
|
||||
extends PlexusTestCase
|
||||
{
|
||||
@Requirement
|
||||
@Inject
|
||||
private DefaultLifecycles defaultLifeCycles;
|
||||
|
||||
@Override
|
||||
|
@ -49,19 +53,20 @@ public class DefaultLifecyclesTest
|
|||
configuration.setClassPathScanning( PlexusConstants.SCANNING_INDEX );
|
||||
}
|
||||
|
||||
protected void setUp()
|
||||
throws Exception
|
||||
@Override
|
||||
protected void setUp() throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
defaultLifeCycles = lookup( DefaultLifecycles.class );
|
||||
getContainer();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown()
|
||||
throws Exception
|
||||
protected synchronized void setupContainer()
|
||||
{
|
||||
defaultLifeCycles = null;
|
||||
super.tearDown();
|
||||
super.setupContainer();
|
||||
|
||||
( (DefaultPlexusContainer) getContainer() ).addPlexusInjector( Collections.emptyList(),
|
||||
binder -> binder.requestInjection( this ) );
|
||||
}
|
||||
|
||||
public void testDefaultLifecycles()
|
||||
|
|
|
@ -23,10 +23,11 @@ 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;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* Just asserts that it's able to create those components. Handy when plexus gets a nervous breakdown.
|
||||
* Just asserts that it's able to create those components. Handy when CDI container gets a nervous breakdown.
|
||||
*
|
||||
* @author Kristian Rosenvold
|
||||
*/
|
||||
|
@ -34,49 +35,29 @@ import org.codehaus.plexus.component.annotations.Requirement;
|
|||
public class LifecycleExecutorSubModulesTest
|
||||
extends AbstractCoreMavenComponentTestCase
|
||||
{
|
||||
@Requirement
|
||||
@Inject
|
||||
private DefaultLifecycles defaultLifeCycles;
|
||||
|
||||
@Requirement
|
||||
@Inject
|
||||
private MojoExecutor mojoExecutor;
|
||||
|
||||
@Requirement
|
||||
@Inject
|
||||
private LifecycleModuleBuilder lifeCycleBuilder;
|
||||
|
||||
@Requirement
|
||||
@Inject
|
||||
private LifecycleDependencyResolver lifeCycleDependencyResolver;
|
||||
|
||||
@Requirement
|
||||
@Inject
|
||||
private LifecycleExecutionPlanCalculator lifeCycleExecutionPlanCalculator;
|
||||
|
||||
@Requirement
|
||||
@Inject
|
||||
private LifeCyclePluginAnalyzer lifeCyclePluginAnalyzer;
|
||||
|
||||
@Requirement
|
||||
@Inject
|
||||
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();
|
||||
}
|
||||
@Inject
|
||||
private ExceptionHandler exceptionHandler;
|
||||
|
||||
protected String getProjectsDirectory()
|
||||
{
|
||||
|
@ -93,6 +74,7 @@ public class LifecycleExecutorSubModulesTest
|
|||
assertNotNull( lifeCycleExecutionPlanCalculator );
|
||||
assertNotNull( lifeCyclePluginAnalyzer );
|
||||
assertNotNull( lifeCycleTaskSegmentCalculator );
|
||||
assertNotNull( exceptionHandler );
|
||||
}
|
||||
|
||||
}
|
|
@ -26,7 +26,6 @@ import java.util.HashSet;
|
|||
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;
|
||||
|
@ -37,7 +36,6 @@ 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;
|
||||
|
@ -46,45 +44,25 @@ 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;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class LifecycleExecutorTest
|
||||
extends AbstractCoreMavenComponentTestCase
|
||||
{
|
||||
@Requirement
|
||||
@Inject
|
||||
private DefaultLifecycleExecutor lifecycleExecutor;
|
||||
|
||||
@Requirement
|
||||
@Inject
|
||||
private DefaultLifecycleTaskSegmentCalculator lifeCycleTaskSegmentCalculator;
|
||||
|
||||
@Requirement
|
||||
@Inject
|
||||
private LifecycleExecutionPlanCalculator lifeCycleExecutionPlanCalculator;
|
||||
|
||||
@Requirement
|
||||
@Inject
|
||||
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";
|
||||
|
|
|
@ -30,12 +30,12 @@ import org.apache.maven.AbstractCoreMavenComponentTestCase;
|
|||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.execution.MavenSession;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.codehaus.plexus.component.annotations.Requirement;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class LifecycleDependencyResolverTest extends AbstractCoreMavenComponentTestCase
|
||||
{
|
||||
@Requirement
|
||||
@Inject
|
||||
private LifecycleDependencyResolver resolver;
|
||||
|
||||
@Override
|
||||
|
@ -44,15 +44,6 @@ public class LifecycleDependencyResolverTest extends AbstractCoreMavenComponentT
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp()
|
||||
throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
resolver = lookup( LifecycleDependencyResolver.class );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCachedReactorProjectDependencies() throws Exception
|
||||
{
|
||||
MavenSession session = createMavenSession( new File( "src/test/projects/lifecycle-dependency-resolver/pom.xml" ), new Properties(), true );
|
||||
|
|
|
@ -31,29 +31,16 @@ import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
|||
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.codehaus.plexus.classworlds.realm.ClassRealm;
|
||||
import org.codehaus.plexus.component.annotations.Requirement;
|
||||
import org.codehaus.plexus.component.repository.ComponentDescriptor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class PluginManagerTest
|
||||
extends AbstractCoreMavenComponentTestCase
|
||||
{
|
||||
@Requirement
|
||||
@Inject
|
||||
private DefaultBuildPluginManager pluginManager;
|
||||
|
||||
protected void setUp()
|
||||
throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
pluginManager = (DefaultBuildPluginManager) lookup( BuildPluginManager.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown()
|
||||
throws Exception
|
||||
{
|
||||
pluginManager = null;
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
protected String getProjectsDirectory()
|
||||
{
|
||||
|
|
|
@ -47,6 +47,8 @@ import org.codehaus.plexus.PlexusContainer;
|
|||
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator;
|
||||
import org.codehaus.plexus.util.dag.CycleDetectedException;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* @author Jason van Zyl
|
||||
*/
|
||||
|
@ -55,15 +57,9 @@ public class PluginParameterExpressionEvaluatorTest
|
|||
{
|
||||
private static final String FS = File.separator;
|
||||
|
||||
@Inject
|
||||
private RepositorySystem factory;
|
||||
|
||||
public void setUp()
|
||||
throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
factory = lookup( RepositorySystem.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown()
|
||||
throws Exception
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.net.URI;
|
|||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.model.building.ModelBuildingException;
|
||||
|
@ -28,10 +29,13 @@ import org.apache.maven.model.building.ModelProblem;
|
|||
import org.apache.maven.repository.RepositorySystem;
|
||||
import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
|
||||
import org.codehaus.plexus.ContainerConfiguration;
|
||||
import org.codehaus.plexus.DefaultPlexusContainer;
|
||||
import org.codehaus.plexus.PlexusConstants;
|
||||
import org.codehaus.plexus.PlexusTestCase;
|
||||
import org.eclipse.aether.DefaultRepositorySystemSession;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* @author Jason van Zyl
|
||||
*/
|
||||
|
@ -40,6 +44,7 @@ public abstract class AbstractMavenProjectTestCase
|
|||
{
|
||||
protected ProjectBuilder projectBuilder;
|
||||
|
||||
@Inject
|
||||
protected RepositorySystem repositorySystem;
|
||||
|
||||
@Override
|
||||
|
@ -50,6 +55,15 @@ public abstract class AbstractMavenProjectTestCase
|
|||
containerConfiguration.setClassPathScanning( PlexusConstants.SCANNING_INDEX );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected synchronized void setupContainer()
|
||||
{
|
||||
super.setupContainer();
|
||||
|
||||
( (DefaultPlexusContainer) getContainer() ).addPlexusInjector( Collections.emptyList(),
|
||||
binder -> binder.requestInjection( this ) );
|
||||
}
|
||||
|
||||
protected void setUp()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -64,8 +78,6 @@ public abstract class AbstractMavenProjectTestCase
|
|||
// default over to the main project builder...
|
||||
projectBuilder = lookup( ProjectBuilder.class );
|
||||
}
|
||||
|
||||
repositorySystem = lookup( RepositorySystem.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.apache.maven.project;
|
|||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
@ -34,12 +35,15 @@ import org.apache.maven.project.harness.PomTestWrapper;
|
|||
import org.apache.maven.repository.RepositorySystem;
|
||||
import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
|
||||
import org.codehaus.plexus.ContainerConfiguration;
|
||||
import org.codehaus.plexus.DefaultPlexusContainer;
|
||||
import org.codehaus.plexus.PlexusConstants;
|
||||
import org.codehaus.plexus.PlexusTestCase;
|
||||
import org.eclipse.aether.DefaultRepositorySystemSession;
|
||||
import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory;
|
||||
import org.eclipse.aether.repository.LocalRepository;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
@ -53,12 +57,23 @@ public class PomConstructionTest
|
|||
|
||||
private static String BASE_MIXIN_DIR = BASE_DIR + "/resources-mixins";
|
||||
|
||||
@Inject
|
||||
private DefaultProjectBuilder projectBuilder;
|
||||
|
||||
@Inject
|
||||
private RepositorySystem repositorySystem;
|
||||
|
||||
private File testDirectory;
|
||||
|
||||
@Override
|
||||
protected synchronized void setupContainer()
|
||||
{
|
||||
super.setupContainer();
|
||||
|
||||
( (DefaultPlexusContainer) getContainer() ).addPlexusInjector( Collections.emptyList(),
|
||||
binder -> binder.requestInjection( this ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration )
|
||||
{
|
||||
|
@ -70,10 +85,9 @@ public class PomConstructionTest
|
|||
protected void setUp()
|
||||
throws Exception
|
||||
{
|
||||
getContainer();
|
||||
testDirectory = new File( getBasedir(), BASE_POM_DIR );
|
||||
new File( getBasedir(), BASE_MIXIN_DIR );
|
||||
projectBuilder = (DefaultProjectBuilder) lookup( ProjectBuilder.class );
|
||||
repositorySystem = lookup( RepositorySystem.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -20,20 +20,34 @@ package org.apache.maven.project.artifact;
|
|||
*/
|
||||
|
||||
import org.apache.maven.repository.RepositorySystem;
|
||||
import org.codehaus.plexus.DefaultPlexusContainer;
|
||||
import org.codehaus.plexus.PlexusTestCase;
|
||||
import org.junit.Ignore;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.Collections;
|
||||
|
||||
@Ignore
|
||||
public class MavenMetadataSourceTest
|
||||
extends PlexusTestCase
|
||||
{
|
||||
@Inject
|
||||
private RepositorySystem repositorySystem;
|
||||
|
||||
protected void setUp()
|
||||
throws Exception
|
||||
@Override
|
||||
protected synchronized void setupContainer()
|
||||
{
|
||||
super.setupContainer();
|
||||
|
||||
( (DefaultPlexusContainer) getContainer() ).addPlexusInjector( Collections.emptyList(),
|
||||
binder -> binder.requestInjection( this ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
repositorySystem = lookup( RepositorySystem.class );
|
||||
getContainer();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -21,12 +21,18 @@ package org.apache.maven.rtinfo.internal;
|
|||
|
||||
import org.apache.maven.rtinfo.RuntimeInformation;
|
||||
import org.codehaus.plexus.ContainerConfiguration;
|
||||
import org.codehaus.plexus.DefaultPlexusContainer;
|
||||
import org.codehaus.plexus.PlexusConstants;
|
||||
import org.codehaus.plexus.PlexusTestCase;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.Collections;
|
||||
|
||||
public class DefaultRuntimeInformationTest
|
||||
extends PlexusTestCase
|
||||
{
|
||||
@Inject
|
||||
RuntimeInformation rtInfo;
|
||||
|
||||
@Override
|
||||
protected void customizeContainerConfiguration(
|
||||
|
@ -37,21 +43,30 @@ public class DefaultRuntimeInformationTest
|
|||
configuration.setClassPathScanning(PlexusConstants.SCANNING_INDEX);
|
||||
}
|
||||
|
||||
public void testGetMavenVersion()
|
||||
throws Exception
|
||||
@Override
|
||||
protected void setUp() throws Exception
|
||||
{
|
||||
RuntimeInformation rtInfo = lookup( RuntimeInformation.class );
|
||||
super.setUp();
|
||||
getContainer();
|
||||
}
|
||||
@Override
|
||||
protected synchronized void setupContainer()
|
||||
{
|
||||
super.setupContainer();
|
||||
|
||||
( (DefaultPlexusContainer) getContainer() ).addPlexusInjector( Collections.emptyList(),
|
||||
binder -> binder.requestInjection( this ) );
|
||||
}
|
||||
|
||||
public void testGetMavenVersion()
|
||||
{
|
||||
String mavenVersion = rtInfo.getMavenVersion();
|
||||
assertNotNull( mavenVersion );
|
||||
assertTrue( mavenVersion.length() > 0 );
|
||||
}
|
||||
|
||||
public void testIsMavenVersion()
|
||||
throws Exception
|
||||
{
|
||||
RuntimeInformation rtInfo = lookup( RuntimeInformation.class );
|
||||
|
||||
assertTrue( rtInfo.isMavenVersion( "2.0" ) );
|
||||
assertFalse( rtInfo.isMavenVersion( "9.9" ) );
|
||||
|
||||
|
|
|
@ -23,13 +23,13 @@ import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
|
|||
import org.apache.maven.model.Profile;
|
||||
import org.apache.maven.project.DefaultProjectBuilder;
|
||||
import org.apache.maven.project.DefaultProjectBuildingRequest;
|
||||
import org.apache.maven.project.ProjectBuilder;
|
||||
import org.apache.maven.project.ProjectBuildingRequest;
|
||||
import org.apache.maven.project.harness.PomTestWrapper;
|
||||
import org.apache.maven.repository.RepositorySystem;
|
||||
import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
|
||||
import org.apache.maven.settings.io.xpp3.SettingsXpp3Reader;
|
||||
import org.codehaus.plexus.ContainerConfiguration;
|
||||
import org.codehaus.plexus.DefaultPlexusContainer;
|
||||
import org.codehaus.plexus.PlexusConstants;
|
||||
import org.codehaus.plexus.PlexusTestCase;
|
||||
import org.codehaus.plexus.util.ReaderFactory;
|
||||
|
@ -38,9 +38,11 @@ import org.eclipse.aether.DefaultRepositorySystemSession;
|
|||
import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory;
|
||||
import org.eclipse.aether.repository.LocalRepository;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.util.Collections;
|
||||
|
||||
public class PomConstructionWithSettingsTest
|
||||
extends PlexusTestCase
|
||||
|
@ -49,8 +51,10 @@ public class PomConstructionWithSettingsTest
|
|||
|
||||
private static final String BASE_POM_DIR = BASE_DIR + "/resources-settings";
|
||||
|
||||
@Inject
|
||||
private DefaultProjectBuilder projectBuilder;
|
||||
|
||||
@Inject
|
||||
private RepositorySystem repositorySystem;
|
||||
|
||||
private File testDirectory;
|
||||
|
@ -63,12 +67,20 @@ public class PomConstructionWithSettingsTest
|
|||
containerConfiguration.setClassPathScanning( PlexusConstants.SCANNING_INDEX );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected synchronized void setupContainer()
|
||||
{
|
||||
super.setupContainer();
|
||||
|
||||
( (DefaultPlexusContainer) getContainer() ).addPlexusInjector( Collections.emptyList(),
|
||||
binder -> binder.requestInjection( this ) );
|
||||
}
|
||||
|
||||
protected void setUp()
|
||||
throws Exception
|
||||
{
|
||||
getContainer();
|
||||
testDirectory = new File( getBasedir(), BASE_POM_DIR );
|
||||
projectBuilder = (DefaultProjectBuilder) lookup( ProjectBuilder.class );
|
||||
repositorySystem = lookup( RepositorySystem.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -386,15 +386,8 @@ public class MavenCliTest
|
|||
super.customizeContainer(container);
|
||||
container.addComponent(mock(Maven.class), "org.apache.maven.Maven");
|
||||
|
||||
((DefaultPlexusContainer)container).addPlexusInjector(Collections.<PlexusBeanModule>emptyList(),
|
||||
new Module()
|
||||
{
|
||||
public void configure( final Binder binder )
|
||||
{
|
||||
binder.bind( EventSpyDispatcher.class ).toInstance( eventSpyDispatcherMock );
|
||||
}
|
||||
}
|
||||
);
|
||||
( (DefaultPlexusContainer) container ).addPlexusInjector( Collections.emptyList(),
|
||||
binder -> binder.bind( EventSpyDispatcher.class ).toInstance( eventSpyDispatcherMock ) );
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue