more legacy discoverer tests

PR: MRM-9

git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@349653 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Porter 2005-11-29 05:15:31 +00:00
parent fcd8104a67
commit 7b61ac8764
5 changed files with 50 additions and 3 deletions

View File

@ -79,10 +79,13 @@ public class LegacyArtifactDiscoverer
String type = tokens.nextToken(); String type = tokens.nextToken();
if ( type.endsWith( "s" ) ) if ( !type.endsWith( "s" ) )
{ {
type = type.substring( 0, type.length() - 1 ); addKickedOutPath( path );
return null;
} }
type = type.substring( 0, type.length() - 1 );
// contains artifactId, version, classifier, and extension. // contains artifactId, version, classifier, and extension.
String avceGlob = tokens.nextToken(); String avceGlob = tokens.nextToken();

View File

@ -25,10 +25,11 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
/** /**
* Test the default artifact discoverer. * Test the legacy artifact discoverer.
* *
* @author <a href="mailto:brett@apache.org">Brett Porter</a> * @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id$ * @version $Id$
* @todo share as much as possible with default via abstract test case
*/ */
public class LegacyArtifactDiscovererTest public class LegacyArtifactDiscovererTest
extends PlexusTestCase extends PlexusTestCase
@ -147,6 +148,44 @@ public class LegacyArtifactDiscovererTest
} }
} }
public void testKickoutWithInvalidType()
{
List artifacts = discoverer.discoverArtifacts( repositoryLocation, null, false );
assertNotNull( "Check artifacts not null", artifacts );
boolean found = false;
for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
{
String path = (String) i.next();
found = path.replace( '\\', '/' ).equals( "invalid/foo/invalid-1.0.foo" );
}
assertTrue( "Check exclusion was found", found );
for ( Iterator i = artifacts.iterator(); i.hasNext(); )
{
Artifact a = (Artifact) i.next();
assertFalse( "Check not invalid-1.0.foo", a.getFile().getName().equals( "invalid-1.0.foo" ) );
}
}
public void testInclusion()
{
List artifacts = discoverer.discoverArtifacts( repositoryLocation, null, true );
assertNotNull( "Check artifacts not null", artifacts );
assertTrue( "Check normal included",
artifacts.contains( createArtifact( "org.apache.maven", "testing", "1.0" ) ) );
}
public void testJavaSourcesInclusion()
{
List artifacts = discoverer.discoverArtifacts( repositoryLocation, null, true );
assertNotNull( "Check artifacts not null", artifacts );
assertTrue( "Check normal included",
artifacts.contains( createSourceArtifact( "org.apache.maven", "testing", "1.0" ) ) );
}
public void testSnapshotInclusion() public void testSnapshotInclusion()
{ {
List artifacts = discoverer.discoverArtifacts( repositoryLocation, null, true ); List artifacts = discoverer.discoverArtifacts( repositoryLocation, null, true );
@ -172,4 +211,9 @@ public class LegacyArtifactDiscovererTest
return factory.createArtifact( groupId, artifactId, version, null, "jar" ); return factory.createArtifact( groupId, artifactId, version, null, "jar" );
} }
private Artifact createSourceArtifact( String groupId, String artifactId, String version )
{
return factory.createArtifact( groupId, artifactId, version, null, "java-source" );
}
} }