Пример #1
0
 /**
  * CookieList with multiple entries and some '+' chars and URL-encoded values converted to a JSON
  * document.
  */
 @Test
 public void convertEncodedCookieListToString() {
   String cookieStr =
       "name1=myCookieValue1;  "
           + "  name2=my+Cookie+Value+2;"
           + "name3=my%2BCookie%26Value%3B3%3D;"
           + "  name4=my%25CookieValue4;  "
           + "name5=myCookieValue5;"
           + "  name6=myCookieValue6;";
   String expectedCookieStr =
       "{"
           + "\"name1\":\"myCookieValue1\","
           + "\"name2\":\"my Cookie Value 2\","
           + "\"name3\":\"my+Cookie&Value;3=\","
           + "\"name4\":\"my%CookieValue4\","
           + "\"name5\":\"myCookieValue5\","
           + "\"name6\":\"myCookieValue6\""
           + "}";
   JSONObject jsonObject = CookieList.toJSONObject(cookieStr);
   JSONObject expectedJsonObject = new JSONObject(expectedCookieStr);
   String cookieToStr = CookieList.toString(jsonObject);
   JSONObject finalJsonObject = CookieList.toJSONObject(cookieToStr);
   Util.compareActualVsExpectedJsonObjects(jsonObject, expectedJsonObject);
   Util.compareActualVsExpectedJsonObjects(finalJsonObject, expectedJsonObject);
 }
Пример #2
0
 /** CookieList from a JSONObject with valid key and null value */
 @Test
 public void convertCookieListWithNullValueToString() {
   JSONObject jsonObject = new JSONObject();
   jsonObject.put("key", JSONObject.NULL);
   String cookieToStr = CookieList.toString(jsonObject);
   assertTrue("toString() should be empty", "".equals(cookieToStr));
 }