Search in sources :

Example 6 with DeleteOnClose

use of org.apache.qpid.server.protocol.v1_0.type.messaging.DeleteOnClose in project qpid-broker-j by apache.

the class DeleteOnCloseTest method dynamicNodeIsPersisted.

@Test
public void dynamicNodeIsPersisted() throws Exception {
    assumeThat(getBrokerAdmin().supportsRestart(), is(true));
    final String newTempQueueAddress;
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        Source source = new Source();
        source.setDynamicNodeProperties(Collections.singletonMap(Session_1_0.LIFETIME_POLICY, new DeleteOnClose()));
        source.setExpiryPolicy(TerminusExpiryPolicy.NEVER);
        source.setDynamic(true);
        final Interaction interaction = transport.newInteraction();
        final Attach attachResponse = interaction.negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).attachRole(Role.RECEIVER).attachSource(source).attach().consumeResponse().getLatestResponse(Attach.class);
        assertThat(attachResponse.getSource(), is(notNullValue()));
        newTempQueueAddress = ((Source) attachResponse.getSource()).getAddress();
        assertThat(Utils.doesNodeExist(_brokerAddress, newTempQueueAddress), is(true));
    }
    final ListenableFuture<Void> restart = getBrokerAdmin().restart();
    restart.get(BrokerAdmin.RESTART_TIMEOUT, TimeUnit.MILLISECONDS);
    _brokerAddress = getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.ANONYMOUS_AMQP);
    assertThat(Utils.doesNodeExist(_brokerAddress, newTempQueueAddress), is(true));
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) DeleteOnClose(org.apache.qpid.server.protocol.v1_0.type.messaging.DeleteOnClose) Begin(org.apache.qpid.server.protocol.v1_0.type.transport.Begin) Source(org.apache.qpid.server.protocol.v1_0.type.messaging.Source) Open(org.apache.qpid.server.protocol.v1_0.type.transport.Open) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 7 with DeleteOnClose

use of org.apache.qpid.server.protocol.v1_0.type.messaging.DeleteOnClose in project qpid-broker-j by apache.

the class DeleteOnCloseTest method deleteOnCloseOnSource.

@Test
@SpecificationTest(section = "3.5.10", description = "A node dynamically created with this lifetime policy will be deleted at the point that the link which caused its\n" + "creation ceases to exist.")
public void deleteOnCloseOnSource() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        Source source = new Source();
        source.setDynamicNodeProperties(Collections.singletonMap(Session_1_0.LIFETIME_POLICY, new DeleteOnClose()));
        source.setDynamic(true);
        final Interaction interaction = transport.newInteraction();
        final Attach attachResponse = interaction.negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).attachRole(Role.RECEIVER).attachSource(source).attach().consumeResponse().getLatestResponse(Attach.class);
        assertThat(attachResponse.getSource(), is(notNullValue()));
        final String newTempQueueAddress = ((Source) attachResponse.getSource()).getAddress();
        assertThat(Utils.doesNodeExist(_brokerAddress, newTempQueueAddress), is(true));
        interaction.detachClose(true).detach().consumeResponse().getLatestResponse(Detach.class);
        assertThat(Utils.doesNodeExist(_brokerAddress, newTempQueueAddress), is(false));
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) DeleteOnClose(org.apache.qpid.server.protocol.v1_0.type.messaging.DeleteOnClose) Begin(org.apache.qpid.server.protocol.v1_0.type.transport.Begin) Source(org.apache.qpid.server.protocol.v1_0.type.messaging.Source) Open(org.apache.qpid.server.protocol.v1_0.type.transport.Open) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Aggregations

DeleteOnClose (org.apache.qpid.server.protocol.v1_0.type.messaging.DeleteOnClose)7 Attach (org.apache.qpid.server.protocol.v1_0.type.transport.Attach)6 Begin (org.apache.qpid.server.protocol.v1_0.type.transport.Begin)6 Open (org.apache.qpid.server.protocol.v1_0.type.transport.Open)6 FrameTransport (org.apache.qpid.tests.protocol.v1_0.FrameTransport)6 Interaction (org.apache.qpid.tests.protocol.v1_0.Interaction)6 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)5 Test (org.junit.Test)5 Source (org.apache.qpid.server.protocol.v1_0.type.messaging.Source)3 Target (org.apache.qpid.server.protocol.v1_0.type.messaging.Target)3 HashMap (java.util.HashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 AbstractConfiguredObject (org.apache.qpid.server.model.AbstractConfiguredObject)1 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)1 LifetimePolicy (org.apache.qpid.server.protocol.v1_0.type.LifetimePolicy)1 DeleteOnNoLinks (org.apache.qpid.server.protocol.v1_0.type.messaging.DeleteOnNoLinks)1 DeleteOnNoLinksOrMessages (org.apache.qpid.server.protocol.v1_0.type.messaging.DeleteOnNoLinksOrMessages)1 DeleteOnNoMessages (org.apache.qpid.server.protocol.v1_0.type.messaging.DeleteOnNoMessages)1 Flow (org.apache.qpid.server.protocol.v1_0.type.transport.Flow)1 CreatingLinkInfo (org.apache.qpid.server.queue.CreatingLinkInfo)1