Package org.apache.wink.client

Examples of org.apache.wink.client.RestClient


        server.setMockResponseContent("REQUEST".getBytes("UTF-16"));
        server.setMockResponseContentType("text/plain; charset=UTF-16");

        server.startServer();
        try {
            RestClient client = getRestClient();
            Resource resource =
                client.resource(MessageFormat.format(SERVICE_URL, String.valueOf(server
                    .getServerPort())));
            String response = resource.accept(MediaType.TEXT_PLAIN_TYPE).get(String.class);
            assertEquals("REQUEST", response);

        } finally {
View Full Code Here


        server.setMockResponseContent("REQUEST".getBytes("UTF-8"));
        server.setMockResponseContentType("");

        server.startServer();
        try {
            RestClient client = getRestClient();
            Resource resource =
                client.resource(MessageFormat.format(SERVICE_URL, String.valueOf(server
                    .getServerPort())));
            String response = resource.accept(MediaType.TEXT_PLAIN_TYPE).get(String.class);
            assertEquals("REQUEST", response);
        } finally {
            server.stopServer();
View Full Code Here

    protected RestClient client;

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

        assertEquals(conf.getProxyHost(), "localhost");
        assertEquals(conf.getProxyPort(), 8080);
        assertEquals(conf.getConnectTimeout(), 6000);
        assertEquals(conf.isFollowRedirects(), true);

        RestClient rc = new RestClient(conf);
        ClientConfig config = rc.getConfig();

        // test configuration locking
        try {
            config.proxyHost("localhost");
            fail("Configuration is locked - IllegalStateException must be thrown");
View Full Code Here

        // that the connection is going through the proxy, because we
        // specify a different port for the server in the resource URL
        server.setMockResponseCode(200);
        ClientConfig config = new ClientConfig();
        config.proxyHost("localhost").proxyPort(serverPort);
        RestClient client = new RestClient(config);
        String resourceUrl = "http://googoo:" + (serverPort + 1) + "/some/service";
        Resource resource = client.resource(resourceUrl);
        resource.get(String.class);
        assertEquals(resourceUrl, server.getRequestUrl());
    }
View Full Code Here

        int connectTimeout = 2000;
        ClientConfig config = new ClientConfig();

        // set the connect timeout
        config.connectTimeout(connectTimeout);
        RestClient client = new RestClient(config);

        // shouldn't be able to connect
        Resource resource = client.resource("http://localhost:1111/koko");
        long before = System.currentTimeMillis();
        try {
            // the client should "connect timeout"
            resource.get(String.class);
            fail("Expected Exception to be thrown");
View Full Code Here

        server.setDelayResponse(5000);

        ClientConfig config = new ClientConfig();
        // set the read timeout to be 2 seconds
        config.readTimeout(2000);
        RestClient client = new RestClient(config);
        Resource resource = client.resource(serviceURL);
        long before = System.currentTimeMillis();
        try {
            // the client should "read timeout" after 2 seconds
            resource.get(String.class);
            fail("Expected Exception to be thrown");
View Full Code Here

            }
        };

        conf.applications(app);

        RestClient client = new RestClient(conf);
        Resource resource = client.resource(serviceURL + "/testResourcePut");
        Foo response =
            resource.contentType("text/plain").accept("text/plain").post(Foo.class,
                                                                         new Foo(SENT_MESSAGE));
        assertEquals(RECEIVED_MESSAGE, response.foo);

        // Negative test - Foo Provider not registered
        try {
            client = new RestClient();
            resource = client.resource(serviceURL + "/testResourcePut");
            response =
                resource.contentType("text/plain").accept("text/plain").post(Foo.class,
                                                                             new Foo(SENT_MESSAGE));
            fail("ClientRuntimeException must be thrown");
        } catch (ClientRuntimeException e) {
View Full Code Here

    protected RestClient client;

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

                providers.add(new DataBindingJAXRSWriter(registry));
                return providers;
            }

        });
        RestClient client = new RestClient(config);
       
        // Default to GET for RPC
        httpMethod = HttpMethod.GET;

        for (Map.Entry<Class<?>, String> e : mapping.entrySet()) {
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.