1 package org.apache.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.archiva.model.ArtifactReference;
23 import org.apache.archiva.policies.CachedFailuresPolicy;
24 import org.apache.archiva.policies.ChecksumPolicy;
25 import org.apache.archiva.policies.ReleasesPolicy;
26 import org.apache.archiva.policies.SnapshotsPolicy;
27 import org.junit.Test;
31 import static org.junit.Assert.assertTrue;
34 * ManagedLegacyTransferTest
38 public class ManagedLegacyTransferTest
39 extends AbstractProxyTestCase
42 * Incoming request on a Managed Legacy repository, for content that does not
43 * exist in the managed legacy repository, but does exist on a remote default layout repository.
46 public void testManagedLegacyNotPresentRemoteDefaultPresent()
49 String path = "org.apache.maven.test/jars/get-default-layout-1.0.jar";
50 File expectedFile = new File( managedLegacyDir, path );
51 ArtifactReference artifact = managedLegacyRepository.toArtifactReference( path );
53 assertNotExistsInManagedLegacyRepo( expectedFile );
55 // Configure Connector (usually done within archiva.xml configuration)
56 saveConnector( ID_LEGACY_MANAGED, ID_PROXIED1, false );
58 File downloadedFile = proxyHandler.fetchFromProxies( managedLegacyRepository, artifact );
60 File proxied2File = new File( REPOPATH_PROXIED1,
61 "org/apache/maven/test/get-default-layout/1.0/get-default-layout-1.0.jar" );
62 assertFileEquals( expectedFile, downloadedFile, proxied2File );
63 assertNoTempFiles( expectedFile );
67 * Incoming request on a Managed Legacy repository, for content that already
68 * exist in the managed legacy repository, and also exist on a remote default layout repository.
71 public void testManagedLegacyPresentRemoteDefaultPresent()
74 String path = "org.apache.maven.test/jars/get-default-layout-present-1.0.jar";
75 String remotePath = "org/apache/maven/test/get-default-layout-present/1.0/get-default-layout-present-1.0.jar";
77 File expectedFile = new File( managedLegacyDir, path );
78 File remoteFile = new File( REPOPATH_PROXIED1, remotePath );
80 setManagedOlderThanRemote( expectedFile, remoteFile );
82 ArtifactReference artifact = managedLegacyRepository.toArtifactReference( path );
84 // Configure Connector (usually done within archiva.xml configuration)
85 saveConnector( ID_LEGACY_MANAGED, ID_PROXIED1, ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
86 SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
88 File downloadedFile = proxyHandler.fetchFromProxies( managedLegacyRepository, artifact );
90 assertFileEquals( expectedFile, downloadedFile, remoteFile );
91 assertNoTempFiles( expectedFile );
95 * Incoming request on a Managed Legacy repository, for content that does not
96 * exist in the managed legacy repository, and does not exist on a remote legacy layout repository.
99 public void testManagedLegacyNotPresentRemoteLegacyPresent()
102 String path = "org.apache.maven.test/plugins/get-legacy-plugin-1.0.jar";
103 File expectedFile = new File( managedLegacyDir, path );
104 ArtifactReference artifact = managedLegacyRepository.toArtifactReference( path );
106 assertNotExistsInManagedLegacyRepo( expectedFile );
108 // Configure Connector (usually done within archiva.xml configuration)
109 saveConnector( ID_LEGACY_MANAGED, ID_LEGACY_PROXIED, false );
111 File downloadedFile = proxyHandler.fetchFromProxies( managedLegacyRepository, artifact );
113 File proxiedFile = new File( REPOPATH_PROXIED_LEGACY, path );
114 assertFileEquals( expectedFile, downloadedFile, proxiedFile );
115 assertNoTempFiles( expectedFile );
119 * Incoming request on a Managed Legacy repository, for content that does exist in the
120 * managed legacy repository, and also exists on a remote legacy layout repository.
123 public void testManagedLegacyPresentRemoteLegacyPresent()
126 String path = "org.apache.maven.test/jars/get-default-layout-present-1.0.jar";
127 File expectedFile = new File( managedLegacyDir, path );
128 File remoteFile = new File( REPOPATH_PROXIED_LEGACY, path );
130 setManagedOlderThanRemote( expectedFile, remoteFile );
132 ArtifactReference artifact = managedLegacyRepository.toArtifactReference( path );
134 // Configure Connector (usually done within archiva.xml configuration)
135 saveConnector( ID_LEGACY_MANAGED, ID_LEGACY_PROXIED, false );
137 File downloadedFile = proxyHandler.fetchFromProxies( managedLegacyRepository, artifact );
139 assertFileEquals( expectedFile, downloadedFile, remoteFile );
140 assertNoTempFiles( expectedFile );
144 * Incoming request on a Managed Legacy repository, for content that does exist in the
145 * managed legacy repository, and does not exist on a remote legacy layout repository.
148 public void testManagedLegacyPresentRemoteLegacyNotPresent()
151 String path = "org.apache.maven.test/jars/managed-only-lib-2.1.jar";
152 File expectedFile = new File( managedLegacyDir, path );
153 ArtifactReference artifact = managedLegacyRepository.toArtifactReference( path );
155 assertTrue( expectedFile.exists() );
157 // Configure Connector (usually done within archiva.xml configuration)
158 saveConnector( ID_LEGACY_MANAGED, ID_LEGACY_PROXIED, false );
160 File downloadedFile = proxyHandler.fetchFromProxies( managedLegacyRepository, artifact );
162 assertNotDownloaded( downloadedFile );
163 assertNoTempFiles( expectedFile );
167 * Incoming request on a Managed Legacy repository, for content that does exist in the
168 * managed legacy repository, and does not exists on a remote default layout repository.
171 public void testManagedLegacyPresentRemoteDefaultNotPresent()
174 String path = "org.apache.maven.test/jars/managed-only-lib-2.1.jar";
175 File expectedFile = new File( managedLegacyDir, path );
176 ArtifactReference artifact = managedLegacyRepository.toArtifactReference( path );
178 assertTrue( expectedFile.exists() );
180 // Configure Connector (usually done within archiva.xml configuration)
181 saveConnector( ID_LEGACY_MANAGED, ID_PROXIED1, false );
183 File downloadedFile = proxyHandler.fetchFromProxies( managedLegacyRepository, artifact );
185 assertNotDownloaded( downloadedFile );
186 assertNoTempFiles( expectedFile );
190 * Incoming request on a Managed Legacy repository, for content that does not exist in the
191 * managed legacy repository, and does not exists on a remote legacy layout repository.
194 public void testManagedLegacyNotPresentRemoteLegacyNotPresent()
197 String path = "org.apache.archiva.test/jars/mystery-lib-1.0.jar";
198 File expectedFile = new File( managedLegacyDir, path );
199 ArtifactReference artifact = managedLegacyRepository.toArtifactReference( path );
201 assertNotExistsInManagedLegacyRepo( expectedFile );
203 // Configure Connector (usually done within archiva.xml configuration)
204 saveConnector( ID_LEGACY_MANAGED, ID_LEGACY_PROXIED, false );
206 File downloadedFile = proxyHandler.fetchFromProxies( managedLegacyRepository, artifact );
208 assertNotDownloaded( downloadedFile );
209 assertNoTempFiles( expectedFile );
213 * Incoming request on a Managed Legacy repository, for content that does not exist in the
214 * managed legacy repository, and does not exists on a remote default layout repository.
217 public void testManagedLegacyNotPresentRemoteDefaultNotPresent()
220 String path = "org.apache.archiva.test/jars/mystery-lib-2.1.jar";
221 File expectedFile = new File( managedLegacyDir, path );
222 ArtifactReference artifact = managedLegacyRepository.toArtifactReference( path );
224 assertNotExistsInManagedLegacyRepo( expectedFile );
226 // Configure Connector (usually done within archiva.xml configuration)
227 saveConnector( ID_LEGACY_MANAGED, ID_PROXIED1, false );
229 File downloadedFile = proxyHandler.fetchFromProxies( managedLegacyRepository, artifact );
231 assertNotDownloaded( downloadedFile );
232 assertNoTempFiles( expectedFile );