Package org.apache.wink.client

Examples of org.apache.wink.client.RestClient


     * PROXY AUTH
     */
   
    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
    }
View Full Code Here


        ClientConfig config = new ClientConfig();
        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());
    }
View Full Code Here

        ClientConfig config = new ClientConfig();
        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

        ClientConfig config = new ClientConfig();
        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());
    }
View Full Code Here

        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());
    }
View Full Code Here

    @Override
    public void setUp() throws Exception {
        super.setUp();
        client =
            new RestClient(new ClientConfig().acceptHeaderAutoSet(false)
                .applications(new Application() {

                    @Override
                    public Set<Class<?>> getClasses() {
                        Set<Class<?>> classes = new HashSet<Class<?>>();
View Full Code Here

public class ReadRSSClient {

    public static void main(String[] args) {
        try {
            // create the rest client instance
            RestClient restClient = new RestClient();

            // create the resource instance to interact with
            String rss_url = "http://www.rssboard.org/files/rss-2.0-sample.xml";
            Resource feedResource = restClient.resource(rss_url);

            // perform a GET on the resource. The resource will be returned as
            // an Rss object
            RssFeed rss = feedResource.accept(MediaType.APPLICATION_XML_TYPE).get(RssFeed.class);
View Full Code Here

    protected RestClient client;

    @Override
    public void setUp() throws Exception {
        super.setUp();
        client = new RestClient();
    }
View Full Code Here

        this.baseURI = baseURI;
        requestHeaders = createRequestHeaders(reqHdrs);
    }

    public Response addNewsStory(NewsStory story) throws Exception {
        RestClient client = new RestClient();
        Resource resource = client.resource(baseURI);
        setRequestHeaders(resource);
        JAXBContext context = JAXBContext.newInstance(NewsStory.class);
        StringWriter sw = new StringWriter();
        context.createMarshaller().marshal(story, sw);
        ClientResponse response = resource.contentType("text/xml").post(sw.toString().getBytes());
View Full Code Here

        }
        return resp;
    }

    public Response updateNewsStory(NewsStory story) throws Exception {
        RestClient client = new RestClient();
        Resource resource = client.resource(baseURI);
        setRequestHeaders(resource);

        JAXBContext context = JAXBContext.newInstance(NewsStory.class);
        StringWriter sw = new StringWriter();
        context.createMarshaller().marshal(story, sw);
View Full Code Here

TOP

Related Classes of org.apache.wink.client.RestClient

Copyright © 2018 www.massapicom. 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.