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.common.utils.FileUtils;
23 import org.apache.archiva.model.ArtifactReference;
24 import org.apache.archiva.policies.CachedFailuresPolicy;
25 import org.apache.archiva.policies.ChecksumPolicy;
26 import org.apache.archiva.policies.ReleasesPolicy;
27 import org.apache.archiva.policies.SnapshotsPolicy;
28 import org.apache.maven.wagon.ResourceDoesNotExistException;
29 import org.easymock.EasyMock;
30 import org.junit.Test;
33 import java.nio.file.Files;
34 import java.nio.file.Path;
35 import java.nio.file.Paths;
36 import java.nio.file.StandardCopyOption;
38 import static org.junit.Assert.assertFalse;
39 import static org.junit.Assert.assertNull;
42 * ChecksumTransferTest
46 public class ChecksumTransferTest
47 extends AbstractProxyTestCase
50 public void testGetChecksumWhenConnectorIsDisabled()
53 String path = "org/apache/maven/test/get-checksum-both-right/1.0/get-checksum-both-right-1.0.jar";
54 setupTestableManagedRepository( path );
56 Path expectedFile = managedDefaultDir.resolve( path );
57 ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
59 org.apache.archiva.common.utils.FileUtils.deleteDirectory( expectedFile.getParent() );
60 assertFalse( Files.exists(expectedFile) );
62 // Configure Connector (usually done within archiva.xml configuration)
63 saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS,
64 SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, true );
66 Path downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
68 assertNull( downloadedFile );
72 public void testGetChecksumBothCorrect()
75 String path = "org/apache/maven/test/get-checksum-both-right/1.0/get-checksum-both-right-1.0.jar";
76 setupTestableManagedRepository( path );
78 Path expectedFile = managedDefaultDir.resolve( path );
79 ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
81 org.apache.archiva.common.utils.FileUtils.deleteDirectory( expectedFile.getParent() );
82 assertFalse( Files.exists(expectedFile) );
84 // Configure Connector (usually done within archiva.xml configuration)
85 saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS,
86 SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
88 Path downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
90 Path proxied1File = Paths.get( REPOPATH_PROXIED1, path );
91 assertFileEquals( expectedFile, downloadedFile, proxied1File );
92 assertNoTempFiles( expectedFile );
93 assertChecksums( expectedFile, "066d76e459f7782c312c31e8a11b3c0f1e3e43a7 *get-checksum-both-right-1.0.jar",
94 "e58f30c6a150a2e843552438d18e15cb *get-checksum-both-right-1.0.jar" );
98 public void testGetChecksumCorrectSha1NoMd5()
101 String path = "org/apache/maven/test/get-checksum-sha1-only/1.0/get-checksum-sha1-only-1.0.jar";
102 setupTestableManagedRepository( path );
104 Path expectedFile = managedDefaultDir.resolve( path );
105 ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
107 FileUtils.deleteDirectory( expectedFile.getParent() );
108 assertFalse( Files.exists(expectedFile) );
110 // Configure Connector (usually done within archiva.xml configuration)
111 saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS,
112 SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
114 Path downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
116 Path proxied1File = Paths.get( REPOPATH_PROXIED1, path );
117 assertFileEquals( expectedFile, downloadedFile, proxied1File );
118 assertNoTempFiles( expectedFile );
119 assertChecksums( expectedFile, "748a3a013bf5eacf2bbb40a2ac7d37889b728837 *get-checksum-sha1-only-1.0.jar",
124 public void testGetChecksumNoSha1CorrectMd5()
127 String path = "org/apache/maven/test/get-checksum-md5-only/1.0/get-checksum-md5-only-1.0.jar";
128 setupTestableManagedRepository( path );
130 Path expectedFile = managedDefaultDir.resolve( path );
131 ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
133 FileUtils.deleteDirectory( expectedFile.getParent() );
134 assertFalse( Files.exists(expectedFile) );
136 // Configure Connector (usually done within archiva.xml configuration)
137 saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS,
138 SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
140 Path downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
142 Path proxied1File = Paths.get( REPOPATH_PROXIED1, path );
143 assertFileEquals( expectedFile, downloadedFile, proxied1File );
144 assertNoTempFiles( expectedFile );
145 assertChecksums( expectedFile, null, "f3af5201bf8da801da37db8842846e1c *get-checksum-md5-only-1.0.jar" );
149 public void testGetWithNoChecksumsUsingIgnoredSetting()
152 String path = "org/apache/maven/test/get-default-layout/1.0/get-default-layout-1.0.jar";
153 setupTestableManagedRepository( path );
155 Path expectedFile = managedDefaultDir.resolve( path );
156 ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
158 FileUtils.deleteDirectory( expectedFile.getParent() );
159 assertFalse( Files.exists(expectedFile) );
161 // Configure Connector (usually done within archiva.xml configuration)
162 saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS,
163 SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
165 Path downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
167 Path proxied1File = Paths.get( REPOPATH_PROXIED1, path );
168 assertFileEquals( expectedFile, downloadedFile, proxied1File );
169 assertNoTempFiles( expectedFile );
170 assertChecksums( expectedFile, null, null );
174 public void testGetChecksumBadSha1BadMd5IgnoredSetting()
177 String path = "org/apache/maven/test/get-checksum-both-bad/1.0/get-checksum-both-bad-1.0.jar";
178 setupTestableManagedRepository( path );
180 Path expectedFile = managedDefaultDir.resolve( path );
181 ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
183 FileUtils.deleteDirectory( expectedFile.getParent() );
184 assertFalse( Files.exists(expectedFile) );
186 // Configure Connector (usually done within archiva.xml configuration)
187 saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS,
188 SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
190 Path downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
192 Path proxied1File = Paths.get( REPOPATH_PROXIED1, path );
193 assertFileEquals( expectedFile, downloadedFile, proxied1File );
194 assertNoTempFiles( expectedFile );
195 assertChecksums( expectedFile, "invalid checksum file", "invalid checksum file" );
199 public void testGetChecksumBadSha1BadMd5FailSetting()
202 String path = "org/apache/maven/test/get-checksum-both-bad/1.0/get-checksum-both-bad-1.0.jar";
203 setupTestableManagedRepository( path );
205 Path expectedFile = managedDefaultDir.resolve( path );
206 ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
208 FileUtils.deleteDirectory( expectedFile.getParent() );
209 assertFalse( Files.exists(expectedFile) );
211 // Configure Connector (usually done within archiva.xml configuration)
212 saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FAIL, ReleasesPolicy.ALWAYS,
213 SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
215 Path downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
217 assertNotDownloaded( downloadedFile );
218 assertChecksums( expectedFile, null, null );
222 public void testGetChecksumBadSha1BadMd5FixSetting()
225 String path = "org/apache/maven/test/get-checksum-both-bad/1.0/get-checksum-both-bad-1.0.jar";
226 setupTestableManagedRepository( path );
228 Path expectedFile = managedDefaultDir.resolve( path );
229 ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
231 FileUtils.deleteDirectory( expectedFile.getParent() );
232 assertFalse( Files.exists(expectedFile) );
234 // Configure Connector (usually done within archiva.xml configuration)
235 saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
236 SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
238 Path downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
240 Path proxied1File = Paths.get( REPOPATH_PROXIED1, path );
241 assertFileEquals( expectedFile, downloadedFile, proxied1File );
242 assertNoTempFiles( expectedFile );
243 assertChecksums( expectedFile, "4ec20a12dc91557330bd0b39d1805be5e329ae56 get-checksum-both-bad-1.0.jar",
244 "a292491a35925465e693a44809a078b5 get-checksum-both-bad-1.0.jar" );
248 public void testGetChecksumCorrectSha1BadMd5UsingFailSetting()
251 String path = "org/apache/maven/test/get-checksum-sha1-bad-md5/1.0/get-checksum-sha1-bad-md5-1.0.jar";
252 setupTestableManagedRepository( path );
254 Path expectedFile = managedDefaultDir.resolve(path);
255 ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
257 FileUtils.deleteDirectory( expectedFile.getParent() );
258 assertFalse( Files.exists(expectedFile) );
260 // Configure Connector (usually done within archiva.xml configuration)
261 saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FAIL, ReleasesPolicy.ALWAYS,
262 SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
264 Path downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
266 assertNotDownloaded( downloadedFile );
267 assertChecksums( expectedFile, null, null );
271 public void testGetChecksumNoSha1CorrectMd5UsingFailSetting()
274 String path = "org/apache/maven/test/get-checksum-md5-only/1.0/get-checksum-md5-only-1.0.jar";
275 setupTestableManagedRepository( path );
277 Path expectedFile = managedDefaultDir.resolve(path);
278 ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
280 FileUtils.deleteDirectory( expectedFile.getParent() );
281 assertFalse( Files.exists(expectedFile) );
283 // Configure Connector (usually done within archiva.xml configuration)
284 saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FAIL, ReleasesPolicy.ALWAYS,
285 SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
287 Path downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
289 // This is a success situation. No SHA1 with a Good MD5.
290 Path proxied1File = Paths.get(REPOPATH_PROXIED1, path);
291 assertFileEquals( expectedFile, downloadedFile, proxied1File );
292 assertNoTempFiles( expectedFile );
293 assertChecksums( expectedFile, null, "f3af5201bf8da801da37db8842846e1c *get-checksum-md5-only-1.0.jar" );
297 public void testGetWithNoChecksumsUsingFailSetting()
300 String path = "org/apache/maven/test/get-default-layout/1.0/get-default-layout-1.0.jar";
301 setupTestableManagedRepository( path );
303 Path expectedFile = managedDefaultDir.resolve(path);
304 ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
306 FileUtils.deleteDirectory( expectedFile.getParent() );
307 assertFalse( Files.exists(expectedFile) );
309 // Configure Connector (usually done within archiva.xml configuration)
310 saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FAIL, ReleasesPolicy.ALWAYS,
311 SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
313 Path downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
315 assertNotDownloaded( downloadedFile );
316 assertChecksums( expectedFile, null, null );
320 public void testGetChecksumCorrectSha1BadMd5UsingIgnoredSetting()
323 String path = "org/apache/maven/test/get-checksum-sha1-bad-md5/1.0/get-checksum-sha1-bad-md5-1.0.jar";
324 setupTestableManagedRepository( path );
326 Path expectedFile = managedDefaultDir.resolve(path);
327 ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
329 FileUtils.deleteDirectory( expectedFile.getParent() );
330 assertFalse( Files.exists(expectedFile) );
332 // Configure Connector (usually done within archiva.xml configuration)
333 saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS,
334 SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
336 Path downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
338 Path proxied1File = Paths.get(REPOPATH_PROXIED1, path);
339 assertFileEquals( expectedFile, downloadedFile, proxied1File );
340 assertNoTempFiles( expectedFile );
341 assertChecksums( expectedFile, "3dd1a3a57b807d3ef3fbc6013d926c891cbb8670 *get-checksum-sha1-bad-md5-1.0.jar",
342 "invalid checksum file" );
346 public void testGetChecksumCorrectSha1BadMd5UsingFixSetting()
349 String path = "org/apache/maven/test/get-checksum-sha1-bad-md5/1.0/get-checksum-sha1-bad-md5-1.0.jar";
350 setupTestableManagedRepository( path );
352 Path expectedFile = managedDefaultDir.resolve(path);
353 ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
355 FileUtils.deleteDirectory( expectedFile.getParent() );
356 assertFalse( Files.exists(expectedFile) );
358 // Configure Connector (usually done within archiva.xml configuration)
359 saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
360 SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
363 Path downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
365 Path proxied1File = Paths.get(REPOPATH_PROXIED1, path);
366 assertFileEquals( expectedFile, downloadedFile, proxied1File );
367 assertNoTempFiles( expectedFile );
368 assertChecksums( expectedFile, "3dd1a3a57b807d3ef3fbc6013d926c891cbb8670 *get-checksum-sha1-bad-md5-1.0.jar",
369 "c35f3b76268b73a4ba617f6f275c49ab get-checksum-sha1-bad-md5-1.0.jar" );
373 public void testGetChecksumNoSha1CorrectMd5UsingFixSetting()
376 String path = "org/apache/maven/test/get-checksum-md5-only/1.0/get-checksum-md5-only-1.0.jar";
377 setupTestableManagedRepository( path );
379 Path expectedFile = managedDefaultDir.resolve(path);
380 ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
382 FileUtils.deleteDirectory( expectedFile.getParent() );
383 assertFalse( Files.exists(expectedFile) );
385 // Configure Connector (usually done within archiva.xml configuration)
386 saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
387 SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
389 Path downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
391 Path proxied1File = Paths.get(REPOPATH_PROXIED1, path);
392 assertFileEquals( expectedFile, downloadedFile, proxied1File );
393 assertNoTempFiles( expectedFile );
394 assertChecksums( expectedFile, "71f7dc3f72053a3f2d9fdd6fef9db055ef957ffb get-checksum-md5-only-1.0.jar",
395 "f3af5201bf8da801da37db8842846e1c *get-checksum-md5-only-1.0.jar" );
399 public void testGetWithNoChecksumsUsingFixSetting()
402 String path = "org/apache/maven/test/get-default-layout/1.0/get-default-layout-1.0.jar";
403 setupTestableManagedRepository( path );
405 Path expectedFile = managedDefaultDir.resolve(path);
406 ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
408 FileUtils.deleteDirectory( expectedFile.getParent() );
409 assertFalse( Files.exists(expectedFile) );
411 // Configure Connector (usually done within archiva.xml configuration)
412 saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
413 SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
415 Path downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
417 Path proxied1File = Paths.get(REPOPATH_PROXIED1, path);
418 assertFileEquals( expectedFile, downloadedFile, proxied1File );
419 assertNoTempFiles( expectedFile );
420 assertChecksums( expectedFile, "1f12821c5e43e1a0b76b9564a6ddb0548ccb9486 get-default-layout-1.0.jar",
421 "3f7341545f21226b6f49a3c2704cb9be get-default-layout-1.0.jar" );
425 public void testGetChecksumNotFoundOnRemote()
428 String path = "org/apache/maven/test/get-checksum-sha1-only/1.0/get-checksum-sha1-only-1.0.jar";
429 setupTestableManagedRepository( path );
431 Path expectedFile = managedDefaultDir.resolve( path );
432 ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
434 FileUtils.deleteDirectory( expectedFile.getParent() );
435 assertFalse( Files.exists(expectedFile.getParent()) );
436 assertFalse( Files.exists(expectedFile) );
438 saveRemoteRepositoryConfig( "badproxied", "Bad Proxied", "test://bad.machine.com/repo/", "default" );
440 // Configure Connector (usually done within archiva.xml configuration)
441 saveConnector( ID_DEFAULT_MANAGED, "badproxied", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS,
442 SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
444 wagonMock.get( EasyMock.eq( path ), EasyMock.anyObject( File.class ));
445 EasyMock.expectLastCall().once();
447 wagonMock.get( EasyMock.eq( path + ".sha1" ), EasyMock.anyObject( File.class ));
448 EasyMock.expectLastCall().once();
450 wagonMock.get( EasyMock.eq( path + ".md5" ), EasyMock.anyObject( File.class ));
451 EasyMock.expectLastCall().andThrow( new ResourceDoesNotExistException( "Resource does not exist." ) ).once();
453 wagonMockControl.replay();
455 Path downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
457 wagonMockControl.verify();
459 // Do what the mock doesn't do.
460 Path proxyPath = Paths.get( REPOPATH_PROXIED1, path ).toAbsolutePath();
461 Path localPath = managedDefaultDir.resolve( path ).toAbsolutePath();
462 Files.copy( proxyPath, localPath, StandardCopyOption.REPLACE_EXISTING);
463 Files.copy( proxyPath.resolveSibling( proxyPath.getFileName() + ".sha1" ),
464 localPath.resolveSibling( localPath.getFileName() + ".sha1" ), StandardCopyOption.REPLACE_EXISTING );
467 Path proxied1File = Paths.get( REPOPATH_PROXIED1, path );
468 assertFileEquals( expectedFile, downloadedFile, proxied1File );
469 assertNoTempFiles( expectedFile );
470 assertChecksums( expectedFile, "748a3a013bf5eacf2bbb40a2ac7d37889b728837 *get-checksum-sha1-only-1.0.jar",
475 public void testGetAlwaysBadChecksumPresentLocallyAbsentRemoteUsingIgnoredSetting()
478 String path = "org/apache/maven/test/get-bad-local-checksum/1.0/get-bad-local-checksum-1.0.jar";
479 setupTestableManagedRepository( path );
481 Path expectedFile = managedDefaultDir.resolve( path );
482 Path remoteFile = Paths.get( REPOPATH_PROXIED1, path );
484 setManagedOlderThanRemote( expectedFile, remoteFile );
486 ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
488 // Configure Connector (usually done within archiva.xml configuration)
489 saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS,
490 SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
492 Path downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
494 Path proxied1File = Paths.get( REPOPATH_PROXIED1, path );
495 assertFileEquals( expectedFile, downloadedFile, proxied1File );
496 assertNoTempFiles( expectedFile );
497 // There are no hashcodes on the proxy side to download, hence the local ones should remain invalid.
498 assertChecksums( expectedFile, "invalid checksum file", "invalid checksum file" );
502 public void testGetAlwaysBadChecksumPresentLocallyAbsentRemoteUsingFailSetting()
505 String path = "org/apache/maven/test/get-bad-local-checksum/1.0/get-bad-local-checksum-1.0.jar";
506 setupTestableManagedRepository( path );
508 Path expectedFile = managedDefaultDir.resolve( path );
509 Path remoteFile = Paths.get( REPOPATH_PROXIED1, path );
511 setManagedOlderThanRemote( expectedFile, remoteFile );
513 ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
515 // Configure Connector (usually done within archiva.xml configuration)
516 saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED1, ChecksumPolicy.FAIL, ReleasesPolicy.ALWAYS,
517 SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
519 Path downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
521 assertNotDownloaded( downloadedFile );
522 assertNoTempFiles( expectedFile );
523 // There are no hashcodes on the proxy side to download.
524 // The FAIL policy will delete the checksums as bad.
526 assertChecksums( expectedFile, "invalid checksum file", "invalid checksum file" );
530 public void testGetAlwaysBadChecksumPresentLocallyAbsentRemoteUsingFixSetting()
533 String path = "org/apache/maven/test/get-bad-local-checksum/1.0/get-bad-local-checksum-1.0.jar";
534 setupTestableManagedRepository( path );
536 Path expectedFile = managedDefaultDir.resolve(path);
537 Path remoteFile = Paths.get(REPOPATH_PROXIED1, path);
539 setManagedOlderThanRemote( expectedFile, remoteFile );
541 ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
543 // Configure Connector (usually done within archiva.xml configuration)
544 saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
545 SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
547 Path downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
549 Path proxied1File = Paths.get(REPOPATH_PROXIED1, path);
550 assertFileEquals( expectedFile, downloadedFile, proxied1File );
551 assertNoTempFiles( expectedFile );
552 assertChecksums( expectedFile, "96a08dc80a108cba8efd3b20aec91b32a0b2cbd4 get-bad-local-checksum-1.0.jar",
553 "46fdd6ca55bf1d7a7eb0c858f41e0ccd get-bad-local-checksum-1.0.jar" );