1 package org.apache.maven.plugin.testing.stubs;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
41
42
43
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
56
57
58
59
60
61 public StubArtifactResolver( ArtifactStubFactory factory, boolean throwArtifactResolutionException,
62 boolean throwArtifactNotFoundException )
63 {
64 this.throwArtifactNotFoundException = throwArtifactNotFoundException;
65 this.throwArtifactResolutionException = throwArtifactResolutionException;
66 this.factory = factory;
67 }
68
69
70
71
72
73
74 public void resolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository )
75 throws ArtifactResolutionException, ArtifactNotFoundException
76 {
77 if ( !this.throwArtifactNotFoundException && !this.throwArtifactResolutionException )
78 {
79 try
80 {
81 if ( factory != null )
82 {
83 factory.setArtifactFile( artifact, factory.getWorkingDir() );
84 }
85 }
86 catch ( IOException e )
87 {
88 throw new ArtifactResolutionException( "IOException: " + e.getMessage(), artifact, e );
89 }
90 }
91 else
92 {
93 if ( throwArtifactResolutionException )
94 {
95 throw new ArtifactResolutionException( "Catch!", artifact );
96 }
97
98 throw new ArtifactNotFoundException( "Catch!", artifact );
99 }
100 }
101
102
103
104
105
106 public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
107 List remoteRepositories, ArtifactRepository localRepository,
108 ArtifactMetadataSource source )
109 throws ArtifactResolutionException, ArtifactNotFoundException
110 {
111 return null;
112 }
113
114
115
116
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 return null;
124 }
125
126
127
128
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 return null;
136 }
137
138
139
140
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 return null;
148 }
149
150
151
152
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 return null;
161 }
162
163
164
165
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 return null;
174 }
175
176
177
178
179
180
181 public void resolveAlways( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository )
182 throws ArtifactResolutionException, ArtifactNotFoundException
183 {
184
185 }
186
187 public void resolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository,
188 TransferListener downloadMonitor )
189 throws ArtifactResolutionException, ArtifactNotFoundException
190 {
191
192
193 }
194
195 public ArtifactResolutionResult collect( ArtifactResolutionRequest request )
196 {
197 return null;
198 }
199
200 public ArtifactResolutionResult resolve( ArtifactResolutionRequest request )
201 {
202 return null;
203 }
204 }