示例#1
0
  @Test
  public void givenCloseTag_WhenParse_ThenNameOfTheTagEqualsNameOfTheInputTag() {
    String inputString = "<name></name>";

    handler =
        new Handler() {
          @Override
          public void handle(Element element) {
            myElement = element;
          }
        };
    builder.onCloseTag(handler);
    parser = builder.build();
    parser.parse(inputString);

    assertEquals("name", myElement.getName());
  }
示例#2
0
  @Test
  public void givenCloseTag_WhenHandleSetsTypeOfTag_ThenTypeOfTheTagEqualsCLOSE() {

    String inputString = "<name></name>";

    handler =
        new Handler() {
          @Override
          public void handle(Element element) {
            myElement = element;
          }
        };
    builder.onCloseTag(handler);
    parser = builder.build();
    parser.parse(inputString);
    TagElementType actual = myElement.getType();
    TagElementType expected = TagElementType.CLOSE;

    assertEquals(expected, actual);
  }