// 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);
Assert.assertNotNull(header);
Assert.assertTrue(Boolean.valueOf(header));
ResteasyConstraintViolation violation = r.getReturnValueViolations().iterator().next();
System.out.println("violation: " + violation);
Assert.assertTrue(violation.getMessage().equals("s must have length: 1 <= length <= 3"));
Assert.assertEquals("Foo[abcdef]", violation.getValue());
}
{
// 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));
ViolationReport r = response.getEntity(ViolationReport.class);
System.out.println("entity: " + r);
countViolations(r, 1, 0, 0, 0, 0, 1);
ResteasyConstraintViolation violation = r.getReturnValueViolations().iterator().next();
System.out.println("violation: " + violation);
Assert.assertTrue(violation.getMessage().equals("s must have length: 3 <= length <= 5"));
Assert.assertEquals("Foo[abcdef]", violation.getValue());
}
{
// 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));
ViolationReport r = response.getEntity(ViolationReport.class);
System.out.println("entity: " + r);
countViolations(r, 2, 0, 0, 0, 0, 2);
Iterator<ResteasyConstraintViolation > it = r.getReturnValueViolations().iterator();
ResteasyConstraintViolation cv1 = it.next();
ResteasyConstraintViolation cv2 = it.next();
if (cv1.getMessage().indexOf('1') < 0)
{
ResteasyConstraintViolation temp = cv1;