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
}
}
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;
}
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;
}
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;
}
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)));
}
}
Aggregations