@Test
public void getEndpointInfo_testFailToRefreshEndpointWithBadResponse() throws Exception {

    boolean refresh = true;
    mockCacheInitExpectations();
    when(httpResponseStatusLine.getStatusCode()).thenReturn(200) // first time, return OK
            .thenReturn(401); // 2nd time, return bad response
    when(EntityUtils.toString(httpResponseEntity))
            .thenReturn("{\"instance_url\": \"" + TEST_INSTANCE_URL +"\",  \"access_token\": \"" + TEST_TOKEN + "\"}")
            .thenReturn("bad response");
    gusTransport = createGusTransport();
    EndpointInfo ei = gusTransport.getEndpointInfo();
    assertEquals(TEST_INSTANCE_URL, ei.getEndPoint());
    assertEquals(TEST_TOKEN, ei.getToken());
    EndpointInfo ei2 = gusTransport.getEndpointInfo(refresh);
    assertSame(ei, ei2);
    verify(httpClient, times(2)).execute(any());
    verify(httpResponse, times(2)).getStatusLine();
    verify(httpResponseStatusLine, times(2)).getStatusCode();
    verify(httpResponse, times(2)).getEntity();
}