Service s = new JAXRSServiceImpl(Collections.singletonList(c), true);
DataBinding binding = new JAXBDataBinding();
binding.initialize(s);
DataBindingJSONProvider p = new DataBindingJSONProvider();
p.setDataBinding(binding);
Book b = new Book("CXF", 127L);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
p.writeTo(b, Book.class, Book.class,
new Annotation[0], MediaType.APPLICATION_JSON_TYPE, new MetadataMap<String, Object>(), bos);
String data = "{\"Book\":{\"id\":127,\"name\":\"CXF\",\"state\":\"\"}}";
assertEquals(bos.toString(), data);