コード例 #1
0
  @Test
  public void givenCommentInsideTextValue() {
    String inputString = "<? xml ?><tagname>Text<!--comment_text-->Value</tagname>";

    handler =
        new Handler() {
          @Override
          public void handle(Element element) {
            myElement = element;
          }
        };
    builder.onTextValue(handler);
    parser = builder.build();
    parser.parse(inputString);
    String expected = "TextValue";
    String actual = myElement.getValue();

    assertEquals(expected, actual);
  }
コード例 #2
0
  @Test
  public void givenValidTagWithTextValue_WhenParseWholeTag_ThenOnTextValueInvoked() {
    String inputString = "<? xml ?><tagname>TextValue</tagname>";

    handler =
        new Handler() {
          @Override
          public void handle(Element element) {
            myElement = element;
          }
        };
    builder.onTextValue(handler);
    parser = builder.build();
    parser.parse(inputString);
    String expected = "TextValue";
    String actual = myElement.getValue();

    assertEquals(expected, actual);
  }