use of org.apache.qpid.server.protocol.v1_0.ConnectionHandler in project qpid-broker-j by apache.
the class FrameHandlerTest method testOversizedFrame.
@Test
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.ConnectionHandler in project qpid-broker-j by apache.
the class AMQPConnection_1_0Impl method sendConnectionCloseAsync.
@Override
public void sendConnectionCloseAsync(final CloseReason reason, final String description) {
stopConnection();
final ErrorCondition cause;
switch(reason) {
case MANAGEMENT:
cause = ConnectionError.CONNECTION_FORCED;
break;
case TRANSACTION_TIMEOUT:
cause = AmqpError.RESOURCE_LIMIT_EXCEEDED;
break;
default:
cause = AmqpError.INTERNAL_ERROR;
}
Action<ConnectionHandler> action = object -> closeConnection(cause, description);
addAsyncTask(action);
}
use of org.apache.qpid.server.protocol.v1_0.ConnectionHandler in project qpid-broker-j by apache.
the class FrameHandlerTest method testSaslHeartbeat.
@Test
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