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;
27 import org.junit.Test;
32 * ManagedLegacyTransferTest
36 public class ManagedLegacyTransferTest
37 extends AbstractProxyTestCase
40 * Incoming request on a Managed Legacy repository, for content that does not
41 * exist in the managed legacy repository, but does exist on a remote default layout repository.
44 public void testManagedLegacyNotPresentRemoteDefaultPresent()
47 String path = "org.apache.maven.test/jars/get-default-layout-1.0.jar";
48 File expectedFile = new File( managedLegacyDir, path );
49 ArtifactReference artifact = managedLegacyRepository.toArtifactReference( path );
51 assertNotExistsInManagedLegacyRepo( expectedFile );
53 // Configure Connector (usually done within archiva.xml configuration)
54 saveConnector( ID_LEGACY_MANAGED, ID_PROXIED1, false );
56 File downloadedFile = proxyHandler.fetchFromProxies( managedLegacyRepository, artifact );
58 File proxied2File = new File( REPOPATH_PROXIED1,
59 "org/apache/maven/test/get-default-layout/1.0/get-default-layout-1.0.jar" );
60 assertFileEquals( expectedFile, downloadedFile, proxied2File );
61 assertNoTempFiles( expectedFile );
65 * Incoming request on a Managed Legacy repository, for content that already
66 * exist in the managed legacy repository, and also exist on a remote default layout repository.
69 public void testManagedLegacyPresentRemoteDefaultPresent()
72 String path = "org.apache.maven.test/jars/get-default-layout-present-1.0.jar";
73 String remotePath = "org/apache/maven/test/get-default-layout-present/1.0/get-default-layout-present-1.0.jar";
75 File expectedFile = new File( managedLegacyDir, path );
76 File remoteFile = new File( REPOPATH_PROXIED1, remotePath );
78 setManagedOlderThanRemote( expectedFile, remoteFile );
80 ArtifactReference artifact = managedLegacyRepository.toArtifactReference( path );
82 // Configure Connector (usually done within archiva.xml configuration)
83 saveConnector( ID_LEGACY_MANAGED, ID_PROXIED1, ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
84 SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
86 File downloadedFile = proxyHandler.fetchFromProxies( managedLegacyRepository, artifact );
88 assertFileEquals( expectedFile, downloadedFile, remoteFile );
89 assertNoTempFiles( expectedFile );
93 * Incoming request on a Managed Legacy repository, for content that does not
94 * exist in the managed legacy repository, and does not exist on a remote legacy layout repository.
97 public void testManagedLegacyNotPresentRemoteLegacyPresent()
100 String path = "org.apache.maven.test/plugins/get-legacy-plugin-1.0.jar";
101 File expectedFile = new File( managedLegacyDir, path );
102 ArtifactReference artifact = managedLegacyRepository.toArtifactReference( path );
104 assertNotExistsInManagedLegacyRepo( expectedFile );
106 // Configure Connector (usually done within archiva.xml configuration)
107 saveConnector( ID_LEGACY_MANAGED, ID_LEGACY_PROXIED, false );
109 File downloadedFile = proxyHandler.fetchFromProxies( managedLegacyRepository, artifact );
111 File proxiedFile = new File( REPOPATH_PROXIED_LEGACY, path );
112 assertFileEquals( expectedFile, downloadedFile, proxiedFile );
113 assertNoTempFiles( expectedFile );
117 * Incoming request on a Managed Legacy repository, for content that does exist in the
118 * managed legacy repository, and also exists on a remote legacy layout repository.
121 public void testManagedLegacyPresentRemoteLegacyPresent()
124 String path = "org.apache.maven.test/jars/get-default-layout-present-1.0.jar";
125 File expectedFile = new File( managedLegacyDir, path );
126 File remoteFile = new File( REPOPATH_PROXIED_LEGACY, path );
128 setManagedOlderThanRemote( expectedFile, remoteFile );
130 ArtifactReference artifact = managedLegacyRepository.toArtifactReference( path );
132 // Configure Connector (usually done within archiva.xml configuration)
133 saveConnector( ID_LEGACY_MANAGED, ID_LEGACY_PROXIED, false );
135 File downloadedFile = proxyHandler.fetchFromProxies( managedLegacyRepository, artifact );
137 assertFileEquals( expectedFile, downloadedFile, remoteFile );
138 assertNoTempFiles( expectedFile );
142 * Incoming request on a Managed Legacy repository, for content that does exist in the
143 * managed legacy repository, and does not exist on a remote legacy layout repository.
146 public void testManagedLegacyPresentRemoteLegacyNotPresent()
149 String path = "org.apache.maven.test/jars/managed-only-lib-2.1.jar";
150 File expectedFile = new File( managedLegacyDir, path );
151 ArtifactReference artifact = managedLegacyRepository.toArtifactReference( path );
153 assertTrue( expectedFile.exists() );
155 // Configure Connector (usually done within archiva.xml configuration)
156 saveConnector( ID_LEGACY_MANAGED, ID_LEGACY_PROXIED, false );
158 File downloadedFile = proxyHandler.fetchFromProxies( managedLegacyRepository, artifact );
160 assertNotDownloaded( downloadedFile );
161 assertNoTempFiles( expectedFile );
165 * Incoming request on a Managed Legacy repository, for content that does exist in the
166 * managed legacy repository, and does not exists on a remote default layout repository.
169 public void testManagedLegacyPresentRemoteDefaultNotPresent()
172 String path = "org.apache.maven.test/jars/managed-only-lib-2.1.jar";
173 File expectedFile = new File( managedLegacyDir, path );
174 ArtifactReference artifact = managedLegacyRepository.toArtifactReference( path );
176 assertTrue( expectedFile.exists() );
178 // Configure Connector (usually done within archiva.xml configuration)
179 saveConnector( ID_LEGACY_MANAGED, ID_PROXIED1, false );
181 File downloadedFile = proxyHandler.fetchFromProxies( managedLegacyRepository, artifact );
183 assertNotDownloaded( downloadedFile );
184 assertNoTempFiles( expectedFile );
188 * Incoming request on a Managed Legacy repository, for content that does not exist in the
189 * managed legacy repository, and does not exists on a remote legacy layout repository.
192 public void testManagedLegacyNotPresentRemoteLegacyNotPresent()
195 String path = "org.apache.archiva.test/jars/mystery-lib-1.0.jar";
196 File expectedFile = new File( managedLegacyDir, path );
197 ArtifactReference artifact = managedLegacyRepository.toArtifactReference( path );
199 assertNotExistsInManagedLegacyRepo( expectedFile );
201 // Configure Connector (usually done within archiva.xml configuration)
202 saveConnector( ID_LEGACY_MANAGED, ID_LEGACY_PROXIED, false );
204 File downloadedFile = proxyHandler.fetchFromProxies( managedLegacyRepository, artifact );
206 assertNotDownloaded( downloadedFile );
207 assertNoTempFiles( expectedFile );
211 * Incoming request on a Managed Legacy repository, for content that does not exist in the
212 * managed legacy repository, and does not exists on a remote default layout repository.
215 public void testManagedLegacyNotPresentRemoteDefaultNotPresent()
218 String path = "org.apache.archiva.test/jars/mystery-lib-2.1.jar";
219 File expectedFile = new File( managedLegacyDir, path );
220 ArtifactReference artifact = managedLegacyRepository.toArtifactReference( path );
222 assertNotExistsInManagedLegacyRepo( expectedFile );
224 // Configure Connector (usually done within archiva.xml configuration)
225 saveConnector( ID_LEGACY_MANAGED, ID_PROXIED1, false );
227 File downloadedFile = proxyHandler.fetchFromProxies( managedLegacyRepository, artifact );
229 assertNotDownloaded( downloadedFile );
230 assertNoTempFiles( expectedFile );