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());
}
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);
}
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());
}
Aggregations