001package org.apache.maven.doxia.module.fo;
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 javax.swing.text.MutableAttributeSet;
023import javax.swing.text.SimpleAttributeSet;
024
025import junit.framework.TestCase;
026
027/**
028 * FoConfiguration tests.
029 *
030 * @version $Id$
031 */
032public class FoConfigurationTest
033    extends TestCase
034{
035
036    /** Tests the getAttributeString( String ) method. */
037    public void testGetAttributeString()
038    {
039        FoConfiguration config = new FoConfiguration();
040
041        assertEquals( "Null attribute ID should return empty string!", "", config.getAttributeString( null ) );
042
043        assertEquals( "Non existent attribute ID should return empty string!", "",
044                      config.getAttributeString( "a.dummy.attribute" ) );
045
046        assertEquals( "Wrong attributes returned for italic!", " font-style=\"italic\"",
047                      config.getAttributeString( "italic" ) );
048    }
049
050    /** Tests the getAttributeSet( String ) method. */
051    public void testGetAttributeSet()
052    {
053        FoConfiguration config = new FoConfiguration();
054
055        assertNull( "Null attribute ID should return null AttributeSet!", config.getAttributeSet( null ) );
056
057        assertNull( "Empty attribute ID should return null AttributeSet!", config.getAttributeSet( "" ) );
058
059        assertNull( "Non existent attribute ID should return null AttributeSet!",
060                    config.getAttributeSet( "a.dummy.attribute" ) );
061
062        MutableAttributeSet expected = new SimpleAttributeSet();
063        expected.addAttribute( "font-style", "italic" );
064        MutableAttributeSet actual = config.getAttributeSet( "italic" );
065
066        assertTrue( "Wrong AttributeSet returned for italic!", expected.isEqual( actual ) );
067    }
068
069}