001package org.apache.maven.doxia.module.itext;
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 junit.framework.TestCase;
025
026import com.lowagie.text.PageSize;
027
028/**
029 * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
030 * @version $Id$
031 */
032public class ITextUtilTest
033    extends TestCase
034{
035    public void testGetDefaultPageSize()
036        throws Exception
037    {
038        Locale oldLocale = Locale.getDefault();
039
040        try
041        {
042            Locale.setDefault( Locale.US );
043            assertEquals( PageSize.LETTER, ITextUtil.getDefaultPageSize() );
044
045            Locale.setDefault( Locale.CANADA );
046            assertEquals( PageSize.LETTER, ITextUtil.getDefaultPageSize() );
047
048            Locale.setDefault( Locale.FRANCE );
049            assertEquals( PageSize.A4, ITextUtil.getDefaultPageSize() );
050        }
051        finally
052        {
053            Locale.setDefault( oldLocale );
054        }
055    }
056
057    public void testGetPageSize()
058        throws Exception
059    {
060        assertEquals( "A0", ITextUtil.getPageSize( PageSize.A0 ) );
061        assertEquals( "A1", ITextUtil.getPageSize( PageSize.A1 ) );
062        assertEquals( "A2", ITextUtil.getPageSize( PageSize.A2 ) );
063        assertEquals( "A3", ITextUtil.getPageSize( PageSize.A3 ) );
064        assertEquals( "A4", ITextUtil.getPageSize( PageSize.A4 ) );
065        assertEquals( "A5", ITextUtil.getPageSize( PageSize.A5 ) );
066        assertEquals( "A6", ITextUtil.getPageSize( PageSize.A6 ) );
067        assertEquals( "A7", ITextUtil.getPageSize( PageSize.A7 ) );
068        assertEquals( "A8", ITextUtil.getPageSize( PageSize.A8 ) );
069        assertEquals( "A9", ITextUtil.getPageSize( PageSize.A9 ) );
070        assertEquals( "A10", ITextUtil.getPageSize( PageSize.A10 ) );
071        assertEquals( "LETTER", ITextUtil.getPageSize( PageSize.LETTER ) );
072        assertEquals( "LEGAL", ITextUtil.getPageSize( PageSize.LEGAL ) );
073    }
074
075    public void testIsPageSupported()
076        throws Exception
077    {
078        assertEquals( true, ITextUtil.isPageSizeSupported( "A0" ) );
079        assertEquals( true, ITextUtil.isPageSizeSupported( "A1" ) );
080        assertEquals( true, ITextUtil.isPageSizeSupported( "A2" ) );
081        assertEquals( true, ITextUtil.isPageSizeSupported( "A3" ) );
082        assertEquals( true, ITextUtil.isPageSizeSupported( "A4" ) );
083        assertEquals( true, ITextUtil.isPageSizeSupported( "A5" ) );
084        assertEquals( true, ITextUtil.isPageSizeSupported( "A6" ) );
085        assertEquals( true, ITextUtil.isPageSizeSupported( "A7" ) );
086        assertEquals( true, ITextUtil.isPageSizeSupported( "A8" ) );
087        assertEquals( true, ITextUtil.isPageSizeSupported( "A9" ) );
088        assertEquals( true, ITextUtil.isPageSizeSupported( "A10" ) );
089        assertEquals( true, ITextUtil.isPageSizeSupported( "LETTER" ) );
090        assertEquals( true, ITextUtil.isPageSizeSupported( "letter" ) );
091        assertEquals( true, ITextUtil.isPageSizeSupported( "LEGAL" ) );
092        assertEquals( true, ITextUtil.isPageSizeSupported( "legal" ) );
093    }
094}