Package org.restlet

Examples of org.restlet.Client


        String text = "text";
        Form form = new Form();
        form.add("key", "value");

        client = new Client(Protocol.HTTP);
        Request request = new Request(method, "http://localhost:8111/test");
        Response response = client.handle(request);
        assertTrue(response.getStatus().isSuccess());
        response.getEntity().release();
View Full Code Here


        String text = "text";
        Form form = new Form();
        form.add("key", "value");

        client = new Client(Protocol.HTTP);
        Request request = new Request(method, "http://localhost:8111/test");
        Response response = client.handle(request);
        assertTrue(response.getStatus().isSuccess());
        response.getEntity().release();
View Full Code Here

                                    .getConnectorService().getClientProtocols()) {
                                boolean clientFound = false;

                                // Try to find a client connector matching the
                                // client protocol
                                Client client;
                                for (Iterator<Client> iter = getHelped()
                                        .getClients().iterator(); !clientFound
                                        && iter.hasNext();) {
                                    client = iter.next();
                                    clientFound = client.getProtocols()
                                            .contains(clientProtocol);
                                }

                                if (!clientFound) {
                                    getLogger()
View Full Code Here

        return application;
    }

    private void sendGet(String uri) throws Exception {
        final Request request = new Request(Method.GET, uri);
        Client c = new Client(Protocol.HTTP);
        final Response r = c.handle(request);
        try {
            assertEquals(r.getStatus().getDescription(), Status.SUCCESS_OK,
                    r.getStatus());
            assertXML(new DomRepresentation(r.getEntity()));
        } finally {
            r.release();
            c.stop();
        }
    }
View Full Code Here

        }
    }

    private void sendPut(String uri) throws Exception {
        Request request = new Request(Method.PUT, uri, createTestXml());
        Client c = new Client(Protocol.HTTP);
        Response r = c.handle(request);

        try {
            checkForChunkedHeader(r);
            assertEquals(r.getStatus().getDescription(), Status.SUCCESS_OK,
                    r.getStatus());
            assertXML(new DomRepresentation(r.getEntity()));
        } finally {
            r.release();
            c.stop();
        }

    }
View Full Code Here

    @Override
    protected void logRoute(org.restlet.routing.Route route) {
        if (getLogger().isLoggable(Level.FINE)) {
            if (route instanceof ClientRoute) {
                Client client = ((ClientRoute) route).getClient();

                getLogger().fine(
                        "This client was selected: \"" + client.getProtocols()
                                + "\"");
            } else {
                super.logRoute(route);
            }
        }
View Full Code Here

        this.clientResource.setCommandSequence("314159");
        this.clientResource.setFrom(new Address("sip:alice@atlanta.com",
                "Alice"));
        this.clientResource.setTo(new Address("sip:bob@biloxi.com", "Bob"));

        Client client = new Client(new Context(), Protocol.SIP);
        client.getContext().getParameters().add("minThreads", "1");
        client.getContext().getParameters().add("tracing", "true");
        client.getContext().getParameters().add("proxyHost", "localhost");
        client.getContext().getParameters().add("proxyPort", "5060");
        this.clientResource.setNext(client);
        this.proxy = this.clientResource.wrap(UacResource.class);
    }
View Full Code Here

        // for authentication.
        // extraHeaders.add("X-Amz-Date", "Thu, 17 Nov 2005 18:49:58 GMT");
        request.getAttributes().put("org.restlet.http.headers", extraHeaders);

        // Handle it using an HTTP client connector
        final Client client = new Client(Protocol.HTTP);
        final Response response = client.handle(request);

        // Write the response entity on the console
        final Representation output = response.getEntity();
        output.write(System.out);
    }
View Full Code Here

        };

        comp.getInternalRouter().attach("/local", localOnly);
        String localBase = "riap://component/local";

        Client dispatcher = comp.getContext().getClientDispatcher();

        String msg = "this%20message";
        String echoURI = localBase + "/echo/" + msg;
        Representation echoRep = dispatcher.handle(
                new Request(Method.GET, echoURI)).getEntity();
        assertEquals("expected echo of uri-remainder", msg, echoRep.getText());

        final String objURI = localBase + "/object";
        final Representation objRep = dispatcher.handle(
                new Request(Method.GET, objURI)).getEntity();
        assertSame("expected specific test-object", JUST_SOME_OBJ,
                ((ObjectRepresentation<?>) objRep).getObject());

        final String nullURI = localBase + "/null";
        final Representation nullRep = dispatcher.handle(
                new Request(Method.GET, nullURI)).getEntity();
        assertNull("expected null",
                ((ObjectRepresentation<?>) nullRep).getObject());

        final String anyURI = localBase + "/whatever";
        final Representation anyRep = dispatcher.handle(
                new Request(Method.GET, anyURI)).getEntity();
        assertEquals("expected echo of uri-remainder", DEFAULT_MSG,
                anyRep.getText());

        final String aggURI = localBase + "/self-aggregated";
        final Representation aggRep = dispatcher.handle(
                new Request(Method.GET, aggURI)).getEntity();
        final String expectedResult = buildAggregate(ECHO_TEST_MSG,
                ECHO_TEST_MSG);
        assertEquals("expected specific aggregated message", expectedResult,
                aggRep.getText());

        dispatcher.stop();
    }
View Full Code Here

    /**
     * @param args
     * @throws Exception
     */
    public static void main(String[] args) throws Exception {
        Client sdcClient = new Client(new Context(), Protocol.valueOf("SDC"));
        Series<Parameter> parameters = sdcClient.getContext().getParameters();
        parameters.add("keystorePath", "sdc.keystore");
        parameters.add("keystorePassword", "password");
        parameters.add("enabledCipherSuites", "TLS_RSA_WITH_AES_128_CBC_SHA");
        parameters.add("sslProtocol", "TLSv1");
        sdcClient.start();

        System.out
                .println("Press a key when the SDC agent is started and has established a tunnel...");
        System.in.read();

        Request request = new Request(Method.GET, "http://www.restlet.org");
        request.setProtocol(Protocol.valueOf("SDC"));
        request.setProxyChallengeResponse(new ChallengeResponse(ChallengeScheme
                .valueOf("SDC"), "myUser@example.com", "myPassword"));
        Response response = sdcClient.handle(request);
        response.getEntity().write(System.out);
    }
View Full Code Here

TOP

Related Classes of org.restlet.Client

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.