use of org.sonar.plugins.web.node.TextNode in project sonar-web by SonarSource.
the class PageLexerTest method testNestedTagInAttribute.
@Test
public void testNestedTagInAttribute() {
String fragment = "<td id=\"typeCellHeader\"<c:if test='${param.typeNormalOrError == \"error\"}'>" + "style=\"display:none;\"</c:if>>Type" + "</td>";
StringReader reader = new StringReader(fragment);
PageLexer lexer = new PageLexer();
List<Node> nodeList = lexer.parse(reader);
assertEquals(3, nodeList.size());
assertTrue(nodeList.get(0) instanceof TagNode);
assertTrue(nodeList.get(1) instanceof TextNode);
assertTrue(nodeList.get(2) instanceof TagNode);
TagNode tagNode = (TagNode) nodeList.get(0);
assertEquals(4, tagNode.getAttributes().size());
// the embedded tags are added as attributes
assertThat(tagNode.getAttributes().get(1).getValue()).isEmpty();
assertThat(tagNode.getAttributes().get(3).getValue()).isEmpty();
}
use of org.sonar.plugins.web.node.TextNode in project sonar-web by SonarSource.
the class PageLexerTest method testNestedTagInValue.
@Test
public void testNestedTagInValue() {
String fragment = "<td label=\"Hello <c:if test='${param == true}'>World</c:if>\">Type</td>";
StringReader reader = new StringReader(fragment);
PageLexer lexer = new PageLexer();
List<Node> nodeList = lexer.parse(reader);
assertEquals(3, nodeList.size());
assertTrue(nodeList.get(0) instanceof TagNode);
assertTrue(nodeList.get(1) instanceof TextNode);
assertTrue(nodeList.get(2) instanceof TagNode);
TagNode tagNode = (TagNode) nodeList.get(0);
assertEquals(1, tagNode.getAttributes().size());
}
use of org.sonar.plugins.web.node.TextNode in project sonar-web by SonarSource.
the class PageLexerTest method testNestedComment.
@Test
public void testNestedComment() {
String fragment = "<!-- text <!--><p>This is not part of the comment</p>";
StringReader reader = new StringReader(fragment);
PageLexer lexer = new PageLexer();
List<Node> nodeList = lexer.parse(reader);
assertEquals(4, nodeList.size());
assertTrue(nodeList.get(0) instanceof CommentNode);
assertTrue(nodeList.get(1) instanceof TagNode);
assertTrue(nodeList.get(2) instanceof TextNode);
assertTrue(nodeList.get(3) instanceof TagNode);
}
Aggregations