use of org.apache.cxf.jaxrs.rx2.client.FlowableRxInvokerProvider in project cxf by apache.
the class JAXRSRxJava2FlowableTest method testGetHelloWorldEmpty2.
@Test
public void testGetHelloWorldEmpty2() throws Exception {
String address = "http://localhost:" + PORT + "/rx22/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 testFlowableImmediateErrorsWithExceptionMapper.
@Test
public void testFlowableImmediateErrorsWithExceptionMapper() throws Exception {
String address = "http://localhost:" + PORT + "/rx22/flowable/immediate/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() == 409 && r.readEntity(String.class).contains("stackTrace")).assertComplete();
}
use of org.apache.cxf.jaxrs.rx2.client.FlowableRxInvokerProvider 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 org.apache.cxf.jaxrs.rx2.client.FlowableRxInvokerProvider in project cxf by apache.
the class JAXRSRxJava2FlowableTest method testFlowableImmediateErrors.
@Test
public void testFlowableImmediateErrors() throws Exception {
String address = "http://localhost:" + PORT + "/rx22/flowable/immediate/errors";
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.assertError(InternalServerErrorException.class);
}
use of org.apache.cxf.jaxrs.rx2.client.FlowableRxInvokerProvider 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();
}
Aggregations