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.source;
20  
21  import java.io.File;
22  
23  /**
24   * @author <a href="mailto:oching@exist.com">Maria Odea Ching</a>
25   */
26  public class TestSourceJarMojoTest extends AbstractSourcePluginTestCase {
27  
28      protected String getGoal() {
29          return "test-jar";
30      }
31  
32      public void testDefaultConfiguration() throws Exception {
33          doTestProjectWithTestSourceArchive(
34                  "project-001",
35                  new String[] {
36                      "test-default-configuration.properties",
37                      "foo/project001/AppTest.java",
38                      "foo/project001/",
39                      "foo/",
40                      "META-INF/MANIFEST.MF",
41                      "META-INF/",
42                      "META-INF/maven/",
43                      "META-INF/maven/source/",
44                      "META-INF/maven/source/maven-source-plugin-test-project-001/",
45                      "META-INF/maven/source/maven-source-plugin-test-project-001/pom.properties",
46                      "META-INF/maven/source/maven-source-plugin-test-project-001/pom.xml"
47                  },
48                  "test-sources");
49      }
50  
51      public void testExcludes() throws Exception {
52          doTestProjectWithTestSourceArchive(
53                  "project-003",
54                  new String[] {
55                      "test-default-configuration.properties",
56                      "foo/project003/AppTest.java",
57                      "foo/project003/",
58                      "foo/",
59                      "META-INF/MANIFEST.MF",
60                      "META-INF/",
61                      "META-INF/maven/",
62                      "META-INF/maven/source/",
63                      "META-INF/maven/source/maven-source-plugin-test-project-003/",
64                      "META-INF/maven/source/maven-source-plugin-test-project-003/pom.properties",
65                      "META-INF/maven/source/maven-source-plugin-test-project-003/pom.xml"
66                  },
67                  "test-sources");
68      }
69  
70      public void testNoSources() throws Exception {
71          executeMojo("project-005", "test-sources");
72  
73          // Now make sure that no archive got created
74          final File expectedFile = getTestTargetDir("project-005");
75          assertFalse(
76                  "Test source archive should not have been created[" + expectedFile.getAbsolutePath() + "]",
77                  expectedFile.exists());
78      }
79  
80      public void testIncludeMavenDescriptorWhenExplicitlyConfigured() throws Exception {
81          doTestProjectWithTestSourceArchive(
82                  "project-010",
83                  new String[] {
84                      "test-default-configuration.properties",
85                      "foo/project010/AppTest.java",
86                      "foo/project010/",
87                      "foo/",
88                      "META-INF/MANIFEST.MF",
89                      "META-INF/",
90                      "META-INF/maven/",
91                      "META-INF/maven/source/",
92                      "META-INF/maven/source/maven-source-plugin-test-project-010/",
93                      "META-INF/maven/source/maven-source-plugin-test-project-010/pom.xml",
94                      "META-INF/maven/source/maven-source-plugin-test-project-010/pom" + ".properties"
95                  },
96                  "test-sources");
97      }
98  }