use of org.apache.cxf.jaxrs.rx2.client.FlowableRxInvokerProvider in project cxf by apache.
the class JAXRSRxJava3MaybeTest method testGetHelloWorldJson.
@Test
public void testGetHelloWorldJson() throws Exception {
String address = "http://localhost:" + PORT + "/rx3/maybe/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();
}
use of org.apache.cxf.jaxrs.rx2.client.FlowableRxInvokerProvider in project cxf by apache.
the class JAXRSRxJava2FlowableTest method testFlowableErrorsResponseWithMapper.
@Test
public void testFlowableErrorsResponseWithMapper() throws Exception {
String address = "http://localhost:" + PORT + "/rx22/flowable/mapper/errors";
final Flowable<Response> obs = ClientBuilder.newClient().register(new JacksonJsonProvider()).register(new FlowableRxInvokerProvider()).target(address).request(MediaType.APPLICATION_JSON).rx(FlowableRxInvoker.class).get();
final TestSubscriber<Response> subscriber = new TestSubscriber<>();
obs.subscribe(subscriber);
subscriber.await(3, TimeUnit.SECONDS);
subscriber.assertValue(r -> r.getStatus() == 400).assertComplete();
}
use of org.apache.cxf.jaxrs.rx2.client.FlowableRxInvokerProvider in project cxf by apache.
the class JAXRSRxJava2FlowableTest method testGetHelloWorldEmpty.
@Test
public void testGetHelloWorldEmpty() throws Exception {
String address = "http://localhost:" + PORT + "/rx2/flowable/empty";
final Flowable<Response> obs = ClientBuilder.newClient().register(new JacksonJsonProvider()).register(new FlowableRxInvokerProvider()).target(address).request(MediaType.APPLICATION_JSON).rx(FlowableRxInvoker.class).get();
final TestSubscriber<Response> subscriber = new TestSubscriber<>();
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.FlowableRxInvokerProvider in project cxf by apache.
the class JAXRSRxJava2FlowableTest method testGetHelloWorldAsyncObservable404.
@Test
public void testGetHelloWorldAsyncObservable404() throws Exception {
String address = "http://localhost:" + PORT + "/rx2/flowable/textAsync404";
Invocation.Builder b = ClientBuilder.newClient().register(new FlowableRxInvokerProvider()).target(address).request();
final TestSubscriber<String> subscriber = new TestSubscriber<>();
b.rx(FlowableRxInvoker.class).get(String.class).subscribe(subscriber);
subscriber.await(1, TimeUnit.SECONDS);
subscriber.assertError(NotFoundException.class);
}
use of org.apache.cxf.jaxrs.rx2.client.FlowableRxInvokerProvider in project cxf by apache.
the class JAXRSRxJava2FlowableTest method testGetHelloWorldAsyncObservable.
@Test
public void testGetHelloWorldAsyncObservable() throws Exception {
String address = "http://localhost:" + PORT + "/rx2/flowable/textAsync";
WebClient wc = WebClient.create(address, Collections.singletonList(new FlowableRxInvokerProvider()));
Flowable<String> obs = wc.accept("text/plain").rx(FlowableRxInvoker.class).get(String.class);
final TestSubscriber<String> subscriber = new TestSubscriber<>();
obs.map(s -> s + s).subscribe(subscriber);
subscriber.await(2, TimeUnit.SECONDS);
subscriber.assertResult("Hello, world!Hello, world!");
}
Aggregations