[MRM-703] Artifacts with extensions longer than fours characters breaks repository scanning

Submitted by:  	 Jim Jackson
Merged from: r629020 on archiva-1.0.x branch


git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@629023 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Porter 2008-02-19 08:35:55 +00:00
parent d23dd72c41
commit a13e30feb5
2 changed files with 29 additions and 21 deletions

View File

@ -40,7 +40,7 @@ public class FilenameParser
private static final Pattern mavenPluginPattern = Pattern.compile( "(maven-.*-plugin)|(.*-maven-plugin)" );
private static final Pattern extensionPattern = Pattern.compile( "(.tar.gz$)|(.tar.bz2$)|(.[a-z0-9]{1,4}$)",
private static final Pattern extensionPattern = Pattern.compile( "(.tar.gz$)|(.tar.bz2$)|(.[a-z0-9]*$)",
Pattern.CASE_INSENSITIVE );
private static final Pattern section = Pattern.compile( "([^-]*)" );

View File

@ -121,24 +121,32 @@ public class FilenameParserTest
{
FilenameParser parser = new FilenameParser( "maven-test-plugin-1.8.3.jar" );
assertEquals("maven-test-plugin", parser.nextNonVersion() );
assertEquals("1.8.3", parser.remaining() );
assertEquals( "maven-test-plugin", parser.nextNonVersion() );
assertEquals( "1.8.3", parser.remaining() );
}
public void testNextArbitraryNonVersion()
{
FilenameParser parser = new FilenameParser( "maven-jdk-1.4-plugin-1.0-20070828.123456-42.jar" );
assertEquals("maven-jdk-1.4-plugin", parser.nextNonVersion() );
assertEquals("1.0-20070828.123456-42", parser.remaining() );
assertEquals( "maven-jdk-1.4-plugin", parser.nextNonVersion() );
assertEquals( "1.0-20070828.123456-42", parser.remaining() );
}
public void testNextJython()
{
FilenameParser parser = new FilenameParser( "jython-20020827-no-oro.jar" );
assertEquals("jython", parser.nextNonVersion() );
assertEquals("20020827", parser.nextVersion() );
assertEquals("no-oro", parser.remaining() );
assertEquals( "jython", parser.nextNonVersion() );
assertEquals( "20020827", parser.nextVersion() );
assertEquals( "no-oro", parser.remaining() );
}
public void testLongExtension()
{
FilenameParser parser = new FilenameParser( "libfobs4jmf-0.4.1.4-20080217.211715-4.jnilib" );
assertEquals( "libfobs4jmf-0.4.1.4-20080217.211715-4", parser.getName() );
assertEquals( "jnilib", parser.getExtension() );
}
}