use of org.apache.qpid.server.protocol.v1_0.type.transport.Detach in project qpid-broker-j by apache.
the class TransactionalTransferTest method assertUnknownTransactionIdError.
private void assertUnknownTransactionIdError(final Response<?> response) {
assertThat(response, is(notNullValue()));
final Object body = response.getBody();
assertThat(body, is(notNullValue()));
Error error = null;
if (body instanceof Close) {
error = ((Close) body).getError();
} else if (body instanceof End) {
error = ((End) body).getError();
} else if (body instanceof Detach) {
error = ((Detach) body).getError();
} else {
fail(String.format("Unexpected response %s", body.getClass().getSimpleName()));
}
assertThat(error, is(notNullValue()));
assertThat(error.getCondition(), equalTo(TransactionError.UNKNOWN_ID));
}
use of org.apache.qpid.server.protocol.v1_0.type.transport.Detach in project qpid-broker-j by apache.
the class SendingLinkEndpoint method remoteDetachedPerformDetach.
@Override
protected void remoteDetachedPerformDetach(final Detach detach) {
TerminusExpiryPolicy expiryPolicy = getSource().getExpiryPolicy();
if (Boolean.TRUE.equals(detach.getClosed()) || TerminusExpiryPolicy.LINK_DETACH.equals(expiryPolicy) || ((expiryPolicy == null || TerminusExpiryPolicy.SESSION_END.equals(expiryPolicy)) && getSession().isClosing()) || (TerminusExpiryPolicy.CONNECTION_CLOSE.equals(expiryPolicy) && getSession().getConnection().isClosing())) {
cleanUpUnsettledDeliveries();
close();
} else if (detach.getError() != null) {
cleanUpUnsettledDeliveries();
detach();
destroy();
getConsumerTarget().updateNotifyWorkDesired();
} else {
detach();
// TODO: QPID-7845 : Resuming links is unsupported at the moment. Destroying link unconditionally.
destroy();
getConsumerTarget().updateNotifyWorkDesired();
}
}
use of org.apache.qpid.server.protocol.v1_0.type.transport.Detach in project qpid-broker-j by apache.
the class Session_1_0Test method assertAttachFailed.
private void assertAttachFailed(final AMQPConnection_1_0 connection, final Session_1_0 session, final Attach attach, int invocationOffset) {
ArgumentCaptor<FrameBody> frameCapture = ArgumentCaptor.forClass(FrameBody.class);
verify(connection, times(invocationOffset + 2)).sendFrame(eq(session.getChannelId()), frameCapture.capture());
List<FrameBody> sentFrames = frameCapture.getAllValues();
final boolean condition1 = sentFrames.get(invocationOffset) instanceof Attach;
assertTrue("unexpected Frame sent", condition1);
Attach sentAttach = (Attach) sentFrames.get(invocationOffset);
assertEquals("Unexpected name", attach.getName(), sentAttach.getName());
assertEquals("Unexpected role", Role.SENDER, sentAttach.getRole());
assertEquals("Unexpected source", null, sentAttach.getSource());
final boolean condition = sentFrames.get(invocationOffset + 1) instanceof Detach;
assertTrue("unexpected Frame sent", condition);
Detach sentDetach = (Detach) sentFrames.get(invocationOffset + 1);
assertTrue("Unexpected closed state", sentDetach.getClosed());
}
use of org.apache.qpid.server.protocol.v1_0.type.transport.Detach in project qpid-broker-j by apache.
the class Session_1_0Test method assertDetachSent.
private void assertDetachSent(final AMQPConnection_1_0 connection, final Session_1_0 session, final ErrorCondition expectedError, final int invocationOffset) {
ArgumentCaptor<FrameBody> frameCapture = ArgumentCaptor.forClass(FrameBody.class);
verify(connection, times(invocationOffset + 1)).sendFrame(eq(session.getChannelId()), frameCapture.capture());
List<FrameBody> sentFrames = frameCapture.getAllValues();
final boolean condition = sentFrames.get(invocationOffset) instanceof Detach;
assertTrue("unexpected Frame sent", condition);
Detach sentDetach = (Detach) sentFrames.get(invocationOffset);
assertTrue("Unexpected closed state", sentDetach.getClosed());
assertEquals("Closed with unexpected error condition", expectedError, sentDetach.getError().getCondition());
}
use of org.apache.qpid.server.protocol.v1_0.type.transport.Detach in project qpid-broker-j by apache.
the class Session_1_0Test method sendDetach.
private void sendDetach(final Session_1_0 session, final UnsignedInteger handle, final boolean closed) {
final Detach detach = new Detach();
detach.setHandle(handle);
detach.setClosed(closed);
session.receiveDetach(detach);
}
Aggregations