use of com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider in project cxf by apache.
the class JAXRSRxJava3ObservableTest method testGetHelloWorldJson.
@Test
public void testGetHelloWorldJson() throws Exception {
String address = "http://localhost:" + PORT + "/rx3/observable/textJson";
List<Object> providers = new LinkedList<>();
providers.add(new JacksonJsonProvider());
providers.add(new ObservableRxInvokerProvider());
WebClient wc = WebClient.create(address, providers);
Observable<HelloWorldBean> obs = wc.accept("application/json").rx(ObservableRxInvoker.class).get(HelloWorldBean.class);
Holder<HelloWorldBean> holder = new Holder<>();
Disposable d = obs.subscribe(v -> {
holder.value = v;
});
if (d == null) {
throw new IllegalStateException("Subscribe did not return a Disposable");
}
Thread.sleep(2000);
assertEquals("Hello", holder.value.getGreeting());
assertEquals("World", holder.value.getAudience());
}
use of com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider in project cxf by apache.
the class JAXRSRxJava3ObservableTest method doTestGetHelloWorldJsonList.
private void doTestGetHelloWorldJsonList(String address) throws Exception {
WebClient wc = WebClient.create(address, Collections.singletonList(new JacksonJsonProvider()));
WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(10000000);
GenericType<List<HelloWorldBean>> genericResponseType = new GenericType<List<HelloWorldBean>>() {
};
List<HelloWorldBean> beans = wc.accept("application/json").get(genericResponseType);
assertEquals(2, beans.size());
assertEquals("Hello", beans.get(0).getGreeting());
assertEquals("World", beans.get(0).getAudience());
assertEquals("Ciao", beans.get(1).getGreeting());
assertEquals("World", beans.get(1).getAudience());
}
use of com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider in project cxf by apache.
the class JAXRSRxJava3ObservableTest method testObservableImmediateErrorsWithExceptionMapper.
@Test
public void testObservableImmediateErrorsWithExceptionMapper() throws Exception {
String address = "http://localhost:" + PORT + "/rx3/observable/immediate/mapper/errors";
final Observable<Response> obs = ClientBuilder.newClient().register(new JacksonJsonProvider()).register(new ObservableRxInvokerProvider()).target(address).request(MediaType.APPLICATION_JSON).rx(ObservableRxInvoker.class).get();
final TestObserver<Response> subscriber = new TestObserver<>();
obs.subscribe(subscriber);
subscriber.await(3, TimeUnit.SECONDS);
subscriber.assertValue(r -> r.getStatus() == 409 && r.readEntity(String.class).contains("stackTrace")).assertComplete();
}
use of com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider in project cxf by apache.
the class JAXRSRxJava3ObservableTest method testObservableImmediateErrors.
@Test
public void testObservableImmediateErrors() throws Exception {
String address = "http://localhost:" + PORT + "/rx3/observable/immediate/errors";
final Observable<HelloWorldBean> obs = ClientBuilder.newClient().register(new JacksonJsonProvider()).register(new ObservableRxInvokerProvider()).target(address).request(MediaType.APPLICATION_JSON).rx(ObservableRxInvoker.class).get(HelloWorldBean.class);
final TestObserver<HelloWorldBean> subscriber = new TestObserver<>();
obs.subscribe(subscriber);
subscriber.await(3, TimeUnit.SECONDS);
subscriber.assertError(InternalServerErrorException.class);
}
use of com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider in project cxf by apache.
the class JAXRSRxJava2SingleTest method testGetHelloWorldJson.
@Test
public void testGetHelloWorldJson() throws Exception {
String address = "http://localhost:" + PORT + "/rx2/single/textJson";
final Flowable<HelloWorldBean> obs = ClientBuilder.newClient().register(new JacksonJsonProvider()).register(new FlowableRxInvokerProvider()).target(address).request(MediaType.APPLICATION_JSON).rx(FlowableRxInvoker.class).get(HelloWorldBean.class);
final TestSubscriber<HelloWorldBean> subscriber = new TestSubscriber<>();
obs.subscribe(subscriber);
subscriber.await(3, TimeUnit.SECONDS);
subscriber.assertValue(r -> "Hello".equals(r.getGreeting()) && "World".equals(r.getAudience())).assertComplete();
}
Aggregations