Package org.jboss.resteasy.client

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


   @Test
   public void testGetter() throws Exception
   {
      before(ValidateExecutableResource.class);
      ClientRequest request = new ClientRequest(generateURL("/resource/executable/getter"));
      request.accept(MediaType.APPLICATION_XML);
      ClientResponse<?> response = request.get(ViolationReport.class);
      ViolationReport report = response.getEntity(ViolationReport.class);
      System.out.println("report: " + report.toString());
      countViolations(report, 1, 0, 1, 0, 0, 0);
      after();
View Full Code Here


   @Test
   public void testJson() throws Exception
   {
      ClientRequest request = new ClientRequest("http://localhost:9095/rest/mine/pairs");
      request.accept("application/json");
      String rtn = request.getTarget(String.class);

      System.out.println("**************");
      System.out.println();
      System.out.println(rtn);
View Full Code Here

      System.out.println();
      System.out.println(rtn);
      request.clear();

      request = new ClientRequest("http://localhost:9095/rest/mine/pairs");
      request.accept("application/xml");
      rtn = request.getTarget(String.class);

      System.out.println("******  XML  ********");
      System.out.println();
      System.out.println(rtn);
View Full Code Here

      {
         // Invalid native constraint
         request = new ClientRequest("http://localhost:8080/Validation-test/rest/return/native");
         request.body("application/foo", new Foo("abcdef"));
         request.accept(MediaType.APPLICATION_XML);
         response = request.post();
         ViolationReport r = response.getEntity(ViolationReport.class);
         System.out.println("entity: " + r);
         Assert.assertEquals(500, response.getStatus());
         String header = response.getResponseHeaders().getFirst(Validation.VALIDATION_HEADER);
View Full Code Here

     
      {
         // Invalid imposed constraint
         request = new ClientRequest("http://localhost:8080/Validation-test/rest/return/imposed");
         request.body("application/foo", new Foo("abcdef"));
         request.accept(MediaType.APPLICATION_XML);
         response = request.post(Foo.class);
         Assert.assertEquals(500, response.getStatus());
         String header = response.getResponseHeaders().getFirst(Validation.VALIDATION_HEADER);
         Assert.assertNotNull(header);
         Assert.assertTrue(Boolean.valueOf(header));
View Full Code Here

     
      {
         // Invalid native and imposed constraints
         request = new ClientRequest("http://localhost:8080/Validation-test/rest/return/nativeAndImposed");
         request.body("application/foo", new Foo("abcdef"));
         request.accept(MediaType.APPLICATION_XML);
         response = request.post(Foo.class);
         Assert.assertEquals(500, response.getStatus());
         String header = response.getResponseHeaders().getFirst(Validation.VALIDATION_HEADER);
         Assert.assertNotNull(header);
         Assert.assertTrue(Boolean.valueOf(header));
View Full Code Here

      // Invalid: Should have 1 each of field, property, class, and parameter violations,
      //          and no return value violations.
      request = new ClientRequest("http://localhost:8080/Validation-test/rest/all/a/z");
      foo = new Foo("p");
      request.body("application/foo", foo);
      request.accept(MediaType.APPLICATION_XML);
      response = request.post(Foo.class);
      Assert.assertEquals(400, response.getStatus());
      Object header = response.getHeaders().getFirst(Validation.VALIDATION_HEADER);
      Assert.assertTrue(header instanceof String);
      Assert.assertTrue(Boolean.valueOf(String.class.cast(header)));
View Full Code Here

      log.info("id: " + id);
      Assert.assertEquals(0, id);

      // Retrieve book.
      request = new ClientRequest("http://localhost:8080/resteasy-cdi-ejb-test/rest/book/" + id);
      request.accept(Constants.MEDIA_TYPE_TEST_XML);
      response = request.get();
      log.info("Status: " + response.getStatus());
      assertEquals(200, response.getStatus());
      Book result = response.getEntity(Book.class);
      log.info("book: " + book);
View Full Code Here

   public void testAcceptsProduces() throws Exception
   {
      // test that media type is chosen from resource method and accepts
      {
         ClientRequest request = new ClientRequest(generateURL("/mapper/accepts-produces"));
         request.accept("application/json");
         ClientResponse response = request.get();
         Assert.assertEquals(412, response.getStatus());
         Assert.assertEquals("application/json", response.getResponseHeaders().getFirst("Content-Type"));
         String error = (String) response.getEntity(String.class);
         Assert.assertNotNull(error);
View Full Code Here

         System.out.println(error);
      }

      {
         ClientRequest request = new ClientRequest(generateURL("/mapper/accepts-produces"));
         request.accept("application/xml");
         ClientResponse response = request.get();
         Assert.assertEquals(412, response.getStatus());
         Assert.assertEquals("application/xml", response.getResponseHeaders().getFirst("Content-Type"));
         String error = (String) response.getEntity(String.class);
         Assert.assertNotNull(error);
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.