Examples of writeOutbound()


Examples of io.netty.channel.embedded.EmbeddedChannel.writeOutbound()

public class EventSourceTransportTest {

    @Test
    public void write() {
        final EmbeddedChannel ch = newEventSourceChannel();
        ch.writeOutbound(new OpenFrame());

        final HttpResponse response = ch.readOutbound();
        assertThat(response.getStatus(), equalTo(HttpResponseStatus.OK));
        assertThat(response.headers().get(CONTENT_TYPE), equalTo(EventSourceTransport.CONTENT_TYPE_EVENT_STREAM));
        SockJsTestUtil.verifyNoCacheHeaders(response);
View Full Code Here

Examples of io.netty.channel.embedded.EmbeddedChannel.writeOutbound()

    @Test
    public void write() throws IOException {
        final String url = "/test/htmlfile?c=%63allback";
        final EmbeddedChannel ch = newHtmlFileChannel("/test/htmlfile?c=%63allback");
        ch.writeInbound(new DefaultHttpRequest(HTTP_1_1, GET, url));
        ch.writeOutbound(new OpenFrame());

        final HttpResponse response = ch.readOutbound();
        assertThat(response.getStatus(), equalTo(OK));
        assertThat(response.headers().get(CONTENT_TYPE), equalTo(Transports.CONTENT_TYPE_HTML));
        verifyNoCacheHeaders(response);
View Full Code Here

Examples of io.netty.channel.embedded.EmbeddedChannel.writeOutbound()

    @Test
    public void flush() {
        final SockJsConfig config = SockJsConfig.withPrefix("/test").cookiesNeeded().build();
        final XhrPollingTransport transport = new XhrPollingTransport(config, request("", HttpVersion.HTTP_1_1));
        final EmbeddedChannel channel = new EmbeddedChannel(transport);
        channel.writeOutbound(new OpenFrame());
        final FullHttpResponse response = channel.readOutbound();
        assertThat(response.getStatus(), equalTo(HttpResponseStatus.OK));
        assertThat(response.content().toString(CharsetUtil.UTF_8), equalTo("o" + '\n'));
        assertThat(response.getProtocolVersion(), equalTo(HttpVersion.HTTP_1_1));
        SockJsTestUtil.verifyDefaultResponseHeaders(response, Transports.CONTENT_TYPE_JAVASCRIPT);
View Full Code Here

Examples of io.netty.channel.embedded.EmbeddedChannel.writeOutbound()

    private static final int PRELUDE_SIZE = 2048 + 1;

    @Test
    public void messageReceived() {
        final EmbeddedChannel ch = newStreamingChannel();
        ch.writeOutbound(new OpenFrame());

        final HttpResponse response = ch.readOutbound();
        assertThat(response.getStatus(), equalTo(HttpResponseStatus.OK));
        assertThat(response.headers().get(CONTENT_TYPE), equalTo(Transports.CONTENT_TYPE_JAVASCRIPT));
        assertThat(response.headers().get(TRANSFER_ENCODING), equalTo(CHUNKED.toString()));
View Full Code Here

Examples of io.netty.channel.embedded.EmbeddedChannel.writeOutbound()

public class WebSocketSendHandlerTest {

    @Test
    public void messageReceived() throws Exception {
        final EmbeddedChannel ch = createWebsocketChannel(SockJsConfig.withPrefix("/echo").build());
        ch.writeOutbound(new MessageFrame("testing"));
        final TextWebSocketFrame textFrame = ch.readOutbound();
        assertThat(textFrame.content().toString(CharsetUtil.UTF_8), equalTo("a[\"testing\"]"));
        textFrame.release();
    }
View Full Code Here

Examples of io.netty.channel.embedded.EmbeddedChannel.writeOutbound()

        final DefaultFullHttpRequest request = new DefaultFullHttpRequest(HTTP_1_1, GET, queryUrl);
        final SockJsConfig config = SockJsConfig.withPrefix(queryUrl).cookiesNeeded().build();
        final JsonpPollingTransport jsonpPollingOutbound = new JsonpPollingTransport(config, request);
        final EmbeddedChannel ch = new EmbeddedChannel(jsonpPollingOutbound);
        ch.writeInbound(request);
        ch.writeOutbound(frame);
        final FullHttpResponse response =  ch.readOutbound();
        ch.finish();
        return response;
    }
View Full Code Here

Examples of io.netty.channel.embedded.EmbeddedChannel.writeOutbound()

        env.setBuffer(buffer);

        expectedEncodedMsgSize += bufferSize;
      }

      Assert.assertTrue(channel.writeOutbound(env));

      // --------------------------------------------------------------------
      // verify encoded ByteBuf size
      // --------------------------------------------------------------------
      ByteBuf encodedMsg = (ByteBuf) channel.readOutbound();
View Full Code Here

Examples of io.netty.channel.embedded.EmbeddedChannel.writeOutbound()

    @Test
    public void flush() {
        final EmbeddedChannel channel = new EmbeddedChannel(new CorsOutboundHandler());
        channel.attr(CorsInboundHandler.CORS).set(new CorsMetadata("xyz.com", "content-type"));
        boolean write = channel.writeOutbound(new DefaultFullHttpResponse(HttpVersion.HTTP_1_0, HttpResponseStatus.OK));
        assertThat(write, is(true));

        final HttpResponse response = channel.readOutbound();
        assertThat(response.getProtocolVersion(), equalTo(HttpVersion.HTTP_1_0));
        assertThat(response.headers().get(ACCESS_CONTROL_ALLOW_ORIGIN), equalTo("xyz.com"));
View Full Code Here

Examples of io.netty.channel.embedded.EmbeddedChannel.writeOutbound()

    @Test
    public void flushWithoutPriorOptionsRequest() {
        final EmbeddedChannel channel = new EmbeddedChannel(new CorsOutboundHandler());
        channel.attr(CorsInboundHandler.CORS).set(new CorsMetadata());
        channel.writeOutbound(new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK));

        final HttpResponse response = channel.readOutbound();
        assertThat(response.getProtocolVersion(), equalTo(HttpVersion.HTTP_1_1));
        assertThat(response.headers().get(ACCESS_CONTROL_ALLOW_ORIGIN), equalTo("*"));
        assertThat(response.headers().get(ACCESS_CONTROL_ALLOW_CREDENTIALS), equalTo("true"));
View Full Code Here

Examples of io.netty.channel.embedded.EmbeddedChannel.writeOutbound()

    public void greetingThroughDecoder() throws Exception {
        final EmbeddedChannel ch = new EmbeddedChannel(new HttpResponseEncoder());
        final FullHttpResponse response = sendGreetingRequest();
        assertWelcomeMessage(response);
        // send response through HttpResponseEncoder
        ch.writeOutbound(response);
        final FullHttpResponse response2 = sendGreetingRequest();
        assertWelcomeMessage(response2);
    }

    private FullHttpResponse sendGreetingRequest() {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.