Package org.apache.wink.client

Examples of org.apache.wink.client.ClientConfig


    @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 void testHandlers() {
        server.setMockResponseCode(200);
        server.setMockResponseContent(SENT_MESSAGE);

        ClientConfig config = new ClientConfig();
        config.handlers(new DummyHandler());
        RestClient client = new RestClient(config);
        Resource resource = client.resource(serviceURL + "/testResourcePost");
        ClientResponse response =
            resource.contentType("text/plain").accept("text/plain")
                .post(SENT_MESSAGE.toLowerCase());
View Full Code Here

    private HttpURLConnection openConnection(ClientRequest request) throws IOException {
        URL url = request.getURI().toURL();
        HttpURLConnection connection = null;
        // we're on the client so this is a safe cast
        ClientConfig config = (ClientConfig)request.getAttribute(WinkConfiguration.class);

        // setup proxy
        if (config.getProxyHost() != null) {
            Proxy proxy =
                new Proxy(Proxy.Type.HTTP, new InetSocketAddress(config.getProxyHost(), config
                    .getProxyPort()));
            connection = (HttpURLConnection)url.openConnection(proxy);
        } else {
            connection = (HttpURLConnection)url.openConnection();
        }
        connection.setDoInput(true);
        connection.setDoOutput(true);
        connection.setRequestMethod(request.getMethod());

        connection.setConnectTimeout(config.getConnectTimeout());
        connection.setReadTimeout(config.getReadTimeout());
        connection.setInstanceFollowRedirects(config.isFollowRedirects());

        return connection;
    }
View Full Code Here

            return tg;
        }
    }

    private RestClient getRestClient() {
        return new RestClient(new ClientConfig().applications(new Application() {
            @Override
            public Set<Class<?>> getClasses() {
                Set<Class<?>> set = new HashSet<Class<?>>();
                set.add(TestGenericsProvider.class);
                return set;
View Full Code Here

        if (asyncHttpClient != null) {
            return asyncHttpClient;
        }

        // cast is safe because we're on the client
        ClientConfig config = (ClientConfig) request.getAttribute(WinkConfiguration.class);

        AsyncHttpClientConfig.Builder c = new AsyncHttpClientConfig.Builder();
        c.setConnectionTimeoutInMs(config.getConnectTimeout());
        c.setRequestTimeoutInMs(config.getReadTimeout());
        c.setFollowRedirects(config.isFollowRedirects());

        // setup proxy
        if (config.getProxyHost() != null) {
            c.setProxyServer(new ProxyServer(config.getProxyHost(), config.getProxyPort()));
        }

        return new AsyncHttpClient(c.build());
    }
View Full Code Here

            new GoogleDocsClient(cliHelper).run();
        }
    }

    private GoogleDocsClient(CLIHelper cliHelper) {
        ClientConfig config = new ClientConfig();

        if (cliHelper.hasProxy()) {
            config.proxyHost(cliHelper.getProxyHost());
            config.proxyPort(Integer.valueOf(cliHelper.getProxyPort()));
        }

        // add google authentication handler
        config.handlers(new GoogleAuthHandler(cliHelper.getEmail(), cliHelper.getPassword()));
        restClient = new RestClient(config);
        this.cliHelper = cliHelper;
    }
View Full Code Here

    /**
     * Tests that a regular encoded input is acceptable to the server.
     */
    public void testContentEncodedInboundRequestRegularOutboundPost() {
        ClientConfig config = new ClientConfig();
        config.handlers();
        RestClient client = new RestClient(config);
        ClientResponse response =
            client.resource(getBaseURI() + "/regular/echo").post(getRepeatedString());
        assertEquals(200, response.getStatusCode());
        assertEquals(getRepeatedString(), response.getEntity(String.class));
View Full Code Here

    /**
     * Tests that a GZIP inbound is ok and outbound is also ok.
     */
    public void testGZIPContentEncodedInboundRequestContentEncodedOutboundPost() {
        ClientConfig config = new ClientConfig();
        config.handlers(new DeflateHandler());
        RestClient client = new RestClient(config);
        ClientResponse response =
            client.resource(getBaseURI() + "/contentencode/echo").post(getRepeatedString());

        assertEquals(200, response.getStatusCode());
View Full Code Here

    /**
     * Tests that a deflate inbound is ok and outbound is also ok.
     */
    public void testDeflatedContentEncodedInboundRequestContentEncodedOutboundPost() {
        ClientConfig config = new ClientConfig();
        config.handlers(new DeflateHandler());
        RestClient client = new RestClient(config);
        ClientResponse response =
            client.resource(getBaseURI() + "/contentencode/echo").post(getRepeatedString());

        assertEquals(200, response.getStatusCode());
View Full Code Here

        verifyResponseNotContentEncodedForRepeatedStrings(response);

        /*
         * test even with the GZIP Handler on the path
         */
        ClientConfig clientConfig = new ClientConfig();
        clientConfig.handlers(new GzipHandler());
        client = new RestClient(clientConfig);

        response = client.resource(getBaseURI() + "/regular/repeatedstring").get();
        verifyResponseNotContentEncodedForRepeatedStrings(response);
    }
View Full Code Here

TOP

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

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.