mirror of https://github.com/apache/archiva.git
test invalid version
PR: MRM-9 git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@349661 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
76cee0be7a
commit
0ba475649b
|
@ -22,18 +22,4 @@
|
|||
<artifactId>maven-artifact</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<!-- TODO: why are these needed? -->
|
||||
<reporting>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-clover-plugin</artifactId>
|
||||
<configuration>
|
||||
<flushPolicy>threaded</flushPolicy>
|
||||
<flushInterval>100</flushInterval>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</reporting>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -94,14 +94,34 @@ public class DefaultArtifactDiscoverer
|
|||
Collections.reverse( pathParts );
|
||||
String groupId = StringUtils.join( pathParts.iterator(), "." );
|
||||
|
||||
if ( !filename.startsWith( artifactId + "-" ) )
|
||||
result = artifactFactory.createArtifact( groupId, artifactId, version, Artifact.SCOPE_RUNTIME, "jar" );
|
||||
|
||||
String remainingFilename = filename;
|
||||
if ( !remainingFilename.startsWith( artifactId + "-" ) )
|
||||
{
|
||||
addKickedOutPath( path );
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
remainingFilename = remainingFilename.substring( artifactId.length() + 1 );
|
||||
if ( result.isSnapshot() )
|
||||
{
|
||||
result = artifactFactory.createArtifact( groupId, artifactId, version, Artifact.SCOPE_RUNTIME, "jar" );
|
||||
result.setResolvedVersion( remainingFilename.substring( 0, remainingFilename.length() - 4 ) );
|
||||
if ( !result.getBaseVersion().equals( version ) )
|
||||
{
|
||||
addKickedOutPath( path );
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if ( !remainingFilename.startsWith( version ) )
|
||||
{
|
||||
addKickedOutPath( path );
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
result.setFile( new File( path ) );
|
||||
|
||||
|
|
|
@ -150,6 +150,26 @@ public class DefaultArtifactDiscovererTest
|
|||
}
|
||||
}
|
||||
|
||||
public void testKickoutWithWrongVersion()
|
||||
{
|
||||
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/invalid/1.0/invalid-2.0.jar" );
|
||||
}
|
||||
assertTrue( "Check kickout was found", found );
|
||||
|
||||
for ( Iterator i = artifacts.iterator(); i.hasNext(); )
|
||||
{
|
||||
Artifact a = (Artifact) i.next();
|
||||
assertFalse( "Check not 'invalid-2.0.jar'", a.getFile().getName().equals( "invalid-2.0.jar" ) );
|
||||
}
|
||||
}
|
||||
|
||||
public void testSnapshotInclusion()
|
||||
{
|
||||
List artifacts = discoverer.discoverArtifacts( repositoryLocation, null, true );
|
||||
|
@ -157,7 +177,7 @@ public class DefaultArtifactDiscovererTest
|
|||
|
||||
assertTrue( "Check normal included", artifacts.contains( createArtifact( "javax.sql", "jdbc", "2.0" ) ) );
|
||||
assertTrue( "Check snapshot included",
|
||||
artifacts.contains( createArtifact( "org.apache.maven", "test", "1.0-SNAPSHOT" ) ) );
|
||||
artifacts.contains( createArtifact( "org.apache.maven", "test", "1.0-20050611.112233-1" ) ) );
|
||||
}
|
||||
|
||||
public void testSnapshotExclusion()
|
||||
|
|
Loading…
Reference in New Issue