Add junit in all converted pom.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@433615 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Emmanuel Venisse 2006-08-22 12:43:00 +00:00
parent 7c43aa27d7
commit 5ebedbf64a
3 changed files with 30 additions and 3 deletions

View File

@ -492,6 +492,8 @@ public class PomV3ToV4Translator
if ( notEmpty( v3Deps ) )
{
boolean isJunitPresent = false;
for ( Iterator it = v3Deps.iterator(); it.hasNext(); )
{
org.apache.maven.model.v3_0_0.Dependency v3Dep = (org.apache.maven.model.v3_0_0.Dependency) it.next();
@ -523,6 +525,11 @@ public class PomV3ToV4Translator
}
}
if ( "junit".equals( groupId ) && "junit".equals( artifactId ) )
{
isJunitPresent = true;
}
String type = v3Dep.getType();
if ( "plugin".equals( type ) )
{
@ -582,6 +589,16 @@ public class PomV3ToV4Translator
deps.add( dep );
}
}
if ( !isJunitPresent )
{
Dependency junitDep = new Dependency();
junitDep.setGroupId( "junit" );
junitDep.setArtifactId( "junit" );
junitDep.setVersion( "3.8.2" );
junitDep.setScope( "test" );
deps.add( junitDep );
}
}
return deps;

View File

@ -128,7 +128,12 @@ public class PomV3ToV4TranslatorTest
Assert.assertEquals( "testArtifact", plugin.getArtifactId() );
Assert.assertEquals( "1.0", plugin.getVersion() );
Assert.assertEquals( "check no dependencies", 0, result.getDependencies().size() );
Assert.assertEquals( "check one dependency", 1, result.getDependencies().size() );
Dependency dep = (Dependency) result.getDependencies().get( 0 );
Assert.assertEquals( "junit", dep.getGroupId() );
Assert.assertEquals( "junit", dep.getArtifactId() );
Assert.assertEquals( "3.8.2", dep.getVersion() );
Assert.assertEquals( "test", dep.getScope() );
}
public void testShouldConvertDependencyWithTypePluginAndGroupMavenToBuildPluginEntryWithOAMPluginsGroup()
@ -149,7 +154,12 @@ public class PomV3ToV4TranslatorTest
Assert.assertEquals( "testArtifact", plugin.getArtifactId() );
Assert.assertEquals( "1.0", plugin.getVersion() );
Assert.assertEquals( "check no dependencies", 0, result.getDependencies().size() );
Assert.assertEquals( "check one dependencies", 1, result.getDependencies().size() );
Dependency dep = (Dependency) result.getDependencies().get( 0 );
Assert.assertEquals( "junit", dep.getGroupId() );
Assert.assertEquals( "junit", dep.getArtifactId() );
Assert.assertEquals( "3.8.2", dep.getVersion() );
Assert.assertEquals( "test", dep.getScope() );
}
}

View File

@ -53,7 +53,7 @@ public class V3PomRewriterTest
rewriter.rewrite( new StringReader( pom ), to, false, null, null, null, null );
Xpp3Dom dom = Xpp3DomBuilder.build( new StringReader( to.toString() ) );
String version = dom.getChild( "dependencies" ).getChild( "dependency" ).getChild( "version" ).getValue();
String version = dom.getChild( "dependencies" ).getChild( 0 ).getChild( "version" ).getValue();
assertEquals( "check new version expression", "${project.version}", version );
}