Package org.eclipse.jetty.spdy.parser

Examples of org.eclipse.jetty.spdy.parser.Parser


        ByteBuffer buffer = generator.control(frame1);

        assertThat("buffer is not null", buffer, not(nullValue()));

        TestSPDYParserListener listener = new TestSPDYParserListener();
        Parser parser = new Parser(new StandardCompressionFactory().newDecompressor());
        parser.addListener(listener);
        parser.parse(buffer);
        ControlFrame frame2 = listener.getControlFrame();

        assertThat("frame2 is not null", frame2, not(nullValue()));
        assertThat("frame2 is type RST_STREAM",ControlFrameType.RST_STREAM, equalTo(frame2.getType()));
        RstStreamFrame rstStream = (RstStreamFrame)frame2;
View Full Code Here


        ByteBuffer buffer = generator.control(frame1);

        Assert.assertNotNull(buffer);

        TestSPDYParserListener listener = new TestSPDYParserListener();
        Parser parser = new Parser(new StandardCompressionFactory().newDecompressor());
        parser.addListener(listener);
        while (buffer.hasRemaining())
            parser.parse(ByteBuffer.wrap(new byte[]{buffer.get()}));
        ControlFrame frame2 = listener.getControlFrame();

        Assert.assertNotNull(frame2);
        Assert.assertEquals(ControlFrameType.RST_STREAM, frame2.getType());
        RstStreamFrame rstStream = (RstStreamFrame)frame2;
View Full Code Here

        ByteBuffer buffer = generator.control(frame1);

        Assert.assertNotNull(buffer);

        TestSPDYParserListener listener = new TestSPDYParserListener();
        Parser parser = new Parser(new StandardCompressionFactory().newDecompressor());
        parser.addListener(listener);
        parser.parse(buffer);
        ControlFrame frame2 = listener.getControlFrame();

        Assert.assertNotNull(frame2);
        Assert.assertEquals(ControlFrameType.SETTINGS, frame2.getType());
        SettingsFrame settingsFrame = (SettingsFrame)frame2;
View Full Code Here

        ByteBuffer buffer = generator.control(frame1);

        Assert.assertNotNull(buffer);

        TestSPDYParserListener listener = new TestSPDYParserListener();
        Parser parser = new Parser(new StandardCompressionFactory().newDecompressor());
        parser.addListener(listener);
        while (buffer.hasRemaining())
            parser.parse(ByteBuffer.wrap(new byte[]{buffer.get()}));
        ControlFrame frame2 = listener.getControlFrame();

        Assert.assertNotNull(frame2);
        Assert.assertEquals(ControlFrameType.SETTINGS, frame2.getType());
        SettingsFrame settingsFrame = (SettingsFrame)frame2;
View Full Code Here

        ByteBuffer buffer = generator.data(streamId, 2 * length, data);

        Assert.assertNotNull(buffer);

        TestSPDYParserListener listener = new TestSPDYParserListener();
        Parser parser = new Parser(new StandardCompressionFactory().newDecompressor());
        parser.addListener(listener);
        parser.parse(buffer);
        DataFrame frame2 = listener.getDataFrame();

        Assert.assertNotNull(frame2);
        Assert.assertEquals(streamId, frame2.getStreamId());
        Assert.assertEquals(DataInfo.FLAG_CLOSE, frame2.getFlags());
View Full Code Here

        ByteBuffer buffer = generator.data(streamId, 2 * length, data);

        Assert.assertNotNull(buffer);

        TestSPDYParserListener listener = new TestSPDYParserListener();
        Parser parser = new Parser(new StandardCompressionFactory().newDecompressor());
        parser.addListener(listener);
        while (buffer.hasRemaining())
        {
            parser.parse(ByteBuffer.wrap(new byte[]{buffer.get()}));
            if (buffer.remaining() < length)
            {
                DataFrame frame2 = listener.getDataFrame();
                Assert.assertNotNull(frame2);
                Assert.assertEquals(streamId, frame2.getStreamId());
View Full Code Here

        ByteBuffer buffer = generator.data(streamId, 2 * length, data);

        Assert.assertNotNull(buffer);

        TestSPDYParserListener listener = new TestSPDYParserListener();
        Parser parser = new Parser(new StandardCompressionFactory().newDecompressor());
        parser.addListener(listener);

        // Split the buffer to simulate a split boundary in receiving the bytes
        int split = 3;
        ByteBuffer buffer1 = ByteBuffer.allocate(buffer.remaining() - split);
        buffer.limit(buffer.limit() - split);
        buffer1.put(buffer);
        buffer1.flip();
        ByteBuffer buffer2 = ByteBuffer.allocate(split);
        buffer.limit(buffer.limit() + split);
        buffer2.put(buffer);
        buffer2.flip();

        parser.parse(buffer1);
        DataFrame frame2 = listener.getDataFrame();

        Assert.assertNotNull(frame2);
        Assert.assertEquals(streamId, frame2.getStreamId());
        Assert.assertEquals(0, frame2.getFlags());
        Assert.assertEquals(length - split, frame2.getLength());
        Assert.assertEquals(length - split, listener.getData().remaining());

        parser.parse(buffer2);
        DataFrame frame3 = listener.getDataFrame();

        Assert.assertNotNull(frame3);
        Assert.assertEquals(streamId, frame3.getStreamId());
        Assert.assertEquals(DataInfo.FLAG_CLOSE, frame3.getFlags());
View Full Code Here

        ByteBuffer buffer = generator.control(frame1);

        Assert.assertNotNull(buffer);

        TestSPDYParserListener listener = new TestSPDYParserListener();
        Parser parser = new Parser(new StandardCompressionFactory().newDecompressor());
        parser.addListener(listener);
        parser.parse(buffer);
        ControlFrame frame2 = listener.getControlFrame();

        Assert.assertNotNull(frame2);
        Assert.assertEquals(ControlFrameType.SYN_REPLY, frame2.getType());
        SynReplyFrame synReply = (SynReplyFrame)frame2;
View Full Code Here

        ByteBuffer buffer = generator.control(frame1);

        Assert.assertNotNull(buffer);

        TestSPDYParserListener listener = new TestSPDYParserListener();
        Parser parser = new Parser(new StandardCompressionFactory().newDecompressor());
        parser.addListener(listener);
        while (buffer.hasRemaining())
            parser.parse(ByteBuffer.wrap(new byte[]{buffer.get()}));
        ControlFrame frame2 = listener.getControlFrame();

        Assert.assertNotNull(frame2);
        Assert.assertEquals(ControlFrameType.SYN_REPLY, frame2.getType());
        SynReplyFrame synReply = (SynReplyFrame)frame2;
View Full Code Here

        buffer = ByteBuffer.allocate(1024);
        channel.read(buffer);
        buffer.flip();

        final CountDownLatch rstLatch = new CountDownLatch(1);
        Parser parser = new Parser(new StandardCompressionFactory.StandardDecompressor());
        parser.addListener(new Parser.Listener.Adapter()
        {
            @Override
            public void onControlFrame(ControlFrame frame)
            {
                Assert.assertSame(ControlFrameType.RST_STREAM, frame.getType());
                Assert.assertEquals(StreamStatus.UNSUPPORTED_VERSION.getCode(frame.getVersion()), ((RstStreamFrame)frame).getStatusCode());
                rstLatch.countDown();
            }
        });
        parser.parse(buffer);

        Assert.assertTrue(rstLatch.await(5, TimeUnit.SECONDS));
    }
View Full Code Here

TOP

Related Classes of org.eclipse.jetty.spdy.parser.Parser

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.