001package org.apache.maven.doxia.module.docbook; 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 junit.framework.TestCase; 023 024import org.apache.maven.doxia.sink.Sink; 025 026/** 027 * Test DocbookUtils. 028 * 029 * @author ltheussl 030 * @version $Id$ 031 */ 032public class DocbookUtilsTest 033 extends TestCase 034{ 035 /** 036 * Test of doxiaTableFrameAttribute method, of class DocbookUtils. 037 */ 038 public void testDoxiaTableFrameAttribute() 039 { 040 assertEquals( "box", DocbookUtils.doxiaTableFrameAttribute( "all" ) ); 041 assertEquals( "below", DocbookUtils.doxiaTableFrameAttribute( "bottom" ) ); 042 assertEquals( "void", DocbookUtils.doxiaTableFrameAttribute( "none" ) ); 043 assertEquals( "vsides", DocbookUtils.doxiaTableFrameAttribute( "sides" ) ); 044 assertEquals( "above", DocbookUtils.doxiaTableFrameAttribute( "top" ) ); 045 assertEquals( "hsides", DocbookUtils.doxiaTableFrameAttribute( "topbot" ) ); 046 047 try 048 { 049 DocbookUtils.doxiaTableFrameAttribute( "" ); 050 fail(); 051 } 052 catch ( IllegalArgumentException e ) 053 { 054 assertNotNull( e ); 055 } 056 } 057 058 /** 059 * Test of doxiaListNumbering method, of class DocbookUtils. 060 */ 061 public void testDoxiaListNumbering() 062 { 063 assertEquals( Sink.NUMBERING_LOWER_ALPHA, 064 DocbookUtils.doxiaListNumbering( SimplifiedDocbookMarkup.LOWERALPHA_STYLE ) ); 065 assertEquals( Sink.NUMBERING_LOWER_ROMAN, 066 DocbookUtils.doxiaListNumbering( SimplifiedDocbookMarkup.LOWERROMAN_STYLE ) ); 067 assertEquals( Sink.NUMBERING_UPPER_ALPHA, 068 DocbookUtils.doxiaListNumbering( SimplifiedDocbookMarkup.UPPERALPHA_STYLE ) ); 069 assertEquals( Sink.NUMBERING_UPPER_ROMAN, 070 DocbookUtils.doxiaListNumbering( SimplifiedDocbookMarkup.UPPERROMAN_STYLE ) ); 071 assertEquals( Sink.NUMBERING_DECIMAL, 072 DocbookUtils.doxiaListNumbering( SimplifiedDocbookMarkup.ARABIC_STYLE ) ); 073 074 try 075 { 076 DocbookUtils.doxiaListNumbering( "" ); 077 fail(); 078 } 079 catch ( IllegalArgumentException e ) 080 { 081 assertNotNull( e ); 082 } 083 } 084 085 /** 086 * Test of docbookListNumbering method, of class DocbookUtils. 087 */ 088 public void testDocbookListNumbering() 089 { 090 assertEquals( SimplifiedDocbookMarkup.UPPERALPHA_STYLE, 091 DocbookUtils.docbookListNumbering( Sink.NUMBERING_UPPER_ALPHA ) ); 092 assertEquals( SimplifiedDocbookMarkup.LOWERALPHA_STYLE, 093 DocbookUtils.docbookListNumbering( Sink.NUMBERING_LOWER_ALPHA ) ); 094 assertEquals( SimplifiedDocbookMarkup.UPPERROMAN_STYLE, 095 DocbookUtils.docbookListNumbering( Sink.NUMBERING_UPPER_ROMAN ) ); 096 assertEquals( SimplifiedDocbookMarkup.LOWERROMAN_STYLE, 097 DocbookUtils.docbookListNumbering( Sink.NUMBERING_LOWER_ROMAN ) ); 098 assertEquals( SimplifiedDocbookMarkup.ARABIC_STYLE, 099 DocbookUtils.docbookListNumbering( Sink.NUMBERING_DECIMAL ) ); 100 101 try 102 { 103 DocbookUtils.docbookListNumbering( -1 ); 104 fail(); 105 } 106 catch ( IllegalArgumentException e ) 107 { 108 assertNotNull( e ); 109 } 110 } 111 112 /** 113 * Test of trademarkFromClass method, of class DocbookUtils. 114 */ 115 public void testTrademarkFromClass() 116 { 117 assertEquals( '\u00AE', DocbookUtils.trademarkFromClass( "registered" ) ); 118 assertEquals( '\u00A9', DocbookUtils.trademarkFromClass( "copyright" ) ); 119 assertEquals( '\u2120', DocbookUtils.trademarkFromClass( "service" ) ); 120 assertEquals( '\u2122', DocbookUtils.trademarkFromClass( "trade" ) ); 121 122 try 123 { 124 DocbookUtils.trademarkFromClass( "" ); 125 fail(); 126 } 127 catch ( IllegalArgumentException e ) 128 { 129 assertNotNull( e ); 130 } 131 } 132}