Search in sources :

Example 1 with SessionDetached

use of org.apache.qpid.server.protocol.v0_10.transport.SessionDetached in project qpid-broker-j by apache.

the class SessionTest method detach.

@Test
@SpecificationTest(section = "9.session.detach", description = "Detaches the current transport from the named session.")
public void detach() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        byte[] sessionName = "test".getBytes(StandardCharsets.UTF_8);
        final int channelId = 1;
        SessionDetached sessionDetached = interaction.openAnonymousConnection().channelId(channelId).session().attachName(sessionName).attach().consumeResponse(SessionAttached.class).session().detachName(sessionName).detach().consumeResponse().getLatestResponse(SessionDetached.class);
        assertThat(sessionDetached.getName(), IsEqual.equalTo(sessionName));
        assertThat(sessionDetached.getChannel(), IsEqual.equalTo(channelId));
    }
}
Also used : SessionAttached(org.apache.qpid.server.protocol.v0_10.transport.SessionAttached) SessionDetached(org.apache.qpid.server.protocol.v0_10.transport.SessionDetached) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 2 with SessionDetached

use of org.apache.qpid.server.protocol.v0_10.transport.SessionDetached in project qpid-broker-j by apache.

the class SessionTest method detachUnknownSession.

@Test
@SpecificationTest(section = "9.session", description = "The transport MUST be attached in order to use any control other than" + " \"attach\", \"attached\", \"detach\", or \"detached\"." + " A peer receiving any other control on a detached transport MUST discard it and send a" + " session.detached with the \"not-attached\" reason code.")
public void detachUnknownSession() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        byte[] sessionName = "test".getBytes(StandardCharsets.UTF_8);
        final int channelId = 1;
        SessionDetached sessionDetached = interaction.openAnonymousConnection().channelId(channelId).session().detachName(sessionName).detach().consumeResponse().getLatestResponse(SessionDetached.class);
        assertThat(sessionDetached.getName(), IsEqual.equalTo(sessionName));
        assertThat(sessionDetached.getChannel(), IsEqual.equalTo(channelId));
    }
}
Also used : SessionDetached(org.apache.qpid.server.protocol.v0_10.transport.SessionDetached) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 3 with SessionDetached

use of org.apache.qpid.server.protocol.v0_10.transport.SessionDetached in project qpid-broker-j by apache.

the class ServerConnection method invokeSessionDetached.

private void invokeSessionDetached(int channel, SessionDetachCode sessionDetachCode) {
    SessionDetached sessionDetached = new SessionDetached();
    sessionDetached.setChannel(channel);
    sessionDetached.setCode(sessionDetachCode);
    invoke(sessionDetached);
}
Also used : SessionDetached(org.apache.qpid.server.protocol.v0_10.transport.SessionDetached)

Example 4 with SessionDetached

use of org.apache.qpid.server.protocol.v0_10.transport.SessionDetached in project qpid-broker-j by apache.

the class SessionTest method attachSameSessionTwiceDisallowed.

@Test
@SpecificationTest(section = "9.session", description = "A session MUST NOT be attached to more than one transport at a time.")
public void attachSameSessionTwiceDisallowed() throws Exception {
    try (FrameTransport transport1 = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction1 = transport1.newInteraction();
        byte[] sessionName = "test".getBytes(StandardCharsets.UTF_8);
        final int channelId1 = 1;
        SessionAttached sessionAttached = interaction1.openAnonymousConnection().channelId(channelId1).session().attachName(sessionName).attach().consumeResponse().getLatestResponse(SessionAttached.class);
        assertThat(sessionAttached.getName(), IsEqual.equalTo(sessionName));
        assertThat(sessionAttached.getChannel(), IsEqual.equalTo(channelId1));
        try (FrameTransport transport2 = new FrameTransport(_brokerAddress).connect()) {
            final Interaction interaction2 = transport2.newInteraction();
            final int channelId2 = 2;
            SessionDetached sessionDetached = interaction2.openAnonymousConnection().channelId(channelId2).session().attachName(sessionName).attach().consumeResponse().getLatestResponse(SessionDetached.class);
            assertThat(sessionDetached.getName(), IsEqual.equalTo(sessionName));
            assertThat(sessionDetached.getCode(), IsEqual.equalTo(SessionDetachCode.SESSION_BUSY));
            assertThat(sessionDetached.getChannel(), IsEqual.equalTo(channelId2));
        }
    }
}
Also used : SessionAttached(org.apache.qpid.server.protocol.v0_10.transport.SessionAttached) SessionDetached(org.apache.qpid.server.protocol.v0_10.transport.SessionDetached) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Aggregations

SessionDetached (org.apache.qpid.server.protocol.v0_10.transport.SessionDetached)4 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)3 Test (org.junit.Test)3 SessionAttached (org.apache.qpid.server.protocol.v0_10.transport.SessionAttached)2