Package org.apache.wink.client

Examples of org.apache.wink.client.ClientConfig


     * Tests that a content encoded get repeated strings resource is possible.
     * This is GZIP content encoded. This uses the client handler
     * {@link GzipHandler}.
     */
    public void testGZIPContentEncodedGetRepeatedStringsResource() throws IOException {
        ClientConfig clientConfig = new ClientConfig();
        clientConfig.handlers(new GzipHandler());
        RestClient client = new RestClient(clientConfig);

        ClientResponse response =
            client.resource(getBaseURI() + "/contentencode/repeatedstring").get();
        assertEquals(200, response.getStatusCode());
View Full Code Here


    /**
     * Tests that the server side request headers have the Content-Encoding
     * stripped since the filter is decoding it.
     */
    public void testHttpHeaderRequest() throws IOException {
        RestClient client = new RestClient(new ClientConfig().handlers(new GzipHandler()));
        ClientResponse response =
            client.resource(getBaseURI() + "/contentencode/httpheadercontentencoding")
                .header(HttpHeaders.ACCEPT_ENCODING, "*").accept(MediaType.TEXT_PLAIN)
                .contentType(MediaType.TEXT_PLAIN).post("HI");
        assertEquals(200, response.getStatusCode());
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 null;
    }

    private RestClient createRestClient() {
        ClientConfig config = new ClientConfig();
       
        // configureBasicAuth(config, userName, password);
       
        config.applications(new Application() {

            @Override
            public Set<Class<?>> getClasses() {
                return Collections.emptySet();
            }
View Full Code Here

        log.debug("Opening w/username: {}", username);

        // Using Apache HttpClient here, as it appears the default wink client does not handle redirects properly, even when configured to do so
        HttpClient httpClient = new DefaultHttpClient();
        ClientConfig config = new ApacheHttpClientConfig(httpClient);
        config.followRedirects(true);

        config.handlers(
            new LoggingHandler(log, /*debug*/ false),
            new BasicAuthSecurityHandler(username, password)
        );

        this.client = new RestClient(config);
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

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.