HADOOP-14178. Move Mockito up to version 2.23.4. Contributed by Akira Ajisaka and Masatake Iwasaki.
This commit is contained in:
parent
02eb91856e
commit
1129288cf5
|
@ -667,7 +667,7 @@ spin.js v2.3.2
|
|||
Azure Data Lake Store - Java client SDK 2.0.11
|
||||
JCodings 1.0.8
|
||||
Joni 2.1.2
|
||||
Mockito 1.8.5
|
||||
Mockito 2.23.4
|
||||
JUL to SLF4J bridge 1.7.25
|
||||
SLF4J API Module 1.7.25
|
||||
SLF4J LOG4J-12 Binding 1.7.25
|
||||
|
|
|
@ -385,7 +385,7 @@
|
|||
<!-- Add back in Mockito since the hadoop-hdfs test jar needs it. -->
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-all</artifactId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<!-- Add back in the transitive dependencies excluded from hadoop-common in client TODO remove once we have a filter for "is in these artifacts" -->
|
||||
|
@ -729,7 +729,7 @@
|
|||
|
||||
<!-- Mockito tries to include its own unrelocated copy of hamcrest. :( -->
|
||||
<filter>
|
||||
<artifact>org.mockito:mockito-all</artifact>
|
||||
<artifact>org.mockito:mockito-core</artifact>
|
||||
<excludes>
|
||||
<exclude>asm-license.txt</exclude>
|
||||
<exclude>cglib-license.txt</exclude>
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-all</artifactId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -47,6 +47,7 @@ import org.mockito.stubbing.Answer;
|
|||
|
||||
import static org.hamcrest.CoreMatchers.not;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
|
||||
public class TestAuthenticationFilter {
|
||||
|
||||
|
@ -533,7 +534,7 @@ public class TestAuthenticationFilter {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
).when(chain).doFilter(Mockito.<ServletRequest>anyObject(), Mockito.<ServletResponse>anyObject());
|
||||
).when(chain).doFilter(any(), any());
|
||||
|
||||
Mockito.when(response.containsHeader("WWW-Authenticate")).thenReturn(true);
|
||||
filter.doFilter(request, response, chain);
|
||||
|
@ -616,8 +617,8 @@ public class TestAuthenticationFilter {
|
|||
Assert.assertNotNull("cookie missing", v);
|
||||
Assert.assertTrue(v.contains("u=") && v.contains("p=") && v.contains
|
||||
("t=") && v.contains("e=") && v.contains("s="));
|
||||
Mockito.verify(chain).doFilter(Mockito.any(ServletRequest.class),
|
||||
Mockito.any(ServletResponse.class));
|
||||
Mockito.verify(chain).doFilter(any(ServletRequest.class),
|
||||
any(ServletResponse.class));
|
||||
|
||||
SignerSecretProvider secretProvider =
|
||||
StringSignerSecretProviderCreator.newStringSignerSecretProvider();
|
||||
|
@ -727,7 +728,7 @@ public class TestAuthenticationFilter {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
).when(chain).doFilter(Mockito.<ServletRequest>anyObject(), Mockito.<ServletResponse>anyObject());
|
||||
).when(chain).doFilter(any(), any());
|
||||
|
||||
filter.doFilter(request, response, chain);
|
||||
|
||||
|
@ -780,7 +781,7 @@ public class TestAuthenticationFilter {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
).when(chain).doFilter(Mockito.<ServletRequest>anyObject(), Mockito.<ServletResponse>anyObject());
|
||||
).when(chain).doFilter(any(), any());
|
||||
|
||||
filter.doFilter(request, response, chain);
|
||||
|
||||
|
@ -1090,8 +1091,8 @@ public class TestAuthenticationFilter {
|
|||
Assert.assertTrue(v.contains("u=") && v.contains("p=") && v.contains
|
||||
("t=") && v.contains("i=") && v.contains("e=")
|
||||
&& v.contains("s="));
|
||||
Mockito.verify(chain).doFilter(Mockito.any(ServletRequest.class),
|
||||
Mockito.any(ServletResponse.class));
|
||||
Mockito.verify(chain).doFilter(any(ServletRequest.class),
|
||||
any(ServletResponse.class));
|
||||
|
||||
SignerSecretProvider secretProvider =
|
||||
StringSignerSecretProviderCreator.newStringSignerSecretProvider();
|
||||
|
@ -1134,8 +1135,8 @@ public class TestAuthenticationFilter {
|
|||
|
||||
Mockito.verify(response).sendError(Mockito.eq(HttpServletResponse
|
||||
.SC_UNAUTHORIZED), Mockito.anyString());
|
||||
Mockito.verify(chain, Mockito.never()).doFilter(Mockito.any
|
||||
(ServletRequest.class), Mockito.any(ServletResponse.class));
|
||||
Mockito.verify(chain, Mockito.never()).doFilter(
|
||||
any(ServletRequest.class), any(ServletResponse.class));
|
||||
|
||||
Assert.assertTrue("cookie is missing",
|
||||
cookieMap.containsKey(AuthenticatedURL.AUTH_COOKIE));
|
||||
|
|
|
@ -26,8 +26,8 @@ import static org.mockito.Mockito.verify;
|
|||
|
||||
public class TestRandomSignerSecretProvider {
|
||||
|
||||
// rollover every 50 msec
|
||||
private final int timeout = 100;
|
||||
// rollover every 250 msec
|
||||
private final int timeout = 500;
|
||||
private final long rolloverFrequency = timeout / 2;
|
||||
|
||||
{
|
||||
|
|
|
@ -193,7 +193,7 @@
|
|||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-all</artifactId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -31,9 +31,9 @@ import static org.hamcrest.CoreMatchers.is;
|
|||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.spy;
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.apache.hadoop.fs;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Matchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.apache.hadoop.fs;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Matchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
|
@ -92,7 +92,7 @@ public class TestFsShell {
|
|||
public void testExceptionNullMessage() throws Exception {
|
||||
final String cmdName = "-cmdExNullMsg";
|
||||
final Command cmd = Mockito.mock(Command.class);
|
||||
Mockito.when(cmd.run(Mockito.anyVararg())).thenThrow(
|
||||
Mockito.when(cmd.run(Mockito.any())).thenThrow(
|
||||
new IllegalArgumentException());
|
||||
Mockito.when(cmd.getUsage()).thenReturn(cmdName);
|
||||
|
||||
|
|
|
@ -36,7 +36,6 @@ import org.apache.hadoop.fs.FilterFileSystem;
|
|||
import org.apache.hadoop.fs.Path;
|
||||
import org.apache.hadoop.fs.permission.FsPermission;
|
||||
import org.apache.hadoop.fs.shell.CopyCommands.Put;
|
||||
import org.apache.hadoop.util.Progressable;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
@ -153,8 +152,7 @@ public class TestCopy {
|
|||
|
||||
private OngoingStubbing<FSDataOutputStream> whenFsCreate() throws IOException {
|
||||
return when(mockFs.create(eq(tmpPath), any(FsPermission.class),
|
||||
anyBoolean(), anyInt(), anyShort(), anyLong(),
|
||||
any(Progressable.class)));
|
||||
anyBoolean(), anyInt(), anyShort(), anyLong(), any()));
|
||||
}
|
||||
|
||||
private void tryCopyStream(InputStream in, boolean shouldPass) {
|
||||
|
|
|
@ -20,7 +20,7 @@ package org.apache.hadoop.fs.shell;
|
|||
import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY;
|
||||
import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.HADOOP_SHELL_MISSING_DEFAULT_FS_WARNING_KEY;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
package org.apache.hadoop.fs.shell;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
|
@ -25,9 +25,9 @@ import static org.apache.hadoop.fs.FileContextTestHelper.isFile;
|
|||
import static org.apache.hadoop.fs.viewfs.Constants.PERMISSION_555;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyBoolean;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
@ -536,7 +536,7 @@ abstract public class ViewFsBaseTest {
|
|||
|
||||
@Test
|
||||
public void testGetFileChecksum() throws AccessControlException,
|
||||
UnresolvedLinkException, IOException {
|
||||
UnresolvedLinkException, IOException, URISyntaxException {
|
||||
AbstractFileSystem mockAFS = mock(AbstractFileSystem.class);
|
||||
InodeTree.ResolveResult<AbstractFileSystem> res =
|
||||
new InodeTree.ResolveResult<AbstractFileSystem>(null, mockAFS , null,
|
||||
|
@ -544,13 +544,10 @@ abstract public class ViewFsBaseTest {
|
|||
@SuppressWarnings("unchecked")
|
||||
InodeTree<AbstractFileSystem> fsState = mock(InodeTree.class);
|
||||
when(fsState.resolve(anyString(), anyBoolean())).thenReturn(res);
|
||||
ViewFs vfs = mock(ViewFs.class);
|
||||
ViewFs vfs = new ViewFs(conf);
|
||||
vfs.fsState = fsState;
|
||||
|
||||
when(vfs.getFileChecksum(new Path("/tmp/someFile")))
|
||||
.thenCallRealMethod();
|
||||
vfs.getFileChecksum(new Path("/tmp/someFile"));
|
||||
|
||||
verify(mockAFS).getFileChecksum(new Path("someFile"));
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ import java.io.IOException;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.zookeeper.AsyncCallback;
|
||||
import org.apache.zookeeper.CreateMode;
|
||||
import org.apache.zookeeper.KeeperException;
|
||||
import org.apache.zookeeper.KeeperException.Code;
|
||||
|
@ -45,6 +44,8 @@ import org.apache.hadoop.ha.ActiveStandbyElector.ActiveNotFoundException;
|
|||
import org.apache.hadoop.util.ZKUtil.ZKAuthInfo;
|
||||
import org.apache.hadoop.test.GenericTestUtils;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
|
||||
public class TestActiveStandbyElector {
|
||||
|
||||
private ZooKeeper mockZK;
|
||||
|
@ -438,8 +439,7 @@ public class TestActiveStandbyElector {
|
|||
Event.KeeperState.SyncConnected);
|
||||
elector.processWatchEvent(mockZK, mockEvent);
|
||||
Mockito.verify(mockZK, Mockito.times(0)).exists(Mockito.anyString(),
|
||||
Mockito.anyBoolean(), Mockito.<AsyncCallback.StatCallback> anyObject(),
|
||||
Mockito.<Object> anyObject());
|
||||
Mockito.anyBoolean(), any(), any());
|
||||
|
||||
// disconnection should enter safe mode
|
||||
Mockito.when(mockEvent.getState()).thenReturn(
|
||||
|
@ -663,38 +663,35 @@ public class TestActiveStandbyElector {
|
|||
byte[] data = new byte[8];
|
||||
Mockito.when(
|
||||
mockZK.getData(Mockito.eq(ZK_LOCK_NAME), Mockito.eq(false),
|
||||
Mockito.<Stat> anyObject())).thenReturn(data);
|
||||
any())).thenReturn(data);
|
||||
Assert.assertEquals(data, elector.getActiveData());
|
||||
Mockito.verify(mockZK, Mockito.times(1)).getData(
|
||||
Mockito.eq(ZK_LOCK_NAME), Mockito.eq(false),
|
||||
Mockito.<Stat> anyObject());
|
||||
Mockito.eq(ZK_LOCK_NAME), Mockito.eq(false), any());
|
||||
|
||||
// active does not exist
|
||||
Mockito.when(
|
||||
mockZK.getData(Mockito.eq(ZK_LOCK_NAME), Mockito.eq(false),
|
||||
Mockito.<Stat> anyObject())).thenThrow(
|
||||
any())).thenThrow(
|
||||
new KeeperException.NoNodeException());
|
||||
try {
|
||||
elector.getActiveData();
|
||||
Assert.fail("ActiveNotFoundException expected");
|
||||
} catch(ActiveNotFoundException e) {
|
||||
Mockito.verify(mockZK, Mockito.times(2)).getData(
|
||||
Mockito.eq(ZK_LOCK_NAME), Mockito.eq(false),
|
||||
Mockito.<Stat> anyObject());
|
||||
Mockito.eq(ZK_LOCK_NAME), Mockito.eq(false), any());
|
||||
}
|
||||
|
||||
// error getting active data rethrows keeperexception
|
||||
try {
|
||||
Mockito.when(
|
||||
mockZK.getData(Mockito.eq(ZK_LOCK_NAME), Mockito.eq(false),
|
||||
Mockito.<Stat> anyObject())).thenThrow(
|
||||
any())).thenThrow(
|
||||
new KeeperException.AuthFailedException());
|
||||
elector.getActiveData();
|
||||
Assert.fail("KeeperException.AuthFailedException expected");
|
||||
} catch(KeeperException.AuthFailedException ke) {
|
||||
Mockito.verify(mockZK, Mockito.times(3)).getData(
|
||||
Mockito.eq(ZK_LOCK_NAME), Mockito.eq(false),
|
||||
Mockito.<Stat> anyObject());
|
||||
Mockito.eq(ZK_LOCK_NAME), Mockito.eq(false), any());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -729,7 +726,7 @@ public class TestActiveStandbyElector {
|
|||
};
|
||||
|
||||
Mockito.when(mockZK.create(Mockito.anyString(), Mockito.eq(new byte[]{}),
|
||||
Mockito.anyListOf(ACL.class),
|
||||
Mockito.anyList(),
|
||||
Mockito.eq(CreateMode.PERSISTENT))).thenThrow(ke);
|
||||
|
||||
elector.ensureParentZNode();
|
||||
|
|
|
@ -29,9 +29,9 @@ import java.io.IOException;
|
|||
import java.io.PrintWriter;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.atLeastOnce;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
package org.apache.hadoop.http.lib;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import javax.servlet.FilterChain;
|
||||
|
@ -55,7 +56,7 @@ public class TestStaticUserWebFilter {
|
|||
suf.doFilter(mock(HttpServletRequest.class), mock(ServletResponse.class),
|
||||
chain);
|
||||
|
||||
Mockito.verify(chain).doFilter(wrapperArg.capture(), Mockito.<ServletResponse>anyObject());
|
||||
Mockito.verify(chain).doFilter(wrapperArg.capture(), any());
|
||||
|
||||
HttpServletRequestWrapper wrapper = wrapperArg.getValue();
|
||||
assertEquals("myuser", wrapper.getUserPrincipal().getName());
|
||||
|
|
|
@ -43,9 +43,9 @@ import javax.security.sasl.SaslException;
|
|||
|
||||
import static org.apache.hadoop.io.retry.RetryPolicies.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyBoolean;
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
public class TestRetryProxy {
|
||||
|
|
|
@ -22,7 +22,7 @@ import static org.apache.hadoop.test.MetricsAsserts.assertGauge;
|
|||
import static org.apache.hadoop.test.MetricsAsserts.assertCounter;
|
||||
import static org.apache.hadoop.test.MetricsAsserts.getMetrics;
|
||||
import static org.mockito.Mockito.anyInt;
|
||||
import static org.mockito.Mockito.anyObject;
|
||||
import static org.mockito.Mockito.any;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
@ -254,7 +254,7 @@ public class TestFairCallQueue {
|
|||
// put should offer to all but last subqueue, only put to last subqueue.
|
||||
Mockito.reset(fcq);
|
||||
try {
|
||||
doThrow(stopPuts).when(fcq).putQueue(anyInt(), anyObject());
|
||||
doThrow(stopPuts).when(fcq).putQueue(anyInt(), any());
|
||||
fcq.put(p0);
|
||||
fail("didn't fail");
|
||||
} catch (Exception e) {
|
||||
|
@ -268,7 +268,7 @@ public class TestFairCallQueue {
|
|||
// put with lowest priority should not offer, just put.
|
||||
Mockito.reset(fcq);
|
||||
try {
|
||||
doThrow(stopPuts).when(fcq).putQueue(anyInt(), anyObject());
|
||||
doThrow(stopPuts).when(fcq).putQueue(anyInt(), any());
|
||||
fcq.put(p2);
|
||||
fail("didn't fail");
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -23,6 +23,8 @@ import static org.junit.Assert.assertFalse;
|
|||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
@ -867,7 +869,7 @@ public class TestIPC {
|
|||
}
|
||||
// wait until reader put a call to callQueue, to make sure all readers
|
||||
// are blocking on the queue after initialClients threads are started.
|
||||
verify(spy, timeout(5000).times(i + 1)).put(Mockito.<Call>anyObject());
|
||||
verify(spy, timeout(5000).times(i + 1)).put(any());
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -1604,11 +1606,11 @@ public class TestIPC {
|
|||
Socket s;
|
||||
// don't attempt bind with no service host.
|
||||
s = checkConnect(null, asProxy);
|
||||
Mockito.verify(s, Mockito.never()).bind(Mockito.any(SocketAddress.class));
|
||||
Mockito.verify(s, Mockito.never()).bind(any(SocketAddress.class));
|
||||
|
||||
// don't attempt bind with service host not belonging to this host.
|
||||
s = checkConnect("1.2.3.4", asProxy);
|
||||
Mockito.verify(s, Mockito.never()).bind(Mockito.any(SocketAddress.class));
|
||||
Mockito.verify(s, Mockito.never()).bind(any(SocketAddress.class));
|
||||
|
||||
// do attempt bind when service host is this host.
|
||||
InetAddress addr = InetAddress.getLocalHost();
|
||||
|
@ -1643,7 +1645,7 @@ public class TestIPC {
|
|||
SocketFactory mockFactory = Mockito.mock(SocketFactory.class);
|
||||
Mockito.doReturn(s).when(mockFactory).createSocket();
|
||||
doThrow(expectedConnectEx).when(s).connect(
|
||||
Mockito.any(SocketAddress.class), Mockito.anyInt());
|
||||
any(SocketAddress.class), Mockito.anyInt());
|
||||
|
||||
// do a dummy call and expect it to throw an exception on connect.
|
||||
// tests should verify if/how a bind occurred.
|
||||
|
|
|
@ -52,7 +52,6 @@ import org.apache.hadoop.test.Whitebox;
|
|||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.slf4j.event.Level;
|
||||
|
@ -95,6 +94,7 @@ import static org.junit.Assert.assertNotSame;
|
|||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.timeout;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
@ -1133,7 +1133,7 @@ public class TestRPC extends TestRpcBase {
|
|||
return null;
|
||||
}
|
||||
}));
|
||||
verify(spy, timeout(500).times(i + 1)).add(Mockito.<Call>anyObject());
|
||||
verify(spy, timeout(500).times(i + 1)).add(any());
|
||||
}
|
||||
try {
|
||||
proxy.sleep(null, newSleepRequest(100));
|
||||
|
@ -1204,7 +1204,7 @@ public class TestRPC extends TestRpcBase {
|
|||
return null;
|
||||
}
|
||||
}));
|
||||
verify(spy, timeout(500).times(i + 1)).add(Mockito.<Call>anyObject());
|
||||
verify(spy, timeout(500).times(i + 1)).add(any());
|
||||
}
|
||||
// Start another sleep RPC call and verify the call is backed off due to
|
||||
// avg response time(3s) exceeds threshold (2s).
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.apache.hadoop.ipc;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Matchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -154,12 +153,12 @@ public class TestServer {
|
|||
|
||||
// No stack trace should be logged for a terse exception.
|
||||
server.logException(logger, new TestException2(), dummyCall);
|
||||
verify(logger, times(1)).info(anyObject());
|
||||
verify(logger, times(1)).info(any());
|
||||
|
||||
// Full stack trace should be logged for other exceptions.
|
||||
final Throwable te3 = new TestException3();
|
||||
server.logException(logger, te3, dummyCall);
|
||||
verify(logger, times(1)).info(anyObject(), eq(te3));
|
||||
verify(logger, times(1)).info(any(), eq(te3));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -34,8 +34,8 @@ import java.util.Set;
|
|||
import java.util.Collections;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
|
|
@ -32,7 +32,7 @@ import org.junit.runner.RunWith;
|
|||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Captor;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
|
|
@ -27,7 +27,7 @@ import org.junit.runner.RunWith;
|
|||
import static org.mockito.Mockito.*;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Captor;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import org.apache.hadoop.metrics2.MetricsVisitor;
|
||||
import org.apache.hadoop.metrics2.AbstractMetric;
|
||||
|
|
|
@ -23,8 +23,8 @@ import static org.apache.hadoop.test.MetricsAsserts.*;
|
|||
import static org.mockito.AdditionalMatchers.eq;
|
||||
import static org.mockito.AdditionalMatchers.geq;
|
||||
import static org.mockito.AdditionalMatchers.leq;
|
||||
import static org.mockito.Matchers.anyLong;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.anyLong;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.junit.Assert.*;
|
||||
|
|
|
@ -31,8 +31,8 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
import static org.apache.hadoop.metrics2.lib.Interns.info;
|
||||
import static org.apache.hadoop.test.MetricsAsserts.*;
|
||||
import static org.mockito.Matchers.anyDouble;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.anyDouble;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,6 +18,8 @@ package org.apache.hadoop.security;
|
|||
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
|
||||
import org.apache.hadoop.http.HttpServer2;
|
||||
import org.apache.hadoop.security.authentication.server.AuthenticationFilter;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
|
@ -27,9 +29,6 @@ import org.mockito.Mockito;
|
|||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.Writer;
|
||||
import java.util.Map;
|
||||
|
||||
public class TestAuthenticationFilter {
|
||||
|
@ -69,10 +68,7 @@ public class TestAuthenticationFilter {
|
|||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
).when(container).addFilter(Mockito.<String>anyObject(),
|
||||
Mockito.<String>anyObject(),
|
||||
Mockito.<Map<String, String>>anyObject());
|
||||
}).when(container).addFilter(any(), any(), any());
|
||||
|
||||
new AuthenticationFilterInitializer().initFilter(container, conf);
|
||||
}
|
||||
|
|
|
@ -25,8 +25,8 @@ import static org.junit.Assert.assertArrayEquals;
|
|||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNull;
|
||||
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.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
|
|
@ -34,8 +34,8 @@ import static org.apache.hadoop.security.LdapGroupsMapping.LDAP_NUM_ATTEMPTS_BEF
|
|||
import static org.apache.hadoop.security.LdapGroupsMapping.LDAP_NUM_ATTEMPTS_KEY;
|
||||
import static org.apache.hadoop.security.LdapGroupsMapping.LDAP_URL_KEY;
|
||||
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.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
|
|
@ -32,9 +32,9 @@ import org.junit.Assert;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
package org.apache.hadoop.security;
|
||||
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
|
||||
import static org.mockito.Mockito.any;
|
||||
import static org.mockito.Mockito.contains;
|
||||
|
|
|
@ -28,8 +28,8 @@ import java.util.List;
|
|||
|
||||
import static org.apache.hadoop.security.RuleBasedLdapGroupsMapping
|
||||
.CONVERSION_RULE_KEY;
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
|
||||
/**
|
||||
* Test cases to verify the rules supported by RuleBasedLdapGroupsMapping.
|
||||
|
|
|
@ -21,8 +21,6 @@ import java.util.Collection;
|
|||
import java.util.ArrayList;
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.FilterConfig;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
|
@ -33,6 +31,8 @@ import org.mockito.Mockito;
|
|||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
|
||||
/**
|
||||
* Test the default and customized behaviors of XFrameOptionsFilter.
|
||||
*
|
||||
|
@ -63,8 +63,7 @@ public class TestXFrameOptionsFilter {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
).when(chain).doFilter(Mockito.<ServletRequest>anyObject(),
|
||||
Mockito.<ServletResponse>anyObject());
|
||||
).when(chain).doFilter(any(), any());
|
||||
|
||||
Mockito.doAnswer(
|
||||
new Answer() {
|
||||
|
@ -78,8 +77,7 @@ public class TestXFrameOptionsFilter {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
).when(response).setHeader(Mockito.<String>anyObject(),
|
||||
Mockito.<String>anyObject());
|
||||
).when(response).setHeader(any(), any());
|
||||
|
||||
XFrameOptionsFilter filter = new XFrameOptionsFilter();
|
||||
filter.init(filterConfig);
|
||||
|
@ -119,8 +117,7 @@ public class TestXFrameOptionsFilter {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
).when(chain).doFilter(Mockito.<ServletRequest>anyObject(),
|
||||
Mockito.<ServletResponse>anyObject());
|
||||
).when(chain).doFilter(any(), any());
|
||||
|
||||
Mockito.doAnswer(
|
||||
new Answer() {
|
||||
|
@ -134,8 +131,7 @@ public class TestXFrameOptionsFilter {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
).when(response).setHeader(Mockito.<String>anyObject(),
|
||||
Mockito.<String>anyObject());
|
||||
).when(response).setHeader(any(), any());
|
||||
|
||||
XFrameOptionsFilter filter = new XFrameOptionsFilter();
|
||||
filter.init(filterConfig);
|
||||
|
|
|
@ -23,7 +23,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.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@ package org.apache.hadoop.test;
|
|||
|
||||
import static com.google.common.base.Preconditions.*;
|
||||
|
||||
import org.hamcrest.Description;
|
||||
import org.junit.Assert;
|
||||
|
||||
import static org.mockito.AdditionalMatchers.geq;
|
||||
|
@ -104,19 +103,22 @@ public class MetricsAsserts {
|
|||
return getMetrics(source, true);
|
||||
}
|
||||
|
||||
private static class InfoWithSameName extends ArgumentMatcher<MetricsInfo> {
|
||||
private static class InfoWithSameName
|
||||
implements ArgumentMatcher<MetricsInfo>{
|
||||
private final String expected;
|
||||
|
||||
InfoWithSameName(MetricsInfo info) {
|
||||
expected = checkNotNull(info.name(), "info name");
|
||||
}
|
||||
|
||||
@Override public boolean matches(Object info) {
|
||||
return expected.equals(((MetricsInfo)info).name());
|
||||
@Override
|
||||
public boolean matches(MetricsInfo info) {
|
||||
return expected.equals(info.name());
|
||||
}
|
||||
|
||||
@Override public void describeTo(Description desc) {
|
||||
desc.appendText("Info with name="+ expected);
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Info with name=" + expected;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -129,9 +131,10 @@ public class MetricsAsserts {
|
|||
return argThat(new InfoWithSameName(info));
|
||||
}
|
||||
|
||||
private static class AnyInfo extends ArgumentMatcher<MetricsInfo> {
|
||||
@Override public boolean matches(Object info) {
|
||||
return info instanceof MetricsInfo; // not null as well
|
||||
private static class AnyInfo implements ArgumentMatcher<MetricsInfo> {
|
||||
@Override
|
||||
public boolean matches(MetricsInfo info) {
|
||||
return info != null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import static org.junit.Assert.assertEquals;
|
|||
import static org.junit.Assert.assertFalse;
|
||||
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.spy;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-all</artifactId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-all</artifactId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -35,7 +35,7 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-all</artifactId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
|
|
@ -88,7 +88,7 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-all</artifactId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -60,7 +60,7 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-all</artifactId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -47,10 +47,12 @@ import org.junit.Test;
|
|||
|
||||
import static org.apache.hadoop.test.GenericTestUtils.assertExceptionContains;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import org.mockito.Matchers;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.anyLong;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
|
@ -316,15 +318,13 @@ public class TestRequestHedgingProxyProvider {
|
|||
public void testFileNotFoundExceptionWithSingleProxy() throws Exception {
|
||||
ClientProtocol active = Mockito.mock(ClientProtocol.class);
|
||||
Mockito
|
||||
.when(active.getBlockLocations(Matchers.anyString(),
|
||||
Matchers.anyLong(), Matchers.anyLong()))
|
||||
.when(active.getBlockLocations(anyString(), anyLong(), anyLong()))
|
||||
.thenThrow(new RemoteException("java.io.FileNotFoundException",
|
||||
"File does not exist!"));
|
||||
|
||||
ClientProtocol standby = Mockito.mock(ClientProtocol.class);
|
||||
Mockito
|
||||
.when(standby.getBlockLocations(Matchers.anyString(),
|
||||
Matchers.anyLong(), Matchers.anyLong()))
|
||||
.when(standby.getBlockLocations(anyString(), anyLong(), anyLong()))
|
||||
.thenThrow(
|
||||
new RemoteException("org.apache.hadoop.ipc.StandbyException",
|
||||
"Standby NameNode"));
|
||||
|
@ -354,18 +354,16 @@ public class TestRequestHedgingProxyProvider {
|
|||
} catch (RemoteException ex) {
|
||||
Exception rEx = ex.unwrapRemoteException();
|
||||
if (rEx instanceof StandbyException) {
|
||||
Mockito.verify(active).getBlockLocations(Matchers.anyString(),
|
||||
Matchers.anyLong(), Matchers.anyLong());
|
||||
Mockito.verify(active).getBlockLocations(anyString(), anyLong(),
|
||||
anyLong());
|
||||
Mockito.verify(standby, Mockito.times(2))
|
||||
.getBlockLocations(Matchers.anyString(),
|
||||
Matchers.anyLong(), Matchers.anyLong());
|
||||
.getBlockLocations(anyString(), anyLong(), anyLong());
|
||||
} else {
|
||||
Assert.assertTrue(rEx instanceof FileNotFoundException);
|
||||
Mockito.verify(active, Mockito.times(2))
|
||||
.getBlockLocations(Matchers.anyString(),
|
||||
Matchers.anyLong(), Matchers.anyLong());
|
||||
Mockito.verify(standby).getBlockLocations(Matchers.anyString(),
|
||||
Matchers.anyLong(), Matchers.anyLong());
|
||||
.getBlockLocations(anyString(), anyLong(), anyLong());
|
||||
Mockito.verify(standby).getBlockLocations(anyString(), anyLong(),
|
||||
anyLong());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -384,8 +382,7 @@ public class TestRequestHedgingProxyProvider {
|
|||
RandomStringUtils.randomAlphabetic(8) + ".foo.bar:9820");
|
||||
ClientProtocol active = Mockito.mock(ClientProtocol.class);
|
||||
Mockito
|
||||
.when(active.getBlockLocations(Matchers.anyString(),
|
||||
Matchers.anyLong(), Matchers.anyLong()))
|
||||
.when(active.getBlockLocations(anyString(), anyLong(), anyLong()))
|
||||
.thenThrow(new RemoteException("java.io.FileNotFoundException",
|
||||
"File does not exist!"));
|
||||
|
||||
|
@ -539,15 +536,15 @@ public class TestRequestHedgingProxyProvider {
|
|||
public void testHedgingWhenFileNotFoundException() throws Exception {
|
||||
ClientProtocol active = Mockito.mock(ClientProtocol.class);
|
||||
Mockito
|
||||
.when(active.getBlockLocations(Matchers.anyString(),
|
||||
Matchers.anyLong(), Matchers.anyLong()))
|
||||
.when(active.getBlockLocations(anyString(),
|
||||
anyLong(), anyLong()))
|
||||
.thenThrow(new RemoteException("java.io.FileNotFoundException",
|
||||
"File does not exist!"));
|
||||
|
||||
ClientProtocol standby = Mockito.mock(ClientProtocol.class);
|
||||
Mockito
|
||||
.when(standby.getBlockLocations(Matchers.anyString(),
|
||||
Matchers.anyLong(), Matchers.anyLong()))
|
||||
.when(standby.getBlockLocations(anyString(),
|
||||
anyLong(), anyLong()))
|
||||
.thenThrow(
|
||||
new RemoteException("org.apache.hadoop.ipc.StandbyException",
|
||||
"Standby NameNode"));
|
||||
|
@ -568,10 +565,10 @@ public class TestRequestHedgingProxyProvider {
|
|||
Assert.assertTrue(rEx instanceof FileNotFoundException);
|
||||
}
|
||||
}
|
||||
Mockito.verify(active).getBlockLocations(Matchers.anyString(),
|
||||
Matchers.anyLong(), Matchers.anyLong());
|
||||
Mockito.verify(standby).getBlockLocations(Matchers.anyString(),
|
||||
Matchers.anyLong(), Matchers.anyLong());
|
||||
Mockito.verify(active).getBlockLocations(anyString(),
|
||||
anyLong(), anyLong());
|
||||
Mockito.verify(standby).getBlockLocations(anyString(),
|
||||
anyLong(), anyLong());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -20,8 +20,8 @@ package org.apache.hadoop.hdfs.web;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.Matchers.anyBoolean;
|
||||
import static org.mockito.Matchers.anyLong;
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.anyLong;
|
||||
import static org.mockito.Mockito.CALLS_REAL_METHODS;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
|
|
@ -25,7 +25,8 @@ import static org.junit.Assert.assertNotSame;
|
|||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
@ -174,7 +175,7 @@ public class TestTokenAspect {
|
|||
Token<TokenIdentifier> token = new Token<TokenIdentifier>(new byte[0],
|
||||
new byte[0], DummyFs.TOKEN_KIND, new Text("127.0.0.1:1234"));
|
||||
|
||||
doReturn(token).when(fs).getDelegationToken(anyString());
|
||||
doReturn(token).when(fs).getDelegationToken(any());
|
||||
doReturn(token).when(fs).getRenewToken();
|
||||
|
||||
fs.emulateSecurityEnabled = true;
|
||||
|
@ -197,7 +198,7 @@ public class TestTokenAspect {
|
|||
Token<TokenIdentifier> token = new Token<TokenIdentifier>(new byte[0],
|
||||
new byte[0], DummyFs.TOKEN_KIND, new Text("127.0.0.1:1234"));
|
||||
|
||||
doReturn(token).when(fs).getDelegationToken(anyString());
|
||||
doReturn(token).when(fs).getDelegationToken(any());
|
||||
doReturn(token).when(fs).getRenewToken();
|
||||
|
||||
fs.initialize(new URI("dummyfs://127.0.0.1:1234"), conf);
|
||||
|
@ -304,7 +305,7 @@ public class TestTokenAspect {
|
|||
|
||||
// now that token is invalid, should get a new one
|
||||
tokenAspect.ensureTokenInitialized();
|
||||
verify(fs, times(2)).getDelegationToken(anyString());
|
||||
verify(fs, times(2)).getDelegationToken(any());
|
||||
verify(fs).setDelegationToken(token2);
|
||||
assertNotSame(action, getActionFromTokenAspect(tokenAspect));
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-all</artifactId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -69,7 +69,7 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-all</artifactId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -155,7 +155,7 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-all</artifactId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -101,7 +101,7 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-all</artifactId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
|
|
@ -20,7 +20,7 @@ package org.apache.hadoop.hdfs.server.federation;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.spy;
|
||||
|
||||
|
@ -59,7 +59,7 @@ import org.apache.hadoop.hdfs.server.namenode.ha.HAContext;
|
|||
import org.apache.hadoop.hdfs.server.protocol.NamespaceInfo;
|
||||
import org.apache.hadoop.security.AccessControlException;
|
||||
import org.apache.hadoop.test.GenericTestUtils;
|
||||
import org.mockito.internal.util.reflection.Whitebox;
|
||||
import org.apache.hadoop.test.Whitebox;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
import org.slf4j.Logger;
|
||||
|
|
|
@ -22,7 +22,7 @@ import static org.apache.hadoop.hdfs.server.federation.resolver.order.AvailableS
|
|||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package org.apache.hadoop.hdfs.server.federation.resolver.order;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
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;
|
||||
|
|
|
@ -59,13 +59,13 @@ import org.apache.hadoop.hdfs.server.federation.store.protocol.RemoveMountTableE
|
|||
import org.apache.hadoop.hdfs.server.federation.store.protocol.UpdateMountTableEntryRequest;
|
||||
import org.apache.hadoop.hdfs.server.federation.store.records.MountTable;
|
||||
import org.apache.hadoop.security.UserGroupInformation;
|
||||
import org.apache.hadoop.test.Whitebox;
|
||||
import org.apache.hadoop.util.Time;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.internal.util.reflection.Whitebox;
|
||||
|
||||
/**
|
||||
* The administrator interface of the {@link Router} implemented by
|
||||
|
|
|
@ -46,13 +46,13 @@ import org.apache.hadoop.hdfs.server.federation.store.records.MountTable;
|
|||
import org.apache.hadoop.hdfs.tools.federation.RouterAdmin;
|
||||
import org.apache.hadoop.security.UserGroupInformation;
|
||||
import org.apache.hadoop.test.GenericTestUtils;
|
||||
import org.apache.hadoop.test.Whitebox;
|
||||
import org.apache.hadoop.util.ToolRunner;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.internal.util.reflection.Whitebox;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
|
||||
|
|
|
@ -150,7 +150,7 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-all</artifactId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -55,12 +55,11 @@ import org.apache.hadoop.security.SecurityUtil;
|
|||
import org.apache.hadoop.security.UserGroupInformation;
|
||||
import org.apache.hadoop.test.GenericTestUtils;
|
||||
import org.apache.hadoop.util.StringUtils;
|
||||
import org.hamcrest.BaseMatcher;
|
||||
import org.hamcrest.Description;
|
||||
import org.junit.After;
|
||||
import org.junit.Assume;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.ArgumentMatcher;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import sun.net.spi.nameservice.NameService;
|
||||
|
@ -169,15 +168,15 @@ public class TestDFSClientFailover {
|
|||
return spy;
|
||||
}
|
||||
|
||||
private class MatchesPort extends BaseMatcher<SocketAddress> {
|
||||
private class MatchesPort implements ArgumentMatcher<SocketAddress> {
|
||||
@Override
|
||||
public boolean matches(Object arg0) {
|
||||
public boolean matches(SocketAddress arg0) {
|
||||
return ((InetSocketAddress)arg0).getPort() == portToInjectOn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void describeTo(Description desc) {
|
||||
desc.appendText("matches port " + portToInjectOn);
|
||||
public String toString() {
|
||||
return "matches port " + portToInjectOn;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,12 +22,11 @@ import static org.junit.Assert.assertEquals;
|
|||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyBoolean;
|
||||
import static org.mockito.Matchers.anyLong;
|
||||
import static org.mockito.Matchers.anyObject;
|
||||
import static org.mockito.Matchers.anyShort;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.anyLong;
|
||||
import static org.mockito.ArgumentMatchers.anyShort;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
|
@ -53,10 +52,8 @@ import java.util.concurrent.TimeUnit;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.crypto.CryptoProtocolVersion;
|
||||
import org.apache.hadoop.fs.ChecksumException;
|
||||
import org.apache.hadoop.fs.CommonConfigurationKeys;
|
||||
import org.apache.hadoop.fs.CreateFlag;
|
||||
import org.apache.hadoop.fs.FSDataInputStream;
|
||||
import org.apache.hadoop.fs.FSDataOutputStream;
|
||||
import org.apache.hadoop.fs.FileChecksum;
|
||||
|
@ -81,7 +78,6 @@ import org.apache.hadoop.hdfs.server.namenode.NotReplicatedYetException;
|
|||
import org.apache.hadoop.hdfs.server.protocol.NamenodeProtocols;
|
||||
import org.apache.hadoop.hdfs.web.WebHdfsConstants;
|
||||
import org.apache.hadoop.hdfs.web.WebHdfsTestUtil;
|
||||
import org.apache.hadoop.io.EnumSetWritable;
|
||||
import org.apache.hadoop.io.IOUtils;
|
||||
import org.apache.hadoop.io.LongWritable;
|
||||
import org.apache.hadoop.io.Writable;
|
||||
|
@ -98,7 +94,6 @@ import org.apache.log4j.Level;
|
|||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Matchers;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.internal.stubbing.answers.ThrowsException;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
|
@ -252,10 +247,10 @@ public class TestDFSClientRetries {
|
|||
};
|
||||
when(mockNN.addBlock(anyString(),
|
||||
anyString(),
|
||||
any(ExtendedBlock.class),
|
||||
any(DatanodeInfo[].class),
|
||||
anyLong(), any(String[].class),
|
||||
Matchers.<EnumSet<AddBlockFlag>>any()))
|
||||
any(),
|
||||
any(),
|
||||
anyLong(), any(),
|
||||
any()))
|
||||
.thenAnswer(answer);
|
||||
|
||||
Mockito.doReturn(new HdfsFileStatus.Builder()
|
||||
|
@ -280,10 +275,8 @@ public class TestDFSClientRetries {
|
|||
.fileId(1010)
|
||||
.build())
|
||||
.when(mockNN)
|
||||
.create(anyString(), (FsPermission) anyObject(), anyString(),
|
||||
(EnumSetWritable<CreateFlag>) anyObject(), anyBoolean(),
|
||||
anyShort(), anyLong(), (CryptoProtocolVersion[]) anyObject(),
|
||||
anyObject());
|
||||
.create(anyString(), any(), anyString(), any(), anyBoolean(),
|
||||
anyShort(), anyLong(), any(), any());
|
||||
|
||||
final DFSClient client = new DFSClient(null, mockNN, conf, null);
|
||||
OutputStream os = client.create("testfile", true);
|
||||
|
|
|
@ -63,8 +63,8 @@ import org.junit.BeforeClass;
|
|||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Matchers.anyBoolean;
|
||||
import static org.mockito.Matchers.anyLong;
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.anyLong;
|
||||
import org.mockito.Mockito;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
|
|
@ -56,7 +56,7 @@ import static org.junit.Assert.assertEquals;
|
|||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.Matchers.anyLong;
|
||||
import static org.mockito.ArgumentMatchers.anyLong;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.spy;
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ import static org.junit.Assert.assertFalse;
|
|||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.inOrder;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
|
|
|
@ -52,7 +52,6 @@ import org.apache.hadoop.crypto.key.JavaKeyStoreProvider;
|
|||
import org.apache.hadoop.crypto.key.KeyProvider;
|
||||
import org.apache.hadoop.crypto.key.KeyProviderFactory;
|
||||
import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
|
||||
import org.apache.hadoop.fs.CreateFlag;
|
||||
import org.apache.hadoop.fs.FSDataInputStream;
|
||||
import org.apache.hadoop.fs.FSDataOutputStream;
|
||||
import org.apache.hadoop.fs.FSTestWrapper;
|
||||
|
@ -89,7 +88,6 @@ import org.apache.hadoop.hdfs.tools.offlineImageViewer.PBImageXmlWriter;
|
|||
import org.apache.hadoop.hdfs.web.WebHdfsConstants;
|
||||
import org.apache.hadoop.hdfs.web.WebHdfsFileSystem;
|
||||
import org.apache.hadoop.hdfs.web.WebHdfsTestUtil;
|
||||
import org.apache.hadoop.io.EnumSetWritable;
|
||||
import org.apache.hadoop.io.IOUtils;
|
||||
import org.apache.hadoop.ipc.RemoteException;
|
||||
import org.apache.hadoop.security.AccessControlException;
|
||||
|
@ -114,10 +112,10 @@ import org.junit.rules.Timeout;
|
|||
import org.mockito.Mockito;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.mockito.Matchers.anyBoolean;
|
||||
import static org.mockito.Matchers.anyLong;
|
||||
import static org.mockito.Matchers.anyObject;
|
||||
import static org.mockito.Matchers.anyShort;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.anyLong;
|
||||
import static org.mockito.ArgumentMatchers.anyShort;
|
||||
import static org.mockito.Mockito.withSettings;
|
||||
import static org.mockito.Mockito.anyString;
|
||||
import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.FS_TRASH_INTERVAL_DEFAULT;
|
||||
|
@ -964,10 +962,8 @@ public class TestEncryptionZones {
|
|||
"fakeKey", "fakeVersion"))
|
||||
.build())
|
||||
.when(mcp)
|
||||
.create(anyString(), (FsPermission) anyObject(), anyString(),
|
||||
(EnumSetWritable<CreateFlag>) anyObject(), anyBoolean(),
|
||||
anyShort(), anyLong(), (CryptoProtocolVersion[]) anyObject(),
|
||||
anyObject());
|
||||
.create(anyString(), any(), anyString(), any(), anyBoolean(),
|
||||
anyShort(), anyLong(), any(), any());
|
||||
}
|
||||
|
||||
// This test only uses mocks. Called from the end of an existing test to
|
||||
|
|
|
@ -21,9 +21,9 @@ import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.IPC_CLIENT_CONN
|
|||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.Matchers.anyLong;
|
||||
import static org.mockito.Matchers.anyObject;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.anyLong;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.spy;
|
||||
|
||||
|
@ -40,7 +40,6 @@ import org.apache.hadoop.fs.FileSystem;
|
|||
import org.apache.hadoop.fs.Path;
|
||||
import org.apache.hadoop.hdfs.client.HdfsClientConfigKeys;
|
||||
import org.apache.hadoop.hdfs.protocol.DatanodeInfo;
|
||||
import org.apache.hadoop.hdfs.protocol.ExtendedBlock;
|
||||
import org.apache.hadoop.hdfs.protocol.HdfsConstants;
|
||||
import org.apache.hadoop.hdfs.protocol.LocatedBlocks;
|
||||
import org.apache.hadoop.hdfs.server.datanode.DataNode;
|
||||
|
@ -154,7 +153,7 @@ public class TestFileAppend4 {
|
|||
// Delay completeFile
|
||||
GenericTestUtils.DelayAnswer delayer = new GenericTestUtils.DelayAnswer(LOG);
|
||||
doAnswer(delayer).when(spyNN).complete(
|
||||
anyString(), anyString(), (ExtendedBlock)anyObject(), anyLong());
|
||||
anyString(), anyString(), any(), anyLong());
|
||||
|
||||
DFSClient client = new DFSClient(null, spyNN, conf, null);
|
||||
file1 = new Path("/testRecoverFinalized");
|
||||
|
@ -225,7 +224,7 @@ public class TestFileAppend4 {
|
|||
GenericTestUtils.DelayAnswer delayer =
|
||||
new GenericTestUtils.DelayAnswer(LOG);
|
||||
doAnswer(delayer).when(spyNN).complete(anyString(), anyString(),
|
||||
(ExtendedBlock) anyObject(), anyLong());
|
||||
any(), anyLong());
|
||||
|
||||
DFSClient client = new DFSClient(null, spyNN, conf, null);
|
||||
file1 = new Path("/testCompleteOtherLease");
|
||||
|
|
|
@ -17,11 +17,11 @@
|
|||
*/
|
||||
package org.apache.hadoop.hdfs;
|
||||
|
||||
import static org.mockito.Matchers.anyBoolean;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Matchers.anyShort;
|
||||
import static org.mockito.Matchers.anyLong;
|
||||
import static org.mockito.Matchers.anyObject;
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.anyShort;
|
||||
import static org.mockito.ArgumentMatchers.anyLong;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.spy;
|
||||
|
@ -34,8 +34,6 @@ import java.security.PrivilegedExceptionAction;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.crypto.CryptoProtocolVersion;
|
||||
import org.apache.hadoop.fs.CreateFlag;
|
||||
import org.apache.hadoop.fs.FSDataOutputStream;
|
||||
import org.apache.hadoop.fs.FileSystem;
|
||||
import org.apache.hadoop.fs.Options;
|
||||
|
@ -47,7 +45,6 @@ import org.apache.hadoop.hdfs.protocol.HdfsConstants;
|
|||
import org.apache.hadoop.hdfs.protocol.HdfsFileStatus;
|
||||
import org.apache.hadoop.hdfs.server.namenode.NameNodeAdapter;
|
||||
import org.apache.hadoop.hdfs.server.protocol.NamenodeProtocols;
|
||||
import org.apache.hadoop.io.EnumSetWritable;
|
||||
import org.apache.hadoop.ipc.RemoteException;
|
||||
import org.apache.hadoop.security.UserGroupInformation;
|
||||
import org.apache.hadoop.security.token.SecretManager.InvalidToken;
|
||||
|
@ -374,10 +371,8 @@ public class TestLease {
|
|||
.fileId(1010)
|
||||
.build())
|
||||
.when(mcp)
|
||||
.create(anyString(), (FsPermission) anyObject(), anyString(),
|
||||
(EnumSetWritable<CreateFlag>) anyObject(), anyBoolean(),
|
||||
anyShort(), anyLong(), (CryptoProtocolVersion[]) anyObject(),
|
||||
anyObject());
|
||||
.create(anyString(), any(), anyString(),
|
||||
any(), anyBoolean(), anyShort(), anyLong(), any(), any());
|
||||
|
||||
final Configuration conf = new Configuration();
|
||||
final DFSClient c1 = createDFSClientAs(ugi[0], conf);
|
||||
|
|
|
@ -22,6 +22,7 @@ import static org.apache.hadoop.test.MetricsAsserts.getMetrics;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
|
||||
|
@ -57,8 +58,6 @@ import org.apache.hadoop.hdfs.server.datanode.FsDatasetTestUtils.MaterializedRep
|
|||
import org.apache.hadoop.hdfs.server.datanode.InternalDataNodeTestUtils;
|
||||
import org.apache.hadoop.hdfs.server.datanode.SimulatedFSDataset;
|
||||
import org.apache.hadoop.hdfs.server.namenode.NameNode;
|
||||
import org.apache.hadoop.hdfs.server.protocol.DatanodeRegistration;
|
||||
import org.apache.hadoop.hdfs.server.protocol.StorageReceivedDeletedBlocks;
|
||||
import org.apache.hadoop.io.IOUtils;
|
||||
import org.apache.hadoop.metrics2.MetricsRecordBuilder;
|
||||
import org.apache.hadoop.test.GenericTestUtils;
|
||||
|
@ -576,9 +575,9 @@ public class TestReplication {
|
|||
InternalDataNodeTestUtils.spyOnBposToNN(dn, nn);
|
||||
DelayAnswer delayer = new GenericTestUtils.DelayAnswer(LOG);
|
||||
Mockito.doAnswer(delayer).when(spy).blockReceivedAndDeleted(
|
||||
Mockito.<DatanodeRegistration>anyObject(),
|
||||
any(),
|
||||
Mockito.anyString(),
|
||||
Mockito.<StorageReceivedDeletedBlocks[]>anyObject());
|
||||
any());
|
||||
|
||||
FileSystem fs = cluster.getFileSystem();
|
||||
// Create and close a small file with two blocks
|
||||
|
|
|
@ -31,8 +31,8 @@ import java.io.IOException;
|
|||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyLong;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyLong;
|
||||
import static org.mockito.Mockito.times;
|
||||
|
||||
/**
|
||||
|
|
|
@ -31,14 +31,13 @@ import static org.apache.hadoop.test.MetricsAsserts.getMetrics;
|
|||
import org.apache.hadoop.util.FakeTimer;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import org.junit.Test;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyLong;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyLong;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
@ -81,7 +80,7 @@ public class TestBlockReaderLocalMetrics {
|
|||
TimeUnit.MILLISECONDS);
|
||||
|
||||
FileChannel dataIn = Mockito.mock(FileChannel.class);
|
||||
Mockito.when(dataIn.read(any(ByteBuffer.class), anyLong())).thenAnswer(
|
||||
Mockito.when(dataIn.read(any(), anyLong())).thenAnswer(
|
||||
new Answer<Object>() {
|
||||
@Override
|
||||
public Object answer(InvocationOnMock invocation) throws Throwable {
|
||||
|
@ -93,8 +92,8 @@ public class TestBlockReaderLocalMetrics {
|
|||
BlockReaderIoProvider blockReaderIoProvider = new BlockReaderIoProvider(
|
||||
clientConf.getShortCircuitConf(), metrics, TIMER);
|
||||
|
||||
blockReaderIoProvider.read(dataIn, any(ByteBuffer.class), anyLong());
|
||||
blockReaderIoProvider.read(dataIn, any(ByteBuffer.class), anyLong());
|
||||
blockReaderIoProvider.read(dataIn, any(), anyLong());
|
||||
blockReaderIoProvider.read(dataIn, any(), anyLong());
|
||||
|
||||
GenericTestUtils.waitFor(new Supplier<Boolean>() {
|
||||
@Override
|
||||
|
@ -127,7 +126,7 @@ public class TestBlockReaderLocalMetrics {
|
|||
FileChannel dataIn1 = Mockito.mock(FileChannel.class);
|
||||
FileChannel dataIn2 = Mockito.mock(FileChannel.class);
|
||||
|
||||
Mockito.when(dataIn1.read(any(ByteBuffer.class), anyLong())).thenAnswer(
|
||||
Mockito.when(dataIn1.read(any(), anyLong())).thenAnswer(
|
||||
new Answer<Object>() {
|
||||
@Override
|
||||
public Object answer(InvocationOnMock invocation) throws Throwable {
|
||||
|
@ -136,7 +135,7 @@ public class TestBlockReaderLocalMetrics {
|
|||
}
|
||||
});
|
||||
|
||||
Mockito.when(dataIn2.read(any(ByteBuffer.class), anyLong())).thenAnswer(
|
||||
Mockito.when(dataIn2.read(any(), anyLong())).thenAnswer(
|
||||
new Answer<Object>() {
|
||||
@Override
|
||||
public Object answer(InvocationOnMock invocation) throws Throwable {
|
||||
|
@ -150,8 +149,8 @@ public class TestBlockReaderLocalMetrics {
|
|||
BlockReaderIoProvider blockReaderIoProvider2 = new BlockReaderIoProvider(
|
||||
clientConf.getShortCircuitConf(), metrics, TIMER);
|
||||
|
||||
blockReaderIoProvider1.read(dataIn1, any(ByteBuffer.class), anyLong());
|
||||
blockReaderIoProvider2.read(dataIn2, any(ByteBuffer.class), anyLong());
|
||||
blockReaderIoProvider1.read(dataIn1, any(), anyLong());
|
||||
blockReaderIoProvider2.read(dataIn2, any(), anyLong());
|
||||
|
||||
GenericTestUtils.waitFor(new Supplier<Boolean>() {
|
||||
@Override
|
||||
|
@ -189,7 +188,7 @@ public class TestBlockReaderLocalMetrics {
|
|||
for (int i = 0; i < 5; i++) {
|
||||
dataIns[i] = Mockito.mock(FileChannel.class);
|
||||
long delay = SLOW_READ_DELAY * random.nextInt(5);
|
||||
Mockito.when(dataIns[i].read(any(ByteBuffer.class), anyLong()))
|
||||
Mockito.when(dataIns[i].read(any(), anyLong()))
|
||||
.thenAnswer(new Answer<Object>() {
|
||||
@Override
|
||||
public Object answer(InvocationOnMock invocation) throws Throwable {
|
||||
|
@ -205,7 +204,7 @@ public class TestBlockReaderLocalMetrics {
|
|||
clientConf.getShortCircuitConf(), metrics, TIMER);
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
blockReaderIoProvider.read(dataIns[i], any(ByteBuffer.class), anyLong());
|
||||
blockReaderIoProvider.read(dataIns[i], any(), anyLong());
|
||||
}
|
||||
|
||||
GenericTestUtils.waitFor(new Supplier<Boolean>() {
|
||||
|
|
|
@ -23,7 +23,7 @@ import static org.junit.Assert.assertEquals;
|
|||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
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;
|
||||
|
||||
|
@ -58,7 +58,6 @@ import org.mockito.invocation.InvocationOnMock;
|
|||
import org.mockito.stubbing.Answer;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import com.google.protobuf.RpcController;
|
||||
import com.google.protobuf.ServiceException;
|
||||
|
||||
public class TestBlockListAsLongs {
|
||||
|
@ -222,9 +221,8 @@ public class TestBlockListAsLongs {
|
|||
request.set((BlockReportRequestProto) args[1]);
|
||||
return BlockReportResponseProto.newBuilder().build();
|
||||
}
|
||||
}).when(mockProxy).blockReport(any(RpcController.class),
|
||||
any(BlockReportRequestProto.class));
|
||||
|
||||
}).when(mockProxy).blockReport(any(), any(BlockReportRequestProto.class));
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
DatanodeProtocolClientSideTranslatorPB nn =
|
||||
new DatanodeProtocolClientSideTranslatorPB(mockProxy);
|
||||
|
|
|
@ -19,9 +19,9 @@ package org.apache.hadoop.hdfs.qjournal.client;
|
|||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.Matchers.anyLong;
|
||||
import static org.mockito.Matchers.anyBoolean;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.anyLong;
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
|
|
|
@ -24,7 +24,7 @@ import static org.junit.Assert.assertEquals;
|
|||
import static org.junit.Assert.assertNotEquals;
|
||||
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;
|
||||
|
||||
|
@ -88,7 +88,6 @@ import org.mockito.invocation.InvocationOnMock;
|
|||
import org.mockito.stubbing.Answer;
|
||||
|
||||
import com.google.protobuf.BlockingService;
|
||||
import com.google.protobuf.RpcController;
|
||||
import com.google.protobuf.ServiceException;
|
||||
import org.apache.hadoop.fs.StorageType;
|
||||
|
||||
|
@ -303,8 +302,7 @@ public class TestBlockToken {
|
|||
.getIdentifier())));
|
||||
|
||||
doAnswer(new GetLengthAnswer(sm, id)).when(mockDN)
|
||||
.getReplicaVisibleLength(any(RpcController.class),
|
||||
any(GetReplicaVisibleLengthRequestProto.class));
|
||||
.getReplicaVisibleLength(any(), any());
|
||||
|
||||
RPC.setProtocolEngine(conf, ClientDatanodeProtocolPB.class,
|
||||
ProtobufRpcEngine.class);
|
||||
|
|
|
@ -114,7 +114,7 @@ import static org.junit.Assert.assertFalse;
|
|||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.reset;
|
||||
|
|
|
@ -42,7 +42,7 @@ import static org.junit.Assert.assertEquals;
|
|||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
|
|
|
@ -21,7 +21,7 @@ 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.mockito.Matchers.any;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
|
@ -23,7 +23,7 @@ import static org.junit.Assert.assertNotEquals;
|
|||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@ import static org.hamcrest.core.Is.is;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
|
@ -61,7 +63,6 @@ import org.apache.hadoop.hdfs.server.blockmanagement.DatanodeDescriptor;
|
|||
import org.apache.hadoop.hdfs.server.blockmanagement.DatanodeStorageInfo;
|
||||
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants;
|
||||
import org.apache.hadoop.hdfs.server.namenode.NameNode;
|
||||
import org.apache.hadoop.hdfs.server.protocol.BlockReportContext;
|
||||
import org.apache.hadoop.hdfs.server.protocol.DatanodeRegistration;
|
||||
import org.apache.hadoop.hdfs.server.protocol.DatanodeStorage;
|
||||
import org.apache.hadoop.hdfs.server.protocol.StorageBlockReport;
|
||||
|
@ -626,10 +627,10 @@ public abstract class BlockReportTestBase {
|
|||
|
||||
Mockito.doAnswer(delayer)
|
||||
.when(spy).blockReport(
|
||||
Mockito.<DatanodeRegistration>anyObject(),
|
||||
Mockito.anyString(),
|
||||
Mockito.<StorageBlockReport[]>anyObject(),
|
||||
Mockito.<BlockReportContext>anyObject());
|
||||
any(),
|
||||
anyString(),
|
||||
any(),
|
||||
any());
|
||||
|
||||
// Force a block report to be generated. The block report will have
|
||||
// an RBW replica in it. Wait for the RPC to be sent, but block
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
package org.apache.hadoop.hdfs.server.datanode;
|
||||
|
||||
import org.apache.hadoop.hdfs.server.protocol.SlowDiskReports;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
|
@ -42,9 +41,6 @@ import org.apache.hadoop.hdfs.server.protocol.DatanodeRegistration;
|
|||
import org.apache.hadoop.hdfs.server.protocol.HeartbeatResponse;
|
||||
import org.apache.hadoop.hdfs.server.protocol.NNHAStatusHeartbeat;
|
||||
import org.apache.hadoop.hdfs.server.protocol.NamespaceInfo;
|
||||
import org.apache.hadoop.hdfs.server.protocol.SlowPeerReports;
|
||||
import org.apache.hadoop.hdfs.server.protocol.StorageReport;
|
||||
import org.apache.hadoop.hdfs.server.protocol.VolumeFailureSummary;
|
||||
import org.junit.Assert;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
|
@ -52,7 +48,7 @@ import org.mockito.stubbing.Answer;
|
|||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
|
||||
/**
|
||||
|
@ -161,13 +157,13 @@ public class InternalDataNodeTestUtils {
|
|||
1L));
|
||||
|
||||
when(
|
||||
namenode.sendHeartbeat(Mockito.any(DatanodeRegistration.class),
|
||||
Mockito.any(StorageReport[].class), Mockito.anyLong(),
|
||||
namenode.sendHeartbeat(Mockito.any(),
|
||||
Mockito.any(), Mockito.anyLong(),
|
||||
Mockito.anyLong(), Mockito.anyInt(), Mockito.anyInt(),
|
||||
Mockito.anyInt(), Mockito.any(VolumeFailureSummary.class),
|
||||
Mockito.anyInt(), Mockito.any(),
|
||||
Mockito.anyBoolean(),
|
||||
Mockito.any(SlowPeerReports.class),
|
||||
Mockito.any(SlowDiskReports.class))).thenReturn(
|
||||
Mockito.any(),
|
||||
Mockito.any())).thenReturn(
|
||||
new HeartbeatResponse(new DatanodeCommand[0], new NNHAStatusHeartbeat(
|
||||
HAServiceState.ACTIVE, 1), null, ThreadLocalRandom.current()
|
||||
.nextLong() | 1L));
|
||||
|
|
|
@ -48,7 +48,6 @@ import org.apache.hadoop.hdfs.protocolPB.DatanodeProtocolClientSideTranslatorPB;
|
|||
import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsDatasetSpi;
|
||||
import org.apache.hadoop.hdfs.server.datanode.metrics.DataNodeMetrics;
|
||||
import org.apache.hadoop.hdfs.server.protocol.BlockCommand;
|
||||
import org.apache.hadoop.hdfs.server.protocol.BlockReportContext;
|
||||
import org.apache.hadoop.hdfs.server.protocol.DatanodeCommand;
|
||||
import org.apache.hadoop.hdfs.server.protocol.DatanodeProtocol;
|
||||
import org.apache.hadoop.hdfs.server.protocol.DatanodeRegistration;
|
||||
|
@ -59,7 +58,6 @@ import org.apache.hadoop.hdfs.server.protocol.NamespaceInfo;
|
|||
import org.apache.hadoop.hdfs.server.protocol.ReceivedDeletedBlockInfo;
|
||||
import org.apache.hadoop.hdfs.server.protocol.RegisterCommand;
|
||||
import org.apache.hadoop.hdfs.server.protocol.SlowPeerReports;
|
||||
import org.apache.hadoop.hdfs.server.protocol.StorageBlockReport;
|
||||
import org.apache.hadoop.hdfs.server.protocol.StorageReceivedDeletedBlocks;
|
||||
import org.apache.hadoop.hdfs.server.protocol.StorageReport;
|
||||
import org.apache.hadoop.hdfs.server.protocol.VolumeFailureSummary;
|
||||
|
@ -143,7 +141,7 @@ public class TestBPOfferService {
|
|||
.when(mock).versionRequest();
|
||||
|
||||
Mockito.doReturn(DFSTestUtil.getLocalDatanodeRegistration())
|
||||
.when(mock).registerDatanode(Mockito.any(DatanodeRegistration.class));
|
||||
.when(mock).registerDatanode(Mockito.any());
|
||||
|
||||
Mockito.doAnswer(new HeartbeatAnswer(nnIdx))
|
||||
.when(mock).sendHeartbeat(
|
||||
|
@ -200,11 +198,9 @@ public class TestBPOfferService {
|
|||
waitForBothActors(bpos);
|
||||
|
||||
// The DN should have register to both NNs.
|
||||
Mockito.verify(mockNN1).registerDatanode(
|
||||
Mockito.any(DatanodeRegistration.class));
|
||||
Mockito.verify(mockNN2).registerDatanode(
|
||||
Mockito.any(DatanodeRegistration.class));
|
||||
|
||||
Mockito.verify(mockNN1).registerDatanode(Mockito.any());
|
||||
Mockito.verify(mockNN2).registerDatanode(Mockito.any());
|
||||
|
||||
// Should get block reports from both NNs
|
||||
waitForBlockReport(mockNN1);
|
||||
waitForBlockReport(mockNN2);
|
||||
|
@ -267,10 +263,10 @@ public class TestBPOfferService {
|
|||
Mockito.doReturn(new BlockCommand(DatanodeProtocol.DNA_INVALIDATE,
|
||||
FAKE_BPID, new Block[] { FAKE_BLOCK.getLocalBlock() }))
|
||||
.when(mockNN2).blockReport(
|
||||
Mockito.<DatanodeRegistration>anyObject(),
|
||||
Mockito.any(),
|
||||
Mockito.eq(FAKE_BPID),
|
||||
Mockito.<StorageBlockReport[]>anyObject(),
|
||||
Mockito.<BlockReportContext>anyObject());
|
||||
Mockito.any(),
|
||||
Mockito.any());
|
||||
|
||||
bpos.start();
|
||||
try {
|
||||
|
@ -287,8 +283,7 @@ public class TestBPOfferService {
|
|||
|
||||
// Should ignore the delete command from the standby
|
||||
Mockito.verify(mockFSDataset, Mockito.never())
|
||||
.invalidate(Mockito.eq(FAKE_BPID),
|
||||
(Block[]) Mockito.anyObject());
|
||||
.invalidate(Mockito.eq(FAKE_BPID), Mockito.any());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -487,10 +482,10 @@ public class TestBPOfferService {
|
|||
public Boolean get() {
|
||||
try {
|
||||
Mockito.verify(mockNN).blockReport(
|
||||
Mockito.<DatanodeRegistration>anyObject(),
|
||||
Mockito.any(),
|
||||
Mockito.eq(FAKE_BPID),
|
||||
Mockito.<StorageBlockReport[]>anyObject(),
|
||||
Mockito.<BlockReportContext>anyObject());
|
||||
Mockito.any(),
|
||||
Mockito.any());
|
||||
return true;
|
||||
} catch (Throwable t) {
|
||||
LOG.info("waiting on block report: " + t.getMessage());
|
||||
|
@ -513,10 +508,10 @@ public class TestBPOfferService {
|
|||
private Boolean get(DatanodeProtocolClientSideTranslatorPB mockNN) {
|
||||
try {
|
||||
Mockito.verify(mockNN).blockReport(
|
||||
Mockito.<DatanodeRegistration>anyObject(),
|
||||
Mockito.any(),
|
||||
Mockito.eq(FAKE_BPID),
|
||||
Mockito.<StorageBlockReport[]>anyObject(),
|
||||
Mockito.<BlockReportContext>anyObject());
|
||||
Mockito.any(),
|
||||
Mockito.any());
|
||||
return true;
|
||||
} catch (Throwable t) {
|
||||
LOG.info("waiting on block report: " + t.getMessage());
|
||||
|
@ -538,9 +533,9 @@ public class TestBPOfferService {
|
|||
public Boolean get() {
|
||||
try {
|
||||
Mockito.verify(mockNN).blockReceivedAndDeleted(
|
||||
Mockito.<DatanodeRegistration>anyObject(),
|
||||
Mockito.eq(fakeBlockPoolId),
|
||||
captor.capture());
|
||||
Mockito.any(),
|
||||
Mockito.eq(fakeBlockPoolId),
|
||||
captor.capture());
|
||||
return true;
|
||||
} catch (Throwable t) {
|
||||
return false;
|
||||
|
@ -600,9 +595,9 @@ public class TestBPOfferService {
|
|||
// Now mockNN1 is acting like active namenode and mockNN2 as Standby
|
||||
assertSame(mockNN1, bpos.getActiveNN());
|
||||
Mockito.doAnswer(new BPOfferServiceSynchronousCallAnswer(0))
|
||||
.when(mockNN1).reportBadBlocks(Mockito.any(LocatedBlock[].class));
|
||||
.when(mockNN1).reportBadBlocks(Mockito.any());
|
||||
Mockito.doAnswer(new BPOfferServiceSynchronousCallAnswer(1))
|
||||
.when(mockNN2).reportBadBlocks(Mockito.any(LocatedBlock[].class));
|
||||
.when(mockNN2).reportBadBlocks(Mockito.any());
|
||||
bpos.reportBadBlocks(FAKE_BLOCK, mockFSDataset.getVolume(FAKE_BLOCK)
|
||||
.getStorageID(), mockFSDataset.getVolume(FAKE_BLOCK)
|
||||
.getStorageType());
|
||||
|
@ -641,10 +636,10 @@ public class TestBPOfferService {
|
|||
// Now mockNN1 is acting like active namenode and mockNN2 as Standby
|
||||
assertSame(mockNN1, bpos.getActiveNN());
|
||||
Mockito.doAnswer(new BPOfferServiceSynchronousCallAnswer(0))
|
||||
.when(mockNN1).errorReport(Mockito.any(DatanodeRegistration.class),
|
||||
.when(mockNN1).errorReport(Mockito.any(),
|
||||
Mockito.anyInt(), Mockito.anyString());
|
||||
Mockito.doAnswer(new BPOfferServiceSynchronousCallAnswer(1))
|
||||
.when(mockNN2).errorReport(Mockito.any(DatanodeRegistration.class),
|
||||
.when(mockNN2).errorReport(Mockito.any(),
|
||||
Mockito.anyInt(), Mockito.anyString());
|
||||
String errorString = "Can't send invalid block " + FAKE_BLOCK;
|
||||
bpos.trySendErrorReport(DatanodeProtocol.INVALID_BLOCK, errorString);
|
||||
|
@ -679,21 +674,14 @@ public class TestBPOfferService {
|
|||
bpos.triggerHeartbeatForTests();
|
||||
// Now mockNN1 is acting like active namenode and mockNN2 as Standby
|
||||
assertSame(mockNN1, bpos.getActiveNN());
|
||||
Mockito.doAnswer(new Answer<Void>() {
|
||||
// Throw an IOException when this function is first called which will
|
||||
// in turn add that errorReport back to the bpThreadQueue and let it
|
||||
// process the next time.
|
||||
@Override
|
||||
public Void answer(InvocationOnMock invocation) throws Throwable {
|
||||
if (firstCallTime == 0) {
|
||||
firstCallTime = Time.now();
|
||||
throw new IOException();
|
||||
} else {
|
||||
// Throw an IOException when this function is first called which will
|
||||
// in turn add that errorReport back to the bpThreadQueue and let it
|
||||
// process the next time.
|
||||
Mockito.doThrow(new IOException("Throw IOException in the first call."))
|
||||
.doAnswer((Answer<Void>) invocation -> {
|
||||
secondCallTime = Time.now();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}).when(mockNN1).errorReport(Mockito.any(DatanodeRegistration.class),
|
||||
}).when(mockNN1).errorReport(Mockito.any(DatanodeRegistration.class),
|
||||
Mockito.anyInt(), Mockito.anyString());
|
||||
String errorString = "Can't send invalid block " + FAKE_BLOCK;
|
||||
bpos.trySendErrorReport(DatanodeProtocol.INVALID_BLOCK, errorString);
|
||||
|
@ -880,9 +868,9 @@ public class TestBPOfferService {
|
|||
|
||||
// The DN should have register to both NNs.
|
||||
Mockito.verify(mockNN1)
|
||||
.registerDatanode(Mockito.any(DatanodeRegistration.class));
|
||||
.registerDatanode(Mockito.any());
|
||||
Mockito.verify(mockNN2)
|
||||
.registerDatanode(Mockito.any(DatanodeRegistration.class));
|
||||
.registerDatanode(Mockito.any());
|
||||
|
||||
// Should get block reports from both NNs
|
||||
waitForBlockReport(mockNN1);
|
||||
|
@ -927,8 +915,7 @@ public class TestBPOfferService {
|
|||
Thread.sleep(1000);
|
||||
|
||||
// verify new NN registered
|
||||
Mockito.verify(mockNN3)
|
||||
.registerDatanode(Mockito.any(DatanodeRegistration.class));
|
||||
Mockito.verify(mockNN3).registerDatanode(Mockito.any());
|
||||
|
||||
// When we receive a block, it should report it to both NNs
|
||||
bpos.notifyNamenodeReceivedBlock(FAKE_BLOCK, null, "", false);
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
*/
|
||||
package org.apache.hadoop.hdfs.server.datanode;
|
||||
|
||||
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.timeout;
|
||||
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.apache.hadoop.hdfs.server.datanode;
|
|||
import org.apache.hadoop.hdfs.AppendTestUtil;
|
||||
import org.apache.hadoop.hdfs.DFSClient;
|
||||
import org.apache.hadoop.hdfs.server.namenode.NameNode;
|
||||
import org.apache.hadoop.hdfs.server.protocol.SlowDiskReports;
|
||||
|
||||
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_BLOCK_SIZE_KEY;
|
||||
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_HEARTBEAT_RECHECK_INTERVAL_KEY;
|
||||
|
@ -29,11 +28,10 @@ import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_REPLICATION_MIN_
|
|||
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.anyBoolean;
|
||||
import static org.mockito.Matchers.anyListOf;
|
||||
import static org.mockito.Matchers.anyLong;
|
||||
import static org.mockito.Matchers.anyObject;
|
||||
import static org.mockito.ArgumentMatchers.anyList;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.anyLong;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
@ -77,7 +75,6 @@ import org.apache.hadoop.hdfs.DistributedFileSystem;
|
|||
import org.apache.hadoop.hdfs.HdfsConfiguration;
|
||||
import org.apache.hadoop.hdfs.MiniDFSCluster;
|
||||
import org.apache.hadoop.hdfs.StripedFileTestUtil;
|
||||
import org.apache.hadoop.hdfs.server.protocol.SlowPeerReports;
|
||||
import org.apache.hadoop.util.AutoCloseableLock;
|
||||
import org.apache.hadoop.hdfs.protocol.DatanodeID;
|
||||
import org.apache.hadoop.hdfs.protocol.DatanodeInfo;
|
||||
|
@ -101,8 +98,6 @@ import org.apache.hadoop.hdfs.server.protocol.InterDatanodeProtocol;
|
|||
import org.apache.hadoop.hdfs.server.protocol.NNHAStatusHeartbeat;
|
||||
import org.apache.hadoop.hdfs.server.protocol.NamespaceInfo;
|
||||
import org.apache.hadoop.hdfs.server.protocol.ReplicaRecoveryInfo;
|
||||
import org.apache.hadoop.hdfs.server.protocol.StorageReport;
|
||||
import org.apache.hadoop.hdfs.server.protocol.VolumeFailureSummary;
|
||||
import org.apache.hadoop.test.GenericTestUtils;
|
||||
import org.apache.hadoop.test.GenericTestUtils.SleepAnswer;
|
||||
import org.apache.hadoop.util.DataChecksum;
|
||||
|
@ -223,17 +218,17 @@ public class TestBlockRecovery {
|
|||
(1, CLUSTER_ID, POOL_ID, 1L));
|
||||
|
||||
when(namenode.sendHeartbeat(
|
||||
Mockito.any(DatanodeRegistration.class),
|
||||
Mockito.any(StorageReport[].class),
|
||||
Mockito.any(),
|
||||
Mockito.any(),
|
||||
Mockito.anyLong(),
|
||||
Mockito.anyLong(),
|
||||
Mockito.anyInt(),
|
||||
Mockito.anyInt(),
|
||||
Mockito.anyInt(),
|
||||
Mockito.any(VolumeFailureSummary.class),
|
||||
Mockito.any(),
|
||||
Mockito.anyBoolean(),
|
||||
Mockito.any(SlowPeerReports.class),
|
||||
Mockito.any(SlowDiskReports.class)))
|
||||
Mockito.any(),
|
||||
Mockito.any()))
|
||||
.thenReturn(new HeartbeatResponse(
|
||||
new DatanodeCommand[0],
|
||||
new NNHAStatusHeartbeat(HAServiceState.ACTIVE, 1),
|
||||
|
@ -317,9 +312,9 @@ public class TestBlockRecovery {
|
|||
syncList.add(record1);
|
||||
syncList.add(record2);
|
||||
|
||||
when(dn1.updateReplicaUnderRecovery((ExtendedBlock)anyObject(), anyLong(),
|
||||
when(dn1.updateReplicaUnderRecovery(any(ExtendedBlock.class), anyLong(),
|
||||
anyLong(), anyLong())).thenReturn("storage1");
|
||||
when(dn2.updateReplicaUnderRecovery((ExtendedBlock)anyObject(), anyLong(),
|
||||
when(dn2.updateReplicaUnderRecovery(any(ExtendedBlock.class), anyLong(),
|
||||
anyLong(), anyLong())).thenReturn("storage2");
|
||||
|
||||
BlockRecoveryWorker.RecoveryTaskContiguous RecoveryTaskContiguous =
|
||||
|
@ -555,7 +550,7 @@ public class TestBlockRecovery {
|
|||
BlockRecoveryWorker.RecoveryTaskContiguous spyTask
|
||||
= spy(RecoveryTaskContiguous);
|
||||
spyTask.recover();
|
||||
verify(spyTask, never()).syncBlock(anyListOf(BlockRecord.class));
|
||||
verify(spyTask, never()).syncBlock(anyList());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -583,7 +578,7 @@ public class TestBlockRecovery {
|
|||
} catch(IOException e){
|
||||
GenericTestUtils.assertExceptionContains("All datanodes failed", e);
|
||||
}
|
||||
verify(spyTask, never()).syncBlock(anyListOf(BlockRecord.class));
|
||||
verify(spyTask, never()).syncBlock(anyList());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -92,8 +92,8 @@ 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.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.timeout;
|
||||
|
||||
|
|
|
@ -55,7 +55,6 @@ import org.apache.hadoop.hdfs.server.protocol.DatanodeRegistration;
|
|||
import org.apache.hadoop.hdfs.server.protocol.HeartbeatResponse;
|
||||
import org.apache.hadoop.hdfs.server.protocol.SlowPeerReports;
|
||||
import org.apache.hadoop.hdfs.server.protocol.StorageReport;
|
||||
import org.apache.hadoop.hdfs.server.protocol.VolumeFailureSummary;
|
||||
import org.apache.hadoop.test.GenericTestUtils;
|
||||
|
||||
import org.apache.log4j.Level;
|
||||
|
@ -170,7 +169,7 @@ public class TestDataNodeLifeline {
|
|||
anyInt(),
|
||||
anyInt(),
|
||||
anyInt(),
|
||||
any(VolumeFailureSummary.class),
|
||||
any(),
|
||||
anyBoolean(),
|
||||
any(SlowPeerReports.class),
|
||||
any(SlowDiskReports.class));
|
||||
|
@ -185,7 +184,7 @@ public class TestDataNodeLifeline {
|
|||
anyInt(),
|
||||
anyInt(),
|
||||
anyInt(),
|
||||
any(VolumeFailureSummary.class));
|
||||
any());
|
||||
|
||||
// While waiting on the latch for the expected number of lifeline messages,
|
||||
// poll DataNode tracking information. Thanks to the lifeline, we expect
|
||||
|
@ -212,7 +211,7 @@ public class TestDataNodeLifeline {
|
|||
anyInt(),
|
||||
anyInt(),
|
||||
anyInt(),
|
||||
any(VolumeFailureSummary.class));
|
||||
any());
|
||||
|
||||
// Also verify lifeline call through metrics. We expect at least
|
||||
// numLifelines, guaranteed by waiting on the latch. There is a small
|
||||
|
@ -239,7 +238,7 @@ public class TestDataNodeLifeline {
|
|||
anyInt(),
|
||||
anyInt(),
|
||||
anyInt(),
|
||||
any(VolumeFailureSummary.class),
|
||||
any(),
|
||||
anyBoolean(),
|
||||
any(SlowPeerReports.class),
|
||||
any(SlowDiskReports.class));
|
||||
|
@ -265,7 +264,7 @@ public class TestDataNodeLifeline {
|
|||
anyInt(),
|
||||
anyInt(),
|
||||
anyInt(),
|
||||
any(VolumeFailureSummary.class));
|
||||
any());
|
||||
|
||||
// Also verify no lifeline calls through metrics.
|
||||
assertEquals("Expect metrics to count no lifeline calls.", 0,
|
||||
|
|
|
@ -41,7 +41,6 @@ import org.junit.rules.Timeout;
|
|||
import org.mockito.ArgumentCaptor;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
@ -51,7 +50,13 @@ import java.net.Socket;
|
|||
import java.util.UUID;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.anyLong;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
|
||||
/**
|
||||
* Mock-based unit test to verify that DataXceiver does not fail when no
|
||||
|
@ -86,7 +91,7 @@ public class TestDataXceiverBackwardsCompat {
|
|||
|
||||
doReturn(pair).when(saslClient).socketSend(
|
||||
any(Socket.class), any(OutputStream.class), any(InputStream.class),
|
||||
any(DataEncryptionKeyFactory.class), any(Token.class),
|
||||
any(DataEncryptionKeyFactory.class), any(),
|
||||
any(DatanodeID.class));
|
||||
doReturn(mock(ReplicaHandler.class)).when(data).createTemporary(
|
||||
any(StorageType.class), any(String.class), any(ExtendedBlock.class),
|
||||
|
@ -154,12 +159,12 @@ public class TestDataXceiverBackwardsCompat {
|
|||
|
||||
doReturn(mockBlockReceiver).when(xceiver).getBlockReceiver(
|
||||
any(ExtendedBlock.class), any(StorageType.class),
|
||||
any(DataInputStream.class), anyString(), anyString(),
|
||||
any(), anyString(), any(),
|
||||
any(BlockConstructionStage.class), anyLong(), anyLong(), anyLong(),
|
||||
anyString(), any(DatanodeInfo.class), any(DataNode.class),
|
||||
any(DataChecksum.class), any(CachingStrategy.class),
|
||||
ArgumentCaptor.forClass(Boolean.class).capture(),
|
||||
anyBoolean(), any(String.class));
|
||||
anyBoolean(), any());
|
||||
|
||||
Token<BlockTokenIdentifier> token = (Token<BlockTokenIdentifier>)mock(
|
||||
Token.class);
|
||||
|
|
|
@ -34,14 +34,20 @@ import org.junit.Test;
|
|||
import org.junit.rules.Timeout;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.core.Is.is;
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.anyLong;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -146,12 +152,10 @@ public class TestDataXceiverLazyPersistHint {
|
|||
getMockDn(nonLocalLazyPersist),
|
||||
mock(DataXceiverServer.class)));
|
||||
doReturn(mockBlockReceiver).when(xceiverSpy).getBlockReceiver(
|
||||
any(ExtendedBlock.class), any(StorageType.class),
|
||||
any(DataInputStream.class), anyString(), anyString(),
|
||||
any(BlockConstructionStage.class), anyLong(), anyLong(), anyLong(),
|
||||
anyString(), any(DatanodeInfo.class), any(DataNode.class),
|
||||
any(DataChecksum.class), any(CachingStrategy.class),
|
||||
captor.capture(), anyBoolean(), any(String.class));
|
||||
any(), any(), any(), anyString(), anyString(),
|
||||
any(), anyLong(), anyLong(), anyLong(),
|
||||
anyString(), any(), any(), any(), any(),
|
||||
captor.capture(), anyBoolean(), any());
|
||||
doReturn(mock(DataOutputStream.class)).when(xceiverSpy)
|
||||
.getBufferedOutputStream();
|
||||
return xceiverSpy;
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
package org.apache.hadoop.hdfs.server.datanode;
|
||||
|
||||
import org.apache.hadoop.hdfs.server.protocol.SlowDiskReports;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
|
@ -43,17 +42,12 @@ import org.apache.hadoop.hdfs.DFSTestUtil;
|
|||
import org.apache.hadoop.hdfs.HdfsConfiguration;
|
||||
import org.apache.hadoop.hdfs.MiniDFSCluster;
|
||||
import org.apache.hadoop.hdfs.protocolPB.DatanodeProtocolClientSideTranslatorPB;
|
||||
import org.apache.hadoop.hdfs.server.protocol.BlockReportContext;
|
||||
import org.apache.hadoop.hdfs.server.protocol.DatanodeCommand;
|
||||
import org.apache.hadoop.hdfs.server.protocol.DatanodeRegistration;
|
||||
import org.apache.hadoop.hdfs.server.protocol.HeartbeatResponse;
|
||||
import org.apache.hadoop.hdfs.server.protocol.NamespaceInfo;
|
||||
import org.apache.hadoop.hdfs.server.protocol.NNHAStatusHeartbeat;
|
||||
import org.apache.hadoop.hdfs.server.protocol.RegisterCommand;
|
||||
import org.apache.hadoop.hdfs.server.protocol.SlowPeerReports;
|
||||
import org.apache.hadoop.hdfs.server.protocol.StorageBlockReport;
|
||||
import org.apache.hadoop.hdfs.server.protocol.StorageReport;
|
||||
import org.apache.hadoop.hdfs.server.protocol.VolumeFailureSummary;
|
||||
import org.apache.hadoop.test.GenericTestUtils;
|
||||
import org.slf4j.event.Level;
|
||||
import org.junit.After;
|
||||
|
@ -139,8 +133,8 @@ public class TestDatanodeProtocolRetryPolicy {
|
|||
Mockito.verify(mockNN).blockReport(
|
||||
Mockito.eq(datanodeRegistration),
|
||||
Mockito.eq(POOL_ID),
|
||||
Mockito.<StorageBlockReport[]>anyObject(),
|
||||
Mockito.<BlockReportContext>anyObject());
|
||||
Mockito.any(),
|
||||
Mockito.any());
|
||||
return true;
|
||||
} catch (Throwable t) {
|
||||
LOG.info("waiting on block report: " + t.getMessage());
|
||||
|
@ -212,17 +206,17 @@ public class TestDatanodeProtocolRetryPolicy {
|
|||
return heartbeatResponse;
|
||||
}
|
||||
}).when(namenode).sendHeartbeat(
|
||||
Mockito.any(DatanodeRegistration.class),
|
||||
Mockito.any(StorageReport[].class),
|
||||
Mockito.any(),
|
||||
Mockito.any(),
|
||||
Mockito.anyLong(),
|
||||
Mockito.anyLong(),
|
||||
Mockito.anyInt(),
|
||||
Mockito.anyInt(),
|
||||
Mockito.anyInt(),
|
||||
Mockito.any(VolumeFailureSummary.class),
|
||||
Mockito.any(),
|
||||
Mockito.anyBoolean(),
|
||||
Mockito.any(SlowPeerReports.class),
|
||||
Mockito.any(SlowDiskReports.class));
|
||||
Mockito.any(),
|
||||
Mockito.any());
|
||||
|
||||
dn = new DataNode(conf, locations, null, null) {
|
||||
@Override
|
||||
|
|
|
@ -29,7 +29,6 @@ import org.apache.hadoop.hdfs.*;
|
|||
import org.apache.hadoop.hdfs.protocol.BlockListAsLongs;
|
||||
import org.apache.hadoop.hdfs.protocolPB.DatanodeProtocolClientSideTranslatorPB;
|
||||
import org.apache.hadoop.hdfs.server.namenode.NameNode;
|
||||
import org.apache.hadoop.hdfs.server.protocol.BlockReportContext;
|
||||
import org.apache.hadoop.hdfs.server.protocol.DatanodeRegistration;
|
||||
import org.apache.hadoop.hdfs.server.protocol.StorageBlockReport;
|
||||
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_BLOCKREPORT_SPLIT_THRESHOLD_KEY;
|
||||
|
@ -42,7 +41,8 @@ import org.mockito.Mockito;
|
|||
|
||||
import static org.hamcrest.core.Is.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.mockito.Matchers.*;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.times;
|
||||
|
||||
/**
|
||||
|
@ -135,7 +135,7 @@ public class TestDnRespectsBlockReportSplitThreshold {
|
|||
Mockito.verify(nnSpy, times(cluster.getStoragesPerDatanode())).blockReport(
|
||||
any(DatanodeRegistration.class),
|
||||
anyString(),
|
||||
captor.capture(), Mockito.<BlockReportContext>anyObject());
|
||||
captor.capture(), any());
|
||||
|
||||
verifyCapturedArguments(captor, 1, BLOCKS_IN_FILE);
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ public class TestDnRespectsBlockReportSplitThreshold {
|
|||
Mockito.verify(nnSpy, times(1)).blockReport(
|
||||
any(DatanodeRegistration.class),
|
||||
anyString(),
|
||||
captor.capture(), Mockito.<BlockReportContext>anyObject());
|
||||
captor.capture(), any());
|
||||
|
||||
verifyCapturedArguments(captor, cluster.getStoragesPerDatanode(), BLOCKS_IN_FILE);
|
||||
}
|
||||
|
@ -199,7 +199,7 @@ public class TestDnRespectsBlockReportSplitThreshold {
|
|||
Mockito.verify(nnSpy, times(cluster.getStoragesPerDatanode())).blockReport(
|
||||
any(DatanodeRegistration.class),
|
||||
anyString(),
|
||||
captor.capture(), Mockito.<BlockReportContext>anyObject());
|
||||
captor.capture(), any());
|
||||
|
||||
verifyCapturedArguments(captor, 1, BLOCKS_IN_FILE);
|
||||
}
|
||||
|
|
|
@ -22,10 +22,10 @@ import org.apache.hadoop.hdfs.server.protocol.SlowDiskReports;
|
|||
import static org.apache.hadoop.test.MetricsAsserts.getMetrics;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyBoolean;
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
import static org.mockito.Matchers.anyLong;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.anyLong;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
package org.apache.hadoop.hdfs.server.datanode;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
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.atLeastOnce;
|
||||
import static org.mockito.Mockito.times;
|
||||
|
||||
|
|
|
@ -34,7 +34,6 @@ import org.apache.hadoop.hdfs.server.protocol.DatanodeStorage;
|
|||
import org.apache.hadoop.hdfs.server.protocol.SlowDiskReports;
|
||||
import org.apache.hadoop.hdfs.server.protocol.SlowPeerReports;
|
||||
import org.apache.hadoop.hdfs.server.protocol.StorageReport;
|
||||
import org.apache.hadoop.hdfs.server.protocol.VolumeFailureSummary;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
@ -44,9 +43,9 @@ import org.mockito.Mockito;
|
|||
import static org.hamcrest.core.Is.is;
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
import static org.mockito.Matchers.anyLong;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.anyLong;
|
||||
|
||||
public class TestStorageReport {
|
||||
public static final Logger LOG =
|
||||
|
@ -109,7 +108,7 @@ public class TestStorageReport {
|
|||
any(DatanodeRegistration.class),
|
||||
captor.capture(),
|
||||
anyLong(), anyLong(), anyInt(), anyInt(), anyInt(),
|
||||
Mockito.any(VolumeFailureSummary.class), Mockito.anyBoolean(),
|
||||
any(), Mockito.anyBoolean(),
|
||||
Mockito.any(SlowPeerReports.class),
|
||||
Mockito.any(SlowDiskReports.class));
|
||||
|
||||
|
|
|
@ -17,9 +17,8 @@
|
|||
*/
|
||||
package org.apache.hadoop.hdfs.server.datanode;
|
||||
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyBoolean;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.timeout;
|
||||
|
||||
|
@ -33,7 +32,6 @@ import org.apache.hadoop.hdfs.MiniDFSCluster;
|
|||
import org.apache.hadoop.hdfs.client.BlockReportOptions;
|
||||
import org.apache.hadoop.hdfs.protocol.Block;
|
||||
import org.apache.hadoop.hdfs.protocolPB.DatanodeProtocolClientSideTranslatorPB;
|
||||
import org.apache.hadoop.hdfs.server.protocol.BlockReportContext;
|
||||
import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsDatasetSpi;
|
||||
import org.apache.hadoop.hdfs.server.protocol.DatanodeRegistration;
|
||||
import org.apache.hadoop.hdfs.server.protocol.DatanodeStorage;
|
||||
|
@ -81,7 +79,7 @@ public final class TestTriggerBlockReport {
|
|||
any(DatanodeRegistration.class),
|
||||
anyString(),
|
||||
any(StorageBlockReport[].class),
|
||||
Mockito.<BlockReportContext>anyObject());
|
||||
any());
|
||||
Mockito.verify(spy, times(1)).blockReceivedAndDeleted(
|
||||
any(DatanodeRegistration.class),
|
||||
anyString(),
|
||||
|
@ -124,7 +122,7 @@ public final class TestTriggerBlockReport {
|
|||
any(DatanodeRegistration.class),
|
||||
anyString(),
|
||||
any(StorageBlockReport[].class),
|
||||
Mockito.<BlockReportContext>anyObject());
|
||||
any());
|
||||
}
|
||||
|
||||
cluster.shutdown();
|
||||
|
|
|
@ -126,7 +126,7 @@ public class TestDatasetVolumeChecker {
|
|||
GenericTestUtils.waitFor(() -> numCallbackInvocations.get() > 0, 5, 10000);
|
||||
|
||||
// Ensure that the check was invoked at least once.
|
||||
verify(volume, times(1)).check(anyObject());
|
||||
verify(volume, times(1)).check(any());
|
||||
if (result) {
|
||||
assertThat(numCallbackInvocations.get(), is(1L));
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ public class TestDatasetVolumeChecker {
|
|||
|
||||
// Ensure each volume's check() method was called exactly once.
|
||||
for (FsVolumeSpi volume : volumes) {
|
||||
verify(volume, times(1)).check(anyObject());
|
||||
verify(volume, times(1)).check(any());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -217,10 +217,10 @@ public class TestDatasetVolumeChecker {
|
|||
when(volume.getStorageLocation()).thenReturn(location);
|
||||
|
||||
if (health != null) {
|
||||
when(volume.check(anyObject())).thenReturn(health);
|
||||
when(volume.check(any())).thenReturn(health);
|
||||
} else {
|
||||
final DiskErrorException de = new DiskErrorException("Fake Exception");
|
||||
when(volume.check(anyObject())).thenThrow(de);
|
||||
when(volume.check(any())).thenThrow(de);
|
||||
}
|
||||
volumes.add(volume);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@ import org.apache.hadoop.hdfs.server.datanode.fsdataset.*;
|
|||
import org.apache.hadoop.util.FakeTimer;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -37,8 +36,11 @@ import java.util.*;
|
|||
|
||||
import static org.hamcrest.core.Is.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.mockito.Matchers.anyObject;
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -106,7 +108,7 @@ public class TestDatasetVolumeCheckerFailures {
|
|||
|
||||
// The closed volume should not have been checked as it cannot
|
||||
// be referenced.
|
||||
verify(volumes.get(0), times(0)).check(anyObject());
|
||||
verify(volumes.get(0), times(0)).check(any());
|
||||
}
|
||||
|
||||
@Test(timeout=60000)
|
||||
|
@ -147,15 +149,11 @@ public class TestDatasetVolumeCheckerFailures {
|
|||
when(reference.getVolume()).thenReturn(volume);
|
||||
when(volume.obtainReference()).thenReturn(reference);
|
||||
when(volume.getStorageLocation()).thenReturn(location);
|
||||
when(volume.check(anyObject())).thenAnswer(
|
||||
new Answer<VolumeCheckResult>() {
|
||||
@Override
|
||||
public VolumeCheckResult answer(InvocationOnMock invocation)
|
||||
throws Throwable {
|
||||
when(volume.check(any())).thenAnswer(
|
||||
(Answer<VolumeCheckResult>) invocation -> {
|
||||
Thread.sleep(Long.MAX_VALUE); // Sleep forever.
|
||||
return VolumeCheckResult.HEALTHY; // unreachable.
|
||||
}
|
||||
});
|
||||
});
|
||||
return volume;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,32 +20,22 @@ package org.apache.hadoop.hdfs.server.datanode.checker;
|
|||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hdfs.DFSConfigKeys;
|
||||
import org.apache.hadoop.hdfs.HdfsConfiguration;
|
||||
import org.apache.hadoop.hdfs.LogVerificationAppender;
|
||||
import org.apache.hadoop.hdfs.server.datanode.StorageLocation;
|
||||
import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsVolumeReference;
|
||||
import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsVolumeSpi;
|
||||
import org.apache.hadoop.util.FakeTimer;
|
||||
import org.apache.log4j.Level;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.spi.LoggingEvent;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TestName;
|
||||
import static org.mockito.Matchers.anyObject;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.*;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
|
@ -80,16 +70,13 @@ public class TestDatasetVolumeCheckerTimeout {
|
|||
when(volume.obtainReference()).thenReturn(reference);
|
||||
when(volume.getStorageLocation()).thenReturn(location);
|
||||
|
||||
when(volume.check(anyObject())).thenAnswer(new Answer<VolumeCheckResult>() {
|
||||
@Override
|
||||
public VolumeCheckResult answer(
|
||||
InvocationOnMock invocationOnMock) throws Throwable {
|
||||
when(volume.check(any())).thenAnswer(
|
||||
(Answer<VolumeCheckResult>) invocationOnMock -> {
|
||||
// Wait for the disk check to timeout and then release lock.
|
||||
lock.lock();
|
||||
lock.unlock();
|
||||
return VolumeCheckResult.HEALTHY;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return volume;
|
||||
}
|
||||
|
@ -128,7 +115,7 @@ public class TestDatasetVolumeCheckerTimeout {
|
|||
lock.unlock();
|
||||
|
||||
// Ensure that the check was invoked only once.
|
||||
verify(volume, times(1)).check(anyObject());
|
||||
verify(volume, times(1)).check(any());
|
||||
assertThat(numCallbackInvocations.get(), is(1L));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
|||
import static org.hamcrest.CoreMatchers.is;
|
||||
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.mock;
|
||||
import static org.mockito.Mockito.timeout;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
|
|
@ -69,7 +69,6 @@ import org.apache.hadoop.util.StringUtils;
|
|||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Matchers;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -97,10 +96,10 @@ import static org.junit.Assert.assertTrue;
|
|||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyListOf;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.anyList;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
@ -213,7 +212,7 @@ public class TestFsDatasetImpl {
|
|||
DataStorage.VolumeBuilder builder =
|
||||
new DataStorage.VolumeBuilder(storage, sd);
|
||||
when(storage.prepareVolume(eq(datanode), eq(loc),
|
||||
anyListOf(NamespaceInfo.class)))
|
||||
anyList()))
|
||||
.thenReturn(builder);
|
||||
|
||||
dataset.addVolume(loc, nsInfos);
|
||||
|
@ -332,7 +331,7 @@ public class TestFsDatasetImpl {
|
|||
DataStorage.VolumeBuilder builder =
|
||||
new DataStorage.VolumeBuilder(storage, sd);
|
||||
when(storage.prepareVolume(eq(datanode), eq(loc),
|
||||
anyListOf(NamespaceInfo.class)))
|
||||
anyList()))
|
||||
.thenReturn(builder);
|
||||
|
||||
dataset.addVolume(loc, nsInfos);
|
||||
|
@ -366,7 +365,7 @@ public class TestFsDatasetImpl {
|
|||
DataStorage.VolumeBuilder builder = new DataStorage.VolumeBuilder(storage, sd);
|
||||
when(storage.prepareVolume(eq(datanode),
|
||||
eq(StorageLocation.parse(badDir.toURI().toString())),
|
||||
Matchers.<List<NamespaceInfo>>any()))
|
||||
anyList()))
|
||||
.thenReturn(builder);
|
||||
|
||||
StorageLocation location = StorageLocation.parse(badDir.toString());
|
||||
|
@ -510,7 +509,7 @@ public class TestFsDatasetImpl {
|
|||
new DataStorage.VolumeBuilder(storage, sd);
|
||||
when(
|
||||
storage.prepareVolume(eq(datanode), eq(loc),
|
||||
anyListOf(NamespaceInfo.class))).thenReturn(builder);
|
||||
anyList())).thenReturn(builder);
|
||||
|
||||
String cacheFilePath =
|
||||
String.format("%s/%s/%s/%s/%s", path, CURRENT_DIR, BLOCK_POOL_IDS[0],
|
||||
|
|
|
@ -70,7 +70,7 @@ 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.mockito.Matchers.any;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
|
||||
/**
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.apache.hadoop.hdfs.server.namenode;
|
|||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
|
@ -59,7 +60,6 @@ import org.apache.hadoop.hdfs.server.namenode.NNStorage.NameNodeDirType;
|
|||
import org.apache.hadoop.hdfs.util.Holder;
|
||||
import org.apache.hadoop.hdfs.util.MD5FileUtils;
|
||||
import org.apache.hadoop.io.IOUtils;
|
||||
import org.mockito.Matchers;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
|
@ -200,7 +200,7 @@ public abstract class FSImageTestUtil {
|
|||
List<StorageDirectory> sds = Lists.newArrayList(sd);
|
||||
Mockito.doReturn(sds).when(storage).dirIterable(NameNodeDirType.EDITS);
|
||||
Mockito.doReturn(sd).when(storage)
|
||||
.getStorageDirectory(Matchers.<URI>anyObject());
|
||||
.getStorageDirectory(any());
|
||||
|
||||
FSEditLog editLog = new FSEditLog(new Configuration(),
|
||||
storage,
|
||||
|
|
|
@ -37,7 +37,7 @@ import java.util.List;
|
|||
import java.util.Optional;
|
||||
|
||||
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
/**
|
||||
|
|
|
@ -75,7 +75,7 @@ import static org.junit.Assert.assertFalse;
|
|||
import static org.junit.Assert.assertNull;
|
||||
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.doThrow;
|
||||
|
||||
/**
|
||||
|
|
|
@ -54,7 +54,7 @@ import static org.junit.Assert.assertTrue;
|
|||
import static org.junit.Assert.fail;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
|
|
@ -89,7 +89,6 @@ import org.slf4j.event.Level;
|
|||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.ArgumentMatcher;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
@ -621,14 +620,7 @@ public class TestCheckpoint {
|
|||
}
|
||||
|
||||
private File filePathContaining(final String substring) {
|
||||
return Mockito.argThat(
|
||||
new ArgumentMatcher<File>() {
|
||||
@Override
|
||||
public boolean matches(Object argument) {
|
||||
String path = ((File) argument).getAbsolutePath();
|
||||
return path.contains(substring);
|
||||
}
|
||||
});
|
||||
return Mockito.argThat(arg -> arg.getAbsolutePath().contains(substring));
|
||||
}
|
||||
|
||||
private void checkTempImages(NNStorage storage) throws IOException {
|
||||
|
@ -1993,7 +1985,7 @@ public class TestCheckpoint {
|
|||
NNStorage dstImage = Mockito.mock(NNStorage.class);
|
||||
Mockito.doReturn(Lists.newArrayList(new File("/wont-be-written")))
|
||||
.when(dstImage).getFiles(
|
||||
Mockito.<NameNodeDirType>anyObject(), Mockito.anyString());
|
||||
Mockito.<NameNodeDirType>any(), Mockito.anyString());
|
||||
|
||||
File mockImageFile = File.createTempFile("image", "");
|
||||
FileOutputStream imageFile = new FileOutputStream(mockImageFile);
|
||||
|
|
|
@ -32,7 +32,7 @@ import org.junit.Test;
|
|||
import java.io.IOException;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
/**
|
||||
|
@ -77,7 +77,7 @@ public class TestCommitBlockSynchronization {
|
|||
doReturn(blockInfo).when(namesystemSpy).getStoredBlock(any(Block.class));
|
||||
doReturn(blockInfo).when(file).getLastBlock();
|
||||
doNothing().when(namesystemSpy).closeFileCommitBlocks(
|
||||
any(String.class), any(INodeFile.class), any(BlockInfo.class));
|
||||
any(), any(INodeFile.class), any(BlockInfo.class));
|
||||
doReturn(mock(FSEditLog.class)).when(namesystemSpy).getEditLog();
|
||||
|
||||
return namesystemSpy;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue