@@ -51,14 +51,6 @@ public interface ArchivaAdministrationService | |||
List<LegacyArtifactPath> getLegacyArtifactPaths() | |||
throws ArchivaRestServiceException; | |||
@Path( "addLegacyArtifactPath" ) | |||
@POST | |||
@Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) | |||
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) | |||
@RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) | |||
void addLegacyArtifactPath( LegacyArtifactPath legacyArtifactPath ) | |||
throws ArchivaRestServiceException; | |||
@Path( "deleteLegacyArtifactPath" ) | |||
@GET | |||
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) |
@@ -25,8 +25,6 @@ import org.apache.archiva.admin.model.beans.LegacyArtifactPath; | |||
import org.apache.archiva.admin.model.beans.NetworkConfiguration; | |||
import org.apache.archiva.admin.model.beans.OrganisationInformation; | |||
import org.apache.archiva.admin.model.beans.UiConfiguration; | |||
import org.apache.archiva.model.ArtifactReference; | |||
import org.apache.archiva.repository.ManagedRepositoryContent; | |||
import org.apache.archiva.repository.scanner.RepositoryContentConsumers; | |||
import org.apache.archiva.rest.api.model.AdminRepositoryConsumer; | |||
import org.apache.archiva.rest.api.services.ArchivaAdministrationService; | |||
@@ -38,8 +36,6 @@ import org.apache.commons.lang.StringUtils; | |||
import org.springframework.stereotype.Service; | |||
import javax.inject.Inject; | |||
import javax.inject.Named; | |||
import javax.ws.rs.core.Response; | |||
import java.util.ArrayList; | |||
import java.util.Collections; | |||
import java.util.List; | |||
@@ -56,9 +52,6 @@ public class DefaultArchivaAdministrationService | |||
@Inject | |||
private ArchivaAdministration archivaAdministration; | |||
@Inject | |||
@Named ( value = "managedRepositoryContent#legacy" ) | |||
private ManagedRepositoryContent repositoryContent; | |||
@Inject | |||
private RepositoryContentConsumers repoConsumerUtil; | |||
@@ -77,37 +70,6 @@ public class DefaultArchivaAdministrationService | |||
} | |||
} | |||
@Override | |||
public void addLegacyArtifactPath( LegacyArtifactPath legacyArtifactPath ) | |||
throws ArchivaRestServiceException | |||
{ | |||
// Check the proposed Artifact matches the path | |||
ArtifactReference artifact = new ArtifactReference(); | |||
artifact.setGroupId( legacyArtifactPath.getGroupId() ); | |||
artifact.setArtifactId( legacyArtifactPath.getArtifactId() ); | |||
artifact.setClassifier( legacyArtifactPath.getClassifier() ); | |||
artifact.setVersion( legacyArtifactPath.getVersion() ); | |||
artifact.setType( legacyArtifactPath.getType() ); | |||
String path = repositoryContent.toPath( artifact ); | |||
if ( !StringUtils.equals( path, legacyArtifactPath.getPath() ) ) | |||
{ | |||
throw new ArchivaRestServiceException( | |||
"artifact path reference '" + legacyArtifactPath.getPath() + "' does not match the initial path: '" | |||
+ path + "'", Response.Status.BAD_REQUEST.getStatusCode(), null ); | |||
} | |||
try | |||
{ | |||
archivaAdministration.addLegacyArtifactPath( legacyArtifactPath, getAuditInformation() ); | |||
} | |||
catch ( RepositoryAdminException e ) | |||
{ | |||
throw new ArchivaRestServiceException( e.getMessage(), e ); | |||
} | |||
} | |||
@Override | |||
public Boolean deleteLegacyArtifactPath( String path ) |
@@ -62,7 +62,6 @@ import org.apache.archiva.repository.ManagedRepositoryContent; | |||
import org.apache.archiva.repository.RepositoryContentFactory; | |||
import org.apache.archiva.repository.RepositoryException; | |||
import org.apache.archiva.repository.RepositoryNotFoundException; | |||
import org.apache.archiva.repository.content.legacy.LegacyPathParser; | |||
import org.apache.archiva.repository.content.maven2.RepositoryRequest; | |||
import org.apache.archiva.repository.events.AuditListener; | |||
import org.apache.archiva.repository.layout.LayoutException; | |||
@@ -201,7 +200,7 @@ public class ArchivaDavResourceFactory | |||
this.digestSha1 = plexusSisuBridge.lookup( Digester.class, "sha1" ); | |||
// TODO remove this hard dependency on maven !! | |||
repositoryRequest = new RepositoryRequest( new LegacyPathParser( archivaConfiguration ) ); | |||
repositoryRequest = new RepositoryRequest( ); | |||
} | |||
@PostConstruct |
@@ -36,7 +36,6 @@ import org.apache.archiva.proxy.DefaultRepositoryProxyConnectors; | |||
import org.apache.archiva.proxy.model.ProxyFetchResult; | |||
import org.apache.archiva.repository.ManagedRepositoryContent; | |||
import org.apache.archiva.repository.RepositoryContentFactory; | |||
import org.apache.archiva.repository.content.legacy.LegacyPathParser; | |||
import org.apache.archiva.repository.content.maven2.ManagedDefaultRepositoryContent; | |||
import org.apache.archiva.repository.content.maven2.RepositoryRequest; | |||
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner; | |||
@@ -460,7 +459,7 @@ public class ArchivaDavResourceFactoryTest | |||
ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO ); | |||
// use actual object (this performs the isMetadata, isDefault and isSupportFile check!) | |||
RepositoryRequest repoRequest = new RepositoryRequest( new LegacyPathParser( this.archivaConfiguration ) ); | |||
RepositoryRequest repoRequest = new RepositoryRequest( ); | |||
resourceFactory.setRepositoryRequest( repoRequest ); | |||
try | |||
@@ -521,7 +520,7 @@ public class ArchivaDavResourceFactoryTest | |||
ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO ); | |||
// use actual object (this performs the isMetadata, isDefault and isSupportFile check!) | |||
RepositoryRequest repoRequest = new RepositoryRequest( new LegacyPathParser( this.archivaConfiguration ) ); | |||
RepositoryRequest repoRequest = new RepositoryRequest( ); | |||
resourceFactory.setRepositoryRequest( repoRequest ); | |||
try | |||
@@ -572,7 +571,7 @@ public class ArchivaDavResourceFactoryTest | |||
ManagedRepositoryContent legacyRepo = createManagedRepositoryContent( LEGACY_REPO ); | |||
// use actual object (this performs the isMetadata, isDefault and isSupportFile check!) | |||
RepositoryRequest repoRequest = new RepositoryRequest( new LegacyPathParser( this.archivaConfiguration ) ); | |||
RepositoryRequest repoRequest = new RepositoryRequest( ); | |||
resourceFactory.setRepositoryRequest( repoRequest ); | |||
try |
@@ -22,8 +22,6 @@ package org.apache.archiva.repository.content.maven2; | |||
import org.apache.archiva.model.ArtifactReference; | |||
import org.apache.archiva.repository.ManagedRepositoryContent; | |||
import org.apache.archiva.repository.content.PathParser; | |||
import org.apache.archiva.repository.content.legacy.LegacyPathParser; | |||
import org.apache.archiva.repository.content.legacy.ManagedLegacyRepositoryContent; | |||
import org.apache.archiva.repository.layout.LayoutException; | |||
import org.apache.archiva.repository.metadata.MetadataTools; | |||
import org.apache.commons.lang.StringUtils; | |||
@@ -36,11 +34,9 @@ public class RepositoryRequest | |||
{ | |||
private PathParser defaultPathParser = new DefaultPathParser(); | |||
private PathParser legacyPathParser; | |||
public RepositoryRequest( LegacyPathParser legacyPathParser ) | |||
public RepositoryRequest() | |||
{ | |||
this.legacyPathParser = legacyPathParser; | |||
// no op | |||
} | |||
/** | |||
@@ -77,7 +73,7 @@ public class RepositoryRequest | |||
} | |||
else if ( isLegacy( path ) ) | |||
{ | |||
return legacyPathParser.toArtifactReference( path ); | |||
throw new LayoutException( "Legacy Maven1 repository not supported anymore." ); | |||
} | |||
else | |||
{ | |||
@@ -264,11 +260,6 @@ public class RepositoryRequest | |||
if ( isMetadata( referencedResource ) ) | |||
{ | |||
if ( repository instanceof ManagedLegacyRepositoryContent ) | |||
{ | |||
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. |
@@ -29,14 +29,9 @@ | |||
<context:annotation-config/> | |||
<context:component-scan base-package="org.apache.archiva.dependency.tree.maven2,org.apache.archiva.metadata.repository.storage.maven2, | |||
org.apache.archiva.repository.content.maven2,org.apache.archiva.repository.content.legacy"/> | |||
org.apache.archiva.repository.content.maven2"/> | |||
<bean name="pathParser#legacy" class="org.apache.archiva.repository.content.legacy.LegacyPathParser"> | |||
<constructor-arg> | |||
<ref bean="archivaConfiguration#default"/> | |||
</constructor-arg> | |||
</bean> | |||
<alias name="repositoryStorage#maven2" alias="repositoryStorage#default"/> | |||
<alias name="repositoryStorage#maven2" alias="repositoryStorage#legacy"/> |
@@ -1,455 +0,0 @@ | |||
package org.apache.archiva.metadata.repository.storage.maven2; | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
* distributed with this work for additional information | |||
* regarding copyright ownership. The ASF licenses this file | |||
* to you under the Apache License, Version 2.0 (the | |||
* "License"); you may not use this file except in compliance | |||
* with the License. You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, | |||
* software distributed under the License is distributed on an | |||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
* KIND, either express or implied. See the License for the | |||
* specific language governing permissions and limitations | |||
* under the License. | |||
*/ | |||
import org.apache.archiva.model.ArtifactReference; | |||
import org.apache.archiva.repository.AbstractRepositoryLayerTestCase; | |||
import org.apache.archiva.repository.layout.LayoutException; | |||
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner; | |||
import org.junit.Test; | |||
import org.junit.runner.RunWith; | |||
import org.springframework.test.context.ContextConfiguration; | |||
import static org.junit.Assert.*; | |||
/** | |||
* AbstractLegacyRepositoryContentTestCase | |||
*/ | |||
@RunWith ( ArchivaSpringJUnit4ClassRunner.class ) | |||
@ContextConfiguration ( { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context-no-mock-conf.xml" } ) | |||
public abstract class AbstractLegacyRepositoryContentTestCase | |||
extends AbstractRepositoryLayerTestCase | |||
{ | |||
@Test | |||
public void testBadPathArtifactIdMissingA() | |||
{ | |||
assertBadPath( "groupId/jars/-1.0.jar", "artifactId is missing" ); | |||
} | |||
@Test | |||
public void testBadPathArtifactIdMissingB() | |||
{ | |||
assertBadPath( "groupId/jars/1.0.jar", "artifactId is missing" ); | |||
} | |||
@Test | |||
public void testBadPathMissingType() | |||
{ | |||
assertBadPath( "invalid/invalid/1/invalid-1", "missing type" ); | |||
} | |||
@Test | |||
public void testBadPathTooShort() | |||
{ | |||
// NEW | |||
assertBadPath( "invalid/invalid-1.0.jar", "path is too short" ); | |||
} | |||
@Test | |||
public void testBadPathWrongPackageExtension() | |||
{ | |||
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 org.apache.archiva.repository.layout.LayoutException | |||
* | |||
*/ | |||
@Test | |||
public void testGoodButOddVersionSpecGanymedSsh2() | |||
throws LayoutException | |||
{ | |||
String groupId = "ch.ethz.ganymed"; | |||
String artifactId = "ganymed-ssh2"; | |||
String version = "build210"; | |||
String type = "jar"; | |||
String path = "ch.ethz.ganymed/jars/ganymed-ssh2-build210.jar"; | |||
assertLayout( path, groupId, artifactId, version, null, type ); | |||
} | |||
/** | |||
* [MRM-432] Oddball version spec. | |||
* Example of an oddball / unusual version spec. | |||
* | |||
* @throws org.apache.archiva.repository.layout.LayoutException | |||
* | |||
*/ | |||
@Test | |||
public void testGoodButOddVersionSpecJavaxComm() | |||
throws LayoutException | |||
{ | |||
String groupId = "javax"; | |||
String artifactId = "comm"; | |||
String version = "3.0-u1"; | |||
String type = "jar"; | |||
String path = "javax/jars/comm-3.0-u1.jar"; | |||
assertLayout( path, groupId, artifactId, version, null, type ); | |||
} | |||
/** | |||
* [MRM-432] Oddball version spec. | |||
* Example of an oddball / unusual version spec. | |||
* | |||
* @throws org.apache.archiva.repository.layout.LayoutException | |||
* | |||
*/ | |||
@Test | |||
public void testGoodButOddVersionSpecJavaxPersistence() | |||
throws LayoutException | |||
{ | |||
String groupId = "javax.persistence"; | |||
String artifactId = "ejb"; | |||
String version = "3.0-public_review"; | |||
String type = "jar"; | |||
String path = "javax.persistence/jars/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? | |||
*/ | |||
assertLayout( path, groupId, artifactId, version, null, type ); | |||
} | |||
@Test | |||
public void testGoodCommonsLang() | |||
throws LayoutException | |||
{ | |||
String groupId = "commons-lang"; | |||
String artifactId = "commons-lang"; | |||
String version = "2.1"; | |||
String type = "jar"; | |||
String path = "commons-lang/jars/commons-lang-2.1.jar"; | |||
assertLayout( path, groupId, artifactId, version, null, type ); | |||
} | |||
@Test | |||
public void testGoodDerby() | |||
throws LayoutException | |||
{ | |||
String groupId = "org.apache.derby"; | |||
String artifactId = "derby"; | |||
String version = "10.2.2.0"; | |||
String type = "jar"; | |||
String path = "org.apache.derby/jars/derby-10.2.2.0.jar"; | |||
assertLayout( path, groupId, artifactId, version, null, type ); | |||
} | |||
/** | |||
* Test the ejb-client type spec. | |||
* Type specs are not a 1 to 1 map to the extension. | |||
* This tests that effect. | |||
* @throws org.apache.archiva.repository.layout.LayoutException | |||
*/ | |||
/* TODO: Re-enabled in the future. | |||
public void testGoodFooEjbClient() | |||
throws LayoutException | |||
{ | |||
String groupId = "com.foo"; | |||
String artifactId = "foo-client"; | |||
String version = "1.0"; | |||
String type = "ejb"; // oddball type-spec (should result in jar extension) | |||
String path = "com.foo/ejbs/foo-client-1.0.jar"; | |||
assertLayout( path, groupId, artifactId, version, classifier, type ); | |||
} | |||
*/ | |||
/** | |||
* Test the classifier. | |||
* | |||
* @throws org.apache.archiva.repository.layout.LayoutException | |||
* | |||
*/ | |||
@Test | |||
public void testGoodFooLibJavadoc() | |||
throws LayoutException | |||
{ | |||
String groupId = "com.foo.lib"; | |||
String artifactId = "foo-lib"; | |||
String version = "2.1-alpha-1"; | |||
String type = "javadoc"; | |||
String classifier = "javadoc"; | |||
String path = "com.foo.lib/javadoc.jars/foo-lib-2.1-alpha-1-javadoc.jar"; | |||
assertLayout( path, groupId, artifactId, version, classifier, type ); | |||
} | |||
/** | |||
* Test the classifier, and java-source type spec. | |||
* | |||
* @throws org.apache.archiva.repository.layout.LayoutException | |||
* | |||
*/ | |||
@Test | |||
public void testGoodFooLibSources() | |||
throws LayoutException | |||
{ | |||
String groupId = "com.foo.lib"; | |||
String artifactId = "foo-lib"; | |||
String version = "2.1-alpha-1"; | |||
String type = "java-source"; // oddball type-spec (should result in jar extension) | |||
String classifier = "sources"; | |||
String path = "com.foo.lib/java-sources/foo-lib-2.1-alpha-1-sources.jar"; | |||
assertLayout( path, groupId, artifactId, version, classifier, type ); | |||
} | |||
@Test | |||
public void testGoodFooTool() | |||
throws LayoutException | |||
{ | |||
String groupId = "com.foo"; | |||
String artifactId = "foo-tool"; | |||
String version = "1.0"; | |||
String type = "jar"; | |||
String path = "com.foo/jars/foo-tool-1.0.jar"; | |||
assertLayout( path, groupId, artifactId, version, null, type ); | |||
} | |||
@Test | |||
public void testGoodGeronimoEjbSpec() | |||
throws LayoutException | |||
{ | |||
String groupId = "org.apache.geronimo.specs"; | |||
String artifactId = "geronimo-ejb_2.1_spec"; | |||
String version = "1.0.1"; | |||
String type = "jar"; | |||
String path = "org.apache.geronimo.specs/jars/geronimo-ejb_2.1_spec-1.0.1.jar"; | |||
assertLayout( path, groupId, artifactId, version, null, type ); | |||
} | |||
@Test | |||
public void testGoodLdapClientsPom() | |||
throws LayoutException | |||
{ | |||
String groupId = "directory-clients"; | |||
String artifactId = "ldap-clients"; | |||
String version = "0.9.1-SNAPSHOT"; | |||
String type = "pom"; | |||
String path = "directory-clients/poms/ldap-clients-0.9.1-SNAPSHOT.pom"; | |||
assertLayout( path, groupId, artifactId, version, null, type ); | |||
} | |||
/** | |||
* A timestamped versioned artifact, should reside in a SNAPSHOT baseversion directory. | |||
* | |||
* @throws org.apache.archiva.repository.layout.LayoutException | |||
* | |||
*/ | |||
@Test | |||
public void testGoodSnapshotMavenTest() | |||
throws LayoutException | |||
{ | |||
String groupId = "org.apache.archiva.test"; | |||
String artifactId = "redonkulous"; | |||
String version = "3.1-beta-1-20050831.101112-42"; | |||
String type = "jar"; | |||
String path = "org.apache.archiva.test/jars/redonkulous-3.1-beta-1-20050831.101112-42.jar"; | |||
assertLayout( path, groupId, artifactId, version, null, type ); | |||
} | |||
/** | |||
* [MRM-519] version identifiers within filename cause misidentification of version. | |||
* Example uses "test" in artifact Id, which is also part of the versionKeyword list. | |||
*/ | |||
@Test | |||
public void testGoodVersionKeywordInArtifactId() | |||
throws LayoutException | |||
{ | |||
String groupId = "maven"; | |||
String artifactId = "maven-test-plugin"; | |||
String version = "1.8.2"; | |||
String type = "pom"; | |||
String path = "maven/poms/maven-test-plugin-1.8.2.pom"; | |||
assertLayout( path, groupId, artifactId, version, null, type ); | |||
} | |||
/** | |||
* [MRM-562] Artifact type "maven-plugin" is not detected correctly in .toArtifactReference() methods. | |||
* Example uses "test" in artifact Id, which is also part of the versionKeyword list. | |||
*/ | |||
@Test | |||
public void testGoodDetectPluginMavenTest() | |||
throws LayoutException | |||
{ | |||
String groupId = "maven"; | |||
String artifactId = "maven-test-plugin"; | |||
String version = "1.8.2"; | |||
String type = "maven-one-plugin"; | |||
String path = "maven/plugins/maven-test-plugin-1.8.2.jar"; | |||
assertLayout( path, groupId, artifactId, version, null, type ); | |||
} | |||
/** | |||
* [MRM-562] Artifact type "maven-plugin" is not detected correctly in .toArtifactReference() methods. | |||
*/ | |||
@Test | |||
public void testGoodDetectPluginAvalonMeta() | |||
throws LayoutException | |||
{ | |||
String groupId = "avalon-meta"; | |||
String artifactId = "avalon-meta-plugin"; | |||
String version = "1.1"; | |||
String type = "maven-one-plugin"; | |||
String path = "avalon-meta/plugins/avalon-meta-plugin-1.1.jar"; | |||
assertLayout( path, groupId, artifactId, version, null, type ); | |||
} | |||
/** | |||
* [MRM-562] Artifact type "maven-plugin" is not detected correctly in .toArtifactReference() methods. | |||
*/ | |||
@Test | |||
public void testGoodDetectPluginCactusMaven() | |||
throws LayoutException | |||
{ | |||
String groupId = "cactus"; | |||
String artifactId = "cactus-maven"; | |||
String version = "1.7dev-20040815"; | |||
String type = "maven-one-plugin"; | |||
String path = "cactus/plugins/cactus-maven-1.7dev-20040815.jar"; | |||
assertLayout( path, groupId, artifactId, version, null, type ); | |||
} | |||
/** | |||
* [MRM-562] Artifact type "maven-plugin" is not detected correctly in .toArtifactReference() methods. | |||
*/ | |||
@Test | |||
public void testGoodDetectPluginGeronimoPackaging() | |||
throws LayoutException | |||
{ | |||
String groupId = "geronimo"; | |||
String artifactId = "geronimo-packaging-plugin"; | |||
String version = "1.0.1"; | |||
String type = "maven-one-plugin"; | |||
String path = "geronimo/plugins/geronimo-packaging-plugin-1.0.1.jar"; | |||
assertLayout( path, groupId, artifactId, version, null, type ); | |||
} | |||
/** | |||
* [MRM-768] Artifact type "maven-plugin" does not distinguish maven1 and maven2 plugins. | |||
* This produces conflicts when m2 plugins are stored in legacy-layout repository | |||
*/ | |||
@Test | |||
public void testMaven1Maven2PluginTypeDistinc() | |||
throws Exception | |||
{ | |||
String groupId = "com.sun.tools.xjc.maven2"; | |||
String artifactId = "maven-jaxb-plugin"; | |||
String version = "1.1"; | |||
String type = "maven-plugin"; | |||
String path = "com.sun.tools.xjc.maven2/maven-plugins/maven-jaxb-plugin-1.1.jar"; | |||
assertLayout( path, groupId, artifactId, version, null, type ); | |||
} | |||
/** | |||
* Perform a roundtrip through the layout routines to determine success. | |||
* | |||
* @param classifier TODO | |||
*/ | |||
private void assertLayout( String path, String groupId, String artifactId, String version, String classifier, | |||
String type ) | |||
throws LayoutException | |||
{ | |||
ArtifactReference expectedArtifact = createArtifact( groupId, artifactId, version, classifier, type ); | |||
// --- Artifact Tests. | |||
// Artifact to Path | |||
assertEquals( "Artifact <" + expectedArtifact + "> to path:", path, toPath( expectedArtifact ) ); | |||
// --- Artifact Reference Tests | |||
// Path to Artifact Reference. | |||
ArtifactReference testReference = toArtifactReference( path ); | |||
assertArtifactReference( testReference, groupId, artifactId, version, classifier, type ); | |||
// And back again, using test Reference from previous step. | |||
assertEquals( "Artifact <" + expectedArtifact + "> to path:", path, toPath( testReference ) ); | |||
} | |||
private void assertArtifactReference( ArtifactReference actualReference, String groupId, String artifactId, | |||
String version, String classifier, String type ) | |||
{ | |||
String expectedId = "ArtifactReference - " + groupId + ":" + artifactId + ":" + version + ":" + type; | |||
assertNotNull( expectedId + " - Should not be null.", actualReference ); | |||
assertEquals( expectedId + " - Group ID", groupId, actualReference.getGroupId() ); | |||
assertEquals( expectedId + " - Artifact ID", artifactId, actualReference.getArtifactId() ); | |||
assertEquals( expectedId + " - Version ID", version, actualReference.getVersion() ); | |||
assertEquals( expectedId + " - classifier", classifier, actualReference.getClassifier() ); | |||
assertEquals( expectedId + " - Type", type, actualReference.getType() ); | |||
} | |||
protected ArtifactReference createArtifact( String groupId, String artifactId, String version, String classifier, | |||
String type ) | |||
{ | |||
ArtifactReference artifact = new ArtifactReference(); | |||
artifact.setGroupId( groupId ); | |||
artifact.setArtifactId( artifactId ); | |||
artifact.setVersion( version ); | |||
artifact.setClassifier( classifier ); | |||
artifact.setType( type ); | |||
assertNotNull( artifact ); | |||
return artifact; | |||
} | |||
private void assertBadPath( String path, String reason ) | |||
{ | |||
try | |||
{ | |||
toArtifactReference( path ); | |||
fail( | |||
"Should have thrown a LayoutException on the invalid path [" + path + "] because of [" + reason + "]" ); | |||
} | |||
catch ( LayoutException e ) | |||
{ | |||
/* expected path */ | |||
} | |||
} | |||
protected abstract ArtifactReference toArtifactReference( String path ) | |||
throws LayoutException; | |||
protected abstract String toPath( ArtifactReference reference ); | |||
} |
@@ -1,196 +0,0 @@ | |||
package org.apache.archiva.metadata.repository.storage.maven2; | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
* distributed with this work for additional information | |||
* regarding copyright ownership. The ASF licenses this file | |||
* to you under the Apache License, Version 2.0 (the | |||
* "License"); you may not use this file except in compliance | |||
* with the License. You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, | |||
* software distributed under the License is distributed on an | |||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
* KIND, either express or implied. See the License for the | |||
* specific language governing permissions and limitations | |||
* under the License. | |||
*/ | |||
import org.apache.archiva.admin.model.beans.ManagedRepository; | |||
import org.apache.archiva.common.utils.VersionComparator; | |||
import org.apache.archiva.model.ArtifactReference; | |||
import org.apache.archiva.model.ProjectReference; | |||
import org.apache.archiva.model.VersionedReference; | |||
import org.apache.archiva.repository.ManagedRepositoryContent; | |||
import org.apache.archiva.repository.layout.LayoutException; | |||
import org.junit.Before; | |||
import org.junit.Test; | |||
import javax.inject.Inject; | |||
import javax.inject.Named; | |||
import java.io.File; | |||
import java.util.ArrayList; | |||
import java.util.Collections; | |||
import java.util.List; | |||
import java.util.Set; | |||
import static org.junit.Assert.*; | |||
/** | |||
* ManagedLegacyRepositoryContentTest | |||
* | |||
* | |||
*/ | |||
public class ManagedLegacyRepositoryContentTest | |||
extends AbstractLegacyRepositoryContentTestCase | |||
{ | |||
@Inject | |||
@Named( "managedRepositoryContent#legacy" ) | |||
private ManagedRepositoryContent repoContent; | |||
@Before | |||
public void setUp() | |||
throws Exception | |||
{ | |||
File repoDir = new File( "src/test/repositories/legacy-repository" ); | |||
ManagedRepository repository = createRepository( "testRepo", "Unit Test Repo", repoDir ); | |||
repository.setLayout( "legacy" ); | |||
//repoContent = (ManagedRepositoryContent) lookup( ManagedRepositoryContent.class, "legacy" ); | |||
repoContent.setRepository( repository ); | |||
} | |||
@Test | |||
public void testGetVersionsFromProjectReference() | |||
throws Exception | |||
{ | |||
assertVersions( "org.apache.maven", "testing", new String[]{ "UNKNOWN", | |||
// "1.0-javadoc", | |||
// "1.0-sources", | |||
"1.0", "1.0-20050611.112233-1" } ); | |||
} | |||
@Test | |||
public void testGetVersionsFromVersionedReference() | |||
throws Exception | |||
{ | |||
assertVersions( "org.apache.maven", "testing", "1.0", new String[]{ | |||
// "1.0-javadoc", | |||
// "1.0-sources", | |||
"1.0", "1.0-20050611.112233-1" } ); | |||
} | |||
private void assertVersions( String groupId, String artifactId, String[] expectedVersions ) | |||
throws Exception | |||
{ | |||
ProjectReference reference = new ProjectReference(); | |||
reference.setGroupId( groupId ); | |||
reference.setArtifactId( artifactId ); | |||
// Request the versions. | |||
Set<String> testedVersionSet = repoContent.getVersions( reference ); | |||
// Sort the list (for asserts later) | |||
List<String> testedVersions = new ArrayList<>(); | |||
testedVersions.addAll( testedVersionSet ); | |||
Collections.sort( testedVersions, new VersionComparator() ); | |||
// Test the expected array of versions, to the actual tested versions | |||
assertEquals( "Assert (Project) Versions: length/size", expectedVersions.length, testedVersions.size() ); | |||
for ( int i = 0; i < expectedVersions.length; i++ ) | |||
{ | |||
String actualVersion = testedVersions.get( i ); | |||
assertEquals( "(Project) Versions[" + i + "]", expectedVersions[i], actualVersion ); | |||
} | |||
} | |||
private void assertVersions( String groupId, String artifactId, String version, String[] expectedVersions ) | |||
throws Exception | |||
{ | |||
VersionedReference reference = new VersionedReference(); | |||
reference.setGroupId( groupId ); | |||
reference.setArtifactId( artifactId ); | |||
reference.setVersion( version ); | |||
// Request the versions. | |||
Set<String> testedVersionSet = repoContent.getVersions( reference ); | |||
// Sort the list (for asserts later) | |||
List<String> testedVersions = new ArrayList<>(); | |||
testedVersions.addAll( testedVersionSet ); | |||
Collections.sort( testedVersions, new VersionComparator() ); | |||
// Test the expected array of versions, to the actual tested versions | |||
assertEquals( "Assert (Project) Versions: length/size", expectedVersions.length, testedVersions.size() ); | |||
for ( int i = 0; i < expectedVersions.length; i++ ) | |||
{ | |||
String actualVersion = testedVersions.get( i ); | |||
assertEquals( "(Project) Versions[" + i + "]", expectedVersions[i], actualVersion ); | |||
} | |||
} | |||
@Test | |||
public void testGetRelatedArtifacts() | |||
throws Exception | |||
{ | |||
ArtifactReference reference = createArtifact( "org.apache.maven", "testing", "1.0", null, "jar" ); | |||
Set<ArtifactReference> related = repoContent.getRelatedArtifacts( reference ); | |||
assertNotNull( related ); | |||
String expected[] = new String[]{ "org.apache.maven/jars/testing-1.0.jar", | |||
"org.apache.maven/java-sources/testing-1.0-sources.jar", | |||
"org.apache.maven/jars/testing-1.0-20050611.112233-1.jar", "org.apache.maven/poms/testing-1.0.pom", | |||
"org.apache.maven/distributions/testing-1.0.tar.gz", "org.apache.maven/distributions/testing-1.0.zip", | |||
"org.apache.maven/javadoc.jars/testing-1.0-javadoc.jar" }; | |||
StringBuilder relatedDebugString = new StringBuilder(); | |||
relatedDebugString.append( "[" ); | |||
for ( ArtifactReference ref : related ) | |||
{ | |||
String actualPath = repoContent.toPath( ref ); | |||
relatedDebugString.append( actualPath ).append( ":" ); | |||
} | |||
relatedDebugString.append( "]" ); | |||
for ( String expectedPath : expected ) | |||
{ | |||
boolean found = false; | |||
for ( ArtifactReference actualRef : related ) | |||
{ | |||
String actualPath = repoContent.toPath( actualRef ); | |||
if ( actualPath.endsWith( expectedPath ) ) | |||
{ | |||
found = true; | |||
break; | |||
} | |||
} | |||
if ( !found ) | |||
{ | |||
fail( "Unable to find expected artifact [" + expectedPath + "] in list of related artifacts. " | |||
+ "Related <" + relatedDebugString + ">" ); | |||
} | |||
} | |||
assertEquals( "Related <" + relatedDebugString + ">:", expected.length, related.size() ); | |||
} | |||
@Override | |||
protected ArtifactReference toArtifactReference( String path ) | |||
throws LayoutException | |||
{ | |||
return repoContent.toArtifactReference( path ); | |||
} | |||
@Override | |||
protected String toPath( ArtifactReference reference ) | |||
{ | |||
return repoContent.toPath( reference ); | |||
} | |||
} |
@@ -1,68 +0,0 @@ | |||
package org.apache.archiva.metadata.repository.storage.maven2; | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
* distributed with this work for additional information | |||
* regarding copyright ownership. The ASF licenses this file | |||
* to you under the Apache License, Version 2.0 (the | |||
* "License"); you may not use this file except in compliance | |||
* with the License. You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, | |||
* software distributed under the License is distributed on an | |||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
* KIND, either express or implied. See the License for the | |||
* specific language governing permissions and limitations | |||
* under the License. | |||
*/ | |||
import org.apache.archiva.admin.model.beans.RemoteRepository; | |||
import org.apache.archiva.model.ArtifactReference; | |||
import org.apache.archiva.repository.RemoteRepositoryContent; | |||
import org.apache.archiva.repository.layout.LayoutException; | |||
import org.junit.Before; | |||
import javax.inject.Inject; | |||
import javax.inject.Named; | |||
/** | |||
* RemoteLegacyRepositoryContentTest | |||
* | |||
* | |||
*/ | |||
public class RemoteLegacyRepositoryContentTest | |||
extends AbstractLegacyRepositoryContentTestCase | |||
{ | |||
@Inject | |||
@Named( "remoteRepositoryContent#legacy" ) | |||
private RemoteRepositoryContent repoContent; | |||
@Before | |||
public void setUp() | |||
throws Exception | |||
{ | |||
RemoteRepository repository = | |||
createRemoteRepository( "testRemoteLegacyRepo", "Unit Test Remote Legacy Repo", | |||
"http://repo1.maven.org/maven/" ); | |||
repository.setLayout( "legacy" ); | |||
//repoContent = (RemoteRepositoryContent) lookup( RemoteRepositoryContent.class, "legacy" ); | |||
repoContent.setRepository( repository ); | |||
} | |||
@Override | |||
protected ArtifactReference toArtifactReference( String path ) | |||
throws LayoutException | |||
{ | |||
return repoContent.toArtifactReference( path ); | |||
} | |||
@Override | |||
protected String toPath( ArtifactReference reference ) | |||
{ | |||
return repoContent.toPath( reference ); | |||
} | |||
} |
@@ -0,0 +1,99 @@ | |||
package org.apache.archiva.repository; | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
* distributed with this work for additional information | |||
* regarding copyright ownership. The ASF licenses this file | |||
* to you under the Apache License, Version 2.0 (the | |||
* "License"); you may not use this file except in compliance | |||
* with the License. You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, | |||
* software distributed under the License is distributed on an | |||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
* KIND, either express or implied. See the License for the | |||
* specific language governing permissions and limitations | |||
* under the License. | |||
*/ | |||
import org.apache.archiva.admin.model.beans.ManagedRepository; | |||
import org.apache.archiva.admin.model.beans.RemoteRepository; | |||
import org.junit.Rule; | |||
import org.junit.rules.TestName; | |||
import org.junit.runner.RunWith; | |||
import org.springframework.context.ApplicationContext; | |||
import org.springframework.test.context.ContextConfiguration; | |||
import java.io.File; | |||
import javax.inject.Inject; | |||
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner; | |||
/** | |||
* AbstractRepositoryLayerTestCase | |||
* | |||
* | |||
*/ | |||
@RunWith( ArchivaSpringJUnit4ClassRunner.class ) | |||
@ContextConfiguration( { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context-no-mock-conf.xml" } ) | |||
public abstract class AbstractRepositoryLayerTestCase | |||
{ | |||
@Rule | |||
public TestName name = new TestName(); | |||
@Inject | |||
protected ApplicationContext applicationContext; | |||
protected ManagedRepository createRepository( String id, String name, File location ) | |||
{ | |||
ManagedRepository repo = new ManagedRepository(); | |||
repo.setId( id ); | |||
repo.setName( name ); | |||
repo.setLocation( location.getAbsolutePath() ); | |||
return repo; | |||
} | |||
protected RemoteRepository createRemoteRepository( String id, String name, String url ) | |||
{ | |||
RemoteRepository repo = new RemoteRepository(); | |||
repo.setId( id ); | |||
repo.setName( name ); | |||
repo.setUrl( url ); | |||
return repo; | |||
} | |||
protected ManagedRepositoryContent createManagedRepositoryContent( String id, String name, File location, | |||
String layout ) | |||
throws Exception | |||
{ | |||
ManagedRepository repo = new ManagedRepository(); | |||
repo.setId( id ); | |||
repo.setName( name ); | |||
repo.setLocation( location.getAbsolutePath() ); | |||
repo.setLayout( layout ); | |||
ManagedRepositoryContent repoContent = | |||
applicationContext.getBean( "managedRepositoryContent#" + layout, ManagedRepositoryContent.class ); | |||
repoContent.setRepository( repo ); | |||
return repoContent; | |||
} | |||
protected RemoteRepositoryContent createRemoteRepositoryContent( String id, String name, String url, String layout ) | |||
throws Exception | |||
{ | |||
RemoteRepository repo = new RemoteRepository(); | |||
repo.setId( id ); | |||
repo.setName( name ); | |||
repo.setUrl( url ); | |||
repo.setLayout( layout ); | |||
RemoteRepositoryContent repoContent = | |||
applicationContext.getBean( "remoteRepositoryContent#" + layout, RemoteRepositoryContent.class ); | |||
repoContent.setRepository( repo ); | |||
return repoContent; | |||
} | |||
} |
@@ -24,7 +24,6 @@ import org.apache.archiva.common.utils.FileUtil; | |||
import org.apache.archiva.configuration.ArchivaConfiguration; | |||
import org.apache.archiva.model.ArtifactReference; | |||
import org.apache.archiva.repository.ManagedRepositoryContent; | |||
import org.apache.archiva.repository.content.legacy.LegacyPathParser; | |||
import org.apache.archiva.repository.layout.LayoutException; | |||
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner; | |||
import org.apache.commons.lang.StringUtils; | |||
@@ -43,9 +42,9 @@ import static org.junit.Assert.*; | |||
/** | |||
* RepositoryRequestTest | |||
*/ | |||
@RunWith ( ArchivaSpringJUnit4ClassRunner.class ) | |||
@ContextConfiguration ( | |||
{ "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context-repo-request-test.xml" } ) | |||
@RunWith( ArchivaSpringJUnit4ClassRunner.class ) | |||
@ContextConfiguration( { "classpath*:/META-INF/spring-context.xml", | |||
"classpath:/spring-context-repo-request-test.xml" } ) | |||
public class RepositoryRequestTest | |||
{ | |||
@@ -53,7 +52,7 @@ public class RepositoryRequestTest | |||
protected ApplicationContext applicationContext; | |||
@Inject | |||
@Named ( "archivaConfiguration#repo-request-test" ) | |||
@Named( "archivaConfiguration#repo-request-test" ) | |||
private ArchivaConfiguration archivaConfiguration; | |||
private RepositoryRequest repoRequest; | |||
@@ -62,8 +61,7 @@ public class RepositoryRequestTest | |||
public void setUp() | |||
throws Exception | |||
{ | |||
LegacyPathParser legacyPathParser = new LegacyPathParser( archivaConfiguration ); | |||
repoRequest = new RepositoryRequest( legacyPathParser ); | |||
repoRequest = new RepositoryRequest(); | |||
} | |||
@Test | |||
@@ -84,11 +82,6 @@ public class RepositoryRequestTest | |||
assertInvalidRequest( "groupId/jars/-1.0.jar" ); | |||
} | |||
@Test | |||
public void testInvalidLegacyRequestBadLocation() | |||
{ | |||
assertInvalidRequest( "org.apache.maven.test/jars/artifactId-1.0.war" ); | |||
} | |||
@Test | |||
public void testInvalidRequestTooShort() | |||
@@ -102,7 +95,7 @@ public class RepositoryRequestTest | |||
assertInvalidRequest( "invalid/invalid/1.0-20050611.123456-1/invalid-1.0-20050611.123456-1.jar" ); | |||
} | |||
@Test | |||
@Test( expected = LayoutException.class ) | |||
public void testValidLegacyGanymed() | |||
throws Exception | |||
{ | |||
@@ -118,7 +111,7 @@ public class RepositoryRequestTest | |||
"ganymed-ssh2", "build210", null, "jar" ); | |||
} | |||
@Test | |||
@Test( expected = LayoutException.class ) | |||
public void testValidLegacyJavaxComm() | |||
throws Exception | |||
{ | |||
@@ -132,7 +125,7 @@ public class RepositoryRequestTest | |||
assertValid( "javax/comm/3.0-u1/comm-3.0-u1.jar", "javax", "comm", "3.0-u1", null, "jar" ); | |||
} | |||
@Test | |||
@Test( expected = LayoutException.class ) | |||
public void testValidLegacyJavaxPersistence() | |||
throws Exception | |||
{ | |||
@@ -148,7 +141,7 @@ public class RepositoryRequestTest | |||
"3.0-public_review", null, "jar" ); | |||
} | |||
@Test | |||
@Test( expected = LayoutException.class ) | |||
public void testValidLegacyMavenTestPlugin() | |||
throws Exception | |||
{ | |||
@@ -163,7 +156,7 @@ public class RepositoryRequestTest | |||
null, "pom" ); | |||
} | |||
@Test | |||
@Test( expected = LayoutException.class ) | |||
public void testValidLegacyCommonsLangJavadoc() | |||
throws Exception | |||
{ | |||
@@ -179,7 +172,7 @@ public class RepositoryRequestTest | |||
"2.1", "javadoc", "javadoc" ); | |||
} | |||
@Test | |||
@Test( expected = LayoutException.class ) | |||
public void testValidLegacyDerbyPom() | |||
throws Exception | |||
{ | |||
@@ -197,7 +190,7 @@ public class RepositoryRequestTest | |||
null, "pom" ); | |||
} | |||
@Test | |||
@Test( expected = LayoutException.class ) | |||
public void testValidLegacyGeronimoEjbSpec() | |||
throws Exception | |||
{ | |||
@@ -213,7 +206,7 @@ public class RepositoryRequestTest | |||
"org.apache.geronimo.specs", "geronimo-ejb_2.1_spec", "1.0.1", null, "jar" ); | |||
} | |||
@Test | |||
@Test( expected = LayoutException.class ) | |||
public void testValidLegacyLdapSnapshot() | |||
throws Exception | |||
{ | |||
@@ -229,7 +222,7 @@ public class RepositoryRequestTest | |||
"directory-clients", "ldap-clients", "0.9.1-SNAPSHOT", null, "pom" ); | |||
} | |||
@Test | |||
@Test( expected = LayoutException.class ) | |||
public void testValidLegacyTestArchSnapshot() | |||
throws Exception | |||
{ | |||
@@ -245,7 +238,7 @@ public class RepositoryRequestTest | |||
"test-arch", "2.0.3-SNAPSHOT", null, "pom" ); | |||
} | |||
@Test | |||
@Test( expected = LayoutException.class ) | |||
public void testValidLegacyOddDottedArtifactId() | |||
throws Exception | |||
{ | |||
@@ -261,7 +254,7 @@ public class RepositoryRequestTest | |||
"com.company.department", "com.company.department.project", "0.2", null, "pom" ); | |||
} | |||
@Test | |||
@Test( expected = LayoutException.class ) | |||
public void testValidLegacyTimestampedSnapshot() | |||
throws Exception | |||
{ | |||
@@ -394,22 +387,6 @@ public class RepositoryRequestTest | |||
repository ) ); | |||
} | |||
/** | |||
* [MRM-481] Artifact requests with a .xml.zip extension fail with a 404 Error | |||
*/ | |||
@Test | |||
public void testToNativePathArtifactLegacyToDefaultDualExtension() | |||
throws Exception | |||
{ | |||
ManagedRepositoryContent repository = createManagedRepo( "default" ); | |||
// TODO: this is a good test case for maven 1 -> maven 2 link, since m2 doesn't support the distribution-zip type | |||
// Test (artifact) legacy to default - dual extension | |||
// NOTE: The detection of a dual extension is flawed. | |||
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 ) ); | |||
} | |||
@Test | |||
public void testToNativePathMetadataDefaultToDefault() | |||
@@ -423,71 +400,6 @@ public class RepositoryRequestTest | |||
repository ) ); | |||
} | |||
@Test | |||
public void testNativePathPomLegacyToDefault() | |||
throws Exception | |||
{ | |||
ManagedRepositoryContent repository = createManagedRepo( "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 ) ); | |||
} | |||
@Test | |||
public void testNativePathPomLegacyToLegacy() | |||
throws Exception | |||
{ | |||
ManagedRepositoryContent repository = createManagedRepo( "legacy" ); | |||
// Test (pom) legacy to default | |||
assertEquals( "org.apache.derby/poms/derby-10.2.2.0.pom", | |||
repoRequest.toNativePath( "org.apache.derby/poms/derby-10.2.2.0.pom", repository ) ); | |||
} | |||
@Test | |||
public void testNativePathPomLegacyToDefaultEjb() | |||
throws Exception | |||
{ | |||
ManagedRepositoryContent repository = createManagedRepo( "default" ); | |||
// Test (pom) legacy to default | |||
String result = repoRequest.toNativePath( "mygroup/ejbs/myejb-1.0.jar", repository ); | |||
assertEquals( "mygroup/myejb/1.0/myejb-1.0.jar", result ); | |||
} | |||
@Test | |||
public void testNativePathPomLegacyToLegacyEjb() | |||
throws Exception | |||
{ | |||
ManagedRepositoryContent repository = createManagedRepo( "legacy" ); | |||
// Test (pom) legacy to default | |||
assertEquals( "mygroup/ejbs/myejb-1.0.jar", | |||
repoRequest.toNativePath( "mygroup/ejbs/myejb-1.0.jar", repository ) ); | |||
} | |||
@Test | |||
public void testNativePathPomLegacyToLegacyStrutsModule() | |||
throws Exception | |||
{ | |||
ManagedRepositoryContent repository = createManagedRepo( "legacy" ); | |||
// Test (pom) legacy to default | |||
assertEquals( "WebPortal/struts-modules/eventsDB-1.2.3.struts-module", | |||
repoRequest.toNativePath( "WebPortal/struts-modules/eventsDB-1.2.3.struts-module", repository ) ); | |||
} | |||
@Test | |||
public void testNativePathSupportFileLegacyToDefault() | |||
throws Exception | |||
{ | |||
ManagedRepositoryContent repository = createManagedRepo( "default" ); | |||
// Test (supportfile) legacy to default | |||
assertEquals( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0.jar.sha1", | |||
repoRequest.toNativePath( "org.apache.derby/jars/derby-10.2.2.0.jar.sha1", repository ) ); | |||
} | |||
@Test | |||
public void testNativePathBadRequestTooShort() | |||
@@ -561,48 +473,6 @@ public class RepositoryRequestTest | |||
} | |||
} | |||
@Test | |||
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 | |||
{ | |||
repoRequest.toNativePath( "org/apache/derby/derby/10.2.2.0/maven-metadata.xml", repository ); | |||
fail( "Should have thrown a LayoutException, can't translate a maven-metadata.xml to a legacy layout." ); | |||
} | |||
catch ( LayoutException e ) | |||
{ | |||
// expected path. | |||
} | |||
} | |||
@Test | |||
public void testNativePathPomDefaultToLegacy() | |||
throws Exception | |||
{ | |||
ManagedRepositoryContent repository = createManagedRepo( "legacy" ); | |||
// Test (pom) default to legacy | |||
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 ) ); | |||
} | |||
@Test | |||
public void testNativePathSupportFileDefaultToLegacy() | |||
throws Exception | |||
{ | |||
ManagedRepositoryContent repository = createManagedRepo( "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 ) ); | |||
} | |||
private void assertValid( String path, String groupId, String artifactId, String version, String classifier, | |||
String type ) |