Переглянути джерело

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
tags/archiva-0.9-alpha-1
Brett Porter 18 роки тому
джерело
коміт
0ba475649b

+ 0
- 14
maven-repository-discovery/pom.xml Переглянути файл

@@ -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>

+ 22
- 2
maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DefaultArtifactDiscoverer.java Переглянути файл

@@ -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;
}

result = artifactFactory.createArtifact( groupId, artifactId, version, Artifact.SCOPE_RUNTIME, "jar" );
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 ) );


+ 21
- 1
maven-repository-discovery/src/test/java/org/apache/maven/repository/discovery/DefaultArtifactDiscovererTest.java Переглянути файл

@@ -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()

+ 0
- 0
maven-repository-discovery/src/test/repository/invalid/invalid/1.0/invalid-2.0.jar Переглянути файл


Завантаження…
Відмінити
Зберегти