use of com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider in project cxf by apache.
the class JAXRSClientServerResourceJacksonSpringProviderTest method testGetCollectionOfBooks.
@Test
public void testGetCollectionOfBooks() throws Exception {
String endpointAddress = "http://localhost:" + PORT + "/webapp/store1/bookstore/collections";
WebClient wc = WebClient.create(endpointAddress, Collections.singletonList(new JacksonJsonProvider()));
wc.accept("application/json");
Collection<? extends Book> collection = wc.getCollection(Book.class);
assertEquals(1, collection.size());
Book book = collection.iterator().next();
assertEquals(123L, book.getId());
}
use of com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider in project cxf by apache.
the class JAXRSClientServerResourceJacksonSpringProviderTest method testGetGenericSuperBookInt1.
@Test
public void testGetGenericSuperBookInt1() throws Exception {
String endpointAddress = "http://localhost:" + PORT + "/webapp/genericstoreInt1/int/books/superbook";
WebClient wc = WebClient.create(endpointAddress, Collections.singletonList(new JacksonJsonProvider()));
WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(1000000000L);
GenericType<List<SuperBook>> genericResponseType = new GenericType<List<SuperBook>>() {
};
List<SuperBook> books = wc.get(genericResponseType);
assertEquals(1, books.size());
assertEquals(111L, books.get(0).getId());
}
use of com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider in project cxf by apache.
the class JAXRSClientServerResourceJacksonSpringProviderTest method testEchoGenericSuperBookWebClient.
@Test
public void testEchoGenericSuperBookWebClient() throws Exception {
String endpointAddress = "http://localhost:" + PORT + "/webapp/custombus/genericstore/books/superbook";
WebClient wc = WebClient.create(endpointAddress, Collections.singletonList(new JacksonJsonProvider()));
wc.accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON);
SuperBook book = wc.post(new SuperBook("Super", 124L, true), SuperBook.class);
assertEquals(124L, book.getId());
assertTrue(book.isSuperBook());
}
use of com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider in project cxf by apache.
the class JAXRSClientServerResourceJacksonSpringProviderTest method testMultipart.
@Test
public void testMultipart() throws Exception {
String endpointAddress = "http://localhost:" + PORT + "/webapp/multipart";
MultipartStore proxy = JAXRSClientFactory.create(endpointAddress, MultipartStore.class, Collections.singletonList(new JacksonJsonProvider()));
Book json = new Book("json", 1L);
InputStream is1 = getClass().getResourceAsStream("/org/apache/cxf/systest/jaxrs/resources/java.jpg");
Map<String, Object> attachments = proxy.addBookJsonImageStream(json, is1);
assertEquals(2, attachments.size());
Book json2 = ((Attachment) attachments.get("application/json")).getObject(Book.class);
assertEquals("json", json2.getName());
assertEquals(1L, json2.getId());
InputStream is2 = ((Attachment) attachments.get("application/octet-stream")).getObject(InputStream.class);
byte[] image1 = IOUtils.readBytesFromStream(getClass().getResourceAsStream("/org/apache/cxf/systest/jaxrs/resources/java.jpg"));
byte[] image2 = IOUtils.readBytesFromStream(is2);
assertArrayEquals(image1, image2);
}
use of com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider in project cxf by apache.
the class JAXRSClientServerResourceJacksonSpringProviderTest method testGetCollectionOfSuperBooks.
@Test
public void testGetCollectionOfSuperBooks() throws Exception {
String endpointAddress = "http://localhost:" + PORT + "/webapp/store2/books/superbooks";
WebClient wc = WebClient.create(endpointAddress, Collections.singletonList(new JacksonJsonProvider()));
wc.accept("application/json");
Collection<? extends Book> collection = wc.getCollection(Book.class);
assertEquals(1, collection.size());
Book book = collection.iterator().next();
assertEquals(999L, book.getId());
}
Aggregations