1
0
Fork 0
mirror of https://github.com/ethauvin/JSON-java.git synced 2025-06-18 16:24:19 -07:00

Adds exception tests

This commit is contained in:
John J. Aylward 2017-07-09 19:05:00 -04:00
parent e94783f91b
commit 38d11227ee
2 changed files with 83 additions and 0 deletions

View file

@ -32,6 +32,7 @@ import org.json.JSONObject;
import org.json.JSONPointerException;
import org.json.XML;
import org.json.junit.data.BrokenToString;
import org.json.junit.data.ExceptionalBean;
import org.json.junit.data.Fraction;
import org.json.junit.data.GenericBean;
import org.json.junit.data.GenericBeanInt;
@ -2680,4 +2681,17 @@ public class JSONObjectTest {
1, jo.length());
assertNotNull(jo.get("ALL"));
}
/**
* Tests the exception portions of populateMap.
*/
@Test
public void testExceptionalBean() {
ExceptionalBean bean = new ExceptionalBean();
final JSONObject jo = new JSONObject(bean);
assertEquals("Expected 1 key to be mapped. Instead found: "+jo.keySet().toString(),
1, jo.length());
assertTrue(jo.get("closeable") instanceof JSONObject);
assertTrue(jo.getJSONObject("closeable").has("string"));
}
}