@Test
public void testRetryDisabledDoesNotAffectError() throws IOException {

    // Create environment that disables retry logic with 4xx error
    DXEnvironment env = DXEnvironment.Builder.fromDefaults().disableRetry().setBearerToken("BOGUS").build();
    // Check that retry really is disabled
    Assert.assertTrue(env.isRetryDisabled());
    boolean thrown = false;
    long startTime = System.currentTimeMillis();
    // Tests deserialization of InvalidAuthentication
    DXHTTPRequest c = new DXHTTPRequest(env);
    try {
        c.request("/system/findDataObjects", DXJSON.parseJson("{}"),
                RetryStrategy.SAFE_TO_RETRY);
        Assert.fail("Expected findDataObjects to fail with InvalidAuthentication");
    } catch (InvalidAuthenticationException e) {
        thrown = true;
        long timeElapsed = System.currentTimeMillis() - startTime;
        Assert.assertTrue(timeElapsed < 2500);
        // Error message should be something like
        // "the token could not be found"
        Assert.assertTrue(e.toString().contains("token"));
        Assert.assertEquals(401, e.getStatusCode());
    }
    Assert.assertTrue(thrown);
}