Package org.restlet.data

Examples of org.restlet.data.Response


            if (this.baseName != null) {
                String filePath;
                for (Reference ref : getVariantsReferences()) {
                    // Add the new variant to the result list
                    Response contextResponse = getDispatcher().get(
                            ref.toString());
                    if (contextResponse.getStatus().isSuccess()
                            && (contextResponse.getEntity() != null)) {
                        filePath = ref.toString(false, false).substring(
                                rootLength);
                        Representation rep = contextResponse.getEntity();
                        rep.setIdentifier(baseRef + filePath);
                        resultSet.add(rep);
                    }
                }
            }
View Full Code Here


        ReferenceList result = new ReferenceList(0);
        try {
            Request contextCall = new Request(Method.GET, this.targetUri);
            contextCall.getClientInfo().getAcceptedMediaTypes().add(
                    new Preference<MediaType>(MediaType.TEXT_URI_LIST));
            Response contextResponse = getDispatcher().handle(contextCall);
            if (contextResponse.getEntity() != null) {
                ReferenceList listVariants = new ReferenceList(contextResponse
                        .getEntity());
                Set<String> extensions = null;
                String entryUri;
                String fullEntryName;
                String baseEntryName;
View Full Code Here

        assertEquals("received [<order foo='1'/>] as an order id = " + ID, response);
    }

    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

                response.getEntity().getText());
    }
   
    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

        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

        Component component = null;

        // Look for the Component XML configuration file.
        ServletWarClient client = new ServletWarClient(new Context(),
                getServletContext());
        Response response = client.get("war:///WEB-INF/restlet.xml");
        if (response.getStatus().isSuccess() && response.isEntityAvailable()) {
            component = new Component(response.getEntity());
        }

        // Look for the component class name specified in the web.xml file.
        if (component == null) {
            // Try to instantiate a new target component
View Full Code Here

     */
    private boolean isDefaultComponent() {
        // The Component is provided via an XML configuration file.
        ServletWarClient client = new ServletWarClient(new Context(),
                getServletContext());
        Response response = client.get("war:///WEB-INF/restlet.xml");
        if (response.getStatus().isSuccess() && response.isEntityAvailable()) {
            return false;
        }

        // The Component is provided via a context parameter in the "web.xml"
        // file.
View Full Code Here

  }
 
  public void testExceptionHandling(){
    Context con = new Context();
    Request req = new Request();
    Response resp = new Response(req);
   
    myResource.init(con, req, resp);
    myResource.handleGet();
   
    assertEquals(resp.getStatus(), myResource.getStatus());
    assertEquals(resp.getEntity(), myResource.getRepresentation());
  }
View Full Code Here

        assertXpathEvaluatesTo("3.0", "//prop3", dom);
    }

    public void testObjectGetAsJSON() throws Exception {
        Request request = newRequestGET( "foo.json" );
        Response response = new Response(request);
       
        FooReflectiveResource resource = new FooReflectiveResource( null, request, response );
        resource.handleGet();
       
        JSON json = getJSON(response);
View Full Code Here

                "<prop1>one</prop1>" +
                "<prop2>2</prop2>" +
                "<prop3>3.0</prop3>" +
            "</org.geoserver.rest.Foo>";
        Request request = newRequestPOST("foo",xml,"text/xml");
        Response response = new Response(request);
       
        FooReflectiveResource resource = new FooReflectiveResource( null, request, response );
        resource.handlePost();
       
        assertEquals( "one", resource.posted.prop1 );
View Full Code Here

TOP

Related Classes of org.restlet.data.Response

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.