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   * Copyright 2001-2006 The Apache Software Foundation.
26   *
27   * Licensed under the Apache License, Version 2.0 (the "License");
28   * you may not use this file except in compliance with the License.
29   * You may obtain a copy of the License at
30   *
31   *      http://www.apache.org/licenses/LICENSE-2.0
32   *
33   * Unless required by applicable law or agreed to in writing, software
34   * distributed under the License is distributed on an "AS IS" BASIS,
35   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
36   * See the License for the specific language governing permissions and
37   * limitations under the License.
38   */
39  
40  /**
41   * @author <a href="snicoll@apache.org">Stephane Nicoll</a>
42   * @version $Id: FileNameMappingFactoryTest.java 992847 2010-09-05 18:16:55Z snicoll $
43   */
44  public class FileNameMappingFactoryTest
45      extends TestCase
46  {
47  
48      public void testDefaultFileNameMapping()
49      {
50          final FileNameMapping actual = FileNameMappingFactory.getDefaultFileNameMapping();
51          assertNotNull( actual );
52          assertEquals( StandardFileNameMapping.class, actual.getClass() );
53      }
54  
55      public void testGetFileNameMappingByName()
56      {
57          final FileNameMapping actual =
58              FileNameMappingFactory.getFileNameMapping( FileNameMappingFactory.STANDARD_FILE_NAME_MAPPING );
59          assertNotNull( actual );
60          assertEquals( StandardFileNameMapping.class, actual.getClass() );
61      }
62  
63      public void testGetFileNameMappingByName2()
64      {
65          final FileNameMapping actual =
66              FileNameMappingFactory.getFileNameMapping( FileNameMappingFactory.FULL_FILE_NAME_MAPPING );
67          assertNotNull( actual );
68          assertEquals( FullFileNameMapping.class, actual.getClass() );
69      }
70  
71      public void testGetFileNameMappingByName3()
72      {
73          final FileNameMapping actual =
74              FileNameMappingFactory.getFileNameMapping( FileNameMappingFactory.NO_VERSION_FILE_NAME_MAPPING );
75          assertNotNull( actual );
76          assertEquals( NoVersionFileNameMapping.class, actual.getClass() );
77      }
78  
79      public void testGetFileNameMappingByClass()
80      {
81          final FileNameMapping actual =
82              FileNameMappingFactory.getFileNameMapping( StandardFileNameMapping.class.getName() );
83          assertNotNull( actual );
84          assertEquals( StandardFileNameMapping.class, actual.getClass() );
85      }
86  
87      public void testGetFileNameMappingByClass2()
88      {
89          final FileNameMapping actual = FileNameMappingFactory.getFileNameMapping( FullFileNameMapping.class.getName() );
90          assertNotNull( actual );
91          assertEquals( FullFileNameMapping.class, actual.getClass() );
92      }
93  
94      public void testGetFileNameMappingByUnknownClass()
95      {
96          try
97          {
98              FileNameMappingFactory.getFileNameMapping( "com.foo.bar" );
99              fail( "Should have failed" );
100         }
101         catch ( IllegalStateException e )
102         {
103             // OK
104         }
105     }
106 }