HBASE-18925 Update mockito dependency from mockito-all:1.10.19 to mockito-core:2.1.0 for JDK8 support.

Last mockito-all release was in Dec'14. Mockito-core has had many releases since then.

From mockito's site:
- "Mockito does not produce the mockito-all artifact anymore ; this one was primarily
aimed at ant users, and contained other dependencies. We felt it was time to move on
and remove such artifacts as they cause problems in dependency management system like
maven or gradle."
- anyX() and any(SomeType.class) matchers now reject nulls and check type.
This commit is contained in:
Apekshit Sharma 2017-10-02 22:53:34 -07:00
parent b3e438b9c5
commit 71a55dcd64
71 changed files with 345 additions and 404 deletions

View File

@ -192,7 +192,7 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId> <artifactId>mockito-core</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -138,13 +138,12 @@ public class TestClientScanner {
RpcRetryingCaller<Result[]> caller = Mockito.mock(RpcRetryingCaller.class); RpcRetryingCaller<Result[]> caller = Mockito.mock(RpcRetryingCaller.class);
Mockito.when(rpcFactory.<Result[]> newCaller()).thenReturn(caller); Mockito.when(rpcFactory.<Result[]> newCaller()).thenReturn(caller);
Mockito.when(caller.callWithoutRetries(Mockito.any(RetryingCallable.class), Mockito.when(caller.callWithoutRetries(Mockito.any(),
Mockito.anyInt())).thenAnswer(new Answer<Result[]>() { Mockito.anyInt())).thenAnswer(new Answer<Result[]>() {
private int count = 0; private int count = 0;
@Override @Override
public Result[] answer(InvocationOnMock invocation) throws Throwable { public Result[] answer(InvocationOnMock invocation) throws Throwable {
ScannerCallableWithReplicas callable = invocation.getArgumentAt(0, ScannerCallableWithReplicas callable = invocation.getArgument(0);
ScannerCallableWithReplicas.class);
switch (count) { switch (count) {
case 0: // initialize case 0: // initialize
count++; count++;
@ -176,7 +175,7 @@ public class TestClientScanner {
// One for fetching the results // One for fetching the results
// One for fetching empty results and quit as we do not have moreResults hint. // One for fetching empty results and quit as we do not have moreResults hint.
inOrder.verify(caller, Mockito.times(2)).callWithoutRetries( inOrder.verify(caller, Mockito.times(2)).callWithoutRetries(
Mockito.any(RetryingCallable.class), Mockito.anyInt()); Mockito.any(), Mockito.anyInt());
assertEquals(1, scanner.cache.size()); assertEquals(1, scanner.cache.size());
Result r = scanner.cache.poll(); Result r = scanner.cache.poll();
@ -199,13 +198,12 @@ public class TestClientScanner {
RpcRetryingCaller<Result[]> caller = Mockito.mock(RpcRetryingCaller.class); RpcRetryingCaller<Result[]> caller = Mockito.mock(RpcRetryingCaller.class);
Mockito.when(rpcFactory.<Result[]> newCaller()).thenReturn(caller); Mockito.when(rpcFactory.<Result[]> newCaller()).thenReturn(caller);
Mockito.when(caller.callWithoutRetries(Mockito.any(RetryingCallable.class), Mockito.when(caller.callWithoutRetries(Mockito.any(),
Mockito.anyInt())).thenAnswer(new Answer<Result[]>() { Mockito.anyInt())).thenAnswer(new Answer<Result[]>() {
private int count = 0; private int count = 0;
@Override @Override
public Result[] answer(InvocationOnMock invocation) throws Throwable { public Result[] answer(InvocationOnMock invocation) throws Throwable {
ScannerCallableWithReplicas callable = invocation.getArgumentAt(0, ScannerCallableWithReplicas callable = invocation.getArgument(0);
ScannerCallableWithReplicas.class);
switch (count) { switch (count) {
case 0: // initialize case 0: // initialize
count++; count++;
@ -235,7 +233,7 @@ public class TestClientScanner {
scanner.loadCache(); scanner.loadCache();
inOrder.verify(caller, Mockito.times(1)).callWithoutRetries( inOrder.verify(caller, Mockito.times(1)).callWithoutRetries(
Mockito.any(RetryingCallable.class), Mockito.anyInt()); Mockito.any(), Mockito.anyInt());
assertEquals(1, scanner.cache.size()); assertEquals(1, scanner.cache.size());
Result r = scanner.cache.poll(); Result r = scanner.cache.poll();
@ -260,13 +258,12 @@ public class TestClientScanner {
RpcRetryingCaller<Result[]> caller = Mockito.mock(RpcRetryingCaller.class); RpcRetryingCaller<Result[]> caller = Mockito.mock(RpcRetryingCaller.class);
Mockito.when(rpcFactory.<Result[]> newCaller()).thenReturn(caller); Mockito.when(rpcFactory.<Result[]> newCaller()).thenReturn(caller);
Mockito.when(caller.callWithoutRetries(Mockito.any(RetryingCallable.class), Mockito.when(caller.callWithoutRetries(Mockito.any(),
Mockito.anyInt())).thenAnswer(new Answer<Result[]>() { Mockito.anyInt())).thenAnswer(new Answer<Result[]>() {
private int count = 0; private int count = 0;
@Override @Override
public Result[] answer(InvocationOnMock invocation) throws Throwable { public Result[] answer(InvocationOnMock invocation) throws Throwable {
ScannerCallableWithReplicas callable = invocation.getArgumentAt(0, ScannerCallableWithReplicas callable = invocation.getArgument(0);
ScannerCallableWithReplicas.class);
switch (count) { switch (count) {
case 0: // initialize case 0: // initialize
count++; count++;
@ -296,7 +293,7 @@ public class TestClientScanner {
scanner.loadCache(); scanner.loadCache();
inOrder.verify(caller, Mockito.times(1)).callWithoutRetries( inOrder.verify(caller, Mockito.times(1)).callWithoutRetries(
Mockito.any(RetryingCallable.class), Mockito.anyInt()); Mockito.any(), Mockito.anyInt());
assertEquals(3, scanner.cache.size()); assertEquals(3, scanner.cache.size());
Result r = scanner.cache.poll(); Result r = scanner.cache.poll();
@ -333,13 +330,12 @@ public class TestClientScanner {
RpcRetryingCaller<Result[]> caller = Mockito.mock(RpcRetryingCaller.class); RpcRetryingCaller<Result[]> caller = Mockito.mock(RpcRetryingCaller.class);
Mockito.when(rpcFactory.<Result[]> newCaller()).thenReturn(caller); Mockito.when(rpcFactory.<Result[]> newCaller()).thenReturn(caller);
Mockito.when(caller.callWithoutRetries(Mockito.any(RetryingCallable.class), Mockito.when(caller.callWithoutRetries(Mockito.any(),
Mockito.anyInt())).thenAnswer(new Answer<Result[]>() { Mockito.anyInt())).thenAnswer(new Answer<Result[]>() {
private int count = 0; private int count = 0;
@Override @Override
public Result[] answer(InvocationOnMock invocation) throws Throwable { public Result[] answer(InvocationOnMock invocation) throws Throwable {
ScannerCallableWithReplicas callable = invocation.getArgumentAt(0, ScannerCallableWithReplicas callable = invocation.getArgument(0);
ScannerCallableWithReplicas.class);
switch (count) { switch (count) {
case 0: // initialize case 0: // initialize
count++; count++;
@ -369,7 +365,7 @@ public class TestClientScanner {
scanner.loadCache(); scanner.loadCache();
inOrder.verify(caller, Mockito.times(1)).callWithoutRetries( inOrder.verify(caller, Mockito.times(1)).callWithoutRetries(
Mockito.any(RetryingCallable.class), Mockito.anyInt()); Mockito.any(), Mockito.anyInt());
assertEquals(1, scanner.cache.size()); assertEquals(1, scanner.cache.size());
Result r = scanner.cache.poll(); Result r = scanner.cache.poll();
@ -398,13 +394,12 @@ public class TestClientScanner {
RpcRetryingCaller<Result[]> caller = Mockito.mock(RpcRetryingCaller.class); RpcRetryingCaller<Result[]> caller = Mockito.mock(RpcRetryingCaller.class);
Mockito.when(rpcFactory.<Result[]> newCaller()).thenReturn(caller); Mockito.when(rpcFactory.<Result[]> newCaller()).thenReturn(caller);
Mockito.when(caller.callWithoutRetries(Mockito.any(RetryingCallable.class), Mockito.when(caller.callWithoutRetries(Mockito.any(),
Mockito.anyInt())).thenAnswer(new Answer<Result[]>() { Mockito.anyInt())).thenAnswer(new Answer<Result[]>() {
private int count = 0; private int count = 0;
@Override @Override
public Result[] answer(InvocationOnMock invocation) throws Throwable { public Result[] answer(InvocationOnMock invocation) throws Throwable {
ScannerCallableWithReplicas callable = invocation.getArgumentAt(0, ScannerCallableWithReplicas callable = invocation.getArgument(0);
ScannerCallableWithReplicas.class);
switch (count) { switch (count) {
case 0: // initialize case 0: // initialize
count++; count++;
@ -436,7 +431,7 @@ public class TestClientScanner {
scanner.loadCache(); scanner.loadCache();
inOrder.verify(caller, Mockito.times(2)).callWithoutRetries( inOrder.verify(caller, Mockito.times(2)).callWithoutRetries(
Mockito.any(RetryingCallable.class), Mockito.anyInt()); Mockito.any(), Mockito.anyInt());
assertEquals(2, scanner.cache.size()); assertEquals(2, scanner.cache.size());
Result r = scanner.cache.poll(); Result r = scanner.cache.poll();

View File

@ -44,7 +44,7 @@ public class TestHTableMultiplexerViaMocks {
mockConnection = mock(ClusterConnection.class); mockConnection = mock(ClusterConnection.class);
// Call the real put(TableName, Put, int) method // Call the real put(TableName, Put, int) method
when(mockMultiplexer.put(any(TableName.class), any(Put.class), anyInt())).thenCallRealMethod(); when(mockMultiplexer.put(any(TableName.class), any(), anyInt())).thenCallRealMethod();
// Return the mocked ClusterConnection // Return the mocked ClusterConnection
when(mockMultiplexer.getConnection()).thenReturn(mockConnection); when(mockMultiplexer.getConnection()).thenReturn(mockConnection);

View File

@ -30,9 +30,7 @@ import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.ipc.HBaseRpcController; import org.apache.hadoop.hbase.ipc.HBaseRpcController;
import org.apache.hadoop.hbase.ipc.RpcControllerFactory; import org.apache.hadoop.hbase.ipc.RpcControllerFactory;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.IsSnapshotDoneRequest;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.IsSnapshotDoneResponse; import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.IsSnapshotDoneResponse;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SnapshotRequest;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SnapshotResponse; import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SnapshotResponse;
import org.apache.hadoop.hbase.testclassification.ClientTests; import org.apache.hadoop.hbase.testclassification.ClientTests;
import org.apache.hadoop.hbase.testclassification.SmallTests; import org.apache.hadoop.hbase.testclassification.SmallTests;
@ -103,14 +101,14 @@ public class TestSnapshotFromAdmin {
Mockito Mockito
.when( .when(
mockMaster.snapshot((RpcController) Mockito.any(), mockMaster.snapshot((RpcController) Mockito.any(),
Mockito.any(SnapshotRequest.class))).thenReturn(response); Mockito.any())).thenReturn(response);
// setup the response // setup the response
IsSnapshotDoneResponse.Builder builder = IsSnapshotDoneResponse.newBuilder(); IsSnapshotDoneResponse.Builder builder = IsSnapshotDoneResponse.newBuilder();
builder.setDone(false); builder.setDone(false);
// first five times, we return false, last we get success // first five times, we return false, last we get success
Mockito.when( Mockito.when(
mockMaster.isSnapshotDone((RpcController) Mockito.any(), mockMaster.isSnapshotDone((RpcController) Mockito.any(),
Mockito.any(IsSnapshotDoneRequest.class))).thenReturn(builder.build(), builder.build(), Mockito.any())).thenReturn(builder.build(), builder.build(),
builder.build(), builder.build(), builder.build(), builder.setDone(true).build()); builder.build(), builder.build(), builder.build(), builder.setDone(true).build());
// setup the admin and run the test // setup the admin and run the test
@ -162,12 +160,12 @@ public class TestSnapshotFromAdmin {
Mockito.when(mockConnection.getKeepAliveMasterService()).thenReturn(master); Mockito.when(mockConnection.getKeepAliveMasterService()).thenReturn(master);
SnapshotResponse response = SnapshotResponse.newBuilder().setExpectedTimeout(0).build(); SnapshotResponse response = SnapshotResponse.newBuilder().setExpectedTimeout(0).build();
Mockito.when( Mockito.when(
master.snapshot((RpcController) Mockito.any(), Mockito.any(SnapshotRequest.class))) master.snapshot((RpcController) Mockito.any(), Mockito.any()))
.thenReturn(response); .thenReturn(response);
IsSnapshotDoneResponse doneResponse = IsSnapshotDoneResponse.newBuilder().setDone(true).build(); IsSnapshotDoneResponse doneResponse = IsSnapshotDoneResponse.newBuilder().setDone(true).build();
Mockito.when( Mockito.when(
master.isSnapshotDone((RpcController) Mockito.any(), master.isSnapshotDone((RpcController) Mockito.any(),
Mockito.any(IsSnapshotDoneRequest.class))).thenReturn(doneResponse); Mockito.any())).thenReturn(doneResponse);
// make sure that we can use valid names // make sure that we can use valid names
admin.snapshot(new SnapshotDescription("snapshot", TableName.valueOf(name.getMethodName()))); admin.snapshot(new SnapshotDescription("snapshot", TableName.valueOf(name.getMethodName())));

View File

@ -113,8 +113,8 @@ public class TestHBaseSaslRpcClient {
final SaslClientCallbackHandler saslClCallbackHandler = new SaslClientCallbackHandler(token); final SaslClientCallbackHandler saslClCallbackHandler = new SaslClientCallbackHandler(token);
saslClCallbackHandler.handle(callbackArray); saslClCallbackHandler.handle(callbackArray);
verify(nameCallback).setName(anyString()); verify(nameCallback).setName(anyString());
verify(realmCallback).setText(anyString()); verify(realmCallback).setText(any());
verify(passwordCallback).setPassword(any(char[].class)); verify(passwordCallback).setPassword(any());
} }
@Test @Test

View File

@ -269,7 +269,7 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId> <artifactId>mockito-core</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -213,7 +213,7 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId> <artifactId>mockito-core</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<!-- Some tests rely on Hadoop's KeyStoreTestUtil, which needs bc. --> <!-- Some tests rely on Hadoop's KeyStoreTestUtil, which needs bc. -->

View File

@ -206,7 +206,7 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId> <artifactId>mockito-core</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -63,13 +63,13 @@ public class TestMapReduceExamples {
@Override @Override
public Void answer(InvocationOnMock invocation) throws Throwable { public Void answer(InvocationOnMock invocation) throws Throwable {
ImmutableBytesWritable writer = (ImmutableBytesWritable) invocation.getArguments()[0]; ImmutableBytesWritable writer = (ImmutableBytesWritable) invocation.getArgument(0);
Put put = (Put) invocation.getArguments()[1]; Put put = (Put) invocation.getArgument(1);
assertEquals("row", Bytes.toString(writer.get())); assertEquals("row", Bytes.toString(writer.get()));
assertEquals("row", Bytes.toString(put.getRow())); assertEquals("row", Bytes.toString(put.getRow()));
return null; return null;
} }
}).when(ctx).write(any(ImmutableBytesWritable.class), any(Put.class)); }).when(ctx).write(any(), any());
uploader.map(null, new Text("row,family,qualifier,value"), ctx); uploader.map(null, new Text("row,family,qualifier,value"), ctx);
@ -134,13 +134,13 @@ public class TestMapReduceExamples {
@Override @Override
public Void answer(InvocationOnMock invocation) throws Throwable { public Void answer(InvocationOnMock invocation) throws Throwable {
ImmutableBytesWritable writer = (ImmutableBytesWritable) invocation.getArguments()[0]; ImmutableBytesWritable writer = (ImmutableBytesWritable) invocation.getArgument(0);
Put put = (Put) invocation.getArguments()[1]; Put put = (Put) invocation.getArgument(1);
assertEquals("tableName-column1", Bytes.toString(writer.get())); assertEquals("tableName-column1", Bytes.toString(writer.get()));
assertEquals("test", Bytes.toString(put.getRow())); assertEquals("test", Bytes.toString(put.getRow()));
return null; return null;
} }
}).when(ctx).write(any(ImmutableBytesWritable.class), any(Put.class)); }).when(ctx).write(any(), any());
Result result = mock(Result.class); Result result = mock(Result.class);
when(result.getValue(Bytes.toBytes("columnFamily"), Bytes.toBytes("column1"))).thenReturn( when(result.getValue(Bytes.toBytes("columnFamily"), Bytes.toBytes("column1"))).thenReturn(
Bytes.toBytes("test")); Bytes.toBytes("test"));

View File

@ -311,7 +311,7 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId> <artifactId>mockito-core</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -17,6 +17,7 @@
*/ */
package org.apache.hadoop.hbase.http; package org.apache.hadoop.hbase.http;
import com.google.common.annotations.VisibleForTesting;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InterruptedIOException; import java.io.InterruptedIOException;
@ -32,6 +33,7 @@ import java.util.Enumeration;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
import javax.servlet.Filter; import javax.servlet.Filter;
import javax.servlet.FilterChain; import javax.servlet.FilterChain;
@ -48,6 +50,8 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.HadoopIllegalArgumentException; import org.apache.hadoop.HadoopIllegalArgumentException;
import org.apache.hadoop.hbase.shaded.com.google.common.base.Preconditions;
import org.apache.hadoop.hbase.shaded.com.google.common.collect.Lists;
import org.apache.yetus.audience.InterfaceAudience; import org.apache.yetus.audience.InterfaceAudience;
import org.apache.yetus.audience.InterfaceStability; import org.apache.yetus.audience.InterfaceStability;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
@ -90,9 +94,6 @@ import org.eclipse.jetty.webapp.WebAppContext;
import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.servlet.ServletContainer; import org.glassfish.jersey.servlet.ServletContainer;
import org.apache.hadoop.hbase.shaded.com.google.common.base.Preconditions;
import org.apache.hadoop.hbase.shaded.com.google.common.collect.Lists;
/** /**
* Create a Jetty embedded server to answer http requests. The primary goal * Create a Jetty embedded server to answer http requests. The primary goal
* is to serve up status information for the server. * is to serve up status information for the server.
@ -161,6 +162,11 @@ public class HttpServer implements FilterContainer {
private final List<ListenerInfo> listeners = Lists.newArrayList(); private final List<ListenerInfo> listeners = Lists.newArrayList();
@VisibleForTesting
public List<ServerConnector> getServerConnectors() {
return listeners.stream().map(info -> info.listener).collect(Collectors.toList());
}
protected final WebAppContext webAppContext; protected final WebAppContext webAppContext;
protected final boolean findPort; protected final boolean findPort;
protected final Map<ServletContextHandler, Boolean> defaultContexts = new HashMap<>(); protected final Map<ServletContextHandler, Boolean> defaultContexts = new HashMap<>();
@ -1011,6 +1017,7 @@ public class HttpServer implements FilterContainer {
* Open the main listener for the server * Open the main listener for the server
* @throws Exception * @throws Exception
*/ */
@VisibleForTesting
void openListeners() throws Exception { void openListeners() throws Exception {
for (ListenerInfo li : listeners) { for (ListenerInfo li : listeners) {
ServerConnector listener = li.listener; ServerConnector listener = li.listener;

View File

@ -67,7 +67,6 @@ import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.experimental.categories.Category; import org.junit.experimental.categories.Category;
import org.mockito.Mockito; import org.mockito.Mockito;
import org.mockito.internal.util.reflection.Whitebox;
@Category({MiscTests.class, SmallTests.class}) @Category({MiscTests.class, SmallTests.class})
public class TestHttpServer extends HttpServerFunctionalTest { public class TestHttpServer extends HttpServerFunctionalTest {
@ -557,10 +556,7 @@ public class TestHttpServer extends HttpServerFunctionalTest {
HttpServer server = createServer(host, port); HttpServer server = createServer(host, port);
try { try {
// not bound, ephemeral should return requested port (0 for ephemeral) // not bound, ephemeral should return requested port (0 for ephemeral)
List<?> listeners = (List<?>) Whitebox.getInternalState(server, ServerConnector listener = server.getServerConnectors().get(0);
"listeners");
ServerConnector listener = (ServerConnector) Whitebox.getInternalState(
listeners.get(0), "listener");
assertEquals(port, listener.getPort()); assertEquals(port, listener.getPort());
// verify hostname is what was given // verify hostname is what was given

View File

@ -262,7 +262,7 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId> <artifactId>mockito-core</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -36,6 +36,6 @@ public class TestDriver {
ProgramDriver programDriverMock = mock(ProgramDriver.class); ProgramDriver programDriverMock = mock(ProgramDriver.class);
Driver.setProgramDriver(programDriverMock); Driver.setProgramDriver(programDriverMock);
Driver.main(new String[]{}); Driver.main(new String[]{});
verify(programDriverMock).driver(Mockito.any(String[].class)); verify(programDriverMock).driver(Mockito.any());
} }
} }

View File

@ -107,7 +107,7 @@ public class TestGroupingTableMap {
gTableMap.map(null, result, outputCollectorMock, reporter); gTableMap.map(null, result, outputCollectorMock, reporter);
verify(result).listCells(); verify(result).listCells();
verify(outputCollectorMock, times(1)) verify(outputCollectorMock, times(1))
.collect(any(ImmutableBytesWritable.class), any(Result.class)); .collect(any(), any());
verifyNoMoreInteractions(outputCollectorMock); verifyNoMoreInteractions(outputCollectorMock);
} finally { } finally {
if (gTableMap != null) if (gTableMap != null)

View File

@ -55,7 +55,7 @@ public class TestIdentityTableMap {
reporterMock); reporterMock);
verify(outputCollectorMock, times(recordNumber)).collect( verify(outputCollectorMock, times(recordNumber)).collect(
Mockito.any(ImmutableBytesWritable.class), Mockito.any(Result.class)); Mockito.any(), Mockito.any());
} finally { } finally {
if (identityTableMap != null) if (identityTableMap != null)
identityTableMap.close(); identityTableMap.close();

View File

@ -21,8 +21,8 @@ package org.apache.hadoop.hbase.mapred;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.Matchers.any; import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times; import static org.mockito.Mockito.times;
@ -89,7 +89,7 @@ public class TestRowCounter {
mock(OutputCollector.class), reporter); mock(OutputCollector.class), reporter);
Mockito.verify(reporter, times(iterationNumber)).incrCounter( Mockito.verify(reporter, times(iterationNumber)).incrCounter(
any(Enum.class), anyInt()); any(), anyLong());
} }
@Test @Test

View File

@ -50,7 +50,7 @@ public class TestGroupingTableMapper {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Mapper<ImmutableBytesWritable, Result, ImmutableBytesWritable, Result>.Context context = Mapper<ImmutableBytesWritable, Result, ImmutableBytesWritable, Result>.Context context =
mock(Mapper.Context.class); mock(Mapper.Context.class);
context.write(any(ImmutableBytesWritable.class), any(Result.class)); context.write(any(), any());
List<Cell> keyValue = new ArrayList<>(); List<Cell> keyValue = new ArrayList<>();
byte[] row = {}; byte[] row = {};
keyValue.add(new KeyValue(row, Bytes.toBytes("family2"), Bytes.toBytes("clm"), Bytes keyValue.add(new KeyValue(row, Bytes.toBytes("family2"), Bytes.toBytes("clm"), Bytes

View File

@ -675,13 +675,13 @@ public class TestImportExport {
@Override @Override
public Void answer(InvocationOnMock invocation) throws Throwable { public Void answer(InvocationOnMock invocation) throws Throwable {
ImmutableBytesWritable writer = (ImmutableBytesWritable) invocation.getArguments()[0]; ImmutableBytesWritable writer = (ImmutableBytesWritable) invocation.getArgument(0);
MapReduceCell key = (MapReduceCell) invocation.getArguments()[1]; MapReduceCell key = (MapReduceCell) invocation.getArgument(1);
assertEquals("Key", Bytes.toString(writer.get())); assertEquals("Key", Bytes.toString(writer.get()));
assertEquals("row", Bytes.toString(CellUtil.cloneRow(key))); assertEquals("row", Bytes.toString(CellUtil.cloneRow(key)));
return null; return null;
} }
}).when(ctx).write(any(ImmutableBytesWritable.class), any(MapReduceCell.class)); }).when(ctx).write(any(), any());
importer.setup(ctx); importer.setup(ctx);
Result value = mock(Result.class); Result value = mock(Result.class);

View File

@ -23,7 +23,6 @@ import org.apache.hadoop.hbase.shaded.com.google.common.collect.ImmutableMap;
import org.apache.hadoop.hbase.shaded.com.google.common.collect.Lists; import org.apache.hadoop.hbase.shaded.com.google.common.collect.Lists;
import org.apache.hadoop.hbase.shaded.com.google.common.collect.Maps; import org.apache.hadoop.hbase.shaded.com.google.common.collect.Maps;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.client.Scan; import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.testclassification.SmallTests; import org.apache.hadoop.hbase.testclassification.SmallTests;
@ -68,8 +67,8 @@ public class TestMultiTableSnapshotInputFormatImpl {
// probably be the more "pure" // probably be the more "pure"
// way of doing things. This is the lesser of two evils, perhaps? // way of doing things. This is the lesser of two evils, perhaps?
doNothing().when(this.subject). doNothing().when(this.subject).
restoreSnapshot(any(Configuration.class), any(String.class), any(Path.class), restoreSnapshot(any(), any(), any(),
any(Path.class), any(FileSystem.class)); any(), any());
this.conf = new Configuration(); this.conf = new Configuration();
this.rootDir = new Path("file:///test-root-dir"); this.rootDir = new Path("file:///test-root-dir");
@ -180,7 +179,7 @@ public class TestMultiTableSnapshotInputFormatImpl {
for (Map.Entry<String, Path> entry : snapshotDirs.entrySet()) { for (Map.Entry<String, Path> entry : snapshotDirs.entrySet()) {
verify(this.subject).restoreSnapshot(eq(this.conf), eq(entry.getKey()), eq(this.rootDir), verify(this.subject).restoreSnapshot(eq(this.conf), eq(entry.getKey()), eq(this.rootDir),
eq(entry.getValue()), any(FileSystem.class)); eq(entry.getValue()), any());
} }
} }
} }

View File

@ -184,13 +184,13 @@ public class TestWALPlayer {
@Override @Override
public Void answer(InvocationOnMock invocation) throws Throwable { public Void answer(InvocationOnMock invocation) throws Throwable {
ImmutableBytesWritable writer = (ImmutableBytesWritable) invocation.getArguments()[0]; ImmutableBytesWritable writer = (ImmutableBytesWritable) invocation.getArgument(0);
MapReduceCell key = (MapReduceCell) invocation.getArguments()[1]; MapReduceCell key = (MapReduceCell) invocation.getArgument(1);
assertEquals("row", Bytes.toString(writer.get())); assertEquals("row", Bytes.toString(writer.get()));
assertEquals("row", Bytes.toString(CellUtil.cloneRow(key))); assertEquals("row", Bytes.toString(CellUtil.cloneRow(key)));
return null; return null;
} }
}).when(context).write(any(ImmutableBytesWritable.class), any(MapReduceCell.class)); }).when(context).write(any(), any());
mapper.map(key, value, context); mapper.map(key, value, context);

View File

@ -98,7 +98,7 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId> <artifactId>mockito-core</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -111,7 +111,7 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId> <artifactId>mockito-core</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -331,7 +331,7 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId> <artifactId>mockito-core</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -61,8 +61,8 @@ public class TestRemoteAdminRetries {
Response response = new Response(509); Response response = new Response(509);
when(client.get(anyString(), anyString())).thenReturn(response); when(client.get(anyString(), anyString())).thenReturn(response);
when(client.delete(anyString())).thenReturn(response); when(client.delete(anyString())).thenReturn(response);
when(client.put(anyString(), anyString(), any(byte[].class))).thenReturn(response); when(client.put(anyString(), anyString(), any())).thenReturn(response);
when(client.post(anyString(), anyString(), any(byte[].class))).thenReturn(response); when(client.post(anyString(), anyString(), any())).thenReturn(response);
Configuration configuration = TEST_UTIL.getConfiguration(); Configuration configuration = TEST_UTIL.getConfiguration();
configuration.setInt("hbase.rest.client.max.retries", RETRIES); configuration.setInt("hbase.rest.client.max.retries", RETRIES);
@ -120,7 +120,7 @@ public class TestRemoteAdminRetries {
remoteAdmin.createTable(new HTableDescriptor(TableName.valueOf("TestTable"))); remoteAdmin.createTable(new HTableDescriptor(TableName.valueOf("TestTable")));
} }
}); });
verify(client, times(RETRIES)).put(anyString(), anyString(), any(byte[].class)); verify(client, times(RETRIES)).put(anyString(), anyString(), any());
} }
@Test @Test

View File

@ -70,9 +70,9 @@ public class TestRemoteHTableRetries {
Response response = new Response(509); Response response = new Response(509);
when(client.get(anyString(), anyString())).thenReturn(response); when(client.get(anyString(), anyString())).thenReturn(response);
when(client.delete(anyString())).thenReturn(response); when(client.delete(anyString())).thenReturn(response);
when(client.put(anyString(), anyString(), any(byte[].class))).thenReturn( when(client.put(anyString(), anyString(), any())).thenReturn(
response); response);
when(client.post(anyString(), anyString(), any(byte[].class))).thenReturn( when(client.post(anyString(), anyString(), any())).thenReturn(
response); response);
Configuration configuration = TEST_UTIL.getConfiguration(); Configuration configuration = TEST_UTIL.getConfiguration();
@ -118,7 +118,7 @@ public class TestRemoteHTableRetries {
remoteTable.put(new Put(Bytes.toBytes("Row"))); remoteTable.put(new Put(Bytes.toBytes("Row")));
} }
}); });
verify(client, times(RETRIES)).put(anyString(), anyString(), any(byte[].class)); verify(client, times(RETRIES)).put(anyString(), anyString(), any());
} }
@Test @Test
@ -131,7 +131,7 @@ public class TestRemoteHTableRetries {
remoteTable.put(Arrays.asList(puts)); remoteTable.put(Arrays.asList(puts));
} }
}); });
verify(client, times(RETRIES)).put(anyString(), anyString(), any(byte[].class)); verify(client, times(RETRIES)).put(anyString(), anyString(), any());
} }
@Test @Test
@ -142,7 +142,7 @@ public class TestRemoteHTableRetries {
remoteTable.getScanner(new Scan()); remoteTable.getScanner(new Scan());
} }
}); });
verify(client, times(RETRIES)).post(anyString(), anyString(), any(byte[].class)); verify(client, times(RETRIES)).post(anyString(), anyString(), any());
} }
@Test @Test
@ -155,7 +155,7 @@ public class TestRemoteHTableRetries {
remoteTable.checkAndPut(ROW_1, COLUMN_1, QUALIFIER_1, VALUE_1, put ); remoteTable.checkAndPut(ROW_1, COLUMN_1, QUALIFIER_1, VALUE_1, put );
} }
}); });
verify(client, times(RETRIES)).put(anyString(), anyString(), any(byte[].class)); verify(client, times(RETRIES)).put(anyString(), anyString(), any());
} }
@Test @Test

View File

@ -164,7 +164,7 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId> <artifactId>mockito-core</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -582,11 +582,11 @@ public class TestRSGroupBasedLoadBalancer {
Mockito.when(gm.listRSGroups()).thenReturn( Mockito.when(gm.listRSGroups()).thenReturn(
Lists.newLinkedList(groupMap.values())); Lists.newLinkedList(groupMap.values()));
Mockito.when(gm.isOnline()).thenReturn(true); Mockito.when(gm.isOnline()).thenReturn(true);
Mockito.when(gm.getRSGroupOfTable(Mockito.any(TableName.class))) Mockito.when(gm.getRSGroupOfTable(Mockito.any()))
.thenAnswer(new Answer<String>() { .thenAnswer(new Answer<String>() {
@Override @Override
public String answer(InvocationOnMock invocation) throws Throwable { public String answer(InvocationOnMock invocation) throws Throwable {
return tableMap.get(invocation.getArguments()[0]); return tableMap.get(invocation.getArgument(0));
} }
}); });
return gm; return gm;

View File

@ -605,7 +605,7 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId> <artifactId>mockito-core</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -23,6 +23,9 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -402,8 +405,8 @@ public class TestHBaseTestingUtility {
@Test public void testResolvePortConflict() throws Exception { @Test public void testResolvePortConflict() throws Exception {
// raises port conflict between 1st call and 2nd call of randomPort() by mocking Random object // raises port conflict between 1st call and 2nd call of randomPort() by mocking Random object
Random random = Mockito.mock(Random.class); Random random = mock(Random.class);
Mockito.when(random.nextInt(Mockito.any(Integer.class))) when(random.nextInt(anyInt()))
.thenAnswer(new Answer<Integer>() { .thenAnswer(new Answer<Integer>() {
int[] numbers = { 1, 1, 2 }; int[] numbers = { 1, 1, 2 };
int count = 0; int count = 0;
@ -417,8 +420,8 @@ public class TestHBaseTestingUtility {
}); });
HBaseTestingUtility.PortAllocator.AvailablePortChecker portChecker = HBaseTestingUtility.PortAllocator.AvailablePortChecker portChecker =
Mockito.mock(HBaseTestingUtility.PortAllocator.AvailablePortChecker.class); mock(HBaseTestingUtility.PortAllocator.AvailablePortChecker.class);
Mockito.when(portChecker.available(Mockito.any(Integer.class))).thenReturn(true); when(portChecker.available(anyInt())).thenReturn(true);
HBaseTestingUtility.PortAllocator portAllocator = HBaseTestingUtility.PortAllocator portAllocator =
new HBaseTestingUtility.PortAllocator(random, portChecker); new HBaseTestingUtility.PortAllocator(random, portChecker);
@ -426,7 +429,7 @@ public class TestHBaseTestingUtility {
int port1 = portAllocator.randomFreePort(); int port1 = portAllocator.randomFreePort();
int port2 = portAllocator.randomFreePort(); int port2 = portAllocator.randomFreePort();
assertNotEquals(port1, port2); assertNotEquals(port1, port2);
Mockito.verify(random, Mockito.times(3)).nextInt(Mockito.any(Integer.class)); Mockito.verify(random, Mockito.times(3)).nextInt(anyInt());
} }
@Test @Test

View File

@ -165,7 +165,7 @@ public class TestMetaTableAccessorNoCluster {
.thenThrow(new ServiceException("Server not running (3 of 3)")) .thenThrow(new ServiceException("Server not running (3 of 3)"))
.thenAnswer(new Answer<ScanResponse>() { .thenAnswer(new Answer<ScanResponse>() {
public ScanResponse answer(InvocationOnMock invocation) throws Throwable { public ScanResponse answer(InvocationOnMock invocation) throws Throwable {
((HBaseRpcController) invocation.getArguments()[0]).setCellScanner(CellUtil ((HBaseRpcController) invocation.getArgument(0)).setCellScanner(CellUtil
.createCellScanner(cellScannables)); .createCellScanner(cellScannables));
return builder.setScannerId(1234567890L).setMoreResults(false).build(); return builder.setScannerId(1234567890L).setMoreResults(false).build();
} }
@ -189,7 +189,7 @@ public class TestMetaTableAccessorNoCluster {
// Now shove our HRI implementation into the spied-upon connection. // Now shove our HRI implementation into the spied-upon connection.
Mockito.doReturn(implementation). Mockito.doReturn(implementation).
when(connection).getClient(Mockito.any(ServerName.class)); when(connection).getClient(Mockito.any());
// Scan meta for user tables and verify we got back expected answer. // Scan meta for user tables and verify we got back expected answer.
NavigableMap<RegionInfo, Result> hris = NavigableMap<RegionInfo, Result> hris =

View File

@ -250,7 +250,7 @@ public class TestMetaTableLocator {
Mockito.mock(AdminProtos.AdminService.BlockingInterface.class); Mockito.mock(AdminProtos.AdminService.BlockingInterface.class);
Mockito.when(implementation.getRegionInfo((RpcController)Mockito.any(), Mockito.when(implementation.getRegionInfo((RpcController)Mockito.any(),
(GetRegionInfoRequest)Mockito.any())).thenThrow(connectException); (GetRegionInfoRequest)Mockito.any())).thenThrow(connectException);
Mockito.when(connection.getAdmin(Mockito.any(ServerName.class))). Mockito.when(connection.getAdmin(Mockito.any())).
thenReturn(implementation); thenReturn(implementation);
RpcControllerFactory controllerFactory = Mockito.mock(RpcControllerFactory.class); RpcControllerFactory controllerFactory = Mockito.mock(RpcControllerFactory.class);
Mockito.when(controllerFactory.newController()).thenReturn( Mockito.when(controllerFactory.newController()).thenReturn(
@ -325,12 +325,12 @@ public class TestMetaTableLocator {
thenReturn(anyLocation); thenReturn(anyLocation);
if (admin != null) { if (admin != null) {
// If a call to getHRegionConnection, return this implementation. // If a call to getHRegionConnection, return this implementation.
Mockito.when(connection.getAdmin(Mockito.any(ServerName.class))). Mockito.when(connection.getAdmin(Mockito.any())).
thenReturn(admin); thenReturn(admin);
} }
if (client != null) { if (client != null) {
// If a call to getClient, return this implementation. // If a call to getClient, return this implementation.
Mockito.when(connection.getClient(Mockito.any(ServerName.class))). Mockito.when(connection.getClient(Mockito.any())).
thenReturn(client); thenReturn(client);
} }
return connection; return connection;

View File

@ -362,7 +362,7 @@ public class TestZooKeeperTableArchiveClient {
public Iterable<FileStatus> answer(InvocationOnMock invocation) throws Throwable { public Iterable<FileStatus> answer(InvocationOnMock invocation) throws Throwable {
counter[0]++; counter[0]++;
LOG.debug(counter[0] + "/ " + expected + ") Wrapping call to getDeletableFiles for files: " LOG.debug(counter[0] + "/ " + expected + ") Wrapping call to getDeletableFiles for files: "
+ invocation.getArguments()[0]); + invocation.getArgument(0));
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Iterable<FileStatus> ret = (Iterable<FileStatus>) invocation.callRealMethod(); Iterable<FileStatus> ret = (Iterable<FileStatus>) invocation.callRealMethod();

View File

@ -116,12 +116,12 @@ public class HConnectionTestingUtility {
.thenReturn(new RegionLocations(loc)); .thenReturn(new RegionLocations(loc));
if (admin != null) { if (admin != null) {
// If a call to getAdmin, return this implementation. // If a call to getAdmin, return this implementation.
Mockito.when(c.getAdmin(Mockito.any(ServerName.class))). Mockito.when(c.getAdmin(Mockito.any())).
thenReturn(admin); thenReturn(admin);
} }
if (client != null) { if (client != null) {
// If a call to getClient, return this client. // If a call to getClient, return this client.
Mockito.when(c.getClient(Mockito.any(ServerName.class))). Mockito.when(c.getClient(Mockito.any())).
thenReturn(client); thenReturn(client);
} }
NonceGenerator ng = Mockito.mock(NonceGenerator.class); NonceGenerator ng = Mockito.mock(NonceGenerator.class);

View File

@ -96,8 +96,8 @@ public class TestForeignExceptionDispatcher {
assertTrue("Monitor didn't get timeout", monitor.hasException()); assertTrue("Monitor didn't get timeout", monitor.hasException());
// verify that that we propagated the error // verify that that we propagated the error
Mockito.verify(listener1).receive(Mockito.any(ForeignException.class)); Mockito.verify(listener1).receive(Mockito.any());
Mockito.verify(listener2).receive(Mockito.any(ForeignException.class)); Mockito.verify(listener2).receive(Mockito.any());
} }
/** /**
@ -118,7 +118,7 @@ public class TestForeignExceptionDispatcher {
timer.start(); timer.start();
timer.trigger(); timer.trigger();
// make sure that we got the timer error // make sure that we got the timer error
Mockito.verify(listener1, Mockito.times(1)).receive(Mockito.any(ForeignException.class)); Mockito.verify(listener1, Mockito.times(1)).receive(Mockito.any());
Mockito.verify(listener2, Mockito.times(1)).receive(Mockito.any(ForeignException.class)); Mockito.verify(listener2, Mockito.times(1)).receive(Mockito.any());
} }
} }

View File

@ -45,7 +45,7 @@ public class TestTimeoutExceptionInjector {
TimeoutExceptionInjector timer = new TimeoutExceptionInjector(listener, time); TimeoutExceptionInjector timer = new TimeoutExceptionInjector(listener, time);
timer.start(); timer.start();
timer.trigger(); timer.trigger();
Mockito.verify(listener, Mockito.times(1)).receive(Mockito.any(ForeignException.class)); Mockito.verify(listener, Mockito.times(1)).receive(Mockito.any());
} }
/** /**
@ -58,7 +58,7 @@ public class TestTimeoutExceptionInjector {
TimeoutExceptionInjector timer = new TimeoutExceptionInjector(listener, time); TimeoutExceptionInjector timer = new TimeoutExceptionInjector(listener, time);
timer.start(); timer.start();
timer.trigger(); timer.trigger();
Mockito.verify(listener).receive(Mockito.any(ForeignException.class)); Mockito.verify(listener).receive(Mockito.any());
} }
/** /**
@ -98,7 +98,7 @@ public class TestTimeoutExceptionInjector {
LOG.debug("Correctly failed timer: " + e.getMessage()); LOG.debug("Correctly failed timer: " + e.getMessage());
} }
Thread.sleep(time * 2); Thread.sleep(time * 2);
Mockito.verify(listener, Mockito.times(1)).receive(Mockito.any(ForeignException.class)); Mockito.verify(listener, Mockito.times(1)).receive(Mockito.any());
Mockito.verifyNoMoreInteractions(listener); Mockito.verifyNoMoreInteractions(listener);
} }
} }

View File

@ -22,7 +22,6 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any; import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Matchers.eq; import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
@ -42,7 +41,6 @@ import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import java.util.Set; import java.util.Set;
import java.util.concurrent.BlockingQueue; import java.util.concurrent.BlockingQueue;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
@ -56,8 +54,6 @@ import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.monitoring.MonitoredRPCHandlerImpl; import org.apache.hadoop.hbase.monitoring.MonitoredRPCHandlerImpl;
import org.apache.hadoop.hbase.security.User;
import org.apache.hadoop.hbase.shaded.com.google.protobuf.Message;
import org.apache.hadoop.hbase.shaded.protobuf.RequestConverter; import org.apache.hadoop.hbase.shaded.protobuf.RequestConverter;
import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ScanRequest; import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ScanRequest;
import org.apache.hadoop.hbase.shaded.protobuf.generated.RPCProtos; import org.apache.hadoop.hbase.shaded.protobuf.generated.RPCProtos;
@ -182,7 +178,6 @@ public class TestSimpleRpcScheduler {
@Test @Test
public void testHandlerIsolation() throws IOException, InterruptedException { public void testHandlerIsolation() throws IOException, InterruptedException {
CallRunner generalTask = createMockTask(); CallRunner generalTask = createMockTask();
CallRunner priorityTask = createMockTask(); CallRunner priorityTask = createMockTask();
CallRunner replicationTask = createMockTask(); CallRunner replicationTask = createMockTask();
@ -219,9 +214,7 @@ public class TestSimpleRpcScheduler {
scheduler.init(CONTEXT); scheduler.init(CONTEXT);
scheduler.start(); scheduler.start();
for (CallRunner task : tasks) { for (CallRunner task : tasks) {
when(qosFunction.getPriority((RPCProtos.RequestHeader) anyObject(), when(qosFunction.getPriority(any(), any(), any())).thenReturn(qos.get(task));
(Message) anyObject(), (User) anyObject()))
.thenReturn(qos.get(task));
scheduler.dispatch(task); scheduler.dispatch(task);
} }
for (CallRunner task : tasks) { for (CallRunner task : tasks) {
@ -238,13 +231,11 @@ public class TestSimpleRpcScheduler {
ServerCall call = mock(ServerCall.class); ServerCall call = mock(ServerCall.class);
CallRunner task = mock(CallRunner.class); CallRunner task = mock(CallRunner.class);
when(task.getRpcCall()).thenReturn(call); when(task.getRpcCall()).thenReturn(call);
when(call.getRequestUser()).thenReturn(Optional.empty());
return task; return task;
} }
@Test @Test
public void testRpcScheduler() throws Exception { public void testRpcScheduler() throws Exception {
testRpcScheduler(RpcExecutor.CALL_QUEUE_TYPE_DEADLINE_CONF_VALUE); testRpcScheduler(RpcExecutor.CALL_QUEUE_TYPE_DEADLINE_CONF_VALUE);
testRpcScheduler(RpcExecutor.CALL_QUEUE_TYPE_FIFO_CONF_VALUE); testRpcScheduler(RpcExecutor.CALL_QUEUE_TYPE_FIFO_CONF_VALUE);
} }
@ -254,9 +245,7 @@ public class TestSimpleRpcScheduler {
schedConf.set(RpcExecutor.CALL_QUEUE_TYPE_CONF_KEY, queueType); schedConf.set(RpcExecutor.CALL_QUEUE_TYPE_CONF_KEY, queueType);
PriorityFunction priority = mock(PriorityFunction.class); PriorityFunction priority = mock(PriorityFunction.class);
when(priority.getPriority(any(RequestHeader.class), when(priority.getPriority(any(), any(), any())).thenReturn(HConstants.NORMAL_QOS);
any(Message.class), any(User.class)))
.thenReturn(HConstants.NORMAL_QOS);
RpcScheduler scheduler = new SimpleRpcScheduler(schedConf, 1, 1, 1, priority, RpcScheduler scheduler = new SimpleRpcScheduler(schedConf, 1, 1, 1, priority,
HConstants.QOS_THRESHOLD); HConstants.QOS_THRESHOLD);
@ -268,25 +257,22 @@ public class TestSimpleRpcScheduler {
RequestHeader smallHead = RequestHeader.newBuilder().setCallId(1).build(); RequestHeader smallHead = RequestHeader.newBuilder().setCallId(1).build();
when(smallCallTask.getRpcCall()).thenReturn(smallCall); when(smallCallTask.getRpcCall()).thenReturn(smallCall);
when(smallCall.getHeader()).thenReturn(smallHead); when(smallCall.getHeader()).thenReturn(smallHead);
when(smallCall.getRequestUser()).thenReturn(Optional.empty());
CallRunner largeCallTask = mock(CallRunner.class); CallRunner largeCallTask = mock(CallRunner.class);
ServerCall largeCall = mock(ServerCall.class); ServerCall largeCall = mock(ServerCall.class);
RequestHeader largeHead = RequestHeader.newBuilder().setCallId(50).build(); RequestHeader largeHead = RequestHeader.newBuilder().setCallId(50).build();
when(largeCallTask.getRpcCall()).thenReturn(largeCall); when(largeCallTask.getRpcCall()).thenReturn(largeCall);
when(largeCall.getHeader()).thenReturn(largeHead); when(largeCall.getHeader()).thenReturn(largeHead);
when(largeCall.getRequestUser()).thenReturn(Optional.empty());
CallRunner hugeCallTask = mock(CallRunner.class); CallRunner hugeCallTask = mock(CallRunner.class);
ServerCall hugeCall = mock(ServerCall.class); ServerCall hugeCall = mock(ServerCall.class);
RequestHeader hugeHead = RequestHeader.newBuilder().setCallId(100).build(); RequestHeader hugeHead = RequestHeader.newBuilder().setCallId(100).build();
when(hugeCallTask.getRpcCall()).thenReturn(hugeCall); when(hugeCallTask.getRpcCall()).thenReturn(hugeCall);
when(hugeCall.getHeader()).thenReturn(hugeHead); when(hugeCall.getHeader()).thenReturn(hugeHead);
when(hugeCall.getRequestUser()).thenReturn(Optional.empty());
when(priority.getDeadline(eq(smallHead), any(Message.class))).thenReturn(0L); when(priority.getDeadline(eq(smallHead), any())).thenReturn(0L);
when(priority.getDeadline(eq(largeHead), any(Message.class))).thenReturn(50L); when(priority.getDeadline(eq(largeHead), any())).thenReturn(50L);
when(priority.getDeadline(eq(hugeHead), any(Message.class))).thenReturn(100L); when(priority.getDeadline(eq(hugeHead), any())).thenReturn(100L);
final ArrayList<Integer> work = new ArrayList<>(); final ArrayList<Integer> work = new ArrayList<>();
doAnswerTaskExecution(smallCallTask, work, 10, 250); doAnswerTaskExecution(smallCallTask, work, 10, 250);
@ -337,8 +323,7 @@ public class TestSimpleRpcScheduler {
schedConf.setFloat(RWQueueRpcExecutor.CALL_QUEUE_SCAN_SHARE_CONF_KEY, 0f); schedConf.setFloat(RWQueueRpcExecutor.CALL_QUEUE_SCAN_SHARE_CONF_KEY, 0f);
PriorityFunction priority = mock(PriorityFunction.class); PriorityFunction priority = mock(PriorityFunction.class);
when(priority.getPriority(any(RequestHeader.class), any(Message.class), when(priority.getPriority(any(), any(), any())).thenReturn(HConstants.NORMAL_QOS);
any(User.class))).thenReturn(HConstants.NORMAL_QOS);
RpcScheduler scheduler = new SimpleRpcScheduler(schedConf, 2, 1, 1, priority, RpcScheduler scheduler = new SimpleRpcScheduler(schedConf, 2, 1, 1, priority,
HConstants.QOS_THRESHOLD); HConstants.QOS_THRESHOLD);
@ -353,8 +338,7 @@ public class TestSimpleRpcScheduler {
schedConf.setFloat(RWQueueRpcExecutor.CALL_QUEUE_SCAN_SHARE_CONF_KEY, 0.5f); schedConf.setFloat(RWQueueRpcExecutor.CALL_QUEUE_SCAN_SHARE_CONF_KEY, 0.5f);
PriorityFunction priority = mock(PriorityFunction.class); PriorityFunction priority = mock(PriorityFunction.class);
when(priority.getPriority(any(RPCProtos.RequestHeader.class), any(Message.class), when(priority.getPriority(any(), any(), any())).thenReturn(HConstants.NORMAL_QOS);
any(User.class))).thenReturn(HConstants.NORMAL_QOS);
RpcScheduler scheduler = new SimpleRpcScheduler(schedConf, 3, 1, 1, priority, RpcScheduler scheduler = new SimpleRpcScheduler(schedConf, 3, 1, 1, priority,
HConstants.QOS_THRESHOLD); HConstants.QOS_THRESHOLD);
@ -369,14 +353,12 @@ public class TestSimpleRpcScheduler {
when(putCallTask.getRpcCall()).thenReturn(putCall); when(putCallTask.getRpcCall()).thenReturn(putCall);
when(putCall.getHeader()).thenReturn(putHead); when(putCall.getHeader()).thenReturn(putHead);
when(putCall.getParam()).thenReturn(putCall.param); when(putCall.getParam()).thenReturn(putCall.param);
when(putCall.getRequestUser()).thenReturn(Optional.empty());
CallRunner getCallTask = mock(CallRunner.class); CallRunner getCallTask = mock(CallRunner.class);
ServerCall getCall = mock(ServerCall.class); ServerCall getCall = mock(ServerCall.class);
RequestHeader getHead = RequestHeader.newBuilder().setMethodName("get").build(); RequestHeader getHead = RequestHeader.newBuilder().setMethodName("get").build();
when(getCallTask.getRpcCall()).thenReturn(getCall); when(getCallTask.getRpcCall()).thenReturn(getCall);
when(getCall.getHeader()).thenReturn(getHead); when(getCall.getHeader()).thenReturn(getHead);
when(getCall.getRequestUser()).thenReturn(Optional.empty());
CallRunner scanCallTask = mock(CallRunner.class); CallRunner scanCallTask = mock(CallRunner.class);
ServerCall scanCall = mock(ServerCall.class); ServerCall scanCall = mock(ServerCall.class);
@ -385,7 +367,6 @@ public class TestSimpleRpcScheduler {
when(scanCallTask.getRpcCall()).thenReturn(scanCall); when(scanCallTask.getRpcCall()).thenReturn(scanCall);
when(scanCall.getHeader()).thenReturn(scanHead); when(scanCall.getHeader()).thenReturn(scanHead);
when(scanCall.getParam()).thenReturn(scanCall.param); when(scanCall.getParam()).thenReturn(scanCall.param);
when(scanCall.getRequestUser()).thenReturn(Optional.empty());
ArrayList<Integer> work = new ArrayList<>(); ArrayList<Integer> work = new ArrayList<>();
doAnswerTaskExecution(putCallTask, work, 1, 1000); doAnswerTaskExecution(putCallTask, work, 1, 1000);
@ -449,8 +430,7 @@ public class TestSimpleRpcScheduler {
schedConf.setInt("hbase.ipc.server.max.callqueue.length", 5); schedConf.setInt("hbase.ipc.server.max.callqueue.length", 5);
PriorityFunction priority = mock(PriorityFunction.class); PriorityFunction priority = mock(PriorityFunction.class);
when(priority.getPriority(any(RequestHeader.class), any(Message.class), when(priority.getPriority(any(), any(), any())).thenReturn(HConstants.NORMAL_QOS);
any(User.class))).thenReturn(HConstants.NORMAL_QOS);
SimpleRpcScheduler scheduler = new SimpleRpcScheduler(schedConf, 0, 0, 0, priority, SimpleRpcScheduler scheduler = new SimpleRpcScheduler(schedConf, 0, 0, 0, priority,
HConstants.QOS_THRESHOLD); HConstants.QOS_THRESHOLD);
try { try {
@ -463,7 +443,6 @@ public class TestSimpleRpcScheduler {
RequestHeader putHead = RequestHeader.newBuilder().setMethodName("mutate").build(); RequestHeader putHead = RequestHeader.newBuilder().setMethodName("mutate").build();
when(putCallTask.getRpcCall()).thenReturn(putCall); when(putCallTask.getRpcCall()).thenReturn(putCall);
when(putCall.getHeader()).thenReturn(putHead); when(putCall.getHeader()).thenReturn(putHead);
when(putCall.getRequestUser()).thenReturn(Optional.empty());
assertTrue(scheduler.dispatch(putCallTask)); assertTrue(scheduler.dispatch(putCallTask));
@ -516,8 +495,7 @@ public class TestSimpleRpcScheduler {
schedConf.set(RpcExecutor.CALL_QUEUE_TYPE_CONF_KEY, schedConf.set(RpcExecutor.CALL_QUEUE_TYPE_CONF_KEY,
RpcExecutor.CALL_QUEUE_TYPE_CODEL_CONF_VALUE); RpcExecutor.CALL_QUEUE_TYPE_CODEL_CONF_VALUE);
PriorityFunction priority = mock(PriorityFunction.class); PriorityFunction priority = mock(PriorityFunction.class);
when(priority.getPriority(any(RPCProtos.RequestHeader.class), any(Message.class), when(priority.getPriority(any(), any(), any())).thenReturn(HConstants.NORMAL_QOS);
any(User.class))).thenReturn(HConstants.NORMAL_QOS);
SimpleRpcScheduler scheduler = SimpleRpcScheduler scheduler =
new SimpleRpcScheduler(schedConf, 1, 1, 1, priority, HConstants.QOS_THRESHOLD); new SimpleRpcScheduler(schedConf, 1, 1, 1, priority, HConstants.QOS_THRESHOLD);
try { try {

View File

@ -145,7 +145,7 @@ public class TestSplitLogManager {
// By default, we let the test manage the error as before, so the server // By default, we let the test manage the error as before, so the server
// does not appear as dead from the master point of view, only from the split log pov. // does not appear as dead from the master point of view, only from the split log pov.
Mockito.when(sm.isServerOnline(Mockito.any(ServerName.class))).thenReturn(true); Mockito.when(sm.isServerOnline(Mockito.any())).thenReturn(true);
to = 12000; to = 12000;
conf.setInt(HConstants.HBASE_SPLITLOG_MANAGER_TIMEOUT, to); conf.setInt(HConstants.HBASE_SPLITLOG_MANAGER_TIMEOUT, to);

View File

@ -17,6 +17,8 @@
*/ */
package org.apache.hadoop.hbase.master.assignment; package org.apache.hadoop.hbase.master.assignment;
import static org.mockito.ArgumentMatchers.any;
import java.io.IOException; import java.io.IOException;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
@ -55,23 +57,21 @@ import org.apache.hadoop.hbase.procedure2.ProcedureExecutor;
import org.apache.hadoop.hbase.procedure2.store.NoopProcedureStore; import org.apache.hadoop.hbase.procedure2.store.NoopProcedureStore;
import org.apache.hadoop.hbase.procedure2.store.ProcedureStore; import org.apache.hadoop.hbase.procedure2.store.ProcedureStore;
import org.apache.hadoop.hbase.security.Superusers; import org.apache.hadoop.hbase.security.Superusers;
import org.apache.hadoop.hbase.util.FSUtils;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.apache.hadoop.hbase.shaded.com.google.protobuf.RpcController;
import org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException; import org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException;
import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil; import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;
import org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos; import org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos;
import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos; import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos;
import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MultiRequest; import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MultiRequest;
import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MultiResponse; import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MultiResponse;
import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutateRequest;
import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutateResponse; import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutateResponse;
import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.RegionAction; import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.RegionAction;
import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.RegionActionResult; import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.RegionActionResult;
import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ResultOrException; import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ResultOrException;
import org.apache.hadoop.hbase.util.FSUtils;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
/** /**
* A mocked master services. * A mocked master services.
@ -136,17 +136,15 @@ public class MockMasterServices extends MockNoopMasterServices {
MutateResponse.Builder builder = MutateResponse.newBuilder(); MutateResponse.Builder builder = MutateResponse.newBuilder();
builder.setProcessed(true); builder.setProcessed(true);
try { try {
Mockito.when(ri.mutate((RpcController)Mockito.any(), (MutateRequest)Mockito.any())). Mockito.when(ri.mutate(any(), any())).thenReturn(builder.build());
thenReturn(builder.build());
} catch (ServiceException se) { } catch (ServiceException se) {
throw ProtobufUtil.handleRemoteException(se); throw ProtobufUtil.handleRemoteException(se);
} }
try { try {
Mockito.when(ri.multi((RpcController)Mockito.any(), (MultiRequest)Mockito.any())). Mockito.when(ri.multi(any(), any())).thenAnswer(new Answer<MultiResponse>() {
thenAnswer(new Answer<MultiResponse>() {
@Override @Override
public MultiResponse answer(InvocationOnMock invocation) throws Throwable { public MultiResponse answer(InvocationOnMock invocation) throws Throwable {
return buildMultiResponse( (MultiRequest)invocation.getArguments()[1]); return buildMultiResponse(invocation.getArgument(1));
} }
}); });
} catch (ServiceException se) { } catch (ServiceException se) {

View File

@ -216,7 +216,7 @@ public class TestCleanerChore {
FSUtils.logFileSystemState(fs, testDir, LOG); FSUtils.logFileSystemState(fs, testDir, LOG);
return (Boolean) invocation.callRealMethod(); return (Boolean) invocation.callRealMethod();
} }
}).when(spy).isFileDeletable(Mockito.any(FileStatus.class)); }).when(spy).isFileDeletable(Mockito.any());
// run the chore // run the chore
chore.chore(); chore.chore();
@ -225,7 +225,7 @@ public class TestCleanerChore {
assertTrue("Added file unexpectedly deleted", fs.exists(addedFile)); assertTrue("Added file unexpectedly deleted", fs.exists(addedFile));
assertTrue("Parent directory deleted unexpectedly", fs.exists(parent)); assertTrue("Parent directory deleted unexpectedly", fs.exists(parent));
assertFalse("Original file unexpectedly retained", fs.exists(file)); assertFalse("Original file unexpectedly retained", fs.exists(file));
Mockito.verify(spy, Mockito.times(1)).isFileDeletable(Mockito.any(FileStatus.class)); Mockito.verify(spy, Mockito.times(1)).isFileDeletable(Mockito.any());
Mockito.reset(spy); Mockito.reset(spy);
} }
@ -274,7 +274,7 @@ public class TestCleanerChore {
FSUtils.logFileSystemState(fs, testDir, LOG); FSUtils.logFileSystemState(fs, testDir, LOG);
return (Boolean) invocation.callRealMethod(); return (Boolean) invocation.callRealMethod();
} }
}).when(spy).isFileDeletable(Mockito.any(FileStatus.class)); }).when(spy).isFileDeletable(Mockito.any());
// attempt to delete the directory, which // attempt to delete the directory, which
if (chore.checkAndDeleteDirectory(parent)) { if (chore.checkAndDeleteDirectory(parent)) {
@ -286,7 +286,7 @@ public class TestCleanerChore {
assertTrue("Added file unexpectedly deleted", fs.exists(racyFile)); assertTrue("Added file unexpectedly deleted", fs.exists(racyFile));
assertTrue("Parent directory deleted unexpectedly", fs.exists(parent)); assertTrue("Parent directory deleted unexpectedly", fs.exists(parent));
assertFalse("Original file unexpectedly retained", fs.exists(file)); assertFalse("Original file unexpectedly retained", fs.exists(file));
Mockito.verify(spy, Mockito.times(1)).isFileDeletable(Mockito.any(FileStatus.class)); Mockito.verify(spy, Mockito.times(1)).isFileDeletable(Mockito.any());
} }
@Test @Test

View File

@ -39,6 +39,8 @@ import org.apache.hadoop.hbase.client.RegionInfo;
import org.apache.hadoop.hbase.client.RegionInfoBuilder; import org.apache.hadoop.hbase.client.RegionInfoBuilder;
import org.apache.hadoop.hbase.master.MasterRpcServices; import org.apache.hadoop.hbase.master.MasterRpcServices;
import org.apache.hadoop.hbase.master.MasterServices; import org.apache.hadoop.hbase.master.MasterServices;
import org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.IsSplitOrMergeEnabledResponse;
import org.apache.hadoop.hbase.testclassification.MasterTests; import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.testclassification.SmallTests; import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.Bytes;
@ -49,10 +51,6 @@ import org.junit.experimental.categories.Category;
import org.junit.rules.TestName; import org.junit.rules.TestName;
import org.mockito.Mockito; import org.mockito.Mockito;
import org.apache.hadoop.hbase.shaded.com.google.protobuf.RpcController;
import org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.IsSplitOrMergeEnabledRequest;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.IsSplitOrMergeEnabledResponse;
/** /**
* Tests logic of {@link SimpleRegionNormalizer}. * Tests logic of {@link SimpleRegionNormalizer}.
@ -353,9 +351,9 @@ public class TestSimpleRegionNormalizer {
// for simplicity all regions are assumed to be on one server; doesn't matter to us // for simplicity all regions are assumed to be on one server; doesn't matter to us
ServerName sn = ServerName.valueOf("localhost", 0, 1L); ServerName sn = ServerName.valueOf("localhost", 0, 1L);
when(masterServices.getAssignmentManager().getRegionStates(). when(masterServices.getAssignmentManager().getRegionStates().
getRegionsOfTable(any(TableName.class))).thenReturn(RegionInfo); getRegionsOfTable(any())).thenReturn(RegionInfo);
when(masterServices.getAssignmentManager().getRegionStates(). when(masterServices.getAssignmentManager().getRegionStates().
getRegionServerOfRegion(any(RegionInfo.class))).thenReturn(sn); getRegionServerOfRegion(any())).thenReturn(sn);
for (Map.Entry<byte[], Integer> region : regionSizes.entrySet()) { for (Map.Entry<byte[], Integer> region : regionSizes.entrySet()) {
RegionLoad regionLoad = Mockito.mock(RegionLoad.class); RegionLoad regionLoad = Mockito.mock(RegionLoad.class);
@ -366,8 +364,8 @@ public class TestSimpleRegionNormalizer {
getRegionsLoad().get(region.getKey())).thenReturn(regionLoad); getRegionsLoad().get(region.getKey())).thenReturn(regionLoad);
} }
try { try {
when(masterRpcServices.isSplitOrMergeEnabled(any(RpcController.class), when(masterRpcServices.isSplitOrMergeEnabled(any(),
any(IsSplitOrMergeEnabledRequest.class))).thenReturn( any())).thenReturn(
IsSplitOrMergeEnabledResponse.newBuilder().setEnabled(true).build()); IsSplitOrMergeEnabledResponse.newBuilder().setEnabled(true).build());
} catch (ServiceException se) { } catch (ServiceException se) {
LOG.debug("error setting isSplitOrMergeEnabled switch", se); LOG.debug("error setting isSplitOrMergeEnabled switch", se);

View File

@ -124,7 +124,7 @@ public class TestProcedure {
proc.completedProcedure.await(); proc.completedProcedure.await();
verify(procspy).sendGlobalBarrierReached(); verify(procspy).sendGlobalBarrierReached();
verify(procspy).sendGlobalBarrierComplete(); verify(procspy).sendGlobalBarrierComplete();
verify(procspy, never()).receive(any(ForeignException.class)); verify(procspy, never()).receive(any());
} }
@Test(timeout = 60000) @Test(timeout = 60000)
@ -176,7 +176,7 @@ public class TestProcedure {
procspy.completedProcedure.await(); procspy.completedProcedure.await();
verify(procspy).sendGlobalBarrierReached(); verify(procspy).sendGlobalBarrierReached();
verify(procspy).sendGlobalBarrierComplete(); verify(procspy).sendGlobalBarrierComplete();
verify(procspy, never()).receive(any(ForeignException.class)); verify(procspy, never()).receive(any());
} }
@Test(timeout = 60000) @Test(timeout = 60000)

View File

@ -41,10 +41,10 @@ import java.util.List;
import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.apache.hadoop.hbase.errorhandling.ForeignExceptionDispatcher;
import org.apache.hadoop.hbase.shaded.com.google.common.collect.Lists;
import org.apache.hadoop.hbase.testclassification.MasterTests; import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.testclassification.SmallTests; import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.errorhandling.ForeignException;
import org.apache.hadoop.hbase.errorhandling.ForeignExceptionDispatcher;
import org.junit.After; import org.junit.After;
import org.junit.Test; import org.junit.Test;
import org.junit.experimental.categories.Category; import org.junit.experimental.categories.Category;
@ -52,8 +52,6 @@ import org.mockito.InOrder;
import org.mockito.invocation.InvocationOnMock; import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer; import org.mockito.stubbing.Answer;
import org.apache.hadoop.hbase.shaded.com.google.common.collect.Lists;
/** /**
* Test Procedure coordinator operation. * Test Procedure coordinator operation.
* <p> * <p>
@ -106,7 +104,7 @@ public class TestProcedureCoordinator {
Procedure proc2 = new Procedure(coordinator, monitor, Procedure proc2 = new Procedure(coordinator, monitor,
WAKE_FREQUENCY, TIMEOUT, procName +"2", procData, expected); WAKE_FREQUENCY, TIMEOUT, procName +"2", procData, expected);
Procedure procSpy2 = spy(proc2); Procedure procSpy2 = spy(proc2);
when(coordinator.createProcedure(any(ForeignExceptionDispatcher.class), eq(procName), eq(procData), anyListOf(String.class))) when(coordinator.createProcedure(any(), eq(procName), eq(procData), anyListOf(String.class)))
.thenReturn(procSpy, procSpy2); .thenReturn(procSpy, procSpy2);
coordinator.startProcedure(procSpy.getErrorMonitor(), procName, procData, expected); coordinator.startProcedure(procSpy.getErrorMonitor(), procName, procData, expected);
@ -127,7 +125,7 @@ public class TestProcedureCoordinator {
TIMEOUT, procName, procData, expected); TIMEOUT, procName, procData, expected);
final Procedure procSpy = spy(proc); final Procedure procSpy = spy(proc);
when(coordinator.createProcedure(any(ForeignExceptionDispatcher.class), eq(procName), eq(procData), anyListOf(String.class))) when(coordinator.createProcedure(any(), eq(procName), eq(procData), anyListOf(String.class)))
.thenReturn(procSpy); .thenReturn(procSpy);
// use the passed controller responses // use the passed controller responses
@ -139,10 +137,10 @@ public class TestProcedureCoordinator {
proc = coordinator.startProcedure(proc.getErrorMonitor(), procName, procData, expected); proc = coordinator.startProcedure(proc.getErrorMonitor(), procName, procData, expected);
// and wait for it to finish // and wait for it to finish
while(!proc.completedLatch.await(WAKE_FREQUENCY, TimeUnit.MILLISECONDS)); while(!proc.completedLatch.await(WAKE_FREQUENCY, TimeUnit.MILLISECONDS));
verify(procSpy, atLeastOnce()).receive(any(ForeignException.class)); verify(procSpy, atLeastOnce()).receive(any());
verify(coordinator, times(1)).rpcConnectionFailure(anyString(), eq(cause)); verify(coordinator, times(1)).rpcConnectionFailure(anyString(), eq(cause));
verify(controller, times(1)).sendGlobalBarrierAcquire(procSpy, procData, expected); verify(controller, times(1)).sendGlobalBarrierAcquire(procSpy, procData, expected);
verify(controller, never()).sendGlobalBarrierReached(any(Procedure.class), verify(controller, never()).sendGlobalBarrierReached(any(),
anyListOf(String.class)); anyListOf(String.class));
} }
@ -158,7 +156,7 @@ public class TestProcedureCoordinator {
final Procedure spy = spy(new Procedure(coordinator, final Procedure spy = spy(new Procedure(coordinator,
WAKE_FREQUENCY, TIMEOUT, procName, procData, expected)); WAKE_FREQUENCY, TIMEOUT, procName, procData, expected));
when(coordinator.createProcedure(any(ForeignExceptionDispatcher.class), eq(procName), eq(procData), anyListOf(String.class))) when(coordinator.createProcedure(any(), eq(procName), eq(procData), anyListOf(String.class)))
.thenReturn(spy); .thenReturn(spy);
// use the passed controller responses // use the passed controller responses
@ -171,11 +169,11 @@ public class TestProcedureCoordinator {
Procedure task = coordinator.startProcedure(spy.getErrorMonitor(), procName, procData, expected); Procedure task = coordinator.startProcedure(spy.getErrorMonitor(), procName, procData, expected);
// and wait for it to finish // and wait for it to finish
while(!task.completedLatch.await(WAKE_FREQUENCY, TimeUnit.MILLISECONDS)); while(!task.completedLatch.await(WAKE_FREQUENCY, TimeUnit.MILLISECONDS));
verify(spy, atLeastOnce()).receive(any(ForeignException.class)); verify(spy, atLeastOnce()).receive(any());
verify(coordinator, times(1)).rpcConnectionFailure(anyString(), eq(cause)); verify(coordinator, times(1)).rpcConnectionFailure(anyString(), eq(cause));
verify(controller, times(1)).sendGlobalBarrierAcquire(eq(spy), verify(controller, times(1)).sendGlobalBarrierAcquire(eq(spy),
eq(procData), anyListOf(String.class)); eq(procData), anyListOf(String.class));
verify(controller, times(1)).sendGlobalBarrierReached(any(Procedure.class), verify(controller, times(1)).sendGlobalBarrierReached(any(),
anyListOf(String.class)); anyListOf(String.class));
} }
@ -267,7 +265,7 @@ public class TestProcedureCoordinator {
public void runCoordinatedOperation(Procedure spy, AcquireBarrierAnswer prepareOperation, public void runCoordinatedOperation(Procedure spy, AcquireBarrierAnswer prepareOperation,
BarrierAnswer commitOperation, String... cohort) throws Exception { BarrierAnswer commitOperation, String... cohort) throws Exception {
List<String> expected = Arrays.asList(cohort); List<String> expected = Arrays.asList(cohort);
when(coordinator.createProcedure(any(ForeignExceptionDispatcher.class), eq(procName), eq(procData), anyListOf(String.class))) when(coordinator.createProcedure(any(), eq(procName), eq(procData), anyListOf(String.class)))
.thenReturn(spy); .thenReturn(spy);
// use the passed controller responses // use the passed controller responses

View File

@ -117,7 +117,7 @@ public class TestProcedureMember {
member.receivedReachedGlobalBarrier(op); member.receivedReachedGlobalBarrier(op);
return null; return null;
} }
}).when(mockMemberComms).sendMemberAcquired(any(Subprocedure.class)); }).when(mockMemberComms).sendMemberAcquired(any());
} }
/** /**
@ -147,7 +147,7 @@ public class TestProcedureMember {
order.verify(spy).insideBarrier(); order.verify(spy).insideBarrier();
order.verify(mockMemberComms).sendMemberCompleted(eq(spy), eq(data)); order.verify(mockMemberComms).sendMemberCompleted(eq(spy), eq(data));
order.verify(mockMemberComms, never()).sendMemberAborted(eq(spy), order.verify(mockMemberComms, never()).sendMemberAborted(eq(spy),
any(ForeignException.class)); any());
} }
/** /**
@ -182,8 +182,8 @@ public class TestProcedureMember {
order.verify(spySub, never()).insideBarrier(); order.verify(spySub, never()).insideBarrier();
order.verify(mockMemberComms, never()).sendMemberCompleted(eq(spySub), eq(data)); order.verify(mockMemberComms, never()).sendMemberCompleted(eq(spySub), eq(data));
// error recovery path exercised // error recovery path exercised
order.verify(spySub).cancel(anyString(), any(Exception.class)); order.verify(spySub).cancel(anyString(), any());
order.verify(spySub).cleanup(any(Exception.class)); order.verify(spySub).cleanup(any());
} }
/** /**
@ -200,7 +200,7 @@ public class TestProcedureMember {
public Void answer(InvocationOnMock invocation) throws Throwable { public Void answer(InvocationOnMock invocation) throws Throwable {
throw new IOException("Forced IOException in memeber prepare"); throw new IOException("Forced IOException in memeber prepare");
} }
}).when(mockMemberComms).sendMemberAcquired(any(Subprocedure.class)); }).when(mockMemberComms).sendMemberAcquired(any());
// run the operation // run the operation
// build a new operation // build a new operation
@ -218,8 +218,8 @@ public class TestProcedureMember {
order.verify(spySub, never()).insideBarrier(); order.verify(spySub, never()).insideBarrier();
order.verify(mockMemberComms, never()).sendMemberCompleted(eq(spySub), eq(data)); order.verify(mockMemberComms, never()).sendMemberCompleted(eq(spySub), eq(data));
// error recovery path exercised // error recovery path exercised
order.verify(spySub).cancel(anyString(), any(Exception.class)); order.verify(spySub).cancel(anyString(), any());
order.verify(spySub).cleanup(any(Exception.class)); order.verify(spySub).cleanup(any());
} }
/** /**
@ -261,8 +261,8 @@ public class TestProcedureMember {
order.verify(spySub, never()).insideBarrier(); order.verify(spySub, never()).insideBarrier();
order.verify(mockMemberComms, never()).sendMemberCompleted(eq(spySub), eq(data)); order.verify(mockMemberComms, never()).sendMemberCompleted(eq(spySub), eq(data));
// error recovery path exercised // error recovery path exercised
order.verify(spySub).cancel(anyString(), any(Exception.class)); order.verify(spySub).cancel(anyString(), any());
order.verify(spySub).cleanup(any(Exception.class)); order.verify(spySub).cleanup(any());
} }
/** /**
@ -302,8 +302,8 @@ public class TestProcedureMember {
// Later phases not run // Later phases not run
order.verify(mockMemberComms, never()).sendMemberCompleted(eq(spySub), eq(data)); order.verify(mockMemberComms, never()).sendMemberCompleted(eq(spySub), eq(data));
// error recovery path exercised // error recovery path exercised
order.verify(spySub).cancel(anyString(), any(Exception.class)); order.verify(spySub).cancel(anyString(), any());
order.verify(spySub).cleanup(any(Exception.class)); order.verify(spySub).cleanup(any());
} }
/** /**
@ -328,7 +328,7 @@ public class TestProcedureMember {
Thread.sleep(WAKE_FREQUENCY); Thread.sleep(WAKE_FREQUENCY);
return null; return null;
} }
}).when(mockMemberComms).sendMemberCompleted(any(Subprocedure.class), eq(data)); }).when(mockMemberComms).sendMemberCompleted(any(), eq(data));
// run the operation // run the operation
// build a new operation // build a new operation
@ -344,8 +344,8 @@ public class TestProcedureMember {
order.verify(spySub).insideBarrier(); order.verify(spySub).insideBarrier();
order.verify(mockMemberComms).sendMemberCompleted(eq(spySub), eq(data)); order.verify(mockMemberComms).sendMemberCompleted(eq(spySub), eq(data));
// error recovery path exercised // error recovery path exercised
order.verify(spySub).cancel(anyString(), any(Exception.class)); order.verify(spySub).cancel(anyString(), any());
order.verify(spySub).cleanup(any(Exception.class)); order.verify(spySub).cleanup(any());
} }
/** /**
@ -369,7 +369,7 @@ public class TestProcedureMember {
doThrow(new ForeignException("SRC", "prepare exception")).when(spy).acquireBarrier(); doThrow(new ForeignException("SRC", "prepare exception")).when(spy).acquireBarrier();
// and throw a connection error when we try to tell the controller about it // and throw a connection error when we try to tell the controller about it
doThrow(new IOException("Controller is down!")).when(mockMemberComms) doThrow(new IOException("Controller is down!")).when(mockMemberComms)
.sendMemberAborted(eq(spy), any(ForeignException.class)); .sendMemberAborted(eq(spy), any());
// run the operation // run the operation
@ -388,9 +388,9 @@ public class TestProcedureMember {
// TODO Need to do another refactor to get this to propagate to the coordinator. // TODO Need to do another refactor to get this to propagate to the coordinator.
// make sure we pass a remote exception back the controller // make sure we pass a remote exception back the controller
// order.verify(mockMemberComms).sendMemberAborted(eq(spy), // order.verify(mockMemberComms).sendMemberAborted(eq(spy),
// any(ExternalException.class)); // any());
// order.verify(dispSpy).receiveError(anyString(), // order.verify(dispSpy).receiveError(anyString(),
// any(ExternalException.class), any()); // any(), any());
} }
/** /**
@ -427,7 +427,7 @@ public class TestProcedureMember {
verifyZeroInteractions(pool); verifyZeroInteractions(pool);
// get two abort requests // get two abort requests
// TODO Need to do another refactor to get this to propagate to the coordinator. // TODO Need to do another refactor to get this to propagate to the coordinator.
// verify(mockMemberComms, times(2)).sendMemberAborted(any(Subprocedure.class), any(ExternalException.class)); // verify(mockMemberComms, times(2)).sendMemberAborted(any(), any());
} }
/** /**

View File

@ -284,7 +284,7 @@ public class TestZKProcedure {
Procedure coordinatorTask = Mockito.spy(new Procedure(coordinator, Procedure coordinatorTask = Mockito.spy(new Procedure(coordinator,
coordinatorTaskErrorMonitor, WAKE_FREQUENCY, TIMEOUT, coordinatorTaskErrorMonitor, WAKE_FREQUENCY, TIMEOUT,
opName, data, expected)); opName, data, expected));
when(coordinator.createProcedure(any(ForeignExceptionDispatcher.class), eq(opName), eq(data), anyListOf(String.class))) when(coordinator.createProcedure(any(), eq(opName), eq(data), anyListOf(String.class)))
.thenReturn(coordinatorTask); .thenReturn(coordinatorTask);
// count down the error latch when we get the remote error // count down the error latch when we get the remote error
Mockito.doAnswer(new Answer<Void>() { Mockito.doAnswer(new Answer<Void>() {
@ -296,7 +296,7 @@ public class TestZKProcedure {
coordinatorReceivedErrorLatch.countDown(); coordinatorReceivedErrorLatch.countDown();
return null; return null;
} }
}).when(coordinatorTask).receive(Mockito.any(ForeignException.class)); }).when(coordinatorTask).receive(Mockito.any());
// ---------------------------- // ----------------------------
// start running the operation // start running the operation

View File

@ -31,7 +31,6 @@ import java.util.concurrent.CountDownLatch;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.errorhandling.ForeignException;
import org.apache.hadoop.hbase.errorhandling.ForeignExceptionDispatcher; import org.apache.hadoop.hbase.errorhandling.ForeignExceptionDispatcher;
import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil; import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;
import org.apache.hadoop.hbase.testclassification.MasterTests; import org.apache.hadoop.hbase.testclassification.MasterTests;
@ -131,10 +130,10 @@ public class TestZKProcedureControllers {
LOG.debug("Commit node:" + commit + ", exists:" + ZKUtil.checkExists(watcher, commit)); LOG.debug("Commit node:" + commit + ", exists:" + ZKUtil.checkExists(watcher, commit));
committed.await(); committed.await();
verify(monitor, never()).receive(Mockito.any(ForeignException.class)); verify(monitor, never()).receive(Mockito.any());
// XXX: broken due to composition. // XXX: broken due to composition.
// verify(member, never()).getManager().controllerConnectionFailure(Mockito.anyString(), // verify(member, never()).getManager().controllerConnectionFailure(Mockito.anyString(),
// Mockito.any(IOException.class)); // Mockito.any());
// cleanup after the test // cleanup after the test
ZKUtil.deleteNodeRecursively(watcher, controller.getZkController().getBaseZnode()); ZKUtil.deleteNodeRecursively(watcher, controller.getZkController().getBaseZnode());
assertEquals("Didn't delete prepare node", -1, ZKUtil.checkExists(watcher, prepare)); assertEquals("Didn't delete prepare node", -1, ZKUtil.checkExists(watcher, prepare));
@ -363,7 +362,7 @@ public class TestZKProcedureControllers {
// verify(member, Mockito.times(cohortSize)).submitSubprocedure(Mockito.eq(operationName), // verify(member, Mockito.times(cohortSize)).submitSubprocedure(Mockito.eq(operationName),
// (byte[]) Mockito.argThat(new ArrayEquals(data))); // (byte[]) Mockito.argThat(new ArrayEquals(data)));
Mockito.verify(member, Mockito.verify(member,
Mockito.atLeast(cohortSize)).submitSubprocedure(Mockito.any(Subprocedure.class)); Mockito.atLeast(cohortSize)).submitSubprocedure(Mockito.any());
} }

View File

@ -61,7 +61,7 @@ public class TestFileSystemUtilizationChore {
final FileSystemUtilizationChore chore = new FileSystemUtilizationChore(rs); final FileSystemUtilizationChore chore = new FileSystemUtilizationChore(rs);
doAnswer(new ExpectedRegionSizeSummationAnswer(sum(regionSizes))) doAnswer(new ExpectedRegionSizeSummationAnswer(sum(regionSizes)))
.when(rs) .when(rs)
.reportRegionSizesForQuotas((Map<RegionInfo,Long>) any(Map.class)); .reportRegionSizesForQuotas((Map<RegionInfo,Long>) any());
final Region region = mockRegionWithSize(regionSizes); final Region region = mockRegionWithSize(regionSizes);
Mockito.doReturn(Arrays.asList(region)).when(rs).getRegions(); Mockito.doReturn(Arrays.asList(region)).when(rs).getRegions();
@ -78,7 +78,7 @@ public class TestFileSystemUtilizationChore {
final FileSystemUtilizationChore chore = new FileSystemUtilizationChore(rs); final FileSystemUtilizationChore chore = new FileSystemUtilizationChore(rs);
doAnswer(new ExpectedRegionSizeSummationAnswer(sum(regionSizes))) doAnswer(new ExpectedRegionSizeSummationAnswer(sum(regionSizes)))
.when(rs) .when(rs)
.reportRegionSizesForQuotas((Map<RegionInfo,Long>) any(Map.class)); .reportRegionSizesForQuotas((Map<RegionInfo,Long>) any());
final Region region = mockRegionWithSize(regionSizes); final Region region = mockRegionWithSize(regionSizes);
Mockito.doReturn(Arrays.asList(region)).when(rs).getRegions(); Mockito.doReturn(Arrays.asList(region)).when(rs).getRegions();
@ -102,7 +102,7 @@ public class TestFileSystemUtilizationChore {
final FileSystemUtilizationChore chore = new FileSystemUtilizationChore(rs); final FileSystemUtilizationChore chore = new FileSystemUtilizationChore(rs);
doAnswer(new ExpectedRegionSizeSummationAnswer(sum(Arrays.asList(r1Sum, r2Sum, r3Sum)))) doAnswer(new ExpectedRegionSizeSummationAnswer(sum(Arrays.asList(r1Sum, r2Sum, r3Sum))))
.when(rs) .when(rs)
.reportRegionSizesForQuotas((Map<RegionInfo,Long>) any(Map.class)); .reportRegionSizesForQuotas((Map<RegionInfo,Long>) any());
final Region r1 = mockRegionWithSize(r1Sizes); final Region r1 = mockRegionWithSize(r1Sizes);
final Region r2 = mockRegionWithSize(r2Sizes); final Region r2 = mockRegionWithSize(r2Sizes);
@ -167,7 +167,7 @@ public class TestFileSystemUtilizationChore {
}; };
doAnswer(new ExpectedRegionSizeSummationAnswer(sum(Arrays.asList(leftover1Sum, leftover2Sum)))) doAnswer(new ExpectedRegionSizeSummationAnswer(sum(Arrays.asList(leftover1Sum, leftover2Sum))))
.when(rs) .when(rs)
.reportRegionSizesForQuotas((Map<RegionInfo,Long>) any(Map.class)); .reportRegionSizesForQuotas((Map<RegionInfo,Long>) any());
// We shouldn't compute all of these region sizes, just the leftovers // We shouldn't compute all of these region sizes, just the leftovers
final Region r1 = mockRegionWithSize(Arrays.asList(1024L, 2048L)); final Region r1 = mockRegionWithSize(Arrays.asList(1024L, 2048L));
@ -199,7 +199,7 @@ public class TestFileSystemUtilizationChore {
}; };
doAnswer(new ExpectedRegionSizeSummationAnswer(sum(Arrays.asList(leftover1Sum)))) doAnswer(new ExpectedRegionSizeSummationAnswer(sum(Arrays.asList(leftover1Sum))))
.when(rs) .when(rs)
.reportRegionSizesForQuotas((Map<RegionInfo,Long>) any(Map.class)); .reportRegionSizesForQuotas((Map<RegionInfo,Long>) any());
// We shouldn't compute all of these region sizes, just the leftovers // We shouldn't compute all of these region sizes, just the leftovers
final Region r1 = mockRegionWithSize(Arrays.asList(1024L, 2048L)); final Region r1 = mockRegionWithSize(Arrays.asList(1024L, 2048L));
@ -225,7 +225,7 @@ public class TestFileSystemUtilizationChore {
final FileSystemUtilizationChore chore = new FileSystemUtilizationChore(rs); final FileSystemUtilizationChore chore = new FileSystemUtilizationChore(rs);
doAnswer(new ExpectedRegionSizeSummationAnswer(sum(Arrays.asList(r1Sum)))) doAnswer(new ExpectedRegionSizeSummationAnswer(sum(Arrays.asList(r1Sum))))
.when(rs) .when(rs)
.reportRegionSizesForQuotas((Map<RegionInfo,Long>) any(Map.class)); .reportRegionSizesForQuotas((Map<RegionInfo,Long>) any());
final Region r1 = mockRegionWithSize(r1Sizes); final Region r1 = mockRegionWithSize(r1Sizes);
final Region r2 = mockSplitParentRegionWithSize(r2Sizes); final Region r2 = mockSplitParentRegionWithSize(r2Sizes);
@ -247,7 +247,7 @@ public class TestFileSystemUtilizationChore {
final FileSystemUtilizationChore chore = new FileSystemUtilizationChore(rs); final FileSystemUtilizationChore chore = new FileSystemUtilizationChore(rs);
doAnswer(new ExpectedRegionSizeSummationAnswer(r1Sum)) doAnswer(new ExpectedRegionSizeSummationAnswer(r1Sum))
.when(rs) .when(rs)
.reportRegionSizesForQuotas((Map<RegionInfo,Long>) any(Map.class)); .reportRegionSizesForQuotas((Map<RegionInfo,Long>) any());
final Region r1 = mockRegionWithSize(r1Sizes); final Region r1 = mockRegionWithSize(r1Sizes);
final Region r2 = mockRegionReplicaWithSize(r2Sizes); final Region r2 = mockRegionReplicaWithSize(r2Sizes);
@ -274,7 +274,7 @@ public class TestFileSystemUtilizationChore {
final FileSystemUtilizationChore chore = new FileSystemUtilizationChore(rs); final FileSystemUtilizationChore chore = new FileSystemUtilizationChore(rs);
doAnswer(new ExpectedRegionSizeSummationAnswer( doAnswer(new ExpectedRegionSizeSummationAnswer(
sum(Arrays.asList(r1HFileSizeSum, r2HFileSizeSum)))) sum(Arrays.asList(r1HFileSizeSum, r2HFileSizeSum))))
.when(rs).reportRegionSizesForQuotas((Map<RegionInfo,Long>) any(Map.class)); .when(rs).reportRegionSizesForQuotas((Map<RegionInfo,Long>) any());
final Region r1 = mockRegionWithHFileLinks(r1StoreFileSizes, r1HFileSizes); final Region r1 = mockRegionWithHFileLinks(r1StoreFileSizes, r1HFileSizes);
final Region r2 = mockRegionWithHFileLinks(r2StoreFileSizes, r2HFileSizes); final Region r2 = mockRegionWithHFileLinks(r2StoreFileSizes, r2HFileSizes);

View File

@ -51,7 +51,7 @@ public class TestMasterSpaceQuotaObserverWithMocks {
conf = HBaseConfiguration.create(); conf = HBaseConfiguration.create();
master = mock(HMaster.class); master = mock(HMaster.class);
doCallRealMethod().when(master).updateConfigurationForSpaceQuotaObserver( doCallRealMethod().when(master).updateConfigurationForSpaceQuotaObserver(
any(Configuration.class)); any());
} }
@Test @Test

View File

@ -73,7 +73,7 @@ public class TestNamespaceQuotaViolationStore {
@Test @Test
public void testGetSpaceQuota() throws Exception { public void testGetSpaceQuota() throws Exception {
NamespaceQuotaSnapshotStore mockStore = mock(NamespaceQuotaSnapshotStore.class); NamespaceQuotaSnapshotStore mockStore = mock(NamespaceQuotaSnapshotStore.class);
when(mockStore.getSpaceQuota(any(String.class))).thenCallRealMethod(); when(mockStore.getSpaceQuota(any())).thenCallRealMethod();
Quotas quotaWithSpace = Quotas.newBuilder().setSpace( Quotas quotaWithSpace = Quotas.newBuilder().setSpace(
SpaceQuota.newBuilder() SpaceQuota.newBuilder()
@ -84,7 +84,7 @@ public class TestNamespaceQuotaViolationStore {
Quotas quotaWithoutSpace = Quotas.newBuilder().build(); Quotas quotaWithoutSpace = Quotas.newBuilder().build();
AtomicReference<Quotas> quotaRef = new AtomicReference<>(); AtomicReference<Quotas> quotaRef = new AtomicReference<>();
when(mockStore.getQuotaForNamespace(any(String.class))).then(new Answer<Quotas>() { when(mockStore.getQuotaForNamespace(any())).then(new Answer<Quotas>() {
@Override @Override
public Quotas answer(InvocationOnMock invocation) throws Throwable { public Quotas answer(InvocationOnMock invocation) throws Throwable {
return quotaRef.get(); return quotaRef.get();

View File

@ -77,8 +77,8 @@ public class TestSpaceQuotaViolationPolicyRefresherChore {
when(chore.getConnection()).thenReturn(conn); when(chore.getConnection()).thenReturn(conn);
when(chore.getManager()).thenReturn(manager); when(chore.getManager()).thenReturn(manager);
doCallRealMethod().when(chore).chore(); doCallRealMethod().when(chore).chore();
when(chore.isInViolation(any(SpaceQuotaSnapshot.class))).thenCallRealMethod(); when(chore.isInViolation(any())).thenCallRealMethod();
doCallRealMethod().when(chore).extractQuotaSnapshot(any(Result.class), any(Map.class)); doCallRealMethod().when(chore).extractQuotaSnapshot(any(), any());
} }
@Test @Test

View File

@ -165,7 +165,7 @@ public class TestTableQuotaViolationStore {
@Test @Test
public void testGetSpaceQuota() throws Exception { public void testGetSpaceQuota() throws Exception {
TableQuotaSnapshotStore mockStore = mock(TableQuotaSnapshotStore.class); TableQuotaSnapshotStore mockStore = mock(TableQuotaSnapshotStore.class);
when(mockStore.getSpaceQuota(any(TableName.class))).thenCallRealMethod(); when(mockStore.getSpaceQuota(any())).thenCallRealMethod();
Quotas quotaWithSpace = Quotas.newBuilder().setSpace( Quotas quotaWithSpace = Quotas.newBuilder().setSpace(
SpaceQuota.newBuilder() SpaceQuota.newBuilder()
@ -176,7 +176,7 @@ public class TestTableQuotaViolationStore {
Quotas quotaWithoutSpace = Quotas.newBuilder().build(); Quotas quotaWithoutSpace = Quotas.newBuilder().build();
AtomicReference<Quotas> quotaRef = new AtomicReference<>(); AtomicReference<Quotas> quotaRef = new AtomicReference<>();
when(mockStore.getQuotaForTable(any(TableName.class))).then(new Answer<Quotas>() { when(mockStore.getQuotaForTable(any())).then(new Answer<Quotas>() {
@Override @Override
public Quotas answer(InvocationOnMock invocation) throws Throwable { public Quotas answer(InvocationOnMock invocation) throws Throwable {
return quotaRef.get(); return quotaRef.get();

View File

@ -77,22 +77,13 @@ public class TestTableSpaceQuotaViolationNotifier {
notifier.transitionTable(tn, snapshot); notifier.transitionTable(tn, snapshot);
verify(quotaTable).put(argThat(new SingleCellPutMatcher(expectedPut))); verify(quotaTable).put(argThat(new SingleCellMutationMatcher<Put>(expectedPut)));
}
/**
* Parameterized for Puts.
*/
private static class SingleCellPutMatcher extends SingleCellMutationMatcher<Put> {
private SingleCellPutMatcher(Put expected) {
super(expected);
}
} }
/** /**
* Quick hack to verify a Mutation with one column. * Quick hack to verify a Mutation with one column.
*/ */
private static class SingleCellMutationMatcher<T> extends ArgumentMatcher<T> { final private static class SingleCellMutationMatcher<T> implements ArgumentMatcher<T> {
private final Mutation expected; private final Mutation expected;
private SingleCellMutationMatcher(Mutation expected) { private SingleCellMutationMatcher(Mutation expected) {
@ -100,7 +91,7 @@ public class TestTableSpaceQuotaViolationNotifier {
} }
@Override @Override
public boolean matches(Object argument) { public boolean matches(T argument) {
if (!expected.getClass().isAssignableFrom(argument.getClass())) { if (!expected.getClass().isAssignableFrom(argument.getClass())) {
return false; return false;
} }

View File

@ -18,8 +18,8 @@
*/ */
package org.apache.hadoop.hbase.regionserver; package org.apache.hadoop.hbase.regionserver;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Matchers.any; import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
@ -27,8 +27,6 @@ import static org.mockito.Mockito.when;
import java.util.Optional; import java.util.Optional;
import org.apache.hadoop.hbase.regionserver.compactions.CompactionContext; import org.apache.hadoop.hbase.regionserver.compactions.CompactionContext;
import org.apache.hadoop.hbase.regionserver.compactions.CompactionLifeCycleTracker;
import org.apache.hadoop.hbase.security.User;
import org.mockito.invocation.InvocationOnMock; import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer; import org.mockito.stubbing.Answer;
@ -42,37 +40,23 @@ public class StatefulStoreMockMaker {
return Optional.empty(); return Optional.empty();
} }
public void cancelCompaction(Object originalContext) { public void cancelCompaction(Object originalContext) {}
}
public int getPriority() { public int getPriority() {
return 0; return 0;
} }
private class SelectAnswer implements Answer<Optional<CompactionContext>> {
public Optional<CompactionContext> answer(InvocationOnMock invocation) throws Throwable {
return selectCompaction();
}
}
private class PriorityAnswer implements Answer<Integer> {
public Integer answer(InvocationOnMock invocation) throws Throwable {
return getPriority();
}
}
private class CancelAnswer implements Answer<Object> { private class CancelAnswer implements Answer<Object> {
public CompactionContext answer(InvocationOnMock invocation) throws Throwable { public CompactionContext answer(InvocationOnMock invocation) throws Throwable {
cancelCompaction(invocation.getArguments()[0]); return null; cancelCompaction(invocation.getArgument(0));
return null;
} }
} }
public HStore createStoreMock(String name) throws Exception { public HStore createStoreMock(String name) throws Exception {
HStore store = mock(HStore.class, name); HStore store = mock(HStore.class, name);
when(store.requestCompaction(anyInt(), any(CompactionLifeCycleTracker.class), any(User.class))) when(store.requestCompaction(anyInt(), any(), any())).then(inv -> selectCompaction());
.then(new SelectAnswer()); when(store.getCompactPriority()).then(inv -> getPriority());
when(store.getCompactPriority()).then(new PriorityAnswer()); doAnswer(new CancelAnswer()).when(store).cancelRequestedCompaction(any());
doAnswer(new CancelAnswer()).when(store)
.cancelRequestedCompaction(any(CompactionContext.class));
return store; return store;
} }
} }

View File

@ -22,6 +22,13 @@ import static java.util.Arrays.asList;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.hamcrest.MockitoHamcrest.argThat;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
@ -31,7 +38,6 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataOutputStream; import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.Path;
@ -55,17 +61,6 @@ import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.Pair; import org.apache.hadoop.hbase.util.Pair;
import org.apache.hadoop.hbase.wal.WAL; import org.apache.hadoop.hbase.wal.WAL;
import org.apache.hadoop.hbase.wal.WALKey; import org.apache.hadoop.hbase.wal.WALKey;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;
import static org.mockito.Matchers.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.junit.Before; import org.junit.Before;
import org.junit.ClassRule; import org.junit.ClassRule;
import org.junit.Rule; import org.junit.Rule;
@ -73,6 +68,11 @@ import org.junit.Test;
import org.junit.experimental.categories.Category; import org.junit.experimental.categories.Category;
import org.junit.rules.TemporaryFolder; import org.junit.rules.TemporaryFolder;
import org.junit.rules.TestName; import org.junit.rules.TestName;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
/** /**
* This class attempts to unit test bulk HLog loading. * This class attempts to unit test bulk HLog loading.
@ -108,19 +108,19 @@ public class TestBulkLoad {
storeFileName = (new Path(storeFileName)).getName(); storeFileName = (new Path(storeFileName)).getName();
List<String> storeFileNames = new ArrayList<>(); List<String> storeFileNames = new ArrayList<>();
storeFileNames.add(storeFileName); storeFileNames.add(storeFileName);
when(log.append(any(HRegionInfo.class), any(WALKey.class), when(log.append(any(), any(),
argThat(bulkLogWalEdit(WALEdit.BULK_LOAD, tableName.toBytes(), argThat(bulkLogWalEdit(WALEdit.BULK_LOAD, tableName.toBytes(),
familyName, storeFileNames)), familyName, storeFileNames)),
any(boolean.class))).thenAnswer(new Answer() { anyBoolean())).thenAnswer(new Answer() {
public Object answer(InvocationOnMock invocation) { public Object answer(InvocationOnMock invocation) {
WALKey walKey = invocation.getArgumentAt(1, WALKey.class); WALKey walKey = invocation.getArgument(1);
MultiVersionConcurrencyControl mvcc = walKey.getMvcc(); MultiVersionConcurrencyControl mvcc = walKey.getMvcc();
if (mvcc != null) { if (mvcc != null) {
MultiVersionConcurrencyControl.WriteEntry we = mvcc.begin(); MultiVersionConcurrencyControl.WriteEntry we = mvcc.begin();
walKey.setWriteEntry(we); walKey.setWriteEntry(we);
} }
return 01L; return 01L;
}; };
}); });
testRegionWithFamiliesAndSpecifiedTableName(tableName, family1) testRegionWithFamiliesAndSpecifiedTableName(tableName, family1)
.bulkLoadHFiles(familyPaths, false, null); .bulkLoadHFiles(familyPaths, false, null);
@ -134,18 +134,18 @@ public class TestBulkLoad {
@Test @Test
public void shouldBulkLoadSingleFamilyHLog() throws IOException { public void shouldBulkLoadSingleFamilyHLog() throws IOException {
when(log.append(any(HRegionInfo.class), when(log.append(any(),
any(WALKey.class), argThat(bulkLogWalEditType(WALEdit.BULK_LOAD)), any(), argThat(bulkLogWalEditType(WALEdit.BULK_LOAD)),
any(boolean.class))).thenAnswer(new Answer() { anyBoolean())).thenAnswer(new Answer() {
public Object answer(InvocationOnMock invocation) { public Object answer(InvocationOnMock invocation) {
WALKey walKey = invocation.getArgumentAt(1, WALKey.class); WALKey walKey = invocation.getArgument(1);
MultiVersionConcurrencyControl mvcc = walKey.getMvcc(); MultiVersionConcurrencyControl mvcc = walKey.getMvcc();
if (mvcc != null) { if (mvcc != null) {
MultiVersionConcurrencyControl.WriteEntry we = mvcc.begin(); MultiVersionConcurrencyControl.WriteEntry we = mvcc.begin();
walKey.setWriteEntry(we); walKey.setWriteEntry(we);
} }
return 01L; return 01L;
}; };
}); });
testRegionWithFamilies(family1).bulkLoadHFiles(withFamilyPathsFor(family1), false, null); testRegionWithFamilies(family1).bulkLoadHFiles(withFamilyPathsFor(family1), false, null);
verify(log).sync(anyLong()); verify(log).sync(anyLong());
@ -153,11 +153,11 @@ public class TestBulkLoad {
@Test @Test
public void shouldBulkLoadManyFamilyHLog() throws IOException { public void shouldBulkLoadManyFamilyHLog() throws IOException {
when(log.append(any(HRegionInfo.class), when(log.append(any(),
any(WALKey.class), argThat(bulkLogWalEditType(WALEdit.BULK_LOAD)), any(), argThat(bulkLogWalEditType(WALEdit.BULK_LOAD)),
any(boolean.class))).thenAnswer(new Answer() { anyBoolean())).thenAnswer(new Answer() {
public Object answer(InvocationOnMock invocation) { public Object answer(InvocationOnMock invocation) {
WALKey walKey = invocation.getArgumentAt(1, WALKey.class); WALKey walKey = invocation.getArgument(1);
MultiVersionConcurrencyControl mvcc = walKey.getMvcc(); MultiVersionConcurrencyControl mvcc = walKey.getMvcc();
if (mvcc != null) { if (mvcc != null) {
MultiVersionConcurrencyControl.WriteEntry we = mvcc.begin(); MultiVersionConcurrencyControl.WriteEntry we = mvcc.begin();
@ -173,18 +173,18 @@ public class TestBulkLoad {
@Test @Test
public void shouldBulkLoadManyFamilyHLogEvenWhenTableNameNamespaceSpecified() throws IOException { public void shouldBulkLoadManyFamilyHLogEvenWhenTableNameNamespaceSpecified() throws IOException {
when(log.append(any(HRegionInfo.class), when(log.append(any(),
any(WALKey.class), argThat(bulkLogWalEditType(WALEdit.BULK_LOAD)), any(), argThat(bulkLogWalEditType(WALEdit.BULK_LOAD)),
any(boolean.class))).thenAnswer(new Answer() { anyBoolean())).thenAnswer(new Answer() {
public Object answer(InvocationOnMock invocation) { public Object answer(InvocationOnMock invocation) {
WALKey walKey = invocation.getArgumentAt(1, WALKey.class); WALKey walKey = invocation.getArgument(1);
MultiVersionConcurrencyControl mvcc = walKey.getMvcc(); MultiVersionConcurrencyControl mvcc = walKey.getMvcc();
if (mvcc != null) { if (mvcc != null) {
MultiVersionConcurrencyControl.WriteEntry we = mvcc.begin(); MultiVersionConcurrencyControl.WriteEntry we = mvcc.begin();
walKey.setWriteEntry(we); walKey.setWriteEntry(we);
} }
return 01L; return 01L;
}; };
}); });
TableName tableName = TableName.valueOf("test", "test"); TableName tableName = TableName.valueOf("test", "test");
testRegionWithFamiliesAndSpecifiedTableName(tableName, family1, family2) testRegionWithFamiliesAndSpecifiedTableName(tableName, family1, family2)

View File

@ -387,7 +387,7 @@ public class TestCompaction {
thread.interruptIfNecessary(); thread.interruptIfNecessary();
} }
private class StoreMockMaker extends StatefulStoreMockMaker { class StoreMockMaker extends StatefulStoreMockMaker {
public ArrayList<HStoreFile> compacting = new ArrayList<>(); public ArrayList<HStoreFile> compacting = new ArrayList<>();
public ArrayList<HStoreFile> notCompacting = new ArrayList<>(); public ArrayList<HStoreFile> notCompacting = new ArrayList<>();
private ArrayList<Integer> results; private ArrayList<Integer> results;
@ -556,20 +556,19 @@ public class TestCompaction {
// Set up the region mock that redirects compactions. // Set up the region mock that redirects compactions.
HRegion r = mock(HRegion.class); HRegion r = mock(HRegion.class);
when( when(
r.compact(any(CompactionContext.class), any(HStore.class), r.compact(any(), any(), any(), any())).then(new Answer<Boolean>() {
any(ThroughputController.class), any(User.class))).then(new Answer<Boolean>() { @Override
@Override public Boolean answer(InvocationOnMock invocation) throws Throwable {
public Boolean answer(InvocationOnMock invocation) throws Throwable { invocation.<CompactionContext>getArgument(0).compact(invocation.getArgument(2), null);
invocation.getArgumentAt(0, CompactionContext.class).compact( return true;
invocation.getArgumentAt(2, ThroughputController.class), null); }
return true;
}
}); });
// Set up store mocks for 2 "real" stores and the one we use for blocking CST. // Set up store mocks for 2 "real" stores and the one we use for blocking CST.
ArrayList<Integer> results = new ArrayList<>(); ArrayList<Integer> results = new ArrayList<>();
StoreMockMaker sm = new StoreMockMaker(results), sm2 = new StoreMockMaker(results); StoreMockMaker sm = new StoreMockMaker(results), sm2 = new StoreMockMaker(results);
HStore store = sm.createStoreMock("store1"), store2 = sm2.createStoreMock("store2"); HStore store = sm.createStoreMock("store1");
HStore store2 = sm2.createStoreMock("store2");
BlockingStoreMockMaker blocker = new BlockingStoreMockMaker(); BlockingStoreMockMaker blocker = new BlockingStoreMockMaker();
// First, block the compaction thread so that we could muck with queue. // First, block the compaction thread so that we could muck with queue.

View File

@ -186,7 +186,7 @@ public class TestCompactionArchiveIOException {
// none of the other files are cleared from the compactedfiles list. // none of the other files are cleared from the compactedfiles list.
// Simulate this condition with a dummy file // Simulate this condition with a dummy file
doThrow(new IOException("Error for test")) doThrow(new IOException("Error for test"))
.when(errFS).rename(eq(new Path(storeDir, ERROR_FILE)), any(Path.class)); .when(errFS).rename(eq(new Path(storeDir, ERROR_FILE)), any());
HRegionFileSystem fs = new HRegionFileSystem(conf, errFS, tableDir, info); HRegionFileSystem fs = new HRegionFileSystem(conf, errFS, tableDir, info);
final Configuration walConf = new Configuration(conf); final Configuration walConf = new Configuration(conf);

View File

@ -1104,19 +1104,19 @@ public class TestHRegion {
} }
} }
class IsFlushWALMarker extends ArgumentMatcher<WALEdit> { class IsFlushWALMarker implements ArgumentMatcher<WALEdit> {
volatile FlushAction[] actions; volatile FlushAction[] actions;
public IsFlushWALMarker(FlushAction... actions) { public IsFlushWALMarker(FlushAction... actions) {
this.actions = actions; this.actions = actions;
} }
@Override @Override
public boolean matches(Object edit) { public boolean matches(WALEdit edit) {
List<Cell> cells = ((WALEdit)edit).getCells(); List<Cell> cells = edit.getCells();
if (cells.isEmpty()) { if (cells.isEmpty()) {
return false; return false;
} }
if (WALEdit.isMetaEditFamily(cells.get(0))) { if (WALEdit.isMetaEditFamily(cells.get(0))) {
FlushDescriptor desc = null; FlushDescriptor desc;
try { try {
desc = WALEdit.getFlushDescriptor(cells.get(0)); desc = WALEdit.getFlushDescriptor(cells.get(0));
} catch (IOException e) { } catch (IOException e) {
@ -2441,8 +2441,7 @@ public class TestHRegion {
Mockito.doAnswer(new Answer() { Mockito.doAnswer(new Answer() {
@Override @Override
public Object answer(InvocationOnMock invocation) throws Throwable { public Object answer(InvocationOnMock invocation) throws Throwable {
MiniBatchOperationInProgress<Mutation> mb = invocation.getArgumentAt(0, MiniBatchOperationInProgress<Mutation> mb = invocation.getArgument(0);
MiniBatchOperationInProgress.class);
mb.addOperationsFromCP(0, new Mutation[]{addPut}); mb.addOperationsFromCP(0, new Mutation[]{addPut});
return null; return null;
} }
@ -5960,7 +5959,7 @@ public class TestHRegion {
thenAnswer(new Answer<Long>() { thenAnswer(new Answer<Long>() {
@Override @Override
public Long answer(InvocationOnMock invocation) throws Throwable { public Long answer(InvocationOnMock invocation) throws Throwable {
WALKey key = invocation.getArgumentAt(1, WALKey.class); WALKey key = invocation.getArgument(1);
MultiVersionConcurrencyControl.WriteEntry we = key.getMvcc().begin(); MultiVersionConcurrencyControl.WriteEntry we = key.getMvcc().begin();
key.setWriteEntry(we); key.setWriteEntry(we);
return 1L; return 1L;

View File

@ -1026,7 +1026,7 @@ public class TestHStore {
// call first time after files changed // call first time after files changed
spiedStore.refreshStoreFiles(); spiedStore.refreshStoreFiles();
assertEquals(2, this.store.getStorefilesCount()); assertEquals(2, this.store.getStorefilesCount());
verify(spiedStore, times(1)).replaceStoreFiles(any(Collection.class), any(Collection.class)); verify(spiedStore, times(1)).replaceStoreFiles(any(), any());
// call second time // call second time
spiedStore.refreshStoreFiles(); spiedStore.refreshStoreFiles();

View File

@ -69,8 +69,8 @@ public class TestRegionServerRegionSpaceUseReport {
// Call the real method to convert the map into a protobuf // Call the real method to convert the map into a protobuf
HRegionServer rs = mock(HRegionServer.class); HRegionServer rs = mock(HRegionServer.class);
doCallRealMethod().when(rs).buildRegionSpaceUseReportRequest(any(Map.class)); doCallRealMethod().when(rs).buildRegionSpaceUseReportRequest(any());
doCallRealMethod().when(rs).convertRegionSize(any(RegionInfo.class), anyLong()); doCallRealMethod().when(rs).convertRegionSize(any(), anyLong());
RegionSpaceUseReportRequest requests = rs.buildRegionSpaceUseReportRequest(sizes); RegionSpaceUseReportRequest requests = rs.buildRegionSpaceUseReportRequest(sizes);
assertEquals(sizes.size(), requests.getSpaceUseCount()); assertEquals(sizes.size(), requests.getSpaceUseCount());
@ -87,8 +87,8 @@ public class TestRegionServerRegionSpaceUseReport {
public void testNullMap() { public void testNullMap() {
// Call the real method to convert the map into a protobuf // Call the real method to convert the map into a protobuf
HRegionServer rs = mock(HRegionServer.class); HRegionServer rs = mock(HRegionServer.class);
doCallRealMethod().when(rs).buildRegionSpaceUseReportRequest(any(Map.class)); doCallRealMethod().when(rs).buildRegionSpaceUseReportRequest(any());
doCallRealMethod().when(rs).convertRegionSize(any(RegionInfo.class), anyLong()); doCallRealMethod().when(rs).convertRegionSize(any(), anyLong());
rs.buildRegionSpaceUseReportRequest(null); rs.buildRegionSpaceUseReportRequest(null);
} }
@ -105,8 +105,8 @@ public class TestRegionServerRegionSpaceUseReport {
// Call the real method to convert the map into a protobuf // Call the real method to convert the map into a protobuf
HRegionServer rs = mock(HRegionServer.class); HRegionServer rs = mock(HRegionServer.class);
doCallRealMethod().when(rs).buildRegionSpaceUseReportRequest(any(Map.class)); doCallRealMethod().when(rs).buildRegionSpaceUseReportRequest(any());
doCallRealMethod().when(rs).convertRegionSize(any(RegionInfo.class), anyLong()); doCallRealMethod().when(rs).convertRegionSize(any(), anyLong());
rs.buildRegionSpaceUseReportRequest(sizes); rs.buildRegionSpaceUseReportRequest(sizes);
} }

View File

@ -41,8 +41,6 @@ import org.apache.hadoop.hbase.regionserver.compactions.CompactionRequestImpl;
import org.apache.hadoop.hbase.regionserver.compactions.StripeCompactionPolicy; import org.apache.hadoop.hbase.regionserver.compactions.StripeCompactionPolicy;
import org.apache.hadoop.hbase.regionserver.compactions.StripeCompactor; import org.apache.hadoop.hbase.regionserver.compactions.StripeCompactor;
import org.apache.hadoop.hbase.regionserver.throttle.NoLimitThroughputController; import org.apache.hadoop.hbase.regionserver.throttle.NoLimitThroughputController;
import org.apache.hadoop.hbase.regionserver.throttle.ThroughputController;
import org.apache.hadoop.hbase.security.User;
import org.apache.hadoop.hbase.testclassification.RegionServerTests; import org.apache.hadoop.hbase.testclassification.RegionServerTests;
import org.apache.hadoop.hbase.testclassification.SmallTests; import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.junit.Test; import org.junit.Test;
@ -76,9 +74,9 @@ public class TestStripeStoreEngine {
StripeCompactor mockCompactor = mock(StripeCompactor.class); StripeCompactor mockCompactor = mock(StripeCompactor.class);
se.setCompactorOverride(mockCompactor); se.setCompactorOverride(mockCompactor);
when( when(
mockCompactor.compact(any(CompactionRequestImpl.class), anyInt(), anyLong(), any(byte[].class), mockCompactor.compact(any(), anyInt(), anyLong(), any(),
any(byte[].class), any(byte[].class), any(byte[].class), any(), any(), any(),
any(ThroughputController.class), any(User.class))) any(), any()))
.thenReturn(new ArrayList<>()); .thenReturn(new ArrayList<>());
// Produce 3 L0 files. // Produce 3 L0 files.
@ -105,7 +103,7 @@ public class TestStripeStoreEngine {
private static HStoreFile createFile() throws Exception { private static HStoreFile createFile() throws Exception {
HStoreFile sf = mock(HStoreFile.class); HStoreFile sf = mock(HStoreFile.class);
when(sf.getMetadataValue(any(byte[].class))) when(sf.getMetadataValue(any()))
.thenReturn(StripeStoreFileManager.INVALID_KEY); .thenReturn(StripeStoreFileManager.INVALID_KEY);
when(sf.getReader()).thenReturn(mock(StoreFileReader.class)); when(sf.getReader()).thenReturn(mock(StoreFileReader.class));
when(sf.getPath()).thenReturn(new Path("moo")); when(sf.getPath()).thenReturn(new Path("moo"));

View File

@ -93,22 +93,22 @@ public class TestCompactor {
StoreFileWriter writer = mock(StoreFileWriter.class); StoreFileWriter writer = mock(StoreFileWriter.class);
doAnswer(new Answer<Object>() { doAnswer(new Answer<Object>() {
public Object answer(InvocationOnMock invocation) { public Object answer(InvocationOnMock invocation) {
return realWriter.kvs.add((KeyValue) invocation.getArguments()[0]); return realWriter.kvs.add((KeyValue) invocation.getArgument(0));
} }
}).when(writer).append(any(KeyValue.class)); }).when(writer).append(any());
doAnswer(new Answer<Object>() { doAnswer(new Answer<Object>() {
public Object answer(InvocationOnMock invocation) { public Object answer(InvocationOnMock invocation) {
Object[] args = invocation.getArguments(); Object[] args = invocation.getArguments();
return realWriter.data.put((byte[]) args[0], (byte[]) args[1]); return realWriter.data.put((byte[]) args[0], (byte[]) args[1]);
} }
}).when(writer).appendFileInfo(any(byte[].class), any(byte[].class)); }).when(writer).appendFileInfo(any(), any());
doAnswer(new Answer<Void>() { doAnswer(new Answer<Void>() {
@Override @Override
public Void answer(InvocationOnMock invocation) throws Throwable { public Void answer(InvocationOnMock invocation) throws Throwable {
realWriter.hasMetadata = true; realWriter.hasMetadata = true;
return null; return null;
} }
}).when(writer).appendMetadata(any(long.class), any(boolean.class)); }).when(writer).appendMetadata(anyLong(), anyBoolean());
doAnswer(new Answer<Path>() { doAnswer(new Answer<Path>() {
@Override @Override
public Path answer(InvocationOnMock invocation) throws Throwable { public Path answer(InvocationOnMock invocation) throws Throwable {

View File

@ -42,7 +42,6 @@ import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.io.compress.Compression;
import org.apache.hadoop.hbase.regionserver.HStore; import org.apache.hadoop.hbase.regionserver.HStore;
import org.apache.hadoop.hbase.regionserver.HStoreFile; import org.apache.hadoop.hbase.regionserver.HStoreFile;
import org.apache.hadoop.hbase.regionserver.InternalScanner; import org.apache.hadoop.hbase.regionserver.InternalScanner;
@ -102,7 +101,7 @@ public class TestDateTieredCompactor {
when(store.areWritesEnabled()).thenReturn(true); when(store.areWritesEnabled()).thenReturn(true);
when(store.getFileSystem()).thenReturn(mock(FileSystem.class)); when(store.getFileSystem()).thenReturn(mock(FileSystem.class));
when(store.getRegionInfo()).thenReturn(new HRegionInfo(TABLE_NAME)); when(store.getRegionInfo()).thenReturn(new HRegionInfo(TABLE_NAME));
when(store.createWriterInTmp(anyLong(), any(Compression.Algorithm.class), anyBoolean(), when(store.createWriterInTmp(anyLong(), any(), anyBoolean(),
anyBoolean(), anyBoolean(), anyBoolean())).thenAnswer(writers); anyBoolean(), anyBoolean(), anyBoolean())).thenAnswer(writers);
when(store.getComparator()).thenReturn(CellComparatorImpl.COMPARATOR); when(store.getComparator()).thenReturn(CellComparatorImpl.COMPARATOR);
OptionalLong maxSequenceId = StoreUtils.getMaxSequenceIdInList(storefiles); OptionalLong maxSequenceId = StoreUtils.getMaxSequenceIdInList(storefiles);

View File

@ -52,7 +52,6 @@ import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HColumnDescriptor; import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.io.compress.Compression;
import org.apache.hadoop.hbase.io.hfile.HFile; import org.apache.hadoop.hbase.io.hfile.HFile;
import org.apache.hadoop.hbase.regionserver.BloomType; import org.apache.hadoop.hbase.regionserver.BloomType;
import org.apache.hadoop.hbase.regionserver.HStore; import org.apache.hadoop.hbase.regionserver.HStore;
@ -71,7 +70,6 @@ import org.apache.hadoop.hbase.regionserver.StripeStoreFlusher;
import org.apache.hadoop.hbase.regionserver.compactions.StripeCompactionPolicy.StripeInformationProvider; import org.apache.hadoop.hbase.regionserver.compactions.StripeCompactionPolicy.StripeInformationProvider;
import org.apache.hadoop.hbase.regionserver.compactions.TestCompactor.StoreFileWritersCapture; import org.apache.hadoop.hbase.regionserver.compactions.TestCompactor.StoreFileWritersCapture;
import org.apache.hadoop.hbase.regionserver.throttle.NoLimitThroughputController; import org.apache.hadoop.hbase.regionserver.throttle.NoLimitThroughputController;
import org.apache.hadoop.hbase.security.User;
import org.apache.hadoop.hbase.testclassification.RegionServerTests; import org.apache.hadoop.hbase.testclassification.RegionServerTests;
import org.apache.hadoop.hbase.testclassification.SmallTests; import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.Bytes;
@ -237,7 +235,7 @@ public class TestStripeCompactionPolicy {
scr.execute(sc, NoLimitThroughputController.INSTANCE, null); scr.execute(sc, NoLimitThroughputController.INSTANCE, null);
verify(sc, only()).compact(eq(scr.getRequest()), anyInt(), anyLong(), aryEq(OPEN_KEY), verify(sc, only()).compact(eq(scr.getRequest()), anyInt(), anyLong(), aryEq(OPEN_KEY),
aryEq(OPEN_KEY), aryEq(OPEN_KEY), aryEq(OPEN_KEY), aryEq(OPEN_KEY), aryEq(OPEN_KEY), aryEq(OPEN_KEY),
any(NoLimitThroughputController.class), any(User.class)); any(), any());
} }
@Test @Test
@ -551,9 +549,8 @@ public class TestStripeCompactionPolicy {
scr.execute(sc, NoLimitThroughputController.INSTANCE, null); scr.execute(sc, NoLimitThroughputController.INSTANCE, null);
verify(sc, times(1)).compact(eq(scr.getRequest()), argThat(new ArgumentMatcher<List<byte[]>>() { verify(sc, times(1)).compact(eq(scr.getRequest()), argThat(new ArgumentMatcher<List<byte[]>>() {
@Override @Override
public boolean matches(Object argument) { public boolean matches(List<byte[]> argument) {
@SuppressWarnings("unchecked") List<byte[]> other = argument;
List<byte[]> other = (List<byte[]>) argument;
if (other.size() != boundaries.size()) return false; if (other.size() != boundaries.size()) return false;
for (int i = 0; i < other.size(); ++i) { for (int i = 0; i < other.size(); ++i) {
if (!Bytes.equals(other.get(i), boundaries.get(i))) return false; if (!Bytes.equals(other.get(i), boundaries.get(i))) return false;
@ -562,7 +559,7 @@ public class TestStripeCompactionPolicy {
} }
}), dropDeletesFrom == null ? isNull(byte[].class) : aryEq(dropDeletesFrom), }), dropDeletesFrom == null ? isNull(byte[].class) : aryEq(dropDeletesFrom),
dropDeletesTo == null ? isNull(byte[].class) : aryEq(dropDeletesTo), dropDeletesTo == null ? isNull(byte[].class) : aryEq(dropDeletesTo),
any(NoLimitThroughputController.class), any(User.class)); any(), any());
} }
/** /**
@ -574,7 +571,7 @@ public class TestStripeCompactionPolicy {
* @param count Expected # of resulting stripes, null if not checked. * @param count Expected # of resulting stripes, null if not checked.
* @param size Expected target stripe size, null if not checked. * @param size Expected target stripe size, null if not checked.
* @param start Left boundary of the compaction. * @param start Left boundary of the compaction.
* @param righr Right boundary of the compaction. * @param end Right boundary of the compaction.
*/ */
private void verifyCompaction(StripeCompactionPolicy policy, StripeInformationProvider si, private void verifyCompaction(StripeCompactionPolicy policy, StripeInformationProvider si,
Collection<HStoreFile> sfs, Boolean dropDeletes, Integer count, Long size, Collection<HStoreFile> sfs, Boolean dropDeletes, Integer count, Long size,
@ -588,7 +585,7 @@ public class TestStripeCompactionPolicy {
count == null ? anyInt() : eq(count.intValue()), count == null ? anyInt() : eq(count.intValue()),
size == null ? anyLong() : eq(size.longValue()), aryEq(start), aryEq(end), size == null ? anyLong() : eq(size.longValue()), aryEq(start), aryEq(end),
dropDeletesMatcher(dropDeletes, start), dropDeletesMatcher(dropDeletes, end), dropDeletesMatcher(dropDeletes, start), dropDeletesMatcher(dropDeletes, end),
any(NoLimitThroughputController.class), any(User.class)); any(), any());
} }
/** Verify arbitrary flush. */ /** Verify arbitrary flush. */
@ -612,7 +609,7 @@ public class TestStripeCompactionPolicy {
private byte[] dropDeletesMatcher(Boolean dropDeletes, byte[] value) { private byte[] dropDeletesMatcher(Boolean dropDeletes, byte[] value) {
return dropDeletes == null ? any(byte[].class) return dropDeletes == null ? any()
: (dropDeletes.booleanValue() ? aryEq(value) : isNull(byte[].class)); : (dropDeletes.booleanValue() ? aryEq(value) : isNull(byte[].class));
} }
@ -780,7 +777,7 @@ public class TestStripeCompactionPolicy {
when(store.getColumnFamilyDescriptor()).thenReturn(col); when(store.getColumnFamilyDescriptor()).thenReturn(col);
when(store.getRegionInfo()).thenReturn(info); when(store.getRegionInfo()).thenReturn(info);
when( when(
store.createWriterInTmp(anyLong(), any(Compression.Algorithm.class), anyBoolean(), store.createWriterInTmp(anyLong(), any(), anyBoolean(),
anyBoolean(), anyBoolean(), anyBoolean())).thenAnswer(writers); anyBoolean(), anyBoolean(), anyBoolean())).thenAnswer(writers);
Configuration conf = HBaseConfiguration.create(); Configuration conf = HBaseConfiguration.create();

View File

@ -41,7 +41,6 @@ import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.io.compress.Compression;
import org.apache.hadoop.hbase.regionserver.HStore; import org.apache.hadoop.hbase.regionserver.HStore;
import org.apache.hadoop.hbase.regionserver.InternalScanner; import org.apache.hadoop.hbase.regionserver.InternalScanner;
import org.apache.hadoop.hbase.regionserver.ScanInfo; import org.apache.hadoop.hbase.regionserver.ScanInfo;
@ -201,7 +200,7 @@ public class TestStripeCompactor {
when(store.areWritesEnabled()).thenReturn(true); when(store.areWritesEnabled()).thenReturn(true);
when(store.getFileSystem()).thenReturn(mock(FileSystem.class)); when(store.getFileSystem()).thenReturn(mock(FileSystem.class));
when(store.getRegionInfo()).thenReturn(new HRegionInfo(TABLE_NAME)); when(store.getRegionInfo()).thenReturn(new HRegionInfo(TABLE_NAME));
when(store.createWriterInTmp(anyLong(), any(Compression.Algorithm.class), anyBoolean(), when(store.createWriterInTmp(anyLong(), any(), anyBoolean(),
anyBoolean(), anyBoolean(), anyBoolean())).thenAnswer(writers); anyBoolean(), anyBoolean(), anyBoolean())).thenAnswer(writers);
when(store.getComparator()).thenReturn(CellComparatorImpl.COMPARATOR); when(store.getComparator()).thenReturn(CellComparatorImpl.COMPARATOR);

View File

@ -22,6 +22,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Matchers.any; import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq; import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doAnswer;
@ -997,7 +998,7 @@ public abstract class AbstractTestWALReplay {
} }
return b; return b;
} }
}).when(spyIn).read(any(byte[].class), any(int.class), any(int.class)); }).when(spyIn).read(any(byte[].class), anyInt(), anyInt());
doAnswer(new Answer<Void>() { doAnswer(new Answer<Void>() {
@Override @Override

View File

@ -45,12 +45,16 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.ScheduledThreadPoolExecutor;
import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotEquals;
import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.Matchers.anyLong; import static org.mockito.Matchers.anyLong;
import static org.mockito.Matchers.eq; import static org.mockito.Matchers.eq;
import static org.mockito.Matchers.isA; import static org.mockito.Matchers.isA;
import static org.mockito.Matchers.argThat;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.*; import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@RunWith(MockitoJUnitRunner.class) @RunWith(MockitoJUnitRunner.class)
@Category({MediumTests.class}) @Category({MediumTests.class})
@ -151,14 +155,14 @@ public class TestCanaryTool {
// One table's timeout is set for 0 ms and thus, should lead to an error. // One table's timeout is set for 0 ms and thus, should lead to an error.
verify(mockAppender, times(1)).doAppend(argThat(new ArgumentMatcher<LoggingEvent>() { verify(mockAppender, times(1)).doAppend(argThat(new ArgumentMatcher<LoggingEvent>() {
@Override @Override
public boolean matches(Object argument) { public boolean matches(LoggingEvent argument) {
return ((LoggingEvent) argument).getRenderedMessage().contains("exceeded the configured read timeout."); return ((LoggingEvent) argument).getRenderedMessage().contains("exceeded the configured read timeout.");
} }
})); }));
verify(mockAppender, times(2)).doAppend(argThat(new ArgumentMatcher<LoggingEvent>() { verify(mockAppender, times(2)).doAppend(argThat(new ArgumentMatcher<LoggingEvent>() {
@Override @Override
public boolean matches(Object argument) { public boolean matches(LoggingEvent argument) {
return ((LoggingEvent) argument).getRenderedMessage().contains("The configured read timeout was"); return argument.getRenderedMessage().contains("The configured read timeout was");
} }
})); }));
} }
@ -173,12 +177,13 @@ public class TestCanaryTool {
assertEquals(0, ToolRunner.run(testingUtility.getConfiguration(), canary, args)); assertEquals(0, ToolRunner.run(testingUtility.getConfiguration(), canary, args));
assertNotEquals("verify non-null write latency", null, sink.getWriteLatency()); assertNotEquals("verify non-null write latency", null, sink.getWriteLatency());
assertNotEquals("verify non-zero write latency", 0L, sink.getWriteLatency()); assertNotEquals("verify non-zero write latency", 0L, sink.getWriteLatency());
verify(mockAppender, times(1)).doAppend(argThat(new ArgumentMatcher<LoggingEvent>() { verify(mockAppender, times(1)).doAppend(argThat(
@Override new ArgumentMatcher<LoggingEvent>() {
public boolean matches(Object argument) { @Override
return ((LoggingEvent) argument).getRenderedMessage().contains("The configured write timeout was"); public boolean matches(LoggingEvent argument) {
} return argument.getRenderedMessage().contains("The configured write timeout was");
})); }
}));
} }
//no table created, so there should be no regions //no table created, so there should be no regions
@ -187,8 +192,8 @@ public class TestCanaryTool {
runRegionserverCanary(); runRegionserverCanary();
verify(mockAppender).doAppend(argThat(new ArgumentMatcher<LoggingEvent>() { verify(mockAppender).doAppend(argThat(new ArgumentMatcher<LoggingEvent>() {
@Override @Override
public boolean matches(Object argument) { public boolean matches(LoggingEvent argument) {
return ((LoggingEvent) argument).getRenderedMessage().contains("Regionserver not serving any regions"); return argument.getRenderedMessage().contains("Regionserver not serving any regions");
} }
})); }));
} }
@ -201,8 +206,8 @@ public class TestCanaryTool {
runRegionserverCanary(); runRegionserverCanary();
verify(mockAppender, never()).doAppend(argThat(new ArgumentMatcher<LoggingEvent>() { verify(mockAppender, never()).doAppend(argThat(new ArgumentMatcher<LoggingEvent>() {
@Override @Override
public boolean matches(Object argument) { public boolean matches(LoggingEvent argument) {
return ((LoggingEvent) argument).getRenderedMessage().contains("Regionserver not serving any regions"); return argument.getRenderedMessage().contains("Regionserver not serving any regions");
} }
})); }));
} }

View File

@ -374,7 +374,7 @@ public class TestLoadIncrementalHFilesSplitRecovery {
.when( .when(
hri.bulkLoadHFile((RpcController) Mockito.any(), (BulkLoadHFileRequest) Mockito.any())) hri.bulkLoadHFile((RpcController) Mockito.any(), (BulkLoadHFileRequest) Mockito.any()))
.thenThrow(new ServiceException(new IOException("injecting bulk load error"))); .thenThrow(new ServiceException(new IOException("injecting bulk load error")));
Mockito.when(c.getClient(Mockito.any(ServerName.class))).thenReturn(hri); Mockito.when(c.getClient(Mockito.any())).thenReturn(hri);
return c; return c;
} }

View File

@ -1008,7 +1008,7 @@ public class TestWALSplit {
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
} }
} }
Entry entry = (Entry) invocation.getArguments()[0]; Entry entry = (Entry) invocation.getArgument(0);
WALEdit edit = entry.getEdit(); WALEdit edit = entry.getEdit();
List<Cell> cells = edit.getCells(); List<Cell> cells = edit.getCells();
assertEquals(1, cells.size()); assertEquals(1, cells.size());

View File

@ -63,7 +63,7 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId> <artifactId>mockito-core</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
</dependencies> </dependencies>

22
pom.xml
View File

@ -1435,7 +1435,7 @@
<hamcrest.version>1.3</hamcrest.version> <hamcrest.version>1.3</hamcrest.version>
<htrace.version>3.2.0-incubating</htrace.version> <htrace.version>3.2.0-incubating</htrace.version>
<log4j.version>1.2.17</log4j.version> <log4j.version>1.2.17</log4j.version>
<mockito-all.version>1.10.19</mockito-all.version> <mockito-core.version>2.1.0</mockito-core.version>
<!--Internally we use a different version of protobuf. See hbase-protocol-shaded--> <!--Internally we use a different version of protobuf. See hbase-protocol-shaded-->
<external.protobuf.version>2.5.0</external.protobuf.version> <external.protobuf.version>2.5.0</external.protobuf.version>
<protobuf.plugin.version>0.5.0</protobuf.plugin.version> <protobuf.plugin.version>0.5.0</protobuf.plugin.version>
@ -2040,8 +2040,8 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId> <artifactId>mockito-core</artifactId>
<version>${mockito-all.version}</version> <version>${mockito-core.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
@ -3366,8 +3366,8 @@
<additionalDependencies> <additionalDependencies>
<additionalDependency> <additionalDependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId> <artifactId>mockito-core</artifactId>
<version>${mockito-all.version}</version> <version>${mockito-core.version}</version>
</additionalDependency> </additionalDependency>
<additionalDependency> <additionalDependency>
<groupId>org.hamcrest</groupId> <groupId>org.hamcrest</groupId>
@ -3409,8 +3409,8 @@
<additionalDependencies> <additionalDependencies>
<additionalDependency> <additionalDependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId> <artifactId>mockito-core</artifactId>
<version>${mockito-all.version}</version> <version>${mockito-core.version}</version>
</additionalDependency> </additionalDependency>
<additionalDependency> <additionalDependency>
<groupId>org.hamcrest</groupId> <groupId>org.hamcrest</groupId>
@ -3463,8 +3463,8 @@
<additionalDependencies> <additionalDependencies>
<additionalDependency> <additionalDependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId> <artifactId>mockito-core</artifactId>
<version>${mockito-all.version}</version> <version>${mockito-core.version}</version>
</additionalDependency> </additionalDependency>
<additionalDependency> <additionalDependency>
<groupId>org.hamcrest</groupId> <groupId>org.hamcrest</groupId>
@ -3516,8 +3516,8 @@
<additionalDependencies> <additionalDependencies>
<additionalDependency> <additionalDependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId> <artifactId>mockito-core</artifactId>
<version>${mockito-all.version}</version> <version>${mockito-core.version}</version>
</additionalDependency> </additionalDependency>
<additionalDependency> <additionalDependency>
<groupId>org.hamcrest</groupId> <groupId>org.hamcrest</groupId>

View File

@ -117,8 +117,8 @@ First, add a dependency for Mockito to your Maven POM file.
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId> <artifactId>mockito-core</artifactId>
<version>1.9.5</version> <version>2.1.0</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
---- ----