use of io.reactivex.Flowable in project cxf by apache.
the class JAXRSRxJava2FlowableTest method testFlowableErrorWithExceptionMapperReturnsContentPayload.
@Test
public void testFlowableErrorWithExceptionMapperReturnsContentPayload() throws Exception {
GenericType<List<HelloWorldBean>> helloWorldBeanListType = new GenericType<List<HelloWorldBean>>() {
};
String address = "http://localhost:" + PORT + "/rx22/flowable/mixed/error";
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);
// The response should include the emitted elements prior the error
subscriber.await(3, TimeUnit.SECONDS);
subscriber.assertValue(r -> r.getStatus() == 409 && r.readEntity(helloWorldBeanListType).size() == 4).assertComplete();
}
use of io.reactivex.Flowable in project cxf by apache.
the class JAXRSRxJava2MaybeTest method testGetString.
@Test
public void testGetString() throws Exception {
String address = "http://localhost:" + PORT + "/rx2/maybe/textAsync";
final Flowable<String> obs = ClientBuilder.newClient().register(new FlowableRxInvokerProvider()).target(address).request(MediaType.TEXT_PLAIN).rx(FlowableRxInvoker.class).get(String.class);
final TestSubscriber<String> subscriber = new TestSubscriber<>();
obs.subscribe(subscriber);
subscriber.await(3, TimeUnit.SECONDS);
subscriber.assertValue(r -> "Hello, world!".equals(r)).assertComplete();
}
use of io.reactivex.Flowable in project cxf by apache.
the class JAXRSRxJava2MaybeTest method testGetHelloWorldEmpty.
@Test
public void testGetHelloWorldEmpty() throws Exception {
String address = "http://localhost:" + PORT + "/rx2/maybe/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 -> !r.hasEntity()).assertComplete();
}
use of io.reactivex.Flowable in project cxf by apache.
the class JAXRSRxJava2MaybeTest method testGetHelloWorldJson.
@Test
public void testGetHelloWorldJson() throws Exception {
String address = "http://localhost:" + PORT + "/rx2/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 io.reactivex.Flowable in project cxf by apache.
the class JAXRSRxJava2SingleTest method testGetString.
@Test
public void testGetString() throws Exception {
String address = "http://localhost:" + PORT + "/rx2/single/textAsync";
final Flowable<String> obs = ClientBuilder.newClient().register(new FlowableRxInvokerProvider()).target(address).request(MediaType.TEXT_PLAIN).rx(FlowableRxInvoker.class).get(String.class);
final TestSubscriber<String> subscriber = new TestSubscriber<>();
obs.subscribe(subscriber);
subscriber.await(3, TimeUnit.SECONDS);
subscriber.assertValue(r -> "Hello, world!".equals(r)).assertComplete();
}
Aggregations