use of org.apache.cxf.systest.jaxrs.validation.BookWithValidation in project cxf by apache.
the class JAXRSClientServerValidationSpringTest method testHelloSoapValidationFailsIfNameIsNull.
@Test
public void testHelloSoapValidationFailsIfNameIsNull() throws Exception {
final QName serviceName = new QName("http://bookworld.com", "BookWorld");
final QName portName = new QName("http://bookworld.com", "BookWorldPort");
final String address = "http://localhost:" + PORT + "/bwsoap";
Service service = Service.create(serviceName);
service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, address);
BookWorld bwService = service.getPort(BookWorld.class);
BookWithValidation bw = bwService.echoBook(new BookWithValidation("WS", "123"));
assertEquals("123", bw.getId());
try {
bwService.echoBook(new BookWithValidation(null, "123"));
fail("Validation failure expected");
} catch (SOAPFaultException ex) {
// complete
}
}
use of org.apache.cxf.systest.jaxrs.validation.BookWithValidation 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
}
}
use of org.apache.cxf.systest.jaxrs.validation.BookWithValidation in project cxf by apache.
the class JAXRSServerSpringDiscoveryTest method testThatClientDiscoversServiceProperly.
@Test
public void testThatClientDiscoversServiceProperly() throws Exception {
BookStore bs = JAXRSClientFactory.create("http://localhost:" + PORT, BookStore.class, "org/apache/cxf/systest/jaxrs/discovery/jaxrs-http-client.xml");
assertEquals("http://localhost:" + PORT, WebClient.client(bs).getBaseURI().toString());
BookWithValidation book = bs.getBook("123");
assertEquals(book.getId(), "123");
}
use of org.apache.cxf.systest.jaxrs.validation.BookWithValidation in project cxf by apache.
the class BookStoreWithValidation method addBook.
@POST
@Path("/books")
public Response addBook(@Context final UriInfo uriInfo, @NotNull @FormParam("id") String id, @FormParam("name") String name) {
final BookWithValidation book = new BookWithValidation(name, id);
provider.validateBean(book);
return Response.created(uriInfo.getRequestUriBuilder().path(id).build()).build();
}
use of org.apache.cxf.systest.jaxrs.validation.BookWithValidation in project cxf by apache.
the class JAXRSClientServerValidationSpringTest method testHelloRestValidationFailsIfNameIsNull.
@Test
public void testHelloRestValidationFailsIfNameIsNull() throws Exception {
String address = "http://localhost:" + PORT + "/bwrest";
BookWorld service = JAXRSClientFactory.create(address, 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 (BadRequestException ex) {
// complete
}
}
Aggregations