1 package org.apache.maven.plugins.javadoc.stubs;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import static org.mockito.Mockito.mock;
23 import static org.mockito.Mockito.when;
24
25 import org.apache.maven.artifact.Artifact;
26 import org.apache.maven.model.Build;
27 import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
28
29 import java.io.File;
30 import java.util.ArrayList;
31 import java.util.HashSet;
32 import java.util.List;
33 import java.util.Set;
34
35
36
37
38
39 public class ProxyTestMavenProjectStub
40 extends MavenProjectStub
41 {
42 private Set<Artifact> dependencyArtifacts = new HashSet<>();
43
44 public ProxyTestMavenProjectStub()
45 {
46 readModel( new File( getBasedir(), "proxy-test-plugin-config.xml" ) );
47
48 setGroupId( getModel().getGroupId() );
49 setArtifactId( getModel().getArtifactId() );
50 setVersion( getModel().getVersion() );
51 setName( getModel().getName() );
52 setUrl( getModel().getUrl() );
53 setPackaging( getModel().getPackaging() );
54
55 Build build = new Build();
56 build.setFinalName( getModel().getArtifactId() );
57 build.setSourceDirectory( getBasedir() + "/src/main/java" );
58 build.setDirectory( super.getBasedir() + "/target/test/unit/proxy-test/target" );
59 setBuild( build );
60
61 List<String> compileSourceRoots = new ArrayList<>();
62 compileSourceRoots.add( getBasedir() + "/src/main/java" );
63 setCompileSourceRoots( compileSourceRoots );
64
65
66 Artifact artifact = mock( Artifact.class );
67 when( artifact.getGroupId()).thenReturn( "commons-logging" );
68 when( artifact.getArtifactId()).thenReturn( "commons-logging" );
69 when( artifact.getVersion()).thenReturn( "1.1.1" );
70 when( artifact.getScope()).thenReturn( Artifact.SCOPE_RUNTIME );
71 when( artifact.getType()).thenReturn( "jar" );
72 when( artifact.getFile()).thenReturn( getBasedir() );
73 DefaultArtifactHandlerStub artifactHandler = new DefaultArtifactHandlerStub();
74 artifactHandler.setExtension( "jar" );
75 when( artifact.getArtifactHandler()).thenReturn( artifactHandler );
76
77 dependencyArtifacts.add( artifact );
78 }
79
80
81 @Override
82 public File getBasedir()
83 {
84 return new File( super.getBasedir() + "/src/test/resources/unit/proxy-test" );
85 }
86
87 @Override
88 public Set<Artifact> getDependencyArtifacts()
89 {
90 return dependencyArtifacts;
91 }
92 }