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