1. Project Clover database mar. avr. 16 2024 08:19:06 CEST
  2. Package org.apache.maven.doxia.core

File Xhtml5BaseParserTest.java

 

Code metrics

0
28
4
1
89
55
4
0,14
7
4
1

Classes

Class Line # Actions
Xhtml5BaseParserTest 37 28 0% 4 0
1.0100%
 

Contributing tests

This file is covered by 1 test. .

Source view

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