use of org.sonar.plugins.html.node.TagNode in project sonar-web by SonarSource.
the class PageLexerTest method nestedQuotes.
@Test
public void nestedQuotes() {
String fragment = "<tr class=\"<c:if test='${count%2==0}'>even</c:if>" + "<c:if test='${count%2!=0}'>odd</c:if><c:if test='${ActionType==\"baseline\"}'> baseline</c:if>\">";
StringReader reader = new StringReader(fragment);
PageLexer lexer = new PageLexer();
List<Node> nodeList = lexer.parse(reader);
assertThat(nodeList).hasSize(1);
TagNode tagNode = (TagNode) nodeList.get(0);
assertThat(tagNode.getAttributes()).hasSize(1);
}
use of org.sonar.plugins.html.node.TagNode 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);
assertThat(nodeList).hasSize(3);
assertThat(nodeList.get(0)).isInstanceOf(TagNode.class);
assertThat(nodeList.get(1)).isInstanceOfAny(TextNode.class);
assertThat(nodeList.get(2)).isInstanceOf(TagNode.class);
TagNode tagNode = (TagNode) nodeList.get(0);
assertThat(tagNode.getAttributes()).hasSize(4);
// the embedded tags are added as attributes
assertThat(tagNode.getAttributes().get(1).getValue()).isEmpty();
assertThat(tagNode.getAttributes().get(3).getValue()).isEmpty();
}
Aggregations