View Javadoc

1   package org.apache.maven.plugin.source;
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  
24  /**
25   * @author <a href="mailto:oching@exist.com">Maria Odea Ching</a>
26   */
27  public class SourceJarMojoTest
28      extends AbstractSourcePluginTestCase
29  {
30      protected String getGoal()
31      {
32          return "jar";
33      }
34  
35      public void testDefaultConfiguration()
36          throws Exception
37      {
38          doTestProjectWithSourceArchive( "project-001",
39                                          new String[]{ "default-configuration.properties", "foo/project001/App.java",
40                                              "foo/project001/", "foo/", "META-INF/MANIFEST.MF", "META-INF/" },
41                                          "sources" );
42      }
43  
44      public void testExcludes()
45          throws Exception
46      {
47          doTestProjectWithSourceArchive( "project-003",
48                                          new String[]{ "default-configuration.properties", "foo/project003/App.java",
49                                              "foo/project003/", "foo/", "META-INF/MANIFEST.MF", "META-INF/" },
50                                          "sources" );
51      }
52  
53      public void testNoSources()
54          throws Exception
55      {
56          executeMojo( "project-005", "sources" );
57          // Now make sure that no archive got created
58          final File expectedFile = getTestTargetDir( "project-005" );
59          assertFalse( "Source archive should not have been created[" + expectedFile.getAbsolutePath() + "]",
60                       expectedFile.exists() );
61      }
62  
63      public void testIncludes()
64          throws Exception
65      {
66          doTestProjectWithSourceArchive( "project-007", new String[]{ "templates/configuration-template.properties",
67              "foo/project007/App.java", "templates/", "foo/project007/", "foo/", "META-INF/MANIFEST.MF", "META-INF/"
68  
69          }, "sources" );
70      }
71  
72      public void testIncludePom()
73          throws Exception
74      {
75          doTestProjectWithSourceArchive( "project-009", new String[]{ "default-configuration.properties", "pom.xml",
76              "foo/project009/App.java", "foo/project009/", "foo/", "META-INF/MANIFEST.MF", "META-INF/" }, "sources" );
77      }
78  }