1 package org.apache.maven.archiva.proxy;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import org.apache.maven.archiva.model.ArtifactReference;
23 import org.apache.maven.archiva.policies.CachedFailuresPolicy;
24 import org.apache.maven.archiva.policies.ChecksumPolicy;
25 import org.apache.maven.archiva.policies.ReleasesPolicy;
26 import org.apache.maven.archiva.policies.SnapshotsPolicy;
31 * ManagedLegacyTransferTest
33 * @author Brett Porter
34 * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
37 public class ManagedLegacyTransferTest
38 extends AbstractProxyTestCase
40 public void testLegacyManagedRepoGetNotPresent()
43 String path = "org.apache.maven.test/jars/get-default-layout-1.0.jar";
44 File expectedFile = new File( managedLegacyDir, path );
45 ArtifactReference artifact = createArtifactReference( "legacy", path );
47 expectedFile.delete();
48 assertFalse( expectedFile.exists() );
50 // Configure Connector (usually done within archiva.xml configuration)
51 saveConnector( ID_LEGACY_MANAGED, ID_PROXIED1, ChecksumPolicy.FIX, ReleasesPolicy.IGNORED,
52 SnapshotsPolicy.IGNORED, CachedFailuresPolicy.IGNORED );
54 File downloadedFile = proxyHandler.fetchFromProxies( managedLegacyRepository, artifact );
56 File proxied2File = new File( REPOPATH_PROXIED1,
57 "org/apache/maven/test/get-default-layout/1.0/get-default-layout-1.0.jar" );
58 assertFileEquals( expectedFile, downloadedFile, proxied2File );
59 assertNoTempFiles( expectedFile );
61 // TODO: timestamp preservation requires support for that in wagon
62 // assertEquals( "Check file timestamp", proxiedFile.lastModified(), file.lastModified() );
65 public void testLegacyManagedRepoGetAlreadyPresent()
68 String path = "org.apache.maven.test/jars/get-default-layout-present-1.0.jar";
69 File expectedFile = new File( managedLegacyDir, path );
70 ArtifactReference artifact = createArtifactReference( "legacy", path );
72 assertTrue( expectedFile.exists() );
74 // Configure Connector (usually done within archiva.xml configuration)
75 saveConnector( ID_LEGACY_MANAGED, ID_PROXIED1, ChecksumPolicy.FIX, ReleasesPolicy.IGNORED,
76 SnapshotsPolicy.IGNORED, CachedFailuresPolicy.IGNORED );
78 File downloadedFile = proxyHandler.fetchFromProxies( managedLegacyRepository, artifact );
80 File proxied2File = new File( REPOPATH_PROXIED1,
81 "org/apache/maven/test/get-default-layout-present/1.0/get-default-layout-present-1.0.jar" );
82 assertFileEquals( expectedFile, downloadedFile, proxied2File );
83 assertNoTempFiles( expectedFile );
86 public void testLegacyManagedAndProxyRepoGetNotPresent()
89 String path = "org.apache.maven.test/jars/get-default-layout-1.0.jar";
90 File expectedFile = new File( managedLegacyDir, path );
91 ArtifactReference artifact = createArtifactReference( "legacy", path );
93 assertFalse( expectedFile.exists() );
95 // Configure Connector (usually done within archiva.xml configuration)
96 saveConnector( ID_LEGACY_MANAGED, ID_LEGACY_PROXIED, ChecksumPolicy.IGNORED, ReleasesPolicy.IGNORED,
97 SnapshotsPolicy.IGNORED, CachedFailuresPolicy.IGNORED );
99 File downloadedFile = proxyHandler.fetchFromProxies( managedLegacyRepository, artifact );
101 File proxiedFile = new File( REPOPATH_PROXIED_LEGACY, path );
102 assertFileEquals( expectedFile, downloadedFile, proxiedFile );
103 assertNoTempFiles( expectedFile );
105 // TODO: timestamp preservation requires support for that in wagon
106 // assertEquals( "Check file timestamp", proxiedFile.lastModified(), file.lastModified() );
109 public void testLegacyManagedAndProxyRepoGetAlreadyPresent()
112 String path = "org.apache.maven.test/jars/get-default-layout-present-1.0.jar";
113 File expectedFile = new File( managedLegacyDir, path );
114 ArtifactReference artifact = createArtifactReference( "legacy", path );
116 assertTrue( expectedFile.exists() );
118 // Configure Connector (usually done within archiva.xml configuration)
119 saveConnector( ID_LEGACY_MANAGED, ID_LEGACY_PROXIED, ChecksumPolicy.IGNORED, ReleasesPolicy.IGNORED,
120 SnapshotsPolicy.IGNORED, CachedFailuresPolicy.IGNORED );
122 File downloadedFile = proxyHandler.fetchFromProxies( managedLegacyRepository, artifact );
124 File proxiedFile = new File( REPOPATH_PROXIED_LEGACY, path );
125 assertFileEquals( expectedFile, downloadedFile, proxiedFile );
126 assertNoTempFiles( expectedFile );
129 public void testDefaultRequestConvertedToLegacyPathInManagedRepo()
132 // Check that a Maven2 default request is translated to a legacy path in
133 // the managed repository.
135 String legacyPath = "org.apache.maven.test/jars/get-default-layout-present-1.0.jar";
136 String path = "org/apache/maven/test/get-default-layout-present/1.0/get-default-layout-present-1.0.jar";
137 File expectedFile = new File( managedLegacyDir, legacyPath );
138 ArtifactReference artifact = createArtifactReference( "legacy", legacyPath );
140 expectedFile.delete();
141 assertFalse( expectedFile.exists() );
143 // Configure Connector (usually done within archiva.xml configuration)
144 saveConnector( ID_LEGACY_MANAGED, ID_PROXIED1, ChecksumPolicy.IGNORED, ReleasesPolicy.IGNORED,
145 SnapshotsPolicy.IGNORED, CachedFailuresPolicy.IGNORED );
147 File downloadedFile = proxyHandler.fetchFromProxies( managedLegacyRepository, artifact );
149 File proxiedFile = new File( REPOPATH_PROXIED1, path );
150 assertFileEquals( expectedFile, downloadedFile, proxiedFile );
151 assertNoTempFiles( expectedFile );