Search in sources :

Example 26 with LogAccessor

use of org.springframework.core.log.LogAccessor in project spring-integration by spring-projects.

the class MqttAdapterTests method testDifferentQos.

@Test
public void testDifferentQos() throws Exception {
    DefaultMqttPahoClientFactory factory = new DefaultMqttPahoClientFactory();
    MqttConnectOptions connectOptions = new MqttConnectOptions();
    connectOptions.setCleanSession(false);
    connectOptions.setConnectionTimeout(23);
    connectOptions.setKeepAliveInterval(45);
    connectOptions.setPassword("pass".toCharArray());
    MemoryPersistence persistence = new MemoryPersistence();
    factory.setPersistence(persistence);
    final SocketFactory socketFactory = SocketFactory.getDefault();
    connectOptions.setSocketFactory(socketFactory);
    final Properties props = new Properties();
    connectOptions.setSSLProperties(props);
    connectOptions.setUserName("user");
    connectOptions.setWill("foo", "bar".getBytes(), 2, true);
    factory = spy(factory);
    MqttAsyncClient aClient = mock(MqttAsyncClient.class);
    final MqttClient client = mock(MqttClient.class);
    willAnswer(invocation -> client).given(factory).getClientInstance(anyString(), anyString());
    given(client.isConnected()).willReturn(true);
    new DirectFieldAccessor(client).setPropertyValue("aClient", aClient);
    willAnswer(new CallsRealMethods()).given(client).connect(any(MqttConnectOptions.class));
    willAnswer(new CallsRealMethods()).given(client).subscribe(any(String[].class), any(int[].class));
    willAnswer(new CallsRealMethods()).given(client).subscribe(any(String[].class), any(int[].class), isNull());
    willReturn(alwaysComplete).given(aClient).connect(any(MqttConnectOptions.class), any(), any());
    IMqttToken token = mock(IMqttToken.class);
    given(token.getGrantedQos()).willReturn(new int[] { 2, 0 });
    willReturn(token).given(aClient).subscribe(any(String[].class), any(int[].class), isNull(), isNull(), any());
    MqttPahoMessageDrivenChannelAdapter adapter = new MqttPahoMessageDrivenChannelAdapter("foo", "bar", factory, "baz", "fix");
    AtomicReference<Method> method = new AtomicReference<>();
    ReflectionUtils.doWithMethods(MqttPahoMessageDrivenChannelAdapter.class, m -> {
        m.setAccessible(true);
        method.set(m);
    }, m -> m.getName().equals("connectAndSubscribe"));
    assertThat(method.get()).isNotNull();
    LogAccessor logger = spy(TestUtils.getPropertyValue(adapter, "logger", LogAccessor.class));
    new DirectFieldAccessor(adapter).setPropertyValue("logger", logger);
    given(logger.isWarnEnabled()).willReturn(true);
    method.get().invoke(adapter);
    verify(logger, atLeastOnce()).warn(ArgumentMatchers.<Supplier<? extends CharSequence>>argThat(logMessage -> logMessage.get().equals("Granted QOS different to Requested QOS; topics: [baz, fix] " + "requested: [1, 1] granted: [2, 0]")));
    verify(client).setTimeToWait(30_000L);
    new DirectFieldAccessor(adapter).setPropertyValue("running", Boolean.TRUE);
    adapter.stop();
    verify(client).disconnectForcibly(5_000L);
}
Also used : MqttMessage(org.eclipse.paho.client.mqttv3.MqttMessage) ArgumentMatchers(org.mockito.ArgumentMatchers) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Date(java.util.Date) MqttConnectOptions(org.eclipse.paho.client.mqttv3.MqttConnectOptions) MqttPahoMessageHandler(org.springframework.integration.mqtt.outbound.MqttPahoMessageHandler) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) DefaultPahoMessageConverter(org.springframework.integration.mqtt.support.DefaultPahoMessageConverter) ErrorMessage(org.springframework.messaging.support.ErrorMessage) MessageProcessor(org.springframework.integration.handler.MessageProcessor) BDDMockito.willReturn(org.mockito.BDDMockito.willReturn) NullChannel(org.springframework.integration.channel.NullChannel) BDDMockito.given(org.mockito.BDDMockito.given) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) MessageHandlingException(org.springframework.messaging.MessageHandlingException) ApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher) Method(java.lang.reflect.Method) BDDMockito.willThrow(org.mockito.BDDMockito.willThrow) CallsRealMethods(org.mockito.internal.stubbing.answers.CallsRealMethods) Mockito.atLeastOnce(org.mockito.Mockito.atLeastOnce) MqttException(org.eclipse.paho.client.mqttv3.MqttException) ConsumerStopAction(org.springframework.integration.mqtt.core.ConsumerStopAction) TaskScheduler(org.springframework.scheduling.TaskScheduler) BlockingQueue(java.util.concurrent.BlockingQueue) LogAccessor(org.springframework.core.log.LogAccessor) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) MqttAsyncClient(org.eclipse.paho.client.mqttv3.MqttAsyncClient) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) InvocationTargetException(java.lang.reflect.InvocationTargetException) SocketFactory(javax.net.SocketFactory) Test(org.junit.jupiter.api.Test) Configuration(org.springframework.context.annotation.Configuration) CountDownLatch(java.util.concurrent.CountDownLatch) Assertions.fail(org.assertj.core.api.Assertions.fail) IMqttToken(org.eclipse.paho.client.mqttv3.IMqttToken) Mockito.mock(org.mockito.Mockito.mock) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) QueueChannel(org.springframework.integration.channel.QueueChannel) ArgumentMatchers.anyLong(org.mockito.ArgumentMatchers.anyLong) MqttCallback(org.eclipse.paho.client.mqttv3.MqttCallback) MqttHeaderAccessor(org.springframework.integration.mqtt.support.MqttHeaderAccessor) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) Mockito.spy(org.mockito.Mockito.spy) TestUtils(org.springframework.integration.test.util.TestUtils) AtomicReference(java.util.concurrent.atomic.AtomicReference) Supplier(java.util.function.Supplier) MqttIntegrationEvent(org.springframework.integration.mqtt.event.MqttIntegrationEvent) DefaultMqttPahoClientFactory(org.springframework.integration.mqtt.core.DefaultMqttPahoClientFactory) ArgumentCaptor(org.mockito.ArgumentCaptor) Assertions.assertThatExceptionOfType(org.assertj.core.api.Assertions.assertThatExceptionOfType) MemoryPersistence(org.eclipse.paho.client.mqttv3.persist.MemoryPersistence) IMqttAsyncClient(org.eclipse.paho.client.mqttv3.IMqttAsyncClient) Message(org.springframework.messaging.Message) AbstractIntegrationMessageBuilder(org.springframework.integration.support.AbstractIntegrationMessageBuilder) ThreadPoolTaskScheduler(org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler) MqttDeliveryToken(org.eclipse.paho.client.mqttv3.MqttDeliveryToken) MqttClient(org.eclipse.paho.client.mqttv3.MqttClient) ArgumentMatchers.isNull(org.mockito.ArgumentMatchers.isNull) ProxyFactoryBean(org.springframework.aop.framework.ProxyFactoryBean) Properties(java.util.Properties) IMqttClient(org.eclipse.paho.client.mqttv3.IMqttClient) MqttMessageConverter(org.springframework.integration.mqtt.support.MqttMessageConverter) StaticMessageHeaderAccessor(org.springframework.integration.StaticMessageHeaderAccessor) Mockito.times(org.mockito.Mockito.times) MqttSubscribedEvent(org.springframework.integration.mqtt.event.MqttSubscribedEvent) MessageHeaders(org.springframework.messaging.MessageHeaders) BDDMockito.willAnswer(org.mockito.BDDMockito.willAnswer) Mockito.verify(org.mockito.Mockito.verify) TimeUnit(java.util.concurrent.TimeUnit) MethodInterceptor(org.aopalliance.intercept.MethodInterceptor) Mockito.never(org.mockito.Mockito.never) MqttPahoMessageDrivenChannelAdapter(org.springframework.integration.mqtt.inbound.MqttPahoMessageDrivenChannelAdapter) ReflectionUtils(org.springframework.util.ReflectionUtils) BeanFactory(org.springframework.beans.factory.BeanFactory) MqttConnectionFailedEvent(org.springframework.integration.mqtt.event.MqttConnectionFailedEvent) Condition(org.assertj.core.api.Condition) Bean(org.springframework.context.annotation.Bean) GenericMessage(org.springframework.messaging.support.GenericMessage) MqttToken(org.eclipse.paho.client.mqttv3.MqttToken) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) DefaultMqttPahoClientFactory(org.springframework.integration.mqtt.core.DefaultMqttPahoClientFactory) MemoryPersistence(org.eclipse.paho.client.mqttv3.persist.MemoryPersistence) SocketFactory(javax.net.SocketFactory) IMqttToken(org.eclipse.paho.client.mqttv3.IMqttToken) AtomicReference(java.util.concurrent.atomic.AtomicReference) Method(java.lang.reflect.Method) Properties(java.util.Properties) MqttAsyncClient(org.eclipse.paho.client.mqttv3.MqttAsyncClient) IMqttAsyncClient(org.eclipse.paho.client.mqttv3.IMqttAsyncClient) MqttClient(org.eclipse.paho.client.mqttv3.MqttClient) IMqttClient(org.eclipse.paho.client.mqttv3.IMqttClient) MqttPahoMessageDrivenChannelAdapter(org.springframework.integration.mqtt.inbound.MqttPahoMessageDrivenChannelAdapter) CallsRealMethods(org.mockito.internal.stubbing.answers.CallsRealMethods) MqttConnectOptions(org.eclipse.paho.client.mqttv3.MqttConnectOptions) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) LogAccessor(org.springframework.core.log.LogAccessor) Test(org.junit.jupiter.api.Test)

Example 27 with LogAccessor

use of org.springframework.core.log.LogAccessor in project spring-integration by spring-projects.

the class MqttAdapterTests method testReconnect.

@Test
public void testReconnect() throws Exception {
    final IMqttClient client = mock(IMqttClient.class);
    MqttPahoMessageDrivenChannelAdapter adapter = buildAdapterIn(client, null, ConsumerStopAction.UNSUBSCRIBE_NEVER);
    adapter.setRecoveryInterval(10);
    LogAccessor logger = spy(TestUtils.getPropertyValue(adapter, "logger", LogAccessor.class));
    new DirectFieldAccessor(adapter).setPropertyValue("logger", logger);
    given(logger.isDebugEnabled()).willReturn(true);
    final AtomicInteger attemptingReconnectCount = new AtomicInteger();
    willAnswer(i -> {
        if (attemptingReconnectCount.getAndIncrement() == 0) {
            adapter.connectionLost(new RuntimeException("while schedule running"));
        }
        i.callRealMethod();
        return null;
    }).given(logger).debug("Attempting reconnect");
    ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
    taskScheduler.initialize();
    adapter.setTaskScheduler(taskScheduler);
    adapter.start();
    adapter.connectionLost(new RuntimeException("initial"));
    verify(client).close();
    Thread.sleep(1000);
    // the following assertion should be equalTo, but leq to protect against a slow CI server
    assertThat(attemptingReconnectCount.get()).isLessThanOrEqualTo(2);
    AtomicReference<Object> failed = new AtomicReference<>();
    adapter.setApplicationEventPublisher(failed::set);
    adapter.connectionLost(new IllegalStateException());
    assertThat(failed.get()).isInstanceOf(MqttConnectionFailedEvent.class);
    adapter.stop();
    taskScheduler.destroy();
}
Also used : MqttPahoMessageDrivenChannelAdapter(org.springframework.integration.mqtt.inbound.MqttPahoMessageDrivenChannelAdapter) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) AtomicReference(java.util.concurrent.atomic.AtomicReference) LogAccessor(org.springframework.core.log.LogAccessor) IMqttClient(org.eclipse.paho.client.mqttv3.IMqttClient) ThreadPoolTaskScheduler(org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler) Test(org.junit.jupiter.api.Test)

Example 28 with LogAccessor

use of org.springframework.core.log.LogAccessor in project spring-integration by spring-projects.

the class LoggingHandlerTests method testChangeLevel.

@Test
@SuppressWarnings("unchecked")
public void testChangeLevel() {
    LoggingHandler loggingHandler = new LoggingHandler(Level.INFO);
    loggingHandler.setBeanFactory(mock(BeanFactory.class));
    loggingHandler.afterPropertiesSet();
    DirectFieldAccessor accessor = new DirectFieldAccessor(loggingHandler);
    LogAccessor log = (LogAccessor) accessor.getPropertyValue("messageLogger");
    log = spy(log);
    accessor.setPropertyValue("messageLogger", log);
    when(log.isInfoEnabled()).thenReturn(true);
    loggingHandler.handleMessage(new GenericMessage<>("foo"));
    verify(log, times(1)).info(any(Supplier.class));
    verify(log, never()).warn(any(Supplier.class));
    loggingHandler.setLevel(Level.WARN);
    loggingHandler.handleMessage(new GenericMessage<>("foo"));
    verify(log, times(1)).info(any(Supplier.class));
    verify(log, times(1)).warn(any(Supplier.class));
}
Also used : DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) BeanFactory(org.springframework.beans.factory.BeanFactory) Supplier(java.util.function.Supplier) LogAccessor(org.springframework.core.log.LogAccessor) Test(org.junit.jupiter.api.Test)

Example 29 with LogAccessor

use of org.springframework.core.log.LogAccessor in project spring-integration by spring-projects.

the class JsonToObjectTransformerParserTests method testDefaultObjectMapper.

@Test
@SuppressWarnings("unchecked")
public void testDefaultObjectMapper() {
    Object jsonToObjectTransformer = TestUtils.getPropertyValue(this.defaultJacksonMapperTransformer, "transformer");
    assertThat(TestUtils.getPropertyValue(jsonToObjectTransformer, "jsonObjectMapper").getClass()).isEqualTo(Jackson2JsonObjectMapper.class);
    DirectFieldAccessor dfa = new DirectFieldAccessor(jsonToObjectTransformer);
    LogAccessor logger = (LogAccessor) spy(dfa.getPropertyValue("logger"));
    dfa.setPropertyValue("logger", logger);
    String jsonString = "{\"firstName\":\"John\",\"lastName\":\"Doe\",\"age\":42," + "\"address\":{\"number\":123,\"street\":\"Main Street\"}}";
    QueueChannel replyChannel = new QueueChannel();
    Message<String> message = MessageBuilder.withPayload(jsonString).setReplyChannel(replyChannel).build();
    this.defaultObjectMapperInput.send(message);
    Message<?> reply = replyChannel.receive(0);
    assertThat(reply).isNotNull();
    assertThat(reply.getPayload()).isNotNull();
    assertThat(reply.getPayload().getClass()).isEqualTo(TestPerson.class);
    TestPerson person = (TestPerson) reply.getPayload();
    assertThat(person.getFirstName()).isEqualTo("John");
    assertThat(person.getLastName()).isEqualTo("Doe");
    assertThat(person.getAge()).isEqualTo(42);
    assertThat(person.getAddress().toString()).isEqualTo("123 Main Street");
    ArgumentCaptor<Supplier<String>> argumentCaptor = ArgumentCaptor.forClass(Supplier.class);
    verify(logger).debug(any(Exception.class), argumentCaptor.capture());
    String logMessage = argumentCaptor.getValue().get();
    assertThat(logMessage).startsWith("Cannot build a ResolvableType from the request message");
}
Also used : QueueChannel(org.springframework.integration.channel.QueueChannel) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) Supplier(java.util.function.Supplier) LogAccessor(org.springframework.core.log.LogAccessor) Test(org.junit.jupiter.api.Test)

Example 30 with LogAccessor

use of org.springframework.core.log.LogAccessor in project spring-integration by spring-projects.

the class AsyncAmqpGatewayTests method testConfirmsAndReturns.

@Test
void testConfirmsAndReturns() throws Exception {
    CachingConnectionFactory ccf = new CachingConnectionFactory("localhost");
    ccf.setPublisherConfirmType(CachingConnectionFactory.ConfirmType.CORRELATED);
    ccf.setPublisherReturns(true);
    RabbitTemplate template = new RabbitTemplate(ccf);
    SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(ccf);
    container.setBeanName("replyContainer");
    container.setQueueNames("asyncRQ1");
    container.afterPropertiesSet();
    container.start();
    AsyncRabbitTemplate asyncTemplate = new AsyncRabbitTemplate(template, container);
    asyncTemplate.setEnableConfirms(true);
    asyncTemplate.setMandatory(true);
    SimpleMessageListenerContainer receiver = new SimpleMessageListenerContainer(ccf);
    receiver.setBeanName("receiver");
    receiver.setQueueNames("asyncQ1");
    final CountDownLatch waitForAckBeforeReplying = new CountDownLatch(1);
    MessageListenerAdapter messageListener = new MessageListenerAdapter((ReplyingMessageListener<String, String>) foo -> {
        try {
            waitForAckBeforeReplying.await(10, TimeUnit.SECONDS);
        } catch (@SuppressWarnings("unused") InterruptedException e) {
            Thread.currentThread().interrupt();
        }
        return foo.toUpperCase();
    });
    receiver.setMessageListener(messageListener);
    receiver.afterPropertiesSet();
    receiver.start();
    AsyncAmqpOutboundGateway gateway = new AsyncAmqpOutboundGateway(asyncTemplate);
    LogAccessor logger = spy(TestUtils.getPropertyValue(gateway, "logger", LogAccessor.class));
    given(logger.isDebugEnabled()).willReturn(true);
    final CountDownLatch replyTimeoutLatch = new CountDownLatch(1);
    willAnswer(invocation -> {
        invocation.callRealMethod();
        replyTimeoutLatch.countDown();
        return null;
    }).given(logger).debug(ArgumentMatchers.<Supplier<String>>argThat(logMessage -> logMessage.get().startsWith("Reply not required and async timeout for")));
    new DirectFieldAccessor(gateway).setPropertyValue("logger", logger);
    QueueChannel outputChannel = new QueueChannel();
    outputChannel.setBeanName("output");
    QueueChannel returnChannel = new QueueChannel();
    returnChannel.setBeanName("returns");
    QueueChannel ackChannel = new QueueChannel();
    ackChannel.setBeanName("acks");
    QueueChannel errorChannel = new QueueChannel();
    errorChannel.setBeanName("errors");
    gateway.setOutputChannel(outputChannel);
    gateway.setReturnChannel(returnChannel);
    gateway.setConfirmAckChannel(ackChannel);
    gateway.setConfirmNackChannel(ackChannel);
    gateway.setConfirmCorrelationExpressionString("#this");
    gateway.setExchangeName("");
    gateway.setRoutingKey("asyncQ1");
    gateway.setBeanFactory(mock(BeanFactory.class));
    gateway.afterPropertiesSet();
    gateway.start();
    Message<?> message = MessageBuilder.withPayload("foo").setErrorChannel(errorChannel).build();
    gateway.handleMessage(message);
    Message<?> ack = ackChannel.receive(10000);
    assertThat(ack).isNotNull();
    assertThat(ack.getPayload()).isEqualTo("foo");
    assertThat(ack.getHeaders().get(AmqpHeaders.PUBLISH_CONFIRM)).isEqualTo(true);
    waitForAckBeforeReplying.countDown();
    Message<?> received = outputChannel.receive(10000);
    assertThat(received).isNotNull();
    assertThat(received.getPayload()).isEqualTo("FOO");
    // timeout tests
    asyncTemplate.setReceiveTimeout(10);
    receiver.setMessageListener(message1 -> {
    });
    // reply timeout with no requiresReply
    message = MessageBuilder.withPayload("bar").setErrorChannel(errorChannel).build();
    gateway.handleMessage(message);
    assertThat(replyTimeoutLatch.await(10, TimeUnit.SECONDS)).isTrue();
    // reply timeout with requiresReply
    gateway.setRequiresReply(true);
    message = MessageBuilder.withPayload("baz").setErrorChannel(errorChannel).build();
    gateway.handleMessage(message);
    received = errorChannel.receive(10000);
    assertThat(received).isInstanceOf(ErrorMessage.class);
    ErrorMessage error = (ErrorMessage) received;
    assertThat(error.getPayload()).isInstanceOf(MessagingException.class);
    assertThat(error.getPayload().getCause()).isInstanceOf(AmqpReplyTimeoutException.class);
    asyncTemplate.setReceiveTimeout(30000);
    receiver.setMessageListener(messageListener);
    // error on sending result
    DirectChannel errorForce = new DirectChannel();
    errorForce.setBeanName("errorForce");
    errorForce.subscribe(message1 -> {
        throw new RuntimeException("intentional");
    });
    gateway.setOutputChannel(errorForce);
    message = MessageBuilder.withPayload("qux").setErrorChannel(errorChannel).build();
    gateway.handleMessage(message);
    received = errorChannel.receive(10000);
    assertThat(received).isInstanceOf(ErrorMessage.class);
    error = (ErrorMessage) received;
    assertThat(error.getPayload()).isInstanceOf(MessagingException.class);
    assertThat(((MessagingException) error.getPayload()).getFailedMessage().getPayload()).isEqualTo("QUX");
    gateway.setRoutingKey(UUID.randomUUID().toString());
    message = MessageBuilder.withPayload("fiz").setErrorChannel(errorChannel).build();
    gateway.handleMessage(message);
    Message<?> returned = returnChannel.receive(10000);
    assertThat(returned).isNotNull();
    assertThat(returned).isInstanceOf(ErrorMessage.class);
    assertThat(returned.getPayload()).isInstanceOf(ReturnedAmqpMessageException.class);
    ReturnedAmqpMessageException payload = (ReturnedAmqpMessageException) returned.getPayload();
    assertThat(payload.getFailedMessage().getPayload()).isEqualTo("fiz");
    ackChannel.receive(10000);
    ackChannel.purge(null);
    asyncTemplate = mock(AsyncRabbitTemplate.class);
    RabbitMessageFuture future = asyncTemplate.new RabbitMessageFuture(null, null);
    willReturn(future).given(asyncTemplate).sendAndReceive(anyString(), anyString(), any(org.springframework.amqp.core.Message.class));
    DirectFieldAccessor dfa = new DirectFieldAccessor(future);
    dfa.setPropertyValue("nackCause", "nacknack");
    SettableListenableFuture<Boolean> confirmFuture = new SettableListenableFuture<>();
    confirmFuture.set(false);
    dfa.setPropertyValue("confirm", confirmFuture);
    new DirectFieldAccessor(gateway).setPropertyValue("template", asyncTemplate);
    message = MessageBuilder.withPayload("buz").setErrorChannel(errorChannel).build();
    gateway.handleMessage(message);
    ack = ackChannel.receive(10000);
    assertThat(ack).isNotNull();
    assertThat(returned).isInstanceOf(ErrorMessage.class);
    assertThat(returned.getPayload()).isInstanceOf(ReturnedAmqpMessageException.class);
    NackedAmqpMessageException nack = (NackedAmqpMessageException) ack.getPayload();
    assertThat(nack.getFailedMessage().getPayload()).isEqualTo("buz");
    assertThat(nack.getNackReason()).isEqualTo("nacknack");
    asyncTemplate.stop();
    receiver.stop();
    ccf.destroy();
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) QueueChannel(org.springframework.integration.channel.QueueChannel) MessagingException(org.springframework.messaging.MessagingException) ArgumentMatchers(org.mockito.ArgumentMatchers) SimpleMessageListenerContainer(org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) AsyncRabbitTemplate(org.springframework.amqp.rabbit.AsyncRabbitTemplate) CorrelationData(org.springframework.amqp.rabbit.connection.CorrelationData) SettableListenableFuture(org.springframework.util.concurrent.SettableListenableFuture) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) ErrorMessage(org.springframework.messaging.support.ErrorMessage) Mockito.spy(org.mockito.Mockito.spy) Supplier(java.util.function.Supplier) ReturnedAmqpMessageException(org.springframework.integration.amqp.support.ReturnedAmqpMessageException) MessageBuilder(org.springframework.integration.support.MessageBuilder) BDDMockito.willReturn(org.mockito.BDDMockito.willReturn) AmqpReplyTimeoutException(org.springframework.amqp.core.AmqpReplyTimeoutException) RabbitMessageFuture(org.springframework.amqp.rabbit.AsyncRabbitTemplate.RabbitMessageFuture) RabbitAvailable(org.springframework.amqp.rabbit.junit.RabbitAvailable) NullChannel(org.springframework.integration.channel.NullChannel) BDDMockito.given(org.mockito.BDDMockito.given) CachingConnectionFactory(org.springframework.amqp.rabbit.connection.CachingConnectionFactory) MessageListenerAdapter(org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter) ReplyingMessageListener(org.springframework.amqp.rabbit.listener.adapter.ReplyingMessageListener) Message(org.springframework.messaging.Message) RabbitTemplate(org.springframework.amqp.rabbit.core.RabbitTemplate) UUID(java.util.UUID) LogAccessor(org.springframework.core.log.LogAccessor) BDDMockito.willAnswer(org.mockito.BDDMockito.willAnswer) TimeUnit(java.util.concurrent.TimeUnit) Test(org.junit.jupiter.api.Test) CountDownLatch(java.util.concurrent.CountDownLatch) TestUtils(org.springframework.amqp.utils.test.TestUtils) NackedAmqpMessageException(org.springframework.integration.amqp.support.NackedAmqpMessageException) LogLevels(org.springframework.integration.test.condition.LogLevels) BeanFactory(org.springframework.beans.factory.BeanFactory) AmqpHeaders(org.springframework.amqp.support.AmqpHeaders) DirectChannel(org.springframework.integration.channel.DirectChannel) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Mockito.mock(org.mockito.Mockito.mock) SettableListenableFuture(org.springframework.util.concurrent.SettableListenableFuture) QueueChannel(org.springframework.integration.channel.QueueChannel) ErrorMessage(org.springframework.messaging.support.ErrorMessage) Message(org.springframework.messaging.Message) DirectChannel(org.springframework.integration.channel.DirectChannel) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ReturnedAmqpMessageException(org.springframework.integration.amqp.support.ReturnedAmqpMessageException) BeanFactory(org.springframework.beans.factory.BeanFactory) NackedAmqpMessageException(org.springframework.integration.amqp.support.NackedAmqpMessageException) AsyncRabbitTemplate(org.springframework.amqp.rabbit.AsyncRabbitTemplate) RabbitTemplate(org.springframework.amqp.rabbit.core.RabbitTemplate) AsyncRabbitTemplate(org.springframework.amqp.rabbit.AsyncRabbitTemplate) SimpleMessageListenerContainer(org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer) CountDownLatch(java.util.concurrent.CountDownLatch) MessageListenerAdapter(org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter) RabbitMessageFuture(org.springframework.amqp.rabbit.AsyncRabbitTemplate.RabbitMessageFuture) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) CachingConnectionFactory(org.springframework.amqp.rabbit.connection.CachingConnectionFactory) LogAccessor(org.springframework.core.log.LogAccessor) ErrorMessage(org.springframework.messaging.support.ErrorMessage) Test(org.junit.jupiter.api.Test)

Aggregations

LogAccessor (org.springframework.core.log.LogAccessor)38 Test (org.junit.jupiter.api.Test)34 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)34 BeanFactory (org.springframework.beans.factory.BeanFactory)19 CountDownLatch (java.util.concurrent.CountDownLatch)16 QueueChannel (org.springframework.integration.channel.QueueChannel)15 Supplier (java.util.function.Supplier)11 Message (org.springframework.messaging.Message)11 GenericMessage (org.springframework.messaging.support.GenericMessage)11 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)9 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)9 Mockito.spy (org.mockito.Mockito.spy)9 TestUtils (org.springframework.integration.test.util.TestUtils)8 ThreadPoolTaskScheduler (org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler)8 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)7 AtomicReference (java.util.concurrent.atomic.AtomicReference)7 Mockito.mock (org.mockito.Mockito.mock)7 Mockito.verify (org.mockito.Mockito.verify)7 TimeUnit (java.util.concurrent.TimeUnit)6 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)6