MockHttpServer.MockHttpServerResponse response2 = new MockHttpServer.MockHttpServerResponse();
response2.setMockResponseCode(401);
MockHttpServer.MockHttpServerResponse response3 = new MockHttpServer.MockHttpServerResponse();
response3.setMockResponseCode(200);
server.setMockHttpServerResponses(response1, response2, response3);
ClientConfig config = new ClientConfig();
BasicAuthSecurityHandler basicAuthSecurityHandler = new BasicAuthSecurityHandler();
basicAuthSecurityHandler.setUserName("basicuser");
basicAuthSecurityHandler.setPassword("basicpassword");
ProxyAuthSecurityHandler proxyAuthSecurityHandler = new ProxyAuthSecurityHandler();
proxyAuthSecurityHandler.setUserName("username");
proxyAuthSecurityHandler.setPassword("password");
config.handlers(proxyAuthSecurityHandler, basicAuthSecurityHandler); // proxy first, then basic, of course
RestClient client = new RestClient(config);
Resource resource = client.resource(serviceURL);
ClientResponse response = resource.get();
assertEquals(200, response.getStatusCode());
}