Package org.restlet.data

Examples of org.restlet.data.Request


    }

    @Test
    public void testUnhandledConsumer() throws IOException {
        Client client = new Client(Protocol.HTTP);
        Response response = client.handle(new Request(Method.POST,
                "http://localhost:9080/orders/99991/6"));
        // expect error status as no Restlet consumer to handle POST method
        assertEquals(Status.CLIENT_ERROR_NOT_FOUND, response.getStatus());
        assertNotNull(response.getEntity().getText());
    }
View Full Code Here


    }

    @Test
    public void testConsumer() throws IOException {
        Client client = new Client(Protocol.HTTP);
        Response response = client.handle(new Request(Method.GET,
                "http://localhost:9080/orders/99991/6"));
        assertEquals("received GET request with id=99991 and x=6",
                response.getEntity().getText());
    }
View Full Code Here

    }

    @Test
    public void testUnhandledConsumer() throws IOException {
        Client client = new Client(Protocol.HTTP);
        Response response = client.handle(new Request(Method.POST,
                "http://localhost:9080/orders/99991/6"));
        // expect error status as no Restlet consumer to handle POST method
        assertEquals(Status.CLIENT_ERROR_NOT_FOUND, response.getStatus());
        assertNotNull(response.getEntity().getText());
    }
View Full Code Here

   
    public void process(Exchange exchange) throws Exception {
        RestletEndpoint endpoint = (RestletEndpoint)getEndpoint();
       
        String resourceUri = buildUri(endpoint);
        Request request = new Request(endpoint.getRestletMethod(), resourceUri);

        RestletBinding binding = endpoint.getRestletBinding();
        binding.populateRestletRequestFromExchange(request, exchange);
       
        if (LOG.isDebugEnabled()) {
            LOG.debug("Client sends a request (method: " + request.getMethod()
                    + ", uri: " + resourceUri + ")");
        }
       
        Response response = client.handle(request);
        binding.populateExchangeFromRestletResponse(exchange, response);
View Full Code Here

        form.add("action", action);
        form.add("serversString", servers);
        Representation representation = form.getWebRepresentation();
        URL url = localServerEndPoint.toURL();
        String requestURL = url.toString();
        Request request = new Request(Method.POST, requestURL, representation);
        Response response = client.handle(request);
        if (!response.getStatus().isSuccess()) {
            throw new RuntimeException(response.getStatus().toString());
        }
    }
View Full Code Here

    public void setQuery(final String sparqlQuery, final Map<String, String> queryExtensions) {
        checkNotNull(sparqlQuery, queryExtensions);
        final HashMap<String, String> map = new HashMap<String, String>(queryExtensions);
        map.put("query", sparqlQuery);
        request = new Request(GET, createReferenceFromQuery(map));
        answerHandler.setAcceptedMediaTypes(request);
    }
View Full Code Here

    public void process(Exchange exchange) throws Exception {
        RestletEndpoint endpoint = (RestletEndpoint) getEndpoint();

        String resourceUri = buildUri(endpoint, exchange);
        Request request = new Request(endpoint.getRestletMethod(), resourceUri);

        RestletBinding binding = endpoint.getRestletBinding();
        binding.populateRestletRequestFromExchange(request, exchange);

        if (LOG.isDebugEnabled()) {
            LOG.debug("Client sends a request (method: " + request.getMethod() + ", uri: " + resourceUri + ")");
        }

        Response response = client.handle(request);
        if (throwException) {
            if (response instanceof Response) {
View Full Code Here

   
    public void process(Exchange exchange) throws Exception {
        RestletEndpoint endpoint = (RestletEndpoint)getEndpoint();
       
        String resourceUri = buildUri(endpoint);
        Request request = new Request(endpoint.getRestletMethod(),
                resourceUri);
       
        RestletBinding binding = endpoint.getRestletBinding();
        binding.populateRestletRequestFromExchange(request, exchange);
       
        if (LOG.isDebugEnabled()) {
            LOG.debug("Client sends a request (method: " + request.getMethod()
                    + ", uri: " + resourceUri + ")");
        }
       
        Response response = client.handle(request);
        binding.populateExchangeFromRestletResponse(exchange, response);
View Full Code Here

    //xstream.addImplicitCollection(StatusList.class, "statuses");
    xstream.aliasField("protected", User.class, "protect");   //can't use "protected"
    xstream.omitField(Status.class, "truncated");
   
    String URL = BASE_URL+"friendships/create/"+friendId+".xml";
    Request request = new Request(Method.GET, URL);   
    auth(request);
    Response response = client.handle(request);
   
    try {
      //System.out.println(response.getStatus()+response.getEntity().getText());
View Full Code Here

    return null;
  }

  public User deleteFriend(String friendId) {
    String URL = BASE_URL+"friendships/destroy/"+friendId+".xml";
    Request request = new Request(Method.GET, URL);
    //request.setEntity(status.getTextURLEncoded());
   
    auth(request);
    Response response = client.handle(request);
   
View Full Code Here

TOP

Related Classes of org.restlet.data.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.