]> source.dussan.org Git - archiva.git/blob
e51447ec3ca8e1bcd79516d6dec874b25dfe8b17
[archiva.git] /
1 package org.apache.maven.archiva.proxy;
2
3 /*
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
11  *
12  *  http://www.apache.org/licenses/LICENSE-2.0
13  *
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
19  * under the License.
20  */
21
22 import org.apache.commons.io.FileUtils;
23 import org.apache.maven.archiva.model.ArtifactReference;
24 import org.apache.maven.archiva.policies.CachedFailuresPolicy;
25 import org.apache.maven.archiva.policies.ChecksumPolicy;
26 import org.apache.maven.archiva.policies.ReleasesPolicy;
27 import org.apache.maven.archiva.policies.SnapshotsPolicy;
28 import org.apache.maven.wagon.ResourceDoesNotExistException;
29
30 import java.io.File;
31
32 /**
33  * ChecksumTransferTest
34  *
35  * @author Brett Porter
36  * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
37  * @version $Id$
38  */
39 public class ChecksumTransferTest
40     extends AbstractProxyTestCase
41 {
42     public void testGetChecksumBothCorrect()
43         throws Exception
44     {
45         String path = "org/apache/maven/test/get-checksum-both-right/1.0/get-checksum-both-right-1.0.jar";
46         setupTestableManagedRepository( path );
47
48         File expectedFile = new File( managedDefaultDir, path );
49         ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
50
51         FileUtils.deleteDirectory( expectedFile.getParentFile() );
52         assertFalse( expectedFile.exists() );
53
54         // Configure Connector (usually done within archiva.xml configuration)
55         saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS,
56                        SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO );
57
58         File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
59
60         File proxied1File = new File( REPOPATH_PROXIED1, path );
61         assertFileEquals( expectedFile, downloadedFile, proxied1File );
62         assertNoTempFiles( expectedFile );
63         assertChecksums( expectedFile, "066d76e459f7782c312c31e8a11b3c0f1e3e43a7 *get-checksum-both-right-1.0.jar",
64                          "e58f30c6a150a2e843552438d18e15cb *get-checksum-both-right-1.0.jar" );
65     }
66
67     public void testGetChecksumCorrectSha1NoMd5()
68         throws Exception
69     {
70         String path = "org/apache/maven/test/get-checksum-sha1-only/1.0/get-checksum-sha1-only-1.0.jar";
71         setupTestableManagedRepository( path );
72
73         File expectedFile = new File( managedDefaultDir, path );
74         ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
75
76         FileUtils.deleteDirectory( expectedFile.getParentFile() );
77         assertFalse( expectedFile.exists() );
78
79         // Configure Connector (usually done within archiva.xml configuration)
80         saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS,
81                        SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO );
82
83         File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
84
85         File proxied1File = new File( REPOPATH_PROXIED1, path );
86         assertFileEquals( expectedFile, downloadedFile, proxied1File );
87         assertNoTempFiles( expectedFile );
88         assertChecksums( expectedFile, "748a3a013bf5eacf2bbb40a2ac7d37889b728837 *get-checksum-sha1-only-1.0.jar",
89                          null );
90     }
91
92     public void testGetChecksumNoSha1CorrectMd5()
93         throws Exception
94     {
95         String path = "org/apache/maven/test/get-checksum-md5-only/1.0/get-checksum-md5-only-1.0.jar";
96         setupTestableManagedRepository( path );
97
98         File expectedFile = new File( managedDefaultDir, path );
99         ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
100
101         FileUtils.deleteDirectory( expectedFile.getParentFile() );
102         assertFalse( expectedFile.exists() );
103
104         // Configure Connector (usually done within archiva.xml configuration)
105         saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS,
106                        SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO );
107
108         File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
109
110         File proxied1File = new File( REPOPATH_PROXIED1, path );
111         assertFileEquals( expectedFile, downloadedFile, proxied1File );
112         assertNoTempFiles( expectedFile );
113         assertChecksums( expectedFile, null, "f3af5201bf8da801da37db8842846e1c *get-checksum-md5-only-1.0.jar" );
114     }
115
116     public void testGetWithNoChecksumsUsingIgnoredSetting()
117         throws Exception
118     {
119         String path = "org/apache/maven/test/get-default-layout/1.0/get-default-layout-1.0.jar";
120         setupTestableManagedRepository( path );
121
122         File expectedFile = new File( managedDefaultDir, path );
123         ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
124
125         FileUtils.deleteDirectory( expectedFile.getParentFile() );
126         assertFalse( expectedFile.exists() );
127
128         // Configure Connector (usually done within archiva.xml configuration)
129         saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS,
130                        SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO );
131
132         File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
133
134         File proxied1File = new File( REPOPATH_PROXIED1, path );
135         assertFileEquals( expectedFile, downloadedFile, proxied1File );
136         assertNoTempFiles( expectedFile );
137         assertChecksums( expectedFile, null, null );
138     }
139
140     public void testGetChecksumBadSha1BadMd5IgnoredSetting()
141         throws Exception
142     {
143         String path = "org/apache/maven/test/get-checksum-both-bad/1.0/get-checksum-both-bad-1.0.jar";
144         setupTestableManagedRepository( path );
145
146         File expectedFile = new File( managedDefaultDir, path );
147         ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
148
149         FileUtils.deleteDirectory( expectedFile.getParentFile() );
150         assertFalse( expectedFile.exists() );
151
152         // Configure Connector (usually done within archiva.xml configuration)
153         saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS,
154                        SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO );
155
156         File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
157
158         File proxied1File = new File( REPOPATH_PROXIED1, path );
159         assertFileEquals( expectedFile, downloadedFile, proxied1File );
160         assertNoTempFiles( expectedFile );
161         assertChecksums( expectedFile, "invalid checksum file", "invalid checksum file" );
162     }
163
164     public void testGetChecksumBadSha1BadMd5FailSetting()
165         throws Exception
166     {
167         String path = "org/apache/maven/test/get-checksum-both-bad/1.0/get-checksum-both-bad-1.0.jar";
168         setupTestableManagedRepository( path );
169
170         File expectedFile = new File( managedDefaultDir, path );
171         ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
172
173         FileUtils.deleteDirectory( expectedFile.getParentFile() );
174         assertFalse( expectedFile.exists() );
175
176         // Configure Connector (usually done within archiva.xml configuration)
177         saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FAIL, ReleasesPolicy.ALWAYS,
178                        SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO );
179
180         File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
181
182         assertNotDownloaded( downloadedFile );
183         assertChecksums( expectedFile, null, null );
184     }
185
186     public void testGetChecksumBadSha1BadMd5FixSetting()
187         throws Exception
188     {
189         String path = "org/apache/maven/test/get-checksum-both-bad/1.0/get-checksum-both-bad-1.0.jar";
190         setupTestableManagedRepository( path );
191
192         File expectedFile = new File( managedDefaultDir, path );
193         ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
194
195         FileUtils.deleteDirectory( expectedFile.getParentFile() );
196         assertFalse( expectedFile.exists() );
197
198         // Configure Connector (usually done within archiva.xml configuration)
199         saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
200                        SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO );
201
202         File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
203
204         File proxied1File = new File( REPOPATH_PROXIED1, path );
205         assertFileEquals( expectedFile, downloadedFile, proxied1File );
206         assertNoTempFiles( expectedFile );
207         assertChecksums( expectedFile, "4ec20a12dc91557330bd0b39d1805be5e329ae56  get-checksum-both-bad-1.0.jar",
208                          "a292491a35925465e693a44809a078b5  get-checksum-both-bad-1.0.jar" );
209     }
210
211     public void testGetChecksumCorrectSha1BadMd5UsingFailSetting()
212         throws Exception
213     {
214         String path = "org/apache/maven/test/get-checksum-sha1-bad-md5/1.0/get-checksum-sha1-bad-md5-1.0.jar";
215         setupTestableManagedRepository( path );
216
217         File expectedFile = new File( managedDefaultDir, path );
218         ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
219
220         FileUtils.deleteDirectory( expectedFile.getParentFile() );
221         assertFalse( expectedFile.exists() );
222
223         // Configure Connector (usually done within archiva.xml configuration)
224         saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FAIL, ReleasesPolicy.ALWAYS,
225                        SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO );
226
227         File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
228
229         assertNotDownloaded( downloadedFile );
230         assertChecksums( expectedFile, null, null );
231     }
232
233     public void testGetChecksumNoSha1CorrectMd5UsingFailSetting()
234         throws Exception
235     {
236         String path = "org/apache/maven/test/get-checksum-md5-only/1.0/get-checksum-md5-only-1.0.jar";
237         setupTestableManagedRepository( path );
238
239         File expectedFile = new File( managedDefaultDir, path );
240         ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
241
242         FileUtils.deleteDirectory( expectedFile.getParentFile() );
243         assertFalse( expectedFile.exists() );
244
245         // Configure Connector (usually done within archiva.xml configuration)
246         saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FAIL, ReleasesPolicy.ALWAYS,
247                        SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO );
248
249         File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
250
251         // This is a success situation. No SHA1 with a Good MD5.
252         File proxied1File = new File( REPOPATH_PROXIED1, path );
253         assertFileEquals( expectedFile, downloadedFile, proxied1File );
254         assertNoTempFiles( expectedFile );
255         assertChecksums( expectedFile, null, "f3af5201bf8da801da37db8842846e1c *get-checksum-md5-only-1.0.jar" );
256     }
257
258     public void testGetWithNoChecksumsUsingFailSetting()
259         throws Exception
260     {
261         String path = "org/apache/maven/test/get-default-layout/1.0/get-default-layout-1.0.jar";
262         setupTestableManagedRepository( path );
263
264         File expectedFile = new File( managedDefaultDir, path );
265         ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
266
267         FileUtils.deleteDirectory( expectedFile.getParentFile() );
268         assertFalse( expectedFile.exists() );
269
270         // Configure Connector (usually done within archiva.xml configuration)
271         saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FAIL, ReleasesPolicy.ALWAYS,
272                        SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO );
273
274         File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
275
276         assertNotDownloaded( downloadedFile );
277         assertChecksums( expectedFile, null, null );
278     }
279
280     public void testGetChecksumCorrectSha1BadMd5UsingIgnoredSetting()
281         throws Exception
282     {
283         String path = "org/apache/maven/test/get-checksum-sha1-bad-md5/1.0/get-checksum-sha1-bad-md5-1.0.jar";
284         setupTestableManagedRepository( path );
285
286         File expectedFile = new File( managedDefaultDir, path );
287         ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
288
289         FileUtils.deleteDirectory( expectedFile.getParentFile() );
290         assertFalse( expectedFile.exists() );
291
292         // Configure Connector (usually done within archiva.xml configuration)
293         saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS,
294                        SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO );
295
296         File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
297
298         File proxied1File = new File( REPOPATH_PROXIED1, path );
299         assertFileEquals( expectedFile, downloadedFile, proxied1File );
300         assertNoTempFiles( expectedFile );
301         assertChecksums( expectedFile, "3dd1a3a57b807d3ef3fbc6013d926c891cbb8670 *get-checksum-sha1-bad-md5-1.0.jar",
302                          "invalid checksum file" );
303     }
304
305     public void testGetChecksumCorrectSha1BadMd5UsingFixSetting()
306         throws Exception
307     {
308         String path = "org/apache/maven/test/get-checksum-sha1-bad-md5/1.0/get-checksum-sha1-bad-md5-1.0.jar";
309         setupTestableManagedRepository( path );
310
311         File expectedFile = new File( managedDefaultDir, path );
312         ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
313
314         FileUtils.deleteDirectory( expectedFile.getParentFile() );
315         assertFalse( expectedFile.exists() );
316
317         // Configure Connector (usually done within archiva.xml configuration)
318         saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
319                        SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO );
320
321         File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
322
323         File proxied1File = new File( REPOPATH_PROXIED1, path );
324         assertFileEquals( expectedFile, downloadedFile, proxied1File );
325         assertNoTempFiles( expectedFile );
326         assertChecksums( expectedFile, "3dd1a3a57b807d3ef3fbc6013d926c891cbb8670 *get-checksum-sha1-bad-md5-1.0.jar",
327                          "c35f3b76268b73a4ba617f6f275c49ab  get-checksum-sha1-bad-md5-1.0.jar" );
328     }
329
330     public void testGetChecksumNoSha1CorrectMd5UsingFixSetting()
331         throws Exception
332     {
333         String path = "org/apache/maven/test/get-checksum-md5-only/1.0/get-checksum-md5-only-1.0.jar";
334         setupTestableManagedRepository( path );
335
336         File expectedFile = new File( managedDefaultDir, path );
337         ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
338
339         FileUtils.deleteDirectory( expectedFile.getParentFile() );
340         assertFalse( expectedFile.exists() );
341
342         // Configure Connector (usually done within archiva.xml configuration)
343         saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
344                        SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO );
345
346         File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
347
348         File proxied1File = new File( REPOPATH_PROXIED1, path );
349         assertFileEquals( expectedFile, downloadedFile, proxied1File );
350         assertNoTempFiles( expectedFile );
351         assertChecksums( expectedFile, "71f7dc3f72053a3f2d9fdd6fef9db055ef957ffb  get-checksum-md5-only-1.0.jar",
352                          "f3af5201bf8da801da37db8842846e1c *get-checksum-md5-only-1.0.jar" );
353     }
354
355     public void testGetWithNoChecksumsUsingFixSetting()
356         throws Exception
357     {
358         String path = "org/apache/maven/test/get-default-layout/1.0/get-default-layout-1.0.jar";
359         setupTestableManagedRepository( path );
360
361         File expectedFile = new File( managedDefaultDir, path );
362         ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
363
364         FileUtils.deleteDirectory( expectedFile.getParentFile() );
365         assertFalse( expectedFile.exists() );
366
367         // Configure Connector (usually done within archiva.xml configuration)
368         saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
369                        SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO );
370
371         File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
372
373         File proxied1File = new File( REPOPATH_PROXIED1, path );
374         assertFileEquals( expectedFile, downloadedFile, proxied1File );
375         assertNoTempFiles( expectedFile );
376         assertChecksums( expectedFile, "1f12821c5e43e1a0b76b9564a6ddb0548ccb9486  get-default-layout-1.0.jar",
377                          "3f7341545f21226b6f49a3c2704cb9be  get-default-layout-1.0.jar" );
378     }
379
380     public void testGetChecksumNotFoundOnRemote()
381         throws Exception
382     {
383         String path = "org/apache/maven/test/get-checksum-sha1-only/1.0/get-checksum-sha1-only-1.0.jar";
384         setupTestableManagedRepository( path );
385
386         File expectedFile = new File( managedDefaultDir, path );
387         ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
388
389         FileUtils.deleteDirectory( expectedFile.getParentFile() );
390         assertFalse( expectedFile.getParentFile().exists() );
391         assertFalse( expectedFile.exists() );
392
393         saveRemoteRepositoryConfig( "badproxied", "Bad Proxied", "test://bad.machine.com/repo/", "default" );
394
395         // Configure Connector (usually done within archiva.xml configuration)
396         saveConnector( ID_DEFAULT_MANAGED, "badproxied", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS,
397                        SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO );
398
399         wagonMock.get( path, new File( expectedFile.getAbsolutePath() + ".tmp" ) );
400         wagonMockControl.setVoidCallable();
401         wagonMock.get( path + ".sha1", new File( expectedFile.getAbsolutePath() + ".sha1.tmp" ) );
402         wagonMockControl.setVoidCallable();
403         wagonMock.get( path + ".md5", new File( expectedFile.getAbsolutePath() + ".md5.tmp" ) );
404         wagonMockControl.setThrowable( new ResourceDoesNotExistException( "Resource does not exist." ) );
405         wagonMockControl.replay();
406
407         File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
408
409         wagonMockControl.verify();
410
411         // Do what the mock doesn't do.
412         String proxyPath = new File( REPOPATH_PROXIED1, path ).getAbsolutePath();
413         String localPath = new File( managedDefaultDir, path ).getAbsolutePath();
414         FileUtils.copyFile( new File( proxyPath ), new File( localPath ) );
415         FileUtils.copyFile( new File( proxyPath + ".sha1" ), new File( localPath + ".sha1" ) );
416
417         // Test results.
418         File proxied1File = new File( REPOPATH_PROXIED1, path );
419         assertFileEquals( expectedFile, downloadedFile, proxied1File );
420         assertNoTempFiles( expectedFile );
421         assertChecksums( expectedFile, "748a3a013bf5eacf2bbb40a2ac7d37889b728837 *get-checksum-sha1-only-1.0.jar",
422                          null );
423     }
424
425     public void testGetAlwaysBadChecksumPresentLocallyAbsentRemoteUsingIgnoredSetting()
426         throws Exception
427     {
428         String path = "org/apache/maven/test/get-bad-local-checksum/1.0/get-bad-local-checksum-1.0.jar";
429         setupTestableManagedRepository( path );
430
431         File expectedFile = new File( managedDefaultDir, path );
432         File remoteFile = new File( REPOPATH_PROXIED1, path );
433         
434         setManagedOlderThanRemote( expectedFile, remoteFile );
435
436         ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
437
438         // Configure Connector (usually done within archiva.xml configuration)
439         saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS,
440                        SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO );
441
442         File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
443
444         File proxied1File = new File( REPOPATH_PROXIED1, path );
445         assertFileEquals( expectedFile, downloadedFile, proxied1File );
446         assertNoTempFiles( expectedFile );
447         // There are no hashcodes on the proxy side to download, hence the local ones should remain invalid.
448         assertChecksums( expectedFile, "invalid checksum file", "invalid checksum file" );
449     }
450
451     public void testGetAlwaysBadChecksumPresentLocallyAbsentRemoteUsingFailSetting()
452         throws Exception
453     {
454         String path = "org/apache/maven/test/get-bad-local-checksum/1.0/get-bad-local-checksum-1.0.jar";
455         setupTestableManagedRepository( path );
456
457         File expectedFile = new File( managedDefaultDir, path );
458         File remoteFile = new File( REPOPATH_PROXIED1, path );
459
460         setManagedOlderThanRemote( expectedFile, remoteFile );
461         
462         ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
463
464         // Configure Connector (usually done within archiva.xml configuration)
465         saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED1, ChecksumPolicy.FAIL, ReleasesPolicy.ALWAYS,
466                        SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO );
467
468         File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
469
470         assertNotDownloaded( downloadedFile );
471         assertNoTempFiles( expectedFile );
472         // There are no hashcodes on the proxy side to download.
473         // The FAIL policy will delete the checksums as bad.
474         assertChecksums( expectedFile, null, null );
475     }
476
477     public void testGetAlwaysBadChecksumPresentLocallyAbsentRemoteUsingFixSetting()
478         throws Exception
479     {
480         String path = "org/apache/maven/test/get-bad-local-checksum/1.0/get-bad-local-checksum-1.0.jar";
481         setupTestableManagedRepository( path );
482
483         File expectedFile = new File( managedDefaultDir, path );
484         File remoteFile = new File( REPOPATH_PROXIED1, path );
485         
486         setManagedOlderThanRemote( expectedFile, remoteFile );
487
488         ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
489
490         // Configure Connector (usually done within archiva.xml configuration)
491         saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
492                        SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO );
493
494         File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
495
496         File proxied1File = new File( REPOPATH_PROXIED1, path );
497         assertFileEquals( expectedFile, downloadedFile, proxied1File );
498         assertNoTempFiles( expectedFile );
499         assertChecksums( expectedFile, "96a08dc80a108cba8efd3b20aec91b32a0b2cbd4  get-bad-local-checksum-1.0.jar",
500                          "46fdd6ca55bf1d7a7eb0c858f41e0ccd  get-bad-local-checksum-1.0.jar" );
501     }
502 }