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.commons.io.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;
34 import static org.junit.Assert.assertFalse;
35 import static org.junit.Assert.assertNull;
38 * ChecksumTransferTest
42 public class ChecksumTransferTest
43 extends AbstractProxyTestCase
46 public void testGetChecksumWhenConnectorIsDisabled()
49 String path = "org/apache/maven/test/get-checksum-both-right/1.0/get-checksum-both-right-1.0.jar";
50 setupTestableManagedRepository( path );
52 File expectedFile = new File( managedDefaultDir, path );
53 ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
55 FileUtils.deleteDirectory( expectedFile.getParentFile() );
56 assertFalse( expectedFile.exists() );
58 // Configure Connector (usually done within archiva.xml configuration)
59 saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS,
60 SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, true );
62 File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
64 assertNull( downloadedFile );
68 public void testGetChecksumBothCorrect()
71 String path = "org/apache/maven/test/get-checksum-both-right/1.0/get-checksum-both-right-1.0.jar";
72 setupTestableManagedRepository( path );
74 File expectedFile = new File( managedDefaultDir, path );
75 ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
77 FileUtils.deleteDirectory( expectedFile.getParentFile() );
78 assertFalse( expectedFile.exists() );
80 // Configure Connector (usually done within archiva.xml configuration)
81 saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS,
82 SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
84 File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
86 File proxied1File = new File( REPOPATH_PROXIED1, path );
87 assertFileEquals( expectedFile, downloadedFile, proxied1File );
88 assertNoTempFiles( expectedFile );
89 assertChecksums( expectedFile, "066d76e459f7782c312c31e8a11b3c0f1e3e43a7 *get-checksum-both-right-1.0.jar",
90 "e58f30c6a150a2e843552438d18e15cb *get-checksum-both-right-1.0.jar" );
94 public void testGetChecksumCorrectSha1NoMd5()
97 String path = "org/apache/maven/test/get-checksum-sha1-only/1.0/get-checksum-sha1-only-1.0.jar";
98 setupTestableManagedRepository( path );
100 File expectedFile = new File( managedDefaultDir, path );
101 ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
103 FileUtils.deleteDirectory( expectedFile.getParentFile() );
104 assertFalse( expectedFile.exists() );
106 // Configure Connector (usually done within archiva.xml configuration)
107 saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS,
108 SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
110 File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
112 File proxied1File = new File( REPOPATH_PROXIED1, path );
113 assertFileEquals( expectedFile, downloadedFile, proxied1File );
114 assertNoTempFiles( expectedFile );
115 assertChecksums( expectedFile, "748a3a013bf5eacf2bbb40a2ac7d37889b728837 *get-checksum-sha1-only-1.0.jar",
120 public void testGetChecksumNoSha1CorrectMd5()
123 String path = "org/apache/maven/test/get-checksum-md5-only/1.0/get-checksum-md5-only-1.0.jar";
124 setupTestableManagedRepository( path );
126 File expectedFile = new File( managedDefaultDir, path );
127 ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
129 FileUtils.deleteDirectory( expectedFile.getParentFile() );
130 assertFalse( expectedFile.exists() );
132 // Configure Connector (usually done within archiva.xml configuration)
133 saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS,
134 SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
136 File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
138 File proxied1File = new File( REPOPATH_PROXIED1, path );
139 assertFileEquals( expectedFile, downloadedFile, proxied1File );
140 assertNoTempFiles( expectedFile );
141 assertChecksums( expectedFile, null, "f3af5201bf8da801da37db8842846e1c *get-checksum-md5-only-1.0.jar" );
145 public void testGetWithNoChecksumsUsingIgnoredSetting()
148 String path = "org/apache/maven/test/get-default-layout/1.0/get-default-layout-1.0.jar";
149 setupTestableManagedRepository( path );
151 File expectedFile = new File( managedDefaultDir, path );
152 ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
154 FileUtils.deleteDirectory( expectedFile.getParentFile() );
155 assertFalse( expectedFile.exists() );
157 // Configure Connector (usually done within archiva.xml configuration)
158 saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS,
159 SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
161 File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
163 File proxied1File = new File( REPOPATH_PROXIED1, path );
164 assertFileEquals( expectedFile, downloadedFile, proxied1File );
165 assertNoTempFiles( expectedFile );
166 assertChecksums( expectedFile, null, null );
170 public void testGetChecksumBadSha1BadMd5IgnoredSetting()
173 String path = "org/apache/maven/test/get-checksum-both-bad/1.0/get-checksum-both-bad-1.0.jar";
174 setupTestableManagedRepository( path );
176 File expectedFile = new File( managedDefaultDir, path );
177 ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
179 FileUtils.deleteDirectory( expectedFile.getParentFile() );
180 assertFalse( expectedFile.exists() );
182 // Configure Connector (usually done within archiva.xml configuration)
183 saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS,
184 SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
186 File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
188 File proxied1File = new File( REPOPATH_PROXIED1, path );
189 assertFileEquals( expectedFile, downloadedFile, proxied1File );
190 assertNoTempFiles( expectedFile );
191 assertChecksums( expectedFile, "invalid checksum file", "invalid checksum file" );
195 public void testGetChecksumBadSha1BadMd5FailSetting()
198 String path = "org/apache/maven/test/get-checksum-both-bad/1.0/get-checksum-both-bad-1.0.jar";
199 setupTestableManagedRepository( path );
201 File expectedFile = new File( managedDefaultDir, path );
202 ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
204 FileUtils.deleteDirectory( expectedFile.getParentFile() );
205 assertFalse( expectedFile.exists() );
207 // Configure Connector (usually done within archiva.xml configuration)
208 saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FAIL, ReleasesPolicy.ALWAYS,
209 SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
211 File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
213 assertNotDownloaded( downloadedFile );
214 assertChecksums( expectedFile, null, null );
218 public void testGetChecksumBadSha1BadMd5FixSetting()
221 String path = "org/apache/maven/test/get-checksum-both-bad/1.0/get-checksum-both-bad-1.0.jar";
222 setupTestableManagedRepository( path );
224 File expectedFile = new File( managedDefaultDir, path );
225 ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
227 FileUtils.deleteDirectory( expectedFile.getParentFile() );
228 assertFalse( expectedFile.exists() );
230 // Configure Connector (usually done within archiva.xml configuration)
231 saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
232 SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
234 File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
236 File proxied1File = new File( REPOPATH_PROXIED1, path );
237 assertFileEquals( expectedFile, downloadedFile, proxied1File );
238 assertNoTempFiles( expectedFile );
239 assertChecksums( expectedFile, "4ec20a12dc91557330bd0b39d1805be5e329ae56 get-checksum-both-bad-1.0.jar",
240 "a292491a35925465e693a44809a078b5 get-checksum-both-bad-1.0.jar" );
244 public void testGetChecksumCorrectSha1BadMd5UsingFailSetting()
247 String path = "org/apache/maven/test/get-checksum-sha1-bad-md5/1.0/get-checksum-sha1-bad-md5-1.0.jar";
248 setupTestableManagedRepository( path );
250 File expectedFile = new File( managedDefaultDir, path );
251 ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
253 FileUtils.deleteDirectory( expectedFile.getParentFile() );
254 assertFalse( expectedFile.exists() );
256 // Configure Connector (usually done within archiva.xml configuration)
257 saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FAIL, ReleasesPolicy.ALWAYS,
258 SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
260 File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
262 assertNotDownloaded( downloadedFile );
263 assertChecksums( expectedFile, null, null );
267 public void testGetChecksumNoSha1CorrectMd5UsingFailSetting()
270 String path = "org/apache/maven/test/get-checksum-md5-only/1.0/get-checksum-md5-only-1.0.jar";
271 setupTestableManagedRepository( path );
273 File expectedFile = new File( managedDefaultDir, path );
274 ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
276 FileUtils.deleteDirectory( expectedFile.getParentFile() );
277 assertFalse( expectedFile.exists() );
279 // Configure Connector (usually done within archiva.xml configuration)
280 saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FAIL, ReleasesPolicy.ALWAYS,
281 SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
283 File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
285 // This is a success situation. No SHA1 with a Good MD5.
286 File proxied1File = new File( REPOPATH_PROXIED1, path );
287 assertFileEquals( expectedFile, downloadedFile, proxied1File );
288 assertNoTempFiles( expectedFile );
289 assertChecksums( expectedFile, null, "f3af5201bf8da801da37db8842846e1c *get-checksum-md5-only-1.0.jar" );
293 public void testGetWithNoChecksumsUsingFailSetting()
296 String path = "org/apache/maven/test/get-default-layout/1.0/get-default-layout-1.0.jar";
297 setupTestableManagedRepository( path );
299 File expectedFile = new File( managedDefaultDir, path );
300 ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
302 FileUtils.deleteDirectory( expectedFile.getParentFile() );
303 assertFalse( expectedFile.exists() );
305 // Configure Connector (usually done within archiva.xml configuration)
306 saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FAIL, ReleasesPolicy.ALWAYS,
307 SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
309 File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
311 assertNotDownloaded( downloadedFile );
312 assertChecksums( expectedFile, null, null );
316 public void testGetChecksumCorrectSha1BadMd5UsingIgnoredSetting()
319 String path = "org/apache/maven/test/get-checksum-sha1-bad-md5/1.0/get-checksum-sha1-bad-md5-1.0.jar";
320 setupTestableManagedRepository( path );
322 File expectedFile = new File( managedDefaultDir, path );
323 ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
325 FileUtils.deleteDirectory( expectedFile.getParentFile() );
326 assertFalse( expectedFile.exists() );
328 // Configure Connector (usually done within archiva.xml configuration)
329 saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS,
330 SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
332 File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
334 File proxied1File = new File( REPOPATH_PROXIED1, path );
335 assertFileEquals( expectedFile, downloadedFile, proxied1File );
336 assertNoTempFiles( expectedFile );
337 assertChecksums( expectedFile, "3dd1a3a57b807d3ef3fbc6013d926c891cbb8670 *get-checksum-sha1-bad-md5-1.0.jar",
338 "invalid checksum file" );
342 public void testGetChecksumCorrectSha1BadMd5UsingFixSetting()
345 String path = "org/apache/maven/test/get-checksum-sha1-bad-md5/1.0/get-checksum-sha1-bad-md5-1.0.jar";
346 setupTestableManagedRepository( path );
348 File expectedFile = new File( managedDefaultDir, path );
349 ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
351 FileUtils.deleteDirectory( expectedFile.getParentFile() );
352 assertFalse( expectedFile.exists() );
354 // Configure Connector (usually done within archiva.xml configuration)
355 saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
356 SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
358 File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
360 File proxied1File = new File( REPOPATH_PROXIED1, path );
361 assertFileEquals( expectedFile, downloadedFile, proxied1File );
362 assertNoTempFiles( expectedFile );
363 assertChecksums( expectedFile, "3dd1a3a57b807d3ef3fbc6013d926c891cbb8670 *get-checksum-sha1-bad-md5-1.0.jar",
364 "c35f3b76268b73a4ba617f6f275c49ab get-checksum-sha1-bad-md5-1.0.jar" );
368 public void testGetChecksumNoSha1CorrectMd5UsingFixSetting()
371 String path = "org/apache/maven/test/get-checksum-md5-only/1.0/get-checksum-md5-only-1.0.jar";
372 setupTestableManagedRepository( path );
374 File expectedFile = new File( managedDefaultDir, path );
375 ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
377 FileUtils.deleteDirectory( expectedFile.getParentFile() );
378 assertFalse( expectedFile.exists() );
380 // Configure Connector (usually done within archiva.xml configuration)
381 saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
382 SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
384 File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
386 File proxied1File = new File( REPOPATH_PROXIED1, path );
387 assertFileEquals( expectedFile, downloadedFile, proxied1File );
388 assertNoTempFiles( expectedFile );
389 assertChecksums( expectedFile, "71f7dc3f72053a3f2d9fdd6fef9db055ef957ffb get-checksum-md5-only-1.0.jar",
390 "f3af5201bf8da801da37db8842846e1c *get-checksum-md5-only-1.0.jar" );
394 public void testGetWithNoChecksumsUsingFixSetting()
397 String path = "org/apache/maven/test/get-default-layout/1.0/get-default-layout-1.0.jar";
398 setupTestableManagedRepository( path );
400 File expectedFile = new File( managedDefaultDir, path );
401 ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
403 FileUtils.deleteDirectory( expectedFile.getParentFile() );
404 assertFalse( expectedFile.exists() );
406 // Configure Connector (usually done within archiva.xml configuration)
407 saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
408 SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
410 File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
412 File proxied1File = new File( REPOPATH_PROXIED1, path );
413 assertFileEquals( expectedFile, downloadedFile, proxied1File );
414 assertNoTempFiles( expectedFile );
415 assertChecksums( expectedFile, "1f12821c5e43e1a0b76b9564a6ddb0548ccb9486 get-default-layout-1.0.jar",
416 "3f7341545f21226b6f49a3c2704cb9be get-default-layout-1.0.jar" );
420 public void testGetChecksumNotFoundOnRemote()
423 String path = "org/apache/maven/test/get-checksum-sha1-only/1.0/get-checksum-sha1-only-1.0.jar";
424 setupTestableManagedRepository( path );
426 File expectedFile = new File( managedDefaultDir, path );
427 ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
429 FileUtils.deleteDirectory( expectedFile.getParentFile() );
430 assertFalse( expectedFile.getParentFile().exists() );
431 assertFalse( expectedFile.exists() );
433 saveRemoteRepositoryConfig( "badproxied", "Bad Proxied", "test://bad.machine.com/repo/", "default" );
435 // Configure Connector (usually done within archiva.xml configuration)
436 saveConnector( ID_DEFAULT_MANAGED, "badproxied", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS,
437 SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
439 //wagonMock.get( path, new File( expectedFile.getAbsolutePath() + ".tmp" ) );
440 //wagonMockControl.setMatcher( customWagonGetMatcher );
441 //wagonMockControl.setVoidCallable();
442 wagonMock.get( EasyMock.eq( path ), EasyMock.anyObject( File.class ));
443 EasyMock.expectLastCall().once();
445 //wagonMock.get( path + ".sha1", new File( expectedFile.getAbsolutePath() + ".sha1.tmp" ) );
446 //wagonMockControl.setMatcher( customWagonGetMatcher );
447 //wagonMockControl.setVoidCallable();
448 wagonMock.get( EasyMock.eq( path + ".sha1" ), EasyMock.anyObject( File.class ));
449 EasyMock.expectLastCall().once();
451 //wagonMock.get( path + ".md5", new File( expectedFile.getAbsolutePath() + ".md5.tmp" ) );
452 //wagonMockControl.setMatcher( customWagonGetMatcher );
453 //wagonMockControl.setThrowable( new ResourceDoesNotExistException( "Resource does not exist." ) );
455 wagonMock.get( EasyMock.eq( path + ".md5" ), EasyMock.anyObject( File.class ));
456 EasyMock.expectLastCall().andThrow( new ResourceDoesNotExistException( "Resource does not exist." ) ).once();
458 wagonMockControl.replay();
460 File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
462 wagonMockControl.verify();
464 // Do what the mock doesn't do.
465 String proxyPath = new File( REPOPATH_PROXIED1, path ).getAbsolutePath();
466 String localPath = new File( managedDefaultDir, path ).getAbsolutePath();
467 FileUtils.copyFile( new File( proxyPath ), new File( localPath ) );
468 FileUtils.copyFile( new File( proxyPath + ".sha1" ), new File( localPath + ".sha1" ) );
471 File proxied1File = new File( REPOPATH_PROXIED1, path );
472 assertFileEquals( expectedFile, downloadedFile, proxied1File );
473 assertNoTempFiles( expectedFile );
474 assertChecksums( expectedFile, "748a3a013bf5eacf2bbb40a2ac7d37889b728837 *get-checksum-sha1-only-1.0.jar",
479 public void testGetAlwaysBadChecksumPresentLocallyAbsentRemoteUsingIgnoredSetting()
482 String path = "org/apache/maven/test/get-bad-local-checksum/1.0/get-bad-local-checksum-1.0.jar";
483 setupTestableManagedRepository( path );
485 File expectedFile = new File( managedDefaultDir, path );
486 File remoteFile = new File( REPOPATH_PROXIED1, path );
488 setManagedOlderThanRemote( expectedFile, remoteFile );
490 ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
492 // Configure Connector (usually done within archiva.xml configuration)
493 saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS,
494 SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
496 File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
498 File proxied1File = new File( REPOPATH_PROXIED1, path );
499 assertFileEquals( expectedFile, downloadedFile, proxied1File );
500 assertNoTempFiles( expectedFile );
501 // There are no hashcodes on the proxy side to download, hence the local ones should remain invalid.
502 assertChecksums( expectedFile, "invalid checksum file", "invalid checksum file" );
506 public void testGetAlwaysBadChecksumPresentLocallyAbsentRemoteUsingFailSetting()
509 String path = "org/apache/maven/test/get-bad-local-checksum/1.0/get-bad-local-checksum-1.0.jar";
510 setupTestableManagedRepository( path );
512 File expectedFile = new File( managedDefaultDir, path );
513 File remoteFile = new File( REPOPATH_PROXIED1, path );
515 setManagedOlderThanRemote( expectedFile, remoteFile );
517 ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
519 // Configure Connector (usually done within archiva.xml configuration)
520 saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED1, ChecksumPolicy.FAIL, ReleasesPolicy.ALWAYS,
521 SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
523 File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
525 assertNotDownloaded( downloadedFile );
526 assertNoTempFiles( expectedFile );
527 // There are no hashcodes on the proxy side to download.
528 // The FAIL policy will delete the checksums as bad.
530 assertChecksums( expectedFile, "invalid checksum file", "invalid checksum file" );
534 public void testGetAlwaysBadChecksumPresentLocallyAbsentRemoteUsingFixSetting()
537 String path = "org/apache/maven/test/get-bad-local-checksum/1.0/get-bad-local-checksum-1.0.jar";
538 setupTestableManagedRepository( path );
540 File expectedFile = new File( managedDefaultDir, path );
541 File remoteFile = new File( REPOPATH_PROXIED1, path );
543 setManagedOlderThanRemote( expectedFile, remoteFile );
545 ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
547 // Configure Connector (usually done within archiva.xml configuration)
548 saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
549 SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
551 File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
553 File proxied1File = new File( REPOPATH_PROXIED1, path );
554 assertFileEquals( expectedFile, downloadedFile, proxied1File );
555 assertNoTempFiles( expectedFile );
556 assertChecksums( expectedFile, "96a08dc80a108cba8efd3b20aec91b32a0b2cbd4 get-bad-local-checksum-1.0.jar",
557 "46fdd6ca55bf1d7a7eb0c858f41e0ccd get-bad-local-checksum-1.0.jar" );