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