1 package org.apache.maven.plugin.resources.remote.stub;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.File;
23 import java.util.HashSet;
24 import java.util.LinkedList;
25 import java.util.Properties;
26
27 import org.apache.maven.artifact.Artifact;
28 import org.apache.maven.project.MavenProject;
29 import org.codehaus.plexus.PlexusTestCase;
30 import org.codehaus.plexus.util.FileUtils;
31
32
33
34
35 public class MavenProjectBasicStub
36 extends MavenProject
37 {
38 protected String identifier;
39
40 protected String testRootDir;
41
42 protected Properties properties;
43
44 protected String description;
45
46 protected ModelStub modelStub;
47
48 protected File file;
49
50 protected ArtifactStub artifact;
51
52 public MavenProjectBasicStub( String id )
53 throws Exception
54 {
55
56 super( new ModelStub() );
57
58 modelStub = (ModelStub) getModel();
59 properties = new Properties();
60 artifact = new ArtifactStub();
61 identifier = id;
62
63
64 testRootDir = PlexusTestCase.getBasedir() + "/target/test-classes/unit/test-dir/" + identifier;
65
66 if ( !FileUtils.fileExists( testRootDir ) )
67 {
68 FileUtils.mkdir( testRootDir );
69 }
70
71 artifact.populate( this );
72
73
74
75 initializeParentFields();
76 }
77
78 public String getName()
79 {
80 return "Test Project " + identifier;
81 }
82
83 public void setDescription( String desc )
84 {
85 description = desc;
86 }
87
88 public String getDescription()
89 {
90 if ( description == null )
91 {
92 return "this is a test project";
93 }
94 else
95 {
96 return description;
97 }
98 }
99
100 public File getBasedir()
101 {
102
103
104 return new File( testRootDir );
105 }
106
107 public Artifact getArtifact()
108 {
109 return artifact;
110 }
111
112 public String getGroupId()
113 {
114 return "org.apache.maven.plugin.test";
115 }
116
117 public String getArtifactId()
118 {
119 return "maven-resource-plugin-test#" + identifier;
120 }
121
122 public String getPackaging()
123 {
124 return "ejb";
125 }
126
127 public String getVersion()
128 {
129 return identifier;
130 }
131
132 public void addProperty( String key, String value )
133 {
134 properties.put( key, value );
135 }
136
137 public Properties getProperties()
138 {
139 return properties;
140 }
141
142
143 private void initializeParentFields()
144 {
145
146 super.setFile( new File( getBasedir(), "pom.xml" ) );
147 super.setDependencyArtifacts( new HashSet<Object>() );
148 super.setArtifacts( new HashSet<Object>() );
149 super.setPluginArtifacts( new HashSet<Object>() );
150 super.setReportArtifacts( new HashSet<Object>() );
151 super.setExtensionArtifacts( new HashSet<Object>() );
152 super.setRemoteArtifactRepositories( new LinkedList<Object>() );
153 super.setPluginArtifactRepositories( new LinkedList<Object>() );
154 super.setCollectedProjects( new LinkedList<Object>() );
155 super.setActiveProfiles( new LinkedList<Object>() );
156 super.setOriginalModel( null );
157 super.setExecutionProject( this );
158 super.setArtifact( artifact );
159 }
160 }