Package org.restlet

Examples of org.restlet.Client.handle()


            // specify the range size.
            request = new Request(Method.PUT, "http://localhost:" + TEST_PORT
                    + "/testPut/essai3.txt");
            request.setEntity(new StringRepresentation("888"));
            request.setRanges(Arrays.asList(new Range(8, Range.SIZE_MAX)));
            response = client.handle(request);
            assertEquals(Status.SUCCESS_OK, response.getStatus());
            request.setMethod(Method.GET);
            response = client.handle(request);
            assertEquals(Status.SUCCESS_PARTIAL_CONTENT, response.getStatus());
            assertEquals("888", response.getEntity().getText());
View Full Code Here


            request.setEntity(new StringRepresentation("888"));
            request.setRanges(Arrays.asList(new Range(8, Range.SIZE_MAX)));
            response = client.handle(request);
            assertEquals(Status.SUCCESS_OK, response.getStatus());
            request.setMethod(Method.GET);
            response = client.handle(request);
            assertEquals(Status.SUCCESS_PARTIAL_CONTENT, response.getStatus());
            assertEquals("888", response.getEntity().getText());

            // Partial PUT on a file, the provided representation will be padded
            // just before the end of the file.
View Full Code Here

            // just before the end of the file.
            request = new Request(Method.PUT, "http://localhost:" + TEST_PORT
                    + "/testPut/essai.txt");
            request.setEntity(new StringRepresentation("99"));
            request.setRanges(Arrays.asList(new Range(8, Range.SIZE_MAX)));
            response = client.handle(request);
            assertEquals(Status.SUCCESS_OK, response.getStatus());
            response = client.handle(new Request(Method.GET, request
                    .getResourceRef()));
            assertEquals(Status.SUCCESS_OK, response.getStatus());
            assertEquals("10220000998", response.getEntity().getText());
View Full Code Here

                    + "/testPut/essai.txt");
            request.setEntity(new StringRepresentation("99"));
            request.setRanges(Arrays.asList(new Range(8, Range.SIZE_MAX)));
            response = client.handle(request);
            assertEquals(Status.SUCCESS_OK, response.getStatus());
            response = client.handle(new Request(Method.GET, request
                    .getResourceRef()));
            assertEquals(Status.SUCCESS_OK, response.getStatus());
            assertEquals("10220000998", response.getEntity().getText());

            request = new Request(Method.GET, "http://localhost:" + TEST_PORT
View Full Code Here

            assertEquals("10220000998", response.getEntity().getText());

            request = new Request(Method.GET, "http://localhost:" + TEST_PORT
                    + "/testPut/essai.txt");
            request.setRanges(Arrays.asList(new Range(3, Range.SIZE_MAX)));
            response = client.handle(request);
            assertEquals(Status.SUCCESS_PARTIAL_CONTENT, response.getStatus());
            assertEquals("20000998", response.getEntity().getText());

            BioUtils.delete(testDir, true);
            client.stop();
View Full Code Here

        // Test "range" header.
        request = new Request(Method.GET, "http://localhost:" + TEST_PORT
                + "/test?range=0-500");
        request.setRanges(Arrays.asList(new Range(0, 500)));
        response = client.handle(request);
        assertTrue(response.getStatus().isSuccess());
        response.getEntity().exhaust();

        request = new Request(Method.GET, "http://localhost:" + TEST_PORT
                + "/test?range=-500");
View Full Code Here

        response.getEntity().exhaust();

        request = new Request(Method.GET, "http://localhost:" + TEST_PORT
                + "/test?range=-500");
        request.setRanges(Arrays.asList(new Range(Range.INDEX_LAST, 500)));
        response = client.handle(request);
        assertTrue(response.getStatus().isSuccess());
        response.getEntity().exhaust();

        request = new Request(Method.GET, "http://localhost:" + TEST_PORT
                + "/test?range=500-");
View Full Code Here

        response.getEntity().exhaust();

        request = new Request(Method.GET, "http://localhost:" + TEST_PORT
                + "/test?range=500-");
        request.setRanges(Arrays.asList(new Range(500, Range.SIZE_MAX)));
        response = client.handle(request);
        assertTrue(response.getStatus().isSuccess());
        response.getEntity().exhaust();

        request = new Request(Method.GET, "http://localhost:" + TEST_PORT
                + "/test?range=500-1000");
View Full Code Here

        request = new Request(Method.GET, "http://localhost:" + TEST_PORT
                + "/test?range=500-1000");
        request.setRanges(Arrays.asList(new Range(500, 500)));

        response = client.handle(request);
        assertTrue(response.getStatus().isSuccess());
        response.getEntity().exhaust();

        // Multiple ranges are not supported yet.
        // request = new Request(Method.GET, "http://localhost:" + TEST_PORT
View Full Code Here

        final ChallengeResponse authentication = new ChallengeResponse(
                ChallengeScheme.HTTP_BASIC, LONG_USERNAME, LONG_PASSWORD);
        request.setChallengeResponse(authentication);

        final Response response = client.handle(request);
        assertEquals("Long username did not return 200 OK", Status.SUCCESS_OK,
                response.getStatus());
        assertEquals(AUTHENTICATED_MSG, response.getEntity().getText());
       
        client.stop();
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.