Package org.restlet

Examples of org.restlet.Client.handle()


                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


    }

    @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 populateHostNames() {
    try {
      Request request = new Request(Method.GET,"http://info.teragrid.org/web-apps/XML/ctss-resources-v1/");
      Client client = new Client(Protocol.HTTP);
      Response response = client.handle(request);
      DomRepresentation representation = response.getEntityAsDom();
      Document document = representation.getDocument();
      NodeList nodeList = document.getElementsByTagName("Resource");
      for(int i=0;i<nodeList.getLength();i++){
        this.hostNameItems.add(new SelectItem(nodeList.item(i).getAttributes().getNamedItem("UniqueID").getNodeValue()));
View Full Code Here

  public void populateGridFtpEndPoints(String hostName) {
    if(!hostName.isEmpty()){
    try{
      Request request = new Request(Method.GET,"http://info.teragrid.org/web-apps/xml/kit-services-v1/type/gridftp/");
      Client client = new Client(Protocol.HTTP);
      Response response = client.handle(request);
      DomRepresentation representation = response.getEntityAsDom();
      Document document = representation.getDocument();
      NodeList nodeList = document.getElementsByTagName("Service");
      for(int i=0;i<nodeList.getLength();i++){
        Node node = nodeList.item(i);
View Full Code Here

   */
  public void populateServiceTypes() {
    try {
      Request request = new Request(Method.GET,"http://info.teragrid.org/restdemo/xml/tg/services");
      Client client = new Client(Protocol.HTTP);
      Response response = client.handle(request);
      DomRepresentation representation = response.getEntityAsDom();
      Document document = representation.getDocument();
      NodeList nodeList = document.getElementsByTagName("Service");
      for(int i=0;i<nodeList.getLength();i++){
        String type = nodeList.item(i).getAttributes().getNamedItem("Type").getNodeValue();
View Full Code Here

      Iterator<String> iterator = types.iterator();
      while(iterator.hasNext()){
        try{
          Request request = new Request(Method.GET,"http://info.teragrid.org/restdemo/xml/tg/services/"+iterator.next());
          Client client = new Client(Protocol.HTTP);
          Response response = client.handle(request);
          DomRepresentation representation = response.getEntityAsDom();
          Document document = representation.getDocument();
          NodeList nodeList = document.getElementsByTagName("Service");
          String currentHostName = (String) FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("hostInfo:hostName");
          for(int i=0;i<nodeList.getLength();i++){
View Full Code Here

    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());
View Full Code Here

        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());
View Full Code Here

                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

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.