Package org.apache.wink.client

Examples of org.apache.wink.client.RestClient.resource()


        ProxyAuthSecurityHandler proxyAuthSecurityHandler = new ProxyAuthSecurityHandler();
        // oops, forgot to set username!
        proxyAuthSecurityHandler.setPassword("password");
        config.handlers(proxyAuthSecurityHandler);
        RestClient client = new RestClient(config);
        Resource resource = client.resource(serviceURL);
        try {
            @SuppressWarnings("unused")
            ClientResponse response = resource.get();
            fail("should have got a ClientAuthenticationException");
        } catch (ClientAuthenticationException e) {
View Full Code Here


        ProxyAuthSecurityHandler proxyAuthSecurityHandler = new ProxyAuthSecurityHandler();
        proxyAuthSecurityHandler.setUserName("username");
        // oops, forgot to set password!
        config.handlers(proxyAuthSecurityHandler);
        RestClient client = new RestClient(config);
        Resource resource = client.resource(serviceURL);
        try {
            @SuppressWarnings("unused")
            ClientResponse response = resource.get();
            fail("should have got a ClientAuthenticationException");
        } catch (ClientAuthenticationException e) {
View Full Code Here

        ProxyAuthSecurityHandler proxyAuthSecurityHandler = new ProxyAuthSecurityHandler();
        // oops, forgot to set username!
        proxyAuthSecurityHandler.setPassword("password");
        config.handlers(proxyAuthSecurityHandler);
        RestClient client = new RestClient(config);
        Resource resource = client.resource(serviceURL);
        ClientResponse response = resource.get();
        assertEquals(200, response.getStatusCode());
    }
   
    /*
 
View Full Code Here

     */
   
    public void testNoBasicAuthHandler() throws Exception {
        server.getMockHttpServerResponses().get(0).setMockResponseCode(401);
        RestClient client = new RestClient(new ClientConfig());
        Resource resource = client.resource(serviceURL);
        ClientResponse response = resource.get();
        assertEquals(401, response.getStatusCode())// should have challenged us due to lack of credentials
    }
   
    public void testBasicAuthHandlerNoAuthRequired() throws Exception {
View Full Code Here

        BasicAuthSecurityHandler basicAuthSecurityHandler = new BasicAuthSecurityHandler();
        basicAuthSecurityHandler.setUserName("username");
        basicAuthSecurityHandler.setPassword("password");
        config.handlers(basicAuthSecurityHandler);
        RestClient client = new RestClient(config);
        Resource resource = client.resource(serviceURL);
        ClientResponse response = resource.get();
        assertEquals(200, response.getStatusCode());
    }

    public void testBasicAuthHandlerAuthDenied() throws Exception {
View Full Code Here

        BasicAuthSecurityHandler basicAuthSecurityHandler = new BasicAuthSecurityHandler();
        basicAuthSecurityHandler.setUserName("username");
        basicAuthSecurityHandler.setPassword("password");
        config.handlers(basicAuthSecurityHandler);
        RestClient client = new RestClient(config);
        Resource resource = client.resource(serviceURL);
        try {
            @SuppressWarnings("unused")
            ClientResponse response = resource.get();
            fail("should have got a ClientAuthenticationException");
        } catch (ClientAuthenticationException e) {
View Full Code Here

        BasicAuthSecurityHandler basicAuthSecurityHandler = new BasicAuthSecurityHandler();
        basicAuthSecurityHandler.setUserName("username");
        basicAuthSecurityHandler.setPassword("password");
        config.handlers(basicAuthSecurityHandler);
        RestClient client = new RestClient(config);
        Resource resource = client.resource(serviceURL);
        ClientResponse response = resource.get();
        assertEquals(200, response.getStatusCode());
    }
   
    /*
 
View Full Code Here

     */
   
    public void testNoProxyAuthHandler() throws Exception {
        server.getMockHttpServerResponses().get(0).setMockResponseCode(407);
        RestClient client = new RestClient(new ClientConfig());
        Resource resource = client.resource(serviceURL);
        ClientResponse response = resource.get();
        assertEquals(407, response.getStatusCode())// should have challenged us due to lack of credentials
    }
   
    public void testProxyAuthHandlerNoAuthRequired() throws Exception {
View Full Code Here

        ProxyAuthSecurityHandler proxyAuthSecurityHandler = new ProxyAuthSecurityHandler();
        proxyAuthSecurityHandler.setUserName("username");
        proxyAuthSecurityHandler.setPassword("password");
        config.handlers(proxyAuthSecurityHandler);
        RestClient client = new RestClient(config);
        Resource resource = client.resource(serviceURL);
        ClientResponse response = resource.get();
        assertEquals(200, response.getStatusCode());
    }

    public void testProxyAuthHandlerAuthDenied() throws Exception {
View Full Code Here

        ProxyAuthSecurityHandler proxyAuthSecurityHandler = new ProxyAuthSecurityHandler();
        proxyAuthSecurityHandler.setUserName("username");
        proxyAuthSecurityHandler.setPassword("password");
        config.handlers(proxyAuthSecurityHandler);
        RestClient client = new RestClient(config);
        Resource resource = client.resource(serviceURL);
        try {
            @SuppressWarnings("unused")
            ClientResponse response = resource.get();
            fail("should have got a ClientAuthenticationException");
        } catch (ClientAuthenticationException e) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.