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   * @author <a href="snicoll@apache.org">Stephane Nicoll</a>
41   * @version $Id: FileNameMappingFactoryTest.java 485857 2006-12-11 20:34:39Z snicoll $
42   */
43  public class FileNameMappingFactoryTest
44      extends TestCase
45  {
46  
47      public void testDefaultFileNameMapping()
48      {
49          final FileNameMapping actual = FileNameMappingFactory.INSTANCE.getDefaultFileNameMapping();
50          assertNotNull( actual );
51          assertEquals( StandardFileNameMapping.class, actual.getClass() );
52      }
53  
54      public void testGetFileNameMappingByName()
55      {
56          final FileNameMapping actual =
57              FileNameMappingFactory.INSTANCE.getFileNameMapping( FileNameMappingFactory.STANDARD_FILE_NAME_MAPPING );
58          assertNotNull( actual );
59          assertEquals( StandardFileNameMapping.class, actual.getClass() );
60      }
61  
62      public void testGetFileNameMappingByName2()
63      {
64          final FileNameMapping actual =
65              FileNameMappingFactory.INSTANCE.getFileNameMapping( FileNameMappingFactory.FULL_FILE_NAME_MAPPING );
66          assertNotNull( actual );
67          assertEquals( FullFileNameMapping.class, actual.getClass() );
68      }
69  
70      public void testGetFileNameMappingByClass() {
71          final FileNameMapping actual = FileNameMappingFactory.INSTANCE.getFileNameMapping(StandardFileNameMapping.class.getName());
72          assertNotNull( actual);
73          assertEquals( StandardFileNameMapping.class, actual.getClass());
74      }
75  
76      public void testGetFileNameMappingByClass2()
77      {
78          final FileNameMapping actual =
79              FileNameMappingFactory.INSTANCE.getFileNameMapping( FullFileNameMapping.class.getName() );
80          assertNotNull( actual );
81          assertEquals( FullFileNameMapping.class, actual.getClass() );
82      }
83  
84      public void testGetFileNameMappingByUnknownClass()
85      {
86          try
87          {
88              FileNameMappingFactory.INSTANCE.getFileNameMapping( "com.foo.bar" );
89              fail("Should have failed");
90          }
91          catch ( IllegalStateException e )
92          {
93              // OK
94          }
95      }
96  }