static final String limitJsonText = "{\"limit\":{\"track\":1234}}";
static final String randomJsonText = "{\"random\":\"meaningless\"}";
public void testDetermine() throws Exception {
JSONObject json;
json = new JSONObject(statusJsonText);
if (JSONObjectType.determine(json) != JSONObjectType.Type.STATUS) {
throw new Exception("JSONObjectType.determine failed for STATUS");
}
json = new JSONObject(deleteJsonText);
if (JSONObjectType.determine(json) != JSONObjectType.Type.DELETE) {
throw new Exception("JSONObjectType.determine failed for DELETE");
}
json = new JSONObject(scrubGeoJsonText);
if (JSONObjectType.determine(json) != JSONObjectType.Type.SCRUB_GEO) {
throw new Exception("JSONObjectType.determine failed for SCRUB_GEO");
}
json = new JSONObject(limitJsonText);
if (JSONObjectType.determine(json) != JSONObjectType.Type.LIMIT) {
throw new Exception("JSONObjectType.determine failed for LIMIT");
}
json = new JSONObject(randomJsonText);
if (JSONObjectType.determine(json) != JSONObjectType.Type.UNKNOWN) {
throw new Exception("JSONObjectType.determine failed for random");
}
String disconnectionNotice = "{\"disconnect\":{\"code\":3,\"stream_name\":\"yusuke-sitestream6139-yusuke\",\"reason\":\"control request for yusuke-sitestream6139 106.171.17.29 /1.1/site.json sitestream\"}}";
json = new JSONObject(disconnectionNotice);
if (JSONObjectType.determine(json) != JSONObjectType.Type.DISCONNECTION) {
throw new Exception("JSONObjectType.determine failed for random");
}
}