View Javadoc

1   package org.apache.maven.plugin.ear.output;
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 junit.framework.TestCase;
23  
24  /**
25   * @author <a href="snicoll@apache.org">Stephane Nicoll</a>
26   * @version $Id: FileNameMappingFactoryTest.java 1368659 2012-08-02 19:28:23Z snicoll $
27   */
28  public class FileNameMappingFactoryTest
29      extends TestCase
30  {
31  
32      public void testDefaultFileNameMapping()
33      {
34          final FileNameMapping actual = FileNameMappingFactory.getDefaultFileNameMapping();
35          assertNotNull( actual );
36          assertEquals( StandardFileNameMapping.class, actual.getClass() );
37      }
38  
39      public void testGetFileNameMappingByName()
40      {
41          final FileNameMapping actual =
42              FileNameMappingFactory.getFileNameMapping( FileNameMappingFactory.STANDARD_FILE_NAME_MAPPING );
43          assertNotNull( actual );
44          assertEquals( StandardFileNameMapping.class, actual.getClass() );
45      }
46  
47      public void testGetFileNameMappingByName2()
48      {
49          final FileNameMapping actual =
50              FileNameMappingFactory.getFileNameMapping( FileNameMappingFactory.FULL_FILE_NAME_MAPPING );
51          assertNotNull( actual );
52          assertEquals( FullFileNameMapping.class, actual.getClass() );
53      }
54  
55      public void testGetFileNameMappingByName3()
56      {
57          final FileNameMapping actual =
58              FileNameMappingFactory.getFileNameMapping( FileNameMappingFactory.NO_VERSION_FILE_NAME_MAPPING );
59          assertNotNull( actual );
60          assertEquals( NoVersionFileNameMapping.class, actual.getClass() );
61      }
62  
63      public void testGetFileNameMappingByName4()
64      {
65          final FileNameMapping actual =
66              FileNameMappingFactory.getFileNameMapping( FileNameMappingFactory.NO_VERSION_FOR_EJB_FILE_NAME_MAPPING );
67          assertNotNull( actual );
68          assertEquals( NoVersionForEjbFileNameMapping.class, actual.getClass() );
69      }
70  
71      public void testGetFileNameMappingByClass()
72      {
73          final FileNameMapping actual =
74              FileNameMappingFactory.getFileNameMapping( StandardFileNameMapping.class.getName() );
75          assertNotNull( actual );
76          assertEquals( StandardFileNameMapping.class, actual.getClass() );
77      }
78  
79      public void testGetFileNameMappingByClass2()
80      {
81          final FileNameMapping actual = FileNameMappingFactory.getFileNameMapping( FullFileNameMapping.class.getName() );
82          assertNotNull( actual );
83          assertEquals( FullFileNameMapping.class, actual.getClass() );
84      }
85  
86      public void testGetFileNameMappingByUnknownClass()
87      {
88          try
89          {
90              FileNameMappingFactory.getFileNameMapping( "com.foo.bar" );
91              fail( "Should have failed" );
92          }
93          catch ( IllegalStateException e )
94          {
95              // OK
96          }
97      }
98  }