Skip to content

Commit

Permalink
Migrate all PhaseTests to PlexusJUnit4TestCase
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/maven/release/trunk@1744879 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
rfscholte committed May 21, 2016
1 parent 695c83c commit fc226cf
Show file tree
Hide file tree
Showing 15 changed files with 634 additions and 379 deletions.
Expand Up @@ -64,7 +64,7 @@ protected List<MavenProject> getReactorProjects( String projectPath )

reactorProjects.add( mainProject );

for( Iterator modules = mainProject.getModel().getModules().iterator(); modules.hasNext(); )
for ( Iterator modules = mainProject.getModel().getModules().iterator(); modules.hasNext(); )
{
String module = modules.next().toString();

Expand Down
Expand Up @@ -19,6 +19,10 @@
* under the License.
*/

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Matchers.isA;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
Expand All @@ -41,6 +45,7 @@
import org.apache.maven.shared.release.env.DefaultReleaseEnvironment;
import org.apache.maven.shared.release.scm.DefaultScmRepositoryConfigurator;
import org.apache.maven.shared.release.scm.ReleaseScmCommandException;
import org.junit.Test;
import org.mockito.internal.util.reflection.Whitebox;

/**
Expand All @@ -51,6 +56,7 @@
public abstract class AbstractEditModeRewritingReleasePhaseTestCase
extends AbstractRewritingReleasePhaseTestCase
{
@Test
public void testRewriteBasicPomWithEditMode()
throws Exception
{
Expand All @@ -64,6 +70,7 @@ public void testRewriteBasicPomWithEditMode()
assertTrue( comparePomFiles( reactorProjects ) );
}

@Test
public void testRewriteBasicPomWithEditModeFailure()
throws Exception
{
Expand Down Expand Up @@ -92,6 +99,7 @@ public void testRewriteBasicPomWithEditModeFailure()
}
}

@Test
public void testRewriteBasicPomWithEditModeException()
throws Exception
{
Expand All @@ -102,7 +110,8 @@ public void testRewriteBasicPomWithEditModeException()
mapNextVersion( config, "groupId:artifactId" );

ScmProvider scmProviderMock = mock( ScmProvider.class );
when( scmProviderMock.edit( isA( ScmRepository.class ), isA( ScmFileSet.class) ) ).thenThrow( new ScmException( "..." ) );
when( scmProviderMock.edit( isA( ScmRepository.class ),
isA( ScmFileSet.class ) ) ).thenThrow( new ScmException( "..." ) );

ScmManagerStub scmManager = new ScmManagerStub();
DefaultScmRepositoryConfigurator configurator =
Expand All @@ -126,6 +135,7 @@ public void testRewriteBasicPomWithEditModeException()
verifyNoMoreInteractions( scmProviderMock );
}

@Test
public void testRewritePomPluginDependencies()
throws Exception
{
Expand All @@ -137,6 +147,7 @@ public void testRewritePomPluginDependencies()
assertTrue( comparePomFiles( reactorProjects ) );
}

@Test
public void testRewritePomUnmappedPluginDependencies()
throws Exception
{
Expand All @@ -155,6 +166,7 @@ public void testRewritePomUnmappedPluginDependencies()
}
}

@Test
public void testRewritePomProfile()
throws Exception
{
Expand All @@ -166,6 +178,7 @@ public void testRewritePomProfile()
assertTrue( comparePomFiles( reactorProjects ) );
}

@Test
public void testRewritePomUnmappedProfile()
throws Exception
{
Expand Down
Expand Up @@ -19,6 +19,8 @@
* under the License.
*/

import static org.junit.Assert.fail;

import java.io.File;
import java.io.IOException;
import java.io.Reader;
Expand Down Expand Up @@ -54,8 +56,8 @@
import org.apache.maven.project.MavenProjectBuilder;
import org.apache.maven.project.ProjectBuildingException;
import org.apache.maven.project.ProjectSorter;
import org.apache.maven.shared.release.PlexusJUnit4TestCase;
import org.apache.maven.shared.release.util.ReleaseUtil;
import org.codehaus.plexus.PlexusTestCase;
import org.codehaus.plexus.context.ContextException;
import org.codehaus.plexus.context.DefaultContext;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
Expand All @@ -77,7 +79,7 @@
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
*/
public abstract class AbstractReleaseTestCase
extends PlexusTestCase
extends PlexusJUnit4TestCase
{
protected MavenProjectBuilder projectBuilder;

Expand All @@ -94,7 +96,7 @@ public Object get( Object key )
}
};

protected void setUp()
public void setUp()
throws Exception
{
super.setUp();
Expand All @@ -106,7 +108,7 @@ protected void setUp()
localRepository = new DefaultArtifactRepository( "local", "file://" + localRepoPath, layout );
}

protected void tearDown()
public void tearDown()
throws Exception
{
// unhook circular references to the container that would avoid memory being cleaned up
Expand All @@ -124,10 +126,8 @@ private Map<String,Artifact> createManagedVersionMap( String projectId, Dependen
if ( dependencyManagement != null && dependencyManagement.getDependencies() != null )
{
map = new HashMap<String,Artifact>();
for ( Iterator i = dependencyManagement.getDependencies().iterator(); i.hasNext(); )
for ( Dependency d : dependencyManagement.getDependencies() )
{
Dependency d = (Dependency) i.next();

try
{
VersionRange versionRange = VersionRange.createFromVersionSpec( d.getVersion() );
Expand Down Expand Up @@ -211,16 +211,14 @@ protected List<MavenProject> createReactorProjects( String path, String targetPa
ArtifactMetadataSource artifactMetadataSource = (ArtifactMetadataSource) lookup( ArtifactMetadataSource.ROLE );

// pass back over and resolve dependencies - can't be done earlier as the order may not be correct
for ( Iterator i = reactorProjects.iterator(); i.hasNext(); )
for ( MavenProject project : reactorProjects )
{
MavenProject project = (MavenProject) i.next();

project.setRemoteArtifactRepositories( repos );
project.setPluginArtifactRepositories( repos );

Artifact projectArtifact = project.getArtifact();

Map managedVersions = createManagedVersionMap(
Map<String, Artifact> managedVersions = createManagedVersionMap(
ArtifactUtils.versionlessKey( projectArtifact.getGroupId(), projectArtifact.getArtifactId() ),
project.getDependencyManagement(), artifactFactory );

Expand Down

0 comments on commit fc226cf

Please sign in to comment.