Package netflix.karyon.server

Examples of netflix.karyon.server.MockChannelHandlerContext


    }

    @Override
    public Observable<Void> in(ByteBuf request, ByteBuf response) {
        inCalled = true;
        MockChannelHandlerContext mock = new MockChannelHandlerContext("mock");
        wasLastInCallValid = filterKey.apply(request, new KeyEvaluationContext(mock.channel()));
        return Observable.empty();
    }
View Full Code Here


    }

    @Override
    public Observable<Void> out(ByteBuf response) {
        outCalled = true;
        wasLastOutCallValid = filterKey.apply(response, new KeyEvaluationContext(new MockChannelHandlerContext("").channel()));
        return Observable.empty();
    }
View Full Code Here

        return receivedACall;
    }

    @Override
    public Observable<Void> in(ByteBuf request, ByteBuf response) {
        MockChannelHandlerContext context = new MockChannelHandlerContext("mock");
        wasLastCallValid = filterKey.apply(request, new KeyEvaluationContext(context.channel()));
        receivedACall = true;
        return Observable.empty();
    }
View Full Code Here

    protected static boolean doApply(InterceptorKey<HttpServerRequest<ByteBuf>, HttpKeyEvaluationContext> key, String uri,
                                     HttpMethod httpMethod) {
        DefaultHttpRequest nettyRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_0, httpMethod, uri);
        return key.apply(new HttpServerRequest<ByteBuf>(nettyRequest,
                                                        UnicastContentSubject.<ByteBuf>createWithoutNoSubscriptionTimeout()),
                         new HttpKeyEvaluationContext(new MockChannelHandlerContext("mock").channel()));
    }
View Full Code Here

public class ServletStyleConstraintTest extends InterceptorConstraintTestBase {

    @Test
    public void testServletPathExactMatch() throws Exception {
        ServletStyleUriConstraintKey<ByteBuf> key = new ServletStyleUriConstraintKey<>("d/a/b/c", "d");
        HttpKeyEvaluationContext context = new HttpKeyEvaluationContext(new MockChannelHandlerContext("mock").channel());
        HttpServerRequest<ByteBuf> request = newRequest("/d/a/b/c/");
        boolean keyApplicable = key.apply(request, context);
        Assert.assertTrue("Exact match servlet style constraint failed.", keyApplicable);
        String servletPath = key.getServletPath(request, context);
        Assert.assertEquals("Unexpected servlet path.", "/a/b/c/", servletPath);
View Full Code Here

    }

    @Test
    public void testServletPathPrefixMatch() throws Exception {
        ServletStyleUriConstraintKey<ByteBuf> key = new ServletStyleUriConstraintKey<>("d/a/*", "d");
        HttpKeyEvaluationContext context = new HttpKeyEvaluationContext(new MockChannelHandlerContext("mock").channel());
        HttpServerRequest<ByteBuf> request = newRequest("/d/a/b/c/");
        boolean keyApplicable = key.apply(request, context);
        Assert.assertTrue("Prefix match servlet style constraint failed.", keyApplicable);
        String servletPath = key.getServletPath(request, context);
        Assert.assertEquals("Unexpected servlet path.", "/a", servletPath);
View Full Code Here

    }

    @Test
    public void testServletPathExtensionMatch() throws Exception {
        ServletStyleUriConstraintKey<ByteBuf> key = new ServletStyleUriConstraintKey<>("*.boo", "d");
        HttpKeyEvaluationContext context = new HttpKeyEvaluationContext(new MockChannelHandlerContext("mock").channel());
        HttpServerRequest<ByteBuf> request = newRequest("/d/a/b/c.boo");
        boolean keyApplicable = key.apply(request, context);
        Assert.assertTrue("Extension match servlet style constraint failed.", keyApplicable);
        String servletPath = key.getServletPath(request, context);
        Assert.assertEquals("Unexpected servlet path.", "", servletPath);
View Full Code Here

    }

    @Test
    public void testQueryDecoderCache() throws Exception {
        ServletStyleUriConstraintKey<ByteBuf> key = new ServletStyleUriConstraintKey<>("d/a/b/c", "d");
        Channel mockChannel = new MockChannelHandlerContext("mock").channel();
        HttpKeyEvaluationContext context = new HttpKeyEvaluationContext(mockChannel);
        HttpServerRequest<ByteBuf> request = newRequest("/d/a/b/c/");
        boolean keyApplicable = key.apply(request, context);
        Assert.assertTrue("Exact match servlet style constraint failed.", keyApplicable);
        HttpKeyEvaluationContext context2 = new HttpKeyEvaluationContext(mockChannel);
View Full Code Here

    protected void executeAndAwait(InterceptorExecutor<ByteBuf, ByteBuf, KeyEvaluationContext> executor)
            throws InterruptedException {
        final CountDownLatch completionLatch = new CountDownLatch(1);

        executor.execute(Unpooled.buffer(), Unpooled.buffer(),
                         new KeyEvaluationContext(new MockChannelHandlerContext("mock").channel()))
                .doOnCompleted(new Action0() {
                    @Override
                    public void call() {
                        completionLatch.countDown();
                    }
View Full Code Here

TOP

Related Classes of netflix.karyon.server.MockChannelHandlerContext

Copyright © 2018 www.massapicom. 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.