@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());
}