View Javadoc

1   package org.apache.turbine.services.mimetype;
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.util.Locale;
23  
24  import org.apache.fulcrum.mimetype.MimeTypeService;
25  import org.apache.turbine.services.ServiceManager;
26  import org.apache.turbine.services.TurbineServices;
27  import org.apache.turbine.test.BaseTestCase;
28  import org.apache.turbine.util.TurbineConfig;
29  import org.junit.AfterClass;
30  import org.junit.BeforeClass;
31  import org.junit.Test;
32  
33  import static org.junit.Assert.*;
34  
35  /**
36   * Unit test for Accessing the Fulcrum Mimetype component within Turbine.
37   *
38   * @author <a href="mailto:epugh@upstate.com">Eric Pugh</a>
39   * @author <a href="mailto:sgoeschl@apache.org">Siegfried Goeschl</a>
40   * @version $Id: FulcrumMimetypeComponentTest.java 1606111 2014-06-27 14:46:47Z gk $
41   */
42  public class FulcrumMimetypeComponentTest extends BaseTestCase
43  {
44      private static TurbineConfig tc = null;
45  
46      @Test public void testComponent() throws Exception
47      {
48          ServiceManager serviceManager = TurbineServices.getInstance();
49          MimeTypeService mimeTypeService = (MimeTypeService) serviceManager.getService(MimeTypeService.class.getName());
50  
51          Locale locale = new Locale("en", "US");
52          String s = mimeTypeService.getCharSet(locale);
53          assertEquals("ISO-8859-1", s);
54      }
55  
56      @BeforeClass
57      public static void setUp() throws Exception
58      {
59          tc =
60              new TurbineConfig(
61                  ".",
62                  "/conf/test/TestFulcrumComponents.properties");
63          tc.initialize();
64      }
65      @AfterClass
66      public static void tearDown() throws Exception
67      {
68          if (tc != null)
69          {
70              tc.dispose();
71          }
72      }
73  }