Search in sources :

Example 1 with FrameHandler

use of org.apache.qpid.server.protocol.v1_0.framing.FrameHandler in project qpid-broker-j by apache.

the class FrameHandlerTest method testOversizedFrame.

public void testOversizedFrame() {
    ConnectionHandler connectionHandler = mock(ConnectionHandler.class);
    when(connectionHandler.getMaxFrameSize()).thenReturn(MAX_FRAME_SIZE);
    FrameHandler handler = new FrameHandler(_valueHandler, connectionHandler, true);
    QpidByteBuffer body = QpidByteBuffer.allocate(false, MAX_FRAME_SIZE + 8);
    // size
    body.putInt(body.capacity());
    // DOFF
    body.put((byte) 2);
    // AMQP Frame Type
    body.put((byte) 1);
    // channel
    body.putShort(UnsignedShort.ZERO.shortValue());
    body.position(body.capacity());
    body.flip();
    handler.parse(body);
    ArgumentCaptor<Error> errorCaptor = ArgumentCaptor.forClass(Error.class);
    verify(connectionHandler).handleError(errorCaptor.capture());
    Error error = errorCaptor.getValue();
    assertNotNull(error);
    assertEquals(ConnectionError.FRAMING_ERROR, error.getCondition());
    assertEquals(String.format("specified frame size %s larger than maximum frame header size %s", body.capacity(), MAX_FRAME_SIZE), error.getDescription());
}
Also used : ConnectionHandler(org.apache.qpid.server.protocol.v1_0.ConnectionHandler) ConnectionError(org.apache.qpid.server.protocol.v1_0.type.transport.ConnectionError) Error(org.apache.qpid.server.protocol.v1_0.type.transport.Error) QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer)

Example 2 with FrameHandler

use of org.apache.qpid.server.protocol.v1_0.framing.FrameHandler in project qpid-broker-j by apache.

the class FrameDecoder method resetInputHandlerAfterSaslOutcome.

private void resetInputHandlerAfterSaslOutcome() {
    _state = ParsingState.HEADER;
    _frameHandler = new FrameHandler(_valueHandler, _connectionHandler, false);
}
Also used : FrameHandler(org.apache.qpid.server.protocol.v1_0.framing.FrameHandler)

Example 3 with FrameHandler

use of org.apache.qpid.server.protocol.v1_0.framing.FrameHandler in project qpid-broker-j by apache.

the class FrameHandlerTest method testSaslHeartbeat.

public void testSaslHeartbeat() {
    ConnectionHandler connectionHandler = mock(ConnectionHandler.class);
    when(connectionHandler.getMaxFrameSize()).thenReturn(MAX_FRAME_SIZE);
    FrameHandler handler = new FrameHandler(_valueHandler, connectionHandler, true);
    QpidByteBuffer body = QpidByteBuffer.allocate(false, 8);
    // size
    body.putInt(8);
    // DOFF
    body.put((byte) 2);
    // AMQP Frame Type
    body.put((byte) 1);
    // channel
    body.putShort(UnsignedShort.ZERO.shortValue());
    body.flip();
    handler.parse(body);
    ArgumentCaptor<Error> errorCaptor = ArgumentCaptor.forClass(Error.class);
    verify(connectionHandler).handleError(errorCaptor.capture());
    Error error = errorCaptor.getValue();
    assertNotNull(error);
    assertEquals(ConnectionError.FRAMING_ERROR, error.getCondition());
    assertEquals("Empty (heartbeat) frames are not permitted during SASL negotiation", error.getDescription());
}
Also used : ConnectionHandler(org.apache.qpid.server.protocol.v1_0.ConnectionHandler) ConnectionError(org.apache.qpid.server.protocol.v1_0.type.transport.ConnectionError) Error(org.apache.qpid.server.protocol.v1_0.type.transport.Error) QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer)

Aggregations

QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)2 ConnectionHandler (org.apache.qpid.server.protocol.v1_0.ConnectionHandler)2 ConnectionError (org.apache.qpid.server.protocol.v1_0.type.transport.ConnectionError)2 Error (org.apache.qpid.server.protocol.v1_0.type.transport.Error)2 FrameHandler (org.apache.qpid.server.protocol.v1_0.framing.FrameHandler)1