Package io.netty.channel.embedded

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


        removeLastInboundMessageHandlers(ch);
        final FullHttpRequest sendRequest = httpRequest(path + "/xhr_send", POST);
        final ByteBuf byteBuf = Unpooled.copiedBuffer(content, UTF_8);
        sendRequest.content().writeBytes(byteBuf);
        byteBuf.release();
        ch.writeInbound(sendRequest);
        final FullHttpResponse response = ch.readOutbound();
        ch.finish();
        return response;
    }
View Full Code Here


        final FullHttpRequest request = httpRequest(path + Transports.Type.XHR_SEND.path(), POST);
        request.headers().set(CONTENT_TYPE, contentType);
        final ByteBuf byteBuf = Unpooled.copiedBuffer(content, UTF_8);
        request.content().writeBytes(byteBuf);
        byteBuf.release();
        ch.writeInbound(request);
        Object out;
        try {
            while ((out = ch.readOutbound()) != null) {
                if (out instanceof FullHttpResponse) {
                    return (FullHttpResponse) out;
View Full Code Here

    private static FullHttpResponse xhrRequest(final String url, final SockJsServiceFactory service) {
        final EmbeddedChannel ch = channelForService(service);
        removeLastInboundMessageHandlers(ch);
        final FullHttpRequest request = httpRequest(url + Transports.Type.XHR.path(), GET);
        ch.writeInbound(request);
        final FullHttpResponse response = ch.readOutbound();
        ch.finish();
        return response;
    }
View Full Code Here

    }

    private static FullHttpResponse infoRequest(final String url, final SockJsServiceFactory service) {
        final EmbeddedChannel ch = channelForService(service);
        final FullHttpRequest request = httpRequest(url + "/info", GET);
        ch.writeInbound(request);
        final FullHttpResponse response = ch.readOutbound();
        ch.finish();
        return response;
    }
View Full Code Here

    }

    private static HttpResponse xhrRequest(final FullHttpRequest request, final SockJsServiceFactory service) {
        final EmbeddedChannel ch = channelForService(service);
        removeLastInboundMessageHandlers(ch);
        ch.writeInbound(request);
        final HttpResponse response = ch.readOutbound();
        ch.finish();
        return response;
    }
View Full Code Here

    private static void assertOKResponse(final String sessionPart) {
        final SockJsConfig config = SockJsConfig.withPrefix("/echo").cookiesNeeded().build();
        final EmbeddedChannel ch = channelForMockService(config);
        removeLastInboundMessageHandlers(ch);
        ch.writeInbound(httpRequest("/echo" + sessionPart + Transports.Type.XHR.path()));
        final FullHttpResponse response = ch.readOutbound();
        assertThat(response.getStatus(), is(HttpResponseStatus.OK));
        assertThat(response.content().toString(UTF_8), equalTo("o\n"));
    }
View Full Code Here

    }

    private static void verifyIframe(final String service, final String path) {
        final SockJsConfig config = SockJsConfig.withPrefix(service).cookiesNeeded().build();
        final EmbeddedChannel ch = channelForMockService(config);
        ch.writeInbound(httpRequest(config.prefix() + path));
        final FullHttpResponse response = ch.readOutbound();
        assertThat(response.getStatus().code(), is(HttpResponseStatus.OK.code()));
        assertThat(response.headers().get(CONTENT_TYPE), equalTo("text/html; charset=UTF-8"));
        assertThat(response.headers().get(CACHE_CONTROL), equalTo("max-age=31536000, public"));
        assertThat(response.headers().get(EXPIRES), is(notNullValue()));
View Full Code Here

    }

    private static void assertNotFoundResponse(final String service, final String path) {
        final SockJsConfig config = SockJsConfig.withPrefix(service).cookiesNeeded().build();
        final EmbeddedChannel ch = channelForMockService(config);
        ch.writeInbound(httpRequest('/' + service + path));
        final FullHttpResponse response = ch.readOutbound();
        assertThat(response.getStatus(), is(HttpResponseStatus.NOT_FOUND));
    }

    private static String getEtag(final FullHttpResponse response) {
View Full Code Here

        return ch;
    }

    private static FullHttpResponse infoForMockService(final SockJsServiceFactory factory) {
        final EmbeddedChannel ch = channelForMockService(factory.config());
        ch.writeInbound(httpRequest(factory.config().prefix() + "/info"));
        final FullHttpResponse response = ch.readOutbound();
        ch.close();
        return response;
    }
View Full Code Here

    private HttpUtil() {
    }

    public static HttpResponse decode(final EmbeddedChannel channel) throws Exception {
        final EmbeddedChannel ch = new EmbeddedChannel(new HttpObjectAggregator(8192), new HttpResponseDecoder());
        ch.writeInbound(channel.readOutbound());
        return (HttpResponse) ch.readInbound();
    }

    public static FullHttpResponse decodeFullResponse(final EmbeddedChannel channel) throws Exception {
        final HttpResponse response = decode(channel);
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.