Search in sources :

Example 1 with ExchangeDelete

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)));
    }
}
Also used : ExchangeQueryResult(org.apache.qpid.server.protocol.v0_10.transport.ExchangeQueryResult) ExecutionResult(org.apache.qpid.server.protocol.v0_10.transport.ExecutionResult) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 2 with ExchangeDelete

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());
        }
    }));
}
Also used : ArgumentMatcher(org.mockito.ArgumentMatcher) ExecutionException(org.apache.qpid.server.protocol.v0_10.transport.ExecutionException) ExchangeDelete(org.apache.qpid.server.protocol.v0_10.transport.ExchangeDelete)

Example 3 with ExchangeDelete

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();
}
Also used : ExchangeDelete(org.apache.qpid.server.protocol.v0_10.transport.ExchangeDelete)

Aggregations

ExchangeDelete (org.apache.qpid.server.protocol.v0_10.transport.ExchangeDelete)2 ExchangeQueryResult (org.apache.qpid.server.protocol.v0_10.transport.ExchangeQueryResult)1 ExecutionException (org.apache.qpid.server.protocol.v0_10.transport.ExecutionException)1 ExecutionResult (org.apache.qpid.server.protocol.v0_10.transport.ExecutionResult)1 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)1 Test (org.junit.Test)1 ArgumentMatcher (org.mockito.ArgumentMatcher)1