View Javadoc

1   package org.apache.maven.doxia.module.fo;
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 javax.swing.text.MutableAttributeSet;
23  import javax.swing.text.SimpleAttributeSet;
24  
25  import junit.framework.TestCase;
26  
27  /**
28   * FoConfiguration tests.
29   *
30   * @version $Id: FoConfigurationTest.java 806502 2009-08-21 11:33:25Z vsiveton $
31   */
32  public class FoConfigurationTest
33      extends TestCase
34  {
35  
36      /** Tests the getAttributeString( String ) method. */
37      public void testGetAttributeString()
38      {
39          FoConfiguration config = new FoConfiguration();
40  
41          assertEquals( "Null attribute ID should return empty string!", "", config.getAttributeString( null ) );
42  
43          assertEquals( "Non existent attribute ID should return empty string!", "",
44                        config.getAttributeString( "a.dummy.attribute" ) );
45  
46          assertEquals( "Wrong attributes returned for body.pre!", " font-family=\"monospace\" font-size=\"10pt\"",
47                        config.getAttributeString( "body.pre" ) );
48      }
49  
50      /** Tests the getAttributeSet( String ) method. */
51      public void testGetAttributeSet()
52      {
53          FoConfiguration config = new FoConfiguration();
54  
55          assertNull( "Null attribute ID should return null AttributeSet!", config.getAttributeSet( null ) );
56  
57          assertNull( "Empty attribute ID should return null AttributeSet!", config.getAttributeSet( "" ) );
58  
59          assertNull( "Non existent attribute ID should return null AttributeSet!",
60                      config.getAttributeSet( "a.dummy.attribute" ) );
61  
62          MutableAttributeSet expected = new SimpleAttributeSet();
63          expected.addAttribute( "font-size", "10pt" );
64          expected.addAttribute( "font-family", "monospace" );
65          MutableAttributeSet actual = config.getAttributeSet( "body.pre" );
66  
67          assertTrue( "Wrong AttributeSet returned for body.pre!", expected.isEqual( actual ) );
68      }
69  
70  }