1. Project Clover database mer. févr. 4 2026 12:48:28 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 2 tests. .

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  10 toggle @Override
40    protected AbstractParser createParser() {
41  10 parser = new Xhtml5BaseParser();
42  10 return parser;
43    }
44   
 
45  6 toggle @Override
46    protected String outputExtension() {
47  6 return "xhtml";
48    }
49   
 
50  12 toggle @BeforeEach
51    protected void setUp() throws Exception {
52  12 parser = new Xhtml5BaseParser();
53  12 sink.reset();
54    }
55   
 
56  2 toggle @Test
57    public void test() throws Exception {
58  2 final String text = "<p>element {{&lt; badge color=“secondary” text=“site.xml” /&gt;}}</p>";
59   
60  2 parser.parse(text, sink);
61   
62  2 final Iterator<SinkEventElement> it = sink.getEventList().iterator();
63   
64  2 SinkEventElement element = it.next();
65  2 assertEquals("paragraph", element.getName());
66  2 element = it.next();
67  2 assertEquals("text", element.getName());
68  2 assertEquals("element {{", element.getArgs()[0]);
69  2 element = it.next();
70  2 assertEquals("text", element.getName());
71  2 assertEquals("<", element.getArgs()[0]);
72  2 element = it.next();
73  2 assertEquals("text", element.getName());
74  2 assertEquals(" badge color=“secondary” text=“site.xml” /", element.getArgs()[0]);
75  2 element = it.next();
76  2 assertEquals("text", element.getName());
77  2 assertEquals(">", element.getArgs()[0]);
78  2 element = it.next();
79  2 assertEquals("text", element.getName());
80  2 assertEquals("}}", element.getArgs()[0]);
81  2 element = it.next();
82  2 assertEquals("paragraph_", element.getName());
83  2 assertFalse(it.hasNext());
84    }
85   
 
86  2 toggle @Override
87    protected String getVerbatimSource() {
88  2 return "<pre>&lt;&gt;{}=#*</pre>";
89    }
90   
 
91  2 toggle @Override
92    protected String getVerbatimCodeSource() {
93  2 return "<pre><code>&lt;&gt;{}=#*</code></pre>";
94    }
95    }