More Lambdas
Also, make inner ctors package rather than private to avoid the synthetic class and method the compiler has to create. See: http://stackoverflow.com/questions/921025/eclipse-warning-about-synthetic-accessor-for-private-static-nested-classes-in-jav JMX Lambdas Polishing - clean up More
This commit is contained in:
committed by
Artem Bilan
parent
7b1d43a6dc
commit
c865d38576
@@ -26,7 +26,6 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import javax.management.MBeanServer;
|
||||
import javax.management.Notification;
|
||||
import javax.management.NotificationFilter;
|
||||
import javax.management.ObjectName;
|
||||
|
||||
import org.junit.After;
|
||||
@@ -129,12 +128,7 @@ public class NotificationListeningMessageProducerTests {
|
||||
adapter.setServer(this.server);
|
||||
adapter.setObjectName(this.objectName);
|
||||
adapter.setOutputChannel(outputChannel);
|
||||
adapter.setFilter(new NotificationFilter() {
|
||||
@Override
|
||||
public boolean isNotificationEnabled(Notification notification) {
|
||||
return !notification.getMessage().equals("bad");
|
||||
}
|
||||
});
|
||||
adapter.setFilter(notification -> !notification.getMessage().equals("bad"));
|
||||
adapter.setBeanFactory(mock(BeanFactory.class));
|
||||
adapter.afterPropertiesSet();
|
||||
adapter.start();
|
||||
|
||||
@@ -28,10 +28,7 @@ import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.messaging.MessagingException;
|
||||
import org.springframework.messaging.SubscribableChannel;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
@@ -62,12 +59,7 @@ public class MethodInvokerTests {
|
||||
// System . err.println(names);
|
||||
// the router and the error handler...
|
||||
assertEquals(2, names.size());
|
||||
underscores.subscribe(new MessageHandler() {
|
||||
@Override
|
||||
public void handleMessage(Message<?> message) throws MessagingException {
|
||||
assertEquals("foo", message.getPayload());
|
||||
}
|
||||
});
|
||||
underscores.subscribe(message -> assertEquals("foo", message.getPayload()));
|
||||
echos.send(MessageBuilder.withPayload("foo").setHeader("entity-type", "underscore").build());
|
||||
}
|
||||
|
||||
|
||||
@@ -174,6 +174,10 @@ public class NotificationPublishingChannelAdapterParserTests {
|
||||
|
||||
private static class TestData {
|
||||
|
||||
TestData() {
|
||||
super();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class FooAdvice extends AbstractRequestHandlerAdvice {
|
||||
|
||||
@@ -61,7 +61,6 @@ import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.messaging.MessageHandlingException;
|
||||
import org.springframework.messaging.MessagingException;
|
||||
import org.springframework.messaging.PollableChannel;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -203,21 +202,10 @@ public class IdempotentReceiverIntegrationTests {
|
||||
|
||||
@Bean
|
||||
public IdempotentReceiverInterceptor idempotentReceiverInterceptor() {
|
||||
return new IdempotentReceiverInterceptor(new MetadataStoreSelector(new MessageProcessor<String>() {
|
||||
|
||||
@Override
|
||||
public String processMessage(Message<?> message) {
|
||||
return message.getPayload().toString();
|
||||
}
|
||||
|
||||
}, new MessageProcessor<String>() {
|
||||
|
||||
@Override
|
||||
public String processMessage(Message<?> message) {
|
||||
return message.getPayload().toString().toUpperCase();
|
||||
}
|
||||
|
||||
}, store()));
|
||||
return new IdempotentReceiverInterceptor(
|
||||
new MetadataStoreSelector(
|
||||
message -> message.getPayload().toString(),
|
||||
message -> message.getPayload().toString().toUpperCase(), store()));
|
||||
}
|
||||
|
||||
@Bean
|
||||
@@ -234,14 +222,7 @@ public class IdempotentReceiverIntegrationTests {
|
||||
@org.springframework.integration.annotation.Transformer(inputChannel = "input",
|
||||
outputChannel = "output", adviceChain = {"fooAdvice", "idempotentReceiverInterceptor"})
|
||||
public Transformer transformer() {
|
||||
return new Transformer() {
|
||||
|
||||
@Override
|
||||
public Message<?> transform(Message<?> message) {
|
||||
return message;
|
||||
}
|
||||
|
||||
};
|
||||
return message -> message;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@@ -291,15 +272,10 @@ public class IdempotentReceiverIntegrationTests {
|
||||
@ServiceActivator(inputChannel = "annotatedBeanMessageHandlerChannel2")
|
||||
@IdempotentReceiver("idempotentReceiverInterceptor")
|
||||
public MessageHandler messageHandler2() {
|
||||
return new MessageHandler() {
|
||||
|
||||
@Override
|
||||
public void handleMessage(Message<?> message) throws MessagingException {
|
||||
if (message.getHeaders().containsKey(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE)) {
|
||||
throw new MessageHandlingException(message, "duplicate message has been received");
|
||||
}
|
||||
return message -> {
|
||||
if (message.getHeaders().containsKey(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE)) {
|
||||
throw new MessageHandlingException(message, "duplicate message has been received");
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -108,6 +108,10 @@ public class MessageMetricsAdviceTests {
|
||||
@SuppressWarnings("unused")
|
||||
boolean invoked = false;
|
||||
|
||||
DummyHandler() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMessage(Message<?> message) throws MessagingException {
|
||||
invoked = true;
|
||||
@@ -119,6 +123,10 @@ public class MessageMetricsAdviceTests {
|
||||
|
||||
boolean invoked = false;
|
||||
|
||||
DummyInterceptor() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object invoke(MethodInvocation invocation) throws Throwable {
|
||||
invoked = true;
|
||||
|
||||
@@ -30,8 +30,6 @@ import java.util.concurrent.TimeUnit;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
import org.springframework.beans.DirectFieldAccessor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -91,15 +89,10 @@ public class MonitorTests {
|
||||
TestUtils.getPropertyValue(this.next, "channelMetrics", DefaultMessageChannelMetrics.class);
|
||||
channelMetrics = Mockito.spy(channelMetrics);
|
||||
|
||||
Mockito.doAnswer(new Answer<Object>() {
|
||||
|
||||
@Override
|
||||
public Object answer(InvocationOnMock invocation) throws Throwable {
|
||||
Object result = invocation.callRealMethod();
|
||||
afterSendLatch.countDown();
|
||||
return result;
|
||||
}
|
||||
|
||||
Mockito.doAnswer(invocation -> {
|
||||
Object result = invocation.callRealMethod();
|
||||
afterSendLatch.countDown();
|
||||
return result;
|
||||
}).when(channelMetrics).afterSend(Mockito.any(MetricsContext.class), Mockito.eq(Boolean.TRUE));
|
||||
|
||||
new DirectFieldAccessor(this.next).setPropertyValue("channelMetrics", channelMetrics);
|
||||
|
||||
Reference in New Issue
Block a user