001package org.apache.maven.doxia.module.twiki.parser;
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.module.twiki.TWikiParser;
025
026/**
027 * Common code to the Block unit tests
028 *
029 * @author Juan F. Codagnone
030 * @since Nov 1, 2005
031 */
032public abstract class AbstractBlockTestCase
033    extends TestCase
034{
035    /**
036     * sectionParser to use in all the tests
037     */
038    protected final SectionBlockParser sectionParser = new SectionBlockParser();
039
040    /**
041     * ParagraphBlockParser  to use in all the tests
042     */
043    protected final ParagraphBlockParser paraParser = new ParagraphBlockParser();
044
045    /**
046     * ListBlockParser used in all the tests
047     */
048    protected final GenericListBlockParser listParser = new GenericListBlockParser();
049
050    /**
051     * FormatedTextParser used in all the tests
052     */
053    protected final FormatedTextParser formatTextParser = new FormatedTextParser();
054
055    /**
056     * TextParser used in all the tests
057     */
058    protected final TextParser textParser = new TextParser( new XHTMLWikiWordLinkResolver() );
059
060    /**
061     * TextParser used in all the tests
062     */
063    protected final HRuleBlockParser hruleParser = new HRuleBlockParser();
064
065    /**
066     * TableBlockParser used in all the tests
067     */
068    protected final TableBlockParser tableParser = new TableBlockParser();
069
070    /**
071     * TWiki used in all the tests
072     */
073    protected final TWikiParser twikiParser = new TWikiParser();
074
075    /**
076     * Parser for verbatim blocks
077     */
078    private final VerbatimBlockParser verbatimParser = new VerbatimBlockParser();
079
080    /**
081     * Creates the AbstractBlockTestCase.
082     */
083    public AbstractBlockTestCase()
084    {
085        sectionParser.setParaParser( paraParser );
086        sectionParser.setHrulerParser( hruleParser );
087        paraParser.setSectionParser( sectionParser );
088        paraParser.setListParser( listParser );
089        paraParser.setTextParser( formatTextParser );
090        paraParser.setHrulerParser( hruleParser );
091        paraParser.setTableBlockParser( tableParser );
092        paraParser.setVerbatimParser( verbatimParser );
093        sectionParser.setVerbatimBlockParser( new VerbatimBlockParser() );
094        listParser.setTextParser( formatTextParser );
095        formatTextParser.setTextParser( textParser );
096        tableParser.setTextParser( formatTextParser );
097    }
098
099    /**
100     * Returns the verbatimParser.
101     *
102     * @return <code>VerbatimBlockParser</code> with the verbatimParser.
103     */
104    protected final VerbatimBlockParser getVerbatimParser()
105    {
106        return verbatimParser;
107    }
108}