@KOTest public void loadAndParseJSONP() throws InterruptedException, Exception {
if (js == null) {
url = Utils.prepareURL(
JSONTest.class, "$0({'firstName': 'Mitar', 'sex': 'MALE'})",
"application/javascript",
"callme"
);
orig = scriptElements();
assertTrue(orig > 0, "There should be some scripts on the page");
js = Models.bind(new JSONik(), newContext());
js.applyBindings();
js.setFetched(null);
js.fetchViaJSONP(url);
}
Person p = js.getFetched();
if (p == null) {
throw new InterruptedException();
}
assertEquals("Mitar", p.getFirstName(), "Unexpected: " + p.getFirstName());
assertEquals(Sex.MALE, p.getSex(), "Expecting MALE: " + p.getSex());
int now = scriptElements();
assertEquals(orig, now, "The set of elements is unchanged. Delta: " + (now - orig));
}