use of org.apache.qpid.server.protocol.v0_10.transport.ExchangeDelete in project qpid-broker-j by apache.
the class ExchangeTest method exchangeDelete.
@Test
@SpecificationTest(section = "10.exchange.delete", description = "delete an exchange")
public void exchangeDelete() throws Exception {
String exchangeName = "myexch";
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction = transport.newInteraction();
interaction.openAnonymousConnection().channelId(1).attachSession(SESSION_NAME).exchange().declareExchange(exchangeName).declareType(ExchangeDefaults.DIRECT_EXCHANGE_CLASS).declareId(0).declare().session().flushCompleted().flush().consumeResponse(SessionCompleted.class);
interaction.exchange().deleteExchange(exchangeName).deleteId(1).delete().session().flushCompleted().flush().consumeResponse(SessionCompleted.class);
ExecutionResult result = interaction.exchange().queryExchange(exchangeName).queryId(2).query().session().flushCompleted().flush().consumeResponse(SessionCommandPoint.class).consumeResponse().getLatestResponse(ExecutionResult.class);
ExchangeQueryResult queryResult = (ExchangeQueryResult) result.getValue();
assertThat(queryResult.getNotFound(), is(equalTo(true)));
}
}
use of org.apache.qpid.server.protocol.v0_10.transport.ExchangeDelete in project qpid-broker-j by apache.
the class ServerSessionDelegateTest method testExchangeDeleteWhenIfUsedIsSetAndExchangeHasBindings.
public void testExchangeDeleteWhenIfUsedIsSetAndExchangeHasBindings() throws Exception {
Exchange<?> exchange = mock(Exchange.class);
when(exchange.hasBindings()).thenReturn(true);
doReturn(exchange).when(_host).getAttainedMessageDestination(getTestName());
final ExchangeDelete method = new ExchangeDelete(getTestName(), Option.IF_UNUSED);
_delegate.exchangeDelete(_session, method);
verify(_session).invoke(argThat(new ArgumentMatcher<ExecutionException>() {
@Override
public boolean matches(Object object) {
ExecutionException exception = (ExecutionException) object;
return exception.getErrorCode() == ExecutionErrorCode.PRECONDITION_FAILED && "Exchange has bindings".equals(exception.getDescription());
}
}));
}
use of org.apache.qpid.server.protocol.v0_10.transport.ExchangeDelete in project qpid-broker-j by apache.
the class ServerSessionDelegateTest method testExchangeDeleteWhenIfUsedIsSetAndExchangeHasNoBinding.
public void testExchangeDeleteWhenIfUsedIsSetAndExchangeHasNoBinding() throws Exception {
Exchange<?> exchange = mock(Exchange.class);
when(exchange.hasBindings()).thenReturn(false);
doReturn(exchange).when(_host).getAttainedMessageDestination(getTestName());
final ExchangeDelete method = new ExchangeDelete(getTestName(), Option.IF_UNUSED);
_delegate.exchangeDelete(_session, method);
verify(exchange).delete();
}
Aggregations