Search in sources :

Example 6 with ObservableRxInvokerProvider

use of org.apache.cxf.jaxrs.rx3.client.ObservableRxInvokerProvider in project cxf by apache.

the class JAXRSRxJava3ObservableTest method testObservableImmediateErrors.

@Test
public void testObservableImmediateErrors() throws Exception {
    String address = "http://localhost:" + PORT + "/rx3/observable/immediate/errors";
    final Observable<HelloWorldBean> obs = ClientBuilder.newClient().register(new JacksonJsonProvider()).register(new ObservableRxInvokerProvider()).target(address).request(MediaType.APPLICATION_JSON).rx(ObservableRxInvoker.class).get(HelloWorldBean.class);
    final TestObserver<HelloWorldBean> subscriber = new TestObserver<>();
    obs.subscribe(subscriber);
    subscriber.await(3, TimeUnit.SECONDS);
    subscriber.assertError(InternalServerErrorException.class);
}
Also used : ObservableRxInvokerProvider(org.apache.cxf.jaxrs.rx3.client.ObservableRxInvokerProvider) JacksonJsonProvider(com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider) ObservableRxInvoker(org.apache.cxf.jaxrs.rx3.client.ObservableRxInvoker) TestObserver(io.reactivex.rxjava3.observers.TestObserver) Test(org.junit.Test)

Example 7 with ObservableRxInvokerProvider

use of org.apache.cxf.jaxrs.rx3.client.ObservableRxInvokerProvider in project cxf by apache.

the class JAXRSRxJava2ObservableTest method testObservableImmediateErrors.

@Test
public void testObservableImmediateErrors() throws Exception {
    String address = "http://localhost:" + PORT + "/rx2/observable/immediate/errors";
    final Observable<HelloWorldBean> obs = ClientBuilder.newClient().register(new JacksonJsonProvider()).register(new ObservableRxInvokerProvider()).target(address).request(MediaType.APPLICATION_JSON).rx(ObservableRxInvoker.class).get(HelloWorldBean.class);
    final TestObserver<HelloWorldBean> subscriber = new TestObserver<>();
    obs.subscribe(subscriber);
    subscriber.await(3, TimeUnit.SECONDS);
    subscriber.assertError(InternalServerErrorException.class);
}
Also used : ObservableRxInvokerProvider(org.apache.cxf.jaxrs.rx2.client.ObservableRxInvokerProvider) JacksonJsonProvider(com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider) ObservableRxInvoker(org.apache.cxf.jaxrs.rx2.client.ObservableRxInvoker) TestObserver(io.reactivex.observers.TestObserver) Test(org.junit.Test)

Example 8 with ObservableRxInvokerProvider

use of org.apache.cxf.jaxrs.rx3.client.ObservableRxInvokerProvider in project cxf by apache.

the class JAXRSRxJava3ObservableTest method testGetHelloWorldEmpty.

@Test
public void testGetHelloWorldEmpty() throws Exception {
    String address = "http://localhost:" + PORT + "/rx3/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();
}
Also used : Response(javax.ws.rs.core.Response) BeforeClass(org.junit.BeforeClass) WebClient(org.apache.cxf.jaxrs.client.WebClient) Assert.assertTrue(org.junit.Assert.assertTrue) InternalServerErrorException(javax.ws.rs.InternalServerErrorException) Test(org.junit.Test) JacksonJsonProvider(com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider) TimeUnit(java.util.concurrent.TimeUnit) GenericType(javax.ws.rs.core.GenericType) ClientBuilder(javax.ws.rs.client.ClientBuilder) AbstractResourceInfo(org.apache.cxf.jaxrs.model.AbstractResourceInfo) ObservableRxInvokerProvider(org.apache.cxf.jaxrs.rx3.client.ObservableRxInvokerProvider) List(java.util.List) MediaType(javax.ws.rs.core.MediaType) ObservableRxInvoker(org.apache.cxf.jaxrs.rx3.client.ObservableRxInvoker) Response(javax.ws.rs.core.Response) TestObserver(io.reactivex.rxjava3.observers.TestObserver) Observable(io.reactivex.rxjava3.core.Observable) AbstractBusClientServerTestBase(org.apache.cxf.testutil.common.AbstractBusClientServerTestBase) Disposable(io.reactivex.rxjava3.disposables.Disposable) Holder(javax.xml.ws.Holder) LinkedList(java.util.LinkedList) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) ObservableRxInvokerProvider(org.apache.cxf.jaxrs.rx3.client.ObservableRxInvokerProvider) JacksonJsonProvider(com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider) ObservableRxInvoker(org.apache.cxf.jaxrs.rx3.client.ObservableRxInvoker) TestObserver(io.reactivex.rxjava3.observers.TestObserver) Test(org.junit.Test)

Aggregations

JacksonJsonProvider (com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider)8 Test (org.junit.Test)8 LinkedList (java.util.LinkedList)6 Holder (javax.xml.ws.Holder)6 WebClient (org.apache.cxf.jaxrs.client.WebClient)6 Collections (java.util.Collections)4 List (java.util.List)4 TimeUnit (java.util.concurrent.TimeUnit)4 InternalServerErrorException (javax.ws.rs.InternalServerErrorException)4 ClientBuilder (javax.ws.rs.client.ClientBuilder)4 GenericType (javax.ws.rs.core.GenericType)4 MediaType (javax.ws.rs.core.MediaType)4 Response (javax.ws.rs.core.Response)4 AbstractResourceInfo (org.apache.cxf.jaxrs.model.AbstractResourceInfo)4 ObservableRxInvoker (org.apache.cxf.jaxrs.rx2.client.ObservableRxInvoker)4 ObservableRxInvokerProvider (org.apache.cxf.jaxrs.rx2.client.ObservableRxInvokerProvider)4 ObservableRxInvoker (org.apache.cxf.jaxrs.rx3.client.ObservableRxInvoker)4 ObservableRxInvokerProvider (org.apache.cxf.jaxrs.rx3.client.ObservableRxInvokerProvider)4 AbstractBusClientServerTestBase (org.apache.cxf.testutil.common.AbstractBusClientServerTestBase)4 Assert.assertEquals (org.junit.Assert.assertEquals)4