View Javadoc
1   package org.apache.maven.doxia.module.confluence;
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 java.io.Writer;
23  
24  import org.apache.maven.doxia.sink.Sink;
25  import org.apache.maven.doxia.sink.impl.AbstractSinkTest;
26  import org.apache.maven.doxia.util.HtmlTools;
27  
28  /**
29   * Test the Confluence Sink
30   *
31   * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
32   * @version $Id$
33   * @see ConfluenceSink
34   */
35  public class ConfluenceSinkTest
36      extends AbstractSinkTest
37  {
38      /** {@inheritDoc} */
39      protected Sink createSink( Writer writer )
40      {
41          return new ConfluenceSink( writer );
42      }
43  
44      /** {@inheritDoc} */
45      protected String getAnchorBlock( String anchor )
46      {
47          return ConfluenceMarkup.ANCHOR_START_MARKUP + anchor + ConfluenceMarkup.ANCHOR_END_MARKUP + anchor;
48      }
49  
50      /** {@inheritDoc} */
51      protected boolean isXmlSink()
52      {
53          return false;
54      }
55  
56      /** Not used.
57       * {@inheritDoc} */
58      protected String getAuthorBlock( String author )
59      {
60          return null;
61      }
62  
63      /** Not used.
64       * {@inheritDoc} */
65      protected String getBodyBlock()
66      {
67          return null;
68      }
69  
70      /** {@inheritDoc} */
71      protected String getBoldBlock( String text )
72      {
73          return ConfluenceMarkup.BOLD_START_MARKUP + text + ConfluenceMarkup.BOLD_END_MARKUP;
74      }
75  
76      /** Not used.
77       * {@inheritDoc} */
78      protected String getDateBlock( String date )
79      {
80          return null;
81      }
82  
83      /** Not used.
84       * {@inheritDoc} */
85      protected String getDefinitionListBlock( String definum, String definition )
86      {
87          return null;
88      }
89  
90      /** {@inheritDoc} */
91      protected String getFigureBlock( String source, String caption )
92      {
93          String figureBlock = EOL + ConfluenceMarkup.FIGURE_START_MARKUP + source + ConfluenceMarkup.FIGURE_END_MARKUP;
94          if ( caption != null )
95          {
96              figureBlock += caption;
97          }
98          return figureBlock;
99      }
100 
101     /** Not used.
102      * {@inheritDoc} */
103     protected String getHeadBlock()
104     {
105         return null;
106     }
107 
108     /** {@inheritDoc} */
109     protected String getHorizontalRuleBlock()
110     {
111         return "";
112     }
113 
114     /** {@inheritDoc} */
115     protected String getItalicBlock( String text )
116     {
117         return ConfluenceMarkup.ITALIC_START_MARKUP + text + ConfluenceMarkup.ITALIC_END_MARKUP;
118     }
119 
120     /** {@inheritDoc} */
121     protected String getLineBreakBlock()
122     {
123         return ConfluenceMarkup.LINE_BREAK_MARKUP + EOL;
124     }
125 
126     /** {@inheritDoc} */
127     protected String getLinkBlock( String link, String text )
128     {
129         return ConfluenceMarkup.LINK_START_MARKUP + text + ConfluenceMarkup.LINK_MIDDLE_MARKUP + link
130             + ConfluenceMarkup.LINK_END_MARKUP;
131     }
132 
133     /** {@inheritDoc} */
134     protected String getListBlock( String item )
135     {
136         return ConfluenceMarkup.LIST_ITEM_MARKUP + item + EOL;
137     }
138 
139     /** {@inheritDoc} */
140     protected String getMonospacedBlock( String text )
141     {
142         return ConfluenceMarkup.MONOSPACED_START_MARKUP + text + ConfluenceMarkup.MONOSPACED_END_MARKUP;
143     }
144 
145     /** {@inheritDoc} */
146     protected String getNonBreakingSpaceBlock()
147     {
148         return "";
149     }
150 
151     /** {@inheritDoc} */
152     protected String getNumberedListBlock( String item )
153     {
154         return ConfluenceMarkup.NUMBERING_MARKUP + " " + item + EOL;
155     }
156 
157     /** {@inheritDoc} */
158     protected String getPageBreakBlock()
159     {
160         return "";
161     }
162 
163     /** {@inheritDoc} */
164     protected String getParagraphBlock( String text )
165     {
166         return text + EOL + EOL;
167     }
168 
169     /** {@inheritDoc} */
170     protected String getRawTextBlock( String text )
171     {
172         return "";
173     }
174 
175     /** {@inheritDoc} */
176     protected String getSection1Block( String title )
177     {
178         return "h1. " + title + EOL + EOL;
179     }
180 
181     /** {@inheritDoc} */
182     protected String getSection2Block( String title )
183     {
184         return "h2. " + title + EOL + EOL;
185     }
186 
187     /** {@inheritDoc} */
188     protected String getSection3Block( String title )
189     {
190         return "h3. " + title + EOL + EOL;
191     }
192 
193     /** {@inheritDoc} */
194     protected String getSection4Block( String title )
195     {
196         return "h4. " + title + EOL + EOL;
197     }
198 
199     /** {@inheritDoc} */
200     protected String getSection5Block( String title )
201     {
202         return "h5. " + title + EOL + EOL;
203     }
204 
205     /** {@inheritDoc} */
206     protected String getSectionTitleBlock( String title )
207     {
208         return title;
209     }
210 
211     /** {@inheritDoc} */
212     protected String getTableBlock( String cell, String caption )
213     {
214         return "| " + cell + " |" + EOL + "Table_caption" + EOL + EOL;
215     }
216 
217     /** {@inheritDoc} */
218     protected String getTextBlock( String text )
219     {
220         return HtmlTools.escapeHTML( text );
221     }
222 
223     /** Not used.
224      * {@inheritDoc} */
225     protected String getTitleBlock( String title )
226     {
227         return null;
228     }
229 
230     /** {@inheritDoc} */
231     protected String getVerbatimBlock( String text )
232     {
233         return "{code|borderStyle=solid}" + EOL + text + "{code}" + EOL + EOL;
234     }
235 
236     /** {@inheritDoc} */
237     protected String outputExtension()
238     {
239         return "twiki";
240     }
241     
242     // ----------------------------------------------------------------------
243     // Confluence specific 
244     // ----------------------------------------------------------------------
245 
246     public void testSuperScript()
247     {
248         verifyValignSup( "^ValignSup^" );
249     }
250 
251     public void testSubScript()
252     {
253         verifyValignSub( "~ValignSub~" );
254     }
255 
256     public void testStrikeStrough()
257     {
258         verifyDecorationLineThrough( "-DecorationLineThrough-" );
259     }
260 
261     public void testUnderline()
262     {
263         verifyDecorationUnderline( "+DecorationUnderline+" );
264     }
265 
266     // ----------------------------------------------------------------------
267     // Override unused tests
268     // ----------------------------------------------------------------------
269 
270     /** Not used.
271      * {@inheritDoc} */
272     public void testAuthor()
273     {
274         // nop
275     }
276 
277     /** Not used.
278      * {@inheritDoc} */
279     public void testDate()
280     {
281         // nop
282     }
283 
284     /** Not used.
285      * {@inheritDoc} */
286     public void testHead()
287     {
288         // nop
289     }
290 
291     /** Not used.
292      * {@inheritDoc} */
293     public void testBody()
294     {
295         // nop
296     }
297 
298     /** Not used.
299      * {@inheritDoc} */
300     public void testTitle()
301     {
302         // nop
303     }
304 
305     /** Not used.
306      * {@inheritDoc} */
307     public void testDefinitionList()
308     {
309         // nop
310     }
311 
312     /** {@inheritDoc} */
313     protected String getCommentBlock( String text )
314     {
315         return "";
316     }
317 }