1 package org.apache.maven.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.maven.archiva.policies.CachedFailuresPolicy;
23 import org.apache.maven.archiva.policies.ChecksumPolicy;
24 import org.apache.maven.archiva.policies.PropagateErrorsDownloadPolicy;
25 import org.apache.maven.archiva.policies.PropagateErrorsOnUpdateDownloadPolicy;
26 import org.apache.maven.archiva.policies.ProxyDownloadException;
27 import org.apache.maven.archiva.policies.ReleasesPolicy;
28 import org.apache.maven.archiva.policies.SnapshotsPolicy;
29 import org.apache.maven.archiva.repository.layout.LayoutException;
30 import org.apache.maven.wagon.ResourceDoesNotExistException;
31 import org.apache.maven.wagon.TransferFailedException;
32 import org.apache.maven.wagon.authorization.AuthorizationException;
33 import org.junit.Test;
42 public class ErrorHandlingTest
43 extends AbstractProxyTestCase
45 private static final String PATH_IN_BOTH_REMOTES_NOT_LOCAL =
46 "org/apache/maven/test/get-in-both-proxies/1.0/get-in-both-proxies-1.0.jar";
48 private static final String PATH_IN_BOTH_REMOTES_AND_LOCAL =
49 "org/apache/maven/test/get-on-multiple-repos/1.0/get-on-multiple-repos-1.0.pom";
51 private static final String ID_MOCKED_PROXIED1 = "badproxied1";
53 private static final String NAME_MOCKED_PROXIED1 = "Bad Proxied 1";
55 private static final String ID_MOCKED_PROXIED2 = "badproxied2";
57 private static final String NAME_MOCKED_PROXIED2 = "Bad Proxied 2";
60 public void testPropagateErrorImmediatelyWithErrorThenSuccess()
63 String path = PATH_IN_BOTH_REMOTES_NOT_LOCAL;
64 File expectedFile = setupRepositoriesWithLocalFileNotPresent( path );
66 createMockedProxyConnector( ID_MOCKED_PROXIED1, NAME_MOCKED_PROXIED1, PropagateErrorsDownloadPolicy.STOP );
67 saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED2, false );
69 simulateGetError( path, expectedFile, createTransferException() );
71 confirmSingleFailure( path, ID_MOCKED_PROXIED1 );
75 public void testPropagateErrorImmediatelyWithNotFoundThenError()
78 String path = PATH_IN_BOTH_REMOTES_NOT_LOCAL;
79 File expectedFile = setupRepositoriesWithLocalFileNotPresent( path );
81 createMockedProxyConnector( ID_MOCKED_PROXIED1, NAME_MOCKED_PROXIED1, PropagateErrorsDownloadPolicy.STOP );
82 createMockedProxyConnector( ID_MOCKED_PROXIED2, NAME_MOCKED_PROXIED2, PropagateErrorsDownloadPolicy.STOP );
84 simulateGetError( path, expectedFile, createResourceNotFoundException() );
86 simulateGetError( path, expectedFile, createTransferException() );
88 confirmSingleFailure( path, ID_MOCKED_PROXIED2 );
92 public void testPropagateErrorImmediatelyWithSuccessThenError()
95 String path = PATH_IN_BOTH_REMOTES_NOT_LOCAL;
96 File expectedFile = setupRepositoriesWithLocalFileNotPresent( path );
98 saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED1, false );
100 createMockedProxyConnector( ID_MOCKED_PROXIED2, NAME_MOCKED_PROXIED2, PropagateErrorsDownloadPolicy.STOP );
102 confirmSuccess( path, expectedFile, REPOPATH_PROXIED1 );
106 public void testPropagateErrorImmediatelyWithNotFoundThenSuccess()
109 String path = PATH_IN_BOTH_REMOTES_NOT_LOCAL;
110 File expectedFile = setupRepositoriesWithLocalFileNotPresent( path );
112 createMockedProxyConnector( ID_MOCKED_PROXIED1, NAME_MOCKED_PROXIED1, PropagateErrorsDownloadPolicy.STOP );
114 saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED2, false );
116 simulateGetError( path, expectedFile, createResourceNotFoundException() );
118 confirmSuccess( path, expectedFile, REPOPATH_PROXIED2 );
122 public void testPropagateErrorAtEndWithErrorThenSuccess()
125 String path = PATH_IN_BOTH_REMOTES_NOT_LOCAL;
126 File expectedFile = setupRepositoriesWithLocalFileNotPresent( path );
128 createMockedProxyConnector( ID_MOCKED_PROXIED1, NAME_MOCKED_PROXIED1, PropagateErrorsDownloadPolicy.STOP );
130 saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED2, false );
132 simulateGetError( path, expectedFile, createTransferException() );
134 confirmSingleFailure( path, ID_MOCKED_PROXIED1 );
138 public void testPropagateErrorAtEndWithSuccessThenError()
141 String path = PATH_IN_BOTH_REMOTES_NOT_LOCAL;
142 File expectedFile = setupRepositoriesWithLocalFileNotPresent( path );
144 saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED1, false );
146 createMockedProxyConnector( ID_MOCKED_PROXIED2, NAME_MOCKED_PROXIED2, PropagateErrorsDownloadPolicy.QUEUE );
148 confirmSuccess( path, expectedFile, REPOPATH_PROXIED1 );
152 public void testPropagateErrorAtEndWithNotFoundThenError()
155 String path = PATH_IN_BOTH_REMOTES_NOT_LOCAL;
156 File expectedFile = setupRepositoriesWithLocalFileNotPresent( path );
158 createMockedProxyConnector( ID_MOCKED_PROXIED1, NAME_MOCKED_PROXIED1, PropagateErrorsDownloadPolicy.QUEUE );
160 createMockedProxyConnector( ID_MOCKED_PROXIED2, NAME_MOCKED_PROXIED2, PropagateErrorsDownloadPolicy.QUEUE );
162 simulateGetError( path, expectedFile, createResourceNotFoundException() );
164 simulateGetError( path, expectedFile, createTransferException() );
166 confirmSingleFailure( path, ID_MOCKED_PROXIED2 );
170 public void testPropagateErrorAtEndWithErrorThenNotFound()
173 String path = PATH_IN_BOTH_REMOTES_NOT_LOCAL;
174 File expectedFile = setupRepositoriesWithLocalFileNotPresent( path );
176 createMockedProxyConnector( ID_MOCKED_PROXIED1, NAME_MOCKED_PROXIED1, PropagateErrorsDownloadPolicy.QUEUE );
178 createMockedProxyConnector( ID_MOCKED_PROXIED2, NAME_MOCKED_PROXIED2, PropagateErrorsDownloadPolicy.QUEUE );
180 simulateGetError( path, expectedFile, createTransferException() );
182 simulateGetError( path, expectedFile, createResourceNotFoundException() );
184 confirmSingleFailure( path, ID_MOCKED_PROXIED1 );
188 public void testPropagateErrorAtEndWithErrorThenError()
191 String path = PATH_IN_BOTH_REMOTES_NOT_LOCAL;
192 File expectedFile = setupRepositoriesWithLocalFileNotPresent( path );
194 createMockedProxyConnector( ID_MOCKED_PROXIED1, NAME_MOCKED_PROXIED1, PropagateErrorsDownloadPolicy.QUEUE );
196 createMockedProxyConnector( ID_MOCKED_PROXIED2, NAME_MOCKED_PROXIED2, PropagateErrorsDownloadPolicy.QUEUE );
198 simulateGetError( path, expectedFile, createTransferException() );
200 simulateGetError( path, expectedFile, createTransferException() );
202 confirmFailures( path, new String[]{ID_MOCKED_PROXIED1, ID_MOCKED_PROXIED2} );
206 public void testPropagateErrorAtEndWithNotFoundThenSuccess()
209 String path = PATH_IN_BOTH_REMOTES_NOT_LOCAL;
210 File expectedFile = setupRepositoriesWithLocalFileNotPresent( path );
212 createMockedProxyConnector( ID_MOCKED_PROXIED1, NAME_MOCKED_PROXIED1, PropagateErrorsDownloadPolicy.QUEUE );
214 saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED2, false );
216 simulateGetError( path, expectedFile, createResourceNotFoundException() );
218 confirmSuccess( path, expectedFile, REPOPATH_PROXIED2 );
222 public void testIgnoreErrorWithErrorThenSuccess()
225 String path = PATH_IN_BOTH_REMOTES_NOT_LOCAL;
226 File expectedFile = setupRepositoriesWithLocalFileNotPresent( path );
228 createMockedProxyConnector( ID_MOCKED_PROXIED1, NAME_MOCKED_PROXIED1, PropagateErrorsDownloadPolicy.IGNORE );
230 saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED2, false );
232 simulateGetError( path, expectedFile, createTransferException() );
234 confirmSuccess( path, expectedFile, REPOPATH_PROXIED2 );
238 public void testIgnoreErrorWithSuccessThenError()
241 String path = PATH_IN_BOTH_REMOTES_NOT_LOCAL;
242 File expectedFile = setupRepositoriesWithLocalFileNotPresent( path );
244 saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED1, false );
246 createMockedProxyConnector( ID_MOCKED_PROXIED2, NAME_MOCKED_PROXIED2, PropagateErrorsDownloadPolicy.IGNORE );
248 confirmSuccess( path, expectedFile, REPOPATH_PROXIED1 );
252 public void testIgnoreErrorWithNotFoundThenError()
255 String path = PATH_IN_BOTH_REMOTES_NOT_LOCAL;
256 File expectedFile = setupRepositoriesWithLocalFileNotPresent( path );
258 createMockedProxyConnector( ID_MOCKED_PROXIED1, NAME_MOCKED_PROXIED1, PropagateErrorsDownloadPolicy.IGNORE );
260 createMockedProxyConnector( ID_MOCKED_PROXIED2, NAME_MOCKED_PROXIED2, PropagateErrorsDownloadPolicy.IGNORE );
262 simulateGetError( path, expectedFile, createResourceNotFoundException() );
264 simulateGetError( path, expectedFile, createTransferException() );
266 confirmNotDownloadedNoError( path );
270 public void testIgnoreErrorWithErrorThenNotFound()
273 String path = PATH_IN_BOTH_REMOTES_NOT_LOCAL;
274 File expectedFile = setupRepositoriesWithLocalFileNotPresent( path );
276 createMockedProxyConnector( ID_MOCKED_PROXIED1, NAME_MOCKED_PROXIED1, PropagateErrorsDownloadPolicy.IGNORE );
278 createMockedProxyConnector( ID_MOCKED_PROXIED2, NAME_MOCKED_PROXIED2, PropagateErrorsDownloadPolicy.IGNORE );
280 simulateGetError( path, expectedFile, createTransferException() );
282 simulateGetError( path, expectedFile, createResourceNotFoundException() );
284 confirmNotDownloadedNoError( path );
288 public void testIgnoreErrorWithErrorThenError()
291 String path = PATH_IN_BOTH_REMOTES_NOT_LOCAL;
292 File expectedFile = setupRepositoriesWithLocalFileNotPresent( path );
294 createMockedProxyConnector( ID_MOCKED_PROXIED1, NAME_MOCKED_PROXIED1, PropagateErrorsDownloadPolicy.IGNORE );
296 createMockedProxyConnector( ID_MOCKED_PROXIED2, NAME_MOCKED_PROXIED2, PropagateErrorsDownloadPolicy.IGNORE );
298 simulateGetError( path, expectedFile, createTransferException() );
300 simulateGetError( path, expectedFile, createTransferException() );
302 confirmNotDownloadedNoError( path );
306 public void testPropagateOnUpdateAlwaysArtifactNotPresent()
309 String path = PATH_IN_BOTH_REMOTES_NOT_LOCAL;
310 File expectedFile = setupRepositoriesWithLocalFileNotPresent( path );
312 createMockedProxyConnector( ID_MOCKED_PROXIED1, NAME_MOCKED_PROXIED1, PropagateErrorsDownloadPolicy.STOP,
313 PropagateErrorsOnUpdateDownloadPolicy.ALWAYS );
314 createMockedProxyConnector( ID_MOCKED_PROXIED2, NAME_MOCKED_PROXIED2, PropagateErrorsDownloadPolicy.STOP,
315 PropagateErrorsOnUpdateDownloadPolicy.ALWAYS );
317 simulateGetError( path, expectedFile, createTransferException() );
319 confirmSingleFailure( path, ID_MOCKED_PROXIED1 );
323 public void testPropagateOnUpdateAlwaysArtifactPresent()
326 String path = PATH_IN_BOTH_REMOTES_AND_LOCAL;
327 File expectedFile = setupRepositoriesWithLocalFilePresent( path );
329 createMockedProxyConnector( ID_MOCKED_PROXIED1, NAME_MOCKED_PROXIED1, PropagateErrorsDownloadPolicy.STOP,
330 PropagateErrorsOnUpdateDownloadPolicy.ALWAYS );
331 createMockedProxyConnector( ID_MOCKED_PROXIED2, NAME_MOCKED_PROXIED2, PropagateErrorsDownloadPolicy.STOP,
332 PropagateErrorsOnUpdateDownloadPolicy.ALWAYS );
334 simulateGetIfNewerError( path, expectedFile, createTransferException() );
336 confirmSingleFailure( path, ID_MOCKED_PROXIED1 );
340 public void testPropagateOnUpdateAlwaysQueueArtifactNotPresent()
343 String path = PATH_IN_BOTH_REMOTES_NOT_LOCAL;
344 File expectedFile = setupRepositoriesWithLocalFileNotPresent( path );
346 createMockedProxyConnector( ID_MOCKED_PROXIED1, NAME_MOCKED_PROXIED1, PropagateErrorsDownloadPolicy.QUEUE,
347 PropagateErrorsOnUpdateDownloadPolicy.ALWAYS );
348 createMockedProxyConnector( ID_MOCKED_PROXIED2, NAME_MOCKED_PROXIED2, PropagateErrorsDownloadPolicy.QUEUE,
349 PropagateErrorsOnUpdateDownloadPolicy.ALWAYS );
351 simulateGetError( path, expectedFile, createTransferException() );
352 simulateGetError( path, expectedFile, createTransferException() );
354 confirmFailures( path, new String[] { ID_MOCKED_PROXIED1, ID_MOCKED_PROXIED2 } );
358 public void testPropagateOnUpdateAlwaysQueueArtifactPresent()
361 String path = PATH_IN_BOTH_REMOTES_AND_LOCAL;
362 File expectedFile = setupRepositoriesWithLocalFilePresent( path );
364 createMockedProxyConnector( ID_MOCKED_PROXIED1, NAME_MOCKED_PROXIED1, PropagateErrorsDownloadPolicy.QUEUE,
365 PropagateErrorsOnUpdateDownloadPolicy.ALWAYS );
366 createMockedProxyConnector( ID_MOCKED_PROXIED2, NAME_MOCKED_PROXIED2, PropagateErrorsDownloadPolicy.QUEUE,
367 PropagateErrorsOnUpdateDownloadPolicy.ALWAYS );
369 simulateGetIfNewerError( path, expectedFile, createTransferException() );
370 simulateGetIfNewerError( path, expectedFile, createTransferException() );
372 confirmFailures( path, new String[] { ID_MOCKED_PROXIED1, ID_MOCKED_PROXIED2 } );
376 public void testPropagateOnUpdateAlwaysIgnoreArtifactNotPresent()
379 String path = PATH_IN_BOTH_REMOTES_NOT_LOCAL;
380 File expectedFile = setupRepositoriesWithLocalFileNotPresent( path );
382 createMockedProxyConnector( ID_MOCKED_PROXIED1, NAME_MOCKED_PROXIED1, PropagateErrorsDownloadPolicy.IGNORE,
383 PropagateErrorsOnUpdateDownloadPolicy.ALWAYS );
384 createMockedProxyConnector( ID_MOCKED_PROXIED2, NAME_MOCKED_PROXIED2, PropagateErrorsDownloadPolicy.IGNORE,
385 PropagateErrorsOnUpdateDownloadPolicy.ALWAYS );
387 simulateGetError( path, expectedFile, createTransferException() );
388 simulateGetError( path, expectedFile, createTransferException() );
390 confirmNotDownloadedNoError( path );
394 public void testPropagateOnUpdateAlwaysIgnoreArtifactPresent()
397 String path = PATH_IN_BOTH_REMOTES_AND_LOCAL;
398 File expectedFile = setupRepositoriesWithLocalFilePresent( path );
400 createMockedProxyConnector( ID_MOCKED_PROXIED1, NAME_MOCKED_PROXIED1, PropagateErrorsDownloadPolicy.IGNORE,
401 PropagateErrorsOnUpdateDownloadPolicy.ALWAYS );
402 createMockedProxyConnector( ID_MOCKED_PROXIED2, NAME_MOCKED_PROXIED2, PropagateErrorsDownloadPolicy.IGNORE,
403 PropagateErrorsOnUpdateDownloadPolicy.ALWAYS );
405 simulateGetIfNewerError( path, expectedFile, createTransferException() );
406 simulateGetIfNewerError( path, expectedFile, createTransferException() );
408 confirmNotDownloadedNoError( path );
409 assertTrue( expectedFile.exists() );
413 public void testPropagateOnUpdateNotPresentArtifactNotPresent()
416 String path = PATH_IN_BOTH_REMOTES_NOT_LOCAL;
417 File expectedFile = setupRepositoriesWithLocalFileNotPresent( path );
419 createMockedProxyConnector( ID_MOCKED_PROXIED1, NAME_MOCKED_PROXIED1, PropagateErrorsDownloadPolicy.STOP,
420 PropagateErrorsOnUpdateDownloadPolicy.NOT_PRESENT );
421 createMockedProxyConnector( ID_MOCKED_PROXIED2, NAME_MOCKED_PROXIED2, PropagateErrorsDownloadPolicy.STOP,
422 PropagateErrorsOnUpdateDownloadPolicy.NOT_PRESENT );
424 simulateGetError( path, expectedFile, createTransferException() );
426 confirmSingleFailure( path, ID_MOCKED_PROXIED1 );
430 public void testPropagateOnUpdateNotPresentArtifactPresent()
433 String path = PATH_IN_BOTH_REMOTES_AND_LOCAL;
434 File expectedFile = setupRepositoriesWithLocalFilePresent( path );
436 createMockedProxyConnector( ID_MOCKED_PROXIED1, NAME_MOCKED_PROXIED1, PropagateErrorsDownloadPolicy.STOP,
437 PropagateErrorsOnUpdateDownloadPolicy.NOT_PRESENT );
438 createMockedProxyConnector( ID_MOCKED_PROXIED2, NAME_MOCKED_PROXIED2, PropagateErrorsDownloadPolicy.STOP,
439 PropagateErrorsOnUpdateDownloadPolicy.NOT_PRESENT );
441 simulateGetIfNewerError( path, expectedFile, createTransferException() );
443 confirmNotDownloadedNoError( path );
444 assertTrue( expectedFile.exists() );
448 public void testPropagateOnUpdateNotPresentQueueArtifactNotPresent()
451 String path = PATH_IN_BOTH_REMOTES_NOT_LOCAL;
452 File expectedFile = setupRepositoriesWithLocalFileNotPresent( path );
454 createMockedProxyConnector( ID_MOCKED_PROXIED1, NAME_MOCKED_PROXIED1, PropagateErrorsDownloadPolicy.QUEUE,
455 PropagateErrorsOnUpdateDownloadPolicy.NOT_PRESENT );
456 createMockedProxyConnector( ID_MOCKED_PROXIED2, NAME_MOCKED_PROXIED2, PropagateErrorsDownloadPolicy.QUEUE,
457 PropagateErrorsOnUpdateDownloadPolicy.NOT_PRESENT );
459 simulateGetError( path, expectedFile, createTransferException() );
460 simulateGetError( path, expectedFile, createTransferException() );
462 confirmFailures( path, new String[] { ID_MOCKED_PROXIED1, ID_MOCKED_PROXIED2 } );
466 public void testPropagateOnUpdateNotPresentQueueArtifactPresent()
469 String path = PATH_IN_BOTH_REMOTES_AND_LOCAL;
470 File expectedFile = setupRepositoriesWithLocalFilePresent( path );
472 createMockedProxyConnector( ID_MOCKED_PROXIED1, NAME_MOCKED_PROXIED1, PropagateErrorsDownloadPolicy.QUEUE,
473 PropagateErrorsOnUpdateDownloadPolicy.NOT_PRESENT );
474 createMockedProxyConnector( ID_MOCKED_PROXIED2, NAME_MOCKED_PROXIED2, PropagateErrorsDownloadPolicy.QUEUE,
475 PropagateErrorsOnUpdateDownloadPolicy.NOT_PRESENT );
477 simulateGetIfNewerError( path, expectedFile, createTransferException() );
478 simulateGetIfNewerError( path, expectedFile, createTransferException() );
480 confirmNotDownloadedNoError( path );
481 assertTrue( expectedFile.exists() );
485 public void testPropagateOnUpdateNotPresentIgnoreArtifactNotPresent()
488 String path = PATH_IN_BOTH_REMOTES_NOT_LOCAL;
489 File expectedFile = setupRepositoriesWithLocalFileNotPresent( path );
491 createMockedProxyConnector( ID_MOCKED_PROXIED1, NAME_MOCKED_PROXIED1, PropagateErrorsDownloadPolicy.IGNORE,
492 PropagateErrorsOnUpdateDownloadPolicy.NOT_PRESENT );
493 createMockedProxyConnector( ID_MOCKED_PROXIED2, NAME_MOCKED_PROXIED2, PropagateErrorsDownloadPolicy.IGNORE,
494 PropagateErrorsOnUpdateDownloadPolicy.NOT_PRESENT );
496 simulateGetError( path, expectedFile, createTransferException() );
497 simulateGetError( path, expectedFile, createTransferException() );
499 confirmNotDownloadedNoError( path );
503 public void testPropagateOnUpdateNotPresentIgnoreArtifactPresent()
506 String path = PATH_IN_BOTH_REMOTES_AND_LOCAL;
507 File expectedFile = setupRepositoriesWithLocalFilePresent( path );
509 createMockedProxyConnector( ID_MOCKED_PROXIED1, NAME_MOCKED_PROXIED1, PropagateErrorsDownloadPolicy.IGNORE,
510 PropagateErrorsOnUpdateDownloadPolicy.NOT_PRESENT );
511 createMockedProxyConnector( ID_MOCKED_PROXIED2, NAME_MOCKED_PROXIED2, PropagateErrorsDownloadPolicy.IGNORE,
512 PropagateErrorsOnUpdateDownloadPolicy.NOT_PRESENT );
514 simulateGetIfNewerError( path, expectedFile, createTransferException() );
515 simulateGetIfNewerError( path, expectedFile, createTransferException() );
517 confirmNotDownloadedNoError( path );
518 assertTrue( expectedFile.exists() );
521 // ------------------------------------------
523 // ------------------------------------------
525 private void createMockedProxyConnector( String id, String name, String errorPolicy )
527 saveRemoteRepositoryConfig( id, name, "test://bad.machine.com/repo/", "default" );
528 saveConnector( ID_DEFAULT_MANAGED, id, ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS, SnapshotsPolicy.ALWAYS,
529 CachedFailuresPolicy.NO, errorPolicy, false );
532 private void createMockedProxyConnector( String id, String name, String errorPolicy, String errorOnUpdatePolicy )
534 saveRemoteRepositoryConfig( id, name, "test://bad.machine.com/repo/", "default" );
535 saveConnector( ID_DEFAULT_MANAGED, id, ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS, SnapshotsPolicy.ALWAYS,
536 CachedFailuresPolicy.NO, errorPolicy, errorOnUpdatePolicy, false );
539 private File setupRepositoriesWithLocalFileNotPresent( String path )
542 setupTestableManagedRepository( path );
544 File file = new File( managedDefaultDir, path );
546 assertNotExistsInManagedDefaultRepo( file );
551 private File setupRepositoriesWithLocalFilePresent( String path )
554 setupTestableManagedRepository( path );
556 File file = new File( managedDefaultDir, path );
558 assertTrue( file.exists() );
563 private void simulateGetError( String path, File expectedFile, Exception throwable )
564 throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
566 wagonMock.get( path, createExpectedTempFile( expectedFile ) );
567 wagonMockControl.setMatcher(customWagonGetMatcher);
568 wagonMockControl.setThrowable( throwable, 1 );
571 private void simulateGetIfNewerError( String path, File expectedFile, TransferFailedException exception )
572 throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
574 wagonMock.getIfNewer( path, createExpectedTempFile( expectedFile ), expectedFile.lastModified() );
575 wagonMockControl.setMatcher(customWagonGetIfNewerMatcher);
576 wagonMockControl.setThrowable( exception, 1 );
579 private File createExpectedTempFile( File expectedFile )
581 return new File( managedDefaultDir, expectedFile.getName() + ".tmp" ).getAbsoluteFile();
584 private void confirmSingleFailure( String path, String id )
585 throws LayoutException
587 confirmFailures( path, new String[]{id} );
590 private void confirmFailures( String path, String[] ids )
591 throws LayoutException
593 wagonMockControl.replay();
595 // Attempt the proxy fetch.
596 File downloadedFile = null;
599 downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository,
600 managedDefaultRepository.toArtifactReference( path ) );
601 fail( "Proxy should not have succeeded" );
603 catch ( ProxyDownloadException e )
605 assertEquals( ids.length, e.getFailures().size() );
606 for ( String id : ids )
608 assertTrue( e.getFailures().keySet().contains( id ) );
612 wagonMockControl.verify();
614 assertNotDownloaded( downloadedFile );
617 private void confirmSuccess( String path, File expectedFile, String basedir )
620 File downloadedFile = performDownload( path );
622 File proxied1File = new File( basedir, path );
623 assertFileEquals( expectedFile, downloadedFile, proxied1File );
626 private void confirmNotDownloadedNoError( String path )
629 File downloadedFile = performDownload( path );
631 assertNotDownloaded( downloadedFile );
634 private File performDownload( String path )
635 throws ProxyDownloadException, LayoutException
637 wagonMockControl.replay();
639 // Attempt the proxy fetch.
640 File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository,
641 managedDefaultRepository.toArtifactReference( path ) );
643 wagonMockControl.verify();
644 return downloadedFile;
647 private static TransferFailedException createTransferException()
649 return new TransferFailedException( "test download exception" );
652 private static ResourceDoesNotExistException createResourceNotFoundException()
654 return new ResourceDoesNotExistException( "test download not found" );