Search in sources :

Example 31 with Accepted

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

the class TransactionalTransferTest method receiveTransactionalAcquisitionReceiverSettleFirst.

@Test
@SpecificationTest(section = "4.4.2", description = "Transactional Acquisition[...]In the case of the flow frame," + " the transactional work is not necessarily directly" + " initiated or entirely determined when the flow frame" + " arrives at the resource, but can in fact occur at some " + " later point and in ways not necessarily" + " anticipated by the controller.")
public void receiveTransactionalAcquisitionReceiverSettleFirst() throws Exception {
    Utils.putMessageOnQueue(getBrokerAdmin(), BrokerAdmin.TEST_QUEUE_NAME, getTestName());
    try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
        final Interaction interaction = transport.newInteraction();
        interaction.negotiateOpen().begin().consumeResponse(Begin.class).txnAttachCoordinatorLink(UnsignedInteger.ZERO, this::coordinatorAttachExpected).txnDeclare().attachRole(Role.RECEIVER).attachHandle(UnsignedInteger.ONE).attachSourceAddress(BrokerAdmin.TEST_QUEUE_NAME).attachRcvSettleMode(ReceiverSettleMode.FIRST).attach().consumeResponse(Attach.class).flowIncomingWindow(UnsignedInteger.ONE).flowNextIncomingIdFromPeerLatestSessionBeginAndDeliveryCount().flowOutgoingWindow(UnsignedInteger.ZERO).flowNextOutgoingId(UnsignedInteger.ZERO).flowLinkCredit(UnsignedInteger.ONE).flowHandleFromLinkHandle().flowProperties(Collections.singletonMap(Symbol.valueOf("txn-id"), interaction.getCurrentTransactionId())).flow().receiveDelivery();
        List<Transfer> transfers = interaction.getLatestDelivery();
        assertThat(transfers.size(), is(equalTo(1)));
        Object data = interaction.decodeLatestDelivery().getDecodedLatestDelivery();
        assertThat(data, is(equalTo(getTestName())));
        interaction.dispositionSettled(true).dispositionRole(Role.RECEIVER).dispositionTransactionalStateFromCurrentTransaction(new Accepted()).dispositionFirstFromLatestDelivery().disposition().txnDischarge(false);
        assertThat(interaction.getCoordinatorLatestDeliveryState(), is(instanceOf(Accepted.class)));
        Transfer transfer = transfers.get(0);
        assumeThat(transfer.getState(), is(instanceOf(TransactionalState.class)));
        assumeThat(((TransactionalState) transfer.getState()).getTxnId(), is(equalTo(interaction.getCurrentTransactionId())));
        final String content = getTestName() + "_2";
        Utils.putMessageOnQueue(getBrokerAdmin(), BrokerAdmin.TEST_QUEUE_NAME, content);
        assertThat(Utils.receiveMessage(getBrokerAdmin(), BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(content)));
    }
}
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) Begin(org.apache.qpid.server.protocol.v1_0.type.transport.Begin) Transfer(org.apache.qpid.server.protocol.v1_0.type.transport.Transfer) Accepted(org.apache.qpid.server.protocol.v1_0.type.messaging.Accepted) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 32 with Accepted

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

the class LinkStoreTestCase method setUp.

@Before
public void setUp() throws Exception {
    _linkStore = createLinkStore();
    _source = new Source();
    _target = new Target();
    _source.setAddress(ADDRESS);
    _source.setCapabilities(new Symbol[] { Symbol.getSymbol(CAPABILITY) });
    _source.setDefaultOutcome(new Rejected());
    _source.setDistributionMode(StdDistMode.COPY);
    _source.setDurable(TerminusDurability.UNSETTLED_STATE);
    _source.setDynamic(Boolean.TRUE);
    _source.setExpiryPolicy(TerminusExpiryPolicy.CONNECTION_CLOSE);
    _source.setFilter(Collections.singletonMap(Symbol.valueOf("foo"), NoLocalFilter.INSTANCE));
    _source.setOutcomes(new Accepted().getSymbol());
    _source.setDynamicNodeProperties(Collections.singletonMap(Symbol.valueOf("dynamicProperty"), "dynamicPropertyValue"));
    _source.setTimeout(new UnsignedInteger(1));
    _target.setTimeout(new UnsignedInteger(2));
    _target.setDynamicNodeProperties(Collections.singletonMap(Symbol.valueOf("targetDynamicProperty"), "targetDynamicPropertyValue"));
    _target.setDynamic(Boolean.TRUE);
    _target.setExpiryPolicy(TerminusExpiryPolicy.LINK_DETACH);
    _target.setAddress("bar");
    _target.setCapabilities(new Symbol[] { Symbol.getSymbol(CAPABILITY) });
    _target.setDurable(TerminusDurability.CONFIGURATION);
}
Also used : Target(org.apache.qpid.server.protocol.v1_0.type.messaging.Target) Rejected(org.apache.qpid.server.protocol.v1_0.type.messaging.Rejected) UnsignedInteger(org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger) Source(org.apache.qpid.server.protocol.v1_0.type.messaging.Source) Accepted(org.apache.qpid.server.protocol.v1_0.type.messaging.Accepted) Before(org.junit.Before)

Aggregations

Accepted (org.apache.qpid.server.protocol.v1_0.type.messaging.Accepted)30 FrameTransport (org.apache.qpid.tests.protocol.v1_0.FrameTransport)25 Interaction (org.apache.qpid.tests.protocol.v1_0.Interaction)25 Test (org.junit.Test)25 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)23 Attach (org.apache.qpid.server.protocol.v1_0.type.transport.Attach)18 UnsignedInteger (org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)12 Begin (org.apache.qpid.server.protocol.v1_0.type.transport.Begin)11 Flow (org.apache.qpid.server.protocol.v1_0.type.transport.Flow)9 Transfer (org.apache.qpid.server.protocol.v1_0.type.transport.Transfer)9 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)7 DeliveryState (org.apache.qpid.server.protocol.v1_0.type.DeliveryState)6 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)5 Detach (org.apache.qpid.server.protocol.v1_0.type.transport.Detach)5 TransactionError (org.apache.qpid.server.protocol.v1_0.type.transaction.TransactionError)4 Disposition (org.apache.qpid.server.protocol.v1_0.type.transport.Disposition)4 Error (org.apache.qpid.server.protocol.v1_0.type.transport.Error)4 BrokerAdmin (org.apache.qpid.tests.utils.BrokerAdmin)4 HashMap (java.util.HashMap)3 Map (java.util.Map)3