HADOOP-19243. Upgrade Mockito version to 4.11.0 (#6968)

Mockito is now at a JDK-17 compatible version.

Contributed by Muskan Mishra
This commit is contained in:
muskan1012 2024-11-05 23:05:53 +05:30 committed by GitHub
parent 51ebc3c20e
commit f7651e2f63
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
84 changed files with 266 additions and 143 deletions

View File

@ -407,7 +407,7 @@
<!-- Add back in Mockito since the hadoop-hdfs test jar needs it. --> <!-- Add back in Mockito since the hadoop-hdfs test jar needs it. -->
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId> <artifactId>mockito-inline</artifactId>
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
<!-- Add back in the transitive dependencies excluded from hadoop-common in client TODO remove once we have a filter for "is in these artifacts" --> <!-- Add back in the transitive dependencies excluded from hadoop-common in client TODO remove once we have a filter for "is in these artifacts" -->
@ -765,7 +765,7 @@
<!-- Mockito tries to include its own unrelocated copy of hamcrest. :( --> <!-- Mockito tries to include its own unrelocated copy of hamcrest. :( -->
<filter> <filter>
<artifact>org.mockito:mockito-core</artifact> <artifact>org.mockito:mockito-inline</artifact>
<excludes> <excludes>
<exclude>asm-license.txt</exclude> <exclude>asm-license.txt</exclude>
<exclude>cglib-license.txt</exclude> <exclude>cglib-license.txt</exclude>
@ -777,6 +777,15 @@
<exclude>org/objenesis/*.class</exclude> <exclude>org/objenesis/*.class</exclude>
</excludes> </excludes>
</filter> </filter>
<!-- Additional filters to exclude unexpected contents -->
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>mockito-extensions/**</exclude>
<exclude>win32-x86/**</exclude>
<exclude>win32-x86-64/**</exclude>
</excludes>
</filter>
<!-- skip grizzly internals we don't need to run. --> <!-- skip grizzly internals we don't need to run. -->
<filter> <filter>
<artifact>org.glassfish.grizzly:grizzly-http-servlet</artifact> <artifact>org.glassfish.grizzly:grizzly-http-servlet</artifact>

View File

@ -173,15 +173,27 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.powermock</groupId> <groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId> <artifactId>powermock-api-mockito2</artifactId>
<version>1.7.4</version> <version>2.0.9</version>
<scope>test</scope> <scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.powermock</groupId> <groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId> <artifactId>powermock-module-junit4</artifactId>
<version>1.7.4</version> <version>2.0.9</version>
<scope>test</scope> <scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -49,6 +49,7 @@
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId> <artifactId>mockito-core</artifactId>
<version>4.11.0</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

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

View File

@ -35,6 +35,8 @@
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger; import org.slf4j.Logger;
import static org.apache.hadoop.test.MockitoUtil.verifyZeroInteractions;
/** /**
* This is intended to be a set of unit tests for the * This is intended to be a set of unit tests for the
* org.apache.hadoop.ipc.Server class. * org.apache.hadoop.ipc.Server class.

View File

@ -36,6 +36,8 @@
import org.junit.Test; import org.junit.Test;
import org.mockito.Mockito; import org.mockito.Mockito;
import static org.apache.hadoop.test.MockitoUtil.verifyZeroInteractions;
public class TestCrossOriginFilter { public class TestCrossOriginFilter {
@Test @Test
@ -59,7 +61,7 @@ public void testSameOrigin() throws ServletException, IOException {
filter.init(filterConfig); filter.init(filterConfig);
filter.doFilter(mockReq, mockRes, mockChain); filter.doFilter(mockReq, mockRes, mockChain);
Mockito.verifyZeroInteractions(mockRes); verifyZeroInteractions(mockRes);
Mockito.verify(mockChain).doFilter(mockReq, mockRes); Mockito.verify(mockChain).doFilter(mockReq, mockRes);
} }
@ -224,7 +226,7 @@ public void testDisallowedOrigin() throws ServletException, IOException {
filter.init(filterConfig); filter.init(filterConfig);
filter.doFilter(mockReq, mockRes, mockChain); filter.doFilter(mockReq, mockRes, mockChain);
Mockito.verifyZeroInteractions(mockRes); verifyZeroInteractions(mockRes);
Mockito.verify(mockChain).doFilter(mockReq, mockRes); Mockito.verify(mockChain).doFilter(mockReq, mockRes);
} }
@ -252,7 +254,7 @@ public void testDisallowedMethod() throws ServletException, IOException {
filter.init(filterConfig); filter.init(filterConfig);
filter.doFilter(mockReq, mockRes, mockChain); filter.doFilter(mockReq, mockRes, mockChain);
Mockito.verifyZeroInteractions(mockRes); verifyZeroInteractions(mockRes);
Mockito.verify(mockChain).doFilter(mockReq, mockRes); Mockito.verify(mockChain).doFilter(mockReq, mockRes);
} }
@ -283,7 +285,7 @@ public void testDisallowedHeader() throws ServletException, IOException {
filter.init(filterConfig); filter.init(filterConfig);
filter.doFilter(mockReq, mockRes, mockChain); filter.doFilter(mockReq, mockRes, mockChain);
Mockito.verifyZeroInteractions(mockRes); verifyZeroInteractions(mockRes);
Mockito.verify(mockChain).doFilter(mockReq, mockRes); Mockito.verify(mockChain).doFilter(mockReq, mockRes);
} }

View File

@ -32,6 +32,8 @@
import org.junit.Test; import org.junit.Test;
import org.mockito.Mockito; import org.mockito.Mockito;
import static org.apache.hadoop.test.MockitoUtil.verifyZeroInteractions;
/** /**
* This class tests the behavior of the RestCsrfPreventionFilter. * This class tests the behavior of the RestCsrfPreventionFilter.
* *
@ -75,7 +77,7 @@ public void testNoHeaderDefaultConfigBadRequest()
verify(mockRes, atLeastOnce()).sendError( verify(mockRes, atLeastOnce()).sendError(
HttpServletResponse.SC_BAD_REQUEST, EXPECTED_MESSAGE); HttpServletResponse.SC_BAD_REQUEST, EXPECTED_MESSAGE);
Mockito.verifyZeroInteractions(mockChain); verifyZeroInteractions(mockChain);
} }
@Test @Test
@ -110,7 +112,7 @@ public void testNoHeaderCustomAgentConfigBadRequest()
verify(mockRes, atLeastOnce()).sendError( verify(mockRes, atLeastOnce()).sendError(
HttpServletResponse.SC_BAD_REQUEST, EXPECTED_MESSAGE); HttpServletResponse.SC_BAD_REQUEST, EXPECTED_MESSAGE);
Mockito.verifyZeroInteractions(mockChain); verifyZeroInteractions(mockChain);
} }
@Test @Test
@ -228,7 +230,7 @@ public void testMissingHeaderWithCustomHeaderConfigBadRequest()
filter.init(filterConfig); filter.init(filterConfig);
filter.doFilter(mockReq, mockRes, mockChain); filter.doFilter(mockReq, mockRes, mockChain);
Mockito.verifyZeroInteractions(mockChain); verifyZeroInteractions(mockChain);
} }
@Test @Test
@ -260,7 +262,7 @@ public void testMissingHeaderNoMethodsToIgnoreConfigBadRequest()
filter.init(filterConfig); filter.init(filterConfig);
filter.doFilter(mockReq, mockRes, mockChain); filter.doFilter(mockReq, mockRes, mockChain);
Mockito.verifyZeroInteractions(mockChain); verifyZeroInteractions(mockChain);
} }
@Test @Test
@ -356,6 +358,6 @@ public void testMissingHeaderMultipleIgnoreMethodsConfigBadRequest()
filter.init(filterConfig); filter.init(filterConfig);
filter.doFilter(mockReq, mockRes, mockChain); filter.doFilter(mockReq, mockRes, mockChain);
Mockito.verifyZeroInteractions(mockChain); verifyZeroInteractions(mockChain);
} }
} }

View File

@ -61,4 +61,13 @@ public Object answer(InvocationOnMock invocation) throws Throwable {
} }
}); });
} }
/**
* Verifies that there were no interactions with the given mock objects.
*
* @param mocks the mock objects to verify
*/
public static void verifyZeroInteractions(Object... mocks) {
Mockito.verifyNoInteractions(mocks);
}
} }

View File

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

View File

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

View File

@ -66,7 +66,7 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd">
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId> <artifactId>mockito-inline</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

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

View File

@ -69,7 +69,7 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd">
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId> <artifactId>mockito-inline</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -160,7 +160,7 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd">
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId> <artifactId>mockito-inline</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -164,7 +164,7 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd">
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId> <artifactId>mockito-inline</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -25,6 +25,7 @@
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Field;
import java.security.PrivilegedExceptionAction; import java.security.PrivilegedExceptionAction;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
@ -68,7 +69,6 @@
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.mockito.Mockito; import org.mockito.Mockito;
import org.mockito.internal.util.reflection.FieldSetter;
/** /**
* The administrator interface of the {@link Router} implemented by * The administrator interface of the {@link Router} implemented by
@ -118,18 +118,25 @@ public static void globalSetUp() throws Exception {
* @throws IOException * @throws IOException
* @throws NoSuchFieldException * @throws NoSuchFieldException
*/ */
private static void setUpMocks() throws IOException, NoSuchFieldException { public static void setField(Object target, String fieldName, Object value)
throws NoSuchFieldException, IllegalAccessException {
Field field = target.getClass().getDeclaredField(fieldName);
field.setAccessible(true);
field.set(target, value);
}
private static void setUpMocks()
throws IOException, NoSuchFieldException, IllegalAccessException {
RouterRpcServer spyRpcServer = RouterRpcServer spyRpcServer =
Mockito.spy(routerContext.getRouter().createRpcServer()); Mockito.spy(routerContext.getRouter().createRpcServer());
FieldSetter.setField(routerContext.getRouter(), //Used reflection to set the 'rpcServer field'
Router.class.getDeclaredField("rpcServer"), spyRpcServer); setField(routerContext.getRouter(), "rpcServer", spyRpcServer);
Mockito.doReturn(null).when(spyRpcServer).getFileInfo(Mockito.anyString()); Mockito.doReturn(null).when(spyRpcServer).getFileInfo(Mockito.anyString());
// mock rpc client for destination check when editing mount tables. // mock rpc client for destination check when editing mount tables.
//spy RPC client and used reflection to set the 'rpcClient' field
mockRpcClient = Mockito.spy(spyRpcServer.getRPCClient()); mockRpcClient = Mockito.spy(spyRpcServer.getRPCClient());
FieldSetter.setField(spyRpcServer, setField(spyRpcServer, "rpcClient", mockRpcClient);
RouterRpcServer.class.getDeclaredField("rpcClient"),
mockRpcClient);
RemoteLocation remoteLocation0 = RemoteLocation remoteLocation0 =
new RemoteLocation("ns0", "/testdir", null); new RemoteLocation("ns0", "/testdir", null);
RemoteLocation remoteLocation1 = RemoteLocation remoteLocation1 =

View File

@ -24,7 +24,7 @@
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.Matchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.apache.hadoop.test.Whitebox.getInternalState; import static org.apache.hadoop.test.Whitebox.getInternalState;

View File

@ -166,7 +166,7 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd">
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId> <artifactId>mockito-inline</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -253,9 +253,8 @@ static long toLong(long preferredBlockSize, long layoutRedundancy,
private BlockInfo[] blocks; private BlockInfo[] blocks;
INodeFile(long id, byte[] name, PermissionStatus permissions, long mtime, public INodeFile(long id, byte[] name, PermissionStatus permissions, long mtime, long atime,
long atime, BlockInfo[] blklist, short replication, BlockInfo[] blklist, short replication, long preferredBlockSize) {
long preferredBlockSize) {
this(id, name, permissions, mtime, atime, blklist, replication, null, this(id, name, permissions, mtime, atime, blklist, replication, null,
preferredBlockSize, (byte) 0, CONTIGUOUS); preferredBlockSize, (byte) 0, CONTIGUOUS);
} }

View File

@ -365,6 +365,7 @@ public void testIncrementAndDecrementStripedSafeBlockCount() {
for (long i = 1; i <= BLOCK_TOTAL; i++) { for (long i = 1; i <= BLOCK_TOTAL; i++) {
BlockInfoStriped blockInfo = mock(BlockInfoStriped.class); BlockInfoStriped blockInfo = mock(BlockInfoStriped.class);
when(blockInfo.getRealDataBlockNum()).thenReturn(realDataBlockNum); when(blockInfo.getRealDataBlockNum()).thenReturn(realDataBlockNum);
when(blockInfo.isStriped()).thenReturn(true);
bmSafeMode.incrementSafeBlockCount(realDataBlockNum, blockInfo); bmSafeMode.incrementSafeBlockCount(realDataBlockNum, blockInfo);
bmSafeMode.decrementSafeBlockCount(blockInfo); bmSafeMode.decrementSafeBlockCount(blockInfo);

View File

@ -25,6 +25,7 @@
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_CACHING_ENABLED_KEY; import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_CACHING_ENABLED_KEY;
import static org.apache.hadoop.hdfs.protocol.CachePoolInfo.RELATIVE_EXPIRY_NEVER; import static org.apache.hadoop.hdfs.protocol.CachePoolInfo.RELATIVE_EXPIRY_NEVER;
import static org.apache.hadoop.test.GenericTestUtils.assertExceptionContains; import static org.apache.hadoop.test.GenericTestUtils.assertExceptionContains;
import static org.apache.hadoop.test.MockitoUtil.verifyZeroInteractions;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
@ -1575,7 +1576,7 @@ public void testNoLookupsWhenNotUsed() throws Exception {
CacheManager cm = cluster.getNamesystem().getCacheManager(); CacheManager cm = cluster.getNamesystem().getCacheManager();
LocatedBlocks locations = Mockito.mock(LocatedBlocks.class); LocatedBlocks locations = Mockito.mock(LocatedBlocks.class);
cm.setCachedLocations(locations); cm.setCachedLocations(locations);
Mockito.verifyZeroInteractions(locations); verifyZeroInteractions(locations);
} }
@Test(timeout=120000) @Test(timeout=120000)

View File

@ -62,7 +62,6 @@ private FSNamesystem makeNameSystemSpy(Block block, INodeFile file)
} }
namesystem.dir.getINodeMap().put(file); namesystem.dir.getINodeMap().put(file);
FSNamesystem namesystemSpy = spy(namesystem);
BlockInfo blockInfo = new BlockInfoContiguous(block, (short) 1); BlockInfo blockInfo = new BlockInfoContiguous(block, (short) 1);
blockInfo.convertToBlockUnderConstruction( blockInfo.convertToBlockUnderConstruction(
HdfsServerConstants.BlockUCState.UNDER_CONSTRUCTION, targets); HdfsServerConstants.BlockUCState.UNDER_CONSTRUCTION, targets);
@ -73,8 +72,10 @@ private FSNamesystem makeNameSystemSpy(Block block, INodeFile file)
doReturn(blockInfo).when(file).removeLastBlock(any(Block.class)); doReturn(blockInfo).when(file).removeLastBlock(any(Block.class));
doReturn(true).when(file).isUnderConstruction(); doReturn(true).when(file).isUnderConstruction();
doReturn(new BlockInfoContiguous[1]).when(file).getBlocks(); doReturn(new BlockInfoContiguous[1]).when(file).getBlocks();
FSNamesystem namesystemSpy = spy(namesystem);
doReturn(blockInfo).when(namesystemSpy).getStoredBlock(any(Block.class)); doReturn(blockInfo).when(namesystemSpy).getStoredBlock(nullable(Block.class));
doReturn(file).when(namesystemSpy).getBlockCollection(any(BlockInfo.class));
doReturn(false).when(namesystemSpy).isFileDeleted(any(INodeFile.class));
doReturn(blockInfo).when(file).getLastBlock(); doReturn(blockInfo).when(file).getLastBlock();
doNothing().when(namesystemSpy).closeFileCommitBlocks( doNothing().when(namesystemSpy).closeFileCommitBlocks(
any(), any(INodeFile.class), any(BlockInfo.class)); any(), any(INodeFile.class), any(BlockInfo.class));

View File

@ -28,9 +28,12 @@
import org.mockito.Mockito; import org.mockito.Mockito;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.util.Random;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
/** /**
@ -55,7 +58,8 @@ private boolean unprotectedSetTimes(long atime, long atime0, long precision,
when(fsd.getAccessTimePrecision()).thenReturn(precision); when(fsd.getAccessTimePrecision()).thenReturn(precision);
when(fsd.hasWriteLock()).thenReturn(Boolean.TRUE); when(fsd.hasWriteLock()).thenReturn(Boolean.TRUE);
when(iip.getLastINode()).thenReturn(inode); when(iip.getLastINode()).thenReturn(inode);
when(iip.getLatestSnapshotId()).thenReturn(Mockito.anyInt()); when(iip.getLatestSnapshotId()).thenReturn(new Random().nextInt());
when(inode.setModificationTime(anyLong(), anyInt())).thenReturn(inode);
when(inode.getAccessTime()).thenReturn(atime0); when(inode.getAccessTime()).thenReturn(atime0);
return FSDirAttrOp.unprotectedSetTimes(fsd, iip, mtime, atime, force); return FSDirAttrOp.unprotectedSetTimes(fsd, iip, mtime, atime, force);

View File

@ -41,6 +41,8 @@
import org.junit.Test; import org.junit.Test;
import org.mockito.Mockito; import org.mockito.Mockito;
import static org.apache.hadoop.test.MockitoUtil.verifyZeroInteractions;
/** Test snapshot related operations. */ /** Test snapshot related operations. */
public class TestSnapshotPathINodes { public class TestSnapshotPathINodes {
private static final long seed = 0; private static final long seed = 0;
@ -447,6 +449,6 @@ public void testShortCircuitSnapshotSearch() throws SnapshotException {
INodesInPath iip = Mockito.mock(INodesInPath.class); INodesInPath iip = Mockito.mock(INodesInPath.class);
List<INodeDirectory> snapDirs = new ArrayList<>(); List<INodeDirectory> snapDirs = new ArrayList<>();
FSDirSnapshotOp.checkSnapshot(fsn.getFSDirectory(), iip, snapDirs); FSDirSnapshotOp.checkSnapshot(fsn.getFSDirectory(), iip, snapDirs);
Mockito.verifyZeroInteractions(iip); verifyZeroInteractions(iip);
} }
} }

View File

@ -19,6 +19,8 @@
import java.util.ArrayList; import java.util.ArrayList;
import org.apache.hadoop.fs.permission.FsPermission;
import org.apache.hadoop.fs.permission.PermissionStatus;
import org.apache.hadoop.hdfs.protocol.Block; import org.apache.hadoop.hdfs.protocol.Block;
import org.apache.hadoop.hdfs.protocol.BlockStoragePolicy; import org.apache.hadoop.hdfs.protocol.BlockStoragePolicy;
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo; import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo;
@ -40,6 +42,7 @@
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.anyByte; import static org.mockito.Mockito.anyByte;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
public class TestFileWithSnapshotFeature { public class TestFileWithSnapshotFeature {
@ -60,7 +63,8 @@ public void testUpdateQuotaAndCollectBlocks() {
BlockManager bm = mock(BlockManager.class); BlockManager bm = mock(BlockManager.class);
// No snapshot // No snapshot
INodeFile file = mock(INodeFile.class); INodeFile inodeFileObj = createMockFile(REPL_1);
INodeFile file = spy(inodeFileObj);
when(file.getFileWithSnapshotFeature()).thenReturn(sf); when(file.getFileWithSnapshotFeature()).thenReturn(sf);
when(file.getBlocks()).thenReturn(blocks); when(file.getBlocks()).thenReturn(blocks);
when(file.getStoragePolicyID()).thenReturn((byte) 1); when(file.getStoragePolicyID()).thenReturn((byte) 1);
@ -97,6 +101,16 @@ public void testUpdateQuotaAndCollectBlocks() {
Assert.assertEquals(-BLOCK_SIZE, counts.getTypeSpaces().get(SSD)); Assert.assertEquals(-BLOCK_SIZE, counts.getTypeSpaces().get(SSD));
} }
private INodeFile createMockFile(short replication) {
BlockInfo[] blocks = new BlockInfo[] {};
PermissionStatus perm = new PermissionStatus("foo", "bar", FsPermission
.createImmutable((short) 0x1ff));
INodeFile iNodeFile =
new INodeFile(1, new byte[0], perm, 0, 0, blocks, replication,
BLOCK_SIZE);
return iNodeFile;
}
/** /**
* Test update quota with same blocks. * Test update quota with same blocks.
*/ */
@ -107,7 +121,8 @@ public void testUpdateQuotaDistinctBlocks() {
BlockInfo[] blocks = new BlockInfo[] { BlockInfo[] blocks = new BlockInfo[] {
new BlockInfoContiguous(new Block(1, BLOCK_SIZE, 1), REPL_3) }; new BlockInfoContiguous(new Block(1, BLOCK_SIZE, 1), REPL_3) };
INodeFile file = mock(INodeFile.class); INodeFile inodeFileObj = createMockFile(REPL_1);
INodeFile file = spy(inodeFileObj);
when(file.getBlocks()).thenReturn(blocks); when(file.getBlocks()).thenReturn(blocks);
when(file.getStoragePolicyID()).thenReturn((byte) 1); when(file.getStoragePolicyID()).thenReturn((byte) 1);
when(file.getPreferredBlockReplication()).thenReturn((short) 3); when(file.getPreferredBlockReplication()).thenReturn((short) 3);

View File

@ -45,7 +45,7 @@ protected void heartbeat() throws Exception {
} }
} }
@Test(timeout = 2000) @Test(timeout = 6000)
public void testRMContainerAllocatorExceptionIsHandled() throws Exception { public void testRMContainerAllocatorExceptionIsHandled() throws Exception {
ClientService mockClientService = mock(ClientService.class); ClientService mockClientService = mock(ClientService.class);
AppContext mockContext = mock(AppContext.class); AppContext mockContext = mock(AppContext.class);

View File

@ -62,10 +62,10 @@
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import static org.mockito.Matchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Matchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.Matchers.anyString; import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Matchers.eq; import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times; import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;

View File

@ -20,7 +20,6 @@
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
import static org.mockito.Mockito.spy; import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doNothing;
@ -35,6 +34,7 @@
import org.apache.hadoop.mapred.YARNRunner; import org.apache.hadoop.mapred.YARNRunner;
import org.apache.hadoop.mapreduce.protocol.ClientProtocol; import org.apache.hadoop.mapreduce.protocol.ClientProtocol;
import org.apache.hadoop.security.token.Token; import org.apache.hadoop.security.token.Token;
import org.apache.hadoop.test.MockitoUtil;
import org.apache.hadoop.yarn.api.ApplicationClientProtocol; import org.apache.hadoop.yarn.api.ApplicationClientProtocol;
import org.apache.hadoop.yarn.api.protocolrecords.GetDelegationTokenRequest; import org.apache.hadoop.yarn.api.protocolrecords.GetDelegationTokenRequest;
import org.apache.hadoop.yarn.api.protocolrecords.GetDelegationTokenResponse; import org.apache.hadoop.yarn.api.protocolrecords.GetDelegationTokenResponse;
@ -105,7 +105,8 @@ public void testClusterGetDelegationToken() throws Exception {
rmDTToken.setPassword(ByteBuffer.wrap("testcluster".getBytes())); rmDTToken.setPassword(ByteBuffer.wrap("testcluster".getBytes()));
rmDTToken.setService("0.0.0.0:8032"); rmDTToken.setService("0.0.0.0:8032");
getDTResponse.setRMDelegationToken(rmDTToken); getDTResponse.setRMDelegationToken(rmDTToken);
final ApplicationClientProtocol cRMProtocol = mock(ApplicationClientProtocol.class); final ApplicationClientProtocol cRMProtocol =
MockitoUtil.mockProtocol(ApplicationClientProtocol.class);
when(cRMProtocol.getDelegationToken(any( when(cRMProtocol.getDelegationToken(any(
GetDelegationTokenRequest.class))).thenReturn(getDTResponse); GetDelegationTokenRequest.class))).thenReturn(getDTResponse);
ResourceMgrDelegate rmgrDelegate = new ResourceMgrDelegate( ResourceMgrDelegate rmgrDelegate = new ResourceMgrDelegate(

View File

@ -96,6 +96,8 @@
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId> <artifactId>mockito-core</artifactId>
<version>4.11.0</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -227,7 +227,7 @@
<junit.platform.version>1.8.2</junit.platform.version> <junit.platform.version>1.8.2</junit.platform.version>
<assertj.version>3.12.2</assertj.version> <assertj.version>3.12.2</assertj.version>
<jline.version>3.9.0</jline.version> <jline.version>3.9.0</jline.version>
<powermock.version>1.5.6</powermock.version> <powermock.version>2.0.9</powermock.version>
<solr.version>8.11.2</solr.version> <solr.version>8.11.2</solr.version>
<openssl-wildfly.version>2.1.4.Final</openssl-wildfly.version> <openssl-wildfly.version>2.1.4.Final</openssl-wildfly.version>
<jsonschema2pojo.version>1.0.2</jsonschema2pojo.version> <jsonschema2pojo.version>1.0.2</jsonschema2pojo.version>
@ -1350,8 +1350,8 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId> <artifactId>mockito-inline</artifactId>
<version>2.28.2</version> <version>4.11.0</version>
<exclusions> <exclusions>
<exclusion> <exclusion>
<groupId>log4j</groupId> <groupId>log4j</groupId>

View File

@ -125,7 +125,7 @@
<!-- 'mvn dependency:analyze' fails to detect use of this dependency --> <!-- 'mvn dependency:analyze' fails to detect use of this dependency -->
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId> <artifactId>mockito-inline</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<!-- 'mvn dependency:analyze' fails to detect use of this dependency --> <!-- 'mvn dependency:analyze' fails to detect use of this dependency -->

View File

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

View File

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

View File

@ -323,6 +323,7 @@
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId> <artifactId>mockito-core</artifactId>
<version>4.11.0</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -41,7 +41,7 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId> <artifactId>mockito-inline</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-core</artifactId> <artifactId>mockito-inline</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -69,7 +69,7 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId> <artifactId>mockito-inline</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-core</artifactId> <artifactId>mockito-inline</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -589,7 +589,7 @@ public FakeFSDataInputStream(InputStream in) throws IOException {
/* /*
* test LoadRecordReader. It class reads data from some files. * test LoadRecordReader. It class reads data from some files.
*/ */
@Test (timeout=3000) @Test (timeout=6100)
public void testLoadJobLoadRecordReader() throws Exception { public void testLoadJobLoadRecordReader() throws Exception {
LoadJob.LoadRecordReader test = new LoadJob.LoadRecordReader(); LoadJob.LoadRecordReader test = new LoadJob.LoadRecordReader();
Configuration conf = new Configuration(); Configuration conf = new Configuration();

View File

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

View File

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

View File

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

View File

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

View File

@ -46,8 +46,8 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId> <artifactId>mockito-core</artifactId>
<version>1.9.5</version> <version>4.11.0</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
@ -64,7 +64,7 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.powermock</groupId> <groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId> <artifactId>powermock-api-mockito2</artifactId>
<version>${powermock.version}</version> <version>${powermock.version}</version>
<exclusions> <exclusions>
<exclusion> <exclusion>

View File

@ -22,18 +22,21 @@
import org.apache.hadoop.yarn.appcatalog.model.AppStoreEntry; import org.apache.hadoop.yarn.appcatalog.model.AppStoreEntry;
import org.apache.hadoop.yarn.appcatalog.model.Application; import org.apache.hadoop.yarn.appcatalog.model.Application;
import org.apache.solr.client.solrj.SolrClient; import org.apache.solr.client.solrj.SolrClient;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.powermock.api.mockito.PowerMockito;
import org.mockito.Mockito;
import java.util.List;
import static org.powermock.api.mockito.PowerMockito.when; import static org.powermock.api.mockito.PowerMockito.when;
import static org.powermock.api.support.membermodification.MemberMatcher.method; import static org.powermock.api.support.membermodification.MemberMatcher.method;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.List;
/** /**
* Unit test for AppCatalogSolrClient. * Unit test for AppCatalogSolrClient.
*/ */
@ -51,7 +54,7 @@ public void setup() throws Exception {
String solrHome = targetLocation.split("/test-classes")[0] + "/solr"; String solrHome = targetLocation.split("/test-classes")[0] + "/solr";
solrClient = EmbeddedSolrServerFactory.create(solrHome, CONFIGSET_DIR, solrClient = EmbeddedSolrServerFactory.create(solrHome, CONFIGSET_DIR,
"exampleCollection"); "exampleCollection");
spy = PowerMockito.spy(new AppCatalogSolrClient()); spy = Mockito.spy(new AppCatalogSolrClient());
when(spy, method(AppCatalogSolrClient.class, "getSolrClient")) when(spy, method(AppCatalogSolrClient.class, "getSolrClient"))
.withNoArguments().thenReturn(solrClient); .withNoArguments().thenReturn(solrClient);
} }

View File

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

View File

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

View File

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

View File

@ -34,6 +34,7 @@
import java.io.IOException; import java.io.IOException;
import static org.apache.hadoop.fi.FiConfig.getConfig; import static org.apache.hadoop.fi.FiConfig.getConfig;
import static org.apache.hadoop.test.MockitoUtil.verifyZeroInteractions;
import static org.apache.hadoop.yarn.service.conf.YarnServiceConf import static org.apache.hadoop.yarn.service.conf.YarnServiceConf
.DEFAULT_CONTAINER_FAILURES_VALIDITY_INTERVAL; .DEFAULT_CONTAINER_FAILURES_VALIDITY_INTERVAL;
import static org.apache.hadoop.yarn.service.conf.YarnServiceConf import static org.apache.hadoop.yarn.service.conf.YarnServiceConf
@ -43,7 +44,6 @@
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.reset; import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
/** /**

View File

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

View File

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

View File

@ -55,7 +55,7 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId> <artifactId>mockito-inline</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<!-- 'mvn dependency:analyze' fails to detect use of this dependency --> <!-- 'mvn dependency:analyze' fails to detect use of this dependency -->

View File

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

View File

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

View File

@ -42,13 +42,13 @@
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import static org.apache.hadoop.test.MockitoUtil.verifyZeroInteractions;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
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.eq; import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.verifyZeroInteractions;
/** /**
* Tests for the CGroups handler implementation. * Tests for the CGroups handler implementation.

View File

@ -37,8 +37,8 @@
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import static org.apache.hadoop.test.MockitoUtil.verifyZeroInteractions;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.verifyZeroInteractions;
/** /**
* Tests for the CGroups handler implementation. * Tests for the CGroups handler implementation.

View File

@ -16,6 +16,7 @@
package org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.resources.gpu; package org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.resources.gpu;
import static org.apache.hadoop.test.MockitoUtil.verifyZeroInteractions;
import static org.apache.hadoop.yarn.api.records.ResourceInformation.GPU_URI; import static org.apache.hadoop.yarn.api.records.ResourceInformation.GPU_URI;
import static org.apache.hadoop.yarn.util.resource.CustomResourceTypesConfigurationProvider.initResourceTypes; import static org.apache.hadoop.yarn.util.resource.CustomResourceTypesConfigurationProvider.initResourceTypes;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
@ -27,7 +28,6 @@
import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
import java.io.IOException; import java.io.IOException;

View File

@ -94,6 +94,7 @@
import java.util.Set; import java.util.Set;
import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ConcurrentMap;
import static org.apache.hadoop.test.MockitoUtil.verifyZeroInteractions;
import static org.apache.hadoop.yarn.conf.YarnConfiguration.NM_DOCKER_DEFAULT_RO_MOUNTS; import static org.apache.hadoop.yarn.conf.YarnConfiguration.NM_DOCKER_DEFAULT_RO_MOUNTS;
import static org.apache.hadoop.yarn.conf.YarnConfiguration.NM_DOCKER_DEFAULT_RW_MOUNTS; import static org.apache.hadoop.yarn.conf.YarnConfiguration.NM_DOCKER_DEFAULT_RW_MOUNTS;
import static org.apache.hadoop.yarn.conf.YarnConfiguration.NM_DOCKER_DEFAULT_TMPFS_MOUNTS; import static org.apache.hadoop.yarn.conf.YarnConfiguration.NM_DOCKER_DEFAULT_TMPFS_MOUNTS;
@ -1272,7 +1273,7 @@ public void testCGroupParent() throws ContainerExecutionException {
command); command);
//no --cgroup-parent should be added here //no --cgroup-parent should be added here
Mockito.verifyZeroInteractions(command); verifyZeroInteractions(command);
String resourceOptionsCpu = "/sys/fs/cgroup/cpu/" + hierarchy + String resourceOptionsCpu = "/sys/fs/cgroup/cpu/" + hierarchy +
containerIdStr; containerIdStr;
@ -1283,6 +1284,8 @@ public void testCGroupParent() throws ContainerExecutionException {
String expectedPath = "/" + hierarchy + "/" + containerIdStr; String expectedPath = "/" + hierarchy + "/" + containerIdStr;
Mockito.verify(command).setCGroupParent(expectedPath); Mockito.verify(command).setCGroupParent(expectedPath);
Mockito.reset(command);
//create a runtime with a 'null' cgroups handler - i.e no //create a runtime with a 'null' cgroups handler - i.e no
// cgroup-based resource handlers are in use. // cgroup-based resource handlers are in use.
@ -1296,7 +1299,10 @@ public void testCGroupParent() throws ContainerExecutionException {
command); command);
//no --cgroup-parent should be added in either case //no --cgroup-parent should be added in either case
Mockito.verifyZeroInteractions(command); verifyZeroInteractions(command);
//Ensure no further interaction
Mockito.verifyNoMoreInteractions(command);
} }
@Test @Test

View File

@ -18,6 +18,7 @@
package org.apache.hadoop.yarn.server.nodemanager.containermanager.resourceplugin.com.nec; package org.apache.hadoop.yarn.server.nodemanager.containermanager.resourceplugin.com.nec;
import static org.apache.hadoop.test.MockitoUtil.verifyZeroInteractions;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame; import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
@ -25,7 +26,6 @@
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.anyString;

View File

@ -62,15 +62,10 @@
<artifactId>assertj-core</artifactId> <artifactId>assertj-core</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId> <artifactId>mockito-inline</artifactId>
<version>2.8.9</version> <version>4.11.0</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<!-- 'mvn dependency:analyze' fails to detect use of this dependency --> <!-- 'mvn dependency:analyze' fails to detect use of this dependency -->

View File

@ -16,6 +16,7 @@
package org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.converter; package org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.converter;
import static org.apache.hadoop.test.MockitoUtil.verifyZeroInteractions;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
@ -23,7 +24,6 @@
import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;

View File

@ -16,6 +16,7 @@
package org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.converter; package org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.converter;
import static org.apache.hadoop.test.MockitoUtil.verifyZeroInteractions;
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.converter.FSConfigToCSConfigRuleHandler.DYNAMIC_MAX_ASSIGN; import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.converter.FSConfigToCSConfigRuleHandler.DYNAMIC_MAX_ASSIGN;
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.converter.FSConfigToCSConfigRuleHandler.MAX_CAPACITY_PERCENTAGE; import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.converter.FSConfigToCSConfigRuleHandler.MAX_CAPACITY_PERCENTAGE;
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.converter.FSConfigToCSConfigRuleHandler.MAX_CHILD_CAPACITY; import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.converter.FSConfigToCSConfigRuleHandler.MAX_CHILD_CAPACITY;
@ -36,7 +37,6 @@
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.File; import java.io.File;

View File

@ -15,13 +15,13 @@
*/ */
package org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.converter; package org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.converter;
import static org.apache.hadoop.test.MockitoUtil.verifyZeroInteractions;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
import java.util.List; import java.util.List;

View File

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

View File

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

View File

@ -57,7 +57,7 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId> <artifactId>mockito-inline</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<!-- 'mvn dependency:analyze' fails to detect use of this dependency --> <!-- 'mvn dependency:analyze' fails to detect use of this dependency -->

View File

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

View File

@ -58,8 +58,8 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId> <artifactId>mockito-inline</artifactId>
<version>2.8.9</version> <version>4.11.0</version>
<scope>test</scope> <scope>test</scope>
<exclusions> <exclusions>
<exclusion> <exclusion>
@ -71,25 +71,45 @@
<dependency> <dependency>
<groupId>org.powermock</groupId> <groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId> <artifactId>powermock-api-mockito2</artifactId>
<version>1.7.1</version> <version>2.0.9</version>
<scope>test</scope> <scope>test</scope>
<exclusions> <exclusions>
<exclusion> <exclusion>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId> <artifactId>mockito-core</artifactId>
</exclusion> </exclusion>
<exclusion>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
</exclusion>
<exclusion>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy-agent</artifactId>
</exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.powermock</groupId> <groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId> <artifactId>powermock-module-junit4</artifactId>
<version>1.7.1</version> <version>2.0.9</version>
<scope>test</scope> <scope>test</scope>
<exclusions> <exclusions>
<exclusion>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
</exclusion>
<exclusion> <exclusion>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId> <artifactId>mockito-core</artifactId>
</exclusion> </exclusion>
<exclusion>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
</exclusion>
<exclusion>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy-agent</artifactId>
</exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -27,11 +27,13 @@
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.ArgumentMatchers;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mockStatic;
import static org.mockito.Mockito.when;
/** /**
* Test case for ${@link DocumentStoreCollectionCreator}. * Test case for ${@link DocumentStoreCollectionCreator}.
*/ */
@ -51,9 +53,8 @@ public void setUp() throws YarnException {
"https://localhost:443"); "https://localhost:443");
conf.set(DocumentStoreUtils.TIMELINE_SERVICE_COSMOSDB_MASTER_KEY, conf.set(DocumentStoreUtils.TIMELINE_SERVICE_COSMOSDB_MASTER_KEY,
"1234567"); "1234567");
PowerMockito.mockStatic(DocumentStoreFactory.class); mockStatic(DocumentStoreFactory.class);
PowerMockito.when(DocumentStoreFactory.createDocumentStoreWriter( when(DocumentStoreFactory.createDocumentStoreWriter(any(Configuration.class)))
ArgumentMatchers.any(Configuration.class)))
.thenReturn(documentStoreWriter); .thenReturn(documentStoreWriter);
} }

View File

@ -37,12 +37,16 @@
import org.apache.hadoop.yarn.server.timelineservice.storage.TimelineReader; import org.apache.hadoop.yarn.server.timelineservice.storage.TimelineReader;
import org.apache.hadoop.yarn.server.timelineservice.documentstore.collection.document.TimelineDocument; import org.apache.hadoop.yarn.server.timelineservice.documentstore.collection.document.TimelineDocument;
import org.apache.hadoop.yarn.server.timelineservice.documentstore.collection.document.entity.TimelineEntityDocument; import org.apache.hadoop.yarn.server.timelineservice.documentstore.collection.document.entity.TimelineEntityDocument;
import org.junit.After;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.ArgumentMatchers; import org.mockito.ArgumentMatchers;
import org.powermock.api.mockito.PowerMockito; import org.mockito.MockedStatic;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
@ -51,6 +55,8 @@
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import static org.mockito.Mockito.mockStatic;
import static org.mockito.Mockito.when;
/** /**
* Test case for {@link DocumentStoreTimelineReaderImpl}. * Test case for {@link DocumentStoreTimelineReaderImpl}.
@ -76,6 +82,8 @@ public class TestDocumentStoreTimelineReaderImpl {
public TestDocumentStoreTimelineReaderImpl() throws IOException { public TestDocumentStoreTimelineReaderImpl() throws IOException {
} }
private MockedStatic<DocumentStoreFactory> documentStoreFactoryMockedStatic;
@Before @Before
public void setUp() throws YarnException { public void setUp() throws YarnException {
conf.set(DocumentStoreUtils.TIMELINE_SERVICE_DOCUMENTSTORE_DATABASE_NAME, conf.set(DocumentStoreUtils.TIMELINE_SERVICE_DOCUMENTSTORE_DATABASE_NAME,
@ -84,12 +92,17 @@ public void setUp() throws YarnException {
"https://localhost:443"); "https://localhost:443");
conf.set(DocumentStoreUtils.TIMELINE_SERVICE_COSMOSDB_MASTER_KEY, conf.set(DocumentStoreUtils.TIMELINE_SERVICE_COSMOSDB_MASTER_KEY,
"1234567"); "1234567");
PowerMockito.mockStatic(DocumentStoreFactory.class); documentStoreFactoryMockedStatic = mockStatic(DocumentStoreFactory.class);
PowerMockito.when(DocumentStoreFactory.createDocumentStoreReader( when(DocumentStoreFactory.createDocumentStoreReader(
ArgumentMatchers.any(Configuration.class))) ArgumentMatchers.any(Configuration.class)))
.thenReturn(documentStoreReader); .thenReturn(documentStoreReader);
} }
@After
public void close() {
documentStoreFactoryMockedStatic.close();
}
@Test(expected = YarnException.class) @Test(expected = YarnException.class)
public void testFailOnNoCosmosDBConfigs() throws Exception { public void testFailOnNoCosmosDBConfigs() throws Exception {
DocumentStoreUtils.validateCosmosDBConf(new Configuration()); DocumentStoreUtils.validateCosmosDBConf(new Configuration());

View File

@ -27,10 +27,16 @@
import org.apache.hadoop.yarn.server.timelineservice.documentstore.collection.document.TimelineDocument; import org.apache.hadoop.yarn.server.timelineservice.documentstore.collection.document.TimelineDocument;
import org.apache.hadoop.yarn.server.timelineservice.documentstore.writer.DocumentStoreWriter; import org.apache.hadoop.yarn.server.timelineservice.documentstore.writer.DocumentStoreWriter;
import org.apache.hadoop.yarn.server.timelineservice.documentstore.writer.DummyDocumentStoreWriter; import org.apache.hadoop.yarn.server.timelineservice.documentstore.writer.DummyDocumentStoreWriter;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.ArgumentMatchers; import org.mockito.ArgumentMatchers;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
import org.powermock.api.mockito.PowerMockito; import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
@ -45,6 +51,7 @@ public class TestDocumentStoreTimelineWriterImpl {
private final DocumentStoreWriter<TimelineDocument> documentStoreWriter = new private final DocumentStoreWriter<TimelineDocument> documentStoreWriter = new
DummyDocumentStoreWriter<>(); DummyDocumentStoreWriter<>();
private final Configuration conf = new Configuration(); private final Configuration conf = new Configuration();
private MockedStatic<DocumentStoreFactory> mockedFactory;
@Before @Before
public void setUp() throws YarnException { public void setUp() throws YarnException {
@ -54,10 +61,17 @@ public void setUp() throws YarnException {
"https://localhost:443"); "https://localhost:443");
conf.set(DocumentStoreUtils.TIMELINE_SERVICE_COSMOSDB_MASTER_KEY, conf.set(DocumentStoreUtils.TIMELINE_SERVICE_COSMOSDB_MASTER_KEY,
"1234567"); "1234567");
PowerMockito.mockStatic(DocumentStoreFactory.class); mockedFactory = Mockito.mockStatic(DocumentStoreFactory.class);
PowerMockito.when(DocumentStoreFactory.createDocumentStoreWriter( mockedFactory.when(() -> DocumentStoreFactory.createDocumentStoreWriter(
ArgumentMatchers.any(Configuration.class))) ArgumentMatchers.any(Configuration.class)))
.thenReturn(documentStoreWriter); .thenReturn(documentStoreWriter);
}
@After
public void tearDown() {
if (mockedFactory != null) {
mockedFactory.close();
}
} }
@Test(expected = YarnException.class) @Test(expected = YarnException.class)

View File

@ -31,6 +31,9 @@
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
import static org.mockito.Mockito.mockStatic;
import static org.mockito.Mockito.when;
/** /**
* Test case for {@link CosmosDBDocumentStoreReader}. * Test case for {@link CosmosDBDocumentStoreReader}.
*/ */
@ -42,13 +45,10 @@ public class TestCosmosDBDocumentStoreReader {
public void setUp(){ public void setUp(){
AsyncDocumentClient asyncDocumentClient = AsyncDocumentClient asyncDocumentClient =
Mockito.mock(AsyncDocumentClient.class); Mockito.mock(AsyncDocumentClient.class);
PowerMockito.mockStatic(DocumentStoreUtils.class); Configuration conf = Mockito.mock(Configuration.class);
PowerMockito.when(DocumentStoreUtils.getCosmosDBDatabaseName( mockStatic(DocumentStoreUtils.class);
ArgumentMatchers.any(Configuration.class))) when(DocumentStoreUtils.getCosmosDBDatabaseName(conf)).thenReturn("FooBar");
.thenReturn("FooBar"); when(DocumentStoreUtils.createCosmosDBAsyncClient(conf)).thenReturn(asyncDocumentClient);
PowerMockito.when(DocumentStoreUtils.createCosmosDBAsyncClient(
ArgumentMatchers.any(Configuration.class)))
.thenReturn(asyncDocumentClient);
} }
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)

View File

@ -28,14 +28,15 @@
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.ArgumentMatchers;
import org.mockito.Mockito; import org.mockito.Mockito;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
import java.io.IOException; import java.io.IOException;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.mockStatic;
/** /**
* Test case for {@link CosmosDBDocumentStoreWriter}. * Test case for {@link CosmosDBDocumentStoreWriter}.
*/ */
@ -47,13 +48,12 @@ public class TestCosmosDBDocumentStoreWriter {
public void setUp() { public void setUp() {
AsyncDocumentClient asyncDocumentClient = AsyncDocumentClient asyncDocumentClient =
Mockito.mock(AsyncDocumentClient.class); Mockito.mock(AsyncDocumentClient.class);
PowerMockito.mockStatic(DocumentStoreUtils.class); Configuration conf = Mockito.mock(Configuration.class);
PowerMockito.when(DocumentStoreUtils.getCosmosDBDatabaseName( mockStatic(DocumentStoreUtils.class);
ArgumentMatchers.any(Configuration.class))) when(DocumentStoreUtils.getCosmosDBDatabaseName(conf)).
.thenReturn("FooBar"); thenReturn("FooBar");
PowerMockito.when(DocumentStoreUtils.createCosmosDBAsyncClient( when(DocumentStoreUtils.createCosmosDBAsyncClient(conf)).
ArgumentMatchers.any(Configuration.class))) thenReturn(asyncDocumentClient);
.thenReturn(asyncDocumentClient);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")

View File

@ -446,7 +446,7 @@
<!-- This is needed by HBaseTestingUtility --> <!-- This is needed by HBaseTestingUtility -->
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId> <artifactId>mockito-inline</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>

View File

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

View File

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

View File

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

View File

@ -274,8 +274,8 @@
<!-- TODO: Remove this dependency after upgrading wro4j-maven-plugin to 1.8.1 or later. --> <!-- TODO: Remove this dependency after upgrading wro4j-maven-plugin to 1.8.1 or later. -->
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId> <artifactId>mockito-inline</artifactId>
<version>2.18.0</version> <version>4.11.0</version>
</dependency> </dependency>
</dependencies> </dependencies>
<executions> <executions>