Package org.restlet

Examples of org.restlet.Request


     * @see #createPost(String)
     * @see #createGet(String)
     * @see #createGetFromPath(String)
     */
    void createRequest(Method method, String reference) {
        this.request = new Request(method, reference);
        this.request.setOriginalRef(new Reference(reference));
        this.response = new Response(this.request);
        this.lastCreatedReference = reference;
        setPrefs();
        this.request.getClientInfo().setAgent(this.userAgent);
View Full Code Here


        return new MockFilter(null);
    }

    @Override
    protected Request getRequest() {
        return new Request();
    }
View Full Code Here

     * @throws IOException
     * @throws ResourceException
     */
    public void test() throws IOException, ResourceException {
        client = new Client(Protocol.HTTP);
        Request request = new Request(Method.GET, "http://localhost:8111/test");
        Response response = client.handle(request);
        assertEquals(Status.SUCCESS_OK, response.getStatus());
        assertEquals("asText", response.getEntity().getText());
        response.getEntity().release();

        request = new Request(Method.POST, "http://localhost:8111/test");
        response = client.handle(request);
        assertEquals(Status.SUCCESS_OK, response.getStatus());
        assertEquals("accept", response.getEntity().getText());
        response.getEntity().release();
    }
View Full Code Here

     * @throws ResourceException
     */
    public void test() throws IOException, ResourceException {

        client = new Client(Protocol.HTTP);
        Request request = new Request(Method.GET, "http://localhost:8111/test");
        Response response = client.handle(request);
        assertEquals(Status.SUCCESS_OK, response.getStatus());
        assertEquals("asText-txt", response.getEntity().getText());
        response.getEntity().release();

        request = new Request(Method.POST, "http://localhost:8111/test");
        response = client.handle(request);
        assertEquals(Status.SUCCESS_OK, response.getStatus());
        assertEquals("accept", response.getEntity().getText());
        response.getEntity().release();
    }
View Full Code Here

     *
     * @throws Exception
     */
    public void testIntegration() throws Exception {
        Client client = new Client(new Context(), Arrays.asList(Protocol.HTTP));
        Request request = new Request(Method.POST, uri);
        request.setEntity(new JaxbRepresentation<Sample>(new Sample(IN_STRING)));

        Response response = client.handle(request);

        JaxbRepresentation<Sample> resultRepresentation = new JaxbRepresentation<Sample>(
                response.getEntity(), Sample.class);
        Sample sample = resultRepresentation.getObject();
        assertEquals(HELLO_OUT_STRING, sample.getVal());

        request = new Request(Method.PUT, uri);
        request.setEntity(new JaxbRepresentation<Sample>(new Sample(IN_STRING)));

        response = client.handle(request);
        resultRepresentation = new JaxbRepresentation<Sample>(
                response.getEntity(), Sample.class);
        sample = resultRepresentation.getObject();
        assertEquals(HELLO_OUT_STRING, sample.getVal());

        request = new Request(Method.GET, uri);
        response = client.handle(request);
        resultRepresentation = new JaxbRepresentation<Sample>(
                response.getEntity(), Sample.class);
        sample = resultRepresentation.getObject();
        assertEquals(IN_STRING, sample.getVal());
View Full Code Here

        if (feedRef.isRelative()) {
            feedRef.setBaseRef(getWorkspace().getService().getReference());
        }

        final Request request = new Request(Method.GET, feedRef.getTargetRef());
        final Response response = getWorkspace().getService()
                .getClientDispatcher().handle(request);

        if (response.getStatus().equals(Status.SUCCESS_OK)) {
            return new Feed(response.getEntity());
View Full Code Here

     *            The member representation to post.
     * @return The reference of the new resource.
     * @throws Exception
     */
    public Reference postMember(Representation member) throws Exception {
        final Request request = new Request(Method.POST, getHref(), member);
        final Response response = getWorkspace().getService()
                .getClientDispatcher().handle(request);

        if (response.getStatus().equals(Status.SUCCESS_CREATED)) {
            return response.getLocationRef();
View Full Code Here

     * @param feedUri
     *            The feed URI.
     * @throws IOException
     */
    public Feed(Client clientDispatcher, String feedUri) throws IOException {
        this(clientDispatcher.handle(new Request(Method.GET, feedUri))
                .getEntity());
    }
View Full Code Here

     *            The feed URI.
     * @throws IOException
     */
    public Feed(Context context, String feedUri) throws IOException {
        this(context.getClientDispatcher()
                .handle(new Request(Method.GET, feedUri)).getEntity());
    }
View Full Code Here

     * @param entryUri
     *            The entry URI.
     * @throws IOException
     */
    public Entry(Client clientDispatcher, String entryUri) throws IOException {
        this(clientDispatcher.handle(new Request(Method.GET, entryUri))
                .getEntity());
    }
View Full Code Here

TOP

Related Classes of org.restlet.Request

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.