Search in sources :

Example 1 with DirectiveNode

use of org.sonar.plugins.html.node.DirectiveNode in project sonar-web by SonarSource.

the class PageLexerTest method testDirectiveNode.

@Test
public void testDirectiveNode() {
    String directive = "<!docTyPE html " + "PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
    DoctypeTokenizer tokenizer = new DoctypeTokenizer("<!DOCTYPE", ">");
    List<Node> nodeList = new ArrayList<>();
    CodeReader codeReader = new CodeReader(directive);
    tokenizer.consume(codeReader, nodeList);
    assertThat(nodeList).hasSize(1);
    Node node = nodeList.get(0);
    assertThat(node).isInstanceOf(DirectiveNode.class);
    assertThat(((DirectiveNode) node).getAttributes()).hasSize(4);
}
Also used : CommentNode(org.sonar.plugins.html.node.CommentNode) Node(org.sonar.plugins.html.node.Node) TextNode(org.sonar.plugins.html.node.TextNode) DirectiveNode(org.sonar.plugins.html.node.DirectiveNode) TagNode(org.sonar.plugins.html.node.TagNode) ArrayList(java.util.ArrayList) DirectiveNode(org.sonar.plugins.html.node.DirectiveNode) CodeReader(org.sonar.channel.CodeReader) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 CodeReader (org.sonar.channel.CodeReader)1 CommentNode (org.sonar.plugins.html.node.CommentNode)1 DirectiveNode (org.sonar.plugins.html.node.DirectiveNode)1 Node (org.sonar.plugins.html.node.Node)1 TagNode (org.sonar.plugins.html.node.TagNode)1 TextNode (org.sonar.plugins.html.node.TextNode)1