[MNG-5577] Simplify tests to reduce use of wiring.

- Reduce the use of wiring in unit tests
- Enable class scanning for tests that require it.
- Remove test and wiring that's not used.
This commit is contained in:
Joseph Walton 2019-06-24 22:54:06 +10:00 committed by Sylwester Lachiewicz
parent 2628d713a9
commit b962ff361a
19 changed files with 145 additions and 58 deletions

View File

@ -21,12 +21,22 @@ package org.apache.maven.artifact.factory;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.artifact.versioning.VersionRange;
import org.codehaus.plexus.ContainerConfiguration;
import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.PlexusTestCase;
public class DefaultArtifactFactoryTest public class DefaultArtifactFactoryTest
extends PlexusTestCase extends PlexusTestCase
{ {
@Override
protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration )
{
super.customizeContainerConfiguration( containerConfiguration );
containerConfiguration.setAutoWiring( true );
containerConfiguration.setClassPathScanning( PlexusConstants.SCANNING_INDEX );
}
public void testPropagationOfSystemScopeRegardlessOfInheritedScope() throws Exception public void testPropagationOfSystemScopeRegardlessOfInheritedScope() throws Exception
{ {
ArtifactFactory factory = (ArtifactFactory) lookup( ArtifactFactory.ROLE ); ArtifactFactory factory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );

View File

@ -21,12 +21,22 @@ import org.apache.maven.repository.legacy.resolver.transform.ArtifactTransformat
import org.apache.maven.repository.legacy.resolver.transform.LatestArtifactTransformation; import org.apache.maven.repository.legacy.resolver.transform.LatestArtifactTransformation;
import org.apache.maven.repository.legacy.resolver.transform.ReleaseArtifactTransformation; import org.apache.maven.repository.legacy.resolver.transform.ReleaseArtifactTransformation;
import org.apache.maven.repository.legacy.resolver.transform.SnapshotTransformation; import org.apache.maven.repository.legacy.resolver.transform.SnapshotTransformation;
import org.codehaus.plexus.ContainerConfiguration;
import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.PlexusTestCase;
/** @author Jason van Zyl */ /** @author Jason van Zyl */
public class TransformationManagerTest public class TransformationManagerTest
extends PlexusTestCase extends PlexusTestCase
{ {
@Override
protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration )
{
super.customizeContainerConfiguration( containerConfiguration );
containerConfiguration.setAutoWiring( true );
containerConfiguration.setClassPathScanning( PlexusConstants.SCANNING_INDEX );
}
public void testTransformationManager() public void testTransformationManager()
throws Exception throws Exception
{ {

View File

@ -24,6 +24,8 @@ import java.io.File;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.repository.RepositorySystem; import org.apache.maven.repository.RepositorySystem;
import org.apache.maven.repository.internal.DefaultArtifactDescriptorReader; import org.apache.maven.repository.internal.DefaultArtifactDescriptorReader;
import org.codehaus.plexus.ContainerConfiguration;
import org.codehaus.plexus.PlexusConstants;
import org.eclipse.aether.impl.ArtifactDescriptorReader; import org.eclipse.aether.impl.ArtifactDescriptorReader;
import org.eclipse.aether.impl.ArtifactResolver; import org.eclipse.aether.impl.ArtifactResolver;
@ -32,6 +34,14 @@ public class ProjectClasspathTest
{ {
static final String dir = "projects/scope/"; static final String dir = "projects/scope/";
@Override
protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration )
{
super.customizeContainerConfiguration( containerConfiguration );
containerConfiguration.setAutoWiring( true );
containerConfiguration.setClassPathScanning( PlexusConstants.SCANNING_INDEX );
}
public void setUp() public void setUp()
throws Exception throws Exception
{ {
@ -41,9 +51,6 @@ public class ProjectClasspathTest
projectBuilder = lookup( ProjectBuilder.class, "classpath" ); projectBuilder = lookup( ProjectBuilder.class, "classpath" );
// the metadata source looks up the default impl, so we have to trick it
getContainer().addComponent( projectBuilder, ProjectBuilder.class, "default" );
repositorySystem = lookup( RepositorySystem.class ); repositorySystem = lookup( RepositorySystem.class );
} }

View File

@ -16,10 +16,8 @@ package org.apache.maven.project;
*/ */
import java.io.File; import java.io.File;
import java.io.FileNotFoundException;
import java.util.Collections; import java.util.Collections;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Component;
@ -28,32 +26,6 @@ public class TestProjectBuilder
extends DefaultProjectBuilder extends DefaultProjectBuilder
{ {
@Override
public ProjectBuildingResult build( Artifact artifact, ProjectBuildingRequest request )
throws ProjectBuildingException
{
if ( "maven-test".equals( artifact.getGroupId() ) )
{
String scope = artifact.getArtifactId().substring( "scope-".length() );
try
{
artifact.setFile( ProjectClasspathTest.getFileForClasspathResource( ProjectClasspathTest.dir + "transitive-" + scope + "-dep.xml" ) );
}
catch ( FileNotFoundException e )
{
throw new IllegalStateException( "Missing test POM for " + artifact );
}
}
if ( artifact.getFile() == null )
{
MavenProject project = new MavenProject();
project.setArtifact( artifact );
return new DefaultProjectBuildingResult( project, null, null );
}
return build( artifact.getFile(), request );
}
@Override @Override
public ProjectBuildingResult build( File pomFile, ProjectBuildingRequest configuration ) public ProjectBuildingResult build( File pomFile, ProjectBuildingRequest configuration )
throws ProjectBuildingException throws ProjectBuildingException

View File

@ -43,6 +43,8 @@ import org.apache.maven.wagon.events.TransferEvent;
import org.apache.maven.wagon.events.TransferListener; import org.apache.maven.wagon.events.TransferListener;
import org.apache.maven.wagon.observers.AbstractTransferListener; import org.apache.maven.wagon.observers.AbstractTransferListener;
import org.apache.maven.wagon.observers.Debug; import org.apache.maven.wagon.observers.Debug;
import org.codehaus.plexus.ContainerConfiguration;
import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.PlexusTestCase;
import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.FileUtils;
@ -60,6 +62,14 @@ public class DefaultWagonManagerTest
private ArtifactRepositoryFactory artifactRepositoryFactory; private ArtifactRepositoryFactory artifactRepositoryFactory;
@Override
protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration )
{
super.customizeContainerConfiguration( containerConfiguration );
containerConfiguration.setAutoWiring( true );
containerConfiguration.setClassPathScanning( PlexusConstants.SCANNING_INDEX );
}
protected void setUp() protected void setUp()
throws Exception throws Exception
{ {

View File

@ -37,6 +37,8 @@ import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException
import org.apache.maven.artifact.versioning.OverConstrainedVersionException; import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.artifact.versioning.VersionRange;
import org.apache.maven.repository.legacy.metadata.MetadataResolutionRequest; import org.apache.maven.repository.legacy.metadata.MetadataResolutionRequest;
import org.codehaus.plexus.ContainerConfiguration;
import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.PlexusTestCase;
import java.util.ArrayList; import java.util.ArrayList;
@ -67,6 +69,14 @@ public class DefaultArtifactCollectorTest
private static final String GROUP_ID = "test"; private static final String GROUP_ID = "test";
@Override
protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration )
{
super.customizeContainerConfiguration( containerConfiguration );
containerConfiguration.setAutoWiring( true );
containerConfiguration.setClassPathScanning( PlexusConstants.SCANNING_INDEX );
}
@Override @Override
protected void setUp() protected void setUp()
throws Exception throws Exception

View File

@ -26,6 +26,8 @@ import org.apache.maven.artifact.resolver.ResolutionNode;
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.artifact.versioning.VersionRange;
import org.apache.maven.repository.legacy.resolver.conflict.ConflictResolver; import org.apache.maven.repository.legacy.resolver.conflict.ConflictResolver;
import org.codehaus.plexus.ContainerConfiguration;
import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.PlexusTestCase;
import java.util.Collections; import java.util.Collections;
@ -66,6 +68,14 @@ public abstract class AbstractConflictResolverTest
// TestCase methods ------------------------------------------------------- // TestCase methods -------------------------------------------------------
@Override
protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration )
{
super.customizeContainerConfiguration( containerConfiguration );
containerConfiguration.setAutoWiring( true );
containerConfiguration.setClassPathScanning( PlexusConstants.SCANNING_INDEX );
}
/* /*
* @see junit.framework.TestCase#setUp() * @see junit.framework.TestCase#setUp()
*/ */

View File

@ -17,7 +17,8 @@ package org.apache.maven.repository.metadata;
import org.apache.maven.repository.metadata.GraphConflictResolutionPolicy; import org.apache.maven.repository.metadata.GraphConflictResolutionPolicy;
import org.apache.maven.repository.metadata.MetadataGraphEdge; import org.apache.maven.repository.metadata.MetadataGraphEdge;
import org.codehaus.plexus.PlexusTestCase;
import junit.framework.TestCase;
/** /**
* *
@ -26,7 +27,7 @@ import org.codehaus.plexus.PlexusTestCase;
*/ */
public class DefaultGraphConflictResolutionPolicyTest public class DefaultGraphConflictResolutionPolicyTest
extends PlexusTestCase extends TestCase
{ {
GraphConflictResolutionPolicy policy; GraphConflictResolutionPolicy policy;
MetadataGraphEdge e1; MetadataGraphEdge e1;
@ -37,7 +38,7 @@ extends PlexusTestCase
protected void setUp() throws Exception protected void setUp() throws Exception
{ {
super.setUp(); super.setUp();
policy = (GraphConflictResolutionPolicy) lookup( GraphConflictResolutionPolicy.ROLE, "default" ); policy = new DefaultGraphConflictResolutionPolicy();
e1 = new MetadataGraphEdge( "1.1", true, null, null, 2, 1 ); e1 = new MetadataGraphEdge( "1.1", true, null, null, 2, 1 );
e2 = new MetadataGraphEdge( "1.2", true, null, null, 3, 2 ); e2 = new MetadataGraphEdge( "1.2", true, null, null, 3, 2 );
e3 = new MetadataGraphEdge( "1.2", true, null, null, 2, 3 ); e3 = new MetadataGraphEdge( "1.2", true, null, null, 2, 3 );

View File

@ -28,6 +28,7 @@ import java.util.Set;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
import javax.inject.Singleton;
import org.apache.maven.artifact.InvalidRepositoryException; import org.apache.maven.artifact.InvalidRepositoryException;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
@ -53,6 +54,7 @@ import org.codehaus.plexus.util.StringUtils;
* Assists in populating an execution request for invocation of Maven. * Assists in populating an execution request for invocation of Maven.
*/ */
@Named @Named
@Singleton
public class DefaultMavenExecutionRequestPopulator public class DefaultMavenExecutionRequestPopulator
implements MavenExecutionRequestPopulator implements MavenExecutionRequestPopulator
{ {

View File

@ -23,16 +23,18 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.StringReader; import java.io.StringReader;
import org.codehaus.plexus.PlexusTestCase; import org.apache.maven.configuration.internal.DefaultBeanConfigurator;
import org.codehaus.plexus.util.xml.Xpp3Dom; import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.codehaus.plexus.util.xml.Xpp3DomBuilder; import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import junit.framework.TestCase;
/** /**
* @author Benjamin Bentmann * @author Benjamin Bentmann
*/ */
public class DefaultBeanConfiguratorTest public class DefaultBeanConfiguratorTest
extends PlexusTestCase extends TestCase
{ {
private BeanConfigurator configurator; private BeanConfigurator configurator;
@ -43,7 +45,7 @@ public class DefaultBeanConfiguratorTest
{ {
super.setUp(); super.setUp();
configurator = lookup( BeanConfigurator.class ); configurator = new DefaultBeanConfigurator();
} }
@Override @Override

View File

@ -14,6 +14,8 @@
*/ */
package org.apache.maven.lifecycle; package org.apache.maven.lifecycle;
import org.codehaus.plexus.ContainerConfiguration;
import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.PlexusTestCase;
import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.component.annotations.Requirement;
@ -29,6 +31,14 @@ public class DefaultLifecyclesTest
@Requirement @Requirement
private DefaultLifecycles defaultLifeCycles; private DefaultLifecycles defaultLifeCycles;
@Override
protected void customizeContainerConfiguration(
ContainerConfiguration configuration)
{
super.customizeContainerConfiguration(configuration);
configuration.setAutoWiring(true);
configuration.setClassPathScanning(PlexusConstants.SCANNING_INDEX);
}
protected void setUp() protected void setUp()
throws Exception throws Exception

View File

@ -21,16 +21,18 @@ package org.apache.maven.project;
import java.util.List; import java.util.List;
import javax.inject.Named;
import javax.inject.Singleton;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
import org.apache.maven.artifact.metadata.ResolutionGroup; import org.apache.maven.artifact.metadata.ResolutionGroup;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.project.artifact.MavenMetadataSource; import org.apache.maven.project.artifact.MavenMetadataSource;
import org.codehaus.plexus.component.annotations.Component;
@SuppressWarnings( "deprecation" ) @SuppressWarnings( "deprecation" )
@Component( role = ArtifactMetadataSource.class, hint = "classpath" ) @Named( "classpath" )
@Singleton
public class TestMetadataSource public class TestMetadataSource
extends MavenMetadataSource extends MavenMetadataSource
{ {
@ -48,4 +50,4 @@ public class TestMetadataSource
return rg; return rg;
} }
} }

View File

@ -44,7 +44,7 @@ public class DefaultMavenMetadataCacheTest
throws Exception throws Exception
{ {
super.setUp(); super.setUp();
repositorySystem = new TestRepositorySystem(); repositorySystem = new TestRepositorySystem( null, null );
} }
@Override @Override

View File

@ -26,9 +26,10 @@ import java.util.Set;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DefaultArtifact; import org.apache.maven.artifact.DefaultArtifact;
import org.codehaus.plexus.PlexusTestCase;
public class DefaultProjectArtifactsCacheTest extends PlexusTestCase import junit.framework.TestCase;
public class DefaultProjectArtifactsCacheTest extends TestCase
{ {
private ProjectArtifactsCache cache; private ProjectArtifactsCache cache;
@ -38,7 +39,7 @@ public class DefaultProjectArtifactsCacheTest extends PlexusTestCase
throws Exception throws Exception
{ {
super.setUp(); super.setUp();
cache = lookup( ProjectArtifactsCache.class ); cache = new DefaultProjectArtifactsCache();
} }
public void testProjectDependencyOrder() throws Exception public void testProjectDependencyOrder() throws Exception

View File

@ -1,5 +1,8 @@
package org.apache.maven.repository; package org.apache.maven.repository;
import javax.inject.Named;
import javax.inject.Singleton;
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file
@ -24,12 +27,12 @@ import org.apache.maven.artifact.handler.ArtifactHandler;
import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.codehaus.plexus.component.annotations.Component;
/** /**
* @author jdcasey * @author jdcasey
*/ */
@Component(role=ArtifactRepositoryLayout.class, hint="legacy") @Named( "legacy" )
@Singleton
public class LegacyRepositoryLayout public class LegacyRepositoryLayout
implements ArtifactRepositoryLayout implements ArtifactRepositoryLayout
{ {

View File

@ -19,7 +19,9 @@ package org.apache.maven.repository;
* under the License. * under the License.
*/ */
import org.codehaus.plexus.component.annotations.Component; import javax.inject.Named;
import javax.inject.Singleton;
import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.repository.RemoteRepository; import org.eclipse.aether.repository.RemoteRepository;
import org.eclipse.aether.spi.connector.RepositoryConnector; import org.eclipse.aether.spi.connector.RepositoryConnector;
@ -29,7 +31,8 @@ import org.eclipse.aether.transfer.NoRepositoryConnectorException;
/** /**
* @author Benjamin Bentmann * @author Benjamin Bentmann
*/ */
@Component( role = RepositoryConnectorFactory.class, hint = "test" ) @Named( "test" )
@Singleton
public class TestRepositoryConnectorFactory public class TestRepositoryConnectorFactory
implements RepositoryConnectorFactory implements RepositoryConnectorFactory
{ {

View File

@ -26,6 +26,10 @@ import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DefaultArtifact; import org.apache.maven.artifact.DefaultArtifact;
import org.apache.maven.artifact.InvalidRepositoryException; import org.apache.maven.artifact.InvalidRepositoryException;
@ -48,8 +52,6 @@ import org.apache.maven.project.artifact.ArtifactWithDependencies;
import org.apache.maven.settings.Mirror; import org.apache.maven.settings.Mirror;
import org.apache.maven.settings.Proxy; import org.apache.maven.settings.Proxy;
import org.apache.maven.settings.Server; import org.apache.maven.settings.Server;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.StringUtils;
import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.RepositorySystemSession;
@ -57,16 +59,22 @@ import org.eclipse.aether.RepositorySystemSession;
/** /**
* @author Benjamin Bentmann * @author Benjamin Bentmann
*/ */
@Component( role = RepositorySystem.class ) @Named
@Singleton
public class TestRepositorySystem public class TestRepositorySystem
implements RepositorySystem implements RepositorySystem
{ {
@Requirement private final ModelReader modelReader;
private ModelReader modelReader;
@Requirement private final ArtifactFactory artifactFactory;
private ArtifactFactory artifactFactory;
@Inject
public TestRepositorySystem( ModelReader modelReader, ArtifactFactory artifactFactory )
{
this.modelReader = modelReader;
this.artifactFactory = artifactFactory;
}
public ArtifactRepository buildArtifactRepository( Repository repository ) public ArtifactRepository buildArtifactRepository( Repository repository )
throws InvalidRepositoryException throws InvalidRepositoryException

View File

@ -20,12 +20,23 @@ package org.apache.maven.rtinfo.internal;
*/ */
import org.apache.maven.rtinfo.RuntimeInformation; import org.apache.maven.rtinfo.RuntimeInformation;
import org.codehaus.plexus.ContainerConfiguration;
import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.PlexusTestCase;
public class DefaultRuntimeInformationTest public class DefaultRuntimeInformationTest
extends PlexusTestCase extends PlexusTestCase
{ {
@Override
protected void customizeContainerConfiguration(
ContainerConfiguration configuration)
{
super.customizeContainerConfiguration(configuration);
configuration.setAutoWiring(true);
configuration.setClassPathScanning(PlexusConstants.SCANNING_INDEX);
}
public void testGetMavenVersion() public void testGetMavenVersion()
throws Exception throws Exception
{ {

View File

@ -24,12 +24,13 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import static org.junit.Assume.assumeTrue; import static org.junit.Assume.assumeTrue;
import static org.mockito.Mockito.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times; import static org.mockito.Mockito.times;
import java.io.File; import java.io.File;
import java.util.Collections;
import org.apache.commons.cli.ParseException; import org.apache.commons.cli.ParseException;
import org.apache.maven.Maven; import org.apache.maven.Maven;
@ -37,12 +38,17 @@ import org.apache.maven.eventspy.internal.EventSpyDispatcher;
import org.apache.maven.shared.utils.logging.MessageUtils; import org.apache.maven.shared.utils.logging.MessageUtils;
import org.apache.maven.toolchain.building.ToolchainsBuildingRequest; import org.apache.maven.toolchain.building.ToolchainsBuildingRequest;
import org.apache.maven.toolchain.building.ToolchainsBuildingResult; import org.apache.maven.toolchain.building.ToolchainsBuildingResult;
import org.codehaus.plexus.DefaultPlexusContainer;
import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.PlexusContainer;
import org.eclipse.sisu.plexus.PlexusBeanModule;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.mockito.InOrder; import org.mockito.InOrder;
import com.google.inject.Binder;
import com.google.inject.Module;
public class MavenCliTest public class MavenCliTest
{ {
private MavenCli cli; private MavenCli cli;
@ -314,8 +320,17 @@ public class MavenCliTest
@Override @Override
protected void customizeContainer(PlexusContainer container) { protected void customizeContainer(PlexusContainer container) {
super.customizeContainer(container); super.customizeContainer(container);
container.addComponent(eventSpyDispatcherMock, "org.apache.maven.eventspy.internal.EventSpyDispatcher");
container.addComponent(mock(Maven.class), "org.apache.maven.Maven"); 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 );
}
}
);
} }
}; };