mirror of https://github.com/apache/archiva.git
test invalid snapshot version
PR: MRM-9 git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@349671 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0ba475649b
commit
824ecd2c84
|
@ -107,8 +107,16 @@ public class DefaultArtifactDiscoverer
|
||||||
remainingFilename = remainingFilename.substring( artifactId.length() + 1 );
|
remainingFilename = remainingFilename.substring( artifactId.length() + 1 );
|
||||||
if ( result.isSnapshot() )
|
if ( result.isSnapshot() )
|
||||||
{
|
{
|
||||||
result = artifactFactory.createArtifact( groupId, artifactId, version, Artifact.SCOPE_RUNTIME, "jar" );
|
result = artifactFactory.createArtifact( groupId, artifactId,
|
||||||
result.setResolvedVersion( remainingFilename.substring( 0, remainingFilename.length() - 4 ) );
|
remainingFilename.substring( 0, remainingFilename.length() - 4 ),
|
||||||
|
Artifact.SCOPE_RUNTIME, "jar" );
|
||||||
|
// poor encapsulation requires we do this to populate base version
|
||||||
|
if ( !result.isSnapshot() )
|
||||||
|
{
|
||||||
|
addKickedOutPath( path );
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
if ( !result.getBaseVersion().equals( version ) )
|
if ( !result.getBaseVersion().equals( version ) )
|
||||||
{
|
{
|
||||||
addKickedOutPath( path );
|
addKickedOutPath( path );
|
||||||
|
|
|
@ -170,6 +170,26 @@ public class DefaultArtifactDiscovererTest
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testKickoutWithWrongSnapshotVersion()
|
||||||
|
{
|
||||||
|
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-SNAPSHOT/invalid-1.0.jar" );
|
||||||
|
}
|
||||||
|
assertTrue( "Check kickout was found", found );
|
||||||
|
|
||||||
|
for ( Iterator i = artifacts.iterator(); i.hasNext(); )
|
||||||
|
{
|
||||||
|
Artifact a = (Artifact) i.next();
|
||||||
|
assertFalse( "Check not 'invalid-1.0.jar'", a.getFile().getName().equals( "invalid-1.0.jar" ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void testSnapshotInclusion()
|
public void testSnapshotInclusion()
|
||||||
{
|
{
|
||||||
List artifacts = discoverer.discoverArtifacts( repositoryLocation, null, true );
|
List artifacts = discoverer.discoverArtifacts( repositoryLocation, null, true );
|
||||||
|
|
Loading…
Reference in New Issue