Search in sources :

Example 1 with DirectiveNode

use of org.sonar.plugins.web.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);
    assertEquals(nodeList.size(), 1);
    Node node = nodeList.get(0);
    assertEquals(node.getClass(), DirectiveNode.class);
    DirectiveNode directiveNode = (DirectiveNode) node;
    assertEquals(4, directiveNode.getAttributes().size());
}
Also used : TagNode(org.sonar.plugins.web.node.TagNode) TextNode(org.sonar.plugins.web.node.TextNode) CommentNode(org.sonar.plugins.web.node.CommentNode) Node(org.sonar.plugins.web.node.Node) DirectiveNode(org.sonar.plugins.web.node.DirectiveNode) ArrayList(java.util.ArrayList) DirectiveNode(org.sonar.plugins.web.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.web.node.CommentNode)1 DirectiveNode (org.sonar.plugins.web.node.DirectiveNode)1 Node (org.sonar.plugins.web.node.Node)1 TagNode (org.sonar.plugins.web.node.TagNode)1 TextNode (org.sonar.plugins.web.node.TextNode)1