HttpUrlConnectionFactory.mockedConnection = mockedConnection;
Util.prepareMockedUrlConnection(mockedConnection);
final String response = "{invalidJson}";
Mockito.when(mockedConnection.getInputStream()).thenReturn(Util.createInputStream(response));
Mockito.when(mockedConnection.getResponseCode()).thenReturn(200);
<BUG>TestLogResponse logTrack = new TestLogResponse();
logTrack.listenForLogMessage("Json parsing error", null);
final URL endpointFull = new URL("https://login.invalidlogin.net/common/oauth2/authorize");
assertFalse(discovery.isValidAuthority(endpointFull));
assertTrue("Exception msg is logged", logTrack.message.contains("Json parsing error"));
}</BUG>
public void testIsValidAuthorityNegative_InvalidUrl() throws MalformedURLException {

HttpUrlConnectionFactory.mockedConnection = mockedConnection;
Util.prepareMockedUrlConnection(mockedConnection);
final String response = "{\"error_codes\":\"errors\"}";
Mockito.when(mockedConnection.getInputStream()).thenReturn(Util.createInputStream(response));
Mockito.when(mockedConnection.getResponseCode()).thenReturn(400);
try {
discovery.isValidAuthority(endpointFull);
fail();
} catch (AuthenticationException e) {
assertNotNull(e);
assertTrue(e.getCode().equals(ADALError.DEVELOPER_AUTHORITY_IS_NOT_VALID_INSTANCE));
}
}
public void testServerInvalidJsonResponse() throws IOException {
