Search in sources :

Example 1 with SubscriberHolder

use of org.jocean.idiom.rx.SubscriberHolder in project jocean-http by isdom.

the class DefaultHttpTradeTestCase method testTradeForReadyOutboundResponseAfterResponseOnNext.

@Test
public final void testTradeForReadyOutboundResponseAfterResponseOnNext() {
    final HttpTrade trade = new DefaultHttpTrade(new EmbeddedChannel());
    assertTrue(trade.isActive());
    final SubscriberHolder<HttpObject> subsholder1 = new SubscriberHolder<>();
    final Subscription subscription1 = trade.outbound(Observable.unsafeCreate(subsholder1));
    assertNotNull(subscription1);
    final DefaultHttpRequest req1 = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "/");
    Nettys4Test.emitHttpObjects(subsholder1.getAt(0), req1);
}
Also used : HttpTrade(org.jocean.http.server.HttpServerBuilder.HttpTrade) HttpObject(io.netty.handler.codec.http.HttpObject) DefaultHttpRequest(io.netty.handler.codec.http.DefaultHttpRequest) EmbeddedChannel(io.netty.channel.embedded.EmbeddedChannel) Subscription(rx.Subscription) SubscriberHolder(org.jocean.idiom.rx.SubscriberHolder) Nettys4Test(org.jocean.http.util.Nettys4Test) Test(org.junit.Test)

Example 2 with SubscriberHolder

use of org.jocean.idiom.rx.SubscriberHolder in project jocean-http by isdom.

the class DefaultHttpTradeTestCase method testTradeForResponseAfterAbort.

@Test
public final void testTradeForResponseAfterAbort() {
    final HttpTrade trade = new DefaultHttpTrade(new EmbeddedChannel());
    trade.close();
    assertFalse(trade.isActive());
    final SubscriberHolder<HttpObject> subsholder = new SubscriberHolder<>();
    final Subscription subscription = trade.outbound(Observable.unsafeCreate(subsholder));
    assertNull(subscription);
    assertEquals(0, subsholder.getSubscriberCount());
}
Also used : HttpTrade(org.jocean.http.server.HttpServerBuilder.HttpTrade) HttpObject(io.netty.handler.codec.http.HttpObject) EmbeddedChannel(io.netty.channel.embedded.EmbeddedChannel) Subscription(rx.Subscription) SubscriberHolder(org.jocean.idiom.rx.SubscriberHolder) Nettys4Test(org.jocean.http.util.Nettys4Test) Test(org.junit.Test)

Example 3 with SubscriberHolder

use of org.jocean.idiom.rx.SubscriberHolder in project jocean-http by isdom.

the class DefaultHttpTradeTestCase method testTradeForReadyOutboundResponseAfterResponseOnCompleted.

@Test
public final void testTradeForReadyOutboundResponseAfterResponseOnCompleted() {
    final HttpTrade trade = new DefaultHttpTrade(new EmbeddedChannel());
    assertTrue(trade.isActive());
    final SubscriberHolder<HttpObject> subsholder1 = new SubscriberHolder<>();
    final Subscription subscription1 = trade.outbound(Observable.unsafeCreate(subsholder1));
    assertNotNull(subscription1);
    subsholder1.getAt(0).onCompleted();
}
Also used : HttpTrade(org.jocean.http.server.HttpServerBuilder.HttpTrade) HttpObject(io.netty.handler.codec.http.HttpObject) EmbeddedChannel(io.netty.channel.embedded.EmbeddedChannel) Subscription(rx.Subscription) SubscriberHolder(org.jocean.idiom.rx.SubscriberHolder) Nettys4Test(org.jocean.http.util.Nettys4Test) Test(org.junit.Test)

Aggregations

EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)3 HttpObject (io.netty.handler.codec.http.HttpObject)3 HttpTrade (org.jocean.http.server.HttpServerBuilder.HttpTrade)3 Nettys4Test (org.jocean.http.util.Nettys4Test)3 SubscriberHolder (org.jocean.idiom.rx.SubscriberHolder)3 Test (org.junit.Test)3 Subscription (rx.Subscription)3 DefaultHttpRequest (io.netty.handler.codec.http.DefaultHttpRequest)1