Package org.jboss.resteasy.validation

Examples of org.jboss.resteasy.validation.Foo


   @Test
   public void testReturnValues() throws Exception
   {
      // Valid native constraint
      ClientRequest request = new ClientRequest("http://localhost:8080/Validation-test/rest/return/native");
      Foo foo = new Foo("a");
      request.body("application/foo", foo);
      ClientResponse<?> response = request.post(Foo.class);    
      Assert.assertEquals(200, response.getStatus());
      Assert.assertEquals(foo, response.getEntity());
     
      // Valid imposed constraint
      request = new ClientRequest("http://localhost:8080/Validation-test/rest/return/imposed");
      foo = new Foo("abcde");
      request.body("application/foo", foo);
      response = request.post(Foo.class);     
      Assert.assertEquals(200, response.getStatus());
      Assert.assertEquals(foo, response.getEntity());

      // Valid native and imposed constraints.
      request = new ClientRequest("http://localhost:8080/Validation-test/rest/return/nativeAndImposed");
      foo = new Foo("abc");
      request.body("application/foo", foo);
      response = request.post(Foo.class);     
      Assert.assertEquals(200, response.getStatus());
      Assert.assertEquals(foo, response.getEntity());

      {
         // Invalid native constraint
        // BUT EXECUTABLE VALIDATION IS DISABLE.
         request = new ClientRequest("http://localhost:8080/Validation-test/rest/return/native");
         foo = new Foo("abcdef");
         request.body("application/foo", foo);
         response = request.post(Foo.class);     
         Assert.assertEquals(200, response.getStatus());
         Assert.assertEquals(foo, response.getEntity());
      }
     
      {
         // Invalid imposed constraint
        // BUT EXECUTABLE VALIDATION IS DISABLE.
         request = new ClientRequest("http://localhost:8080/Validation-test/rest/return/imposed");
         foo = new Foo("abcdef");
         request.body("application/foo", foo);
         response = request.post(Foo.class);     
         Assert.assertEquals(200, response.getStatus());
         Assert.assertEquals(foo, response.getEntity());
      }
     
      {
         // Invalid native and imposed constraints
        // BUT EXECUTABLE VALIDATION IS DISABLE.
         request = new ClientRequest("http://localhost:8080/Validation-test/rest/return/nativeAndImposed");
         foo = new Foo("abcdef");
         request.body("application/foo", foo);
         response = request.post(Foo.class);     
         Assert.assertEquals(200, response.getStatus());
         Assert.assertEquals(foo, response.getEntity());
      }
View Full Code Here


   @Test
   public void testViolationsBeforeReturnValue() throws Exception
   {
      // Valid
      ClientRequest request = new ClientRequest("http://localhost:8080/Validation-test/rest/all/abc/wxyz");
      Foo foo = new Foo("pqrs");
      request.body("application/foo", foo);
      ClientResponse<?> response = request.post(Foo.class);
      Assert.assertEquals(200, response.getStatus());
      Assert.assertEquals(foo, response.getEntity());

      // Invalid: Should have 1 each of field, property, class, and parameter violations,
      //          and no return value violations.
     // BUT EXECUTABLE VALIDATION IS DISABLE. There will be no parameter violation.
      request = new ClientRequest("http://localhost:8080/Validation-test/rest/all/a/z");
      foo = new Foo("p");
      request.body("application/foo", foo);
      response = request.post(Foo.class);
      Assert.assertEquals(400, response.getStatus());
      String header = response.getResponseHeaders().getFirst(Validation.VALIDATION_HEADER);
      Assert.assertNotNull(header);
View Full Code Here

public class TestValidationSuppressPathParent
   public void doTestInputViolations(String fieldPath, String propertyPath, String classPath, String parameterPath) throws Exception
   {
      ClientRequest request = new ClientRequest("http://localhost:8080/Validation-test/rest/all/a/z");
      Foo foo = new Foo("p");
      request.body("application/foo", foo);
      ClientResponse<?> response = request.post(Foo.class);
      Assert.assertEquals(400, response.getStatus());
      String header = response.getResponseHeaders().getFirst(Validation.VALIDATION_HEADER);
      Assert.assertNotNull(header);
View Full Code Here

   }
  
   public void doTestReturnValueViolations(String returnValuePath) throws Exception
   {
      ClientRequest request = new ClientRequest("http://localhost:8080/Validation-test/rest/return/native");
      request.body("application/foo", new Foo("abcdef"));
      ClientResponse<?> response = request.post();
      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

TOP

Related Classes of org.jboss.resteasy.validation.Foo

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.