1 package org.apache.maven.archiva.proxy;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
28 import java.io.File;
29
30
31
32
33
34
35 public class ManagedLegacyTransferTest
36 extends AbstractProxyTestCase
37 {
38
39
40
41
42 public void testManagedLegacyNotPresentRemoteDefaultPresent()
43 throws Exception
44 {
45 String path = "org.apache.maven.test/jars/get-default-layout-1.0.jar";
46 File expectedFile = new File( managedLegacyDir, path );
47 ArtifactReference artifact = managedLegacyRepository.toArtifactReference( path );
48
49 assertNotExistsInManagedLegacyRepo( expectedFile );
50
51
52 saveConnector( ID_LEGACY_MANAGED, ID_PROXIED1, false );
53
54 File downloadedFile = proxyHandler.fetchFromProxies( managedLegacyRepository, artifact );
55
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 );
60 }
61
62
63
64
65
66 public void testManagedLegacyPresentRemoteDefaultPresent()
67 throws Exception
68 {
69 String path = "org.apache.maven.test/jars/get-default-layout-present-1.0.jar";
70 String remotePath = "org/apache/maven/test/get-default-layout-present/1.0/get-default-layout-present-1.0.jar";
71
72 File expectedFile = new File( managedLegacyDir, path );
73 File remoteFile = new File( REPOPATH_PROXIED1, remotePath );
74
75 setManagedOlderThanRemote( expectedFile, remoteFile );
76
77 ArtifactReference artifact = managedLegacyRepository.toArtifactReference( path );
78
79
80 saveConnector( ID_LEGACY_MANAGED, ID_PROXIED1, ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
81 SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
82
83 File downloadedFile = proxyHandler.fetchFromProxies( managedLegacyRepository, artifact );
84
85 assertFileEquals( expectedFile, downloadedFile, remoteFile );
86 assertNoTempFiles( expectedFile );
87 }
88
89
90
91
92
93 public void testManagedLegacyNotPresentRemoteLegacyPresent()
94 throws Exception
95 {
96 String path = "org.apache.maven.test/plugins/get-legacy-plugin-1.0.jar";
97 File expectedFile = new File( managedLegacyDir, path );
98 ArtifactReference artifact = managedLegacyRepository.toArtifactReference( path );
99
100 assertNotExistsInManagedLegacyRepo( expectedFile );
101
102
103 saveConnector( ID_LEGACY_MANAGED, ID_LEGACY_PROXIED, false );
104
105 File downloadedFile = proxyHandler.fetchFromProxies( managedLegacyRepository, artifact );
106
107 File proxiedFile = new File( REPOPATH_PROXIED_LEGACY, path );
108 assertFileEquals( expectedFile, downloadedFile, proxiedFile );
109 assertNoTempFiles( expectedFile );
110 }
111
112
113
114
115
116 public void testManagedLegacyPresentRemoteLegacyPresent()
117 throws Exception
118 {
119 String path = "org.apache.maven.test/jars/get-default-layout-present-1.0.jar";
120 File expectedFile = new File( managedLegacyDir, path );
121 File remoteFile = new File( REPOPATH_PROXIED_LEGACY, path );
122
123 setManagedOlderThanRemote( expectedFile, remoteFile );
124
125 ArtifactReference artifact = managedLegacyRepository.toArtifactReference( path );
126
127
128 saveConnector( ID_LEGACY_MANAGED, ID_LEGACY_PROXIED, false );
129
130 File downloadedFile = proxyHandler.fetchFromProxies( managedLegacyRepository, artifact );
131
132 assertFileEquals( expectedFile, downloadedFile, remoteFile );
133 assertNoTempFiles( expectedFile );
134 }
135
136
137
138
139
140 public void testManagedLegacyPresentRemoteLegacyNotPresent()
141 throws Exception
142 {
143 String path = "org.apache.maven.test/jars/managed-only-lib-2.1.jar";
144 File expectedFile = new File( managedLegacyDir, path );
145 ArtifactReference artifact = managedLegacyRepository.toArtifactReference( path );
146
147 assertTrue( expectedFile.exists() );
148
149
150 saveConnector( ID_LEGACY_MANAGED, ID_LEGACY_PROXIED, false );
151
152 File downloadedFile = proxyHandler.fetchFromProxies( managedLegacyRepository, artifact );
153
154 assertNotDownloaded( downloadedFile );
155 assertNoTempFiles( expectedFile );
156 }
157
158
159
160
161
162 public void testManagedLegacyPresentRemoteDefaultNotPresent()
163 throws Exception
164 {
165 String path = "org.apache.maven.test/jars/managed-only-lib-2.1.jar";
166 File expectedFile = new File( managedLegacyDir, path );
167 ArtifactReference artifact = managedLegacyRepository.toArtifactReference( path );
168
169 assertTrue( expectedFile.exists() );
170
171
172 saveConnector( ID_LEGACY_MANAGED, ID_PROXIED1, false );
173
174 File downloadedFile = proxyHandler.fetchFromProxies( managedLegacyRepository, artifact );
175
176 assertNotDownloaded( downloadedFile );
177 assertNoTempFiles( expectedFile );
178 }
179
180
181
182
183
184 public void testManagedLegacyNotPresentRemoteLegacyNotPresent()
185 throws Exception
186 {
187 String path = "org.apache.archiva.test/jars/mystery-lib-1.0.jar";
188 File expectedFile = new File( managedLegacyDir, path );
189 ArtifactReference artifact = managedLegacyRepository.toArtifactReference( path );
190
191 assertNotExistsInManagedLegacyRepo( expectedFile );
192
193
194 saveConnector( ID_LEGACY_MANAGED, ID_LEGACY_PROXIED, false );
195
196 File downloadedFile = proxyHandler.fetchFromProxies( managedLegacyRepository, artifact );
197
198 assertNotDownloaded( downloadedFile );
199 assertNoTempFiles( expectedFile );
200 }
201
202
203
204
205
206 public void testManagedLegacyNotPresentRemoteDefaultNotPresent()
207 throws Exception
208 {
209 String path = "org.apache.archiva.test/jars/mystery-lib-2.1.jar";
210 File expectedFile = new File( managedLegacyDir, path );
211 ArtifactReference artifact = managedLegacyRepository.toArtifactReference( path );
212
213 assertNotExistsInManagedLegacyRepo( expectedFile );
214
215
216 saveConnector( ID_LEGACY_MANAGED, ID_PROXIED1, false );
217
218 File downloadedFile = proxyHandler.fetchFromProxies( managedLegacyRepository, artifact );
219
220 assertNotDownloaded( downloadedFile );
221 assertNoTempFiles( expectedFile );
222 }
223 }