android.util.MalformedJsonException Java Examples
The following examples show how to use
android.util.MalformedJsonException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ZooniverseClientTest.java From android-galaxyzoo with GNU General Public License v3.0 | 5 votes |
@Test public void testLoginWithFailure() throws IOException { final MockWebServer server = new MockWebServer(); //On failure, the server's response code is HTTP_OK, //but it has a "success: false" parameter. final MockResponse response = new MockResponse(); response.setResponseCode(HttpURLConnection.HTTP_OK); response.setBody("test nonsense failure message"); server.enqueue(response); server.start(); final ZooniverseClient client = createZooniverseClient(server); try { final LoginUtils.LoginResult result = client.loginSync("testusername", "testpassword"); assertNotNull(result); assertFalse(result.getSuccess()); } catch (final ZooniverseClient.LoginException e) { assertTrue(e.getCause() instanceof MalformedJsonException); } server.shutdown(); }
Example #2
Source File: JsonSanitizer.java From 365browser with Apache License 2.0 | 4 votes |
private static String sanitizeString(String string) throws MalformedJsonException { if (!checkString(string)) { throw new MalformedJsonException("Invalid escape sequence"); } return string; }