import org.apache.maven.archiva.repository.layout.LayoutException;
/**
- * AbstractDefaultRepositoryContent - common methods for working with default (maven 2) layout.
+ * AbstractDefaultRepositoryContent - common methods for working with default (maven 2) layout.
*
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
* @version $Id$
protected static final char ARTIFACT_SEPARATOR = '-';
+ /**
+ * @plexus.requirement role-hint="default"
+ */
+ private PathParser defaultPathParser;
+
public ArtifactReference toArtifactReference( String path )
throws LayoutException
{
- return DefaultPathParser.toArtifactReference( path );
+ return defaultPathParser.toArtifactReference( path );
}
public String toMetadataPath( ProjectReference reference )
{
StringBuffer path = new StringBuffer();
-
+
path.append( formatAsDirectory( reference.getGroupId() ) ).append( PATH_SEPARATOR );
path.append( reference.getArtifactId() ).append( PATH_SEPARATOR );
path.append( MAVEN_METADATA );
-
+
return path.toString();
}
public String toMetadataPath( VersionedReference reference )
{
StringBuffer path = new StringBuffer();
-
+
path.append( formatAsDirectory( reference.getGroupId() ) ).append( PATH_SEPARATOR );
path.append( reference.getArtifactId() ).append( PATH_SEPARATOR );
if ( reference.getVersion() != null )
path.append( VersionUtil.getBaseVersion( reference.getVersion() ) ).append( PATH_SEPARATOR );
}
path.append( MAVEN_METADATA );
-
+
return path.toString();
}
-
+
public String toPath( ArchivaArtifact reference )
{
if ( reference == null )
import java.util.Map;
/**
- * AbstractLegacyRepositoryContent
+ * AbstractLegacyRepositoryContent
*
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
* @version $Id$
typeToDirectoryMap.put( "javadoc", "javadoc.jar" );
}
+ /**
+ * @plexus.requirement role-hint="legacy"
+ */
+ private PathParser legacyPathParser;
+
public ArtifactReference toArtifactReference( String path )
throws LayoutException
{
- return LegacyPathParser.toArtifactReference( path );
+ return legacyPathParser.toArtifactReference( path );
}
public String toPath( ArchivaArtifact reference )
public static final String MAVEN_ARCHETYPE = "maven-archetype";
public static final String MAVEN_PLUGIN = "maven-plugin";
-
+
private static final Map<String, String> typeToExtensionMap;
private static final Pattern mavenPluginPattern = Pattern.compile( "^(maven-.*-plugin)|(.*-maven-plugin)$" );
return normalizedName.substring( idx + 1 );
}
}
-
+
/**
* Determine if a given artifact Id conforms to the naming scheme for a maven plugin.
- *
+ *
* @param artifactId the artifactId to test.
* @return true if this artifactId conforms to the naming scheme for a maven plugin.
*/
import org.apache.maven.archiva.repository.layout.LayoutException;
/**
- * DefaultPathParser is a parser for maven 2 (default layout) paths to ArtifactReference.
+ * DefaultPathParser is a parser for maven 2 (default layout) paths to ArtifactReference.
*
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
* @version $Id$
- *
- * @plexus.component role="org.apache.maven.archiva.repository.content.DefaultPathParser"
+ *
+ * @plexus.component role="org.apache.maven.archiva.repository.content.PathParser" role-hint="default"
*/
-public class DefaultPathParser
+public class DefaultPathParser implements PathParser
{
private static final String INVALID_ARTIFACT_PATH = "Invalid path to Artifact: ";
/**
- * Convert a path to an ArtifactReference.
- *
- * @param path
- * @return
- * @throws LayoutException
+ * {@inheritDoc}
+ * @see org.apache.maven.archiva.repository.content.PathParser#toArtifactReference(java.lang.String)
*/
- protected static ArtifactReference toArtifactReference( String path )
+ public ArtifactReference toArtifactReference( String path )
throws LayoutException
{
if ( StringUtils.isBlank( path ) )
case '-':
// Definately a classifier.
artifact.setClassifier( parser.remaining() );
-
+
// Set the type.
artifact.setType( ArtifactExtensionMapping.guessTypeFromFilename( filename ) );
break;
artifact.setType( ArtifactExtensionMapping.guessTypeFromFilename( filename ) );
break;
}
-
+
// Special case for maven plugins
- if ( StringUtils.equals( "jar", artifact.getType() ) &&
+ if ( StringUtils.equals( "jar", artifact.getType() ) &&
ArtifactExtensionMapping.isMavenPlugin( artifact.getArtifactId() ) )
{
artifact.setType( ArtifactExtensionMapping.MAVEN_PLUGIN );
return artifact;
}
-
+
}
* under the License.
*/
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Properties;
+
import org.apache.commons.lang.StringUtils;
+import org.apache.maven.archiva.configuration.ArchivaConfiguration;
+import org.apache.maven.archiva.configuration.LegacyArtifactPath;
import org.apache.maven.archiva.model.ArtifactReference;
import org.apache.maven.archiva.repository.layout.LayoutException;
/**
- * LegacyPathParser is a parser for maven 1 (legacy layout) paths to ArtifactReference.
+ * LegacyPathParser is a parser for maven 1 (legacy layout) paths to
+ * ArtifactReference.
*
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
* @version $Id$
+ * @plexus.component role="org.apache.maven.archiva.repository.content.PathParser"
+ * role-hint="legacy"
*/
public class LegacyPathParser
+ implements PathParser
{
private static final String INVALID_ARTIFACT_PATH = "Invalid path to Artifact: ";
- protected static ArtifactReference toArtifactReference( String path )
+ /**
+ * @plexus.requirement
+ */
+ protected ArchivaConfiguration configuration;
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.apache.maven.archiva.repository.content.PathParser#toArtifactReference(java.lang.String)
+ */
+ public ArtifactReference toArtifactReference( String path )
throws LayoutException
{
+ // First, look if a custom resolution rule has been set for this artifact
+ Collection legacy = configuration.getConfiguration().getLegacyArtifactPaths();
+ for ( Iterator iterator = legacy.iterator(); iterator.hasNext(); )
+ {
+ LegacyArtifactPath legacyPath = (LegacyArtifactPath) iterator.next();
+ if ( legacyPath.match( path ) )
+ {
+ return legacyPath.getArtifactReference();
+ }
+ }
+
ArtifactReference artifact = new ArtifactReference();
String normalizedPath = StringUtils.replace( path, "\\", "/" );
{
// Illegal Path Parts Length.
throw new LayoutException( INVALID_ARTIFACT_PATH
- + "legacy paths should only have 3 parts [groupId]/[type]s/[artifactId]-[version].[type], found "
- + pathParts.length + " instead." );
+ + "legacy paths should only have 3 parts [groupId]/[type]s/[artifactId]-[version].[type], found "
+ + pathParts.length + " instead." );
}
// The Group ID.
if ( !expectedType.endsWith( "s" ) )
{
throw new LayoutException( INVALID_ARTIFACT_PATH
- + "legacy paths should have an expected type ending in [s] in the second part of the path." );
+ + "legacy paths should have an expected type ending in [s] in the second part of the path." );
}
// The Filename.
parser.reset();
// Take the first section regardless of content.
String artifactId = parser.next();
-
+
// Is there anything more that is considered not a version id?
String moreArtifactId = parser.nextNonVersion();
if ( StringUtils.isNotBlank( moreArtifactId ) )
// Set Type
artifact.setType( ArtifactExtensionMapping.guessTypeFromFilename( filename ) );
-
+
// Sanity Check: does it have an extension?
if ( StringUtils.isEmpty( artifact.getType() ) )
{
{
// Sanity Check: does extension match pathType on path?
String trimPathType = expectedType.substring( 0, expectedType.length() - 1 );
-
+
String expectedExtension = ArtifactExtensionMapping.getExtension( trimPathType );
String actualExtension = parser.getExtension();
-
+
if ( !expectedExtension.equals( actualExtension ) )
{
throw new LayoutException( INVALID_ARTIFACT_PATH + "mismatch on extension [" + actualExtension
--- /dev/null
+/**\r
+ *\r
+ */\r
+package org.apache.maven.archiva.repository.content;\r
+\r
+import org.apache.maven.archiva.model.ArtifactReference;\r
+import org.apache.maven.archiva.repository.layout.LayoutException;\r
+\r
+/**\r
+ * @author ndeloof\r
+ *\r
+ */\r
+public interface PathParser\r
+{\r
+\r
+ public ArtifactReference toArtifactReference( String path )\r
+ throws LayoutException;\r
+\r
+}\r
/**
* RepositoryRequest is used to determine the type of request that is incoming, and convert it to an appropriate
- * ArtifactReference.
+ * ArtifactReference.
*
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
* @version $Id$
- *
- * @plexus.component
+ *
+ * @plexus.component
* role="org.apache.maven.archiva.repository.content.RepositoryRequest"
*/
public class RepositoryRequest
*/
private ArchivaConfiguration archivaConfiguration;
+ /**
+ * @plexus.requirement role-hint="default"
+ */
+ private PathParser defaultPathParser;
+
+ /**
+ * @plexus.requirement role-hint="legacy"
+ */
+ private PathParser legacyPathParser;
+
private List<String> artifactPatterns;
/**
* Test path to see if it is an artifact being requested (or not).
- *
+ *
* @param requestedPath the path to test.
* @return true if it is an artifact being requested.
*/
/**
* Takes an incoming requested path (in "/" format) and gleans the layout
* and ArtifactReference appropriate for that content.
- *
+ *
* @param requestedPath the relative path to the content.
* @return the ArtifactReference for the requestedPath.
- * @throws LayoutException if the request path is not layout valid.
+ * @throws LayoutException if the request path is not layout valid.
*/
public ArtifactReference toArtifactReference( String requestedPath )
throws LayoutException
{
throw new LayoutException( "Blank request path is not a valid." );
}
-
+
String path = requestedPath;
while ( path.startsWith( "/" ) )
{
if ( isDefault( path ) )
{
- return DefaultPathParser.toArtifactReference( path );
+ return defaultPathParser.toArtifactReference( path );
}
else if ( isLegacy( path ) )
{
- return LegacyPathParser.toArtifactReference( path );
+ return legacyPathParser.toArtifactReference( path );
}
else
{
throw new LayoutException( "Not a valid request path layout, too short." );
}
}
-
+
/**
* <p>
* Tests the path to see if it conforms to the expectations of a metadata request.
* NOTE: This does a cursory check on the path's last element. A result of true
* from this method is not a guarantee that the metadata is in a valid format, or
* that it even contains data.
- * </p>
- *
+ * </p>
+ *
* @param requestedPath the path to test.
* @return true if the requestedPath is likely a metadata request.
*/
{
return requestedPath.endsWith( "/" + MetadataTools.MAVEN_METADATA );
}
-
+
/**
* <p>
* Tests the path to see if it conforms to the expectations of a support file request.
* NOTE: This does a cursory check on the path's extension only. A result of true
* from this method is not a guarantee that the support resource is in a valid format, or
* that it even contains data.
- * </p>
- *
+ * </p>
+ *
* @param requestedPath the path to test.
* @return true if the requestedPath is likely that of a support file request.
*/
String ext = requestedPath.substring( idx );
return ( ".sha1".equals( ext ) || ".md5".equals( ext ) || ".asc".equals( ext ) || ".pgp".equals( ext ) );
}
-
+
/**
* <p>
* Tests the path to see if it conforms to the expectations of a default layout request.
* <p>
* NOTE: This does a cursory check on the count of path elements only. A result of
* true from this method is not a guarantee that the path sections are valid and
- * can be resolved to an artifact reference. use {@link #toArtifactReference(String)}
+ * can be resolved to an artifact reference. use {@link #toArtifactReference(String)}
* if you want a more complete analysis of the validity of the path.
* </p>
- *
+ *
* @param requestedPath the path to test.
* @return true if the requestedPath is likely that of a default layout request.
*/
{
return false;
}
-
+
String pathParts[] = StringUtils.splitPreserveAllTokens( requestedPath, '/' );
return pathParts.length > 3;
}
-
+
/**
* <p>
* Tests the path to see if it conforms to the expectations of a legacy layout request.
* <p>
* NOTE: This does a cursory check on the count of path elements only. A result of
* true from this method is not a guarantee that the path sections are valid and
- * can be resolved to an artifact reference. use {@link #toArtifactReference(String)}
+ * can be resolved to an artifact reference. use {@link #toArtifactReference(String)}
* if you want a more complete analysis of the validity of the path.
* </p>
- *
+ *
* @param requestedPath the path to test.
* @return true if the requestedPath is likely that of a legacy layout request.
*/
{
return false;
}
-
+
String pathParts[] = StringUtils.splitPreserveAllTokens( requestedPath, '/' );
return pathParts.length == 3;
}
-
+
/**
* Adjust the requestedPath to conform to the native layout of the provided {@link ManagedRepositoryContent}.
- *
+ *
* @param requestedPath the incoming requested path.
* @param repository the repository to adjust to.
* @return the adjusted (to native) path.
- * @throws LayoutException if the path cannot be parsed.
+ * @throws LayoutException if the path cannot be parsed.
*/
public String toNativePath( String requestedPath, ManagedRepositoryContent repository ) throws LayoutException
{
{
throw new LayoutException( "Request Path is blank." );
}
-
+
String referencedResource = requestedPath;
// No checksum by default.
String supportfile = "";
-
+
// Figure out support file, and actual referencedResource.
if( isSupportFile( requestedPath ) )
{
{
throw new LayoutException( "Cannot translate metadata request to legacy layout." );
}
-
+
/* Nothing to translate.
* Default layout is the only layout that can contain maven-metadata.xml files, and
* if the managedRepository is layout legacy, this request would never occur.
import org.apache.maven.archiva.repository.layout.LayoutException;
/**
- * AbstractLegacyRepositoryContentTestCase
+ * AbstractLegacyRepositoryContentTestCase
*
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
* @version $Id$
assertBadPath( "org.apache.maven.test/jars/artifactId-1.0.war", "wrong package extension" );
}
- /**
+ /**
* [MRM-432] Oddball version spec.
* Example of an oddball / unusual version spec.
- * @throws LayoutException
+ * @throws LayoutException
*/
public void testGoodButOddVersionSpecGanymedSsh2()
throws LayoutException
import org.apache.maven.archiva.repository.layout.LayoutException;
/**
- * DefaultPathParserTest
+ * DefaultPathParserTest
*
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
* @version $Id$
public class DefaultPathParserTest
extends AbstractRepositoryLayerTestCase
{
+ private PathParser parser = new DefaultPathParser();
+
public void testBadPathMissingType()
{
assertBadPath( "invalid/invalid/1/invalid-1", "missing type" );
"wrong artifact id" );
}
- /**
- * [MRM-481] Artifact requests with a .xml.zip extension fail with a 404 Error
+ /**
+ * [MRM-481] Artifact requests with a .xml.zip extension fail with a 404 Error
*/
public void testGoodButDualExtensions()
throws LayoutException
assertLayout( path, groupId, artifactId, version, classifier, type );
}
-
- /**
+
+ /**
* [MRM-432] Oddball version spec.
* Example of an oddball / unusual version spec.
- * @throws LayoutException
+ * @throws LayoutException
*/
public void testGoodButOddVersionSpecGanymedSsh2()
throws LayoutException
assertLayout( path, groupId, artifactId, version, classifier, type );
}
- /**
+ /**
* [MRM-432] Oddball version spec.
* Example of an oddball / unusual version spec.
- * @throws LayoutException
+ * @throws LayoutException
*/
public void testGoodButOddVersionSpecJavaxComm()
throws LayoutException
/**
* Test the ejb-client type spec.
- * Type specs are not a 1 to 1 map to the extension.
+ * Type specs are not a 1 to 1 map to the extension.
* This tests that effect.
- * @throws LayoutException
+ * @throws LayoutException
*/
- /* TODO: Re-enabled in the future.
+ /* TODO: Re-enabled in the future.
public void testGoodFooEjbClient()
throws LayoutException
{
}
*/
- /**
+ /**
* [MRM-432] Oddball version spec.
* Example of an oddball / unusual version spec.
- * @throws LayoutException
+ * @throws LayoutException
*/
public void testGoodButOddVersionSpecJavaxPersistence()
throws LayoutException
String type = "jar";
String path = "javax/persistence/ejb/3.0-public_review/ejb-3.0-public_review.jar";
- /*
+ /*
* The version id of "public_review" can cause problems. is it part of
* the version spec? or the classifier?
* Since the path spec below shows it in the path, then it is really
- * part of the version spec.
+ * part of the version spec.
*/
assertLayout( path, groupId, artifactId, version, classifier, type );
/**
* Test the classifier, and java-source type spec.
- * @throws LayoutException
+ * @throws LayoutException
*/
public void testGoodFooLibSources()
throws LayoutException
/**
* A timestamped versioned artifact, should reside in a SNAPSHOT baseversion directory.
- * @throws LayoutException
+ * @throws LayoutException
*/
public void testGoodSnapshotMavenTest()
throws LayoutException
{
try
{
- DefaultPathParser.toArtifactReference( "" );
+ parser.toArtifactReference( "" );
fail( "Should have failed due to empty path." );
}
catch ( LayoutException e )
{
try
{
- DefaultPathParser.toArtifactReference( null );
+ parser.toArtifactReference( null );
fail( "Should have failed due to null path." );
}
catch ( LayoutException e )
{
try
{
- DefaultPathParser.toArtifactReference( "" );
+ parser.toArtifactReference( "" );
fail( "Should have failed due to empty path." );
}
catch ( LayoutException e )
{
try
{
- DefaultPathParser.toArtifactReference( null );
+ parser.toArtifactReference( null );
fail( "Should have failed due to null path." );
}
catch ( LayoutException e )
}
/**
- * Perform a path to artifact reference lookup, and verify the results.
+ * Perform a path to artifact reference lookup, and verify the results.
*/
private void assertLayout( String path, String groupId, String artifactId, String version, String classifier,
String type )
throws LayoutException
{
// Path to Artifact Reference.
- ArtifactReference testReference = DefaultPathParser.toArtifactReference( path );
+ ArtifactReference testReference = parser.toArtifactReference( path );
assertArtifactReference( testReference, groupId, artifactId, version, classifier, type );
}
{
try
{
- DefaultPathParser.toArtifactReference( path );
+ parser.toArtifactReference( path );
fail( "Should have thrown a LayoutException on the invalid path [" + path + "] because of [" + reason + "]" );
}
catch ( LayoutException e )
*/
+import org.apache.maven.archiva.configuration.ArchivaConfiguration;
+import org.apache.maven.archiva.configuration.DefaultArchivaConfiguration;
+import org.apache.maven.archiva.configuration.LegacyArtifactPath;
import org.apache.maven.archiva.model.ArtifactReference;
import org.apache.maven.archiva.repository.AbstractRepositoryLayerTestCase;
import org.apache.maven.archiva.repository.layout.LayoutException;
public class LegacyPathParserTest
extends AbstractRepositoryLayerTestCase
{
+ private LegacyPathParser parser = new LegacyPathParser();
+
+ /**
+ * Configure the ArchivaConfiguration
+ * {@inheritDoc}
+ * @see org.codehaus.plexus.PlexusTestCase#setUp()
+ */
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+ ArchivaConfiguration config = (ArchivaConfiguration) lookup( ArchivaConfiguration.class );
+ LegacyArtifactPath jaxen = new LegacyArtifactPath();
+ jaxen.setPath( "jaxen/jars/jaxen-1.0-FCS-full.jar" );
+ jaxen.setArtifact( "jaxen:jaxen:1.0-FCS:full:jar" );
+ config.getConfiguration().addLegacyArtifactPath( jaxen );
+ parser.configuration = config;
+ }
+
+
public void testBadPathArtifactIdMissingA()
{
assertBadPath( "groupId/jars/-1.0.jar", "artifactId is missing" );
assertLayout( path, groupId, artifactId, version, null, type );
}
+ /**
+ * [MRM-594] add some hook in LegacyPathParser to allow exceptions in artifact resolution
+ */
+ public void testCustomExceptionsInArtifactResolution()
+ throws LayoutException
+ {
+ String groupId = "jaxen";
+ String artifactId = "jaxen";
+ String version = "1.0-FCS";
+ String type = "jar";
+ String classifier = "full";
+ String path = "jaxen/jars/jaxen-1.0-FCS-full.jar";
+
+ assertLayout( path, groupId, artifactId, version, classifier, type );
+ }
+
/**
* Perform a path to artifact reference lookup, and verify the results.
- * @param classifier TODO
*/
private void assertLayout( String path, String groupId, String artifactId, String version, String classifier, String type )
throws LayoutException
{
// Path to Artifact Reference.
- ArtifactReference testReference = LegacyPathParser.toArtifactReference( path );
+ ArtifactReference testReference = parser.toArtifactReference( path );
assertArtifactReference( testReference, groupId, artifactId, version, classifier, type );
}
private void assertArtifactReference( ArtifactReference actualReference, String groupId, String artifactId,
String version, String classifier, String type )
{
- String expectedId = "ArtifactReference - " + groupId + ":" + artifactId + ":" + version + ":" + type;
+ String expectedId = "ArtifactReference - " + groupId + ":" + artifactId + ":" + version + ":" + classifier + ":" + type;
assertNotNull( expectedId + " - Should not be null.", actualReference );
{
try
{
- LegacyPathParser.toArtifactReference( path );
+ parser.toArtifactReference( path );
fail( "Should have thrown a LayoutException on the invalid path [" + path + "] because of [" + reason + "]" );
}
catch ( LayoutException e )
// Starting slash should not prevent detection.
assertValid( "/org.apache.derby/poms/derby-10.2.2.0.pom", "org.apache.derby", "derby", "10.2.2.0", null, "pom" );
}
-
+
public void testValidDefaultDerbyPom()
throws Exception
{
assertTrue( repoRequest.isArtifact( "test.maven-arch/poms/test-arch-2.0.3-SNAPSHOT.pom" ) );
assertTrue( repoRequest.isArtifact( "test/maven-arch/test-arch/2.0.3-SNAPSHOT/test-arch-2.0.3-SNAPSHOT.jar" ) );
assertTrue( repoRequest.isArtifact( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz" ) );
-
+
assertFalse( repoRequest.isArtifact( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz.sha1" ) );
assertFalse( repoRequest.isArtifact( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz.md5" ) );
assertFalse( repoRequest.isArtifact( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz.asc" ) );
assertFalse( repoRequest.isArtifact( "org/apache/derby/derby/10.2.2.0/maven-metadata.xml" ) );
assertFalse( repoRequest.isArtifact( "org/apache/derby/derby/maven-metadata.xml" ) );
}
-
+
public void testIsSupportFile()
{
assertTrue( repoRequest.isSupportFile( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz.sha1" ) );
assertTrue( repoRequest.isSupportFile( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz.pgp" ) );
assertTrue( repoRequest.isSupportFile( "org/apache/derby/derby/10.2.2.0/maven-metadata.xml.sha1" ) );
assertTrue( repoRequest.isSupportFile( "org/apache/derby/derby/10.2.2.0/maven-metadata.xml.md5" ) );
-
+
assertFalse( repoRequest.isSupportFile( "test.maven-arch/poms/test-arch-2.0.3-SNAPSHOT.pom" ) );
assertFalse( repoRequest.isSupportFile( "test/maven-arch/test-arch/2.0.3-SNAPSHOT/test-arch-2.0.3-SNAPSHOT.jar" ) );
assertFalse( repoRequest.isSupportFile( "org/apache/archiva/archiva-api/1.0/archiva-api-1.0.xml.zip" ) );
assertFalse( repoRequest.isSupportFile( "org/apache/derby/derby/10.2.2.0/maven-metadata.xml" ) );
assertFalse( repoRequest.isSupportFile( "org/apache/derby/derby/maven-metadata.xml" ) );
}
-
+
public void testIsMetadata()
{
assertTrue( repoRequest.isMetadata( "org/apache/derby/derby/10.2.2.0/maven-metadata.xml" ));
assertTrue( repoRequest.isMetadata( "org/apache/derby/derby/maven-metadata.xml" ));
-
+
assertFalse( repoRequest.isMetadata( "test.maven-arch/poms/test-arch-2.0.3-SNAPSHOT.pom" ) );
assertFalse( repoRequest.isMetadata( "test/maven-arch/test-arch/2.0.3-SNAPSHOT/test-arch-2.0.3-SNAPSHOT.jar" ) );
assertFalse( repoRequest.isMetadata( "org/apache/archiva/archiva-api/1.0/archiva-api-1.0.xml.zip" ) );
assertFalse( repoRequest.isMetadata( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz.pgp" ) );
assertFalse( repoRequest.isMetadata( "org/apache/derby/derby/10.2.2.0/maven-metadata.xml.sha1" ) );
}
-
+
public void testIsDefault()
{
assertFalse( repoRequest.isDefault( "test.maven-arch/poms/test-arch-2.0.3-SNAPSHOT.pom" ) );
assertFalse( repoRequest.isDefault( "directory-clients/poms/ldap-clients-0.9.1-SNAPSHOT.pom" ) );
assertFalse( repoRequest.isDefault( "commons-lang/jars/commons-lang-2.1-javadoc.jar" ) );
-
+
assertTrue( repoRequest.isDefault( "test/maven-arch/test-arch/2.0.3-SNAPSHOT/test-arch-2.0.3-SNAPSHOT.jar" ) );
assertTrue( repoRequest.isDefault( "org/apache/archiva/archiva-api/1.0/archiva-api-1.0.xml.zip" ) );
assertTrue( repoRequest.isDefault( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz" ) );
assertTrue( repoRequest.isDefault( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz.pgp" ) );
assertTrue( repoRequest.isDefault( "org/apache/derby/derby/10.2.2.0/maven-metadata.xml.sha1" ) );
-
+
assertFalse( repoRequest.isDefault( null ) );
assertFalse( repoRequest.isDefault( "" ) );
assertFalse( repoRequest.isDefault( "foo" ) );
assertFalse( repoRequest.isDefault( "some.short/path" ) );
}
-
+
public void testIsLegacy()
{
assertTrue( repoRequest.isLegacy( "test.maven-arch/poms/test-arch-2.0.3-SNAPSHOT.pom" ) );
assertTrue( repoRequest.isLegacy( "directory-clients/poms/ldap-clients-0.9.1-SNAPSHOT.pom" ) );
assertTrue( repoRequest.isLegacy( "commons-lang/jars/commons-lang-2.1-javadoc.jar" ) );
-
+
assertFalse( repoRequest.isLegacy( "test/maven-arch/test-arch/2.0.3-SNAPSHOT/test-arch-2.0.3-SNAPSHOT.jar" ) );
assertFalse( repoRequest.isLegacy( "org/apache/archiva/archiva-api/1.0/archiva-api-1.0.xml.zip" ) );
assertFalse( repoRequest.isLegacy( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz" ) );
assertFalse( repoRequest.isLegacy( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz.pgp" ) );
assertFalse( repoRequest.isLegacy( "org/apache/derby/derby/10.2.2.0/maven-metadata.xml.sha1" ) );
-
+
assertFalse( repoRequest.isLegacy( null ) );
assertFalse( repoRequest.isLegacy( "" ) );
assertFalse( repoRequest.isLegacy( "some.short/path" ) );
}
-
+
private ManagedRepositoryContent createManagedRepo( String layout )
throws Exception
{
File repoRoot = getTestFile( "target/test-repo" );
return createManagedRepositoryContent( "test-internal", "Internal Test Repo", repoRoot, layout );
}
-
+
/**
* [MRM-481] Artifact requests with a .xml.zip extension fail with a 404 Error
*/
assertEquals( "org/project/example-presentation/3.2/example-presentation-3.2.xml.zip", repoRequest
.toNativePath( "org/project/example-presentation/3.2/example-presentation-3.2.xml.zip", repository ) );
}
-
+
/**
* [MRM-481] Artifact requests with a .xml.zip extension fail with a 404 Error
*/
assertEquals( "org/project/example-presentation/3.2.xml/example-presentation-3.2.xml.zip", repoRequest
.toNativePath( "org.project/zips/example-presentation-3.2.xml.zip", repository ) );
}
-
+
public void testToNativePathMetadataDefaultToDefault()
throws Exception
{
{
ManagedRepositoryContent repository = createManagedRepo( "default" );
- // Test (pom) legacy to default
+ // Test (pom) legacy to default
assertEquals( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0.pom", repoRequest
.toNativePath( "org.apache.derby/poms/derby-10.2.2.0.pom", repository ) );
}
// expected path.
}
}
-
+
public void testNativePathBadRequestBlank()
throws Exception
{
// expected path.
}
}
-
+
public void testNativePathBadRequestNull()
throws Exception
{
// expected path.
}
}
-
+
public void testNativePathBadRequestUnknownType()
throws Exception
{
// expected path.
}
}
-
+
public void testToNativePathLegacyMetadataDefaultToLegacy()
throws Exception
{
ManagedRepositoryContent repository = createManagedRepo( "legacy" );
// Test (metadata) default to legacy
-
+
// Special Case: This direction is not supported, should throw a LayoutException.
try
{
// expected path.
}
}
-
+
public void testNativePathPomDefaultToLegacy()
throws Exception
{
assertEquals( "org.apache.derby/poms/derby-10.2.2.0.pom", repoRequest
.toNativePath( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0.pom", repository ) );
}
-
+
public void testNativePathSupportFileDefaultToLegacy()
throws Exception
{
ManagedRepositoryContent repository = createManagedRepo( "legacy" );
- // Test (supportfile) default to legacy
+ // Test (supportfile) default to legacy
assertEquals( "org.apache.derby/jars/derby-10.2.2.0.jar.sha1", repoRequest
.toNativePath( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0.jar.sha1", repository ) );
}