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
@@ -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.file;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Matchers.isA;
|
||||
import static org.mockito.ArgumentMatchers.isA;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@@ -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.
|
||||
@@ -22,7 +22,7 @@ import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.mockito.Matchers.isA;
|
||||
import static org.mockito.ArgumentMatchers.isA;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
@@ -36,7 +36,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.messaging.Message;
|
||||
|
||||
@@ -154,9 +154,6 @@ public class FileReadingMessageSourceTests {
|
||||
// record the comparator to reverse order the files
|
||||
when(comparator.compare(file1, file2)).thenReturn(1);
|
||||
when(comparator.compare(file1, file3)).thenReturn(1);
|
||||
when(comparator.compare(file2, file3)).thenReturn(1);
|
||||
when(comparator.compare(file2, file1)).thenReturn(-1);
|
||||
when(comparator.compare(file3, file1)).thenReturn(-1);
|
||||
when(comparator.compare(file3, file2)).thenReturn(-1);
|
||||
|
||||
when(inputDirectoryMock.listFiles()).thenReturn(new File[]{file2, file3, file1});
|
||||
|
||||
@@ -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.
|
||||
@@ -28,8 +28,8 @@ 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.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.times;
|
||||
@@ -309,7 +309,7 @@ public class RemoteFileOutboundGatewayTests {
|
||||
}).when(session).rename(anyString(), anyString());
|
||||
final List<String> madeDirs = new ArrayList<String>();
|
||||
doAnswer(invocation -> {
|
||||
madeDirs.add(invocation.getArgumentAt(0, String.class));
|
||||
madeDirs.add(invocation.getArgument(0));
|
||||
return null;
|
||||
}).when(session).mkdir(anyString());
|
||||
when(sessionFactory.getSession()).thenReturn(session);
|
||||
@@ -909,7 +909,7 @@ public class RemoteFileOutboundGatewayTests {
|
||||
when(sessionFactory.getSession()).thenReturn(session);
|
||||
final AtomicReference<String> written = new AtomicReference<String>();
|
||||
doAnswer(invocation -> {
|
||||
written.set(invocation.getArgumentAt(1, String.class));
|
||||
written.set(invocation.getArgument(1));
|
||||
return null;
|
||||
}).when(session).write(any(InputStream.class), anyString());
|
||||
tempFolder.newFile("baz.txt");
|
||||
@@ -943,7 +943,7 @@ public class RemoteFileOutboundGatewayTests {
|
||||
when(sessionFactory.getSession()).thenReturn(session);
|
||||
final AtomicReference<String> written = new AtomicReference<String>();
|
||||
doAnswer(invocation -> {
|
||||
written.set(invocation.getArgumentAt(1, String.class));
|
||||
written.set(invocation.getArgument(1));
|
||||
return null;
|
||||
}).when(session).write(any(InputStream.class), anyString());
|
||||
tempFolder.newFile("baz.txt");
|
||||
|
||||
@@ -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.
|
||||
@@ -19,8 +19,8 @@ package org.springframework.integration.file.remote.handler;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertSame;
|
||||
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.doThrow;
|
||||
import static org.mockito.Mockito.mock;
|
||||
@@ -64,7 +64,7 @@ public class FileTransferringMessageHandlerTests {
|
||||
|
||||
when(sf.getSession()).thenReturn(session);
|
||||
doAnswer(invocation -> {
|
||||
String path = invocation.getArgumentAt(1, String.class);
|
||||
String path = invocation.getArgument(1);
|
||||
assertFalse(path.startsWith("/"));
|
||||
return null;
|
||||
}).when(session).rename(Mockito.anyString(), Mockito.anyString());
|
||||
@@ -87,8 +87,8 @@ public class FileTransferringMessageHandlerTests {
|
||||
final AtomicReference<String> finalPath = new AtomicReference<String>();
|
||||
when(sf.getSession()).thenReturn(session);
|
||||
doAnswer(invocation -> {
|
||||
temporaryPath.set(invocation.getArgumentAt(0, String.class));
|
||||
finalPath.set(invocation.getArgumentAt(1, String.class));
|
||||
temporaryPath.set(invocation.getArgument(0));
|
||||
finalPath.set(invocation.getArgument(1));
|
||||
return null;
|
||||
}).when(session).rename(Mockito.anyString(), Mockito.anyString());
|
||||
FileTransferringMessageHandler<F> handler = new FileTransferringMessageHandler<F>(sf);
|
||||
@@ -110,7 +110,7 @@ public class FileTransferringMessageHandlerTests {
|
||||
|
||||
when(sf.getSession()).thenReturn(session);
|
||||
doAnswer(invocation -> {
|
||||
String path = invocation.getArgumentAt(1, String.class);
|
||||
String path = invocation.getArgument(1);
|
||||
assertFalse(path.startsWith("/"));
|
||||
return null;
|
||||
}).when(session).rename(Mockito.anyString(), Mockito.anyString());
|
||||
@@ -195,4 +195,5 @@ public class FileTransferringMessageHandlerTests {
|
||||
when(session.isOpen()).thenReturn(false);
|
||||
return session;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user