Package io.apigee.trireme.net

Examples of io.apigee.trireme.net.HTTPParsingMachine$Result


        DefaultActionMapper defaultActionMapper = new DefaultActionMapper();
        defaultActionMapper.setContainer(container);
        ActionMapping actionMapping = defaultActionMapper.getMapping(request, configManager);

        Result result = actionMapping.getResult();
        assertNull(result);
    }
View Full Code Here


        DefaultActionMapper defaultActionMapper = new DefaultActionMapper();
        defaultActionMapper.setContainer(container);
        ActionMapping actionMapping = defaultActionMapper.getMapping(request, configManager);

        Result result = actionMapping.getResult();
        assertNotNull(result);
        assertTrue(result instanceof ServletRedirectResult);

        Mock invMock = new Mock(ActionInvocation.class);
        ActionInvocation inv = (ActionInvocation) invMock.proxy();
        ActionContext ctx = ActionContext.getContext();
        ctx.put(ServletActionContext.HTTP_REQUEST, request);
        StrutsMockHttpServletResponse response = new StrutsMockHttpServletResponse();
        ctx.put(ServletActionContext.HTTP_RESPONSE, response);
        invMock.expectAndReturn("getInvocationContext", ctx);
        invMock.expectAndReturn("getStack", ctx.getValueStack());
        result.execute(inv);
        assertEquals("http://www.google.com", response.getRedirectURL());
        //TODO: need to test location but there's noaccess to the property/method, unless we use reflection
    }
View Full Code Here

        DefaultActionMapper defaultActionMapper = new DefaultActionMapper();
        defaultActionMapper.setContainer(container);
        ActionMapping actionMapping = defaultActionMapper.getMapping(request, configManager);
       

        Result result = actionMapping.getResult();
        assertNotNull(result);
        assertTrue(result instanceof ServletRedirectResult);

        // TODO: need to test location but there's noaccess to the property/method, unless we use reflection
    }
View Full Code Here

            proxy.setMethod(method);
            request.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, proxy.getInvocation().getStack());

            // if the ActionMapping says to go straight to a result, do it!
            if (mapping.getResult() != null) {
                Result result = mapping.getResult();
                result.execute(proxy.getInvocation());
            } else {
                proxy.execute();
            }

            // If there was a previous value stack then set it back onto the request
View Full Code Here

            if (savedInvocation != null) {
                // set the valuestack to the request scope
                ValueStack stack = savedInvocation.getStack();
                request.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, stack);

                Result result = savedInvocation.getResult();

                if ((result != null) && (savedInvocation.getProxy().getExecuteResult())) {
                    result.execute(savedInvocation);
                }

                // turn off execution of this invocations result
                invocation.getProxy().setExecuteResult(false);
View Full Code Here

            return CLASS_NAME;
        }

        private void init(int type)
        {
            parser = new HTTPParsingMachine(
                (type == REQUEST) ? HTTPParsingMachine.ParsingMode.REQUEST : HTTPParsingMachine.ParsingMode.RESPONSE);
        }
View Full Code Here

    @Test
    public void testCompleteRequestLengthSplit3()
    {
        ByteBuffer whole = Utils.stringToBuffer(COMPLETE_REQUEST_LENGTH, Charsets.ASCII);
        HTTPParsingMachine parser = new HTTPParsingMachine(HTTPParsingMachine.ParsingMode.REQUEST);

        // Split right down the middle of the request line
        ByteBuffer split = splitBuffer(whole, 26);
        HTTPParsingMachine.Result r = parser.parse(split);
        assertFalse(r.isError());
        assertFalse(r.isComplete());
        assertFalse(r.isHeadersComplete());

        // Process the rest of the message
        r = parser.parse(whole);
        assertFalse(r.isError());
        assertTrue(r.isComplete());
        assertTrue(r.isHeadersComplete());
        assertEquals("GET", r.getMethod());
        assertEquals("/foo/bar/baz", r.getUri());
        assertEquals("Myself", getFirstHeader(r, "User-Agent"));
        assertEquals("Hello, World!", Utils.bufferToString(r.getBody(), Charsets.ASCII));
        parser.parse(null);
    }
View Full Code Here

    @Test
    public void testCompleteRequestLengthSplit4()
    {
        ByteBuffer whole = Utils.stringToBuffer(COMPLETE_REQUEST_LENGTH, Charsets.ASCII);
        HTTPParsingMachine parser = new HTTPParsingMachine(HTTPParsingMachine.ParsingMode.REQUEST);

        // Split right down the middle of the request line
        ByteBuffer split = splitBuffer(whole, 27);
        HTTPParsingMachine.Result r = parser.parse(split);
        assertFalse(r.isError());
        assertFalse(r.isComplete());
        assertFalse(r.isHeadersComplete());

        // Process the rest of the message
        r = parser.parse(whole);
        assertFalse(r.isError());
        assertTrue(r.isComplete());
        assertTrue(r.isHeadersComplete());
        assertEquals("GET", r.getMethod());
        assertEquals("/foo/bar/baz", r.getUri());
        assertEquals("Myself", getFirstHeader(r, "User-Agent"));
        assertEquals("Hello, World!", Utils.bufferToString(r.getBody(), Charsets.ASCII));
        parser.parse(null);
    }
View Full Code Here

public class HTTPParserTest
{
    @Test
    public void testCompleteRequestLength()
    {
        HTTPParsingMachine parser = new HTTPParsingMachine(HTTPParsingMachine.ParsingMode.REQUEST);
        HTTPParsingMachine.Result r =
            parser.parse(Utils.stringToBuffer(COMPLETE_REQUEST_LENGTH, Charsets.ASCII));
        assertFalse(r.isError());
        assertTrue(r.isComplete());
        assertTrue(r.isHeadersComplete());
        assertTrue(r.hasHeaders());
        assertTrue(r.hasBody());
        assertEquals(1, r.getMajor());
        assertEquals(1, r.getMinor());
        assertEquals("GET", r.getMethod());
        assertEquals("/foo/bar/baz", r.getUri());
        assertEquals("Myself", getFirstHeader(r, "User-Agent"));
        assertEquals("Hello, World!", Utils.bufferToString(r.getBody(), Charsets.ASCII));
        parser.parse(null);
    }
View Full Code Here

    }

    @Test
    public void testCompleteRequestLengthBlankHeader()
    {
        HTTPParsingMachine parser = new HTTPParsingMachine(HTTPParsingMachine.ParsingMode.REQUEST);
        HTTPParsingMachine.Result r =
            parser.parse(Utils.stringToBuffer(COMPLETE_REQUEST_LENGTH_BLANK_HDR, Charsets.ASCII));
        assertFalse(r.isError());
        assertTrue(r.isComplete());
        assertTrue(r.isHeadersComplete());
        assertTrue(r.hasHeaders());
        assertTrue(r.hasBody());
        assertEquals(1, r.getMajor());
        assertEquals(1, r.getMinor());
        assertEquals("GET", r.getMethod());
        assertEquals("/foo/bar/baz", r.getUri());
        assertEquals("", getFirstHeader(r, "User-Agent"));
        assertEquals("Hello, World!", Utils.bufferToString(r.getBody(), Charsets.ASCII));
        parser.parse(null);
    }
View Full Code Here

TOP

Related Classes of io.apigee.trireme.net.HTTPParsingMachine$Result

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.