示例#1
0
  @Test
  public void testSameNames() {
    String s;

    s = HtmlDecoder.decode("á");
    assertEquals(1, s.length());
    assertEquals(0xE1, s.charAt(0));

    s = HtmlDecoder.decode("Á");
    assertEquals(1, s.length());
    assertEquals(0xC1, s.charAt(0));
  }
示例#2
0
  @Test
  public void testHexDecimal() {
    String s;
    s = HtmlDecoder.decode("ÿ");
    assertEquals(1, s.length());
    assertEquals(0xFF, s.charAt(0));

    s = HtmlDecoder.decode("&#xFF");
    assertEquals(5, s.length());
    assertEquals("&#xFF", s);

    s = HtmlDecoder.decode("&#");
    assertEquals("&#", s);

    s = HtmlDecoder.decode("&");
    assertEquals("&", s);

    s = HtmlDecoder.decode("&#123");
    assertEquals("&#123", s);

    s = HtmlDecoder.decode("{");
    assertEquals(1, s.length());
    assertEquals(123, s.charAt(0));

    s = HtmlDecoder.decode("aaa AA aaa");
    assertEquals("aaa AA aaa", s);
  }
示例#3
0
  @Test
  public void testDecodeNotFound() {
    String s =
        "switchTab("Senthil1");showWorkFlow("/xyz/abc.jsp?strWorkId=1691&archived=0");";

    String out = HtmlDecoder.decode(s);

    assertEquals(
        "switchTab(\"Senthil1\");showWorkFlow(\"/xyz/abc.jsp?strWorkId=1691&archived=0\");", out);
  }
示例#4
0
  @Test
  public void testEntities() {
    String s;

    s = HtmlDecoder.decode("&");
    assertEquals("&", s);

    s = HtmlDecoder.decode("&amp");
    assertEquals("&amp", s);

    s = HtmlDecoder.decode("&");
    assertEquals("&", s);

    s = HtmlDecoder.decode("2 < 5");
    assertEquals("2 < 5", s);

    s = HtmlDecoder.decode("&aacute;");
    assertEquals(1, s.length());
    assertEquals(0xe1, s.charAt(0));
  }