diff options
author | Brett Porter <brett@apache.org> | 2006-09-01 04:21:20 +0000 |
---|---|---|
committer | Brett Porter <brett@apache.org> | 2006-09-01 04:21:20 +0000 |
commit | b16695cf64c0fe6ff2a3b7fd9bff5adbbfe23db3 (patch) | |
tree | 345e70bf94e9336f5efea0be5bd777d847dc0902 /archiva-proxy/src/test | |
parent | 2102fd5298e06f0197d3eef290abf9f3b311409c (diff) | |
download | archiva-b16695cf64c0fe6ff2a3b7fd9bff5adbbfe23db3.tar.gz archiva-b16695cf64c0fe6ff2a3b7fd9bff5adbbfe23db3.zip |
[MRM-153] handle relocation of artifacts
Submitted by: Nicolas de Loof (applied with changes)
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@439168 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-proxy/src/test')
9 files changed, 256 insertions, 0 deletions
diff --git a/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ProxyRequestHandlerTest.java b/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ProxyRequestHandlerTest.java index a1c9da8ff..c82a9bfc5 100644 --- a/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ProxyRequestHandlerTest.java +++ b/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ProxyRequestHandlerTest.java @@ -1624,6 +1624,136 @@ public class ProxyRequestHandlerTest assertEquals( "Check file matches", expectedFile, file ); } + public void testRelocateMaven1Request() + throws IOException, ResourceDoesNotExistException, ProxyException + { + String path = "org.apache.maven.test/jars/get-relocated-artefact-1.0.jar"; + String relocatedPath = + "org/apache/maven/test/get-default-layout-present/1.0/get-default-layout-present-1.0.jar"; + File expectedFile = new File( defaultManagedRepository.getBasedir(), relocatedPath ); + + assertTrue( expectedFile.exists() ); + + File file = requestHandler.get( path, proxiedRepositories, defaultManagedRepository ); + + assertEquals( "Check file matches", expectedFile, file ); + } + + public void testDoublyRelocateMaven1Request() + throws IOException, ResourceDoesNotExistException, ProxyException + { + String path = "org.apache.maven.test/jars/get-doubly-relocated-artefact-1.0.jar"; + String relocatedPath = + "org/apache/maven/test/get-default-layout-present/1.0/get-default-layout-present-1.0.jar"; + File expectedFile = new File( defaultManagedRepository.getBasedir(), relocatedPath ); + + assertTrue( expectedFile.exists() ); + + File file = requestHandler.get( path, proxiedRepositories, defaultManagedRepository ); + + assertEquals( "Check file matches", expectedFile, file ); + } + + public void testRelocateMaven1PomRequest() + throws IOException, ResourceDoesNotExistException, ProxyException + { + String path = "org.apache.maven.test/poms/get-relocated-artefact-with-pom-1.0.pom"; + String relocatedPath = + "org/apache/maven/test/get-default-layout-present-with-pom/1.0/get-default-layout-present-with-pom-1.0.pom"; + File expectedFile = new File( defaultManagedRepository.getBasedir(), relocatedPath ); + + assertTrue( expectedFile.exists() ); + + File file = requestHandler.get( path, proxiedRepositories, defaultManagedRepository ); + + assertEquals( "Check file matches", expectedFile, file ); + + assertTrue( expectedFile.exists() ); + } + + public void testRelocateMaven1PomRequestMissingTarget() + throws IOException, ResourceDoesNotExistException, ProxyException + { + String path = "org.apache.maven.test/poms/get-relocated-artefact-1.0.pom"; + String relocatedPath = + "org/apache/maven/test/get-default-layout-present/1.0/get-default-layout-present-1.0.pom"; + File expectedFile = new File( defaultManagedRepository.getBasedir(), relocatedPath ); + + assertFalse( expectedFile.exists() ); + + try + { + requestHandler.get( path, proxiedRepositories, defaultManagedRepository ); + fail( "Should have failed to find target POM" ); + } + catch ( ResourceDoesNotExistException e ) + { + assertTrue( true ); + } + } + + public void testRelocateMaven1ChecksumRequest() + throws IOException, ResourceDoesNotExistException, ProxyException + { + String path = "org.apache.maven.test/jars/get-relocated-artefact-1.0.jar.md5"; + String relocatedPath = + "org/apache/maven/test/get-default-layout-present/1.0/get-default-layout-present-1.0.jar.md5"; + File expectedFile = new File( defaultManagedRepository.getBasedir(), relocatedPath ); + + assertTrue( expectedFile.exists() ); + + File file = requestHandler.get( path, proxiedRepositories, defaultManagedRepository ); + + assertEquals( "Check file matches", expectedFile, file ); + + assertTrue( expectedFile.exists() ); + + path = "org.apache.maven.test/jars/get-relocated-artefact-1.0.jar.sha1"; + relocatedPath = "org/apache/maven/test/get-default-layout-present/1.0/get-default-layout-present-1.0.jar.sha1"; + expectedFile = new File( defaultManagedRepository.getBasedir(), relocatedPath ); + + assertFalse( expectedFile.exists() ); + + try + { + requestHandler.get( path, proxiedRepositories, defaultManagedRepository ); + fail( "Checksum was not present, should not be found" ); + } + catch ( ResourceDoesNotExistException e ) + { + assertTrue( true ); + } + } + + public void testRelocateMaven2Request() + throws IOException, ResourceDoesNotExistException, ProxyException + { + String path = "org/apache/maven/test/get-relocated-artefact/1.0/get-relocated-artefact-1.0.jar"; + String relocatedPath = + "org/apache/maven/test/get-default-layout-present/1.0/get-default-layout-present-1.0.jar"; + File expectedFile = new File( defaultManagedRepository.getBasedir(), relocatedPath ); + + assertTrue( expectedFile.exists() ); + + File file = requestHandler.get( path, proxiedRepositories, defaultManagedRepository ); + + assertEquals( "Check file matches", expectedFile, file ); + } + + public void testRelocateMaven2RequestInLegacyManagedRepo() + throws IOException, ResourceDoesNotExistException, ProxyException + { + String path = "org/apache/maven/test/get-relocated-artefact/1.0/get-relocated-artefact-1.0.jar"; + String relocatedPath = "org.apache.maven.test/jars/get-default-layout-present-1.0.jar"; + File expectedFile = new File( legacyManagedRepository.getBasedir(), relocatedPath ); + + assertTrue( expectedFile.exists() ); + + File file = requestHandler.get( path, proxiedRepositories, legacyManagedRepository ); + + assertEquals( "Check file matches", expectedFile, file ); + } + private static Versioning getVersioning( List versions ) { Versioning versioning = new Versioning(); diff --git a/archiva-proxy/src/test/repositories/legacy-managed/org.apache.maven.test/jars/get-default-layout-present-1.0.jar.md5 b/archiva-proxy/src/test/repositories/legacy-managed/org.apache.maven.test/jars/get-default-layout-present-1.0.jar.md5 new file mode 100644 index 000000000..b597d8ce4 --- /dev/null +++ b/archiva-proxy/src/test/repositories/legacy-managed/org.apache.maven.test/jars/get-default-layout-present-1.0.jar.md5 @@ -0,0 +1 @@ +7dfb7ade9a8fa90bfbfac52d3090b8c2 *get-default-layout-present-1.0.jar diff --git a/archiva-proxy/src/test/repositories/legacy-managed/org.apache.maven.test/poms/get-relocated-artefact-1.0.pom b/archiva-proxy/src/test/repositories/legacy-managed/org.apache.maven.test/poms/get-relocated-artefact-1.0.pom new file mode 100644 index 000000000..a1f78ac5e --- /dev/null +++ b/archiva-proxy/src/test/repositories/legacy-managed/org.apache.maven.test/poms/get-relocated-artefact-1.0.pom @@ -0,0 +1,29 @@ +<!-- + ~ Copyright 2005-2006 The Apache Software Foundation. + ~ + ~ Licensed 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. + --> + +<project> + <modelVersion>4.0.0</modelVersion> + <groupId>org.apache.maven.test</groupId> + <artifactId>get-relocated-artefact</artifactId> + <version>1.0</version> + + <distributionManagement> + <relocation> + <artifactId>get-default-layout-present</artifactId> + </relocation> + </distributionManagement> + +</project>
\ No newline at end of file diff --git a/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-default-layout-present-with-pom/1.0/get-default-layout-present-with-pom-1.0.jar b/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-default-layout-present-with-pom/1.0/get-default-layout-present-with-pom-1.0.jar new file mode 100644 index 000000000..a3b38382c --- /dev/null +++ b/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-default-layout-present-with-pom/1.0/get-default-layout-present-with-pom-1.0.jar @@ -0,0 +1,3 @@ +get-default-layout-present-1.0.jar +(managed) + diff --git a/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-default-layout-present-with-pom/1.0/get-default-layout-present-with-pom-1.0.pom b/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-default-layout-present-with-pom/1.0/get-default-layout-present-with-pom-1.0.pom new file mode 100644 index 000000000..1806ff09f --- /dev/null +++ b/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-default-layout-present-with-pom/1.0/get-default-layout-present-with-pom-1.0.pom @@ -0,0 +1,21 @@ +<!-- + ~ Copyright 2005-2006 The Apache Software Foundation. + ~ + ~ Licensed 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. + --> + +<project> + <groupId>org.apache.maven.test</groupId> + <artifactId>get-default-layout-present-with-pom</artifactId> + <version>1.0</version> +</project> diff --git a/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-default-layout-present/1.0/get-default-layout-present-1.0.jar.md5 b/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-default-layout-present/1.0/get-default-layout-present-1.0.jar.md5 new file mode 100644 index 000000000..b597d8ce4 --- /dev/null +++ b/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-default-layout-present/1.0/get-default-layout-present-1.0.jar.md5 @@ -0,0 +1 @@ +7dfb7ade9a8fa90bfbfac52d3090b8c2 *get-default-layout-present-1.0.jar diff --git a/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-doubly-relocated-artefact/1.0/get-doubly-relocated-artefact-1.0.pom b/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-doubly-relocated-artefact/1.0/get-doubly-relocated-artefact-1.0.pom new file mode 100644 index 000000000..fb10d7878 --- /dev/null +++ b/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-doubly-relocated-artefact/1.0/get-doubly-relocated-artefact-1.0.pom @@ -0,0 +1,29 @@ +<!-- + ~ Copyright 2005-2006 The Apache Software Foundation. + ~ + ~ Licensed 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. + --> + +<project> + <modelVersion>4.0.0</modelVersion> + <groupId>org.apache.maven.test</groupId> + <artifactId>get-doubly-relocated-artefact</artifactId> + <version>1.0</version> + + <distributionManagement> + <relocation> + <artifactId>get-relocated-artefact</artifactId> + </relocation> + </distributionManagement> + +</project>
\ No newline at end of file diff --git a/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-relocated-artefact-with-pom/1.0/get-relocated-artefact-with-pom-1.0.pom b/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-relocated-artefact-with-pom/1.0/get-relocated-artefact-with-pom-1.0.pom new file mode 100644 index 000000000..dd65f7b81 --- /dev/null +++ b/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-relocated-artefact-with-pom/1.0/get-relocated-artefact-with-pom-1.0.pom @@ -0,0 +1,29 @@ +<!-- + ~ Copyright 2005-2006 The Apache Software Foundation. + ~ + ~ Licensed 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. + --> + +<project> + <modelVersion>4.0.0</modelVersion> + <groupId>org.apache.maven.test</groupId> + <artifactId>get-relocated-artefact-with-pom</artifactId> + <version>1.0</version> + + <distributionManagement> + <relocation> + <artifactId>get-default-layout-present-with-pom</artifactId> + </relocation> + </distributionManagement> + +</project>
\ No newline at end of file diff --git a/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-relocated-artefact/1.0/get-relocated-artefact-1.0.pom b/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-relocated-artefact/1.0/get-relocated-artefact-1.0.pom new file mode 100644 index 000000000..48513de0b --- /dev/null +++ b/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/get-relocated-artefact/1.0/get-relocated-artefact-1.0.pom @@ -0,0 +1,13 @@ +<project> + <modelVersion>4.0.0</modelVersion> + <groupId>org.apache.maven.test</groupId> + <artifactId>get-relocated-artefact</artifactId> + <version>1.0</version> + + <distributionManagement> + <relocation> + <artifactId>get-default-layout-present</artifactId> + </relocation> + </distributionManagement> + +</project>
\ No newline at end of file |