INT-4206: Upgrade to Mockito 2.5
JIRA: https://jira.spring.io/browse/INT-4206 * Fix unnecessary dependency resolution in BOM module * Fix `MessagingMethodInvokerHelper` to handle `$MockitoMock$` generated classed which isn't CGLib `Proxies` any more * Provide fixes for test classes according upgrade to Mockito `2.5` * Fix Ceckstyle do not allow static imports for deprecated Mockito classes
This commit is contained in:
committed by
Gary Russell
parent
e04a8d9948
commit
54654546b9
@@ -578,7 +578,8 @@ public class MessagingMethodInvokerHelper<T> extends AbstractExpressionEvaluator
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (org.springframework.util.ClassUtils.isCglibProxyClass(targetClass)) {
|
||||
else if (org.springframework.util.ClassUtils.isCglibProxyClass(targetClass)
|
||||
|| targetClass.getSimpleName().contains("$MockitoMock$")) {
|
||||
Class<?> superClass = targetObject.getClass().getSuperclass();
|
||||
if (!Object.class.equals(superClass)) {
|
||||
targetClass = superClass;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -20,7 +20,7 @@ import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
import static org.hamcrest.Matchers.nullValue;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.mockito.Matchers.isA;
|
||||
import static org.mockito.ArgumentMatchers.isA;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@@ -34,7 +34,7 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import org.springframework.integration.store.MessageGroup;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2017 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,8 @@
|
||||
|
||||
package org.springframework.integration.aggregator;
|
||||
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.isA;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.isA;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -19,8 +19,8 @@ package org.springframework.integration.aggregator;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.isA;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.isA;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -36,7 +36,7 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.internal.stubbing.answers.ThrowsException;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import org.springframework.integration.store.MessageGroup;
|
||||
import org.springframework.integration.store.MessageGroupStore;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -29,7 +29,7 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.integration.store.MessageGroup;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -34,7 +34,7 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import org.springframework.aop.framework.ProxyFactory;
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -18,7 +18,7 @@ package org.springframework.integration.channel;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Matchers.anyObject;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.inOrder;
|
||||
@@ -38,7 +38,7 @@ import org.junit.runner.RunWith;
|
||||
import org.mockito.InOrder;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
@@ -159,7 +159,7 @@ public class MixedDispatcherConfigurationScenarioTests {
|
||||
assertTrue("not all messages were accepted", failed.get());
|
||||
verify(handlerA, times(TOTAL_EXECUTIONS)).handleMessage(message);
|
||||
verify(handlerB, times(0)).handleMessage(message);
|
||||
verify(exceptionRegistry, times(TOTAL_EXECUTIONS)).add((Exception) anyObject());
|
||||
verify(exceptionRegistry, times(TOTAL_EXECUTIONS)).add(any(Exception.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -178,10 +178,6 @@ public class MixedDispatcherConfigurationScenarioTests {
|
||||
throw e;
|
||||
}).when(handlerA).handleMessage(message);
|
||||
|
||||
doAnswer(invocation -> {
|
||||
allDone.countDown();
|
||||
return null;
|
||||
}).when(handlerB).handleMessage(message);
|
||||
|
||||
Runnable messageSenderTask = () -> {
|
||||
try {
|
||||
@@ -204,7 +200,7 @@ public class MixedDispatcherConfigurationScenarioTests {
|
||||
assertTrue("not all messages were accepted", failed.get());
|
||||
verify(handlerA, times(TOTAL_EXECUTIONS)).handleMessage(message);
|
||||
verify(handlerB, times(0)).handleMessage(message);
|
||||
verify(exceptionRegistry, times(TOTAL_EXECUTIONS)).add((Exception) anyObject());
|
||||
verify(exceptionRegistry, times(TOTAL_EXECUTIONS)).add(any(Exception.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -286,7 +282,7 @@ public class MixedDispatcherConfigurationScenarioTests {
|
||||
verify(handlerA, times(14)).handleMessage(message);
|
||||
verify(handlerB, times(13)).handleMessage(message);
|
||||
verify(handlerC, times(13)).handleMessage(message);
|
||||
verify(exceptionRegistry, times(14)).add((Exception) anyObject());
|
||||
verify(exceptionRegistry, times(14)).add(any(Exception.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -339,7 +335,7 @@ public class MixedDispatcherConfigurationScenarioTests {
|
||||
verify(handlerA, times(14)).handleMessage(message);
|
||||
verify(handlerB, times(13)).handleMessage(message);
|
||||
verify(handlerC, times(13)).handleMessage(message);
|
||||
verify(exceptionRegistry, times(14)).add((Exception) anyObject());
|
||||
verify(exceptionRegistry, times(14)).add(any(Exception.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -420,7 +416,7 @@ public class MixedDispatcherConfigurationScenarioTests {
|
||||
verify(handlerA, times(TOTAL_EXECUTIONS)).handleMessage(message);
|
||||
verify(handlerB, times(TOTAL_EXECUTIONS)).handleMessage(message);
|
||||
verify(handlerC, never()).handleMessage(message);
|
||||
verify(exceptionRegistry, never()).add((Exception) anyObject());
|
||||
verify(exceptionRegistry, never()).add(any(Exception.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -440,7 +436,6 @@ public class MixedDispatcherConfigurationScenarioTests {
|
||||
allDone.countDown();
|
||||
return null;
|
||||
}).when(handlerB).handleMessage(message);
|
||||
doAnswer(invocation -> null).when(handlerC).handleMessage(message);
|
||||
|
||||
Runnable messageSenderTask = () -> {
|
||||
try {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -55,9 +55,9 @@ public class P2pChannelTests {
|
||||
private void verifySubscriptions(final AbstractSubscribableChannel channel) {
|
||||
final Log logger = mock(Log.class);
|
||||
when(logger.isInfoEnabled()).thenReturn(true);
|
||||
final List<String> logs = new ArrayList<String>();
|
||||
final List<String> logs = new ArrayList<>();
|
||||
doAnswer(invocation -> {
|
||||
logs.add(invocation.getArgumentAt(0, String.class));
|
||||
logs.add(invocation.getArgument(0));
|
||||
return null;
|
||||
}).when(logger).info(Mockito.anyString());
|
||||
ReflectionUtils.doWithFields(AbstractMessageChannel.class, field -> {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 the original author or authors.
|
||||
* Copyright 2016-2017 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.
|
||||
@@ -23,7 +23,7 @@ import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.BDDMockito.willAnswer;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
@@ -109,7 +109,7 @@ public class ReactiveConsumerTests {
|
||||
BlockingQueue<Message<?>> messages = new LinkedBlockingQueue<>();
|
||||
|
||||
willAnswer(i -> {
|
||||
messages.put(i.getArgumentAt(0, Message.class));
|
||||
messages.put(i.getArgument(0));
|
||||
return null;
|
||||
})
|
||||
.given(testSubscriber)
|
||||
@@ -169,7 +169,7 @@ public class ReactiveConsumerTests {
|
||||
BlockingQueue<Message<?>> messages = new LinkedBlockingQueue<>();
|
||||
|
||||
willAnswer(i -> {
|
||||
messages.put(i.getArgumentAt(0, Message.class));
|
||||
messages.put(i.getArgument(0));
|
||||
return null;
|
||||
})
|
||||
.given(testSubscriber)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -24,7 +24,7 @@ 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.mockito.Matchers.any;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -309,7 +309,7 @@ public class ChainParserTests {
|
||||
final AtomicReference<String> log = new AtomicReference<String>();
|
||||
when(logger.isWarnEnabled()).thenReturn(true);
|
||||
doAnswer(invocation -> {
|
||||
log.set(invocation.getArgumentAt(0, String.class));
|
||||
log.set(invocation.getArgument(0));
|
||||
return null;
|
||||
}).when(logger).warn(any());
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -20,8 +20,8 @@ import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.BDDMockito.willAnswer;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.contains;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.contains;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
@@ -122,7 +122,7 @@ public class SourcePollingChannelAdapterFactoryBeanTests {
|
||||
});
|
||||
when(txAdvice.invoke(any(MethodInvocation.class))).thenAnswer(invocation -> {
|
||||
count.incrementAndGet();
|
||||
return invocation.getArgumentAt(0, MethodInvocation.class).proceed();
|
||||
return ((MethodInvocation) invocation.getArgument(0)).proceed();
|
||||
});
|
||||
|
||||
pollerMetadata.setAdviceChain(adviceChain);
|
||||
@@ -195,7 +195,7 @@ public class SourcePollingChannelAdapterFactoryBeanTests {
|
||||
TaskScheduler taskScheduler = mock(TaskScheduler.class);
|
||||
|
||||
willAnswer(invocation -> {
|
||||
Runnable task = invocation.getArgumentAt(0, Runnable.class);
|
||||
Runnable task = invocation.getArgument(0);
|
||||
task.run();
|
||||
return null;
|
||||
})
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -17,7 +17,7 @@
|
||||
package org.springframework.integration.config.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Matchers.anyObject;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
@@ -36,6 +36,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
/**
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Gunnar Hillert
|
||||
* @author Artem Bilan
|
||||
* @since 2.0
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@@ -60,12 +61,12 @@ public class PublishingInterceptorParserTests {
|
||||
MessageHandler handler = Mockito.mock(MessageHandler.class);
|
||||
defaultChannel.subscribe(handler);
|
||||
doAnswer(invocation -> {
|
||||
Message<?> message = (Message<?>) invocation.getArguments()[0];
|
||||
Message<?> message = invocation.getArgument(0);
|
||||
assertEquals("hello", message.getPayload());
|
||||
return null;
|
||||
}).when(handler).handleMessage((Message<?>) anyObject());
|
||||
}).when(handler).handleMessage(any(Message.class));
|
||||
testBean.echoDefaultChannel("hello");
|
||||
verify(handler, times(1)).handleMessage((Message<?>) anyObject());
|
||||
verify(handler, times(1)).handleMessage(any(Message.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -73,13 +74,13 @@ public class PublishingInterceptorParserTests {
|
||||
MessageHandler handler = Mockito.mock(MessageHandler.class);
|
||||
echoChannel.subscribe(handler);
|
||||
doAnswer(invocation -> {
|
||||
Message<?> message = (Message<?>) invocation.getArguments()[0];
|
||||
Message<?> message = invocation.getArgument(0);
|
||||
assertEquals("bar", message.getHeaders().get("foo"));
|
||||
assertEquals("Echoing: hello", message.getPayload());
|
||||
return null;
|
||||
}).when(handler).handleMessage((Message<?>) anyObject());
|
||||
}).when(handler).handleMessage(any(Message.class));
|
||||
testBean.echo("hello");
|
||||
verify(handler, times(1)).handleMessage((Message<?>) anyObject());
|
||||
verify(handler, times(1)).handleMessage(any(Message.class));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -104,6 +105,7 @@ public class PublishingInterceptorParserTests {
|
||||
public String echoDefaultChannel(String str) {
|
||||
return str;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -112,6 +114,7 @@ public class PublishingInterceptorParserTests {
|
||||
public String echo(String str) {
|
||||
return str;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -276,7 +276,7 @@ public class BroadcastingDispatcherTests {
|
||||
|
||||
private void defaultTaskExecutorMock() {
|
||||
Mockito.doAnswer(invocation -> {
|
||||
(invocation.getArgumentAt(0, Runnable.class)).run();
|
||||
((Runnable) invocation.getArgument(0)).run();
|
||||
return null;
|
||||
}).when(taskExecutorMock).execute(Mockito.any(Runnable.class));
|
||||
}
|
||||
@@ -288,7 +288,7 @@ public class BroadcastingDispatcherTests {
|
||||
final AtomicInteger count = new AtomicInteger();
|
||||
Mockito.doAnswer(invocation -> {
|
||||
if (passes[count.getAndIncrement()]) {
|
||||
(invocation.getArgumentAt(0, Runnable.class)).run();
|
||||
((Runnable) invocation.getArgument(0)).run();
|
||||
}
|
||||
return null;
|
||||
}).when(taskExecutorMock).execute(Mockito.any(Runnable.class));
|
||||
@@ -307,6 +307,7 @@ public class BroadcastingDispatcherTests {
|
||||
public void handleMessage(Message<?> message) {
|
||||
this.messageList.add(message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -30,7 +30,7 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import org.springframework.integration.MessageRejectedException;
|
||||
import org.springframework.messaging.Message;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -29,7 +29,7 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import org.springframework.beans.DirectFieldAccessor;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2016 the original author or authors.
|
||||
* Copyright 2014-2017 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.
|
||||
@@ -23,7 +23,7 @@ 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.mockito.Matchers.any;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.atLeast;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2017 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,32 +16,35 @@
|
||||
|
||||
package org.springframework.integration.handler;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.containsString;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.hamcrest.CoreMatchers.containsString;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessagingException;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
|
||||
/**
|
||||
* @author Iwein Fuld
|
||||
* @author Gunnar Hillert
|
||||
*/
|
||||
@RunWith(org.mockito.runners.MockitoJUnitRunner.class)
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class AbstractReplyProducingMessageHandlerTests {
|
||||
|
||||
private AbstractReplyProducingMessageHandler handler = new AbstractReplyProducingMessageHandler() {
|
||||
|
||||
@Override
|
||||
protected Object handleRequestMessage(Message<?> requestMessage) {
|
||||
return requestMessage;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
private Message<?> message = MessageBuilder.withPayload("test").build();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 the original author or authors.
|
||||
* Copyright 2016-2017 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.
|
||||
@@ -25,8 +25,8 @@ import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
@@ -111,8 +111,8 @@ public class AsyncHandlerTests {
|
||||
Log logger = spy(TestUtils.getPropertyValue(this.handler, "logger", Log.class));
|
||||
new DirectFieldAccessor(this.handler).setPropertyValue("logger", logger);
|
||||
doAnswer(invocation -> {
|
||||
failedCallbackMessage = invocation.getArgumentAt(0, String.class);
|
||||
failedCallbackException = invocation.getArgumentAt(1, Exception.class);
|
||||
failedCallbackMessage = invocation.getArgument(0);
|
||||
failedCallbackException = invocation.getArgument(1);
|
||||
exceptionLatch.countDown();
|
||||
return null;
|
||||
}).when(logger).error(anyString(), any(Throwable.class));
|
||||
@@ -260,6 +260,7 @@ public class AsyncHandlerTests {
|
||||
private interface Foo {
|
||||
|
||||
String exchange(String payload);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -26,7 +26,7 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
@@ -69,7 +69,6 @@ public class MessageHandlerChainTests {
|
||||
@Before
|
||||
public void setup() {
|
||||
Mockito.when(outputChannel.send(Mockito.any(Message.class))).thenReturn(true);
|
||||
Mockito.when(outputChannel.send(Mockito.any(Message.class), Mockito.anyLong())).thenReturn(true);
|
||||
producer1 = new ProducingHandlerStub(handler1);
|
||||
producer2 = new ProducingHandlerStub(handler2);
|
||||
producer3 = new ProducingHandlerStub(handler3);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -66,7 +66,7 @@ public class SendTimeoutConfigurationTests {
|
||||
|
||||
private long getTimeout(String endpointName) {
|
||||
return TestUtils.getPropertyValue(context.getBean(endpointName),
|
||||
"handler.messagingTemplate.sendTimeout", Long.class).longValue();
|
||||
"handler.messagingTemplate.sendTimeout", Long.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -897,7 +897,7 @@ public class AdvisedMessageHandlerTests {
|
||||
when(logger.isWarnEnabled()).thenReturn(Boolean.TRUE);
|
||||
final AtomicReference<String> logMessage = new AtomicReference<String>();
|
||||
doAnswer(invocation -> {
|
||||
logMessage.set(invocation.getArgumentAt(0, String.class));
|
||||
logMessage.set(invocation.getArgument(0));
|
||||
return null;
|
||||
}).when(logger).warn(Mockito.anyString());
|
||||
DirectFieldAccessor accessor = new DirectFieldAccessor(advice);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -24,7 +24,7 @@ import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
|
||||
Reference in New Issue
Block a user