View Javadoc

1   package org.apache.maven.plugin.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          throws Exception
42      {
43          properties = new Properties();
44          identifier = id;
45          testRootDir = PlexusTestCase.getBasedir() + "/target/test-classes/unit/test-dir/" + identifier;
46  
47          if ( !FileUtils.fileExists( testRootDir ) )
48          {
49              FileUtils.mkdir( testRootDir );
50          }
51      }
52  
53      public String getName()
54      {
55          return "Test Project " + identifier;
56      }
57  
58      public void setDescription( String desc )
59      {
60          description = desc;
61      }
62  
63      public String getDescription()
64      {
65          if ( description == null )
66          {
67              return "this is a test project";
68          }
69          else
70          {
71              return description;
72          }
73      }
74  
75      public File getBasedir()
76      {
77          // create an isolated environment
78          // see setupTestEnvironment for details
79          return new File( testRootDir );
80      }
81  
82      public String getGroupId()
83      {
84          return "org.apache.maven.plugin.test";
85      }
86  
87      public String getArtifactId()
88      {
89          return "maven-resource-plugin-test#" + identifier;
90      }
91  
92      public String getPackaging()
93      {
94          return "org.apache.maven.plugin.test";
95      }
96  
97      public String getVersion()
98      {
99          return identifier;
100     }
101 
102     public void addProperty( String key, String value )
103     {
104         properties.put( key, value );
105     }
106 
107     public Properties getProperties()
108     {
109         return properties;
110     }
111 }