o Switched tests over to use new interface

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@780119 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2009-05-29 21:44:35 +00:00
parent ae675f8157
commit 85205e0b57
5 changed files with 18 additions and 40 deletions

View File

@ -6,6 +6,7 @@ import java.util.Properties;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.model.Profile;
@Deprecated
public interface ProjectBuilderConfiguration
extends ProjectBuildingRequest
{
@ -29,24 +30,6 @@ public interface ProjectBuilderConfiguration
boolean isProcessPlugins();
/**
* Controls the level of validation to perform on processed models. By default, models are validated in strict mode.
*
* @param lenientValidation A flag whether validation should be lenient instead of strict. For building of projects,
* strict validation should be used to ensure proper building. For the mere retrievel of dependencies
* during artifact resolution, lenient validation should be used to account for models of poor quality.
* @return This configuration, never {@code null}.
*/
ProjectBuilderConfiguration setLenientValidation( boolean lenientValidation );
/**
* Gets the level of validation to perform on processed models.
*
* @return {@code true} if lenient validation is enabled and only the dependency information is to be validated,
* {@code false} if strict validation is enabled and the entire model is validated.
*/
boolean istLenientValidation();
// Profiles
/**

View File

@ -35,21 +35,21 @@ import org.codehaus.plexus.PlexusTestCase;
public abstract class AbstractMavenProjectTestCase
extends PlexusTestCase
{
protected MavenProjectBuilder projectBuilder;
protected ProjectBuilder projectBuilder;
protected void setUp()
throws Exception
{
super.setUp();
if ( getContainer().hasComponent( MavenProjectBuilder.class, "test" ) )
if ( getContainer().hasComponent( ProjectBuilder.class, "test" ) )
{
projectBuilder = lookup( MavenProjectBuilder.class, "test" );
projectBuilder = lookup( ProjectBuilder.class, "test" );
}
else
{
// default over to the main project builder...
projectBuilder = lookup( MavenProjectBuilder.class );
projectBuilder = lookup( ProjectBuilder.class );
}
}
@ -62,7 +62,7 @@ public abstract class AbstractMavenProjectTestCase
super.tearDown();
}
protected MavenProjectBuilder getProjectBuilder()
protected ProjectBuilder getProjectBuilder()
{
return projectBuilder;
}
@ -117,7 +117,7 @@ public abstract class AbstractMavenProjectTestCase
protected MavenProject getProjectWithDependencies( File pom )
throws Exception
{
ProjectBuilderConfiguration configuration = new DefaultProjectBuilderConfiguration();
ProjectBuildingRequest configuration = new DefaultProjectBuildingRequest();
configuration.setLocalRepository( getLocalRepository() );
configuration.setRemoteRepositories( Arrays.asList( new ArtifactRepository[] {} ) );
configuration.setProcessPlugins( false );
@ -143,7 +143,7 @@ public abstract class AbstractMavenProjectTestCase
protected MavenProject getProject( File pom )
throws Exception
{
ProjectBuilderConfiguration configuration = new DefaultProjectBuilderConfiguration();
ProjectBuildingRequest configuration = new DefaultProjectBuildingRequest();
configuration.setLocalRepository( getLocalRepository() );
return projectBuilder.build( pom, configuration );

View File

@ -27,14 +27,13 @@ import java.util.List;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.model.Plugin;
import org.codehaus.plexus.util.FileUtils;
public class DefaultMavenProjectBuilderTest
extends AbstractMavenProjectTestCase
{
private List filesToDelete = new ArrayList();
private List<File> filesToDelete = new ArrayList<File>();
private File localRepoDir;
@ -44,7 +43,7 @@ public class DefaultMavenProjectBuilderTest
{
super.setUp();
projectBuilder = lookup( MavenProjectBuilder.class );
projectBuilder = lookup( ProjectBuilder.class );
localRepoDir = new File( System.getProperty( "java.io.tmpdir" ), "local-repo." + System.currentTimeMillis() );
localRepoDir.mkdirs();
@ -60,9 +59,9 @@ public class DefaultMavenProjectBuilderTest
if ( !filesToDelete.isEmpty() )
{
for ( Iterator it = filesToDelete.iterator(); it.hasNext(); )
for ( Iterator<File> it = filesToDelete.iterator(); it.hasNext(); )
{
File file = (File) it.next();
File file = it.next();
if ( file.exists() )
{

View File

@ -33,7 +33,7 @@ public class ProjectClasspathTest
throws Exception
{
//super.setUp();
projectBuilder = lookup( MavenProjectBuilder.class, "classpath" );
projectBuilder = lookup( ProjectBuilder.class, "classpath" );
}
@Override

View File

@ -6,19 +6,15 @@ package org.apache.maven.project;
import java.io.FileNotFoundException;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.repository.RepositorySystem;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
@Component(role=MavenProjectBuilder.class,hint="classpath")
public class TestMavenProjectBuilder
extends DefaultMavenProjectBuilder
@Component(role=ProjectBuilder.class,hint="classpath")
public class TestProjectBuilder
extends DefaultProjectBuilder
{
@Requirement(hint="classpath")
private RepositorySystem repositorySystem;
@Override
public MavenProject buildFromRepository( Artifact artifact, ProjectBuilderConfiguration configuration )
public MavenProject build( Artifact artifact, ProjectBuildingRequest request )
throws ProjectBuildingException
{
if ( "maven-test".equals( artifact.getGroupId() ) )
@ -38,6 +34,6 @@ public class TestMavenProjectBuilder
{
return new MavenProject();
}
return build( artifact.getFile(), configuration );
return build( artifact.getFile(), request );
}
}