Package io.netty.channel.embedded

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


        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;
    }

    private static FullHttpResponse xhrSendRequest(final String path,
                                                   final String content,
View Full Code Here


                if (out instanceof FullHttpResponse) {
                    return (FullHttpResponse) out;
                }
            }
        } finally {
            ch.finish();
        }
        throw new IllegalStateException("No outbound FullHttpResponse was written");
    }

    private static FullHttpResponse xhrRequest(final String url, final SockJsServiceFactory service) {
View Full Code Here

        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;
    }

    private static FullHttpResponse infoRequest(final String url, final SockJsServiceFactory service) {
        final EmbeddedChannel ch = channelForService(service);
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;
    }

    private static HttpResponse xhrRequest(final FullHttpRequest request, final SockJsServiceFactory service) {
        final EmbeddedChannel ch = channelForService(service);
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;
    }

    /*
     * This is needed as otherwise the pipeline chain will stop, and since we
View Full Code Here

        assertThat(headers.get(HttpHeaders.Names.ACCESS_CONTROL_ALLOW_METHODS), is("OPTIONS, GET"));
        assertThat(headers.get(HttpHeaders.Names.ACCESS_CONTROL_ALLOW_HEADERS), is("Content-Type"));
        assertThat(headers.get(HttpHeaders.Names.ACCESS_CONTROL_ALLOW_CREDENTIALS), is("true"));
        assertThat(headers.get(HttpHeaders.Names.EXPIRES), is("dummy"));
        assertThat(headers.get(HttpHeaders.Names.SET_COOKIE), is("JSESSIONID=dummy;path=/"));
        channel.finish();
    }

    @Test
    public void verifyChannelAttributesNotPreflightRequestDefaults() {
        final FullHttpRequest httpRequest = createHttpRequest(HttpMethod.GET);
View Full Code Here

        channel.writeInbound(httpRequest);
        final CorsMetadata corsMetadata = channel.attr(CorsInboundHandler.CORS).get();
        assertThat(corsMetadata.origin(), is("*"));
        assertThat(corsMetadata.hasHeaders(), is(false));
        assertThat((FullHttpRequest) channel.readInbound(), equalTo(httpRequest));
        channel.finish();
    }

    @Test
    public void verifyChannelAttributesNotPreflightRequest() {
        final HttpRequest httpRequest = createHttpRequest(HttpMethod.GET);
View Full Code Here

        channel.writeInbound(httpRequest);
        final CorsMetadata corsMetadata = channel.attr(CorsInboundHandler.CORS).get();
        assertThat(corsMetadata.origin(), is("example.se"));
        assertThat(corsMetadata.headers(), is("content-type"));
        assertThat((HttpRequest) channel.readInbound(), equalTo(httpRequest));
        channel.finish();
    }

    private static FullHttpRequest createHttpRequest(HttpMethod method) {
        return new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, method, "/info");
    }
View Full Code Here

        final HttpResponse response = channel.readOutbound();
        assertThat(response.getProtocolVersion(), equalTo(HttpVersion.HTTP_1_0));
        assertThat(response.headers().get(ACCESS_CONTROL_ALLOW_ORIGIN), equalTo("xyz.com"));
        assertThat(response.headers().get(ACCESS_CONTROL_ALLOW_CREDENTIALS), equalTo("true"));
        assertThat(response.headers().get(ACCESS_CONTROL_ALLOW_HEADERS), equalTo("content-type"));
        channel.finish();
    }

    @Test
    public void flushWithoutPriorOptionsRequest() {
        final EmbeddedChannel channel = new EmbeddedChannel(new CorsOutboundHandler());
View Full Code Here

        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"));
        assertThat(response.headers().get(ACCESS_CONTROL_ALLOW_HEADERS), is(nullValue()));
        channel.finish();
    }

}
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.