01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: */
18: package org.apache.ivy.plugins.resolver;
19:
20: import java.io.File;
21: import java.io.IOException;
22: import java.text.ParseException;
23: import java.util.ArrayList;
24: import java.util.Date;
25: import java.util.List;
26:
27: import org.apache.ivy.core.cache.RepositoryCacheManager;
28: import org.apache.ivy.core.module.descriptor.Artifact;
29: import org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor;
30: import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
31: import org.apache.ivy.core.module.id.ModuleRevisionId;
32: import org.apache.ivy.core.report.DownloadReport;
33: import org.apache.ivy.core.report.MetadataArtifactDownloadReport;
34: import org.apache.ivy.core.resolve.DownloadOptions;
35: import org.apache.ivy.core.resolve.ResolveData;
36: import org.apache.ivy.core.resolve.ResolvedModuleRevision;
37: import org.apache.ivy.plugins.resolver.util.ResolvedResource;
38:
39: public class MockResolver extends AbstractResolver {
40: static MockResolver buildMockResolver(String name,
41: boolean findRevision, final Date publicationDate) {
42: return buildMockResolver(name, findRevision, ModuleRevisionId
43: .newInstance("test", "test", "test"), publicationDate);
44: }
45:
46: static MockResolver buildMockResolver(String name,
47: boolean findRevision, final ModuleRevisionId mrid,
48: final Date publicationDate) {
49: return buildMockResolver(name, findRevision, mrid,
50: publicationDate, false);
51: }
52:
53: static MockResolver buildMockResolver(String name,
54: boolean findRevision, final ModuleRevisionId mrid,
55: final Date publicationDate, final boolean isdefault) {
56: final MockResolver r = new MockResolver();
57: r.setName(name);
58: if (findRevision) {
59: DefaultModuleDescriptor md = new DefaultModuleDescriptor(
60: mrid, "integration", publicationDate, isdefault);
61: r.rmr = new ResolvedModuleRevision(r, r, md,
62: new MetadataArtifactDownloadReport(md
63: .getMetadataArtifact()));
64: }
65: return r;
66: }
67:
68: List askedDeps = new ArrayList();
69:
70: ResolvedModuleRevision rmr;
71:
72: public ResolvedModuleRevision getDependency(
73: DependencyDescriptor dd, ResolveData data)
74: throws ParseException {
75: askedDeps.add(dd);
76: return rmr;
77: }
78:
79: public DownloadReport download(Artifact[] artifacts,
80: DownloadOptions options) {
81: return null;
82: }
83:
84: public void publish(Artifact artifact, File src, boolean overwrite)
85: throws IOException {
86: }
87:
88: public ResolvedResource findIvyFileRef(DependencyDescriptor dd,
89: ResolveData data) {
90: return null;
91: }
92:
93: public RepositoryCacheManager getRepositoryCacheManager() {
94: return null;
95: }
96:
97: }
|