Search in sources :

Example 1 with Detach

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));
}
Also used : Error(org.apache.qpid.server.protocol.v1_0.type.transport.Error) TransactionError(org.apache.qpid.server.protocol.v1_0.type.transaction.TransactionError) Close(org.apache.qpid.server.protocol.v1_0.type.transport.Close) End(org.apache.qpid.server.protocol.v1_0.type.transport.End) Detach(org.apache.qpid.server.protocol.v1_0.type.transport.Detach)

Example 2 with Detach

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();
    }
}
Also used : TerminusExpiryPolicy(org.apache.qpid.server.protocol.v1_0.type.messaging.TerminusExpiryPolicy)

Example 3 with Detach

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());
}
Also used : Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) FrameBody(org.apache.qpid.server.protocol.v1_0.type.FrameBody) Detach(org.apache.qpid.server.protocol.v1_0.type.transport.Detach)

Example 4 with Detach

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());
}
Also used : FrameBody(org.apache.qpid.server.protocol.v1_0.type.FrameBody) Detach(org.apache.qpid.server.protocol.v1_0.type.transport.Detach)

Example 5 with Detach

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);
}
Also used : Detach(org.apache.qpid.server.protocol.v1_0.type.transport.Detach)

Aggregations

Detach (org.apache.qpid.server.protocol.v1_0.type.transport.Detach)43 Test (org.junit.Test)41 Attach (org.apache.qpid.server.protocol.v1_0.type.transport.Attach)39 FrameTransport (org.apache.qpid.tests.protocol.v1_0.FrameTransport)39 Interaction (org.apache.qpid.tests.protocol.v1_0.Interaction)37 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)34 Begin (org.apache.qpid.server.protocol.v1_0.type.transport.Begin)19 Flow (org.apache.qpid.server.protocol.v1_0.type.transport.Flow)15 UnsignedInteger (org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)13 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)12 Error (org.apache.qpid.server.protocol.v1_0.type.transport.Error)12 DeliveryState (org.apache.qpid.server.protocol.v1_0.type.DeliveryState)10 Disposition (org.apache.qpid.server.protocol.v1_0.type.transport.Disposition)9 Accepted (org.apache.qpid.server.protocol.v1_0.type.messaging.Accepted)8 Source (org.apache.qpid.server.protocol.v1_0.type.messaging.Source)8 TransactionError (org.apache.qpid.server.protocol.v1_0.type.transaction.TransactionError)8 Ignore (org.junit.Ignore)8 HashMap (java.util.HashMap)7 AmqpError (org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError)7 End (org.apache.qpid.server.protocol.v1_0.type.transport.End)7