Search in sources :

Example 21 with FlowableRxInvokerProvider

use of org.apache.cxf.jaxrs.rx2.client.FlowableRxInvokerProvider 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();
}
Also used : Response(javax.ws.rs.core.Response) FlowableRxInvokerProvider(org.apache.cxf.jaxrs.rx2.client.FlowableRxInvokerProvider) BeforeClass(org.junit.BeforeClass) 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) ClientBuilder(javax.ws.rs.client.ClientBuilder) AbstractResourceInfo(org.apache.cxf.jaxrs.model.AbstractResourceInfo) MediaType(javax.ws.rs.core.MediaType) Response(javax.ws.rs.core.Response) Flowable(io.reactivex.Flowable) AbstractBusClientServerTestBase(org.apache.cxf.testutil.common.AbstractBusClientServerTestBase) FlowableRxInvoker(org.apache.cxf.jaxrs.rx2.client.FlowableRxInvoker) TestSubscriber(io.reactivex.subscribers.TestSubscriber) FlowableRxInvokerProvider(org.apache.cxf.jaxrs.rx2.client.FlowableRxInvokerProvider) JacksonJsonProvider(com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider) FlowableRxInvoker(org.apache.cxf.jaxrs.rx2.client.FlowableRxInvoker) TestSubscriber(io.reactivex.subscribers.TestSubscriber) Test(org.junit.Test)

Example 22 with FlowableRxInvokerProvider

use of org.apache.cxf.jaxrs.rx2.client.FlowableRxInvokerProvider 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();
}
Also used : FlowableRxInvokerProvider(org.apache.cxf.jaxrs.rx2.client.FlowableRxInvokerProvider) BeforeClass(org.junit.BeforeClass) 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) ClientBuilder(javax.ws.rs.client.ClientBuilder) AbstractResourceInfo(org.apache.cxf.jaxrs.model.AbstractResourceInfo) MediaType(javax.ws.rs.core.MediaType) Response(javax.ws.rs.core.Response) Flowable(io.reactivex.Flowable) AbstractBusClientServerTestBase(org.apache.cxf.testutil.common.AbstractBusClientServerTestBase) FlowableRxInvoker(org.apache.cxf.jaxrs.rx2.client.FlowableRxInvoker) TestSubscriber(io.reactivex.subscribers.TestSubscriber) FlowableRxInvokerProvider(org.apache.cxf.jaxrs.rx2.client.FlowableRxInvokerProvider) JacksonJsonProvider(com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider) FlowableRxInvoker(org.apache.cxf.jaxrs.rx2.client.FlowableRxInvoker) TestSubscriber(io.reactivex.subscribers.TestSubscriber) Test(org.junit.Test)

Example 23 with FlowableRxInvokerProvider

use of org.apache.cxf.jaxrs.rx2.client.FlowableRxInvokerProvider 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();
}
Also used : FlowableRxInvokerProvider(org.apache.cxf.jaxrs.rx2.client.FlowableRxInvokerProvider) BeforeClass(org.junit.BeforeClass) 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) ClientBuilder(javax.ws.rs.client.ClientBuilder) AbstractResourceInfo(org.apache.cxf.jaxrs.model.AbstractResourceInfo) MediaType(javax.ws.rs.core.MediaType) Flowable(io.reactivex.Flowable) AbstractBusClientServerTestBase(org.apache.cxf.testutil.common.AbstractBusClientServerTestBase) FlowableRxInvoker(org.apache.cxf.jaxrs.rx2.client.FlowableRxInvoker) TestSubscriber(io.reactivex.subscribers.TestSubscriber) FlowableRxInvokerProvider(org.apache.cxf.jaxrs.rx2.client.FlowableRxInvokerProvider) FlowableRxInvoker(org.apache.cxf.jaxrs.rx2.client.FlowableRxInvoker) TestSubscriber(io.reactivex.subscribers.TestSubscriber) Test(org.junit.Test)

Example 24 with FlowableRxInvokerProvider

use of org.apache.cxf.jaxrs.rx2.client.FlowableRxInvokerProvider in project cxf by apache.

the class JAXRSRxJava2SingleTest method testGetError.

@Test
public void testGetError() throws Exception {
    String address = "http://localhost:" + PORT + "/rx2/single/error";
    final Flowable<String> obs = ClientBuilder.newClient().register(new FlowableRxInvokerProvider()).target(address).request(MediaType.APPLICATION_JSON).rx(FlowableRxInvoker.class).get(String.class);
    final TestSubscriber<String> subscriber = new TestSubscriber<>();
    obs.subscribe(subscriber);
    subscriber.await(3, TimeUnit.SECONDS);
    subscriber.assertError(InternalServerErrorException.class);
}
Also used : FlowableRxInvokerProvider(org.apache.cxf.jaxrs.rx2.client.FlowableRxInvokerProvider) FlowableRxInvoker(org.apache.cxf.jaxrs.rx2.client.FlowableRxInvoker) TestSubscriber(io.reactivex.subscribers.TestSubscriber) Test(org.junit.Test)

Example 25 with FlowableRxInvokerProvider

use of org.apache.cxf.jaxrs.rx2.client.FlowableRxInvokerProvider in project cxf by apache.

the class JAXRSRxJava3MaybeTest method testGetHelloWorldEmpty.

@Test
public void testGetHelloWorldEmpty() throws Exception {
    String address = "http://localhost:" + PORT + "/rx3/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();
}
Also used : Response(javax.ws.rs.core.Response) Flowable(io.reactivex.rxjava3.core.Flowable) BeforeClass(org.junit.BeforeClass) FlowableRxInvoker(org.apache.cxf.jaxrs.rx3.client.FlowableRxInvoker) FlowableRxInvokerProvider(org.apache.cxf.jaxrs.rx3.client.FlowableRxInvokerProvider) Assert.assertTrue(org.junit.Assert.assertTrue) InternalServerErrorException(javax.ws.rs.InternalServerErrorException) TestSubscriber(io.reactivex.rxjava3.subscribers.TestSubscriber) Test(org.junit.Test) JacksonJsonProvider(com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider) TimeUnit(java.util.concurrent.TimeUnit) ClientBuilder(javax.ws.rs.client.ClientBuilder) AbstractResourceInfo(org.apache.cxf.jaxrs.model.AbstractResourceInfo) MediaType(javax.ws.rs.core.MediaType) Response(javax.ws.rs.core.Response) AbstractBusClientServerTestBase(org.apache.cxf.testutil.common.AbstractBusClientServerTestBase) FlowableRxInvokerProvider(org.apache.cxf.jaxrs.rx3.client.FlowableRxInvokerProvider) JacksonJsonProvider(com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider) FlowableRxInvoker(org.apache.cxf.jaxrs.rx3.client.FlowableRxInvoker) TestSubscriber(io.reactivex.rxjava3.subscribers.TestSubscriber) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)36 JacksonJsonProvider (com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider)30 TimeUnit (java.util.concurrent.TimeUnit)26 InternalServerErrorException (javax.ws.rs.InternalServerErrorException)26 ClientBuilder (javax.ws.rs.client.ClientBuilder)26 MediaType (javax.ws.rs.core.MediaType)26 AbstractResourceInfo (org.apache.cxf.jaxrs.model.AbstractResourceInfo)26 AbstractBusClientServerTestBase (org.apache.cxf.testutil.common.AbstractBusClientServerTestBase)26 Assert.assertTrue (org.junit.Assert.assertTrue)26 BeforeClass (org.junit.BeforeClass)26 Response (javax.ws.rs.core.Response)22 TestSubscriber (io.reactivex.rxjava3.subscribers.TestSubscriber)18 TestSubscriber (io.reactivex.subscribers.TestSubscriber)18 LinkedList (java.util.LinkedList)18 Invocation (javax.ws.rs.client.Invocation)18 WebClient (org.apache.cxf.jaxrs.client.WebClient)18 FlowableRxInvokerProvider (org.apache.cxf.jaxrs.rx2.client.FlowableRxInvokerProvider)18 FlowableRxInvokerProvider (org.apache.cxf.jaxrs.rx3.client.FlowableRxInvokerProvider)18 FlowableRxInvoker (org.apache.cxf.jaxrs.rx2.client.FlowableRxInvoker)17 FlowableRxInvoker (org.apache.cxf.jaxrs.rx3.client.FlowableRxInvoker)17