Coverage Report - org.apache.maven.plugin.testing.stubs.StubArtifactResolver
 
Classes in this File Line Coverage Branch Coverage Complexity
StubArtifactResolver
0%
0/25
0%
0/8
1,667
 
 1  
 package org.apache.maven.plugin.testing.stubs;
 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 java.io.IOException;
 23  
 import java.util.List;
 24  
 import java.util.Map;
 25  
 import java.util.Set;
 26  
 
 27  
 import org.apache.maven.artifact.Artifact;
 28  
 import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
 29  
 import org.apache.maven.artifact.repository.ArtifactRepository;
 30  
 import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
 31  
 import org.apache.maven.artifact.resolver.ArtifactResolutionException;
 32  
 import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
 33  
 import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
 34  
 import org.apache.maven.artifact.resolver.ArtifactResolver;
 35  
 import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
 36  
 import org.apache.maven.plugin.testing.ArtifactStubFactory;
 37  
 import org.apache.maven.wagon.events.TransferListener;
 38  
 
 39  
 /**
 40  
  * Stub resolver. The constructor allows the specification of the exception to throw so that handling can be tested too.
 41  
  *
 42  
  * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
 43  
  * @version $Id: StubArtifactResolver.java 800605 2009-08-03 22:45:25Z olamy $
 44  
  */
 45  
 public class StubArtifactResolver
 46  
     implements ArtifactResolver
 47  
 {
 48  
     private boolean throwArtifactResolutionException;
 49  
 
 50  
     private boolean throwArtifactNotFoundException;
 51  
 
 52  
     private ArtifactStubFactory factory;
 53  
 
 54  
     /**
 55  
      * Default constructor
 56  
      *
 57  
      * @param factory
 58  
      * @param throwArtifactResolutionException
 59  
      * @param throwArtifactNotFoundException
 60  
      */
 61  
     public StubArtifactResolver( ArtifactStubFactory factory, boolean throwArtifactResolutionException,
 62  
                                 boolean throwArtifactNotFoundException )
 63  0
     {
 64  0
         this.throwArtifactNotFoundException = throwArtifactNotFoundException;
 65  0
         this.throwArtifactResolutionException = throwArtifactResolutionException;
 66  0
         this.factory = factory;
 67  0
     }
 68  
 
 69  
     /**
 70  
      * Creates dummy file and sets it in the artifact to simulate resolution
 71  
      *
 72  
      * @see org.apache.maven.artifact.resolver.ArtifactResolver#resolve(org.apache.maven.artifact.Artifact, java.util.List, org.apache.maven.artifact.repository.ArtifactRepository)
 73  
      */
 74  
     public void resolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository )
 75  
         throws ArtifactResolutionException, ArtifactNotFoundException
 76  
     {
 77  0
         if ( !this.throwArtifactNotFoundException && !this.throwArtifactResolutionException )
 78  
         {
 79  
             try
 80  
             {
 81  0
                 if ( factory != null )
 82  
                 {
 83  0
                     factory.setArtifactFile( artifact, factory.getWorkingDir() );
 84  
                 }
 85  
             }
 86  0
             catch ( IOException e )
 87  
             {
 88  0
                 throw new ArtifactResolutionException( "IOException: " + e.getMessage(), artifact, e );
 89  0
             }
 90  
         }
 91  
         else
 92  
         {
 93  0
             if ( throwArtifactResolutionException )
 94  
             {
 95  0
                 throw new ArtifactResolutionException( "Catch!", artifact );
 96  
             }
 97  
 
 98  0
             throw new ArtifactNotFoundException( "Catch!", artifact );
 99  
         }
 100  0
     }
 101  
 
 102  
     /**
 103  
      * @return <code>null</code>.
 104  
      * @see org.apache.maven.artifact.resolver.ArtifactResolver#resolveTransitively(java.util.Set, org.apache.maven.artifact.Artifact, java.util.List, org.apache.maven.artifact.repository.ArtifactRepository, org.apache.maven.artifact.metadata.ArtifactMetadataSource)
 105  
      */
 106  
     public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
 107  
                                                         List remoteRepositories, ArtifactRepository localRepository,
 108  
                                                         ArtifactMetadataSource source )
 109  
         throws ArtifactResolutionException, ArtifactNotFoundException
 110  
     {
 111  0
         return null;
 112  
     }
 113  
 
 114  
     /**
 115  
      * @return <code>null</code>.
 116  
      * @see org.apache.maven.artifact.resolver.ArtifactResolver#resolveTransitively(java.util.Set, org.apache.maven.artifact.Artifact, java.util.List, org.apache.maven.artifact.repository.ArtifactRepository, org.apache.maven.artifact.metadata.ArtifactMetadataSource, java.util.List)
 117  
      */
 118  
     public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
 119  
                                                         List remoteRepositories, ArtifactRepository localRepository,
 120  
                                                         ArtifactMetadataSource source, List listeners )
 121  
         throws ArtifactResolutionException, ArtifactNotFoundException
 122  
     {
 123  0
         return null;
 124  
     }
 125  
 
 126  
     /**
 127  
      * @return <code>null</code>.
 128  
      * @see org.apache.maven.artifact.resolver.ArtifactResolver#resolveTransitively(java.util.Set, org.apache.maven.artifact.Artifact, org.apache.maven.artifact.repository.ArtifactRepository, java.util.List, org.apache.maven.artifact.metadata.ArtifactMetadataSource, org.apache.maven.artifact.resolver.filter.ArtifactFilter)
 129  
      */
 130  
     public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
 131  
                                                         ArtifactRepository localRepository, List remoteRepositories,
 132  
                                                         ArtifactMetadataSource source, ArtifactFilter filter )
 133  
         throws ArtifactResolutionException, ArtifactNotFoundException
 134  
     {
 135  0
         return null;
 136  
     }
 137  
 
 138  
     /**
 139  
      * @return <code>null</code>.
 140  
      * @see org.apache.maven.artifact.resolver.ArtifactResolver#resolveTransitively(java.util.Set, org.apache.maven.artifact.Artifact, java.util.Map, org.apache.maven.artifact.repository.ArtifactRepository, java.util.List, org.apache.maven.artifact.metadata.ArtifactMetadataSource)
 141  
      */
 142  
     public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
 143  
                                                         Map managedVersions, ArtifactRepository localRepository,
 144  
                                                         List remoteRepositories, ArtifactMetadataSource source )
 145  
         throws ArtifactResolutionException, ArtifactNotFoundException
 146  
     {
 147  0
         return null;
 148  
     }
 149  
 
 150  
     /**
 151  
      * @return <code>null</code>.
 152  
      * @see org.apache.maven.artifact.resolver.ArtifactResolver#resolveTransitively(java.util.Set, org.apache.maven.artifact.Artifact, java.util.Map, org.apache.maven.artifact.repository.ArtifactRepository, java.util.List, org.apache.maven.artifact.metadata.ArtifactMetadataSource, org.apache.maven.artifact.resolver.filter.ArtifactFilter)
 153  
      */
 154  
     public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
 155  
                                                         Map managedVersions, ArtifactRepository localRepository,
 156  
                                                         List remoteRepositories, ArtifactMetadataSource source,
 157  
                                                         ArtifactFilter filter )
 158  
         throws ArtifactResolutionException, ArtifactNotFoundException
 159  
     {
 160  0
         return null;
 161  
     }
 162  
 
 163  
     /**
 164  
      * @return <code>null</code>.
 165  
      * @see org.apache.maven.artifact.resolver.ArtifactResolver#resolveTransitively(java.util.Set, org.apache.maven.artifact.Artifact, java.util.Map, org.apache.maven.artifact.repository.ArtifactRepository, java.util.List, org.apache.maven.artifact.metadata.ArtifactMetadataSource, org.apache.maven.artifact.resolver.filter.ArtifactFilter, java.util.List)
 166  
      */
 167  
     public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
 168  
                                                         Map managedVersions, ArtifactRepository localRepository,
 169  
                                                         List remoteRepositories, ArtifactMetadataSource source,
 170  
                                                         ArtifactFilter filter, List listeners )
 171  
         throws ArtifactResolutionException, ArtifactNotFoundException
 172  
     {
 173  0
         return null;
 174  
     }
 175  
 
 176  
     /**
 177  
      * By default, do nothing.
 178  
      *
 179  
      * @see org.apache.maven.artifact.resolver.ArtifactResolver#resolveAlways(org.apache.maven.artifact.Artifact, java.util.List, org.apache.maven.artifact.repository.ArtifactRepository)
 180  
      */
 181  
     public void resolveAlways( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository )
 182  
         throws ArtifactResolutionException, ArtifactNotFoundException
 183  
     {
 184  
         // nop
 185  0
     }
 186  
 
 187  
     public void resolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository,
 188  
                          TransferListener downloadMonitor )
 189  
         throws ArtifactResolutionException, ArtifactNotFoundException
 190  
     {
 191  
         // TODO Auto-generated method stub
 192  
         
 193  0
     }
 194  
     
 195  
     public ArtifactResolutionResult collect( ArtifactResolutionRequest request )
 196  
     {
 197  0
         return null;
 198  
     }
 199  
 
 200  
     public ArtifactResolutionResult resolve( ArtifactResolutionRequest request )
 201  
     {
 202  0
         return null;
 203  
     }
 204  
 }