Examples of RestClient


Examples of org.apache.wink.client.RestClient

        assertEquals(RECEIVED_MESSAGE, tg.getT());
    }

    public void testInvoke() {
        server.setMockResponseCode(200);
        RestClient client = getRestClient();
        Resource resource = client.resource(serviceURL);

        String string = resource.invoke("GET", String.class, null);
        assertEquals(RECEIVED_MESSAGE, string);

        // test generic entity
View Full Code Here

Examples of org.apache.wink.client.RestClient

        assertEquals(RECEIVED_MESSAGE, tg.getT());
    }

    public void testHttpErrorNoResponse() throws IOException {
        server.setMockResponseCode(400);
        RestClient client = getRestClient();
        Resource resource = client.resource(serviceURL);
        try {
            resource.accept("text/plain").invoke("GET", String.class, null);
            fail("ClientWebException must be thrown");
        } catch (ClientWebException e) {
            assertTrue(e.getResponse().getStatusCode() == 400);
View Full Code Here

Examples of org.apache.wink.client.RestClient

        }
    }

    public void testHttpErrorWithResponse() throws IOException {
        server.setMockResponseCode(400);
        RestClient client = getRestClient();
        Resource resource = client.resource(serviceURL);
        try {
            ClientResponse res = resource.accept("text/plain").get();
            assertTrue(res.getStatusCode() == 400);
        } catch (Exception e) {
            fail("Exception must not be thrown");
View Full Code Here

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

Examples of org.apache.wink.client.RestClient

        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

Examples of org.apache.wink.client.RestClient

    protected RestClient client;

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

Examples of org.apache.wink.client.RestClient

        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

Examples of org.apache.wink.client.RestClient

        // 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

Examples of org.apache.wink.client.RestClient

        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

Examples of org.apache.wink.client.RestClient

        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
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.