Search in sources :

Example 16 with Attach

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

the class Interaction method txnAttachCoordinatorLink.

// ///////////////
// transaction //
// //////////////
public Interaction txnAttachCoordinatorLink(InteractionTransactionalState transactionalState) throws Exception {
    Attach attach = new Attach();
    attach.setName("testTransactionCoordinator-" + transactionalState.getHandle());
    attach.setHandle(transactionalState.getHandle());
    attach.setInitialDeliveryCount(UnsignedInteger.ZERO);
    attach.setTarget(new Coordinator());
    attach.setRole(Role.SENDER);
    Source source = new Source();
    attach.setSource(source);
    source.setOutcomes(Accepted.ACCEPTED_SYMBOL, Rejected.REJECTED_SYMBOL);
    sendPerformativeAndChainFuture(attach, _sessionChannel);
    consumeResponse(Attach.class);
    consumeResponse(Flow.class);
    return this;
}
Also used : Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) Coordinator(org.apache.qpid.server.protocol.v1_0.type.transaction.Coordinator) BaseSource(org.apache.qpid.server.protocol.v1_0.type.BaseSource) Source(org.apache.qpid.server.protocol.v1_0.type.messaging.Source)

Example 17 with Attach

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

the class Interaction method copyAttach.

private Attach copyAttach(final Attach attach) {
    final Attach attachCopy = new Attach();
    attachCopy.setName(attach.getName());
    attachCopy.setHandle(attach.getHandle());
    attachCopy.setRole(attach.getRole());
    attachCopy.setSndSettleMode(attach.getSndSettleMode());
    attachCopy.setRcvSettleMode(attach.getRcvSettleMode());
    final BaseSource baseSource = attach.getSource();
    if (baseSource != null && baseSource instanceof Source) {
        final Source source = (Source) baseSource;
        final Source sourceCopy = new Source();
        sourceCopy.setAddress(source.getAddress());
        sourceCopy.setDurable(source.getDurable());
        sourceCopy.setExpiryPolicy(source.getExpiryPolicy());
        sourceCopy.setTimeout(source.getTimeout());
        sourceCopy.setDynamic(source.getDynamic());
        if (source.getDynamicNodeProperties() != null) {
            sourceCopy.setDynamicNodeProperties(new LinkedHashMap<>(source.getDynamicNodeProperties()));
        }
        sourceCopy.setFilter(source.getFilter());
        sourceCopy.setDefaultOutcome(source.getDefaultOutcome());
        sourceCopy.setOutcomes(source.getOutcomes());
        sourceCopy.setCapabilities(source.getCapabilities());
        attachCopy.setSource(sourceCopy);
    } else {
        attachCopy.setSource(baseSource);
    }
    final BaseTarget baseTarget = attach.getTarget();
    if (baseTarget != null && baseTarget instanceof Target) {
        final Target target = (Target) baseTarget;
        final Target targetCopy = new Target();
        targetCopy.setAddress(target.getAddress());
        targetCopy.setDurable(target.getDurable());
        targetCopy.setExpiryPolicy(target.getExpiryPolicy());
        targetCopy.setTimeout(target.getTimeout());
        targetCopy.setDynamic(target.getDynamic());
        if (target.getDynamicNodeProperties() != null) {
            targetCopy.setDynamicNodeProperties(new LinkedHashMap<>(target.getDynamicNodeProperties()));
        }
        targetCopy.setCapabilities(target.getCapabilities());
        attachCopy.setTarget(targetCopy);
    } else {
        attachCopy.setTarget(baseTarget);
    }
    if (attach.getUnsettled() != null) {
        attachCopy.setUnsettled(new LinkedHashMap<>(attach.getUnsettled()));
    }
    attachCopy.setIncompleteUnsettled(attach.getIncompleteUnsettled());
    attachCopy.setInitialDeliveryCount(attach.getInitialDeliveryCount());
    attachCopy.setMaxMessageSize(attach.getMaxMessageSize());
    attachCopy.setOfferedCapabilities(attach.getOfferedCapabilities());
    attachCopy.setDesiredCapabilities(attach.getDesiredCapabilities());
    if (attach.getProperties() != null) {
        attachCopy.setProperties(new LinkedHashMap<>(attach.getProperties()));
    }
    return attachCopy;
}
Also used : BaseTarget(org.apache.qpid.server.protocol.v1_0.type.BaseTarget) Target(org.apache.qpid.server.protocol.v1_0.type.messaging.Target) BaseSource(org.apache.qpid.server.protocol.v1_0.type.BaseSource) Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) BaseSource(org.apache.qpid.server.protocol.v1_0.type.BaseSource) Source(org.apache.qpid.server.protocol.v1_0.type.messaging.Source) BaseTarget(org.apache.qpid.server.protocol.v1_0.type.BaseTarget)

Example 18 with Attach

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

the class DecodeErrorTest method nodePropertiesSupportedDistributionModes.

@Test
@SpecificationTest(section = "3.5.9", description = "The value of this entry MUST be of a type which provides the lifetime-policy archetype.")
public void nodePropertiesSupportedDistributionModes() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Target target = new Target();
        target.setDynamic(Boolean.TRUE);
        target.setDynamicNodeProperties(Collections.singletonMap(Symbol.valueOf("supported-dist-modes"), UnsignedInteger.ZERO));
        final Response<?> latestResponse = transport.newInteraction().negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).attachTarget(target).attachRole(Role.SENDER).attach().consumeResponse().getLatestResponse();
        assertThat(latestResponse, is(notNullValue()));
        final Object responseBody = latestResponse.getBody();
        final Error error;
        if (responseBody instanceof End) {
            error = ((End) responseBody).getError();
        } else if (responseBody instanceof Close) {
            error = ((Close) responseBody).getError();
        } else {
            fail(String.format("Expected response of either Detach, End, or Close. Got '%s'", responseBody));
            error = null;
        }
        assertThat(error, is(notNullValue()));
        assertThat(error.getCondition(), is(equalTo(DECODE_ERROR)));
    }
}
Also used : Target(org.apache.qpid.server.protocol.v1_0.type.messaging.Target) Begin(org.apache.qpid.server.protocol.v1_0.type.transport.Begin) Error(org.apache.qpid.server.protocol.v1_0.type.transport.Error) End(org.apache.qpid.server.protocol.v1_0.type.transport.End) Close(org.apache.qpid.server.protocol.v1_0.type.transport.Close) 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)

Example 19 with Attach

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

the class DecodeErrorTest method nodePropertiesLifetimePolicy.

@Test
@SpecificationTest(section = "3.5.9", description = "The value of this entry MUST be of a type which provides the lifetime-policy archetype.")
public void nodePropertiesLifetimePolicy() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Source source = new Source();
        source.setDynamic(Boolean.TRUE);
        source.setDynamicNodeProperties(Collections.singletonMap(Symbol.valueOf("lifetime-policy"), UnsignedInteger.MAX_VALUE));
        final Response<?> latestResponse = transport.newInteraction().negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).attachSource(source).attachRole(Role.SENDER).attach().consumeResponse().getLatestResponse();
        assertThat(latestResponse, is(notNullValue()));
        final Object responseBody = latestResponse.getBody();
        final Error error;
        if (responseBody instanceof End) {
            error = ((End) responseBody).getError();
        } else if (responseBody instanceof Close) {
            error = ((Close) responseBody).getError();
        } else {
            fail(String.format("Expected response of either Detach, End, or Close. Got '%s'", responseBody));
            error = null;
        }
        assertThat(error, is(notNullValue()));
        assertThat(error.getCondition(), is(equalTo(DECODE_ERROR)));
    }
}
Also used : Begin(org.apache.qpid.server.protocol.v1_0.type.transport.Begin) Error(org.apache.qpid.server.protocol.v1_0.type.transport.Error) End(org.apache.qpid.server.protocol.v1_0.type.transport.End) Close(org.apache.qpid.server.protocol.v1_0.type.transport.Close) 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)

Example 20 with Attach

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

the class AnonymousTerminusTest method transferPreSettledToKnownDestination.

@SpecificationTest(section = "Using the Anonymous Terminus for Message Routing. 2.2. Sending A Message", description = "Messages sent over links into a routing node will be" + " forwarded to the node referenced in the to field of properties of the message" + " just as if a direct link has been established to that node.")
@Test
public void transferPreSettledToKnownDestination() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = openInteractionWithAnonymousRelayCapability(transport);
        interaction.begin().consumeResponse(Begin.class).attachRole(Role.SENDER).attach().consumeResponse(Attach.class).consumeResponse(Flow.class).transferPayload(generateMessagePayloadToDestination(BrokerAdmin.TEST_QUEUE_NAME)).transferSettled(Boolean.TRUE).transferDeliveryTag(_deliveryTag).transfer().sync();
        Object receivedMessage = Utils.receiveMessage(_brokerAddress, BrokerAdmin.TEST_QUEUE_NAME);
        assertThat(receivedMessage, is(equalTo(TEST_MESSAGE_CONTENT)));
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Begin(org.apache.qpid.server.protocol.v1_0.type.transport.Begin) Flow(org.apache.qpid.server.protocol.v1_0.type.transport.Flow) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Aggregations

Attach (org.apache.qpid.server.protocol.v1_0.type.transport.Attach)85 Test (org.junit.Test)84 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)82 FrameTransport (org.apache.qpid.tests.protocol.v1_0.FrameTransport)82 Interaction (org.apache.qpid.tests.protocol.v1_0.Interaction)70 Begin (org.apache.qpid.server.protocol.v1_0.type.transport.Begin)39 Open (org.apache.qpid.server.protocol.v1_0.type.transport.Open)37 Flow (org.apache.qpid.server.protocol.v1_0.type.transport.Flow)36 UnsignedInteger (org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)32 Disposition (org.apache.qpid.server.protocol.v1_0.type.transport.Disposition)32 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)27 InteractionTransactionalState (org.apache.qpid.tests.protocol.v1_0.InteractionTransactionalState)24 Error (org.apache.qpid.server.protocol.v1_0.type.transport.Error)23 Detach (org.apache.qpid.server.protocol.v1_0.type.transport.Detach)20 AmqpError (org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError)18 Accepted (org.apache.qpid.server.protocol.v1_0.type.messaging.Accepted)17 Source (org.apache.qpid.server.protocol.v1_0.type.messaging.Source)17 DeliveryState (org.apache.qpid.server.protocol.v1_0.type.DeliveryState)14 InetSocketAddress (java.net.InetSocketAddress)13 TransactionError (org.apache.qpid.server.protocol.v1_0.type.transaction.TransactionError)11