Migrate tests to AssertJ
Mostly thanks to IDEA's plugin: https://plugins.jetbrains.com/plugin/10345-assertions2assertj There is still a lot of work to do when complex and composite matchers are used. * Add `awaitility` dependency and deprecate `EventuallyMatcher` in favor of `awaitility` * Remove Hamcrest from dependencies and disable JUnit & Hamcrest static imports to encourage to use only AssertJ * Migrate JUnit assumptions in rules to AssertJ's assumptions * Deprecate some custom matchers in favor of existing in Hamcrest after upgrading the last to version `2.1` * Replace `ExpectedException` rules with `assertThatThrownBy()` * Mention `MessagePredicate` in the `testing.adoc`
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
package org.springframework.integration.jmx;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@@ -49,12 +48,12 @@ public class AttributePollingMessageSourceTests {
|
||||
source.setObjectName("test:name=counter");
|
||||
source.setServer(server);
|
||||
Message<?> message1 = source.receive();
|
||||
assertNotNull(message1);
|
||||
assertEquals(0, message1.getPayload());
|
||||
assertThat(message1).isNotNull();
|
||||
assertThat(message1.getPayload()).isEqualTo(0);
|
||||
counter.increment();
|
||||
Message<?> message2 = source.receive();
|
||||
assertNotNull(message2);
|
||||
assertEquals(1, message2.getPayload());
|
||||
assertThat(message2).isNotNull();
|
||||
assertThat(message2.getPayload()).isEqualTo(1);
|
||||
|
||||
factoryBean.destroy();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2016 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,11 +16,7 @@
|
||||
|
||||
package org.springframework.integration.jmx;
|
||||
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -73,20 +69,20 @@ public class MBeanAttributeFilterTests {
|
||||
adapter.start();
|
||||
|
||||
Message<?> result = channel.receive(testTimeout);
|
||||
assertNotNull(result);
|
||||
assertEquals(HashMap.class, result.getPayload().getClass());
|
||||
assertThat(result).isNotNull();
|
||||
assertThat(result.getPayload().getClass()).isEqualTo(HashMap.class);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> payload = (Map<String, Object>) result.getPayload();
|
||||
assertEquals(4, payload.size());
|
||||
assertThat(payload.size()).isEqualTo(4);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> bean = (Map<String, Object>) payload
|
||||
.get(domain + ":name=in,type=MessageChannel");
|
||||
|
||||
assertEquals(2, bean.size());
|
||||
assertTrue(bean.containsKey("SendCount"));
|
||||
assertTrue(bean.containsKey("SendErrorCount"));
|
||||
assertThat(bean.size()).isEqualTo(2);
|
||||
assertThat(bean.containsKey("SendCount")).isTrue();
|
||||
assertThat(bean.containsKey("SendErrorCount")).isTrue();
|
||||
|
||||
adapter.stop();
|
||||
}
|
||||
@@ -99,12 +95,12 @@ public class MBeanAttributeFilterTests {
|
||||
adapterNot.start();
|
||||
|
||||
Message<?> result = channel.receive(testTimeout);
|
||||
assertNotNull(result);
|
||||
assertEquals(HashMap.class, result.getPayload().getClass());
|
||||
assertThat(result).isNotNull();
|
||||
assertThat(result.getPayload().getClass()).isEqualTo(HashMap.class);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> payload = (Map<String, Object>) result.getPayload();
|
||||
assertEquals(4, payload.size());
|
||||
assertThat(payload.size()).isEqualTo(4);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> bean = (Map<String, Object>) payload
|
||||
@@ -112,16 +108,10 @@ public class MBeanAttributeFilterTests {
|
||||
|
||||
List<String> keys = new ArrayList<String>(bean.keySet());
|
||||
Collections.sort(keys);
|
||||
assertThat(keys, contains("LoggingEnabled",
|
||||
"MaxSendDuration",
|
||||
"MeanErrorRate",
|
||||
"MeanErrorRatio",
|
||||
"MeanSendDuration",
|
||||
"MeanSendRate",
|
||||
"MinSendDuration",
|
||||
"StandardDeviationSendDuration",
|
||||
"SubscriberCount",
|
||||
"TimeSinceLastSend"));
|
||||
assertThat(keys)
|
||||
.containsExactly("LoggingEnabled", "MaxSendDuration", "MeanErrorRate", "MeanErrorRatio",
|
||||
"MeanSendDuration", "MeanSendRate", "MinSendDuration", "StandardDeviationSendDuration",
|
||||
"SubscriberCount", "TimeSinceLastSend");
|
||||
|
||||
adapterNot.stop();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,9 +16,7 @@
|
||||
|
||||
package org.springframework.integration.jmx;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -63,14 +61,14 @@ public class MBeanTreePollingMessageSourceTests {
|
||||
|
||||
Object received = source.doReceive();
|
||||
|
||||
assertEquals(HashMap.class, received.getClass());
|
||||
assertThat(received.getClass()).isEqualTo(HashMap.class);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> beans = (Map<String, Object>) received;
|
||||
|
||||
// test for a couple of MBeans
|
||||
assertTrue(beans.containsKey("java.lang:type=OperatingSystem"));
|
||||
assertTrue(beans.containsKey("java.lang:type=Runtime"));
|
||||
assertThat(beans.containsKey("java.lang:type=OperatingSystem")).isTrue();
|
||||
assertThat(beans.containsKey("java.lang:type=Runtime")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -82,15 +80,15 @@ public class MBeanTreePollingMessageSourceTests {
|
||||
|
||||
Object received = source.doReceive();
|
||||
|
||||
assertEquals(HashMap.class, received.getClass());
|
||||
assertThat(received.getClass()).isEqualTo(HashMap.class);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> beans = (Map<String, Object>) received;
|
||||
|
||||
// test for a few MBeans
|
||||
assertTrue(beans.containsKey("java.lang:type=OperatingSystem"));
|
||||
assertTrue(beans.containsKey("java.lang:type=Runtime"));
|
||||
assertFalse(beans.containsKey("java.util.logging:type=Logging"));
|
||||
assertThat(beans.containsKey("java.lang:type=OperatingSystem")).isTrue();
|
||||
assertThat(beans.containsKey("java.lang:type=Runtime")).isTrue();
|
||||
assertThat(beans.containsKey("java.util.logging:type=Logging")).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -102,15 +100,15 @@ public class MBeanTreePollingMessageSourceTests {
|
||||
|
||||
Object received = source.doReceive();
|
||||
|
||||
assertEquals(HashMap.class, received.getClass());
|
||||
assertThat(received.getClass()).isEqualTo(HashMap.class);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> beans = (Map<String, Object>) received;
|
||||
|
||||
// test for a few MBeans
|
||||
assertFalse(beans.containsKey("java.lang:type=OperatingSystem"));
|
||||
assertFalse(beans.containsKey("java.lang:type=Runtime"));
|
||||
assertTrue(beans.containsKey("java.util.logging:type=Logging"));
|
||||
assertThat(beans.containsKey("java.lang:type=OperatingSystem")).isFalse();
|
||||
assertThat(beans.containsKey("java.lang:type=Runtime")).isFalse();
|
||||
assertThat(beans.containsKey("java.util.logging:type=Logging")).isTrue();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,10 +16,7 @@
|
||||
|
||||
package org.springframework.integration.jmx;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
@@ -102,12 +99,12 @@ public class NotificationListeningMessageProducerTests {
|
||||
adapter.onApplicationEvent(new ContextRefreshedEvent(Mockito.mock(ApplicationContext.class)));
|
||||
this.numberHolder.publish("foo");
|
||||
Message<?> message = outputChannel.receive(0);
|
||||
assertNotNull(message);
|
||||
assertTrue(message.getPayload() instanceof Notification);
|
||||
assertThat(message).isNotNull();
|
||||
assertThat(message.getPayload() instanceof Notification).isTrue();
|
||||
Notification notification = (Notification) message.getPayload();
|
||||
assertEquals("foo", notification.getMessage());
|
||||
assertEquals(objectName, notification.getSource());
|
||||
assertNull(message.getHeaders().get(JmxHeaders.NOTIFICATION_HANDBACK));
|
||||
assertThat(notification.getMessage()).isEqualTo("foo");
|
||||
assertThat(notification.getSource()).isEqualTo(objectName);
|
||||
assertThat(message.getHeaders().get(JmxHeaders.NOTIFICATION_HANDBACK)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -125,12 +122,12 @@ public class NotificationListeningMessageProducerTests {
|
||||
adapter.onApplicationEvent(new ContextRefreshedEvent(Mockito.mock(ApplicationContext.class)));
|
||||
this.numberHolder.publish("foo");
|
||||
Message<?> message = outputChannel.receive(0);
|
||||
assertNotNull(message);
|
||||
assertTrue(message.getPayload() instanceof Notification);
|
||||
assertThat(message).isNotNull();
|
||||
assertThat(message.getPayload() instanceof Notification).isTrue();
|
||||
Notification notification = (Notification) message.getPayload();
|
||||
assertEquals("foo", notification.getMessage());
|
||||
assertEquals(objectName, notification.getSource());
|
||||
assertEquals(handback, message.getHeaders().get(JmxHeaders.NOTIFICATION_HANDBACK));
|
||||
assertThat(notification.getMessage()).isEqualTo("foo");
|
||||
assertThat(notification.getSource()).isEqualTo(objectName);
|
||||
assertThat(message.getHeaders().get(JmxHeaders.NOTIFICATION_HANDBACK)).isEqualTo(handback);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -148,13 +145,13 @@ public class NotificationListeningMessageProducerTests {
|
||||
adapter.onApplicationEvent(new ContextRefreshedEvent(Mockito.mock(ApplicationContext.class)));
|
||||
this.numberHolder.publish("bad");
|
||||
Message<?> message = outputChannel.receive(0);
|
||||
assertNull(message);
|
||||
assertThat(message).isNull();
|
||||
this.numberHolder.publish("okay");
|
||||
message = outputChannel.receive(0);
|
||||
assertNotNull(message);
|
||||
assertTrue(message.getPayload() instanceof Notification);
|
||||
assertThat(message).isNotNull();
|
||||
assertThat(message.getPayload() instanceof Notification).isTrue();
|
||||
Notification notification = (Notification) message.getPayload();
|
||||
assertEquals("okay", notification.getMessage());
|
||||
assertThat(notification.getMessage()).isEqualTo("okay");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.integration.jmx;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -82,13 +82,13 @@ public class NotificationPublishingMessageHandlerTests {
|
||||
@Test
|
||||
public void simplePublish() {
|
||||
MessageHandler handler = context.getBean("testPublisher", MessageHandler.class);
|
||||
assertEquals(0, this.listener.notifications.size());
|
||||
assertThat(this.listener.notifications.size()).isEqualTo(0);
|
||||
handler.handleMessage(new GenericMessage<String>("foo"));
|
||||
assertEquals(1, this.listener.notifications.size());
|
||||
assertThat(this.listener.notifications.size()).isEqualTo(1);
|
||||
Notification notification = this.listener.notifications.get(0);
|
||||
assertEquals(this.publisherObjectName, notification.getSource());
|
||||
assertEquals("foo", notification.getMessage());
|
||||
assertEquals("test.type", notification.getType());
|
||||
assertThat(notification.getSource()).isEqualTo(this.publisherObjectName);
|
||||
assertThat(notification.getMessage()).isEqualTo("foo");
|
||||
assertThat(notification.getType()).isEqualTo("test.type");
|
||||
}
|
||||
|
||||
public static class TestNotificationListener implements NotificationListener {
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
package org.springframework.integration.jmx;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -100,8 +99,8 @@ public class OperationInvokingMessageHandlerTests {
|
||||
Message<?> message = MessageBuilder.withPayload(params).build();
|
||||
handler.handleMessage(message);
|
||||
Message<?> reply = outputChannel.receive(0);
|
||||
assertNotNull(reply);
|
||||
assertEquals("foobar", reply.getPayload());
|
||||
assertThat(reply).isNotNull();
|
||||
assertThat(reply.getPayload()).isEqualTo("foobar");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -131,8 +130,8 @@ public class OperationInvokingMessageHandlerTests {
|
||||
Message<?> message = MessageBuilder.withPayload(params).build();
|
||||
handler.handleMessage(message);
|
||||
Message<?> reply = outputChannel.receive(0);
|
||||
assertNotNull(reply);
|
||||
assertEquals("foobar", reply.getPayload());
|
||||
assertThat(reply).isNotNull();
|
||||
assertThat(reply.getPayload()).isEqualTo("foobar");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -148,8 +147,8 @@ public class OperationInvokingMessageHandlerTests {
|
||||
Message<?> message = MessageBuilder.withPayload(params).build();
|
||||
handler.handleMessage(message);
|
||||
Message<?> reply = outputChannel.receive(0);
|
||||
assertNotNull(reply);
|
||||
assertEquals("foo123", reply.getPayload());
|
||||
assertThat(reply).isNotNull();
|
||||
assertThat(reply.getPayload()).isEqualTo("foo123");
|
||||
}
|
||||
|
||||
public interface TestOpsMBean {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,14 +16,9 @@
|
||||
|
||||
package org.springframework.integration.jmx;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@@ -90,7 +85,8 @@ public class ServiceActivatorDefaultFrameworkMethodTests {
|
||||
Message<?> message = MessageBuilder.withPayload("test").setReplyChannel(replyChannel).build();
|
||||
this.gatewayTestInputChannel.send(message);
|
||||
Message<?> reply = replyChannel.receive(0);
|
||||
assertEquals("gatewayTestInputChannel,gatewayTestService,gateway,requestChannel,bridge,replyChannel", reply.getHeaders().get("history").toString());
|
||||
assertThat(reply.getHeaders().get("history").toString())
|
||||
.isEqualTo("gatewayTestInputChannel,gatewayTestService,gateway,requestChannel,bridge,replyChannel");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -99,10 +95,13 @@ public class ServiceActivatorDefaultFrameworkMethodTests {
|
||||
Message<?> message = MessageBuilder.withPayload("test").setReplyChannel(replyChannel).build();
|
||||
this.replyingHandlerTestInputChannel.send(message);
|
||||
Message<?> reply = replyChannel.receive(0);
|
||||
assertEquals("TEST", reply.getPayload());
|
||||
assertEquals("replyingHandlerTestInputChannel,replyingHandlerTestService", reply.getHeaders().get("history").toString());
|
||||
assertThat(reply.getPayload()).isEqualTo("TEST");
|
||||
assertThat(reply.getHeaders().get("history").toString())
|
||||
.isEqualTo("replyingHandlerTestInputChannel,replyingHandlerTestService");
|
||||
StackTraceElement[] st = (StackTraceElement[]) reply.getHeaders().get("callStack");
|
||||
assertTrue(StackTraceUtils.isFrameContainingXBeforeFrameContainingY("AbstractSubscribableChannel", "MethodInvokerHelper", st));
|
||||
assertThat(StackTraceUtils
|
||||
.isFrameContainingXBeforeFrameContainingY("AbstractSubscribableChannel", "MethodInvokerHelper", st))
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -111,11 +110,13 @@ public class ServiceActivatorDefaultFrameworkMethodTests {
|
||||
Message<?> message = MessageBuilder.withPayload("test").setReplyChannel(replyChannel).build();
|
||||
this.optimizedRefReplyingHandlerTestInputChannel.send(message);
|
||||
Message<?> reply = replyChannel.receive(0);
|
||||
assertEquals("TEST", reply.getPayload());
|
||||
assertEquals("optimizedRefReplyingHandlerTestInputChannel,optimizedRefReplyingHandlerTestService",
|
||||
reply.getHeaders().get("history").toString());
|
||||
assertThat(reply.getPayload()).isEqualTo("TEST");
|
||||
assertThat(reply.getHeaders().get("history").toString())
|
||||
.isEqualTo("optimizedRefReplyingHandlerTestInputChannel,optimizedRefReplyingHandlerTestService");
|
||||
StackTraceElement[] st = (StackTraceElement[]) reply.getHeaders().get("callStack");
|
||||
assertTrue(StackTraceUtils.isFrameContainingXBeforeFrameContainingY("AbstractSubscribableChannel", "MethodInvokerHelper", st));
|
||||
assertThat(StackTraceUtils
|
||||
.isFrameContainingXBeforeFrameContainingY("AbstractSubscribableChannel", "MethodInvokerHelper", st))
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -124,10 +125,14 @@ public class ServiceActivatorDefaultFrameworkMethodTests {
|
||||
Message<?> message = MessageBuilder.withPayload("test").setReplyChannel(replyChannel).build();
|
||||
this.replyingHandlerWithStandardMethodTestInputChannel.send(message);
|
||||
Message<?> reply = replyChannel.receive(0);
|
||||
assertEquals("TEST", reply.getPayload());
|
||||
assertEquals("replyingHandlerWithStandardMethodTestInputChannel,replyingHandlerWithStandardMethodTestService", reply.getHeaders().get("history").toString());
|
||||
assertThat(reply.getPayload()).isEqualTo("TEST");
|
||||
assertThat(reply.getHeaders().get("history").toString())
|
||||
.isEqualTo("replyingHandlerWithStandardMethodTestInputChannel," +
|
||||
"replyingHandlerWithStandardMethodTestService");
|
||||
StackTraceElement[] st = (StackTraceElement[]) reply.getHeaders().get("callStack");
|
||||
assertTrue(StackTraceUtils.isFrameContainingXBeforeFrameContainingY("AbstractSubscribableChannel", "MethodInvokerHelper", st));
|
||||
assertThat(StackTraceUtils
|
||||
.isFrameContainingXBeforeFrameContainingY("AbstractSubscribableChannel", "MethodInvokerHelper", st))
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -136,8 +141,9 @@ public class ServiceActivatorDefaultFrameworkMethodTests {
|
||||
Message<?> message = MessageBuilder.withPayload("test").setReplyChannel(replyChannel).build();
|
||||
this.replyingHandlerWithOtherMethodTestInputChannel.send(message);
|
||||
Message<?> reply = replyChannel.receive(0);
|
||||
assertEquals("bar", reply.getPayload());
|
||||
assertEquals("replyingHandlerWithOtherMethodTestInputChannel,replyingHandlerWithOtherMethodTestService", reply.getHeaders().get("history").toString());
|
||||
assertThat(reply.getPayload()).isEqualTo("bar");
|
||||
assertThat(reply.getHeaders().get("history").toString())
|
||||
.isEqualTo("replyingHandlerWithOtherMethodTestInputChannel,replyingHandlerWithOtherMethodTestService");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -151,14 +157,15 @@ public class ServiceActivatorDefaultFrameworkMethodTests {
|
||||
@Test
|
||||
public void testMessageProcessor() {
|
||||
Object processor = TestUtils.getPropertyValue(processorTestService, "handler.processor");
|
||||
assertSame(testMessageProcessor, processor);
|
||||
assertThat(processor).isSameAs(testMessageProcessor);
|
||||
|
||||
QueueChannel replyChannel = new QueueChannel();
|
||||
Message<?> message = MessageBuilder.withPayload("bar").setReplyChannel(replyChannel).build();
|
||||
this.processorTestInputChannel.send(message);
|
||||
Message<?> reply = replyChannel.receive(0);
|
||||
assertEquals("foo:bar", reply.getPayload());
|
||||
assertEquals("processorTestInputChannel,processorTestService", reply.getHeaders().get("history").toString());
|
||||
assertThat(reply.getPayload()).isEqualTo("foo:bar");
|
||||
assertThat(reply.getHeaders().get("history").toString())
|
||||
.isEqualTo("processorTestInputChannel,processorTestService");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -169,11 +176,11 @@ public class ServiceActivatorDefaultFrameworkMethodTests {
|
||||
fail("Expected exception due to 2 endpoints referencing the same bean");
|
||||
}
|
||||
catch (Exception e) {
|
||||
assertThat(e, Matchers.instanceOf(BeanCreationException.class));
|
||||
assertThat(e.getCause(), Matchers.instanceOf(BeanCreationException.class));
|
||||
assertThat(e.getCause().getCause(), Matchers.instanceOf(IllegalArgumentException.class));
|
||||
assertThat(e.getCause().getCause().getMessage(),
|
||||
Matchers.containsString("An AbstractMessageProducingMessageHandler may only be referenced once"));
|
||||
assertThat(e).isInstanceOf(BeanCreationException.class);
|
||||
assertThat(e.getCause()).isInstanceOf(BeanCreationException.class);
|
||||
assertThat(e.getCause().getCause()).isInstanceOf(IllegalArgumentException.class);
|
||||
assertThat(e.getCause().getCause().getMessage())
|
||||
.contains("An AbstractMessageProducingMessageHandler may only be referenced once");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -200,7 +207,9 @@ public class ServiceActivatorDefaultFrameworkMethodTests {
|
||||
Exception e = new RuntimeException();
|
||||
StackTraceElement[] st = e.getStackTrace();
|
||||
// use this to test that StackTraceUtils works as expected and returns false
|
||||
assertFalse(StackTraceUtils.isFrameContainingXBeforeFrameContainingY("AbstractSubscribableChannel", "MethodInvokerHelper", st));
|
||||
assertThat(StackTraceUtils.isFrameContainingXBeforeFrameContainingY("AbstractSubscribableChannel",
|
||||
"MethodInvokerHelper", st))
|
||||
.isFalse();
|
||||
return "bar";
|
||||
}
|
||||
|
||||
@@ -213,8 +222,11 @@ public class ServiceActivatorDefaultFrameworkMethodTests {
|
||||
public void handleMessage(Message<?> requestMessage) {
|
||||
Exception e = new RuntimeException();
|
||||
StackTraceElement[] st = e.getStackTrace();
|
||||
assertTrue(StackTraceUtils.isFrameContainingXBeforeFrameContainingY("AbstractSubscribableChannel", "MethodInvokerHelper", st));
|
||||
assertThat(StackTraceUtils.isFrameContainingXBeforeFrameContainingY("AbstractSubscribableChannel",
|
||||
"MethodInvokerHelper", st))
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
package org.springframework.integration.jmx;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -69,7 +68,7 @@ public class UpdateMappingsTests {
|
||||
Message<?> message = MessageBuilder.withPayload("Hello, world!")
|
||||
.setHeader("routing.header", "baz").build();
|
||||
in.send(message);
|
||||
assertNotNull(qux.receive());
|
||||
assertThat(qux.receive()).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -79,16 +78,16 @@ public class UpdateMappingsTests {
|
||||
messagingTemplate.convertAndSend(control,
|
||||
"@'router.handler'.replaceChannelMappings('foo=bar \n baz=qux')");
|
||||
Map<?, ?> mappings = messagingTemplate.convertSendAndReceive(control, "@'router.handler'.getChannelMappings()", Map.class);
|
||||
assertNotNull(mappings);
|
||||
assertEquals(2, mappings.size());
|
||||
assertEquals("bar", mappings.get("foo"));
|
||||
assertEquals("qux", mappings.get("baz"));
|
||||
assertThat(mappings).isNotNull();
|
||||
assertThat(mappings.size()).isEqualTo(2);
|
||||
assertThat(mappings.get("foo")).isEqualTo("bar");
|
||||
assertThat(mappings.get("baz")).isEqualTo("qux");
|
||||
messagingTemplate.convertAndSend(control,
|
||||
"@'router.handler'.replaceChannelMappings('foo=qux \n baz=bar')");
|
||||
mappings = messagingTemplate.convertSendAndReceive(control, "@'router.handler'.getChannelMappings()", Map.class);
|
||||
assertEquals(2, mappings.size());
|
||||
assertEquals("bar", mappings.get("baz"));
|
||||
assertEquals("qux", mappings.get("foo"));
|
||||
assertThat(mappings.size()).isEqualTo(2);
|
||||
assertThat(mappings.get("baz")).isEqualTo("bar");
|
||||
assertThat(mappings.get("foo")).isEqualTo("qux");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -98,7 +97,7 @@ public class UpdateMappingsTests {
|
||||
Set<ObjectName> names = this.server.queryNames(ObjectName
|
||||
.getInstance("update.mapping.domain:type=MessageHandler,name=router,bean=endpoint"),
|
||||
null);
|
||||
assertEquals(1, names.size());
|
||||
assertThat(names.size()).isEqualTo(1);
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
map.put("foo", "bar");
|
||||
map.put("baz", "qux");
|
||||
@@ -106,10 +105,10 @@ public class UpdateMappingsTests {
|
||||
this.server.invoke(names.iterator().next(), "setChannelMappings", params,
|
||||
new String[] { "java.util.Map" });
|
||||
Map<?, ?> mappings = messagingTemplate.convertSendAndReceive(control, "@'router.handler'.getChannelMappings()", Map.class);
|
||||
assertNotNull(mappings);
|
||||
assertEquals(2, mappings.size());
|
||||
assertEquals("bar", mappings.get("foo"));
|
||||
assertEquals("qux", mappings.get("baz"));
|
||||
assertThat(mappings).isNotNull();
|
||||
assertThat(mappings.size()).isEqualTo(2);
|
||||
assertThat(mappings.get("foo")).isEqualTo("bar");
|
||||
assertThat(mappings.get("baz")).isEqualTo("qux");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,9 +16,7 @@
|
||||
|
||||
package org.springframework.integration.jmx.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -66,13 +64,13 @@ public class AttributePollingChannelAdapterParserTests {
|
||||
this.testBean.test("foo");
|
||||
this.adapter.start();
|
||||
Message<?> result = this.channel.receive(10000);
|
||||
assertNotNull(result);
|
||||
assertEquals("foo", result.getPayload());
|
||||
assertThat(result).isNotNull();
|
||||
assertThat(result.getPayload()).isEqualTo("foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAutoChannel() {
|
||||
assertSame(this.autoChannel, TestUtils.getPropertyValue(this.autoChannelAdapter, "outputChannel"));
|
||||
assertThat(TestUtils.getPropertyValue(this.autoChannelAdapter, "outputChannel")).isSameAs(this.autoChannel);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.integration.jmx.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -48,7 +48,7 @@ public class ControlBusParserTests {
|
||||
MessagingTemplate messagingTemplate = new MessagingTemplate();
|
||||
Object value = messagingTemplate.convertSendAndReceive(control,
|
||||
"@integrationMbeanExporter.getChannelSendRate('testChannel').count", Object.class);
|
||||
assertEquals(0, value);
|
||||
assertThat(value).isEqualTo(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2016 the original author or authors.
|
||||
* Copyright 2015-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
package org.springframework.integration.jmx.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import java.util.Iterator;
|
||||
@@ -66,41 +65,41 @@ public class CustomObjectNameTests {
|
||||
@Test
|
||||
public void testCustomMBeanRegistration() throws Exception {
|
||||
Set<ObjectName> names = server.queryNames(new ObjectName("custom:type=MessageChannel,*"), null);
|
||||
assertEquals(1, names.size());
|
||||
assertThat(names.size()).isEqualTo(1);
|
||||
ObjectName name = names.iterator().next();
|
||||
assertEquals("custom:type=MessageChannel,name=foo", name.toString());
|
||||
assertThat(name.toString()).isEqualTo("custom:type=MessageChannel,name=foo");
|
||||
MBeanInfo mBeanInfo = server.getMBeanInfo(name);
|
||||
assertEquals("custom channel", mBeanInfo.getDescription());
|
||||
assertThat(mBeanInfo.getDescription()).isEqualTo("custom channel");
|
||||
names = server.queryNames(new ObjectName("custom:type=MessageHandler,*"), null);
|
||||
assertEquals(1, names.size());
|
||||
assertThat(names.size()).isEqualTo(1);
|
||||
name = names.iterator().next();
|
||||
assertEquals("custom:type=MessageHandler,name=foo", name.toString());
|
||||
assertThat(name.toString()).isEqualTo("custom:type=MessageHandler,name=foo");
|
||||
mBeanInfo = server.getMBeanInfo(name);
|
||||
assertEquals("custom handler", mBeanInfo.getDescription());
|
||||
assertThat(mBeanInfo.getDescription()).isEqualTo("custom handler");
|
||||
Descriptor descriptor = mBeanInfo.getDescriptor();
|
||||
assertEquals("true", descriptor.getFieldValue("log"));
|
||||
assertEquals("foo", descriptor.getFieldValue("logFile"));
|
||||
assertEquals("1000", descriptor.getFieldValue("currencyTimeLimit"));
|
||||
assertEquals("bar", descriptor.getFieldValue("persistLocation"));
|
||||
assertEquals("baz", descriptor.getFieldValue("persistName"));
|
||||
assertEquals("10", descriptor.getFieldValue("persistPeriod"));
|
||||
assertEquals("Never", descriptor.getFieldValue("persistPolicy"));
|
||||
assertThat(descriptor.getFieldValue("log")).isEqualTo("true");
|
||||
assertThat(descriptor.getFieldValue("logFile")).isEqualTo("foo");
|
||||
assertThat(descriptor.getFieldValue("currencyTimeLimit")).isEqualTo("1000");
|
||||
assertThat(descriptor.getFieldValue("persistLocation")).isEqualTo("bar");
|
||||
assertThat(descriptor.getFieldValue("persistName")).isEqualTo("baz");
|
||||
assertThat(descriptor.getFieldValue("persistPeriod")).isEqualTo("10");
|
||||
assertThat(descriptor.getFieldValue("persistPolicy")).isEqualTo("Never");
|
||||
names = server.queryNames(new ObjectName("custom:type=MessageSource,*"), null);
|
||||
assertEquals(1, names.size());
|
||||
assertThat(names.size()).isEqualTo(1);
|
||||
name = names.iterator().next();
|
||||
assertEquals("custom:type=MessageSource,name=foo", name.toString());
|
||||
assertThat(name.toString()).isEqualTo("custom:type=MessageSource,name=foo");
|
||||
names = server.queryNames(new ObjectName("custom:type=MessageRouter,*"), null);
|
||||
assertEquals(1, names.size());
|
||||
assertThat(names.size()).isEqualTo(1);
|
||||
name = names.iterator().next();
|
||||
assertEquals("custom:type=MessageRouter,name=foo", name.toString());
|
||||
assertThat(name.toString()).isEqualTo("custom:type=MessageRouter,name=foo");
|
||||
names = server.queryNames(new ObjectName("test.custom:type=MessageHandler,*"), null);
|
||||
assertEquals(2, names.size());
|
||||
assertThat(names.size()).isEqualTo(2);
|
||||
Iterator<ObjectName> iterator = names.iterator();
|
||||
name = iterator.next();
|
||||
assertEquals("test.custom:type=MessageHandler,name=standardHandler,bean=handler", name.toString());
|
||||
assertThat(name.toString()).isEqualTo("test.custom:type=MessageHandler,name=standardHandler,bean=handler");
|
||||
name = iterator.next();
|
||||
assertEquals("test.custom:type=MessageHandler,name=errorLogger,bean=internal", name.toString());
|
||||
assertTrue(AopUtils.isJdkDynamicProxy(this.customHandler));
|
||||
assertThat(name.toString()).isEqualTo("test.custom:type=MessageHandler,name=errorLogger,bean=internal");
|
||||
assertThat(AopUtils.isJdkDynamicProxy(this.customHandler)).isTrue();
|
||||
}
|
||||
|
||||
@IntegrationManagedResource(objectName = "${customChannelName}", description = "custom channel")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.integration.jmx.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -73,22 +73,22 @@ public class DynamicRouterTests {
|
||||
@Test @DirtiesContext
|
||||
public void testRouteChange() throws Exception {
|
||||
routingChannel.send(new GenericMessage<String>("123"));
|
||||
assertEquals("123", processAChannel.receive(0).getPayload());
|
||||
assertThat(processAChannel.receive(0).getPayload()).isEqualTo("123");
|
||||
routingChannel.send(MessageBuilder.withPayload(123).build());
|
||||
assertEquals(123, processBChannel.receive(0).getPayload());
|
||||
assertThat(processBChannel.receive(0).getPayload()).isEqualTo(123);
|
||||
|
||||
controlChannel.send(MessageBuilder.withPayload(new String[]{"java.lang.String", "processCChannel"}).build());
|
||||
|
||||
routingChannel.send(new GenericMessage<String>("123"));
|
||||
assertEquals("123", processCChannel.receive(0).getPayload());
|
||||
assertThat(processCChannel.receive(0).getPayload()).isEqualTo("123");
|
||||
}
|
||||
|
||||
@Test @DirtiesContext
|
||||
public void testRouteChangeMap() throws Exception {
|
||||
routingChannel.send(new GenericMessage<String>("123"));
|
||||
assertEquals("123", processAChannel.receive(0).getPayload());
|
||||
assertThat(processAChannel.receive(0).getPayload()).isEqualTo("123");
|
||||
routingChannel.send(MessageBuilder.withPayload(123).build());
|
||||
assertEquals(123, processBChannel.receive(0).getPayload());
|
||||
assertThat(processBChannel.receive(0).getPayload()).isEqualTo(123);
|
||||
Map<String, Object> args = new HashMap<String, Object>();
|
||||
args.put("p1", "java.lang.String");
|
||||
args.put("p2", "processCChannel");
|
||||
@@ -96,15 +96,15 @@ public class DynamicRouterTests {
|
||||
controlChannel.send(MessageBuilder.withPayload(args).build());
|
||||
|
||||
routingChannel.send(new GenericMessage<String>("123"));
|
||||
assertEquals("123", processCChannel.receive(0).getPayload());
|
||||
assertThat(processCChannel.receive(0).getPayload()).isEqualTo("123");
|
||||
}
|
||||
|
||||
@Test @DirtiesContext
|
||||
public void testRouteChangeMapNamedArgs() throws Exception {
|
||||
routingChannel.send(new GenericMessage<String>("123"));
|
||||
assertEquals("123", processAChannel.receive(0).getPayload());
|
||||
assertThat(processAChannel.receive(0).getPayload()).isEqualTo("123");
|
||||
routingChannel.send(MessageBuilder.withPayload(123).build());
|
||||
assertEquals(123, processBChannel.receive(0).getPayload());
|
||||
assertThat(processBChannel.receive(0).getPayload()).isEqualTo(123);
|
||||
Map<String, Object> args = new HashMap<String, Object>();
|
||||
args.put("key", "java.lang.String");
|
||||
args.put("channelName", "processCChannel");
|
||||
@@ -112,7 +112,7 @@ public class DynamicRouterTests {
|
||||
controlChannel.send(MessageBuilder.withPayload(args).build());
|
||||
|
||||
routingChannel.send(new GenericMessage<String>("123"));
|
||||
assertEquals("123", processCChannel.receive(0).getPayload());
|
||||
assertThat(processCChannel.receive(0).getPayload()).isEqualTo("123");
|
||||
}
|
||||
|
||||
@Test @DirtiesContext @Ignore
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.integration.jmx.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@@ -54,7 +54,7 @@ public class MBeanAutoDetectTests {
|
||||
// System . err.println(server.queryNames(new ObjectName("test.MBeanAutoDetectFirst:*"), null));
|
||||
Set<ObjectName> names = server.queryNames(
|
||||
new ObjectName("test.MBeanAutoDetectFirst:type=ExpressionEvaluatingRouter,*"), null);
|
||||
assertEquals(1, names.size());
|
||||
assertThat(names.size()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -64,7 +64,7 @@ public class MBeanAutoDetectTests {
|
||||
// System . err.println(server.queryNames(new ObjectName("test.MBeanAutoDetectFirst:*"), null));
|
||||
Set<ObjectName> names = server.queryNames(
|
||||
new ObjectName("test.MBeanAutoDetectFirst:type=ExpressionEvaluatingRouter,*"), null);
|
||||
assertEquals(1, names.size());
|
||||
assertThat(names.size()).isEqualTo(1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,16 +16,13 @@
|
||||
|
||||
package org.springframework.integration.jmx.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.management.MBeanServer;
|
||||
|
||||
import org.assertj.core.data.Offset;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@@ -69,68 +66,69 @@ public class MBeanExporterParserTests {
|
||||
IntegrationMBeanExporter exporter = this.context.getBean(IntegrationMBeanExporter.class);
|
||||
MBeanServer server = this.context.getBean("mbs", MBeanServer.class);
|
||||
Properties properties = TestUtils.getPropertyValue(exporter, "objectNameStaticProperties", Properties.class);
|
||||
assertNotNull(properties);
|
||||
assertEquals(2, properties.size());
|
||||
assertTrue(properties.containsKey("foo"));
|
||||
assertTrue(properties.containsKey("bar"));
|
||||
assertEquals(server, exporter.getServer());
|
||||
assertSame(context.getBean("keyNamer"), TestUtils.getPropertyValue(exporter, "namingStrategy"));
|
||||
assertThat(properties).isNotNull();
|
||||
assertThat(properties.size()).isEqualTo(2);
|
||||
assertThat(properties.containsKey("foo")).isTrue();
|
||||
assertThat(properties.containsKey("bar")).isTrue();
|
||||
assertThat(exporter.getServer()).isEqualTo(server);
|
||||
assertThat(TestUtils.getPropertyValue(exporter, "namingStrategy")).isSameAs(context.getBean("keyNamer"));
|
||||
MessageChannelMetrics metrics = context.getBean("foo", MessageChannelMetrics.class);
|
||||
assertTrue(metrics.isCountsEnabled());
|
||||
assertFalse(metrics.isStatsEnabled());
|
||||
assertThat(metrics.isCountsEnabled()).isTrue();
|
||||
assertThat(metrics.isStatsEnabled()).isFalse();
|
||||
checkCustomized(metrics);
|
||||
MessageHandlerMetrics handlerMetrics = context.getBean("transformer.handler", MessageHandlerMetrics.class);
|
||||
checkCustomized(handlerMetrics);
|
||||
metrics = context.getBean("bar", MessageChannelMetrics.class);
|
||||
assertTrue(metrics.isCountsEnabled());
|
||||
assertFalse(metrics.isStatsEnabled());
|
||||
assertThat(metrics.isCountsEnabled()).isTrue();
|
||||
assertThat(metrics.isStatsEnabled()).isFalse();
|
||||
metrics = context.getBean("baz", MessageChannelMetrics.class);
|
||||
assertFalse(metrics.isCountsEnabled());
|
||||
assertFalse(metrics.isStatsEnabled());
|
||||
assertThat(metrics.isCountsEnabled()).isFalse();
|
||||
assertThat(metrics.isStatsEnabled()).isFalse();
|
||||
metrics = context.getBean("qux", MessageChannelMetrics.class);
|
||||
assertFalse(metrics.isCountsEnabled());
|
||||
assertFalse(metrics.isStatsEnabled());
|
||||
assertThat(metrics.isCountsEnabled()).isFalse();
|
||||
assertThat(metrics.isStatsEnabled()).isFalse();
|
||||
metrics = context.getBean("fiz", MessageChannelMetrics.class);
|
||||
assertTrue(metrics.isCountsEnabled());
|
||||
assertTrue(metrics.isStatsEnabled());
|
||||
assertThat(metrics.isCountsEnabled()).isTrue();
|
||||
assertThat(metrics.isStatsEnabled()).isTrue();
|
||||
metrics = context.getBean("buz", MessageChannelMetrics.class);
|
||||
assertTrue(metrics.isCountsEnabled());
|
||||
assertTrue(metrics.isStatsEnabled());
|
||||
assertThat(metrics.isCountsEnabled()).isTrue();
|
||||
assertThat(metrics.isStatsEnabled()).isTrue();
|
||||
metrics = context.getBean("!excluded", MessageChannelMetrics.class);
|
||||
assertFalse(metrics.isCountsEnabled());
|
||||
assertFalse(metrics.isStatsEnabled());
|
||||
assertThat(metrics.isCountsEnabled()).isFalse();
|
||||
assertThat(metrics.isStatsEnabled()).isFalse();
|
||||
checkCustomized(metrics);
|
||||
MetricsFactory factory = context.getBean(MetricsFactory.class);
|
||||
IntegrationManagementConfigurer configurer = context.getBean(IntegrationManagementConfigurer.class);
|
||||
assertSame(factory, TestUtils.getPropertyValue(configurer, "metricsFactory"));
|
||||
assertThat(TestUtils.getPropertyValue(configurer, "metricsFactory")).isSameAs(factory);
|
||||
exporter.destroy();
|
||||
}
|
||||
|
||||
private void checkCustomized(MessageChannelMetrics metrics) {
|
||||
assertFalse(metrics.isLoggingEnabled());
|
||||
assertEquals(20, TestUtils.getPropertyValue(metrics, "channelMetrics.sendDuration.window"));
|
||||
assertEquals(1000000., TestUtils.getPropertyValue(metrics, "channelMetrics.sendDuration.factor", Double.class),
|
||||
.01);
|
||||
assertEquals(30, TestUtils.getPropertyValue(metrics, "channelMetrics.sendErrorRate.window"));
|
||||
assertEquals(2000000.,
|
||||
TestUtils.getPropertyValue(metrics, "channelMetrics.sendErrorRate.period", Double.class), .01);
|
||||
assertEquals(.001 / 120000,
|
||||
TestUtils.getPropertyValue(metrics, "channelMetrics.sendErrorRate.lapse", Double.class), .01);
|
||||
assertThat(metrics.isLoggingEnabled()).isFalse();
|
||||
assertThat(TestUtils.getPropertyValue(metrics, "channelMetrics.sendDuration.window")).isEqualTo(20);
|
||||
assertThat(TestUtils.getPropertyValue(metrics, "channelMetrics.sendDuration.factor", Double.class))
|
||||
.isCloseTo(1000000., Offset.offset(.01));
|
||||
assertThat(TestUtils.getPropertyValue(metrics, "channelMetrics.sendErrorRate.window")).isEqualTo(30);
|
||||
assertThat(TestUtils.getPropertyValue(metrics, "channelMetrics.sendErrorRate.period", Double.class))
|
||||
.isCloseTo(2000000., Offset.offset(.01));
|
||||
assertThat(TestUtils.getPropertyValue(metrics, "channelMetrics.sendErrorRate.lapse", Double.class))
|
||||
.isCloseTo(.001 / 120000, Offset.offset(.01));
|
||||
|
||||
assertEquals(40, TestUtils.getPropertyValue(metrics, "channelMetrics.sendSuccessRatio.window"));
|
||||
assertEquals(.001 / 130000, TestUtils.getPropertyValue(metrics, "channelMetrics.sendRate.lapse", Double.class),
|
||||
.01);
|
||||
assertThat(TestUtils.getPropertyValue(metrics, "channelMetrics.sendSuccessRatio.window")).isEqualTo(40);
|
||||
assertThat(TestUtils.getPropertyValue(metrics, "channelMetrics.sendRate.lapse", Double.class))
|
||||
.isCloseTo(.001 / 130000, Offset.offset(.01));
|
||||
|
||||
assertEquals(50, TestUtils.getPropertyValue(metrics, "channelMetrics.sendRate.window"));
|
||||
assertEquals(3000000., TestUtils.getPropertyValue(metrics, "channelMetrics.sendRate.period", Double.class), .01);
|
||||
assertEquals(.001 / 140000, TestUtils.getPropertyValue(metrics, "channelMetrics.sendRate.lapse", Double.class),
|
||||
.01);
|
||||
assertThat(TestUtils.getPropertyValue(metrics, "channelMetrics.sendRate.window")).isEqualTo(50);
|
||||
assertThat(TestUtils.getPropertyValue(metrics, "channelMetrics.sendRate.period", Double.class))
|
||||
.isCloseTo(3000000., Offset.offset(.01));
|
||||
assertThat(TestUtils.getPropertyValue(metrics, "channelMetrics.sendRate.lapse", Double.class))
|
||||
.isCloseTo(.001 / 140000, Offset.offset(.01));
|
||||
}
|
||||
|
||||
private void checkCustomized(MessageHandlerMetrics metrics) {
|
||||
assertEquals(20, TestUtils.getPropertyValue(metrics, "handlerMetrics.duration.window"));
|
||||
assertEquals(1000000., TestUtils.getPropertyValue(metrics, "handlerMetrics.duration.factor", Double.class),
|
||||
.01);
|
||||
assertThat(TestUtils.getPropertyValue(metrics, "handlerMetrics.duration.window")).isEqualTo(20);
|
||||
assertThat(TestUtils.getPropertyValue(metrics, "handlerMetrics.duration.factor", Double.class))
|
||||
.isCloseTo(1000000., Offset.offset(.01));
|
||||
}
|
||||
|
||||
public static class CustomMetrics implements MetricsFactory {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2016 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
package org.springframework.integration.jmx.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@@ -51,10 +50,18 @@ public class MBeanRegistrationCustomNamingTests {
|
||||
@Test
|
||||
public void testHandlerMBeanRegistration() throws Exception {
|
||||
Set<ObjectName> names = server.queryNames(new ObjectName("test.MBeanRegistration:type=Integration,componentType=MessageHandler,*"), null);
|
||||
assertEquals(6, names.size());
|
||||
assertTrue(names.contains(new ObjectName("test.MBeanRegistration:type=Integration,componentType=MessageHandler,name=chain,bean=endpoint")));
|
||||
assertTrue(names.contains(new ObjectName("test.MBeanRegistration:type=Integration,componentType=MessageHandler,name=chain$child.t1,bean=handler")));
|
||||
assertTrue(names.contains(new ObjectName("test.MBeanRegistration:type=Integration,componentType=MessageHandler,name=chain$child.f1,bean=handler")));
|
||||
assertThat(names.size()).isEqualTo(6);
|
||||
assertThat(names
|
||||
.contains(new ObjectName("test.MBeanRegistration:type=Integration,componentType=MessageHandler," +
|
||||
"name=chain,bean=endpoint")))
|
||||
.isTrue();
|
||||
assertThat(names
|
||||
.contains(new ObjectName("test.MBeanRegistration:type=Integration,componentType=MessageHandler," +
|
||||
"name=chain$child.t1,bean=handler")))
|
||||
.isTrue();
|
||||
assertThat(names
|
||||
.contains(new ObjectName("test.MBeanRegistration:type=Integration,componentType=MessageHandler,name=chain$child.f1,bean=handler")))
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
public static class Source {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,9 +16,7 @@
|
||||
|
||||
package org.springframework.integration.jmx.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -54,20 +52,29 @@ public class MBeanRegistrationTests {
|
||||
@Test
|
||||
public void testHandlerMBeanRegistration() throws Exception {
|
||||
Set<ObjectName> names = server.queryNames(new ObjectName("test.MBeanRegistration:type=MessageHandler,*"), null);
|
||||
assertEquals(6, names.size());
|
||||
assertTrue(names.contains(new ObjectName("test.MBeanRegistration:type=MessageHandler,name=chain,bean=endpoint")));
|
||||
assertTrue(names.contains(new ObjectName("test.MBeanRegistration:type=MessageHandler,name=chain$child.t1,bean=handler")));
|
||||
assertTrue(names.contains(new ObjectName("test.MBeanRegistration:type=MessageHandler,name=chain$child.f1,bean=handler")));
|
||||
assertThat(names.size()).isEqualTo(6);
|
||||
assertThat(names
|
||||
.contains(new ObjectName("test.MBeanRegistration:type=MessageHandler,name=chain,bean=endpoint")))
|
||||
.isTrue();
|
||||
assertThat(names
|
||||
.contains(new ObjectName(
|
||||
"test.MBeanRegistration:type=MessageHandler,name=chain$child.t1,bean=handler")))
|
||||
.isTrue();
|
||||
assertThat(names
|
||||
.contains(new ObjectName("test.MBeanRegistration:type=MessageHandler,name=chain$child.f1,bean=handler")))
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExporterMBeanRegistration() throws Exception {
|
||||
// System . err.println(server.queryNames(new ObjectName("*:type=*MBeanExporter,*"), null));
|
||||
// System . err.println(Arrays.asList(server.getMBeanInfo(server.queryNames(new ObjectName("*:type=*Handler,*"), null).iterator().next()).getAttributes()));
|
||||
Set<ObjectName> names = server.queryNames(new ObjectName("test.MBeanRegistration:type=IntegrationMBeanExporter,name=integrationMbeanExporter,*"), null);
|
||||
assertEquals(1, names.size());
|
||||
names = server.queryNames(new ObjectName("test.MBeanRegistration:*,name=org.springframework.integration.MyGateway"), null);
|
||||
assertEquals(server.toString(), 1, names.size());
|
||||
Set<ObjectName> names = server.queryNames(new ObjectName(
|
||||
"test.MBeanRegistration:type=IntegrationMBeanExporter,name=integrationMbeanExporter,*"), null);
|
||||
assertThat(names.size()).isEqualTo(1);
|
||||
names = server.queryNames(new ObjectName("test.MBeanRegistration:*,name=org.springframework.integration" +
|
||||
".MyGateway"), null);
|
||||
assertThat(names.size()).as(server.toString()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -78,7 +85,7 @@ public class MBeanRegistrationTests {
|
||||
for (MBeanOperationInfo info : server.getMBeanInfo(names.iterator().next()).getOperations()) {
|
||||
infos.put(info.getName(), info);
|
||||
}
|
||||
assertNotNull(infos.get("setShouldTrack"));
|
||||
assertThat(infos.get("setShouldTrack")).isNotNull();
|
||||
}
|
||||
|
||||
public static class Source {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2017 the original author or authors.
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,11 +16,7 @@
|
||||
|
||||
package org.springframework.integration.jmx.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -111,16 +107,16 @@ public class MBeanTreePollingChannelAdapterParserTests {
|
||||
adapterDefault.start();
|
||||
|
||||
Message<?> result = channel1.receive(testTimeout);
|
||||
assertNotNull(result);
|
||||
assertThat(result).isNotNull();
|
||||
|
||||
assertEquals(HashMap.class, result.getPayload().getClass());
|
||||
assertThat(result.getPayload().getClass()).isEqualTo(HashMap.class);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> beans = (Map<String, Object>) result.getPayload();
|
||||
|
||||
// test for a couple of MBeans
|
||||
assertTrue(beans.containsKey("java.lang:type=OperatingSystem"));
|
||||
assertTrue(beans.containsKey("java.lang:type=Runtime"));
|
||||
assertThat(beans.containsKey("java.lang:type=OperatingSystem")).isTrue();
|
||||
assertThat(beans.containsKey("java.lang:type=Runtime")).isTrue();
|
||||
|
||||
adapterDefault.stop();
|
||||
}
|
||||
@@ -130,16 +126,16 @@ public class MBeanTreePollingChannelAdapterParserTests {
|
||||
adapterInner.start();
|
||||
|
||||
Message<?> result = channel2.receive(testTimeout);
|
||||
assertNotNull(result);
|
||||
assertThat(result).isNotNull();
|
||||
|
||||
assertEquals(HashMap.class, result.getPayload().getClass());
|
||||
assertThat(result.getPayload().getClass()).isEqualTo(HashMap.class);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> beans = (Map<String, Object>) result.getPayload();
|
||||
|
||||
// test for a couple of MBeans
|
||||
assertTrue(beans.containsKey("java.lang:type=OperatingSystem"));
|
||||
assertTrue(beans.containsKey("java.lang:type=Runtime"));
|
||||
assertThat(beans.containsKey("java.lang:type=OperatingSystem")).isTrue();
|
||||
assertThat(beans.containsKey("java.lang:type=Runtime")).isTrue();
|
||||
|
||||
adapterInner.stop();
|
||||
}
|
||||
@@ -149,22 +145,22 @@ public class MBeanTreePollingChannelAdapterParserTests {
|
||||
adapterQueryName.start();
|
||||
|
||||
ObjectName queryName = TestUtils.getPropertyValue(adapterQueryName, "source.queryName", ObjectName.class);
|
||||
assertEquals("java.lang:type=Runtime", queryName.getCanonicalName());
|
||||
assertThat(queryName.getCanonicalName()).isEqualTo("java.lang:type=Runtime");
|
||||
|
||||
QueryExp queryExp = TestUtils.getPropertyValue(adapterQueryName, "source.queryExpression", QueryExp.class);
|
||||
assertTrue(queryExp.apply(new ObjectName("java.lang:type=Runtime")));
|
||||
assertThat(queryExp.apply(new ObjectName("java.lang:type=Runtime"))).isTrue();
|
||||
|
||||
Message<?> result = channel3.receive(testTimeout);
|
||||
assertNotNull(result);
|
||||
assertThat(result).isNotNull();
|
||||
|
||||
assertEquals(HashMap.class, result.getPayload().getClass());
|
||||
assertThat(result.getPayload().getClass()).isEqualTo(HashMap.class);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> beans = (Map<String, Object>) result.getPayload();
|
||||
|
||||
// test for a couple of MBeans
|
||||
assertFalse(beans.containsKey("java.lang:type=OperatingSystem"));
|
||||
assertTrue(beans.containsKey("java.lang:type=Runtime"));
|
||||
assertThat(beans.containsKey("java.lang:type=OperatingSystem")).isFalse();
|
||||
assertThat(beans.containsKey("java.lang:type=Runtime")).isTrue();
|
||||
|
||||
adapterQueryName.stop();
|
||||
}
|
||||
@@ -174,16 +170,16 @@ public class MBeanTreePollingChannelAdapterParserTests {
|
||||
adapterQueryNameBean.start();
|
||||
|
||||
Message<?> result = channel4.receive(testTimeout);
|
||||
assertNotNull(result);
|
||||
assertThat(result).isNotNull();
|
||||
|
||||
assertEquals(HashMap.class, result.getPayload().getClass());
|
||||
assertThat(result.getPayload().getClass()).isEqualTo(HashMap.class);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> beans = (Map<String, Object>) result.getPayload();
|
||||
|
||||
// test for a couple of MBeans
|
||||
assertTrue(beans.containsKey("java.lang:type=OperatingSystem"));
|
||||
assertFalse(beans.containsKey("java.lang:type=Runtime"));
|
||||
assertThat(beans.containsKey("java.lang:type=OperatingSystem")).isTrue();
|
||||
assertThat(beans.containsKey("java.lang:type=Runtime")).isFalse();
|
||||
|
||||
adapterQueryNameBean.stop();
|
||||
}
|
||||
@@ -193,16 +189,16 @@ public class MBeanTreePollingChannelAdapterParserTests {
|
||||
adapterQueryExprBean.start();
|
||||
|
||||
Message<?> result = channel5.receive(testTimeout);
|
||||
assertNotNull(result);
|
||||
assertThat(result).isNotNull();
|
||||
|
||||
assertEquals(HashMap.class, result.getPayload().getClass());
|
||||
assertThat(result.getPayload().getClass()).isEqualTo(HashMap.class);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> beans = (Map<String, Object>) result.getPayload();
|
||||
|
||||
// test for a couple of MBeans
|
||||
assertFalse(beans.containsKey("java.lang:type=OperatingSystem"));
|
||||
assertTrue(beans.containsKey("java.lang:type=Runtime"));
|
||||
assertThat(beans.containsKey("java.lang:type=OperatingSystem")).isFalse();
|
||||
assertThat(beans.containsKey("java.lang:type=Runtime")).isTrue();
|
||||
|
||||
adapterQueryExprBean.stop();
|
||||
}
|
||||
@@ -212,19 +208,19 @@ public class MBeanTreePollingChannelAdapterParserTests {
|
||||
adapterConverter.start();
|
||||
|
||||
Message<?> result = channel6.receive(testTimeout);
|
||||
assertNotNull(result);
|
||||
assertThat(result).isNotNull();
|
||||
|
||||
assertEquals(HashMap.class, result.getPayload().getClass());
|
||||
assertThat(result.getPayload().getClass()).isEqualTo(HashMap.class);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> beans = (Map<String, Object>) result.getPayload();
|
||||
|
||||
// test for a couple of MBeans
|
||||
assertTrue(beans.containsKey("java.lang:type=OperatingSystem"));
|
||||
assertTrue(beans.containsKey("java.lang:type=Runtime"));
|
||||
assertThat(beans.containsKey("java.lang:type=OperatingSystem")).isTrue();
|
||||
assertThat(beans.containsKey("java.lang:type=Runtime")).isTrue();
|
||||
|
||||
adapterConverter.stop();
|
||||
assertSame(converter, TestUtils.getPropertyValue(adapterConverter, "source.converter"));
|
||||
assertThat(TestUtils.getPropertyValue(adapterConverter, "source.converter")).isSameAs(converter);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.integration.jmx.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@@ -47,11 +47,11 @@ public class MessageStoreTests {
|
||||
@Test
|
||||
public void testHandlerMBeanRegistration() throws Exception {
|
||||
Set<ObjectName> names = server.queryNames(new ObjectName("test.MessageStore:type=SimpleMessageStore,*"), null);
|
||||
assertEquals(1, names.size());
|
||||
assertThat(names.size()).isEqualTo(1);
|
||||
ObjectName name = names.iterator().next();
|
||||
assertEquals(0L, server.getAttribute(name, "MessageCount"));
|
||||
assertEquals(0, server.getAttribute(name, "MessageGroupCount"));
|
||||
assertEquals(0, server.getAttribute(name, "MessageCountForAllMessageGroups"));
|
||||
assertThat(server.getAttribute(name, "MessageCount")).isEqualTo(0L);
|
||||
assertThat(server.getAttribute(name, "MessageGroupCount")).isEqualTo(0);
|
||||
assertThat(server.getAttribute(name, "MessageCountForAllMessageGroups")).isEqualTo(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.integration.jmx.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@@ -58,8 +58,8 @@ public class MethodInvokerTests {
|
||||
Set<ObjectName> names = server.queryNames(new ObjectName("test.MethodInvoker:type=MessageHandler,*"), null);
|
||||
// System . err.println(names);
|
||||
// the router and the error handler...
|
||||
assertEquals(2, names.size());
|
||||
underscores.subscribe(message -> assertEquals("foo", message.getPayload()));
|
||||
assertThat(names.size()).isEqualTo(2);
|
||||
underscores.subscribe(message -> assertThat(message.getPayload()).isEqualTo("foo"));
|
||||
echos.send(MessageBuilder.withPayload("foo").setHeader("entity-type", "underscore").build());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,11 +16,7 @@
|
||||
|
||||
package org.springframework.integration.jmx.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import javax.management.Notification;
|
||||
|
||||
@@ -75,7 +71,7 @@ public class NotificationListeningChannelAdapterParserTests {
|
||||
@Test
|
||||
public void receiveNotification() throws Exception {
|
||||
this.multiAdapter.start();
|
||||
assertNull(channel.receive(0));
|
||||
assertThat(channel.receive(0)).isNull();
|
||||
testPublisher.send("ABC");
|
||||
verifyReceipt(channel, "testPublisher");
|
||||
verifyReceipt(patternChannel, "testPublisher");
|
||||
@@ -84,24 +80,24 @@ public class NotificationListeningChannelAdapterParserTests {
|
||||
verifyReceipt(multiChannel, "testPublisher");
|
||||
|
||||
testPublisher2.send("ABC");
|
||||
assertNull(channel.receive(0));
|
||||
assertNull(patternChannel.receive(0));
|
||||
assertThat(channel.receive(0)).isNull();
|
||||
assertThat(patternChannel.receive(0)).isNull();
|
||||
// multiChannel should see only 1 copy
|
||||
verifyReceipt(multiChannel, "testPublisher2");
|
||||
assertNull(multiChannel.receive(0));
|
||||
assertThat(multiChannel.receive(0)).isNull();
|
||||
}
|
||||
|
||||
private void verifyReceipt(PollableChannel channel, String beanName) {
|
||||
Message<?> message = channel.receive(1000);
|
||||
assertNotNull(message);
|
||||
assertEquals(Notification.class, message.getPayload().getClass());
|
||||
assertEquals("ABC", ((Notification) message.getPayload()).getMessage());
|
||||
assertTrue(((String) ((Notification) message.getPayload()).getSource()).endsWith(beanName));
|
||||
assertThat(message).isNotNull();
|
||||
assertThat(message.getPayload().getClass()).isEqualTo(Notification.class);
|
||||
assertThat(((Notification) message.getPayload()).getMessage()).isEqualTo("ABC");
|
||||
assertThat(((String) ((Notification) message.getPayload()).getSource()).endsWith(beanName)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAutoChannel() {
|
||||
assertSame(autoChannel, TestUtils.getPropertyValue(autoChannelAdapter, "outputChannel"));
|
||||
assertThat(TestUtils.getPropertyValue(autoChannelAdapter, "outputChannel")).isSameAs(autoChannel);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,14 +16,8 @@
|
||||
|
||||
package org.springframework.integration.jmx.config;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@@ -86,66 +80,65 @@ public class NotificationPublishingChannelAdapterParserTests {
|
||||
@Test
|
||||
public void publishStringMessage() throws Exception {
|
||||
adviceCalled = 0;
|
||||
assertNull(listener.lastNotification);
|
||||
assertThat(listener.lastNotification).isNull();
|
||||
Message<?> message = MessageBuilder.withPayload("XYZ")
|
||||
.setHeader(JmxHeaders.NOTIFICATION_TYPE, "test.type").build();
|
||||
channel.send(message);
|
||||
assertNotNull(listener.lastNotification);
|
||||
assertThat(listener.lastNotification).isNotNull();
|
||||
Notification notification = listener.lastNotification;
|
||||
assertEquals("XYZ", notification.getMessage());
|
||||
assertEquals("test.type", notification.getType());
|
||||
assertNull(notification.getUserData());
|
||||
assertEquals(1, adviceCalled);
|
||||
assertThat(notification.getMessage()).isEqualTo("XYZ");
|
||||
assertThat(notification.getType()).isEqualTo("test.type");
|
||||
assertThat(notification.getUserData()).isNull();
|
||||
assertThat(adviceCalled).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void publishUserData() throws Exception {
|
||||
assertNull(listener.lastNotification);
|
||||
assertThat(listener.lastNotification).isNull();
|
||||
TestData data = new TestData();
|
||||
Message<?> message = MessageBuilder.withPayload(data)
|
||||
.setHeader(JmxHeaders.NOTIFICATION_TYPE, "test.type").build();
|
||||
channel.send(message);
|
||||
assertNotNull(listener.lastNotification);
|
||||
assertThat(listener.lastNotification).isNotNull();
|
||||
Notification notification = listener.lastNotification;
|
||||
assertNull(notification.getMessage());
|
||||
assertEquals(data, notification.getUserData());
|
||||
assertEquals("test.type", notification.getType());
|
||||
assertThat(notification.getMessage()).isNull();
|
||||
assertThat(notification.getUserData()).isEqualTo(data);
|
||||
assertThat(notification.getType()).isEqualTo("test.type");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void defaultNotificationType() throws Exception {
|
||||
assertNull(listener.lastNotification);
|
||||
assertThat(listener.lastNotification).isNull();
|
||||
Message<?> message = MessageBuilder.withPayload("test").build();
|
||||
channel.send(message);
|
||||
assertNotNull(listener.lastNotification);
|
||||
assertThat(listener.lastNotification).isNotNull();
|
||||
Notification notification = listener.lastNotification;
|
||||
assertEquals("default.type", notification.getType());
|
||||
assertThat(notification.getType()).isEqualTo("default.type");
|
||||
}
|
||||
|
||||
@Test //INT-2275
|
||||
public void publishStringMessageWithinChain() throws Exception {
|
||||
assertNotNull(
|
||||
this.beanFactory.getBean(
|
||||
"chainWithJmxNotificationPublishing$child."
|
||||
+ "jmx-notification-publishing-channel-adapter-within-chain.handler",
|
||||
MessageHandler.class));
|
||||
assertNull(listener.lastNotification);
|
||||
assertThat(this.beanFactory.getBean(
|
||||
"chainWithJmxNotificationPublishing$child."
|
||||
+ "jmx-notification-publishing-channel-adapter-within-chain.handler",
|
||||
MessageHandler.class)).isNotNull();
|
||||
assertThat(listener.lastNotification).isNull();
|
||||
Message<?> message = MessageBuilder.withPayload("XYZ")
|
||||
.setHeader(JmxHeaders.NOTIFICATION_TYPE, "test.type").build();
|
||||
publishingWithinChainChannel.send(message);
|
||||
assertNotNull(listener.lastNotification);
|
||||
assertThat(listener.lastNotification).isNotNull();
|
||||
Notification notification = listener.lastNotification;
|
||||
assertEquals("XYZ", notification.getMessage());
|
||||
assertEquals("test.type", notification.getType());
|
||||
assertNull(notification.getUserData());
|
||||
assertThat(notification.getMessage()).isEqualTo("XYZ");
|
||||
assertThat(notification.getType()).isEqualTo("test.type");
|
||||
assertThat(notification.getUserData()).isNull();
|
||||
Set<ObjectName> names = server
|
||||
.queryNames(new ObjectName("*:type=MessageHandler," + "name=\"chainWithJmxNotificationPublishing$child."
|
||||
+ "jmx-notification-publishing-channel-adapter-within-chain\",*"), null);
|
||||
assertEquals(1, names.size());
|
||||
assertThat(names.size()).isEqualTo(1);
|
||||
names = server
|
||||
.queryNames(new ObjectName("*:type=MessageChannel,"
|
||||
+ "name=org.springframework.integration.test.anon,source=anonymous,*"), null);
|
||||
assertEquals(1, names.size());
|
||||
assertThat(names.size()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test @DirtiesContext
|
||||
@@ -160,20 +153,20 @@ public class NotificationPublishingChannelAdapterParserTests {
|
||||
fail("Exception expected");
|
||||
}
|
||||
catch (MBeanException e) {
|
||||
assertThat(e.getTargetException(), instanceOf(IllegalStateException.class));
|
||||
assertThat(e.getTargetException().getMessage(), containsString("cannot be changed"));
|
||||
assertThat(e.getTargetException()).isInstanceOf(IllegalStateException.class);
|
||||
assertThat(e.getTargetException().getMessage()).contains("cannot be changed");
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw e;
|
||||
}
|
||||
server.invoke(objectName, "stop", new Object[]{}, new String[]{});
|
||||
server.setAttribute(objectName, new Attribute("ComponentNamePatternsString", "foo, bar"));
|
||||
assertEquals("bar,foo", server.getAttribute(objectName, "ComponentNamePatternsString"));
|
||||
assertThat(server.getAttribute(objectName, "ComponentNamePatternsString")).isEqualTo("bar,foo");
|
||||
tested = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
assertTrue(tested);
|
||||
assertThat(tested).isTrue();
|
||||
}
|
||||
|
||||
private static class TestData {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.integration.jmx.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.BDDMockito.willReturn;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
@@ -89,12 +89,12 @@ public class OperationInvokingChannelAdapterParserTests {
|
||||
|
||||
@Test
|
||||
public void adapterWithDefaults() {
|
||||
assertEquals(0, testBean.messages.size());
|
||||
assertThat(testBean.messages.size()).isEqualTo(0);
|
||||
input.send(new GenericMessage<>("test1"));
|
||||
input.send(new GenericMessage<>("test2"));
|
||||
input.send(new GenericMessage<>("test3"));
|
||||
assertEquals(3, testBean.messages.size());
|
||||
assertEquals(3, adviceCalled);
|
||||
assertThat(testBean.messages.size()).isEqualTo(3);
|
||||
assertThat(adviceCalled).isEqualTo(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -118,17 +118,17 @@ public class OperationInvokingChannelAdapterParserTests {
|
||||
@Test
|
||||
// Headers should be ignored
|
||||
public void adapterWitJmxHeaders() {
|
||||
assertEquals(0, testBean.messages.size());
|
||||
assertThat(testBean.messages.size()).isEqualTo(0);
|
||||
input.send(this.createMessage("1"));
|
||||
input.send(this.createMessage("2"));
|
||||
input.send(this.createMessage("3"));
|
||||
assertEquals(3, testBean.messages.size());
|
||||
assertThat(testBean.messages.size()).isEqualTo(3);
|
||||
}
|
||||
|
||||
@Test //INT-2275
|
||||
public void testInvokeOperationWithinChain() {
|
||||
operationInvokingWithinChain.send(new GenericMessage<>("test1"));
|
||||
assertEquals(1, testBean.messages.size());
|
||||
assertThat(testBean.messages.size()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,17 +16,14 @@
|
||||
|
||||
package org.springframework.integration.jmx.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -93,30 +90,30 @@ public class OperationInvokingOutboundGatewayTests {
|
||||
@Test
|
||||
public void gatewayWithReplyChannel() throws Exception {
|
||||
withReplyChannel.send(new GenericMessage<String>("1"));
|
||||
assertEquals(1, ((List<?>) withReplyChannelOutput.receive().getPayload()).size());
|
||||
assertThat(((List<?>) withReplyChannelOutput.receive().getPayload()).size()).isEqualTo(1);
|
||||
withReplyChannel.send(new GenericMessage<String>("2"));
|
||||
assertEquals(2, ((List<?>) withReplyChannelOutput.receive().getPayload()).size());
|
||||
assertThat(((List<?>) withReplyChannelOutput.receive().getPayload()).size()).isEqualTo(2);
|
||||
withReplyChannel.send(new GenericMessage<String>("3"));
|
||||
assertEquals(3, ((List<?>) withReplyChannelOutput.receive().getPayload()).size());
|
||||
assertEquals(3, adviceCalled);
|
||||
assertThat(((List<?>) withReplyChannelOutput.receive().getPayload()).size()).isEqualTo(3);
|
||||
assertThat(adviceCalled).isEqualTo(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void gatewayWithPrimitiveArgs() throws Exception {
|
||||
primitiveChannel.send(new GenericMessage<Object[]>(new Object[] { true, 0L, 1 }));
|
||||
assertEquals(1, testBean.messages.size());
|
||||
assertThat(testBean.messages.size()).isEqualTo(1);
|
||||
List<Object> argList = new ArrayList<Object>();
|
||||
argList.add(false);
|
||||
argList.add(123L);
|
||||
argList.add(42);
|
||||
primitiveChannel.send(new GenericMessage<List<Object>>(argList));
|
||||
assertEquals(2, testBean.messages.size());
|
||||
assertThat(testBean.messages.size()).isEqualTo(2);
|
||||
Map<String, Object> argMap = new HashMap<String, Object>();
|
||||
argMap.put("p1", true);
|
||||
argMap.put("p2", 0L);
|
||||
argMap.put("p3", 42);
|
||||
primitiveChannel.send(new GenericMessage<Map<String, Object>>(argMap));
|
||||
assertEquals(3, testBean.messages.size());
|
||||
assertThat(testBean.messages.size()).isEqualTo(3);
|
||||
argMap.put("p2", true);
|
||||
argMap.put("p1", 0L);
|
||||
argMap.put("p3", 42);
|
||||
@@ -125,8 +122,8 @@ public class OperationInvokingOutboundGatewayTests {
|
||||
fail("Expected Exception");
|
||||
}
|
||||
catch (Exception e) {
|
||||
assertThat(e, Matchers.instanceOf(MessagingException.class));
|
||||
assertThat(e.getMessage(), Matchers.containsString("failed to find JMX operation"));
|
||||
assertThat(e).isInstanceOf(MessagingException.class);
|
||||
assertThat(e.getMessage()).contains("failed to find JMX operation");
|
||||
}
|
||||
// Args are named starting with Spring 3.2.3
|
||||
argMap = new HashMap<String, Object>();
|
||||
@@ -134,33 +131,33 @@ public class OperationInvokingOutboundGatewayTests {
|
||||
argMap.put("time", 0L);
|
||||
argMap.put("foo", 42);
|
||||
primitiveChannel.send(new GenericMessage<Map<String, Object>>(argMap));
|
||||
assertEquals(4, testBean.messages.size());
|
||||
assertThat(testBean.messages.size()).isEqualTo(4);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void gatewayWithNoReplyChannel() throws Exception {
|
||||
withNoReplyChannel.send(new GenericMessage<String>("1"));
|
||||
assertEquals(1, testBean.messages.size());
|
||||
assertThat(testBean.messages.size()).isEqualTo(1);
|
||||
withNoReplyChannel.send(new GenericMessage<String>("2"));
|
||||
assertEquals(2, testBean.messages.size());
|
||||
assertThat(testBean.messages.size()).isEqualTo(2);
|
||||
withNoReplyChannel.send(new GenericMessage<String>("3"));
|
||||
assertEquals(3, testBean.messages.size());
|
||||
assertThat(testBean.messages.size()).isEqualTo(3);
|
||||
}
|
||||
|
||||
@Test //INT-1029, INT-2822
|
||||
public void testOutboundGatewayInsideChain() throws Exception {
|
||||
List<?> handlers = TestUtils.getPropertyValue(this.operationInvokingWithinChain, "handlers", List.class);
|
||||
assertEquals(1, handlers.size());
|
||||
assertThat(handlers.size()).isEqualTo(1);
|
||||
Object handler = handlers.get(0);
|
||||
assertTrue(handler instanceof OperationInvokingMessageHandler);
|
||||
assertTrue(TestUtils.getPropertyValue(handler, "requiresReply", Boolean.class));
|
||||
assertThat(handler instanceof OperationInvokingMessageHandler).isTrue();
|
||||
assertThat(TestUtils.getPropertyValue(handler, "requiresReply", Boolean.class)).isTrue();
|
||||
|
||||
jmxOutboundGatewayInsideChain.send(MessageBuilder.withPayload("1").build());
|
||||
assertEquals(1, ((List<?>) withReplyChannelOutput.receive().getPayload()).size());
|
||||
assertThat(((List<?>) withReplyChannelOutput.receive().getPayload()).size()).isEqualTo(1);
|
||||
jmxOutboundGatewayInsideChain.send(MessageBuilder.withPayload("2").build());
|
||||
assertEquals(2, ((List<?>) withReplyChannelOutput.receive().getPayload()).size());
|
||||
assertThat(((List<?>) withReplyChannelOutput.receive().getPayload()).size()).isEqualTo(2);
|
||||
jmxOutboundGatewayInsideChain.send(MessageBuilder.withPayload("3").build());
|
||||
assertEquals(3, ((List<?>) withReplyChannelOutput.receive().getPayload()).size());
|
||||
assertThat(((List<?>) withReplyChannelOutput.receive().getPayload()).size()).isEqualTo(3);
|
||||
}
|
||||
|
||||
public static class FooAdvice extends AbstractRequestHandlerAdvice {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.integration.jmx.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@@ -48,7 +48,7 @@ public class PollingAdapterMBeanTests {
|
||||
public void testMessageSourceMBeanExists() throws Exception {
|
||||
// System . err.println(server.queryNames(new ObjectName("*:type=MessageSource,*"), null));
|
||||
Set<ObjectName> names = server.queryNames(new ObjectName("test.PollingAdapterMBean:type=MessageSource,*"), null);
|
||||
assertEquals(1, names.size());
|
||||
assertThat(names.size()).isEqualTo(1);
|
||||
}
|
||||
|
||||
public static class Source {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.integration.jmx.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@@ -53,15 +53,15 @@ public class PriorityChannelTests {
|
||||
public void testHandlerMBeanRegistration() throws Exception {
|
||||
Set<ObjectName> names = server.queryNames(new ObjectName("test.PriorityChannel:type=MessageHandler,*"), null);
|
||||
// Error handler plus the service activator
|
||||
assertEquals(2, names.size());
|
||||
assertThat(names.size()).isEqualTo(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChannelMBeanRegistration() throws Exception {
|
||||
Set<ObjectName> names = server.queryNames(new ObjectName("test.PriorityChannel:type=MessageChannel,name=testChannel,*"), null);
|
||||
assertEquals(1, names.size());
|
||||
assertEquals(0, server.getAttribute(names.iterator().next(), "QueueSize"));
|
||||
assertEquals(0, ((QueueChannelOperations) testChannel).getQueueSize());
|
||||
assertThat(names.size()).isEqualTo(1);
|
||||
assertThat(server.getAttribute(names.iterator().next(), "QueueSize")).isEqualTo(0);
|
||||
assertThat(((QueueChannelOperations) testChannel).getQueueSize()).isEqualTo(0);
|
||||
}
|
||||
|
||||
public static class Source {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.integration.jmx.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -70,7 +70,7 @@ public class RouterMBeanTests {
|
||||
// System . err.println(server.queryNames(new ObjectName("test.RouterMBean:*"), null));
|
||||
Set<ObjectName> names = server.queryNames(
|
||||
new ObjectName("test.RouterMBean:type=MessageHandler,name=ptRouter,*"), null);
|
||||
assertEquals(1, names.size());
|
||||
assertThat(names.size()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -78,24 +78,24 @@ public class RouterMBeanTests {
|
||||
// System . err.println(server.queryNames(new ObjectName("test.RouterMBean:type=MessageChannel,*"), null));
|
||||
Set<ObjectName> names = server.queryNames(
|
||||
new ObjectName("test.RouterMBean:type=MessageChannel,name=testChannel,*"), null);
|
||||
assertEquals(1, names.size());
|
||||
assertThat(names.size()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testErrorChannelMBeanExists() throws Exception {
|
||||
Set<ObjectName> names = server.queryNames(
|
||||
new ObjectName("test.RouterMBean:type=MessageChannel,name=errorChannel,*"), null);
|
||||
assertEquals(1, names.size());
|
||||
assertThat(names.size()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRouterMBeanOnlyRegisteredOnce() throws Exception {
|
||||
// System . err.println(server.queryNames(new ObjectName("*:type=MessageHandler,*"), null));
|
||||
Set<ObjectName> names = server.queryNames(new ObjectName("test.RouterMBean:type=MessageHandler,name=ptRouter,*"), null);
|
||||
assertEquals(1, names.size());
|
||||
assertThat(names.size()).isEqualTo(1);
|
||||
// INT-3896
|
||||
names = server.queryNames(new ObjectName("test.RouterMBean:type=ExpressionEvaluatingRouter,*"), null);
|
||||
assertEquals(0, names.size());
|
||||
assertThat(names.size()).isEqualTo(0);
|
||||
}
|
||||
|
||||
public interface Service {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.integration.jmx.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@@ -49,7 +49,7 @@ public class RouterMBeanVanillaTests {
|
||||
// System . err.println(server.queryNames(new ObjectName("test.RouterMBeanVanilla:*"), null));
|
||||
Set<ObjectName> names = server.queryNames(new ObjectName("test.RouterMBeanVanilla:type=ExpressionEvaluatingRouter,*"), null);
|
||||
// The router is exposed...
|
||||
assertEquals(1, names.size());
|
||||
assertThat(names.size()).isEqualTo(1);
|
||||
}
|
||||
|
||||
public static class Source {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2015 the original author or authors.
|
||||
* Copyright 2014-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,13 +16,7 @@
|
||||
|
||||
package org.springframework.integration.jmx.configuration;
|
||||
|
||||
import static org.hamcrest.Matchers.arrayContaining;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@@ -84,24 +78,24 @@ public class EnableMBeanExportTests {
|
||||
@Test
|
||||
public void testEnableMBeanExport() throws MalformedObjectNameException, ClassNotFoundException {
|
||||
|
||||
assertSame(this.mBeanServer, this.exporter.getServer());
|
||||
assertThat(this.exporter.getServer()).isSameAs(this.mBeanServer);
|
||||
String[] componentNamePatterns = TestUtils.getPropertyValue(this.exporter, "componentNamePatterns", String[].class);
|
||||
assertThat(componentNamePatterns, arrayContaining("input", "inputX", "in*"));
|
||||
assertThat(componentNamePatterns).containsExactly("input", "inputX", "in*");
|
||||
String[] enabledCounts = TestUtils.getPropertyValue(this.configurer, "enabledCountsPatterns", String[].class);
|
||||
assertThat(enabledCounts, arrayContaining("foo", "bar", "baz"));
|
||||
assertThat(enabledCounts).containsExactly("foo", "bar", "baz");
|
||||
String[] enabledStats = TestUtils.getPropertyValue(this.configurer, "enabledStatsPatterns", String[].class);
|
||||
assertThat(enabledStats, arrayContaining("qux", "!*"));
|
||||
assertFalse(TestUtils.getPropertyValue(this.configurer, "defaultLoggingEnabled", Boolean.class));
|
||||
assertTrue(TestUtils.getPropertyValue(this.configurer, "defaultCountsEnabled", Boolean.class));
|
||||
assertTrue(TestUtils.getPropertyValue(this.configurer, "defaultStatsEnabled", Boolean.class));
|
||||
assertSame(this.myMetricsFactory, TestUtils.getPropertyValue(this.configurer, "metricsFactory"));
|
||||
assertThat(enabledStats).containsExactly("qux", "!*");
|
||||
assertThat(TestUtils.getPropertyValue(this.configurer, "defaultLoggingEnabled", Boolean.class)).isFalse();
|
||||
assertThat(TestUtils.getPropertyValue(this.configurer, "defaultCountsEnabled", Boolean.class)).isTrue();
|
||||
assertThat(TestUtils.getPropertyValue(this.configurer, "defaultStatsEnabled", Boolean.class)).isTrue();
|
||||
assertThat(TestUtils.getPropertyValue(this.configurer, "metricsFactory")).isSameAs(this.myMetricsFactory);
|
||||
|
||||
Set<ObjectName> names = this.mBeanServer.queryNames(ObjectName.getInstance("FOO:type=MessageChannel,*"), null);
|
||||
// Only one registered (out of >2 available)
|
||||
assertEquals(1, names.size());
|
||||
assertEquals("input", names.iterator().next().getKeyProperty("name"));
|
||||
assertThat(names.size()).isEqualTo(1);
|
||||
assertThat(names.iterator().next().getKeyProperty("name")).isEqualTo("input");
|
||||
names = this.mBeanServer.queryNames(ObjectName.getInstance("FOO:type=MessageHandler,*"), null);
|
||||
assertEquals(0, names.size());
|
||||
assertThat(names.size()).isEqualTo(0);
|
||||
|
||||
Class<?> clazz = Class.forName("org.springframework.integration.jmx.config.MBeanExporterHelper");
|
||||
List<Object> beanPostProcessors = TestUtils.getPropertyValue(beanFactory, "beanPostProcessors", List.class);
|
||||
@@ -112,9 +106,11 @@ public class EnableMBeanExportTests {
|
||||
break;
|
||||
}
|
||||
}
|
||||
assertNotNull(mBeanExporterHelper);
|
||||
assertTrue(TestUtils.getPropertyValue(mBeanExporterHelper, "siBeanNames", Set.class).contains("input"));
|
||||
assertTrue(TestUtils.getPropertyValue(mBeanExporterHelper, "siBeanNames", Set.class).contains("output"));
|
||||
assertThat(mBeanExporterHelper).isNotNull();
|
||||
assertThat(TestUtils.getPropertyValue(mBeanExporterHelper, "siBeanNames", Set.class).contains("input"))
|
||||
.isTrue();
|
||||
assertThat(TestUtils.getPropertyValue(mBeanExporterHelper, "siBeanNames", Set.class).contains("output"))
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
@Configuration
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2016 the original author or authors.
|
||||
* Copyright 2015-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,9 +16,7 @@
|
||||
|
||||
package org.springframework.integration.monitor;
|
||||
|
||||
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
@@ -70,11 +68,11 @@ public class AggregatingMetricsTests {
|
||||
for (int i = 0; i < count; i++) {
|
||||
input.send(message);
|
||||
}
|
||||
assertEquals(count, this.output.getQueueSize());
|
||||
assertEquals(count, this.output.getSendCount());
|
||||
assertEquals(Long.valueOf(count / 1000).longValue(), this.output.getSendDuration().getCountLong());
|
||||
assertEquals(count, this.handler.getHandleCount());
|
||||
assertEquals(Long.valueOf(count / 1000).longValue(), this.handler.getDuration().getCountLong());
|
||||
assertThat(this.output.getQueueSize()).isEqualTo(count);
|
||||
assertThat(this.output.getSendCount()).isEqualTo(count);
|
||||
assertThat(this.output.getSendDuration().getCountLong()).isEqualTo(Long.valueOf(count / 1000).longValue());
|
||||
assertThat(this.handler.getHandleCount()).isEqualTo(count);
|
||||
assertThat(this.handler.getDuration().getCountLong()).isEqualTo(Long.valueOf(count / 1000).longValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -89,12 +87,12 @@ public class AggregatingMetricsTests {
|
||||
for (int i = 0; i < count; i++) {
|
||||
this.delay.send(message);
|
||||
}
|
||||
assertEquals(count, this.delay.getSendCount());
|
||||
assertEquals(count / sampleSize, this.delay.getSendDuration().getCount());
|
||||
assertThat((int) this.delay.getMeanSendDuration() / sampleSize, greaterThanOrEqualTo(50));
|
||||
assertEquals(count, this.delayer.getHandleCount());
|
||||
assertEquals(count / sampleSize, this.delayer.getDuration().getCount());
|
||||
assertThat((int) this.delayer.getMeanDuration() / sampleSize, greaterThanOrEqualTo(50));
|
||||
assertThat(this.delay.getSendCount()).isEqualTo(count);
|
||||
assertThat(this.delay.getSendDuration().getCount()).isEqualTo(count / sampleSize);
|
||||
assertThat((int) this.delay.getMeanSendDuration() / sampleSize).isGreaterThanOrEqualTo(50);
|
||||
assertThat(this.delayer.getHandleCount()).isEqualTo(count);
|
||||
assertThat(this.delayer.getDuration().getCount()).isEqualTo(count / sampleSize);
|
||||
assertThat((int) this.delayer.getMeanDuration() / sampleSize).isGreaterThanOrEqualTo(50);
|
||||
}
|
||||
|
||||
@Test @Ignore
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.integration.monitor;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -44,7 +44,7 @@ public class ChainWithMessageProducingHandlersTests {
|
||||
@Test
|
||||
public void testSuccessfulApplicationContext() {
|
||||
// this is all we need to do. Until INT-1431 was solved initialization of this AC would fail.
|
||||
assertNotNull(applicationContext);
|
||||
assertThat(applicationContext).isNotNull();
|
||||
}
|
||||
|
||||
public static class SampleProducer {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2009-2016 the original author or authors.
|
||||
* Copyright 2009-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,10 +16,7 @@
|
||||
|
||||
package org.springframework.integration.monitor;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -64,16 +61,16 @@ public class ChannelIntegrationTests {
|
||||
|
||||
String intermediateChannelName = "" + intermediate;
|
||||
|
||||
assertEquals(1, messageChannelsMonitor.getChannelSendCount(intermediateChannelName));
|
||||
assertThat(messageChannelsMonitor.getChannelSendCount(intermediateChannelName)).isEqualTo(1);
|
||||
|
||||
double rate = messageChannelsMonitor.getChannelSendRate("" + requests).getMean();
|
||||
assertTrue("No statistics for requests channel", rate >= 0);
|
||||
assertThat(rate >= 0).as("No statistics for requests channel").isTrue();
|
||||
|
||||
rate = messageChannelsMonitor.getChannelSendRate(intermediateChannelName).getMean();
|
||||
assertTrue("No statistics for intermediate channel", rate >= 0);
|
||||
assertThat(rate >= 0).as("No statistics for intermediate channel").isTrue();
|
||||
|
||||
assertNotNull(intermediate.receive(100L));
|
||||
assertEquals(1, messageChannelsMonitor.getChannelReceiveCount(intermediateChannelName));
|
||||
assertThat(intermediate.receive(100L)).isNotNull();
|
||||
assertThat(messageChannelsMonitor.getChannelReceiveCount(intermediateChannelName)).isEqualTo(1);
|
||||
|
||||
requests.send(new GenericMessage<String>("foo"));
|
||||
try {
|
||||
@@ -82,21 +79,21 @@ public class ChannelIntegrationTests {
|
||||
catch (MessageDeliveryException e) {
|
||||
}
|
||||
|
||||
assertEquals(3, messageChannelsMonitor.getChannelSendCount(intermediateChannelName));
|
||||
assertThat(messageChannelsMonitor.getChannelSendCount(intermediateChannelName)).isEqualTo(3);
|
||||
|
||||
assertEquals(1, messageChannelsMonitor.getChannelSendErrorCount(intermediateChannelName));
|
||||
assertThat(messageChannelsMonitor.getChannelSendErrorCount(intermediateChannelName)).isEqualTo(1);
|
||||
|
||||
assertSame(intermediate, messageChannelsMonitor.getChannelMetrics(intermediateChannelName));
|
||||
assertThat(messageChannelsMonitor.getChannelMetrics(intermediateChannelName)).isSameAs(intermediate);
|
||||
|
||||
MessageHandlerMetrics handlerMetrics = messageChannelsMonitor.getHandlerMetrics("bridge");
|
||||
|
||||
assertEquals(3, handlerMetrics.getHandleCount());
|
||||
assertEquals(1, handlerMetrics.getErrorCount());
|
||||
assertThat(handlerMetrics.getHandleCount()).isEqualTo(3);
|
||||
assertThat(handlerMetrics.getErrorCount()).isEqualTo(1);
|
||||
|
||||
assertNotNull(this.sourceChannel.receive(10000));
|
||||
assertThat(this.sourceChannel.receive(10000)).isNotNull();
|
||||
|
||||
assertTrue(messageChannelsMonitor.getSourceMessageCount("source") > 0);
|
||||
assertTrue(messageChannelsMonitor.getSourceMetrics("source").getMessageCount() > 0);
|
||||
assertThat(messageChannelsMonitor.getSourceMessageCount("source") > 0).isTrue();
|
||||
assertThat(messageChannelsMonitor.getSourceMetrics("source").getMessageCount() > 0).isTrue();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2009-2018 the original author or authors.
|
||||
* Copyright 2009-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
package org.springframework.integration.monitor;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -75,7 +74,7 @@ public class HandlerMonitoringIntegrationTests {
|
||||
public void testErrorLogger() {
|
||||
ClassPathXmlApplicationContext context = createContext("anonymous-handler.xml", "anonymous");
|
||||
try {
|
||||
assertTrue(Arrays.asList(messageHandlersMonitor.getHandlerNames()).contains("errorLogger"));
|
||||
assertThat(Arrays.asList(messageHandlersMonitor.getHandlerNames()).contains("errorLogger")).isTrue();
|
||||
}
|
||||
finally {
|
||||
context.close();
|
||||
@@ -88,10 +87,10 @@ public class HandlerMonitoringIntegrationTests {
|
||||
try {
|
||||
int before = service.getCounter();
|
||||
channel.send(new GenericMessage<>("bar"));
|
||||
assertEquals(before + 1, service.getCounter());
|
||||
assertThat(service.getCounter()).isEqualTo(before + 1);
|
||||
|
||||
int count = messageHandlersMonitor.getHandlerDuration(monitor).getCount();
|
||||
assertTrue("No statistics for input channel", count > 0);
|
||||
assertThat(count > 0).as("No statistics for input channel").isTrue();
|
||||
|
||||
}
|
||||
finally {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2018 the original author or authors.
|
||||
* Copyright 2014-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,14 +16,8 @@
|
||||
|
||||
package org.springframework.integration.monitor;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
import static org.mockito.Mockito.spy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -137,28 +131,29 @@ public class IdempotentReceiverIntegrationTests {
|
||||
Message<String> message = new GenericMessage<>("foo");
|
||||
this.input.send(message);
|
||||
Message<?> receive = this.output.receive(10000);
|
||||
assertNotNull(receive);
|
||||
assertEquals(1, this.adviceCalled.get());
|
||||
assertEquals(1, TestUtils.getPropertyValue(this.store, "metadata", Map.class).size());
|
||||
assertThat(receive).isNotNull();
|
||||
assertThat(this.adviceCalled.get()).isEqualTo(1);
|
||||
assertThat(TestUtils.getPropertyValue(this.store, "metadata", Map.class).size()).isEqualTo(1);
|
||||
String foo = this.store.get("foo");
|
||||
assertEquals("FOO", foo);
|
||||
assertThat(foo).isEqualTo("FOO");
|
||||
|
||||
try {
|
||||
this.input.send(message);
|
||||
fail("MessageRejectedException expected");
|
||||
}
|
||||
catch (Exception e) {
|
||||
assertThat(e, instanceOf(MessageRejectedException.class));
|
||||
assertThat(e).isInstanceOf(MessageRejectedException.class);
|
||||
}
|
||||
this.idempotentReceiverInterceptor.setThrowExceptionOnRejection(false);
|
||||
this.input.send(message);
|
||||
receive = this.output.receive(10000);
|
||||
assertNotNull(receive);
|
||||
assertEquals(2, this.adviceCalled.get());
|
||||
assertTrue(receive.getHeaders().get(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE, Boolean.class));
|
||||
assertEquals(1, TestUtils.getPropertyValue(store, "metadata", Map.class).size());
|
||||
assertThat(receive).isNotNull();
|
||||
assertThat(this.adviceCalled.get()).isEqualTo(2);
|
||||
assertThat(receive.getHeaders().get(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE, Boolean.class))
|
||||
.isTrue();
|
||||
assertThat(TestUtils.getPropertyValue(store, "metadata", Map.class).size()).isEqualTo(1);
|
||||
|
||||
assertTrue(this.txSupplied.get());
|
||||
assertThat(this.txSupplied.get()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -168,11 +163,10 @@ public class IdempotentReceiverIntegrationTests {
|
||||
this.annotatedMethodChannel.send(message);
|
||||
this.annotatedMethodChannel.send(message);
|
||||
|
||||
assertEquals(2, this.fooService.messages.size());
|
||||
assertTrue(
|
||||
this.fooService.messages.get(1)
|
||||
.getHeaders()
|
||||
.get(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE, Boolean.class));
|
||||
assertThat(this.fooService.messages.size()).isEqualTo(2);
|
||||
assertThat(this.fooService.messages.get(1)
|
||||
.getHeaders()
|
||||
.get(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE, Boolean.class)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -182,14 +176,15 @@ public class IdempotentReceiverIntegrationTests {
|
||||
this.annotatedBeanMessageHandlerChannel.send(message);
|
||||
|
||||
Message<?> receive = replyChannel.receive(10000);
|
||||
assertNotNull(receive);
|
||||
assertFalse(receive.getHeaders().containsKey(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE));
|
||||
assertThat(receive).isNotNull();
|
||||
assertThat(receive.getHeaders().containsKey(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE)).isFalse();
|
||||
|
||||
this.annotatedBeanMessageHandlerChannel.send(message);
|
||||
receive = replyChannel.receive(10000);
|
||||
assertNotNull(receive);
|
||||
assertTrue(receive.getHeaders().containsKey(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE));
|
||||
assertTrue(receive.getHeaders().get(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE, Boolean.class));
|
||||
assertThat(receive).isNotNull();
|
||||
assertThat(receive.getHeaders().containsKey(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE)).isTrue();
|
||||
assertThat(receive.getHeaders().get(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE, Boolean.class))
|
||||
.isTrue();
|
||||
|
||||
this.annotatedBeanMessageHandlerChannel2.send(new GenericMessage<String>("baz"));
|
||||
try {
|
||||
@@ -197,7 +192,7 @@ public class IdempotentReceiverIntegrationTests {
|
||||
fail("MessageHandlingException expected");
|
||||
}
|
||||
catch (Exception e) {
|
||||
assertThat(e.getMessage(), containsString("duplicate message has been received"));
|
||||
assertThat(e.getMessage()).contains("duplicate message has been received");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,14 +204,15 @@ public class IdempotentReceiverIntegrationTests {
|
||||
this.bridgeChannel.send(message);
|
||||
|
||||
Message<?> receive = replyChannel.receive(10000);
|
||||
assertNotNull(receive);
|
||||
assertFalse(receive.getHeaders().containsKey(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE));
|
||||
assertThat(receive).isNotNull();
|
||||
assertThat(receive.getHeaders().containsKey(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE)).isFalse();
|
||||
|
||||
this.bridgeChannel.send(message);
|
||||
receive = replyChannel.receive(10000);
|
||||
assertNotNull(receive);
|
||||
assertTrue(receive.getHeaders().containsKey(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE));
|
||||
assertTrue(receive.getHeaders().get(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE, Boolean.class));
|
||||
assertThat(receive).isNotNull();
|
||||
assertThat(receive.getHeaders().containsKey(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE)).isTrue();
|
||||
assertThat(receive.getHeaders().get(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE, Boolean.class))
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -225,14 +221,15 @@ public class IdempotentReceiverIntegrationTests {
|
||||
this.toBridgeChannel.send(message);
|
||||
|
||||
Message<?> receive = this.bridgePollableChannel.receive(10000);
|
||||
assertNotNull(receive);
|
||||
assertFalse(receive.getHeaders().containsKey(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE));
|
||||
assertThat(receive).isNotNull();
|
||||
assertThat(receive.getHeaders().containsKey(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE)).isFalse();
|
||||
|
||||
this.toBridgeChannel.send(message);
|
||||
receive = this.bridgePollableChannel.receive(10000);
|
||||
assertNotNull(receive);
|
||||
assertTrue(receive.getHeaders().containsKey(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE));
|
||||
assertTrue(receive.getHeaders().get(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE, Boolean.class));
|
||||
assertThat(receive).isNotNull();
|
||||
assertThat(receive.getHeaders().containsKey(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE)).isTrue();
|
||||
assertThat(receive.getHeaders().get(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE, Boolean.class))
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
@Configuration
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2009-2018 the original author or authors.
|
||||
* Copyright 2009-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,12 +16,8 @@
|
||||
|
||||
package org.springframework.integration.monitor;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
@@ -81,55 +77,54 @@ public class MBeanExporterIntegrationTests {
|
||||
public void testCircularReferenceNoChannel() {
|
||||
context = new GenericXmlApplicationContext(getClass(), "oref-nonchannel.xml");
|
||||
messageChannelsMonitor = context.getBean(IntegrationMBeanExporter.class);
|
||||
assertNotNull(messageChannelsMonitor);
|
||||
assertThat(messageChannelsMonitor).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCircularReferenceNoChannelInFactoryBean() {
|
||||
context = new GenericXmlApplicationContext(getClass(), "oref-factory-nonchannel.xml");
|
||||
messageChannelsMonitor = context.getBean(IntegrationMBeanExporter.class);
|
||||
assertNotNull(messageChannelsMonitor);
|
||||
assertThat(messageChannelsMonitor).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCircularReferenceWithChannel() {
|
||||
context = new GenericXmlApplicationContext(getClass(), "oref-channel.xml");
|
||||
messageChannelsMonitor = context.getBean(IntegrationMBeanExporter.class);
|
||||
assertNotNull(messageChannelsMonitor);
|
||||
assertThat(messageChannelsMonitor).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCircularReferenceWithChannelInFactoryBean() throws Exception {
|
||||
context = new GenericXmlApplicationContext(getClass(), "oref-factory-channel.xml");
|
||||
messageChannelsMonitor = context.getBean(IntegrationMBeanExporter.class);
|
||||
assertNotNull(messageChannelsMonitor);
|
||||
assertTrue(Arrays.asList(messageChannelsMonitor.getChannelNames()).contains("anonymous"));
|
||||
assertThat(messageChannelsMonitor).isNotNull();
|
||||
assertThat(Arrays.asList(messageChannelsMonitor.getChannelNames()).contains("anonymous")).isTrue();
|
||||
MBeanServer server = context.getBean(MBeanServer.class);
|
||||
assertEquals(1, server.queryNames(ObjectName.getInstance("com.foo:*"), null).size());
|
||||
assertEquals(1,
|
||||
server.queryNames(ObjectName.getInstance("org.springframework.integration:name=anonymous,*"), null)
|
||||
.size());
|
||||
assertThat(server.queryNames(ObjectName.getInstance("com.foo:*"), null).size()).isEqualTo(1);
|
||||
assertThat(server.queryNames(ObjectName.getInstance("org.springframework.integration:name=anonymous,*"), null)
|
||||
.size()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCircularReferenceWithChannelInFactoryBeanAutodetected() {
|
||||
context = new GenericXmlApplicationContext(getClass(), "oref-factory-channel-autodetect.xml");
|
||||
messageChannelsMonitor = context.getBean(IntegrationMBeanExporter.class);
|
||||
assertNotNull(messageChannelsMonitor);
|
||||
assertThat(messageChannelsMonitor).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLifecycleInEndpointWithMessageSource() throws Exception {
|
||||
context = new GenericXmlApplicationContext(getClass(), "lifecycle-source.xml");
|
||||
messageChannelsMonitor = context.getBean(IntegrationMBeanExporter.class);
|
||||
assertNotNull(messageChannelsMonitor);
|
||||
assertThat(messageChannelsMonitor).isNotNull();
|
||||
MBeanServer server = context.getBean(MBeanServer.class);
|
||||
Set<ObjectName> names =
|
||||
server.queryNames(
|
||||
ObjectName.getInstance("org.springframework.integration:type=ManagedEndpoint,*"), null);
|
||||
assertEquals(2, names.size());
|
||||
assertThat(names.size()).isEqualTo(2);
|
||||
names = server.queryNames(ObjectName.getInstance("org.springframework.integration:name=explicit,*"), null);
|
||||
assertEquals(1, names.size());
|
||||
assertThat(names.size()).isEqualTo(1);
|
||||
MBeanOperationInfo[] operations = server.getMBeanInfo(names.iterator().next()).getOperations();
|
||||
String startName = null;
|
||||
for (MBeanOperationInfo info : operations) {
|
||||
@@ -139,17 +134,17 @@ public class MBeanExporterIntegrationTests {
|
||||
}
|
||||
}
|
||||
// Lifecycle method name
|
||||
assertEquals("start", startName);
|
||||
assertTrue((Boolean) server.invoke(names.iterator().next(), "isRunning", null, null));
|
||||
assertThat(startName).isEqualTo("start");
|
||||
assertThat((Boolean) server.invoke(names.iterator().next(), "isRunning", null, null)).isTrue();
|
||||
messageChannelsMonitor.stopActiveComponents(100);
|
||||
assertFalse((Boolean) server.invoke(names.iterator().next(), "isRunning", null, null));
|
||||
assertThat((Boolean) server.invoke(names.iterator().next(), "isRunning", null, null)).isFalse();
|
||||
ActiveChannel activeChannel = context.getBean("activeChannel", ActiveChannel.class);
|
||||
assertTrue(activeChannel.isStopCalled());
|
||||
assertThat(activeChannel.isStopCalled()).isTrue();
|
||||
OtherActiveComponent otherActiveComponent = context.getBean(OtherActiveComponent.class);
|
||||
assertTrue(otherActiveComponent.isBeforeCalled());
|
||||
assertTrue(otherActiveComponent.isAfterCalled());
|
||||
assertTrue(otherActiveComponent.isRunning());
|
||||
assertFalse(context.getBean(AMessageProducer.class).isRunning());
|
||||
assertThat(otherActiveComponent.isBeforeCalled()).isTrue();
|
||||
assertThat(otherActiveComponent.isAfterCalled()).isTrue();
|
||||
assertThat(otherActiveComponent.isRunning()).isTrue();
|
||||
assertThat(context.getBean(AMessageProducer.class).isRunning()).isFalse();
|
||||
|
||||
// check pollers are still running
|
||||
QueueChannel input = (QueueChannel) extractTarget(context.getBean("input"));
|
||||
@@ -157,7 +152,7 @@ public class MBeanExporterIntegrationTests {
|
||||
input.purge(null);
|
||||
input2.purge(null);
|
||||
input.send(new GenericMessage<>("foo"));
|
||||
assertNotNull(input2.receive(10000));
|
||||
assertThat(input2.receive(10000)).isNotNull();
|
||||
}
|
||||
|
||||
private Object extractTarget(Object bean) {
|
||||
@@ -195,14 +190,14 @@ public class MBeanExporterIntegrationTests {
|
||||
public void testLifecycleInEndpointWithoutMessageSource() throws Exception {
|
||||
context = new GenericXmlApplicationContext(getClass(), "lifecycle-no-source.xml");
|
||||
messageChannelsMonitor = context.getBean(IntegrationMBeanExporter.class);
|
||||
assertNotNull(messageChannelsMonitor);
|
||||
assertThat(messageChannelsMonitor).isNotNull();
|
||||
MBeanServer server = context.getBean(MBeanServer.class);
|
||||
Set<ObjectName> names =
|
||||
server.queryNames(
|
||||
ObjectName.getInstance("org.springframework.integration:type=ManagedEndpoint,*"), null);
|
||||
assertEquals(1, names.size());
|
||||
assertThat(names.size()).isEqualTo(1);
|
||||
names = server.queryNames(ObjectName.getInstance("org.springframework.integration:name=gateway,*"), null);
|
||||
assertEquals(1, names.size());
|
||||
assertThat(names.size()).isEqualTo(1);
|
||||
MBeanOperationInfo[] operations = server.getMBeanInfo(names.iterator().next()).getOperations();
|
||||
String startName = null;
|
||||
for (MBeanOperationInfo info : operations) {
|
||||
@@ -212,7 +207,7 @@ public class MBeanExporterIntegrationTests {
|
||||
}
|
||||
}
|
||||
// Lifecycle method name
|
||||
assertEquals("start", startName);
|
||||
assertThat(startName).isEqualTo("start");
|
||||
|
||||
context.close();
|
||||
|
||||
@@ -220,45 +215,45 @@ public class MBeanExporterIntegrationTests {
|
||||
server = context.getBean(MBeanServer.class);
|
||||
names = server.queryNames(
|
||||
ObjectName.getInstance("org.springframework.integration:type=ManagedEndpoint,*"), null);
|
||||
assertEquals(1, names.size());
|
||||
assertThat(names.size()).isEqualTo(1);
|
||||
names = server.queryNames(ObjectName.getInstance("org.springframework.integration:name=gateway,*"), null);
|
||||
assertEquals(1, names.size());
|
||||
assertThat(names.size()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testComponentNames() throws Exception {
|
||||
context = new GenericXmlApplicationContext(getClass(), "excluded-components.xml");
|
||||
messageChannelsMonitor = context.getBean(IntegrationMBeanExporter.class);
|
||||
assertNotNull(messageChannelsMonitor);
|
||||
assertThat(messageChannelsMonitor).isNotNull();
|
||||
MBeanServer server = context.getBean(MBeanServer.class);
|
||||
Set<ObjectName> names =
|
||||
server.queryNames(
|
||||
ObjectName.getInstance("org.springframework.integration:type=MessageChannel,*"), null);
|
||||
// Only one registered (out of >2 available)
|
||||
assertEquals(1, names.size());
|
||||
assertThat(names.size()).isEqualTo(1);
|
||||
names = server.queryNames(
|
||||
ObjectName.getInstance("org.springframework.integration:type=MessageHandler,*"), null);
|
||||
assertEquals(0, names.size());
|
||||
assertThat(names.size()).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDuplicateComponentNames() throws Exception {
|
||||
context = new GenericXmlApplicationContext(getClass(), "duplicate-components.xml");
|
||||
messageChannelsMonitor = context.getBean(IntegrationMBeanExporter.class);
|
||||
assertNotNull(messageChannelsMonitor);
|
||||
assertThat(messageChannelsMonitor).isNotNull();
|
||||
MBeanServer server = context.getBean(MBeanServer.class);
|
||||
Set<ObjectName> names =
|
||||
server.queryNames(
|
||||
ObjectName.getInstance("org.springframework.integration:type=ManagedEndpoint,*"), null);
|
||||
assertEquals(2, names.size());
|
||||
assertThat(names.size()).isEqualTo(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSingleMBeanServer() {
|
||||
AnnotationConfigApplicationContext ctx1 = new AnnotationConfigApplicationContext(Config1.class);
|
||||
AnnotationConfigApplicationContext ctx2 = new AnnotationConfigApplicationContext(Config2.class);
|
||||
assertSame(TestUtils.getPropertyValue(ctx1.getBean(IntegrationMBeanExporter.class), "server"),
|
||||
TestUtils.getPropertyValue(ctx2.getBean(IntegrationMBeanExporter.class), "server"));
|
||||
assertThat(TestUtils.getPropertyValue(ctx2.getBean(IntegrationMBeanExporter.class), "server"))
|
||||
.isSameAs(TestUtils.getPropertyValue(ctx1.getBean(IntegrationMBeanExporter.class), "server"));
|
||||
ctx1.close();
|
||||
ctx2.close();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2009-2017 the original author or authors.
|
||||
* Copyright 2009-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,9 +16,7 @@
|
||||
|
||||
package org.springframework.integration.monitor;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
@@ -28,7 +26,6 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Before;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
|
||||
@@ -89,14 +86,14 @@ public class MessageChannelsMonitorIntegrationTests {
|
||||
channel.send(new GenericMessage<String>("bar"));
|
||||
Thread.sleep(20L);
|
||||
}
|
||||
assertTrue(latch.await(10, TimeUnit.SECONDS));
|
||||
assertEquals(before + 50, service.getCounter());
|
||||
assertThat(latch.await(10, TimeUnit.SECONDS)).isTrue();
|
||||
assertThat(service.getCounter()).isEqualTo(before + 50);
|
||||
|
||||
// The handler monitor is registered under the endpoint id (since it is explicit)
|
||||
int sends = messageChannelsMonitor.getChannelSendRate("" + channel).getCount();
|
||||
assertEquals("No send statistics for input channel", 50, sends, 0.01);
|
||||
assertThat(sends).as("No send statistics for input channel").isEqualTo(50);
|
||||
long sendsLong = messageChannelsMonitor.getChannelSendRate("" + channel).getCountLong();
|
||||
assertEquals("No send statistics for input channel", sendsLong, sends, 0.01);
|
||||
assertThat(sends).as("No send statistics for input channel").isEqualTo(sendsLong);
|
||||
|
||||
}
|
||||
finally {
|
||||
@@ -127,14 +124,14 @@ public class MessageChannelsMonitorIntegrationTests {
|
||||
channel.send(new GenericMessage<String>("bar"));
|
||||
Thread.sleep(20L);
|
||||
}
|
||||
assertTrue(latch.await(10, TimeUnit.SECONDS));
|
||||
assertEquals(before + 10, service.getCounter());
|
||||
assertThat(latch.await(10, TimeUnit.SECONDS)).isTrue();
|
||||
assertThat(service.getCounter()).isEqualTo(before + 10);
|
||||
|
||||
// The handler monitor is registered under the endpoint id (since it is explicit)
|
||||
int sends = messageChannelsMonitor.getChannelSendRate("" + channel).getCount();
|
||||
assertEquals("No send statistics for input channel", 11, sends, 0.01);
|
||||
assertThat(sends).as("No send statistics for input channel").isEqualTo(11);
|
||||
int errors = messageChannelsMonitor.getChannelErrorRate("" + channel).getCount();
|
||||
assertEquals("No error statistics for input channel", 1, errors, 0.01);
|
||||
assertThat(errors).as("No error statistics for input channel").isEqualTo(1);
|
||||
}
|
||||
finally {
|
||||
context.close();
|
||||
@@ -164,16 +161,16 @@ public class MessageChannelsMonitorIntegrationTests {
|
||||
channel.send(new GenericMessage<String>("bar"));
|
||||
Thread.sleep(20L);
|
||||
}
|
||||
assertTrue(latch.await(10, TimeUnit.SECONDS));
|
||||
assertEquals(before + 10, service.getCounter());
|
||||
assertThat(latch.await(10, TimeUnit.SECONDS)).isTrue();
|
||||
assertThat(service.getCounter()).isEqualTo(before + 10);
|
||||
|
||||
// The handler monitor is registered under the endpoint id (since it is explicit)
|
||||
int sends = messageChannelsMonitor.getChannelSendRate("" + channel).getCount();
|
||||
assertEquals("No send statistics for input channel", 11, sends);
|
||||
assertThat(sends).as("No send statistics for input channel").isEqualTo(11);
|
||||
int receives = messageChannelsMonitor.getChannelReceiveCount("" + channel);
|
||||
assertEquals("No send statistics for input channel", 11, receives);
|
||||
assertThat(receives).as("No send statistics for input channel").isEqualTo(11);
|
||||
int errors = messageChannelsMonitor.getChannelErrorRate("" + channel).getCount();
|
||||
assertEquals("Expect no errors for input channel (handler fails)", 0, errors);
|
||||
assertThat(errors).as("Expect no errors for input channel (handler fails)").isEqualTo(0);
|
||||
}
|
||||
finally {
|
||||
context.close();
|
||||
@@ -191,17 +188,18 @@ public class MessageChannelsMonitorIntegrationTests {
|
||||
CountDownLatch latch = new CountDownLatch(1);
|
||||
service.setLatch(latch);
|
||||
channel.send(new GenericMessage<String>("bar"));
|
||||
assertTrue(latch.await(10, TimeUnit.SECONDS));
|
||||
assertEquals(before + 1, service.getCounter());
|
||||
assertThat(latch.await(10, TimeUnit.SECONDS)).isTrue();
|
||||
assertThat(service.getCounter()).isEqualTo(before + 1);
|
||||
|
||||
// The handler monitor is registered under the endpoint id (since it is explicit)
|
||||
int sends = messageChannelsMonitor.getChannelSendRate("" + channel).getCount();
|
||||
assertEquals("No statistics for input channel", 1, sends, 0.01);
|
||||
assertThat(sends).as("No statistics for input channel").isEqualTo(1);
|
||||
|
||||
assertThat(channel, Matchers.instanceOf(ChannelInterceptorAware.class));
|
||||
List<ChannelInterceptor> channelInterceptors = ((ChannelInterceptorAware) channel).getChannelInterceptors();
|
||||
assertEquals(1, channelInterceptors.size());
|
||||
assertThat(channelInterceptors.get(0), Matchers.instanceOf(WireTap.class));
|
||||
assertThat(channel).isInstanceOf(ChannelInterceptorAware.class);
|
||||
List<ChannelInterceptor> channelInterceptors =
|
||||
((ChannelInterceptorAware) channel).getChannelInterceptors();
|
||||
assertThat(channelInterceptors.size()).isEqualTo(1);
|
||||
assertThat(channelInterceptors.get(0)).isInstanceOf(WireTap.class);
|
||||
}
|
||||
finally {
|
||||
context.close();
|
||||
@@ -238,6 +236,7 @@ public class MessageChannelsMonitorIntegrationTests {
|
||||
public int getCounter() {
|
||||
return counter;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Aspect
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2009-2017 the original author or authors.
|
||||
* Copyright 2009-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.integration.monitor;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -66,10 +66,10 @@ public class MessageSourceMonitoringIntegrationTests {
|
||||
int before = service.getCounter();
|
||||
channel.receive(1000L);
|
||||
channel.receive(1000L);
|
||||
assertTrue(before < service.getCounter());
|
||||
assertThat(before < service.getCounter()).isTrue();
|
||||
|
||||
int count = exporter.getSourceMessageCount(monitor);
|
||||
assertTrue("No statistics for input channel", count > 0);
|
||||
assertThat(count > 0).as("No statistics for input channel").isTrue();
|
||||
|
||||
}
|
||||
finally {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2017 the original author or authors.
|
||||
* Copyright 2016-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
package org.springframework.integration.monitor;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@@ -64,12 +63,12 @@ public class MessageSourceTests {
|
||||
public void testMaxFetch() throws Exception {
|
||||
Set<ObjectName> query = this.server.queryNames(new ObjectName("foo:type=MessageSource,*"), null);
|
||||
for (ObjectName instance : query) {
|
||||
assertThat(this.server.getAttribute(instance, "MaxFetchSize"), equalTo(123));
|
||||
assertThat(this.server.getAttribute(instance, "MaxFetchSize")).isEqualTo(123);
|
||||
this.server.setAttribute(instance, new Attribute("MaxFetchSize", 456));
|
||||
assertThat(this.server.getAttribute(instance, "MaxFetchSize"), equalTo(456));
|
||||
assertThat(this.server.getAttribute(instance, "MaxFetchSize")).isEqualTo(456);
|
||||
}
|
||||
assertThat(this.source1.getMaxFetchSize(), equalTo(456));
|
||||
assertThat(this.source2.getMaxFetchSize(), equalTo(456));
|
||||
assertThat(this.source1.getMaxFetchSize()).isEqualTo(456);
|
||||
assertThat(this.source2.getMaxFetchSize()).isEqualTo(456);
|
||||
}
|
||||
|
||||
@Configuration
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2018 the original author or authors.
|
||||
* Copyright 2015-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.integration.monitor;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@@ -56,12 +56,12 @@ public class MessagingGatewaySupportRegistrationTests {
|
||||
public void testHandlerMBeanRegistration() throws Exception {
|
||||
Set<ObjectName> names = this.server
|
||||
.queryNames(new ObjectName("org.springframework.integration:*,name=testGateway"), null);
|
||||
assertEquals(1, names.size());
|
||||
assertThat(names.size()).isEqualTo(1);
|
||||
names = this.server.queryNames(new ObjectName("org.springframework.integration:*,type=MessageSource,name=foo"),
|
||||
null);
|
||||
assertEquals(1, names.size());
|
||||
assertThat(names.size()).isEqualTo(1);
|
||||
names = this.server.queryNames(new ObjectName("org.springframework.integration:*,name=\"foo#2\""), null);
|
||||
assertEquals(1, names.size());
|
||||
assertThat(names.size()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Configuration
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2016 the original author or authors.
|
||||
* Copyright 2015-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,13 +16,7 @@
|
||||
|
||||
package org.springframework.integration.monitor;
|
||||
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
||||
import static org.hamcrest.Matchers.lessThan;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -100,26 +94,26 @@ public class MonitorTests {
|
||||
MessagingTemplate messagingTemplate = new MessagingTemplate(this.input);
|
||||
messagingTemplate.setReceiveTimeout(100000);
|
||||
Integer active = messagingTemplate.convertSendAndReceive("foo", Integer.class);
|
||||
assertEquals(1, active.intValue());
|
||||
assertTrue(afterSendLatch.await(10, TimeUnit.SECONDS));
|
||||
assertEquals(0, this.handler.getActiveCount());
|
||||
assertEquals(1, this.handler.getHandleCount());
|
||||
assertThat(this.handler.getDuration().getMax(), greaterThan(99.0));
|
||||
assertThat(this.handler.getDuration().getMax(), lessThan(10000.0));
|
||||
assertEquals(1, this.input.getSendCount());
|
||||
assertEquals(1, this.input.getReceiveCount());
|
||||
assertEquals(1, this.next.getSendCount());
|
||||
assertThat(this.next.getSendDuration().getMax(), greaterThan(99.0));
|
||||
assertThat(this.next.getSendDuration().getMax(), lessThan(10000.0));
|
||||
assertThat(active.intValue()).isEqualTo(1);
|
||||
assertThat(afterSendLatch.await(10, TimeUnit.SECONDS)).isTrue();
|
||||
assertThat(this.handler.getActiveCount()).isEqualTo(0);
|
||||
assertThat(this.handler.getHandleCount()).isEqualTo(1);
|
||||
assertThat(this.handler.getDuration().getMax()).isGreaterThan(99.0);
|
||||
assertThat(this.handler.getDuration().getMax()).isLessThan(10000.0);
|
||||
assertThat(this.input.getSendCount()).isEqualTo(1);
|
||||
assertThat(this.input.getReceiveCount()).isEqualTo(1);
|
||||
assertThat(this.next.getSendCount()).isEqualTo(1);
|
||||
assertThat(this.next.getSendDuration().getMax()).isGreaterThan(99.0);
|
||||
assertThat(this.next.getSendDuration().getMax()).isLessThan(10000.0);
|
||||
Message<?> fromInbound = this.output.receive(100000);
|
||||
assertNotNull(fromInbound);
|
||||
assertEquals(0, fromInbound.getPayload());
|
||||
assertThat(fromInbound).isNotNull();
|
||||
assertThat(fromInbound.getPayload()).isEqualTo(0);
|
||||
fromInbound = this.output.receive(10000);
|
||||
assertNotNull(fromInbound);
|
||||
assertEquals(1, fromInbound.getPayload());
|
||||
assertThat(this.source.getMessageCount(), greaterThanOrEqualTo(2));
|
||||
assertThat(this.nullChannel.getSendCount(), greaterThanOrEqualTo(2));
|
||||
assertThat(this.pubsub.getSendCount(), greaterThanOrEqualTo(2));
|
||||
assertThat(fromInbound).isNotNull();
|
||||
assertThat(fromInbound.getPayload()).isEqualTo(1);
|
||||
assertThat(this.source.getMessageCount()).isGreaterThanOrEqualTo(2);
|
||||
assertThat(this.nullChannel.getSendCount()).isGreaterThanOrEqualTo(2);
|
||||
assertThat(this.pubsub.getSendCount()).isGreaterThanOrEqualTo(2);
|
||||
}
|
||||
|
||||
public static class TestHandler extends AbstractReplyProducingMessageHandler {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,9 +16,7 @@
|
||||
|
||||
package org.springframework.integration.monitor;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import javax.management.Notification;
|
||||
|
||||
@@ -69,27 +67,27 @@ public class RemoteMBeanServerTests {
|
||||
@Test
|
||||
public void testAttrPoll() throws Exception {
|
||||
Message<?> message = attrChannel.receive(100000);
|
||||
assertNotNull(message);
|
||||
assertEquals("foo", message.getPayload());
|
||||
assertThat(message).isNotNull();
|
||||
assertThat(message.getPayload()).isEqualTo("foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPublish() {
|
||||
publishChannel.send(new GenericMessage<String>("bar"));
|
||||
Message<?> message = publishInChannel.receive(100000);
|
||||
assertNotNull(message);
|
||||
assertTrue(message.getPayload() instanceof Notification);
|
||||
assertThat(message).isNotNull();
|
||||
assertThat(message.getPayload() instanceof Notification).isTrue();
|
||||
Notification notification = (Notification) message.getPayload();
|
||||
assertEquals("bar", notification.getMessage());
|
||||
assertEquals("foo", notification.getType());
|
||||
assertThat(notification.getMessage()).isEqualTo("bar");
|
||||
assertThat(notification.getType()).isEqualTo("foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOperation() {
|
||||
opChannel.send(new GenericMessage<String>("foo"));
|
||||
Message<?> message = opOutChannel.receive(100000);
|
||||
assertNotNull(message);
|
||||
assertEquals("bar", message.getPayload());
|
||||
assertThat(message).isNotNull();
|
||||
assertThat(message.getPayload()).isEqualTo("bar");
|
||||
}
|
||||
|
||||
public interface TesterMBean {
|
||||
|
||||
@@ -16,11 +16,7 @@
|
||||
|
||||
package org.springframework.integration.monitor;
|
||||
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.hamcrest.Matchers.lessThan;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -89,10 +85,10 @@ public class ScatterGatherHandlerIntegrationTests {
|
||||
|
||||
this.inputAuctionWithoutGatherChannel.send(quoteMessage);
|
||||
Message<?> bestQuoteMessage = this.output.receive(10000);
|
||||
assertNotNull(bestQuoteMessage);
|
||||
assertThat(bestQuoteMessage).isNotNull();
|
||||
Object payload = bestQuoteMessage.getPayload();
|
||||
assertThat(payload, instanceOf(Double.class));
|
||||
assertThat((Double) payload, lessThan(10D));
|
||||
assertThat(payload).isInstanceOf(Double.class);
|
||||
assertThat((Double) payload).isLessThan(10D);
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@@ -102,10 +98,10 @@ public class ScatterGatherHandlerIntegrationTests {
|
||||
|
||||
this.inputAuctionWithGatherChannel.send(quoteMessage);
|
||||
Message<?> bestQuoteMessage = this.output.receive(10000);
|
||||
assertNotNull(bestQuoteMessage);
|
||||
assertThat(bestQuoteMessage).isNotNull();
|
||||
Object payload = bestQuoteMessage.getPayload();
|
||||
assertThat(payload, instanceOf(List.class));
|
||||
assertEquals(3, ((List) payload).size());
|
||||
assertThat(payload).isInstanceOf(List.class);
|
||||
assertThat(((List) payload).size()).isEqualTo(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -114,10 +110,10 @@ public class ScatterGatherHandlerIntegrationTests {
|
||||
|
||||
this.distributionChannel.send(quoteMessage);
|
||||
Message<?> bestQuoteMessage = this.output.receive(10000);
|
||||
assertNotNull(bestQuoteMessage);
|
||||
assertThat(bestQuoteMessage).isNotNull();
|
||||
Object payload = bestQuoteMessage.getPayload();
|
||||
assertThat(payload, instanceOf(Double.class));
|
||||
assertThat((Double) payload, lessThan(10D));
|
||||
assertThat(payload).isInstanceOf(Double.class);
|
||||
assertThat((Double) payload).isLessThan(10D);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.integration.monitor;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -55,24 +55,24 @@ public class TransformerContextTests {
|
||||
PollableChannel output = this.context.getBean("output", PollableChannel.class);
|
||||
input.send(new GenericMessage<>("foo"));
|
||||
Message<?> reply = output.receive(0);
|
||||
assertEquals("FOO", reply.getPayload());
|
||||
assertEquals(1, adviceCalled);
|
||||
assertThat(reply.getPayload()).isEqualTo("FOO");
|
||||
assertThat(adviceCalled).isEqualTo(1);
|
||||
|
||||
input = this.context.getBean("direct", MessageChannel.class);
|
||||
input.send(new GenericMessage<>("foo"));
|
||||
reply = output.receive(0);
|
||||
assertEquals("FOO", reply.getPayload());
|
||||
assertThat(reply.getPayload()).isEqualTo("FOO");
|
||||
|
||||
input = this.context.getBean("directRef", MessageChannel.class);
|
||||
input.send(new GenericMessage<>("foo"));
|
||||
reply = output.receive(0);
|
||||
assertEquals("FOO", reply.getPayload());
|
||||
assertEquals(2, adviceCalled);
|
||||
assertThat(reply.getPayload()).isEqualTo("FOO");
|
||||
assertThat(adviceCalled).isEqualTo(2);
|
||||
|
||||
input = this.context.getBean("service", MessageChannel.class);
|
||||
input.send(new GenericMessage<>("foo"));
|
||||
assertEquals(1, bazCalled);
|
||||
assertEquals(3, adviceCalled);
|
||||
assertThat(bazCalled).isEqualTo(1);
|
||||
assertThat(adviceCalled).isEqualTo(3);
|
||||
}
|
||||
|
||||
public static class FooAdvice extends AbstractRequestHandlerAdvice {
|
||||
|
||||
Reference in New Issue
Block a user