mirror of
https://github.com/ethauvin/JSON-java.git
synced 2025-06-17 07:50:52 -07:00
deepened the testing a little bit, slow going
This commit is contained in:
parent
49d4985828
commit
fcb8048038
1 changed files with 26 additions and 5 deletions
|
@ -85,7 +85,6 @@ public class JSONObjectTest {
|
|||
/**
|
||||
* JSONObjects can be built from a Map<String, Object>.
|
||||
* In this test all of the map entries are valid JSON types.
|
||||
* TODO: test with map values that are not valid JSON types
|
||||
*/
|
||||
String expectedStr =
|
||||
"{"+
|
||||
|
@ -109,6 +108,28 @@ public class JSONObjectTest {
|
|||
Util.compareActualVsExpectedJsonObjects(jsonObject, expectedJsonObject);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jsonObjectByMapWithUnsupportedValues() {
|
||||
/**
|
||||
* JSONObjects can be built from a Map<String, Object>.
|
||||
* In this test the map entries are not valid JSON types.
|
||||
* The actual conversion is kind of interesting.
|
||||
*/
|
||||
String expectedStr =
|
||||
"{"+
|
||||
"\"key1\":{},"+
|
||||
"\"key2\":\"java.lang.Exception\""+
|
||||
"}";
|
||||
Map<String, Object> jsonMap = new HashMap<String, Object>();
|
||||
// Just insert some random objects
|
||||
jsonMap.put("key1", new CDL());
|
||||
jsonMap.put("key2", new Exception());
|
||||
|
||||
JSONObject jsonObject = new JSONObject(jsonMap);
|
||||
JSONObject expectedJsonObject = new JSONObject(expectedStr);
|
||||
Util.compareActualVsExpectedJsonObjects(jsonObject, expectedJsonObject);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jsonObjectByMapWithNullValue() {
|
||||
/**
|
||||
|
@ -151,9 +172,8 @@ public class JSONObjectTest {
|
|||
@Test
|
||||
public void jsonObjectByBean() {
|
||||
/**
|
||||
* JSONObject built from a bean. In this case all of the
|
||||
* bean properties are valid JSON types
|
||||
* TODO: test with bean fields that are not valid JSON types
|
||||
* JSONObject built from a bean. In this case all but one of the
|
||||
* bean getters return valid JSON types
|
||||
*/
|
||||
String expectedStr =
|
||||
"{"+
|
||||
|
@ -162,7 +182,8 @@ public class JSONObjectTest {
|
|||
"\"stringKey\":\"hello world!\","+
|
||||
"\"complexStringKey\":\"h\be\tllo w\u1234orld!\","+
|
||||
"\"intKey\":42,"+
|
||||
"\"doubleKey\":-23.45e7"+
|
||||
"\"doubleKey\":-23.45e7,"+
|
||||
"\"stringReaderKey\":{}"+
|
||||
"}";
|
||||
MyBean myBean = new MyBean();
|
||||
JSONObject jsonObject = new JSONObject(myBean);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue