Search in sources :

Example 1 with JAXRSClientBeanValidationFeature

use of org.apache.cxf.jaxrs.client.validation.JAXRSClientBeanValidationFeature in project cxf by apache.

the class JAXRSClientServerValidationSpringTest method testHelloRestValidationFailsIfNameIsNullClient.

@Test
public void testHelloRestValidationFailsIfNameIsNullClient() throws Exception {
    JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
    bean.setAddress("http://localhost:" + PORT + "/bwrest");
    bean.setServiceClass(BookWorld.class);
    bean.setFeatures(Arrays.asList(new JAXRSClientBeanValidationFeature()));
    BookWorld service = bean.create(BookWorld.class);
    BookWithValidation bw = service.echoBook(new BookWithValidation("RS", "123"));
    assertEquals("123", bw.getId());
    try {
        service.echoBook(new BookWithValidation(null, "123"));
        fail("Validation failure expected");
    } catch (ConstraintViolationException ex) {
    // complete
    }
}
Also used : JAXRSClientFactoryBean(org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean) ConstraintViolationException(javax.validation.ConstraintViolationException) JAXRSClientBeanValidationFeature(org.apache.cxf.jaxrs.client.validation.JAXRSClientBeanValidationFeature) BookWithValidation(org.apache.cxf.systest.jaxrs.validation.BookWithValidation) AbstractJAXRSValidationTest(org.apache.cxf.systest.jaxrs.validation.AbstractJAXRSValidationTest) Test(org.junit.Test)

Aggregations

ConstraintViolationException (javax.validation.ConstraintViolationException)1 JAXRSClientFactoryBean (org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean)1 JAXRSClientBeanValidationFeature (org.apache.cxf.jaxrs.client.validation.JAXRSClientBeanValidationFeature)1 AbstractJAXRSValidationTest (org.apache.cxf.systest.jaxrs.validation.AbstractJAXRSValidationTest)1 BookWithValidation (org.apache.cxf.systest.jaxrs.validation.BookWithValidation)1 Test (org.junit.Test)1