View Javadoc
1   package org.apache.maven.plugins.resources.stub;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.io.File;
23  import java.util.Properties;
24  
25  import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
26  import org.codehaus.plexus.PlexusTestCase;
27  import org.codehaus.plexus.util.FileUtils;
28  
29  public class MavenProjectBasicStub
30      extends MavenProjectStub
31  {
32      protected String identifier;
33  
34      protected String testRootDir;
35  
36      protected Properties properties;
37  
38      protected String description;
39  
40      public MavenProjectBasicStub( String id )
41      {
42          properties = new Properties();
43          identifier = id;
44          testRootDir = PlexusTestCase.getBasedir() + "/target/test-classes/unit/test-dir/" + identifier;
45  
46          if ( !FileUtils.fileExists( testRootDir ) )
47          {
48              FileUtils.mkdir( testRootDir );
49          }
50      }
51  
52      public String getName()
53      {
54          return "Test Project " + identifier;
55      }
56  
57      public void setDescription( String desc )
58      {
59          description = desc;
60      }
61  
62      public String getDescription()
63      {
64          if ( description == null )
65          {
66              return "this is a test project";
67          }
68          else
69          {
70              return description;
71          }
72      }
73  
74      public File getBasedir()
75      {
76          // create an isolated environment
77          // see setupTestEnvironment for details
78          return new File( testRootDir );
79      }
80  
81      public String getGroupId()
82      {
83          return "org.apache.maven.plugin.test";
84      }
85  
86      public String getArtifactId()
87      {
88          return "maven-resource-plugin-test#" + identifier;
89      }
90  
91      public String getPackaging()
92      {
93          return "org.apache.maven.plugin.test";
94      }
95  
96      public String getVersion()
97      {
98          return identifier;
99      }
100 
101     public void addProperty( String key, String value )
102     {
103         properties.put( key, value );
104     }
105 
106     public Properties getProperties()
107     {
108         return properties;
109     }
110 }