001package org.apache.turbine.services.mimetype;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 *   http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022import java.util.Locale;
023
024import org.apache.fulcrum.mimetype.MimeTypeService;
025import org.apache.turbine.services.ServiceManager;
026import org.apache.turbine.services.TurbineServices;
027import org.apache.turbine.test.BaseTestCase;
028import org.apache.turbine.util.TurbineConfig;
029import org.junit.AfterClass;
030import org.junit.BeforeClass;
031import org.junit.Test;
032
033import static org.junit.Assert.*;
034
035/**
036 * Unit test for Accessing the Fulcrum Mimetype component within Turbine.
037 *
038 * @author <a href="mailto:epugh@upstate.com">Eric Pugh</a>
039 * @author <a href="mailto:sgoeschl@apache.org">Siegfried Goeschl</a>
040 * @version $Id: FulcrumMimetypeComponentTest.java 1606111 2014-06-27 14:46:47Z gk $
041 */
042public class FulcrumMimetypeComponentTest extends BaseTestCase
043{
044    private static TurbineConfig tc = null;
045
046    @Test public void testComponent() throws Exception
047    {
048        ServiceManager serviceManager = TurbineServices.getInstance();
049        MimeTypeService mimeTypeService = (MimeTypeService) serviceManager.getService(MimeTypeService.class.getName());
050
051        Locale locale = new Locale("en", "US");
052        String s = mimeTypeService.getCharSet(locale);
053        assertEquals("ISO-8859-1", s);
054    }
055
056    @BeforeClass
057    public static void setUp() throws Exception
058    {
059        tc =
060            new TurbineConfig(
061                ".",
062                "/conf/test/TestFulcrumComponents.properties");
063        tc.initialize();
064    }
065    @AfterClass
066    public static void tearDown() throws Exception
067    {
068        if (tc != null)
069        {
070            tc.dispose();
071        }
072    }
073}