* under the License.
*/
-import org.apache.archiva.model.ArtifactReference;
import org.apache.archiva.repository.LayoutException;
+import org.apache.archiva.repository.content.ItemSelector;
import org.apache.archiva.repository.content.PathParser;
-import org.apache.archiva.repository.maven.content.DefaultPathParser;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
import org.apache.commons.lang3.StringUtils;
import org.junit.Test;
String groupId = "org.project";
String artifactId = "example-presentation";
String version = "3.2";
+ String artifactVersion = "3.2";
String classifier = null;
String type = "xml.zip";
String path = "org/project/example-presentation/3.2/example-presentation-3.2.xml.zip";
- assertLayout( path, groupId, artifactId, version, classifier, type );
+ assertLayout( path, groupId, artifactId, version, artifactVersion, classifier, type );
}
@Test
String groupId = "org.project";
String artifactId = "example-presentation";
String version = "3.2";
+ String artifactVersion = "3.2";
String classifier = "extras";
String type = "xml.zip";
String path = "org/project/example-presentation/3.2/example-presentation-3.2-extras.xml.zip";
- assertLayout( path, groupId, artifactId, version, classifier, type );
+ assertLayout( path, groupId, artifactId, version, artifactVersion, classifier, type );
}
@Test
String groupId = "org.project";
String artifactId = "example-distribution";
String version = "1.3";
+ String artifactVersion = "1.3";
String classifier = null;
String type = "tar.gz"; // no longer using distribution-tgz / distribution-zip in maven 2
String path = "org/project/example-distribution/1.3/example-distribution-1.3.tar.gz";
- assertLayout( path, groupId, artifactId, version, classifier, type );
+ assertLayout( path, groupId, artifactId, version, artifactVersion, classifier, type );
}
@Test
String groupId = "org.project";
String artifactId = "example-distribution";
String version = "1.3";
+ String artifactVersion = "1.3";
String classifier = "bin";
String type = "tar.gz"; // no longer using distribution-tgz / distribution-zip in maven 2
String path = "org/project/example-distribution/1.3/example-distribution-1.3-bin.tar.gz";
- assertLayout( path, groupId, artifactId, version, classifier, type );
+ assertLayout( path, groupId, artifactId, version, artifactVersion, classifier, type );
}
/**
String groupId = "ch.ethz.ganymed";
String artifactId = "ganymed-ssh2";
String version = "build210";
+ String artifactVersion = "build210";
String classifier = null;
String type = "jar";
String path = "ch/ethz/ganymed/ganymed-ssh2/build210/ganymed-ssh2-build210.jar";
- assertLayout( path, groupId, artifactId, version, classifier, type );
+ assertLayout( path, groupId, artifactId, version, artifactVersion, classifier, type );
}
/**
String groupId = "javax";
String artifactId = "comm";
String version = "3.0-u1";
+ String artifactVersion = "3.0-u1";
String classifier = null;
String type = "jar";
String path = "javax/comm/3.0-u1/comm-3.0-u1.jar";
- assertLayout( path, groupId, artifactId, version, classifier, type );
+ assertLayout( path, groupId, artifactId, version, artifactVersion, classifier, type );
}
/**
String groupId = "javax.persistence";
String artifactId = "ejb";
String version = "3.0-public_review";
+ String artifactVersion = "3.0-public_review";
String classifier = null;
String type = "jar";
String path = "javax/persistence/ejb/3.0-public_review/ejb-3.0-public_review.jar";
* part of the version spec.
*/
- assertLayout( path, groupId, artifactId, version, classifier, type );
+ assertLayout( path, groupId, artifactId, version, artifactVersion, classifier, type );
}
@Test
String groupId = "com.foo";
String artifactId = "foo-tool";
String version = "1.0";
+ String artifactVersion = "1.0";
String classifier = null;
String type = "jar";
String path = "com/foo/foo-tool/1.0/foo-tool-1.0.jar";
- assertLayout( path, groupId, artifactId, version, classifier, type );
+ assertLayout( path, groupId, artifactId, version, artifactVersion, classifier, type );
}
@Test
String groupId = "commons-lang";
String artifactId = "commons-lang";
String version = "2.1";
+ String artifactVersion = "2.1";
String classifier = null;
String type = "jar";
String path = "commons-lang/commons-lang/2.1/commons-lang-2.1.jar";
- assertLayout( path, groupId, artifactId, version, classifier, type );
+ assertLayout( path, groupId, artifactId, version, artifactVersion, classifier, type );
}
@Test
String groupId = "commons-lang";
String artifactId = "commons-lang";
String version = "2.1";
+ String artifactVersion = "2.1";
String classifier = null;
String type = "jar";
String path = "commons-lang\\commons-lang/2.1\\commons-lang-2.1.jar";
- assertLayout( path, groupId, artifactId, version, classifier, type );
+ assertLayout( path, groupId, artifactId, version, artifactVersion, classifier, type );
}
/**
String groupId = "test.maven-arch";
String artifactId = "test-arch";
String version = "2.0.3-SNAPSHOT";
+ String artifactVersion = "2.0.3-SNAPSHOT";
String classifier = null;
String type = "pom";
String path = "test/maven-arch/test-arch/2.0.3-SNAPSHOT/test-arch-2.0.3-SNAPSHOT.pom";
- assertLayout( path, groupId, artifactId, version, classifier, type );
+ assertLayout( path, groupId, artifactId, version, artifactVersion, classifier, type );
}
/**
String groupId = "com.company.department";
String artifactId = "com.company.department";
String version = "0.2";
+ String artifactVersion = "0.2";
String classifier = null;
String type = "pom";
String path = "com/company/department/com.company.department/0.2/com.company.department-0.2.pom";
- assertLayout( path, groupId, artifactId, version, classifier, type );
+ assertLayout( path, groupId, artifactId, version, artifactVersion, classifier, type );
}
/**
String groupId = "com.company.department";
String artifactId = "com.company.department.project";
String version = "0.3";
+ String artifactVersion = "0.3";
String classifier = null;
String type = "pom";
String path =
"com/company/department/com.company.department.project/0.3/com.company.department.project-0.3.pom";
- assertLayout( path, groupId, artifactId, version, classifier, type );
+ assertLayout( path, groupId, artifactId, version, artifactVersion, classifier, type );
}
/**
String groupId = "com.foo.lib";
String artifactId = "foo-lib";
String version = "2.1-alpha-1";
+ String artifactVersion = "2.1-alpha-1";
String classifier = "sources";
String type = "java-source"; // oddball type-spec (should result in jar extension)
String path = "com/foo/lib/foo-lib/2.1-alpha-1/foo-lib-2.1-alpha-1-sources.jar";
- assertLayout( path, groupId, artifactId, version, classifier, type );
+ assertLayout( path, groupId, artifactId, version, artifactVersion, classifier, type );
}
/**
{
String groupId = "org.apache.archiva.test";
String artifactId = "redonkulous";
- String version = "3.1-beta-1-20050831.101112-42";
+ String version = "3.1-beta-1-SNAPSHOT";
+ String artifactVersion = "3.1-beta-1-20050831.101112-42";
String classifier = null;
String type = "jar";
String path =
"org/apache/archiva/test/redonkulous/3.1-beta-1-SNAPSHOT/redonkulous-3.1-beta-1-20050831.101112-42.jar";
- assertLayout( path, groupId, artifactId, version, classifier, type );
+ assertLayout( path, groupId, artifactId, version, artifactVersion, classifier, type );
}
/**
{
String groupId = "a.group.id";
String artifactId = "artifact-id";
- String version = "1.0-abc-1.1-20080221.062205-9";
+ String version = "1.0-abc-1.1-SNAPSHOT";
+ String artifactVersion = "1.0-abc-1.1-20080221.062205-9";
String classifier = null;
String type = "pom";
String path = "a/group/id/artifact-id/1.0-abc-1.1-SNAPSHOT/artifact-id-1.0-abc-1.1-20080221.062205-9.pom";
- assertLayout( path, groupId, artifactId, version, classifier, type );
+ assertLayout( path, groupId, artifactId, version, artifactVersion, classifier, type );
}
/**
{
String groupId = "a.group.id";
String artifactId = "artifact-id";
- String version = "1.0-20070219.171202-34";
+ String version = "1.0-SNAPSHOT";
+ String artifactVersion = "1.0-20070219.171202-34";
String classifier = "test-sources";
String type = "jar";
String path = "a/group/id/artifact-id/1.0-SNAPSHOT/artifact-id-1.0-20070219.171202-34-test-sources.jar";
- assertLayout( path, groupId, artifactId, version, classifier, type );
+ assertLayout( path, groupId, artifactId, version, artifactVersion, classifier, type );
}
/**
String groupId = "maven";
String artifactId = "maven-test-plugin";
String version = "1.8.2";
+ String artifactVersion = "1.8.2";
String classifier = null;
String type = "pom";
String path = "maven/maven-test-plugin/1.8.2/maven-test-plugin-1.8.2.pom";
- assertLayout( path, groupId, artifactId, version, classifier, type );
+ assertLayout( path, groupId, artifactId, version, artifactVersion, classifier, type );
}
/**
String groupId = "maven";
String artifactId = "maven-test-plugin";
String version = "1.8.2";
+ String artifactVersion = "1.8.2";
String classifier = null;
String type = "maven-plugin";
String path = "maven/maven-test-plugin/1.8.2/maven-test-plugin-1.8.2.jar";
- assertLayout( path, groupId, artifactId, version, classifier, type );
+ assertLayout( path, groupId, artifactId, version, artifactVersion, classifier, type );
}
/**
String groupId = "org.codehaus.mojo";
String artifactId = "cobertura-maven-plugin";
String version = "2.1";
+ String artifactVersion = "2.1";
String classifier = null;
String type = "maven-plugin";
String path = "org/codehaus/mojo/cobertura-maven-plugin/2.1/cobertura-maven-plugin-2.1.jar";
- assertLayout( path, groupId, artifactId, version, classifier, type );
+ assertLayout( path, groupId, artifactId, version, artifactVersion, classifier, type );
}
@Test
{
try
{
- parser.toArtifactReference( "" );
+ parser.toItemSelector( "" );
fail( "Should have failed due to empty path." );
}
catch ( LayoutException e )
{
try
{
- parser.toArtifactReference( null );
+ parser.toItemSelector( null );
fail( "Should have failed due to null path." );
}
catch ( LayoutException e )
{
try
{
- parser.toArtifactReference( "" );
+ parser.toItemSelector( "" );
fail( "Should have failed due to empty path." );
}
catch ( LayoutException e )
{
try
{
- parser.toArtifactReference( null );
+ parser.toItemSelector( null );
fail( "Should have failed due to null path." );
}
catch ( LayoutException e )
/**
* Perform a path to artifact reference lookup, and verify the results.
*/
- private void assertLayout( String path, String groupId, String artifactId, String version, String classifier,
+ private void assertLayout( String path, String groupId, String artifactId, String version, String artifactVersion, String classifier,
String type )
throws LayoutException
{
// Path to Artifact Reference.
- ArtifactReference testReference = parser.toArtifactReference( path );
- assertArtifactReference( testReference, groupId, artifactId, version, classifier, type );
+ ItemSelector testReference = parser.toItemSelector( path );
+ assertArtifactReference( testReference, groupId, artifactId, version, artifactVersion, classifier, type );
}
- private void assertArtifactReference( ArtifactReference actualReference, String groupId, String artifactId,
- String version, String classifier, String type )
+ private void assertArtifactReference( ItemSelector actualReference, String groupId, String artifactId,
+ String version, String artifactVersion, String classifier, String type )
{
String expectedId =
"ArtifactReference - " + groupId + ":" + artifactId + ":" + version + ":" + classifier + ":" + type;
assertNotNull( expectedId + " - Should not be null.", actualReference );
- assertEquals( expectedId + " - Group ID", groupId, actualReference.getGroupId() );
+ assertEquals( expectedId + " - Group ID", groupId, actualReference.getNamespace() );
assertEquals( expectedId + " - Artifact ID", artifactId, actualReference.getArtifactId() );
+ assertEquals( expectedId + " - Artifact Version", artifactVersion, actualReference.getArtifactVersion( ) );
if ( StringUtils.isNotBlank( classifier ) )
{
assertEquals( expectedId + " - Classifier", classifier, actualReference.getClassifier() );
{
try
{
- parser.toArtifactReference( path );
+ parser.toItemSelector( path );
fail(
"Should have thrown a LayoutException on the invalid path [" + path + "] because of [" + reason + "]" );
}
import org.apache.archiva.configuration.FileType;
import org.apache.archiva.configuration.FileTypes;
import org.apache.archiva.repository.ManagedRepositoryContent;
+import org.apache.archiva.repository.content.ItemSelector;
import org.apache.archiva.repository.maven.metadata.storage.ArtifactMappingProvider;
import org.apache.archiva.model.ArtifactReference;
import org.apache.archiva.repository.LayoutException;
throws Exception
{
assertValid( "ch.ethz.ganymed/jars/ganymed-ssh2-build210.jar", "ch.ethz.ganymed", "ganymed-ssh2", "build210",
- null, "jar" );
+ "build210", null, "jar" );
}
@Test
throws Exception
{
assertValid( "ch/ethz/ganymed/ganymed-ssh2/build210/ganymed-ssh2-build210.jar", "ch.ethz.ganymed",
- "ganymed-ssh2", "build210", null, "jar" );
+ "ganymed-ssh2", "build210", "build210", null, "jar" );
}
@Test( expected = LayoutException.class )
public void testValidLegacyJavaxComm()
throws Exception
{
- assertValid( "javax/jars/comm-3.0-u1.jar", "javax", "comm", "3.0-u1", null, "jar" );
+ assertValid( "javax/jars/comm-3.0-u1.jar", "javax", "comm", "3.0-u1", "3.0-u1", null, "jar" );
}
@Test
public void testValidDefaultJavaxComm()
throws Exception
{
- assertValid( "javax/comm/3.0-u1/comm-3.0-u1.jar", "javax", "comm", "3.0-u1", null, "jar" );
+ assertValid( "javax/comm/3.0-u1/comm-3.0-u1.jar", "javax", "comm", "3.0-u1", "3.0-u1", null, "jar" );
}
@Test( expected = LayoutException.class )
throws Exception
{
assertValid( "javax.persistence/jars/ejb-3.0-public_review.jar", "javax.persistence", "ejb",
- "3.0-public_review", null, "jar" );
+ "3.0-public_review", "3.0-public_review", null, "jar" );
}
@Test
throws Exception
{
assertValid( "javax/persistence/ejb/3.0-public_review/ejb-3.0-public_review.jar", "javax.persistence", "ejb",
- "3.0-public_review", null, "jar" );
+ "3.0-public_review", "3.0-public_review",null, "jar" );
}
@Test( expected = LayoutException.class )
public void testValidLegacyMavenTestPlugin()
throws Exception
{
- assertValid( "maven/jars/maven-test-plugin-1.8.2.jar", "maven", "maven-test-plugin", "1.8.2", null, "jar" );
+ assertValid( "maven/jars/maven-test-plugin-1.8.2.jar", "maven", "maven-test-plugin", "1.8.2", "1.8.2",null, "jar" );
}
@Test
public void testValidDefaultMavenTestPlugin()
throws Exception
{
- assertValid( "maven/maven-test-plugin/1.8.2/maven-test-plugin-1.8.2.pom", "maven", "maven-test-plugin", "1.8.2",
+ assertValid( "maven/maven-test-plugin/1.8.2/maven-test-plugin-1.8.2.pom", "maven", "maven-test-plugin", "1.8.2", "1.8.2",
null, "pom" );
}
public void testValidLegacyCommonsLangJavadoc()
throws Exception
{
- assertValid( "commons-lang/javadoc.jars/commons-lang-2.1-javadoc.jar", "commons-lang", "commons-lang", "2.1",
+ assertValid( "commons-lang/javadoc.jars/commons-lang-2.1-javadoc.jar", "commons-lang", "commons-lang", "2.1", "2.1",
"javadoc", "javadoc" );
}
throws Exception
{
assertValid( "commons-lang/commons-lang/2.1/commons-lang-2.1-javadoc.jar", "commons-lang", "commons-lang",
- "2.1", "javadoc", "javadoc" );
+ "2.1", "2.1","javadoc", "javadoc" );
}
@Test( expected = LayoutException.class )
public void testValidLegacyDerbyPom()
throws Exception
{
- assertValid( "org.apache.derby/poms/derby-10.2.2.0.pom", "org.apache.derby", "derby", "10.2.2.0", null, "pom" );
+ assertValid( "org.apache.derby/poms/derby-10.2.2.0.pom", "org.apache.derby", "derby", "10.2.2.0", "10.2.2.0",null, "pom" );
// 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,
+ assertValid( "/org.apache.derby/poms/derby-10.2.2.0.pom", "org.apache.derby", "derby", "10.2.2.0", "10.2.2.0",null,
"pom" );
}
public void testValidDefaultDerbyPom()
throws Exception
{
- assertValid( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0.pom", "org.apache.derby", "derby", "10.2.2.0",
+ assertValid( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0.pom", "org.apache.derby", "derby", "10.2.2.0", "10.2.2.0",
null, "pom" );
}
throws Exception
{
assertValid( "org.apache.geronimo.specs/jars/geronimo-ejb_2.1_spec-1.0.1.jar", "org.apache.geronimo.specs",
- "geronimo-ejb_2.1_spec", "1.0.1", null, "jar" );
+ "geronimo-ejb_2.1_spec", "1.0.1", "1.0.1",null, "jar" );
}
@Test
throws Exception
{
assertValid( "org/apache/geronimo/specs/geronimo-ejb_2.1_spec/1.0.1/geronimo-ejb_2.1_spec-1.0.1.jar",
- "org.apache.geronimo.specs", "geronimo-ejb_2.1_spec", "1.0.1", null, "jar" );
+ "org.apache.geronimo.specs", "geronimo-ejb_2.1_spec", "1.0.1", "1.0.1",null, "jar" );
}
@Test( expected = LayoutException.class )
throws Exception
{
assertValid( "directory-clients/poms/ldap-clients-0.9.1-SNAPSHOT.pom", "directory-clients", "ldap-clients",
- "0.9.1-SNAPSHOT", null, "pom" );
+ "0.9.1-SNAPSHOT", "0.9.1-SNAPSHOT",null, "pom" );
}
@Test
throws Exception
{
assertValid( "directory-clients/ldap-clients/0.9.1-SNAPSHOT/ldap-clients-0.9.1-SNAPSHOT.pom",
- "directory-clients", "ldap-clients", "0.9.1-SNAPSHOT", null, "pom" );
+ "directory-clients", "ldap-clients", "0.9.1-SNAPSHOT", "0.9.1-SNAPSHOT",null, "pom" );
}
@Test( expected = LayoutException.class )
throws Exception
{
assertValid( "test.maven-arch/poms/test-arch-2.0.3-SNAPSHOT.pom", "test.maven-arch", "test-arch",
- "2.0.3-SNAPSHOT", null, "pom" );
+ "2.0.3-SNAPSHOT", "2.0.3-SNAPSHOT",null, "pom" );
}
@Test
throws Exception
{
assertValid( "test/maven-arch/test-arch/2.0.3-SNAPSHOT/test-arch-2.0.3-SNAPSHOT.pom", "test.maven-arch",
- "test-arch", "2.0.3-SNAPSHOT", null, "pom" );
+ "test-arch", "2.0.3-SNAPSHOT", "2.0.3-SNAPSHOT",null, "pom" );
}
@Test( expected = LayoutException.class )
throws Exception
{
assertValid( "com.company.department/poms/com.company.department.project-0.2.pom", "com.company.department",
- "com.company.department.project", "0.2", null, "pom" );
+ "com.company.department.project", "0.2", "0.2",null, "pom" );
}
@Test
throws Exception
{
assertValid( "com/company/department/com.company.department.project/0.2/com.company.department.project-0.2.pom",
- "com.company.department", "com.company.department.project", "0.2", null, "pom" );
+ "com.company.department", "com.company.department.project", "0.2", "0.2",null, "pom" );
}
@Test( expected = LayoutException.class )
throws Exception
{
assertValid( "org.apache.archiva.test/jars/redonkulous-3.1-beta-1-20050831.101112-42.jar",
- "org.apache.archiva.test", "redonkulous", "3.1-beta-1-20050831.101112-42", null, "jar" );
+ "org.apache.archiva.test", "redonkulous", "3.1-beta-1-20050831.101112-42", "3.1-beta-1-20050831.101112-42", null, "jar" );
}
@Test
{
assertValid(
"org/apache/archiva/test/redonkulous/3.1-beta-1-SNAPSHOT/redonkulous-3.1-beta-1-20050831.101112-42.jar",
- "org.apache.archiva.test", "redonkulous", "3.1-beta-1-20050831.101112-42", null, "jar" );
+ "org.apache.archiva.test", "redonkulous", "3.1-beta-1-SNAPSHOT", "3.1-beta-1-20050831.101112-42", null, "jar" );
}
@Test
}
- private void assertValid( String path, String groupId, String artifactId, String version, String classifier,
+ private void assertValid( String path, String groupId, String artifactId, String version, String artifactVersion, String classifier,
String type )
throws Exception
{
"ArtifactReference - " + groupId + ":" + artifactId + ":" + version + ":" + ( classifier != null ?
classifier + ":" : "" ) + type;
- ArtifactReference reference = repoRequest.toArtifactReference( path );
+ ItemSelector reference = repoRequest.toItemSelector( path );
assertNotNull( expectedId + " - Should not be null.", reference );
- assertEquals( expectedId + " - Group ID", groupId, reference.getGroupId() );
+ assertEquals( expectedId + " - Group ID", groupId, reference.getNamespace() );
assertEquals( expectedId + " - Artifact ID", artifactId, reference.getArtifactId() );
+ assertEquals( expectedId + " - Artifact Version", artifactVersion, reference.getArtifactVersion( ) );
if ( StringUtils.isNotBlank( classifier ) )
{
assertEquals( expectedId + " - Classifier", classifier, reference.getClassifier() );
{
try
{
- repoRequest.toArtifactReference( path );
+ repoRequest.toItemSelector( path );
fail( "Expected a LayoutException on an invalid path [" + path + "]" );
}
catch ( LayoutException e )