@@ -0,0 +1,3544 @@
+/*%0A * Licensed to the Apache Software Foundation (ASF) under one or more%0A * contributor license agreements.  See the NOTICE file distributed with%0A * this work for additional information regarding copyright ownership.%0A * The ASF licenses this file to You under the Apache License, Version 2.0%0A * (the %22License%22); you may not use this file except in compliance with%0A * the License.  You may obtain a copy of the License at%0A *%0A *      http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage org.apache.qpid.proton4j.engine.impl;%0A%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.assertTrue;%0A%0Aimport java.io.IOException;%0A%0Aimport org.apache.qpid.proton4j.amqp.transport.AMQPHeader;%0Aimport org.apache.qpid.proton4j.buffer.ProtonByteBufferAllocator;%0Aimport org.apache.qpid.proton4j.engine.Engine;%0Aimport org.apache.qpid.proton4j.engine.EngineHandlerContext;%0Aimport org.apache.qpid.proton4j.engine.HeaderFrame;%0Aimport org.apache.qpid.proton4j.engine.util.TestSupportTransportHandler;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.mockito.Mockito;%0A%0Apublic class ProtonFrameDecodingHandlerTest %7B%0A%0A    private TestSupportTransportHandler testHandler;%0A%0A    @Before%0A    public void setUp() %7B%0A        testHandler = new TestSupportTransportHandler();%0A    %7D%0A%0A    @Test%0A    public void testDecodeValidHeaderTriggersHeaderRead() %7B%0A        Engine engine = createEngine();%0A%0A        // Check for Header processing%0A        engine.pipeline().fireRead(AMQPHeader.getAMQPHeader().getBuffer());%0A%0A        Object frame = testHandler.getFramesRead().get(0);%0A        assertTrue(frame instanceof HeaderFrame);%0A        HeaderFrame header = (HeaderFrame) frame;%0A        assertEquals(AMQPHeader.getAMQPHeader(), header.getBody());%0A    %7D%0A%0A    @Test%0A    public void testDecodeValidSaslHeaderTriggersHeaderRead() %7B%0A        Engine engine = createEngine();%0A%0A        // Check for Header processing%0A        engine.pipeline().fireRead(AMQPHeader.getSASLHeader().getBuffer());%0A%0A        Object frame = testHandler.getFramesRead().get(0);%0A        assertTrue(frame instanceof HeaderFrame);%0A        HeaderFrame header = (HeaderFrame) frame;%0A        assertEquals(AMQPHeader.getSASLHeader(), header.getBody());%0A    %7D%0A%0A    @Test%0A    public void testInvalidHeaderBytesTriggersError() %7B%0A        ProtonFrameDecodingHandler handler = new ProtonFrameDecodingHandler();%0A        EngineHandlerContext context = Mockito.mock(EngineHandlerContext.class);%0A%0A        handler.handleRead(context, ProtonByteBufferAllocator.DEFAULT.wrap(new byte%5B%5D %7B 'S' %7D));%0A%0A        Mockito.verify(context).fireDecodingError(Mockito.any(IOException.class));%0A        Mockito.verifyNoMoreInteractions(context);%0A%0A        // Verify that the parser accepts no new input once in error state.%0A        Mockito.clearInvocations(context);%0A        handler.handleRead(context, AMQPHeader.getSASLHeader().getBuffer());%0A        Mockito.verify(context).fireDecodingError(Mockito.any(IOException.class));%0A    %7D%0A%0A    private Engine createEngine() %7B%0A        ProtonEngine transport = new ProtonEngine();%0A%0A        transport.pipeline().addLast(%22test%22, testHandler);%0A        transport.pipeline().addLast(%22frames%22, new ProtonFrameDecodingHandler());%0A%0A        return transport;%0A    %7D%0A%7D%0A

Add a start on testing the frame decoder directly