Package org.apache.wink.client

Examples of org.apache.wink.client.RestClient.resource()


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


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

        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

        String resourcePath = TEST_SERVLET_PATH + TestController.PATH;

        RestClient restClient = new RestClient(new ClientConfig());

        URL resourceURL = new URL(url.toExternalForm() + resourcePath);
        Resource resource = restClient.resource(resourceURL.toURI());

        // invoke GET on the resource and check the result
        Assert.assertEquals("Hello CDI", resource.get(SyndFeed.class).getTitle().getValue());
    }
}
View Full Code Here

    }

    @Test
    public void testDummy() {
        RestClient client = new RestClient();
        ClientResponse response = client.resource("http://localhost:8080/world").get();
        String out = response.getEntity(String.class);
        System.out.println(out);
        Assert.assertEquals(200, response.getStatusCode());
    }
View Full Code Here

     * Test that a request is processed if it takes less time than the timeout
     * value
     */
    public void testReadTimeoutNoTimeout() {
        RestClient client = getDefaultClient();
        Resource resource = client.resource(getBaseURI() + "?timeout=5000");
        ClientResponse response = resource.get();
        assertEquals(200, response.getStatusCode());
        assertEquals("request processed", response.getEntity(String.class));
    }

View Full Code Here

     * Test that the client times out if the request is not processed in less
     * than the readTimeout value
     */
    public void testReadTimeoutTimeout() {
        RestClient client = getDefaultClient();
        Resource resource = client.resource(getBaseURI() + "?timeout=30000");
        try {
            resource.get();
            fail("The client did not timeout after waiting more than 20000 milliseconds for the request.");
        } catch (ClientRuntimeException e) {
            assertTrue(e.getMessage().indexOf("SocketTimeoutException") != -1);
View Full Code Here

     * {@link AcceptHeaderHandler} should not set anything. However, the
     * underlying client may set the header as a failsafe.
     */
    public void testAcceptHeaderNoEntity() {
        RestClient client = new RestClient();
        ClientResponse resp = client.resource(getBaseURI() + "/echoaccept").get();
        /*
         * in this case the underlying client set the WILDCARD header for
         * default HttpURLConnection based client.
         */
        assertEquals("echo: " + MediaType.WILDCARD, resp.getEntity(String.class));
View Full Code Here

        }
    }

    public void testAtomGETBlogs() throws Exception {
        RestClient client = new RestClient();
        Resource resource = client.resource(BASE_URI);
        AtomFeed feed = resource.accept("application/atom+xml").get(AtomFeed.class);
        assertEquals(BlogService.ID, feed.getId());
        assertEquals(BlogService.ID, feed.getTitle().getValue());

        List<AtomLink> expectedLinks = new ArrayList<AtomLink>();
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.