1. Project Clover database mer. févr. 4 2026 12:48:44 CET
  2. Package org.apache.maven.doxia.core

File Xhtml5BaseParserTest.java

 

Code metrics

0
30
6
1
95
63
6
0,2
5
6
1

Classes

Class Line # Actions
Xhtml5BaseParserTest 33 30 0% 6 0
1.0100%
 

Contributing tests

This file is covered by 1 test. .

Source view

1    /*
2    * Copyright 2012-2025 Christophe Friederich
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.apache.org/licenses/LICENSE-2.0
9    *
10    * Unless required by applicable law or agreed to in writing, software
11    * distributed under the License is distributed on an "AS IS" BASIS,
12    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13    * See the License for the specific language governing permissions and
14    * limitations under the License.
15    */
16    package org.apache.maven.doxia.core;
17   
18    import static org.junit.jupiter.api.Assertions.assertEquals;
19    import static org.junit.jupiter.api.Assertions.assertFalse;
20   
21    import java.util.Iterator;
22    import org.apache.maven.doxia.parser.AbstractParser;
23    import org.apache.maven.doxia.parser.AbstractParserTest;
24    import org.apache.maven.doxia.parser.Xhtml5BaseParser;
25    import org.apache.maven.doxia.sink.impl.SinkEventElement;
26    import org.apache.maven.doxia.sink.impl.SinkEventTestingSink;
27    import org.junit.jupiter.api.BeforeEach;
28    import org.junit.jupiter.api.Test;
29   
30    /**
31    * Test for Xhtml5BaseParser.
32    */
 
33    public class Xhtml5BaseParserTest extends AbstractParserTest {
34   
35    private Xhtml5BaseParser parser;
36   
37    private final SinkEventTestingSink sink = new SinkEventTestingSink();
38   
 
39  5 toggle @Override
40    protected AbstractParser createParser() {
41  5 parser = new Xhtml5BaseParser();
42  5 return parser;
43    }
44   
 
45  3 toggle @Override
46    protected String outputExtension() {
47  3 return "xhtml";
48    }
49   
 
50  6 toggle @BeforeEach
51    protected void setUp() throws Exception {
52  6 parser = new Xhtml5BaseParser();
53  6 sink.reset();
54    }
55   
 
56  1 toggle @Test
57    public void test() throws Exception {
58  1 final String text = "<p>element {{&lt; badge color=“secondary” text=“site.xml” /&gt;}}</p>";
59   
60  1 parser.parse(text, sink);
61   
62  1 final Iterator<SinkEventElement> it = sink.getEventList().iterator();
63   
64  1 SinkEventElement element = it.next();
65  1 assertEquals("paragraph", element.getName());
66  1 element = it.next();
67  1 assertEquals("text", element.getName());
68  1 assertEquals("element {{", element.getArgs()[0]);
69  1 element = it.next();
70  1 assertEquals("text", element.getName());
71  1 assertEquals("<", element.getArgs()[0]);
72  1 element = it.next();
73  1 assertEquals("text", element.getName());
74  1 assertEquals(" badge color=“secondary” text=“site.xml” /", element.getArgs()[0]);
75  1 element = it.next();
76  1 assertEquals("text", element.getName());
77  1 assertEquals(">", element.getArgs()[0]);
78  1 element = it.next();
79  1 assertEquals("text", element.getName());
80  1 assertEquals("}}", element.getArgs()[0]);
81  1 element = it.next();
82  1 assertEquals("paragraph_", element.getName());
83  1 assertFalse(it.hasNext());
84    }
85   
 
86  1 toggle @Override
87    protected String getVerbatimSource() {
88  1 return "<pre>&lt;&gt;{}=#*</pre>";
89    }
90   
 
91  1 toggle @Override
92    protected String getVerbatimCodeSource() {
93  1 return "<pre><code>&lt;&gt;{}=#*</code></pre>";
94    }
95    }