mirror of
https://github.com/fankes/JSON-java-compat.git
synced 2025-09-07 03:06:03 +08:00
clean up code
This commit is contained in:
@@ -75,12 +75,10 @@ public class CookieListTest {
|
||||
public void simpleCookieList() {
|
||||
String cookieStr = "SID=31d4d96e407aad42";
|
||||
JSONObject jsonObject = CookieList.toJSONObject(cookieStr);
|
||||
Object doc = Configuration.defaultConfiguration().jsonProvider().
|
||||
parse(jsonObject.toString());
|
||||
assertTrue("Expected 1 top level item",
|
||||
((Map<?,?>)(JsonPath.read(doc, "$"))).size() == 1);
|
||||
assertTrue("expected 31d4d96e407aad42",
|
||||
"31d4d96e407aad42".equals(JsonPath.read(doc, "$.SID")));
|
||||
// validate JSON content
|
||||
Object doc = Configuration.defaultConfiguration().jsonProvider().parse(jsonObject.toString());
|
||||
assertTrue("Expected 1 top level item", ((Map<?,?>)(JsonPath.read(doc, "$"))).size() == 1);
|
||||
assertTrue("expected 31d4d96e407aad42", "31d4d96e407aad42".equals(JsonPath.read(doc, "$.SID")));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,12 +88,10 @@ public class CookieListTest {
|
||||
public void simpleCookieListWithDelimiter() {
|
||||
String cookieStr = "SID=31d4d96e407aad42;";
|
||||
JSONObject jsonObject = CookieList.toJSONObject(cookieStr);
|
||||
Object doc = Configuration.defaultConfiguration().jsonProvider().
|
||||
parse(jsonObject.toString());
|
||||
assertTrue("Expected 1 top level item",
|
||||
((Map<?,?>)(JsonPath.read(doc, "$"))).size() == 1);
|
||||
assertTrue("expected 31d4d96e407aad42",
|
||||
"31d4d96e407aad42".equals(JsonPath.read(doc, "$.SID")));
|
||||
// validate JSON content
|
||||
Object doc = Configuration.defaultConfiguration().jsonProvider().parse(jsonObject.toString());
|
||||
assertTrue("Expected 1 top level item", ((Map<?,?>)(JsonPath.read(doc, "$"))).size() == 1);
|
||||
assertTrue("expected 31d4d96e407aad42", "31d4d96e407aad42".equals(JsonPath.read(doc, "$.SID")));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,22 +108,15 @@ public class CookieListTest {
|
||||
"name5=myCookieValue5;"+
|
||||
" name6=myCookieValue6;";
|
||||
JSONObject jsonObject = CookieList.toJSONObject(cookieStr);
|
||||
Object doc = Configuration.defaultConfiguration().jsonProvider().
|
||||
parse(jsonObject.toString());
|
||||
assertTrue("Expected 6 top level items",
|
||||
((Map<?,?>)(JsonPath.read(doc, "$"))).size() == 6);
|
||||
assertTrue("expected myCookieValue1",
|
||||
"myCookieValue1".equals(JsonPath.read(doc, "$.name1")));
|
||||
assertTrue("expected myCookieValue2",
|
||||
"myCookieValue2".equals(JsonPath.read(doc, "$.name2")));
|
||||
assertTrue("expected myCookieValue3",
|
||||
"myCookieValue3".equals(JsonPath.read(doc, "$.name3")));
|
||||
assertTrue("expected myCookieValue4",
|
||||
"myCookieValue4".equals(JsonPath.read(doc, "$.name4")));
|
||||
assertTrue("expected myCookieValue5",
|
||||
"myCookieValue5".equals(JsonPath.read(doc, "$.name5")));
|
||||
assertTrue("expected myCookieValue6",
|
||||
"myCookieValue6".equals(JsonPath.read(doc, "$.name6")));
|
||||
// validate JSON content
|
||||
Object doc = Configuration.defaultConfiguration().jsonProvider().parse(jsonObject.toString());
|
||||
assertTrue("Expected 6 top level items", ((Map<?,?>)(JsonPath.read(doc, "$"))).size() == 6);
|
||||
assertTrue("expected myCookieValue1", "myCookieValue1".equals(JsonPath.read(doc, "$.name1")));
|
||||
assertTrue("expected myCookieValue2", "myCookieValue2".equals(JsonPath.read(doc, "$.name2")));
|
||||
assertTrue("expected myCookieValue3", "myCookieValue3".equals(JsonPath.read(doc, "$.name3")));
|
||||
assertTrue("expected myCookieValue4", "myCookieValue4".equals(JsonPath.read(doc, "$.name4")));
|
||||
assertTrue("expected myCookieValue5", "myCookieValue5".equals(JsonPath.read(doc, "$.name5")));
|
||||
assertTrue("expected myCookieValue6", "myCookieValue6".equals(JsonPath.read(doc, "$.name6")));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -154,22 +143,15 @@ public class CookieListTest {
|
||||
"name5=myCookieValue5;"+
|
||||
" name6=myCookieValue6;";
|
||||
JSONObject jsonObject = CookieList.toJSONObject(cookieStr);
|
||||
Object doc = Configuration.defaultConfiguration().jsonProvider().
|
||||
parse(jsonObject.toString());
|
||||
assertTrue("Expected 6 top level items",
|
||||
((Map<?,?>)(JsonPath.read(doc, "$"))).size() == 6);
|
||||
assertTrue("expected myCookieValue1",
|
||||
"myCookieValue1".equals(JsonPath.read(doc, "$.name1")));
|
||||
assertTrue("expected myCookieValue2",
|
||||
"myCookieValue2".equals(JsonPath.read(doc, "$.name2")));
|
||||
assertTrue("expected myCookieValue3",
|
||||
"myCookieValue3".equals(JsonPath.read(doc, "$.name3")));
|
||||
assertTrue("expected myCookieValue4",
|
||||
"myCookieValue4".equals(JsonPath.read(doc, "$.name4")));
|
||||
assertTrue("expected myCookieValue5",
|
||||
"myCookieValue5".equals(JsonPath.read(doc, "$.name5")));
|
||||
assertTrue("expected myCookieValue6",
|
||||
"myCookieValue6".equals(JsonPath.read(doc, "$.name6")));
|
||||
// validate JSON content
|
||||
Object doc = Configuration.defaultConfiguration().jsonProvider().parse(jsonObject.toString());
|
||||
assertTrue("Expected 6 top level items", ((Map<?,?>)(JsonPath.read(doc, "$"))).size() == 6);
|
||||
assertTrue("expected myCookieValue1", "myCookieValue1".equals(JsonPath.read(doc, "$.name1")));
|
||||
assertTrue("expected myCookieValue2", "myCookieValue2".equals(JsonPath.read(doc, "$.name2")));
|
||||
assertTrue("expected myCookieValue3", "myCookieValue3".equals(JsonPath.read(doc, "$.name3")));
|
||||
assertTrue("expected myCookieValue4", "myCookieValue4".equals(JsonPath.read(doc, "$.name4")));
|
||||
assertTrue("expected myCookieValue5", "myCookieValue5".equals(JsonPath.read(doc, "$.name5")));
|
||||
assertTrue("expected myCookieValue6", "myCookieValue6".equals(JsonPath.read(doc, "$.name6")));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -186,21 +168,14 @@ public class CookieListTest {
|
||||
"name5=myCookieValue5;"+
|
||||
" name6=myCookieValue6;";
|
||||
JSONObject jsonObject = CookieList.toJSONObject(cookieStr);
|
||||
Object doc = Configuration.defaultConfiguration().jsonProvider().
|
||||
parse(jsonObject.toString());
|
||||
assertTrue("Expected 6 top level items",
|
||||
((Map<?,?>)(JsonPath.read(doc, "$"))).size() == 6);
|
||||
assertTrue("expected myCookieValue1",
|
||||
"myCookieValue1".equals(JsonPath.read(doc, "$.name1")));
|
||||
assertTrue("expected my Cookie Value 2",
|
||||
"my Cookie Value 2".equals(JsonPath.read(doc, "$.name2")));
|
||||
assertTrue("expected my+Cookie&Value;3=",
|
||||
"my+Cookie&Value;3=".equals(JsonPath.read(doc, "$.name3")));
|
||||
assertTrue("expected my%CookieValue4",
|
||||
"my%CookieValue4".equals(JsonPath.read(doc, "$.name4")));
|
||||
assertTrue("expected my%CookieValue5",
|
||||
"myCookieValue5".equals(JsonPath.read(doc, "$.name5")));
|
||||
assertTrue("expected myCookieValue6",
|
||||
"myCookieValue6".equals(JsonPath.read(doc, "$.name6")));
|
||||
// validate JSON content
|
||||
Object doc = Configuration.defaultConfiguration().jsonProvider().parse(jsonObject.toString());
|
||||
assertTrue("Expected 6 top level items", ((Map<?,?>)(JsonPath.read(doc, "$"))).size() == 6);
|
||||
assertTrue("expected myCookieValue1", "myCookieValue1".equals(JsonPath.read(doc, "$.name1")));
|
||||
assertTrue("expected my Cookie Value 2", "my Cookie Value 2".equals(JsonPath.read(doc, "$.name2")));
|
||||
assertTrue("expected my+Cookie&Value;3=", "my+Cookie&Value;3=".equals(JsonPath.read(doc, "$.name3")));
|
||||
assertTrue("expected my%CookieValue4", "my%CookieValue4".equals(JsonPath.read(doc, "$.name4")));
|
||||
assertTrue("expected my%CookieValue5", "myCookieValue5".equals(JsonPath.read(doc, "$.name5")));
|
||||
assertTrue("expected myCookieValue6", "myCookieValue6".equals(JsonPath.read(doc, "$.name6")));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user