Package netflix.karyon.transport.http

Examples of netflix.karyon.transport.http.HttpKeyEvaluationContext


    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);
        request = newRequest("/x/y/z");
        keyApplicable = key.apply(request, context2);
        Assert.assertFalse("Query decoder cache not cleared..", keyApplicable);
    }
View Full Code Here

TOP

Related Classes of netflix.karyon.transport.http.HttpKeyEvaluationContext

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.