o adding some test code to share with shane

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@727460 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason van Zyl 2008-12-17 18:32:01 +00:00
parent 699640f2ec
commit 306d70f8f5
3 changed files with 37 additions and 3 deletions

View File

@ -74,6 +74,8 @@ public final class PomClassicDomainModel
private File projectDirectory;
private List<ModelProperty> modelProperties;
private int lineageCount;
/**
* Constructor
@ -258,7 +260,6 @@ public final class PomClassicDomainModel
}
catch ( XmlPullParserException e )
{
e.printStackTrace();
throw new IOException( e.getMessage() );
}
}
@ -316,6 +317,16 @@ public final class PomClassicDomainModel
this.eventHistory = eventHistory;
}
public int getLineageCount()
{
return lineageCount;
}
public void setLineageCount( int lineageCount )
{
this.lineageCount = lineageCount;
}
/**
* Returns true if this.asString.equals(o.asString()), otherwise false.
*

View File

@ -142,6 +142,7 @@ public final class DefaultProjectBuilder
PomClassicDomainModel dm = (PomClassicDomainModel) mavenParents.get( 0 );
parentFile = dm.getFile();
domainModel.setParentFile( parentFile );
domainModel.setLineageCount( mavenParents.size() );
}
domainModels.addAll( mavenParents );
@ -210,10 +211,12 @@ public final class DefaultProjectBuilder
try
{
File f = new File( projectDirectory, parent.getRelativePath() ).getCanonicalFile();
if ( f.isDirectory() )
{
f = new File( f, "pom.xml" );
}
return f.exists();
}
catch ( IOException e )

View File

@ -50,12 +50,14 @@ public class PomConstructionTest
artifacts.put( "nexus-test-harness-launcher" , nexusLauncher );
artifacts.put( "nexus-test-harness", nexusAggregator );
PomArtifactResolver resolver = new FileBasedPomArtifactResolver( artifacts );
PomArtifactResolver resolver = new FileBasedPomArtifactResolver( new File( BASE_POM_DIR, "nexus" ) );
// make a version that doesn't require a null mixin set. for most pom construction tests we're
// not going to use mixins.
PomClassicDomainModel model = projectBuilder.buildModel( nexusLauncher, null, resolver );
assertEquals( 3, model.getLineageCount() );
// This will get extremely tedious unless we can shorten these into small expressions to
// retrieve the target values for testing.
@ -68,7 +70,7 @@ public class PomConstructionTest
List executions = plugin.getExecutions();
//assertEquals( 7, executions.size() );
assertEquals( 7, executions.size() );
}
// Need to get this to walk around a directory and automatically build up the artifact set. If we
@ -78,6 +80,24 @@ public class PomConstructionTest
{
private Map<String,File> artifacts = new HashMap<String,File>();
private File basedir;
public FileBasedPomArtifactResolver( File basedir )
{
this.basedir = basedir;
for ( File file : basedir.listFiles() )
{
String fileName = file.getName();
if ( file.getName().endsWith( ".pom" ) )
{
int i = fileName.indexOf( ".pom" );
String id = fileName.substring( 0, i - 1 );
artifacts.put( id, file );
}
}
}
public FileBasedPomArtifactResolver( Map<String, File> artifacts )
{
this.artifacts = artifacts;