Package org.jboss.resteasy.client

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


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


      before(TestResourceWithNullParameterAndReturnValue.class);

      {
         // Null query parameter
         ClientRequest request = new ClientRequest(generateURL("/post"));
         request.accept(MediaType.APPLICATION_XML);
         ClientResponse<?> response = request.post();
         ViolationReport report = response.getEntity(ViolationReport.class);
         System.out.println("report: " + report.toString());
         countViolations(report, 1, 0, 0, 0, 1, 0);
      }
View Full Code Here

      }

      {
         // Null return value
         ClientRequest request = new ClientRequest(generateURL("/get"));
         request.accept(MediaType.APPLICATION_XML);
         ClientResponse<?> response = request.get();
         ViolationReport report = response.getEntity(ViolationReport.class);
         System.out.println("report: " + report.toString());
         countViolations(report, 1, 0, 0, 0, 0, 1);
      }
View Full Code Here

  {
    ClientRequest request = new ClientRequest(generateURL("/accepts/string/default"));
    String str = "La Règle du Jeu";
    System.out.println(str);
    request.body(TEXT_PLAIN_UTF16_TYPE, str);
    request.accept(WILDCARD_UTF16_TYPE);
    ClientResponse<?> response = request.post();
    Assert.assertEquals(200, response.getStatus());
    String entity = response.getEntity(String.class);
    System.out.println("Result: " + entity);
    Assert.assertEquals(str, entity);
View Full Code Here

  {
    ClientRequest request = new ClientRequest(generateURL("/accepts/foo/default"));
    Foo foo = new Foo("La Règle du Jeu");
    System.out.println(foo);
    request.body(TEXT_PLAIN_UTF16_TYPE, foo);
    request.accept(TEXT_PLAIN_UTF16_TYPE);
    ClientResponse<?> response = request.post();
    Assert.assertEquals(200, response.getStatus());
    String entity = response.getEntity(String.class);
    System.out.println("Result: " + entity);
    Assert.assertEquals(foo.valueOf(), entity);
View Full Code Here

    */
   @Test
   public void testBadMediaTypeNoSubtype() throws Exception
   {
      ClientRequest request = new ClientRequest("http://localhost:9095/my/application/count");
      request.accept("text");
      final ClientResponse response = request.get();
      Assert.assertEquals(400, response.getStatus());
   }

   /**
 
View Full Code Here

    */
   @Test
   public void testBadMediaTypeNonNumericQualityValue() throws Exception
   {
      ClientRequest request = new ClientRequest("http://localhost:9095/my/application/count");
      request.accept("text/plain; q=bad");
      final ClientResponse response = request.get();
      Assert.assertEquals(400, response.getStatus());
   }
}
View Full Code Here

      {
         // Text form
         ClientRequest request = new ClientRequest(generateURL("/a/b/c"));
         Foo foo = new Foo("p");
         request.body("application/foo", foo);
         request.accept(mediaType);
         ClientResponse<?> response = request.post(Foo.class);
         Assert.assertEquals(400, response.getStatus());
         String entity = response.getEntity(String.class);
         System.out.println("report: " + entity);
         String start = "<violationReport>";
View Full Code Here

      {
         // Unmarshal report,
         ClientRequest request = new ClientRequest(generateURL("/a/b/c"));
         Foo foo = new Foo("p");
         request.body("application/foo", foo);
         request.accept(MediaType.APPLICATION_XML);
         ClientResponse<?> response = request.post(Foo.class);
         Assert.assertEquals(400, response.getStatus());
         ViolationReport report = response.getEntity(ViolationReport.class);
         System.out.println("report: " + report);
         countViolations(report, 4, 2, 1, 1, 1, 0);
View Full Code Here

      {
         // Text form
         ClientRequest request = new ClientRequest(generateURL("/abc/pqr/xyz"));
         Foo foo = new Foo("123");
         request.body("application/foo", foo);
         request.accept(mediaType);
         ClientResponse<?> response = request.post(Foo.class);
         Assert.assertEquals(500, response.getStatus());
         String entity = response.getEntity(String.class);
         System.out.println("report: " + entity);
         String expected = "<violationReport><returnValueViolations><constraintType>RETURN_VALUE</constraintType><path>post.&lt;return value&gt;</path><message>s must have length: 4 &lt;= length &lt;= 5</message><value>Foo[123]</value></returnValueViolations></violationReport>";
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.