use of org.apache.cxf.jaxrs.rx2.client.ObservableRxInvokerProvider in project cxf by apache.
the class JAXRSRxJava2ObservableTest method testGetHelloWorldJson.
@Test
public void testGetHelloWorldJson() throws Exception {
String address = "http://localhost:" + PORT + "/rx2/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 org.apache.cxf.jaxrs.rx2.client.ObservableRxInvokerProvider in project cxf by apache.
the class JAXRSRxJava2ObservableTest method testObservableImmediateErrorsWithExceptionMapper.
@Test
public void testObservableImmediateErrorsWithExceptionMapper() throws Exception {
String address = "http://localhost:" + PORT + "/rx2/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 org.apache.cxf.jaxrs.rx2.client.ObservableRxInvokerProvider in project cxf by apache.
the class JAXRSRxJava2ObservableTest method testGetHelloWorldEmpty.
@Test
public void testGetHelloWorldEmpty() throws Exception {
String address = "http://localhost:" + PORT + "/rx2/observable/empty";
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 -> "[]".equals(r.readEntity(String.class))).assertComplete();
}
use of org.apache.cxf.jaxrs.rx2.client.ObservableRxInvokerProvider 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 org.apache.cxf.jaxrs.rx2.client.ObservableRxInvokerProvider 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();
}
Aggregations