use of org.apache.qpid.server.protocol.v0_10.transport.ExchangeBoundResult in project qpid-broker-j by apache.
the class ExchangeTest method exchangeBindMultipleBindings.
@Test
@SpecificationTest(section = "10.exchange.bind", description = " Bindings between durable queues and durable exchanges are automatically durable and" + " the server MUST restore such bindings after a server restart.")
public void exchangeBindMultipleBindings() throws Exception {
assumeThat(getBrokerAdmin().supportsRestart(), Matchers.is(true));
try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
final Interaction interaction = transport.newInteraction();
interaction.negotiateOpen().channelId(1).attachSession(SESSION_NAME).queue().declareQueue(BrokerAdmin.TEST_QUEUE_NAME).declareId(0).declareDurable(true).declare().session().flushCompleted().flush().consumeResponse(SessionCompleted.class).exchange().bindId(1).bindExchange("amq.direct").bindQueue(BrokerAdmin.TEST_QUEUE_NAME).bindBindingKey("bk").bind().session().flushCompleted().flush().consumeResponse(SessionCompleted.class);
}
getBrokerAdmin().restart();
try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
final Interaction interaction = transport.newInteraction();
ExecutionResult execResult = interaction.negotiateOpen().channelId(1).attachSession(SESSION_NAME).exchange().boundId(0).boundExchange("amq.direct").boundQueue(BrokerAdmin.TEST_QUEUE_NAME).boundBindingKey("bk").bound().session().flushCompleted().flush().consumeResponse(SessionCommandPoint.class).consumeResponse().getLatestResponse(ExecutionResult.class);
assertThat(execResult.getValue(), is(instanceOf(ExchangeBoundResult.class)));
ExchangeBoundResult result = (ExchangeBoundResult) execResult.getValue();
assertThat(result.getExchangeNotFound(), is(equalTo(false)));
assertThat(result.getQueueNotFound(), is(equalTo(false)));
assertThat(result.getKeyNotMatched(), is(equalTo(false)));
}
}
use of org.apache.qpid.server.protocol.v0_10.transport.ExchangeBoundResult in project qpid-broker-j by apache.
the class ExchangeTest method exchangeBindIgnoreDuplicates.
@Test
@SpecificationTest(section = "10.exchange.bind", description = "A server MUST ignore duplicate bindings - that is, two or more bind commands with the" + " same exchange, queue, and binding-key - without treating these as an error." + " The value of the arguments used for the binding MUST NOT be altered" + " by subsequent binding requests.")
public void exchangeBindIgnoreDuplicates() throws Exception {
getBrokerAdmin().createQueue(BrokerAdmin.TEST_QUEUE_NAME);
try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
final Interaction interaction = transport.newInteraction();
interaction.negotiateOpen().channelId(1).attachSession(SESSION_NAME).exchange().bindId(0).bindExchange("amq.direct").bindQueue(BrokerAdmin.TEST_QUEUE_NAME).bindBindingKey("bk").bind().session().flushCompleted().flush().consumeResponse(SessionCompleted.class).exchange().bindId(1).bindExchange("amq.direct").bindQueue(BrokerAdmin.TEST_QUEUE_NAME).bindBindingKey("bk").bindArguments(Collections.singletonMap(JMS_SELECTOR.name(), "name='a'")).bind().session().flushCompleted().flush().consumeResponse(SessionCompleted.class);
ExecutionResult execResult = interaction.exchange().boundId(2).boundExchange("amq.direct").boundQueue(BrokerAdmin.TEST_QUEUE_NAME).boundBindingKey("bk").boundArguments(Collections.singletonMap(JMS_SELECTOR.name(), "name='a'")).bound().session().flushCompleted().flush().consumeResponse(SessionCommandPoint.class).consumeResponse().getLatestResponse(ExecutionResult.class);
assertThat(execResult.getValue(), is(instanceOf(ExchangeBoundResult.class)));
ExchangeBoundResult result = (ExchangeBoundResult) execResult.getValue();
assertThat(result.getExchangeNotFound(), is(equalTo(false)));
assertThat(result.getQueueNotFound(), is(equalTo(false)));
assertThat(result.getKeyNotMatched(), is(equalTo(false)));
assertThat(result.getArgsNotMatched(), is(equalTo(true)));
}
}
use of org.apache.qpid.server.protocol.v0_10.transport.ExchangeBoundResult in project qpid-broker-j by apache.
the class ExchangeTest method exchangeBind.
@Test
@SpecificationTest(section = "10.exchange.bind", description = "This command binds a queue to an exchange." + " Until a queue is bound it will not receive any messages.")
public void exchangeBind() throws Exception {
getBrokerAdmin().createQueue(BrokerAdmin.TEST_QUEUE_NAME);
try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
final Interaction interaction = transport.newInteraction();
interaction.negotiateOpen().channelId(1).attachSession(SESSION_NAME).exchange().bindId(0).bindExchange("amq.direct").bindQueue(BrokerAdmin.TEST_QUEUE_NAME).bindBindingKey("bk").bind().session().flushCompleted().flush().consumeResponse(SessionCompleted.class);
ExecutionResult execResult = interaction.exchange().boundId(2).boundExchange("amq.direct").boundQueue(BrokerAdmin.TEST_QUEUE_NAME).boundBindingKey("bk").bound().session().flushCompleted().flush().consumeResponse(SessionCommandPoint.class).consumeResponse().getLatestResponse(ExecutionResult.class);
assertThat(execResult.getValue(), is(instanceOf(ExchangeBoundResult.class)));
ExchangeBoundResult result = (ExchangeBoundResult) execResult.getValue();
assertThat(result.getExchangeNotFound(), is(equalTo(false)));
assertThat(result.getQueueNotFound(), is(equalTo(false)));
assertThat(result.getKeyNotMatched(), is(equalTo(false)));
}
}
use of org.apache.qpid.server.protocol.v0_10.transport.ExchangeBoundResult in project qpid-broker-j by apache.
the class ExchangeTest method exchangeUnbind.
@Test
@SpecificationTest(section = "11.exchange.unbind", description = "This command unbinds a queue from an exchange.")
public void exchangeUnbind() throws Exception {
getBrokerAdmin().createQueue(BrokerAdmin.TEST_QUEUE_NAME);
try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
final Interaction interaction = transport.newInteraction();
interaction.negotiateOpen().channelId(1).attachSession(SESSION_NAME).exchange().bindId(0).bindExchange("amq.direct").bindQueue(BrokerAdmin.TEST_QUEUE_NAME).bindBindingKey("bk").bind().session().flushCompleted().flush().consumeResponse(SessionCompleted.class).exchange().unbindId(1).unbindExchange("amq.direct").unbindQueue(BrokerAdmin.TEST_QUEUE_NAME).unbindBindingKey("bk").unbind().session().flushCompleted().flush().consumeResponse(SessionCompleted.class);
ExecutionResult execResult = interaction.exchange().boundId(2).boundExchange("amq.direct").boundQueue(BrokerAdmin.TEST_QUEUE_NAME).boundBindingKey("bk").bound().session().flushCompleted().flush().consumeResponse(SessionCommandPoint.class).consumeResponse().getLatestResponse(ExecutionResult.class);
assertThat(execResult.getValue(), is(instanceOf(ExchangeBoundResult.class)));
ExchangeBoundResult result = (ExchangeBoundResult) execResult.getValue();
assertThat(result.getExchangeNotFound(), is(equalTo(false)));
assertThat(result.getQueueNotFound(), is(equalTo(false)));
assertThat(result.getKeyNotMatched(), is(equalTo(true)));
}
}
Aggregations