Package org.jboss.resteasy.client

Examples of org.jboss.resteasy.client.ClientRequest.body()


   {
      String xml = "<bad-list>"
              + "<foo test=\"hello\"/></bad-list>";

      ClientRequest request = new ClientRequest(generateURL("/list"));
      request.body("application/xml", xml);
      ClientResponse<Foo[]> response = request.post(new GenericType<Foo[]>()
      {
      });
      Assert.assertEquals(400, response.getStatus());
View Full Code Here


   @Test
   public void testFile() throws Exception
   {
      ClientRequest request = new ClientRequest(TEST_URI + "/file/test");
      request
              .body(
                      "multipart/form-data; boundary=---------------------------52524491016334132001492192799",
                      form);
      ClientResponse<?> response = request.post();
      Assert.assertEquals(200, response.getStatus());
View Full Code Here

      ClientResponse<String> response2 = request.get(String.class);
      System.out.println(response2.getEntity());
      Assert.assertEquals(200, response2.getStatus());

      request = new ClientRequest(generateURL("/products/333"));
      request.body("application/foo+json", p);
      response = request.post(Product.class);
      p = response.getEntity();
      Assert.assertEquals(333, p.getId());
      Assert.assertEquals("Iphone", p.getName());
View Full Code Here

      ClientRequest request = new ClientRequest(TestPortProvider.generateURL("/test/string"));
      Customer cust = new Customer();
      String name = "bill\u00E9";
      cust.setName(name);
      request.body("application/xml", cust);
      request.post();


   }
   @Test
View Full Code Here

      String name = "bill\u00E9";
      System.out.println("client name: " + name);

      System.out.println("bytes string: " + new String(name.getBytes("UTF-8"), "UTF-8"));
      cust.setName(name);
      request.body("application/xml", cust);
      request.post();


   }
}
View Full Code Here

      }
      client.header(h.getKey(), sb);
    }

    if (request.entity() != null) {
      client.body(request.entity().getContentType(), request.entity().getEntity());
    }

    ClientResponse<T> response;

    try {
View Full Code Here

            throw new IllegalArgumentException("No telephone number given");

        ClientRequest req = new ClientRequest(DEVGARDEN_SMS_GW + "/" + mode + "/sms");

        String body = "number=" + tel + "&" + "message=" + message; // TODO encode?
        req.body(MediaType.APPLICATION_FORM_URLENCODED, body);

        req.header("Authorization","TAuth realm=\"https://odg.t-online.de\",tauth_token=\"" + token + "\"");
        req.accept(MediaType.TEXT_PLAIN_TYPE);

View Full Code Here

    public ServiceResponse<KieContainerResource> createContainer(String id, KieContainerResource resource) throws ClientResponseFailure {
        ClientResponse<ServiceResponse<KieContainerResource>> response = null;
        try {
            ClientRequest clientRequest = newRequest(baseURI + "/containers/" + id);
            response = clientRequest.body(mediaType, resource).put(new GenericType<ServiceResponse<KieContainerResource>>(){});
            if( response.getStatus() == Response.Status.CREATED.getStatusCode() ) {
                return response.getEntity();
            } else if( response.getStatus() == Response.Status.BAD_REQUEST.getStatusCode() ) {
                return response.getEntity();
            }
View Full Code Here

    public ServiceResponse<String> executeCommands(String id, String payload) throws ClientResponseFailure {
        ClientResponse<ServiceResponse<String>> response = null;
        try {
            ClientRequest clientRequest = newRequest(baseURI + "/containers/" + id);
            response = clientRequest.body(mediaType, payload).post(new GenericType<ServiceResponse<String>>(){});
            if( response.getStatus() == Response.Status.OK.getStatusCode() ) {
                return response.getEntity();
            }
            throw new ClientResponseFailure("Unexpected response code: "+response.getStatus(), response );
        } catch (ClientResponseFailure e) {
View Full Code Here

    public List<ServiceResponse<? extends Object>> executeScript(CommandScript script) throws ClientResponseFailure {
        ClientResponse<List<ServiceResponse<? extends Object>>> response = null;
        try {
            ClientRequest clientRequest = newRequest(baseURI);
            response = clientRequest.body(mediaType, script).post(new GenericType<List<ServiceResponse<? extends Object>>>() {});
            if( response.getStatus() == Response.Status.OK.getStatusCode() ) {
                return response.getEntity();
            }
            throw new ClientResponseFailure("Unexpected response code: "+response.getStatus(), response );
        } catch (ClientResponseFailure e) {
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.