Exemplo n.º 1
0
 public void testNameOrValue() {
   checkNoEncode(NAME_OR_VALUE, "");
   checkNoEncode(NAME_OR_VALUE, "sdf");
   assertEquals("sdf%20hfdf", EncodeOrCheck.nameOrValue("sdf%20hfdf", false, "guj"));
   assertEquals("sdf%2520hfdf", EncodeOrCheck.nameOrValue("sdf%20hfdf", true, "guj"));
   checkEncoding(NAME_OR_VALUE, "abc def", "abc%20def");
   final StringBuilder reservedEnc = new StringBuilder();
   for (int i = 0; i < EncodeOrCheck.RESERVED.length(); i++) {
     EncodeOrCheck.toHex(EncodeOrCheck.RESERVED.charAt(i), reservedEnc);
   }
   checkEncoding(NAME_OR_VALUE, EncodeOrCheck.RESERVED, reservedEnc.toString());
 }
Exemplo n.º 2
0
  public void testCheckForInvalidUriChars() {
    final String allowed = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890{}";
    EncodeOrCheck.checkForInvalidUriChars(allowed, -1, "");
    EncodeOrCheck.checkForInvalidUriChars("aaaaa", -1, "");
    EncodeOrCheck.checkForInvalidUriChars("\\\\\\", -1, "");
    checkForInvalidCharFail("a:a");
    checkForInvalidCharFail("a:1");
    checkForInvalidCharFail("/a:");
    checkForInvalidCharFail("a:");
    checkForInvalidCharFail("/");
    checkForInvalidCharFail(" ");
    checkForInvalidCharFail("\0");

    checkForInvalidCharFail("abc{ }kg jj");
    EncodeOrCheck.checkForInvalidUriChars("abc{ }kgjj", -1, "test");
  }
Exemplo n.º 3
0
 void checkForInvalidCharFail(String uriPart) {
   try {
     EncodeOrCheck.checkForInvalidUriChars(uriPart, -1, "");
     fail("\"" + uriPart + "\" contains an invalid char. The test must fail");
   } catch (IllegalArgumentException e) {
     // wonderful
   }
 }
Exemplo n.º 4
0
 public void testSchemeCheck() {
   // scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
   EncodeOrCheck.scheme("f");
 }
Exemplo n.º 5
0
 public void testEncodePathWithoutMatrix() {
   EncodeOrCheck.pathWithoutMatrix("");
   EncodeOrCheck.pathWithoutMatrix("%20");
 }