mirror of https://github.com/apache/maven.git
Rewrite assertTrue to assertThat to get more meaningful messages
This commit is contained in:
parent
877fcc9cd5
commit
3f3d775ede
|
@ -136,6 +136,11 @@ under the License.
|
|||
<artifactId>mockito-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
<artifactId>hamcrest-library</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -15,6 +15,9 @@ package org.apache.maven;
|
|||
* the License.
|
||||
*/
|
||||
|
||||
import static org.hamcrest.Matchers.endsWith;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
@ -109,6 +112,6 @@ public class ProjectDependenciesResolverTest
|
|||
@SuppressWarnings( "deprecation" )
|
||||
List<Artifact> artifacts = project.getCompileArtifacts();
|
||||
assertEquals( 1, artifacts.size() );
|
||||
assertTrue( artifacts.get( 0 ).getFile().getName().endsWith( "tools.jar" ) );
|
||||
assertThat( artifacts.get( 0 ).getFile().getName(), endsWith( "tools.jar" ) );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,20 +18,23 @@ package org.apache.maven.execution;
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import static org.hamcrest.Matchers.empty;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author Benjamin Bentmann
|
||||
*/
|
||||
public class DefaultMavenExecutionTest
|
||||
extends TestCase
|
||||
{
|
||||
|
||||
@Test
|
||||
public void testCopyDefault()
|
||||
{
|
||||
MavenExecutionRequest original = new DefaultMavenExecutionRequest();
|
||||
|
@ -40,13 +43,14 @@ public class DefaultMavenExecutionTest
|
|||
assertNotSame( copy, original );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResultWithNullTopologicallySortedProjectsIsEmptyList()
|
||||
{
|
||||
MavenExecutionResult result = new DefaultMavenExecutionResult();
|
||||
result.setTopologicallySortedProjects( null );
|
||||
List<MavenProject> projects = result.getTopologicallySortedProjects();
|
||||
assertNotNull( projects );
|
||||
assertTrue( projects.isEmpty() );
|
||||
assertThat( projects, is( empty() ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,24 +15,29 @@ package org.apache.maven.lifecycle.internal;
|
|||
* the License.
|
||||
*/
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import org.apache.maven.execution.MavenSession;
|
||||
import org.apache.maven.lifecycle.internal.stub.ProjectDependencyGraphStub;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author Kristian Rosenvold
|
||||
*/
|
||||
public class ProjectBuildListTest
|
||||
extends TestCase
|
||||
{
|
||||
|
||||
@Test
|
||||
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 );
|
||||
assertThat( "This test assumes there are at least 6 elements in projectBuilds",
|
||||
projectBuildList.size(), is( greaterThanOrEqualTo( 6 ) ) );
|
||||
|
||||
final ProjectBuildList byTaskSegment = projectBuildList.getByTaskSegment( taskSegment );
|
||||
assertEquals( projectBuildList.size(),
|
||||
|
|
|
@ -86,9 +86,7 @@ public abstract class AbstractMavenProjectTestCase
|
|||
@Override
|
||||
protected String getCustomConfigurationName()
|
||||
{
|
||||
String name = AbstractMavenProjectTestCase.class.getName().replace( '.', '/' ) + ".xml";
|
||||
System.out.println( name );
|
||||
return name;
|
||||
return AbstractMavenProjectTestCase.class.getName().replace( '.', '/' ) + ".xml";
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
|
|
@ -18,16 +18,18 @@ package org.apache.maven.project;
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||
import org.codehaus.plexus.util.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class DefaultMavenProjectBuilderTest
|
||||
extends AbstractMavenProjectTestCase
|
||||
{
|
||||
|
@ -287,7 +289,7 @@ public class DefaultMavenProjectBuilderTest
|
|||
catch ( final ProjectBuildingException e )
|
||||
{
|
||||
assertNotNull( e.getMessage() );
|
||||
assertTrue( e.getMessage().contains( "Version must be a constant" ) );
|
||||
assertThat( e.getMessage(), containsString( "Version must be a constant" ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -310,7 +312,7 @@ public class DefaultMavenProjectBuilderTest
|
|||
catch ( final ProjectBuildingException e )
|
||||
{
|
||||
assertNotNull( e.getMessage() );
|
||||
assertTrue( e.getMessage().contains( "Version must be a constant" ) );
|
||||
assertThat( e.getMessage(), containsString( "Version must be a constant" ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -352,7 +354,7 @@ public class DefaultMavenProjectBuilderTest
|
|||
catch ( final ProjectBuildingException e )
|
||||
{
|
||||
assertNotNull( e.getMessage() );
|
||||
assertTrue( e.getMessage().contains( "Version must be a constant" ) );
|
||||
assertThat( e.getMessage(), containsString( "Version must be a constant" ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -375,7 +377,7 @@ public class DefaultMavenProjectBuilderTest
|
|||
catch ( final ProjectBuildingException e )
|
||||
{
|
||||
assertNotNull( e.getMessage() );
|
||||
assertTrue( e.getMessage().contains( "Version must be a constant" ) );
|
||||
assertThat( e.getMessage(), containsString( "Version must be a constant" ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,10 @@ package org.apache.maven.project;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import static org.hamcrest.Matchers.empty;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
@ -76,9 +80,9 @@ public class ExtensionDescriptorBuilderTest
|
|||
|
||||
assertNotNull( ed );
|
||||
assertNotNull( ed.getExportedPackages() );
|
||||
assertTrue( ed.getExportedPackages().isEmpty() );
|
||||
assertThat( ed.getExportedPackages(), is( empty() ) );
|
||||
assertNotNull( ed.getExportedArtifacts() );
|
||||
assertTrue( ed.getExportedArtifacts().isEmpty() );
|
||||
assertThat( ed.getExportedArtifacts(), is( empty() ) );
|
||||
}
|
||||
|
||||
public void testCompleteDescriptor()
|
||||
|
|
|
@ -19,6 +19,11 @@ package org.apache.maven.project;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import static org.hamcrest.Matchers.endsWith;
|
||||
import static org.hamcrest.Matchers.lessThan;
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
@ -726,8 +731,8 @@ public class PomConstructionTest
|
|||
assertEquals( "parent", pom.getValue( "properties/parentArtifactId" ) );
|
||||
assertEquals( "1.0", pom.getValue( "properties/parentVersion" ) );
|
||||
|
||||
assertTrue( pom.getValue( "properties/projectBuildOut" ).toString().endsWith( "bin" ) );
|
||||
assertTrue( pom.getValue( "properties/projectSiteOut" ).toString().endsWith( "doc" ) );
|
||||
assertThat( pom.getValue( "properties/projectBuildOut" ).toString(), endsWith( "bin" ) );
|
||||
assertThat( pom.getValue( "properties/projectSiteOut" ).toString(), endsWith( "doc" ) );
|
||||
}
|
||||
|
||||
public void testInterpolationWithBasedirAlignedDirectories()
|
||||
|
@ -936,13 +941,13 @@ public class PomConstructionTest
|
|||
PomTestWrapper pom = buildPom( "merged-filter-order/sub" );
|
||||
|
||||
assertEquals( 7, ( (List<?>) pom.getValue( "build/filters" ) ).size() );
|
||||
assertTrue( pom.getValue( "build/filters[1]" ).toString().endsWith( "child-a.properties" ) );
|
||||
assertTrue( pom.getValue( "build/filters[2]" ).toString().endsWith( "child-c.properties" ) );
|
||||
assertTrue( pom.getValue( "build/filters[3]" ).toString().endsWith( "child-b.properties" ) );
|
||||
assertTrue( pom.getValue( "build/filters[4]" ).toString().endsWith( "child-d.properties" ) );
|
||||
assertTrue( pom.getValue( "build/filters[5]" ).toString().endsWith( "parent-c.properties" ) );
|
||||
assertTrue( pom.getValue( "build/filters[6]" ).toString().endsWith( "parent-b.properties" ) );
|
||||
assertTrue( pom.getValue( "build/filters[7]" ).toString().endsWith( "parent-d.properties" ) );
|
||||
assertThat( pom.getValue( "build/filters[1]" ).toString(), endsWith( "child-a.properties" ) );
|
||||
assertThat( pom.getValue( "build/filters[2]" ).toString(), endsWith( "child-c.properties" ) );
|
||||
assertThat( pom.getValue( "build/filters[3]" ).toString(), endsWith( "child-b.properties" ) );
|
||||
assertThat( pom.getValue( "build/filters[4]" ).toString(), endsWith( "child-d.properties" ) );
|
||||
assertThat( pom.getValue( "build/filters[5]" ).toString(), endsWith( "parent-c.properties" ) );
|
||||
assertThat( pom.getValue( "build/filters[6]" ).toString(), endsWith( "parent-b.properties" ) );
|
||||
assertThat( pom.getValue( "build/filters[7]" ).toString(), endsWith( "parent-d.properties" ) );
|
||||
}
|
||||
|
||||
/** MNG-4027*/
|
||||
|
@ -1097,7 +1102,7 @@ public class PomConstructionTest
|
|||
PomTestWrapper pom = buildPom( "baseuri-interpolation/pom.xml" );
|
||||
String prop1 = pom.getValue( "properties/prop1" ).toString();
|
||||
assertEquals( pom.getBasedir().toPath().toUri().toASCIIString(), prop1 );
|
||||
assertTrue( prop1.startsWith( "file:///" ) );
|
||||
assertThat( prop1, startsWith( "file:///" ) );
|
||||
}
|
||||
|
||||
/* MNG-3811*/
|
||||
|
@ -1408,8 +1413,8 @@ public class PomConstructionTest
|
|||
throws Exception
|
||||
{
|
||||
PomTestWrapper pom = buildPom( "boolean-interpolation" );
|
||||
assertTrue ((Boolean) pom.getValue( "repositories[1]/releases/enabled" ) );
|
||||
assertTrue((Boolean) pom.getValue( "build/resources[1]/filtering" ) );
|
||||
assertEquals(true, pom.getValue( "repositories[1]/releases/enabled" ) );
|
||||
assertEquals(true, pom.getValue( "build/resources[1]/filtering" ) );
|
||||
}
|
||||
|
||||
|
||||
|
@ -1734,16 +1739,16 @@ public class PomConstructionTest
|
|||
Plugin plugin = plugins.get( i );
|
||||
if ( "maven-resources-plugin".equals( plugin.getArtifactId() ) )
|
||||
{
|
||||
assertTrue( resourcesPlugin < 0 );
|
||||
assertThat( resourcesPlugin, lessThan( 0 ) );
|
||||
resourcesPlugin = i;
|
||||
}
|
||||
else if ( "maven-it-plugin-log-file".equals( plugin.getArtifactId() ) )
|
||||
{
|
||||
assertTrue( customPlugin < 0 );
|
||||
assertThat( customPlugin, lessThan( 0 ) );
|
||||
customPlugin = i;
|
||||
}
|
||||
}
|
||||
assertTrue( plugins.toString(), customPlugin == resourcesPlugin - 1 );
|
||||
assertEquals( plugins.toString(), customPlugin, resourcesPlugin - 1 );
|
||||
}
|
||||
|
||||
/** MNG-4415 */
|
||||
|
|
|
@ -19,6 +19,12 @@ package org.apache.maven.project;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.empty;
|
||||
import static org.hamcrest.Matchers.hasKey;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
@ -155,7 +161,7 @@ public class ProjectBuilderTest
|
|||
FileUtils.fileWrite( parent, "UTF-8", parentContent );
|
||||
// re-build pom with modified parent
|
||||
ProjectBuildingResult result = projectBuilder.build( child, configuration );
|
||||
assertTrue( result.getProject().getProperties().containsKey( "addedProperty" ) );
|
||||
assertThat( result.getProject().getProperties(), hasKey( (Object) "addedProperty" ) );
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -229,7 +235,7 @@ public class ProjectBuilderTest
|
|||
}
|
||||
catch ( InvalidArtifactRTException iarte )
|
||||
{
|
||||
assertTrue( iarte.getMessage().contains( "The groupId cannot be empty." ) );
|
||||
assertThat( iarte.getMessage(), containsString( "The groupId cannot be empty." ) );
|
||||
}
|
||||
|
||||
// multi projects build entry point
|
||||
|
@ -301,7 +307,7 @@ public class ProjectBuilderTest
|
|||
{
|
||||
for ( ProjectBuildingResult result : results )
|
||||
{
|
||||
assertTrue( result.getProblems().isEmpty() );
|
||||
assertThat( result.getProblems(), is( empty() ) );
|
||||
assertNotNull( result.getProject() );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,9 @@ package org.apache.maven.project;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
@ -34,12 +37,6 @@ import org.eclipse.aether.RepositorySystem;
|
|||
import org.eclipse.aether.impl.RemoteRepositoryManager;
|
||||
import org.eclipse.aether.repository.RemoteRepository;
|
||||
|
||||
import static junit.framework.TestCase.assertEquals;
|
||||
import static junit.framework.TestCase.assertNotNull;
|
||||
import static junit.framework.TestCase.assertTrue;
|
||||
import static junit.framework.TestCase.fail;
|
||||
import static org.codehaus.plexus.PlexusTestCase.getBasedir;
|
||||
|
||||
/**
|
||||
* Test cases for the project {@code ModelResolver} implementation.
|
||||
*
|
||||
|
@ -72,7 +69,7 @@ public class ProjectModelResolverTest extends AbstractMavenProjectTestCase
|
|||
catch ( final UnresolvableModelException e )
|
||||
{
|
||||
assertNotNull( e.getMessage() );
|
||||
assertTrue( e.getMessage().startsWith( "Could not find artifact org.apache:apache:pom:0 in central" ) );
|
||||
assertThat( e.getMessage(), startsWith( "Could not find artifact org.apache:apache:pom:0 in central" ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -153,7 +150,7 @@ public class ProjectModelResolverTest extends AbstractMavenProjectTestCase
|
|||
catch ( final UnresolvableModelException e )
|
||||
{
|
||||
assertNotNull( e.getMessage() );
|
||||
assertTrue( e.getMessage().startsWith( "Could not find artifact org.apache:apache:pom:0 in central" ) );
|
||||
assertThat( e.getMessage(), startsWith( "Could not find artifact org.apache:apache:pom:0 in central" ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,12 +19,14 @@ package org.apache.maven.project;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import static org.hamcrest.Matchers.hasItem;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.maven.model.Build;
|
||||
import org.apache.maven.model.Dependency;
|
||||
import org.apache.maven.model.Extension;
|
||||
|
@ -32,7 +34,9 @@ import org.apache.maven.model.Model;
|
|||
import org.apache.maven.model.Parent;
|
||||
import org.apache.maven.model.Plugin;
|
||||
import org.apache.maven.model.PluginManagement;
|
||||
import org.codehaus.plexus.util.dag.CycleDetectedException;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
/**
|
||||
* Test sorting projects by dependencies.
|
||||
|
@ -40,8 +44,9 @@ import org.codehaus.plexus.util.dag.CycleDetectedException;
|
|||
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||
*/
|
||||
public class ProjectSorterTest
|
||||
extends TestCase
|
||||
{
|
||||
@Rule
|
||||
public ExpectedException expectedException = ExpectedException.none();
|
||||
|
||||
private Parent createParent( MavenProject project )
|
||||
{
|
||||
|
@ -104,8 +109,9 @@ public class ProjectSorterTest
|
|||
return new MavenProject( model );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShouldNotFailWhenPluginDepReferencesCurrentProject()
|
||||
throws CycleDetectedException, DuplicateProjectException
|
||||
throws Exception
|
||||
{
|
||||
MavenProject project = createProject( "group", "artifact", "1.0" );
|
||||
|
||||
|
@ -122,8 +128,9 @@ public class ProjectSorterTest
|
|||
new ProjectSorter( Collections.singletonList( project ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShouldNotFailWhenManagedPluginDepReferencesCurrentProject()
|
||||
throws CycleDetectedException, DuplicateProjectException
|
||||
throws Exception
|
||||
{
|
||||
MavenProject project = createProject( "group", "artifact", "1.0" );
|
||||
|
||||
|
@ -144,8 +151,9 @@ public class ProjectSorterTest
|
|||
new ProjectSorter( Collections.singletonList( project ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShouldNotFailWhenProjectReferencesNonExistentProject()
|
||||
throws CycleDetectedException, DuplicateProjectException
|
||||
throws Exception
|
||||
{
|
||||
MavenProject project = createProject( "group", "artifact", "1.0" );
|
||||
|
||||
|
@ -158,8 +166,9 @@ public class ProjectSorterTest
|
|||
new ProjectSorter( Collections.singletonList( project ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMatchingArtifactIdsDifferentGroupIds()
|
||||
throws CycleDetectedException, DuplicateProjectException
|
||||
throws Exception
|
||||
{
|
||||
List<MavenProject> projects = new ArrayList<>();
|
||||
MavenProject project1 = createProject( "groupId1", "artifactId", "1.0" );
|
||||
|
@ -174,8 +183,9 @@ public class ProjectSorterTest
|
|||
assertEquals( project1, projects.get( 1 ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMatchingGroupIdsDifferentArtifactIds()
|
||||
throws CycleDetectedException, DuplicateProjectException
|
||||
throws Exception
|
||||
{
|
||||
List<MavenProject> projects = new ArrayList<>();
|
||||
MavenProject project1 = createProject( "groupId", "artifactId1", "1.0" );
|
||||
|
@ -190,29 +200,25 @@ public class ProjectSorterTest
|
|||
assertEquals( project1, projects.get( 1 ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMatchingIdsAndVersions()
|
||||
throws CycleDetectedException
|
||||
throws Exception
|
||||
{
|
||||
List<MavenProject> projects = new ArrayList<>();
|
||||
MavenProject project1 = createProject( "groupId", "artifactId", "1.0" );
|
||||
projects.add( project1 );
|
||||
MavenProject project2 = createProject( "groupId", "artifactId", "1.0" );
|
||||
projects.add( project2 );
|
||||
|
||||
expectedException.expect( DuplicateProjectException.class );
|
||||
expectedException.reportMissingExceptionWithMessage( "Duplicate projects should fail" );
|
||||
|
||||
try
|
||||
{
|
||||
projects = new ProjectSorter( projects ).getSortedProjects();
|
||||
fail( "Duplicate projects should fail" );
|
||||
}
|
||||
catch ( DuplicateProjectException e )
|
||||
{
|
||||
// expected
|
||||
assertTrue( true );
|
||||
}
|
||||
new ProjectSorter( projects ).getSortedProjects();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMatchingIdsAndDifferentVersions()
|
||||
throws CycleDetectedException, DuplicateProjectException
|
||||
throws Exception
|
||||
{
|
||||
List<MavenProject> projects = new ArrayList<>();
|
||||
MavenProject project1 = createProject( "groupId", "artifactId", "1.0" );
|
||||
|
@ -225,6 +231,7 @@ public class ProjectSorterTest
|
|||
assertEquals( project2, projects.get( 1 ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPluginDependenciesInfluenceSorting()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -261,13 +268,14 @@ public class ProjectSorterTest
|
|||
assertEquals( parentProject, projects.get( 0 ) );
|
||||
|
||||
// the order of these two is non-deterministic, based on when they're added to the reactor.
|
||||
assertTrue( projects.contains( pluginProject ) );
|
||||
assertTrue( projects.contains( pluginLevelDepProject ) );
|
||||
assertThat( projects, hasItem( pluginProject ) );
|
||||
assertThat( projects, hasItem( pluginLevelDepProject ) );
|
||||
|
||||
// the declaring project MUST be listed after the plugin and its plugin-level dep, though.
|
||||
assertEquals( declaringProject, projects.get( 3 ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPluginDependenciesInfluenceSorting_DeclarationInParent()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -296,15 +304,14 @@ public class ProjectSorterTest
|
|||
|
||||
projects = new ProjectSorter( projects ).getSortedProjects();
|
||||
|
||||
System.out.println( projects );
|
||||
|
||||
assertEquals( parentProject, projects.get( 0 ) );
|
||||
|
||||
// the order of these two is non-deterministic, based on when they're added to the reactor.
|
||||
assertTrue( projects.contains( pluginProject ) );
|
||||
assertTrue( projects.contains( pluginLevelDepProject ) );
|
||||
assertThat( projects, hasItem( pluginProject ) );
|
||||
assertThat( projects, hasItem( pluginLevelDepProject ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPluginVersionsAreConsidered()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -320,10 +327,11 @@ public class ProjectSorterTest
|
|||
|
||||
projects = new ProjectSorter( projects ).getSortedProjects();
|
||||
|
||||
assertTrue( projects.contains( pluginProjectA ) );
|
||||
assertTrue( projects.contains( pluginProjectB ) );
|
||||
assertThat( projects, hasItem( pluginProjectA ) );
|
||||
assertThat( projects, hasItem( pluginProjectB ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDependencyPrecedesProjectThatUsesSpecificDependencyVersion()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -342,6 +350,7 @@ public class ProjectSorterTest
|
|||
assertEquals( usingProject, projects.get( 1 ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDependencyPrecedesProjectThatUsesUnresolvedDependencyVersion()
|
||||
throws Exception
|
||||
{
|
||||
|
|
|
@ -19,6 +19,14 @@ package org.apache.maven.toolchain;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.apache.maven.toolchain.java.DefaultJavaToolChain;
|
||||
import org.apache.maven.toolchain.model.PersistedToolchains;
|
||||
import org.apache.maven.toolchain.model.ToolchainModel;
|
||||
|
@ -29,14 +37,6 @@ import org.junit.Test;
|
|||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
public class DefaultToolchainTest
|
||||
{
|
||||
@Mock
|
||||
|
@ -141,10 +141,10 @@ public class DefaultToolchainTest
|
|||
DefaultToolchain tc1 = new DefaultJavaToolChain( jdks.getToolchains().get( 0 ), null );
|
||||
DefaultToolchain tc2 = new DefaultJavaToolChain( jdksExtra.getToolchains().get( 0 ), null );
|
||||
|
||||
assertTrue( tc1.equals( tc1 ) );
|
||||
assertFalse( tc1.equals( tc2 ) );
|
||||
assertFalse( tc2.equals( tc1 ) );
|
||||
assertTrue( tc2.equals( tc2 ) );
|
||||
assertEquals( tc1, tc1 );
|
||||
assertNotEquals( tc1, tc2 );
|
||||
assertNotEquals( tc2, tc1 );
|
||||
assertEquals( tc2, tc2 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
12
pom.xml
12
pom.xml
|
@ -424,6 +424,18 @@ under the License.
|
|||
<artifactId>powermock-reflect</artifactId>
|
||||
<version>${powermockVersion}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
<artifactId>hamcrest-core</artifactId>
|
||||
<version>1.3</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
<artifactId>hamcrest-library</artifactId>
|
||||
<version>1.3</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<!--bootstrap-start-comment-->
|
||||
</dependencyManagement>
|
||||
|
|
Loading…
Reference in New Issue