use of org.apache.cxf.jaxrs.rx3.client.FlowableRxInvokerProvider in project cxf by apache.
the class JAXRSRxJava2FlowableTest method testFlowableErrorWithExceptionMapperReturnsNoExceptionPayload.
@Test
public void testFlowableErrorWithExceptionMapperReturnsNoExceptionPayload() throws Exception {
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 not include the exception payload (injected by exception mapper)
// if some elements have been emitted before
subscriber.await(3, TimeUnit.SECONDS);
subscriber.assertValue(r -> r.getStatus() == 409 && !r.readEntity(String.class).contains("stackTrace")).assertComplete();
}
use of org.apache.cxf.jaxrs.rx3.client.FlowableRxInvokerProvider in project cxf by apache.
the class JAXRSRxJava2FlowableTest method testGetHelloWorldJson.
@Test
public void testGetHelloWorldJson() throws Exception {
String address = "http://localhost:" + PORT + "/rx2/flowable/textJson";
List<Object> providers = new LinkedList<>();
providers.add(new JacksonJsonProvider());
providers.add(new FlowableRxInvokerProvider());
WebClient wc = WebClient.create(address, providers);
Flowable<HelloWorldBean> obs = wc.accept("application/json").rx(FlowableRxInvoker.class).get(HelloWorldBean.class);
final TestSubscriber<HelloWorldBean> subscriber = new TestSubscriber<>();
obs.subscribe(subscriber);
subscriber.await(3, TimeUnit.SECONDS);
subscriber.assertResult(new HelloWorldBean("Hello", "World"));
}
use of org.apache.cxf.jaxrs.rx3.client.FlowableRxInvokerProvider in project cxf by apache.
the class JAXRSRxJava2FlowableTest method testFlowableErrorWithWebException.
@Test
public void testFlowableErrorWithWebException() throws Exception {
String address = "http://localhost:" + PORT + "/rx22/flowable/web/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);
// The response should not include the exception payload (injected by exception mapper)
// if some elements have been emitted before
subscriber.await(3, TimeUnit.SECONDS);
subscriber.assertValue(r -> r.getStatus() == 403 && !r.readEntity(String.class).contains("stackTrace")).assertComplete();
}
use of org.apache.cxf.jaxrs.rx3.client.FlowableRxInvokerProvider in project cxf by apache.
the class JAXRSRxJava3FlowableTest method testGetHelloWorldEmpty.
@Test
public void testGetHelloWorldEmpty() throws Exception {
String address = "http://localhost:" + PORT + "/rx3/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.rx3.client.FlowableRxInvokerProvider in project cxf by apache.
the class JAXRSRxJava3FlowableTest method testGetHelloWorldJson.
@Test
public void testGetHelloWorldJson() throws Exception {
String address = "http://localhost:" + PORT + "/rx3/flowable/textJson";
List<Object> providers = new LinkedList<>();
providers.add(new JacksonJsonProvider());
providers.add(new FlowableRxInvokerProvider());
WebClient wc = WebClient.create(address, providers);
Flowable<HelloWorldBean> obs = wc.accept("application/json").rx(FlowableRxInvoker.class).get(HelloWorldBean.class);
final TestSubscriber<HelloWorldBean> subscriber = new TestSubscriber<>();
obs.subscribe(subscriber);
subscriber.await(3, TimeUnit.SECONDS);
subscriber.assertResult(new HelloWorldBean("Hello", "World"));
}
Aggregations