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