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", new String[]{"default-configuration.properties",
39              "foo/project001/App.java", "foo/project001/", "foo/", "META-INF/MANIFEST.MF", "META-INF/"} );
40      }
41  
42      public void testExcludes()
43          throws Exception
44      {
45          doTestProjectWithSourceArchive( "project-003", new String[]{"default-configuration.properties",
46              "foo/project003/App.java", "foo/project003/", "foo/", "META-INF/MANIFEST.MF", "META-INF/"
47  
48          } );
49      }
50  
51      public void testNoSources()
52          throws Exception
53      {
54          executeMojo( "project-005" );
55          // Now make sure that no archive got created
56          final File expectedFile = getTestTargetDir( "project-005" );
57          assertFalse( "Source archive should not have been created[" + expectedFile.getAbsolutePath() + "]",
58                       expectedFile.exists() );
59      }
60  
61      public void testIncludes()
62          throws Exception
63      {
64          doTestProjectWithSourceArchive( "project-007", new String[]{"templates/configuration-template.properties",
65              "foo/project007/App.java", "templates/", "foo/project007/", "foo/", "META-INF/MANIFEST.MF", "META-INF/"
66  
67          } );
68      }
69  
70      public void testIncludePom()
71          throws Exception
72      {
73          doTestProjectWithSourceArchive( "project-009", new String[]{"default-configuration.properties", "pom.xml",
74              "foo/project009/App.java", "foo/project009/", "foo/", "META-INF/MANIFEST.MF", "META-INF/"} );
75      }
76  }