Search in sources :

Example 11 with ExchangeInfo

use of com.rabbitmq.http.client.domain.ExchangeInfo in project service-api by reportportal.

the class AnalyzerUtilsTest method testDefaultValues.

@Test
void testDefaultValues() {
    ExchangeInfo mock = mock(ExchangeInfo.class);
    when(mock.getArguments()).thenReturn(Collections.emptyMap());
    assertEquals(Integer.MAX_VALUE, AnalyzerUtils.EXCHANGE_PRIORITY.applyAsInt(mock));
    assertFalse(AnalyzerUtils.DOES_SUPPORT_INDEX.test(mock));
}
Also used : ExchangeInfo(com.rabbitmq.http.client.domain.ExchangeInfo) Test(org.junit.jupiter.api.Test)

Example 12 with ExchangeInfo

use of com.rabbitmq.http.client.domain.ExchangeInfo in project service-api by reportportal.

the class AnalyzerUtilsTest method testParsing.

@Test
void testParsing() {
    ExchangeInfo mock = mock(ExchangeInfo.class);
    when(mock.getArguments()).thenReturn(ImmutableMap.<String, Object>builder().put(ANALYZER_PRIORITY, 1).put(ANALYZER_INDEX, true).build());
    assertEquals(1, AnalyzerUtils.EXCHANGE_PRIORITY.applyAsInt(mock));
    assertTrue(AnalyzerUtils.DOES_SUPPORT_INDEX.test(mock));
}
Also used : ExchangeInfo(com.rabbitmq.http.client.domain.ExchangeInfo) Test(org.junit.jupiter.api.Test)

Example 13 with ExchangeInfo

use of com.rabbitmq.http.client.domain.ExchangeInfo in project spring-amqp by spring-projects.

the class RabbitRestApiTests method testSpecificExchange.

@Test
public void testSpecificExchange() {
    RabbitAdmin admin = new RabbitAdmin(connectionFactory);
    Map<String, Object> args = Collections.<String, Object>singletonMap("alternate-exchange", "");
    Exchange exchange = new DirectExchange(UUID.randomUUID().toString(), true, true, args);
    admin.declareExchange(exchange);
    ExchangeInfo exchangeOut = this.rabbitRestClient.getExchange("/", exchange.getName());
    assertThat(exchangeOut.isDurable()).isTrue();
    assertThat(exchangeOut.isAutoDelete()).isTrue();
    assertThat(exchangeOut.getName()).isEqualTo(exchange.getName());
    assertThat(exchangeOut.getArguments()).isEqualTo(args);
    admin.deleteExchange(exchange.getName());
}
Also used : Exchange(org.springframework.amqp.core.Exchange) DirectExchange(org.springframework.amqp.core.DirectExchange) DirectExchange(org.springframework.amqp.core.DirectExchange) ExchangeInfo(com.rabbitmq.http.client.domain.ExchangeInfo) Test(org.junit.jupiter.api.Test)

Example 14 with ExchangeInfo

use of com.rabbitmq.http.client.domain.ExchangeInfo in project spring-amqp by spring-projects.

the class RabbitRestApiTests method testDeleteExchange.

@Test
public void testDeleteExchange() {
    String exchangeName = "testExchange";
    Exchange testExchange = new DirectExchange(exchangeName);
    ExchangeInfo info = new ExchangeInfo();
    info.setArguments(testExchange.getArguments());
    info.setAutoDelete(testExchange.isAutoDelete());
    info.setDurable(testExchange.isDurable());
    info.setType(testExchange.getType());
    this.rabbitRestClient.declareExchange("/", testExchange.getName(), info);
    ExchangeInfo exchangeToAssert = this.rabbitRestClient.getExchange("/", exchangeName);
    assertThat(exchangeToAssert.getName()).isEqualTo(testExchange.getName());
    assertThat(exchangeToAssert.getType()).isEqualTo(testExchange.getType());
    this.rabbitRestClient.deleteExchange("/", testExchange.getName());
    // 6.0.0 REST compatibility
    // assertThat(this.rabbitRestClient.getExchange("/", exchangeName)).isNull();
    RabbitTemplate template = new RabbitTemplate(this.connectionFactory);
    assertThatExceptionOfType(AmqpException.class).isThrownBy(() -> template.execute(channel -> channel.exchangeDeclarePassive(exchangeName))).withCauseExactlyInstanceOf(IOException.class);
}
Also used : Exchange(org.springframework.amqp.core.Exchange) DirectExchange(org.springframework.amqp.core.DirectExchange) DirectExchange(org.springframework.amqp.core.DirectExchange) ExchangeInfo(com.rabbitmq.http.client.domain.ExchangeInfo) Test(org.junit.jupiter.api.Test)

Aggregations

ExchangeInfo (com.rabbitmq.http.client.domain.ExchangeInfo)14 Test (org.junit.jupiter.api.Test)12 Client (com.rabbitmq.http.client.Client)4 DirectExchange (org.springframework.amqp.core.DirectExchange)4 BindingInfo (com.rabbitmq.http.client.domain.BindingInfo)3 QueueInfo (com.rabbitmq.http.client.domain.QueueInfo)3 AmqpOutboundEndpoint (org.springframework.integration.amqp.outbound.AmqpOutboundEndpoint)3 BaseMvcTest (com.epam.ta.reportportal.ws.BaseMvcTest)2 LongString (com.rabbitmq.client.LongString)2 Exchange (org.springframework.amqp.core.Exchange)2 SimpleMessageListenerContainer (org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer)2 RabbitConsumerProperties (org.springframework.cloud.stream.binder.rabbit.properties.RabbitConsumerProperties)2 BindingProperties (org.springframework.cloud.stream.config.BindingProperties)2 Lifecycle (org.springframework.context.Lifecycle)2 MessageChannel (org.springframework.messaging.MessageChannel)2 HashMap (java.util.HashMap)1 AmqpIOException (org.springframework.amqp.AmqpIOException)1 AbstractExchange (org.springframework.amqp.core.AbstractExchange)1 AnonymousQueue (org.springframework.amqp.core.AnonymousQueue)1 Binding (org.springframework.amqp.core.Binding)1