Search in sources :

Example 6 with Source

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

the class MessageConverter_1_0_to_v0_10Test method testAmqpSequenceWithUnsupportedType.

public void testAmqpSequenceWithUnsupportedType() throws Exception {
    final List<Object> originalList = Collections.singletonList(new Source());
    final AmqpSequence amqpSequence = new AmqpSequence(originalList);
    Message_1_0 sourceMessage = createTestMessage(amqpSequence.createEncodingRetainingSection());
    try {
        _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
        fail("expected exception not thrown.");
    } catch (MessageConversionException e) {
    // pass
    }
}
Also used : MessageConversionException(org.apache.qpid.server.protocol.converter.MessageConversionException) NamedAddressSpace(org.apache.qpid.server.model.NamedAddressSpace) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) AmqpSequence(org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpSequence) Source(org.apache.qpid.server.protocol.v1_0.type.messaging.Source)

Example 7 with Source

use of org.apache.qpid.server.protocol.v1_0.type.messaging.Source 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 8 with Source

use of org.apache.qpid.server.protocol.v1_0.type.messaging.Source 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 9 with Source

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

the class Interaction method attachSourceFilter.

public Interaction attachSourceFilter(final Map<Symbol, Filter> filters) {
    Source source = ((Source) _attach.getSource());
    source.setFilter(filters);
    _attach.setSource(source);
    return this;
}
Also used : BaseSource(org.apache.qpid.server.protocol.v1_0.type.BaseSource) Source(org.apache.qpid.server.protocol.v1_0.type.messaging.Source)

Example 10 with Source

use of org.apache.qpid.server.protocol.v1_0.type.messaging.Source 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)

Aggregations

Source (org.apache.qpid.server.protocol.v1_0.type.messaging.Source)32 BaseSource (org.apache.qpid.server.protocol.v1_0.type.BaseSource)16 Attach (org.apache.qpid.server.protocol.v1_0.type.transport.Attach)15 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)14 Test (org.junit.Test)14 Error (org.apache.qpid.server.protocol.v1_0.type.transport.Error)13 FrameTransport (org.apache.qpid.tests.protocol.v1_0.FrameTransport)13 Interaction (org.apache.qpid.tests.protocol.v1_0.Interaction)11 Target (org.apache.qpid.server.protocol.v1_0.type.messaging.Target)10 TransactionError (org.apache.qpid.server.protocol.v1_0.type.transaction.TransactionError)10 AmqpError (org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError)10 MessageSource (org.apache.qpid.server.message.MessageSource)9 LinkKey (org.apache.qpid.server.protocol.v1_0.LinkKey)8 Begin (org.apache.qpid.server.protocol.v1_0.type.transport.Begin)8 StoreException (org.apache.qpid.server.store.StoreException)8 Symbol (org.apache.qpid.server.protocol.v1_0.type.Symbol)7 Flow (org.apache.qpid.server.protocol.v1_0.type.transport.Flow)7 NamedAddressSpace (org.apache.qpid.server.model.NamedAddressSpace)6 AmqpErrorException (org.apache.qpid.server.protocol.v1_0.type.AmqpErrorException)6 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)6