public void testDefaultCredentialComputeErrorUnexpected() throws IOException {
MockMetadataServerTransport transport = new MockMetadataServerTransport(ACCESS_TOKEN);
transport.setTokenRequestStatusCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR);
TestDefaultCredentialProvider testProvider = new TestDefaultCredentialProvider();
Credential defaultCredential = testProvider.getDefaultCredential(transport, JSON_FACTORY);
assertNotNull(defaultCredential);
try {
defaultCredential.refreshToken();
fail("Expected error refreshing token.");
} catch (IOException expected) {
String message = expected.getMessage();
assertTrue(message.contains(Integer.toString(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)));
assertTrue(message.contains("Unexpected"));