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:
parent
51ebc3c20e
commit
f7651e2f63
@ -407,7 +407,7 @@
|
||||
<!-- Add back in Mockito since the hadoop-hdfs test jar needs it. -->
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<!-- Add back in the transitive dependencies excluded from hadoop-common in client TODO remove once we have a filter for "is in these artifacts" -->
|
||||
@ -765,7 +765,7 @@
|
||||
|
||||
<!-- Mockito tries to include its own unrelocated copy of hamcrest. :( -->
|
||||
<filter>
|
||||
<artifact>org.mockito:mockito-core</artifact>
|
||||
<artifact>org.mockito:mockito-inline</artifact>
|
||||
<excludes>
|
||||
<exclude>asm-license.txt</exclude>
|
||||
<exclude>cglib-license.txt</exclude>
|
||||
@ -777,6 +777,15 @@
|
||||
<exclude>org/objenesis/*.class</exclude>
|
||||
</excludes>
|
||||
</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. -->
|
||||
<filter>
|
||||
<artifact>org.glassfish.grizzly:grizzly-http-servlet</artifact>
|
||||
|
@ -173,15 +173,27 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.powermock</groupId>
|
||||
<artifactId>powermock-api-mockito</artifactId>
|
||||
<version>1.7.4</version>
|
||||
<artifactId>powermock-api-mockito2</artifactId>
|
||||
<version>2.0.9</version>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.powermock</groupId>
|
||||
<artifactId>powermock-module-junit4</artifactId>
|
||||
<version>1.7.4</version>
|
||||
<version>2.0.9</version>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
@ -49,6 +49,7 @@
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>4.11.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -251,7 +251,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -35,6 +35,8 @@
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import static org.apache.hadoop.test.MockitoUtil.verifyZeroInteractions;
|
||||
|
||||
/**
|
||||
* This is intended to be a set of unit tests for the
|
||||
* org.apache.hadoop.ipc.Server class.
|
||||
|
@ -36,6 +36,8 @@
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import static org.apache.hadoop.test.MockitoUtil.verifyZeroInteractions;
|
||||
|
||||
public class TestCrossOriginFilter {
|
||||
|
||||
@Test
|
||||
@ -59,7 +61,7 @@ public void testSameOrigin() throws ServletException, IOException {
|
||||
filter.init(filterConfig);
|
||||
filter.doFilter(mockReq, mockRes, mockChain);
|
||||
|
||||
Mockito.verifyZeroInteractions(mockRes);
|
||||
verifyZeroInteractions(mockRes);
|
||||
Mockito.verify(mockChain).doFilter(mockReq, mockRes);
|
||||
}
|
||||
|
||||
@ -224,7 +226,7 @@ public void testDisallowedOrigin() throws ServletException, IOException {
|
||||
filter.init(filterConfig);
|
||||
filter.doFilter(mockReq, mockRes, mockChain);
|
||||
|
||||
Mockito.verifyZeroInteractions(mockRes);
|
||||
verifyZeroInteractions(mockRes);
|
||||
Mockito.verify(mockChain).doFilter(mockReq, mockRes);
|
||||
}
|
||||
|
||||
@ -252,7 +254,7 @@ public void testDisallowedMethod() throws ServletException, IOException {
|
||||
filter.init(filterConfig);
|
||||
filter.doFilter(mockReq, mockRes, mockChain);
|
||||
|
||||
Mockito.verifyZeroInteractions(mockRes);
|
||||
verifyZeroInteractions(mockRes);
|
||||
Mockito.verify(mockChain).doFilter(mockReq, mockRes);
|
||||
}
|
||||
|
||||
@ -283,7 +285,7 @@ public void testDisallowedHeader() throws ServletException, IOException {
|
||||
filter.init(filterConfig);
|
||||
filter.doFilter(mockReq, mockRes, mockChain);
|
||||
|
||||
Mockito.verifyZeroInteractions(mockRes);
|
||||
verifyZeroInteractions(mockRes);
|
||||
Mockito.verify(mockChain).doFilter(mockReq, mockRes);
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,8 @@
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import static org.apache.hadoop.test.MockitoUtil.verifyZeroInteractions;
|
||||
|
||||
/**
|
||||
* This class tests the behavior of the RestCsrfPreventionFilter.
|
||||
*
|
||||
@ -75,7 +77,7 @@ public void testNoHeaderDefaultConfigBadRequest()
|
||||
|
||||
verify(mockRes, atLeastOnce()).sendError(
|
||||
HttpServletResponse.SC_BAD_REQUEST, EXPECTED_MESSAGE);
|
||||
Mockito.verifyZeroInteractions(mockChain);
|
||||
verifyZeroInteractions(mockChain);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -110,7 +112,7 @@ public void testNoHeaderCustomAgentConfigBadRequest()
|
||||
|
||||
verify(mockRes, atLeastOnce()).sendError(
|
||||
HttpServletResponse.SC_BAD_REQUEST, EXPECTED_MESSAGE);
|
||||
Mockito.verifyZeroInteractions(mockChain);
|
||||
verifyZeroInteractions(mockChain);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -228,7 +230,7 @@ public void testMissingHeaderWithCustomHeaderConfigBadRequest()
|
||||
filter.init(filterConfig);
|
||||
filter.doFilter(mockReq, mockRes, mockChain);
|
||||
|
||||
Mockito.verifyZeroInteractions(mockChain);
|
||||
verifyZeroInteractions(mockChain);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -260,7 +262,7 @@ public void testMissingHeaderNoMethodsToIgnoreConfigBadRequest()
|
||||
filter.init(filterConfig);
|
||||
filter.doFilter(mockReq, mockRes, mockChain);
|
||||
|
||||
Mockito.verifyZeroInteractions(mockChain);
|
||||
verifyZeroInteractions(mockChain);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -356,6 +358,6 @@ public void testMissingHeaderMultipleIgnoreMethodsConfigBadRequest()
|
||||
filter.init(filterConfig);
|
||||
filter.doFilter(mockReq, mockRes, mockChain);
|
||||
|
||||
Mockito.verifyZeroInteractions(mockChain);
|
||||
verifyZeroInteractions(mockChain);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -60,7 +60,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -66,7 +66,7 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -49,7 +49,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -69,7 +69,7 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -160,7 +160,7 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -164,7 +164,7 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -25,6 +25,7 @@
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@ -68,7 +69,6 @@
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.internal.util.reflection.FieldSetter;
|
||||
|
||||
/**
|
||||
* The administrator interface of the {@link Router} implemented by
|
||||
@ -118,18 +118,25 @@ public static void globalSetUp() throws Exception {
|
||||
* @throws IOException
|
||||
* @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 =
|
||||
Mockito.spy(routerContext.getRouter().createRpcServer());
|
||||
FieldSetter.setField(routerContext.getRouter(),
|
||||
Router.class.getDeclaredField("rpcServer"), spyRpcServer);
|
||||
//Used reflection to set the 'rpcServer field'
|
||||
setField(routerContext.getRouter(), "rpcServer", spyRpcServer);
|
||||
Mockito.doReturn(null).when(spyRpcServer).getFileInfo(Mockito.anyString());
|
||||
|
||||
// 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());
|
||||
FieldSetter.setField(spyRpcServer,
|
||||
RouterRpcServer.class.getDeclaredField("rpcClient"),
|
||||
mockRpcClient);
|
||||
setField(spyRpcServer, "rpcClient", mockRpcClient);
|
||||
RemoteLocation remoteLocation0 =
|
||||
new RemoteLocation("ns0", "/testdir", null);
|
||||
RemoteLocation remoteLocation1 =
|
||||
|
@ -24,7 +24,7 @@
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.apache.hadoop.test.Whitebox.getInternalState;
|
||||
|
@ -166,7 +166,7 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -253,9 +253,8 @@ static long toLong(long preferredBlockSize, long layoutRedundancy,
|
||||
|
||||
private BlockInfo[] blocks;
|
||||
|
||||
INodeFile(long id, byte[] name, PermissionStatus permissions, long mtime,
|
||||
long atime, BlockInfo[] blklist, short replication,
|
||||
long preferredBlockSize) {
|
||||
public INodeFile(long id, byte[] name, PermissionStatus permissions, long mtime, long atime,
|
||||
BlockInfo[] blklist, short replication, long preferredBlockSize) {
|
||||
this(id, name, permissions, mtime, atime, blklist, replication, null,
|
||||
preferredBlockSize, (byte) 0, CONTIGUOUS);
|
||||
}
|
||||
|
@ -365,6 +365,7 @@ public void testIncrementAndDecrementStripedSafeBlockCount() {
|
||||
for (long i = 1; i <= BLOCK_TOTAL; i++) {
|
||||
BlockInfoStriped blockInfo = mock(BlockInfoStriped.class);
|
||||
when(blockInfo.getRealDataBlockNum()).thenReturn(realDataBlockNum);
|
||||
when(blockInfo.isStriped()).thenReturn(true);
|
||||
|
||||
bmSafeMode.incrementSafeBlockCount(realDataBlockNum, blockInfo);
|
||||
bmSafeMode.decrementSafeBlockCount(blockInfo);
|
||||
|
@ -25,6 +25,7 @@
|
||||
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.test.GenericTestUtils.assertExceptionContains;
|
||||
import static org.apache.hadoop.test.MockitoUtil.verifyZeroInteractions;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
@ -1575,7 +1576,7 @@ public void testNoLookupsWhenNotUsed() throws Exception {
|
||||
CacheManager cm = cluster.getNamesystem().getCacheManager();
|
||||
LocatedBlocks locations = Mockito.mock(LocatedBlocks.class);
|
||||
cm.setCachedLocations(locations);
|
||||
Mockito.verifyZeroInteractions(locations);
|
||||
verifyZeroInteractions(locations);
|
||||
}
|
||||
|
||||
@Test(timeout=120000)
|
||||
|
@ -62,7 +62,6 @@ private FSNamesystem makeNameSystemSpy(Block block, INodeFile file)
|
||||
}
|
||||
namesystem.dir.getINodeMap().put(file);
|
||||
|
||||
FSNamesystem namesystemSpy = spy(namesystem);
|
||||
BlockInfo blockInfo = new BlockInfoContiguous(block, (short) 1);
|
||||
blockInfo.convertToBlockUnderConstruction(
|
||||
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(true).when(file).isUnderConstruction();
|
||||
doReturn(new BlockInfoContiguous[1]).when(file).getBlocks();
|
||||
|
||||
doReturn(blockInfo).when(namesystemSpy).getStoredBlock(any(Block.class));
|
||||
FSNamesystem namesystemSpy = spy(namesystem);
|
||||
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();
|
||||
doNothing().when(namesystemSpy).closeFileCommitBlocks(
|
||||
any(), any(INodeFile.class), any(BlockInfo.class));
|
||||
|
@ -28,9 +28,12 @@
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.Random;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.anyLong;
|
||||
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.hasWriteLock()).thenReturn(Boolean.TRUE);
|
||||
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);
|
||||
|
||||
return FSDirAttrOp.unprotectedSetTimes(fsd, iip, mtime, atime, force);
|
||||
|
@ -41,6 +41,8 @@
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import static org.apache.hadoop.test.MockitoUtil.verifyZeroInteractions;
|
||||
|
||||
/** Test snapshot related operations. */
|
||||
public class TestSnapshotPathINodes {
|
||||
private static final long seed = 0;
|
||||
@ -447,6 +449,6 @@ public void testShortCircuitSnapshotSearch() throws SnapshotException {
|
||||
INodesInPath iip = Mockito.mock(INodesInPath.class);
|
||||
List<INodeDirectory> snapDirs = new ArrayList<>();
|
||||
FSDirSnapshotOp.checkSnapshot(fsn.getFSDirectory(), iip, snapDirs);
|
||||
Mockito.verifyZeroInteractions(iip);
|
||||
verifyZeroInteractions(iip);
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,8 @@
|
||||
|
||||
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.BlockStoragePolicy;
|
||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo;
|
||||
@ -40,6 +42,7 @@
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.anyByte;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class TestFileWithSnapshotFeature {
|
||||
@ -60,7 +63,8 @@ public void testUpdateQuotaAndCollectBlocks() {
|
||||
BlockManager bm = mock(BlockManager.class);
|
||||
|
||||
// No snapshot
|
||||
INodeFile file = mock(INodeFile.class);
|
||||
INodeFile inodeFileObj = createMockFile(REPL_1);
|
||||
INodeFile file = spy(inodeFileObj);
|
||||
when(file.getFileWithSnapshotFeature()).thenReturn(sf);
|
||||
when(file.getBlocks()).thenReturn(blocks);
|
||||
when(file.getStoragePolicyID()).thenReturn((byte) 1);
|
||||
@ -97,6 +101,16 @@ public void testUpdateQuotaAndCollectBlocks() {
|
||||
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.
|
||||
*/
|
||||
@ -107,7 +121,8 @@ public void testUpdateQuotaDistinctBlocks() {
|
||||
BlockInfo[] blocks = new BlockInfo[] {
|
||||
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.getStoragePolicyID()).thenReturn((byte) 1);
|
||||
when(file.getPreferredBlockReplication()).thenReturn((short) 3);
|
||||
|
@ -45,7 +45,7 @@ protected void heartbeat() throws Exception {
|
||||
}
|
||||
}
|
||||
|
||||
@Test(timeout = 2000)
|
||||
@Test(timeout = 6000)
|
||||
public void testRMContainerAllocatorExceptionIsHandled() throws Exception {
|
||||
ClientService mockClientService = mock(ClientService.class);
|
||||
AppContext mockContext = mock(AppContext.class);
|
||||
|
@ -62,10 +62,10 @@
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyBoolean;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
@ -20,7 +20,6 @@
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
@ -35,6 +34,7 @@
|
||||
import org.apache.hadoop.mapred.YARNRunner;
|
||||
import org.apache.hadoop.mapreduce.protocol.ClientProtocol;
|
||||
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.protocolrecords.GetDelegationTokenRequest;
|
||||
import org.apache.hadoop.yarn.api.protocolrecords.GetDelegationTokenResponse;
|
||||
@ -105,7 +105,8 @@ public void testClusterGetDelegationToken() throws Exception {
|
||||
rmDTToken.setPassword(ByteBuffer.wrap("testcluster".getBytes()));
|
||||
rmDTToken.setService("0.0.0.0:8032");
|
||||
getDTResponse.setRMDelegationToken(rmDTToken);
|
||||
final ApplicationClientProtocol cRMProtocol = mock(ApplicationClientProtocol.class);
|
||||
final ApplicationClientProtocol cRMProtocol =
|
||||
MockitoUtil.mockProtocol(ApplicationClientProtocol.class);
|
||||
when(cRMProtocol.getDelegationToken(any(
|
||||
GetDelegationTokenRequest.class))).thenReturn(getDTResponse);
|
||||
ResourceMgrDelegate rmgrDelegate = new ResourceMgrDelegate(
|
||||
|
@ -96,6 +96,8 @@
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
|
||||
<version>4.11.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -227,7 +227,7 @@
|
||||
<junit.platform.version>1.8.2</junit.platform.version>
|
||||
<assertj.version>3.12.2</assertj.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>
|
||||
<openssl-wildfly.version>2.1.4.Final</openssl-wildfly.version>
|
||||
<jsonschema2pojo.version>1.0.2</jsonschema2pojo.version>
|
||||
@ -1350,8 +1350,8 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>2.28.2</version>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<version>4.11.0</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>log4j</groupId>
|
||||
|
@ -125,7 +125,7 @@
|
||||
<!-- 'mvn dependency:analyze' fails to detect use of this dependency -->
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- 'mvn dependency:analyze' fails to detect use of this dependency -->
|
||||
|
@ -41,7 +41,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -527,7 +527,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -323,6 +323,7 @@
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>4.11.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -66,7 +66,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -41,7 +41,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -106,7 +106,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -36,7 +36,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -80,7 +80,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -41,7 +41,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -41,7 +41,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -111,7 +111,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -69,7 +69,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -111,7 +111,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -589,7 +589,7 @@ public FakeFSDataInputStream(InputStream in) throws IOException {
|
||||
/*
|
||||
* test LoadRecordReader. It class reads data from some files.
|
||||
*/
|
||||
@Test (timeout=3000)
|
||||
@Test (timeout=6100)
|
||||
public void testLoadJobLoadRecordReader() throws Exception {
|
||||
LoadJob.LoadRecordReader test = new LoadJob.LoadRecordReader();
|
||||
Configuration conf = new Configuration();
|
||||
|
@ -111,7 +111,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -75,7 +75,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -42,7 +42,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -112,7 +112,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -46,8 +46,8 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-all</artifactId>
|
||||
<version>1.9.5</version>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>4.11.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@ -64,7 +64,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.powermock</groupId>
|
||||
<artifactId>powermock-api-mockito</artifactId>
|
||||
<artifactId>powermock-api-mockito2</artifactId>
|
||||
<version>${powermock.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
|
@ -22,18 +22,21 @@
|
||||
import org.apache.hadoop.yarn.appcatalog.model.AppStoreEntry;
|
||||
import org.apache.hadoop.yarn.appcatalog.model.Application;
|
||||
import org.apache.solr.client.solrj.SolrClient;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
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.support.membermodification.MemberMatcher.method;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Unit test for AppCatalogSolrClient.
|
||||
*/
|
||||
@ -51,7 +54,7 @@ public void setup() throws Exception {
|
||||
String solrHome = targetLocation.split("/test-classes")[0] + "/solr";
|
||||
solrClient = EmbeddedSolrServerFactory.create(solrHome, CONFIGSET_DIR,
|
||||
"exampleCollection");
|
||||
spy = PowerMockito.spy(new AppCatalogSolrClient());
|
||||
spy = Mockito.spy(new AppCatalogSolrClient());
|
||||
when(spy, method(AppCatalogSolrClient.class, "getSolrClient"))
|
||||
.withNoArguments().thenReturn(solrClient);
|
||||
}
|
||||
|
@ -119,7 +119,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -173,7 +173,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
@ -252,7 +252,7 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
@ -34,6 +34,7 @@
|
||||
import java.io.IOException;
|
||||
|
||||
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
|
||||
.DEFAULT_CONTAINER_FAILURES_VALIDITY_INTERVAL;
|
||||
import static org.apache.hadoop.yarn.service.conf.YarnServiceConf
|
||||
@ -43,7 +44,6 @@
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.reset;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
|
@ -81,7 +81,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -110,7 +110,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -55,7 +55,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- 'mvn dependency:analyze' fails to detect use of this dependency -->
|
||||
|
@ -98,7 +98,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -129,7 +129,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -42,13 +42,13 @@
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.apache.hadoop.test.MockitoUtil.verifyZeroInteractions;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
||||
|
||||
/**
|
||||
* Tests for the CGroups handler implementation.
|
||||
|
@ -37,8 +37,8 @@
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.apache.hadoop.test.MockitoUtil.verifyZeroInteractions;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
||||
|
||||
/**
|
||||
* Tests for the CGroups handler implementation.
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
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.util.resource.CustomResourceTypesConfigurationProvider.initResourceTypes;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@ -27,7 +28,6 @@
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -94,6 +94,7 @@
|
||||
import java.util.Set;
|
||||
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_RW_MOUNTS;
|
||||
import static org.apache.hadoop.yarn.conf.YarnConfiguration.NM_DOCKER_DEFAULT_TMPFS_MOUNTS;
|
||||
@ -1272,7 +1273,7 @@ public void testCGroupParent() throws ContainerExecutionException {
|
||||
command);
|
||||
|
||||
//no --cgroup-parent should be added here
|
||||
Mockito.verifyZeroInteractions(command);
|
||||
verifyZeroInteractions(command);
|
||||
|
||||
String resourceOptionsCpu = "/sys/fs/cgroup/cpu/" + hierarchy +
|
||||
containerIdStr;
|
||||
@ -1283,6 +1284,8 @@ public void testCGroupParent() throws ContainerExecutionException {
|
||||
String expectedPath = "/" + hierarchy + "/" + containerIdStr;
|
||||
Mockito.verify(command).setCGroupParent(expectedPath);
|
||||
|
||||
Mockito.reset(command);
|
||||
|
||||
//create a runtime with a 'null' cgroups handler - i.e no
|
||||
// cgroup-based resource handlers are in use.
|
||||
|
||||
@ -1296,7 +1299,10 @@ public void testCGroupParent() throws ContainerExecutionException {
|
||||
command);
|
||||
|
||||
//no --cgroup-parent should be added in either case
|
||||
Mockito.verifyZeroInteractions(command);
|
||||
verifyZeroInteractions(command);
|
||||
|
||||
//Ensure no further interaction
|
||||
Mockito.verifyNoMoreInteractions(command);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
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.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@ -25,7 +26,6 @@
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
|
@ -62,15 +62,10 @@
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<version>2.8.9</version>
|
||||
<version>4.11.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- 'mvn dependency:analyze' fails to detect use of this dependency -->
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
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.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@ -23,7 +24,6 @@
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
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.MAX_CAPACITY_PERCENTAGE;
|
||||
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.anyBoolean;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
|
@ -15,13 +15,13 @@
|
||||
*/
|
||||
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.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -128,7 +128,7 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
@ -51,7 +51,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -57,7 +57,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- 'mvn dependency:analyze' fails to detect use of this dependency -->
|
||||
|
@ -121,7 +121,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -58,8 +58,8 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>2.8.9</version>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<version>4.11.0</version>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
@ -71,25 +71,45 @@
|
||||
<dependency>
|
||||
<groupId>org.powermock</groupId>
|
||||
<artifactId>powermock-api-mockito2</artifactId>
|
||||
<version>1.7.1</version>
|
||||
<version>2.0.9</version>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>net.bytebuddy</groupId>
|
||||
<artifactId>byte-buddy</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>net.bytebuddy</groupId>
|
||||
<artifactId>byte-buddy-agent</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.powermock</groupId>
|
||||
<artifactId>powermock-module-junit4</artifactId>
|
||||
<version>1.7.1</version>
|
||||
<version>2.0.9</version>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>net.bytebuddy</groupId>
|
||||
<artifactId>byte-buddy</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>net.bytebuddy</groupId>
|
||||
<artifactId>byte-buddy-agent</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -27,11 +27,13 @@
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
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.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}.
|
||||
*/
|
||||
@ -51,9 +53,8 @@ public void setUp() throws YarnException {
|
||||
"https://localhost:443");
|
||||
conf.set(DocumentStoreUtils.TIMELINE_SERVICE_COSMOSDB_MASTER_KEY,
|
||||
"1234567");
|
||||
PowerMockito.mockStatic(DocumentStoreFactory.class);
|
||||
PowerMockito.when(DocumentStoreFactory.createDocumentStoreWriter(
|
||||
ArgumentMatchers.any(Configuration.class)))
|
||||
mockStatic(DocumentStoreFactory.class);
|
||||
when(DocumentStoreFactory.createDocumentStoreWriter(any(Configuration.class)))
|
||||
.thenReturn(documentStoreWriter);
|
||||
}
|
||||
|
||||
|
@ -37,12 +37,16 @@
|
||||
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.entity.TimelineEntityDocument;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.mockito.ArgumentMatchers;
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
import org.mockito.MockedStatic;
|
||||
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
@ -51,6 +55,8 @@
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.mockito.Mockito.mockStatic;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* Test case for {@link DocumentStoreTimelineReaderImpl}.
|
||||
@ -76,6 +82,8 @@ public class TestDocumentStoreTimelineReaderImpl {
|
||||
public TestDocumentStoreTimelineReaderImpl() throws IOException {
|
||||
}
|
||||
|
||||
private MockedStatic<DocumentStoreFactory> documentStoreFactoryMockedStatic;
|
||||
|
||||
@Before
|
||||
public void setUp() throws YarnException {
|
||||
conf.set(DocumentStoreUtils.TIMELINE_SERVICE_DOCUMENTSTORE_DATABASE_NAME,
|
||||
@ -84,12 +92,17 @@ public void setUp() throws YarnException {
|
||||
"https://localhost:443");
|
||||
conf.set(DocumentStoreUtils.TIMELINE_SERVICE_COSMOSDB_MASTER_KEY,
|
||||
"1234567");
|
||||
PowerMockito.mockStatic(DocumentStoreFactory.class);
|
||||
PowerMockito.when(DocumentStoreFactory.createDocumentStoreReader(
|
||||
documentStoreFactoryMockedStatic = mockStatic(DocumentStoreFactory.class);
|
||||
when(DocumentStoreFactory.createDocumentStoreReader(
|
||||
ArgumentMatchers.any(Configuration.class)))
|
||||
.thenReturn(documentStoreReader);
|
||||
}
|
||||
|
||||
@After
|
||||
public void close() {
|
||||
documentStoreFactoryMockedStatic.close();
|
||||
}
|
||||
|
||||
@Test(expected = YarnException.class)
|
||||
public void testFailOnNoCosmosDBConfigs() throws Exception {
|
||||
DocumentStoreUtils.validateCosmosDBConf(new Configuration());
|
||||
|
@ -27,10 +27,16 @@
|
||||
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.DummyDocumentStoreWriter;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.mockito.ArgumentMatchers;
|
||||
import org.mockito.MockedStatic;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
@ -45,6 +51,7 @@ public class TestDocumentStoreTimelineWriterImpl {
|
||||
private final DocumentStoreWriter<TimelineDocument> documentStoreWriter = new
|
||||
DummyDocumentStoreWriter<>();
|
||||
private final Configuration conf = new Configuration();
|
||||
private MockedStatic<DocumentStoreFactory> mockedFactory;
|
||||
|
||||
@Before
|
||||
public void setUp() throws YarnException {
|
||||
@ -54,10 +61,17 @@ public void setUp() throws YarnException {
|
||||
"https://localhost:443");
|
||||
conf.set(DocumentStoreUtils.TIMELINE_SERVICE_COSMOSDB_MASTER_KEY,
|
||||
"1234567");
|
||||
PowerMockito.mockStatic(DocumentStoreFactory.class);
|
||||
PowerMockito.when(DocumentStoreFactory.createDocumentStoreWriter(
|
||||
ArgumentMatchers.any(Configuration.class)))
|
||||
.thenReturn(documentStoreWriter);
|
||||
mockedFactory = Mockito.mockStatic(DocumentStoreFactory.class);
|
||||
mockedFactory.when(() -> DocumentStoreFactory.createDocumentStoreWriter(
|
||||
ArgumentMatchers.any(Configuration.class)))
|
||||
.thenReturn(documentStoreWriter);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
if (mockedFactory != null) {
|
||||
mockedFactory.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Test(expected = YarnException.class)
|
||||
|
@ -31,6 +31,9 @@
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import static org.mockito.Mockito.mockStatic;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* Test case for {@link CosmosDBDocumentStoreReader}.
|
||||
*/
|
||||
@ -42,13 +45,10 @@ public class TestCosmosDBDocumentStoreReader {
|
||||
public void setUp(){
|
||||
AsyncDocumentClient asyncDocumentClient =
|
||||
Mockito.mock(AsyncDocumentClient.class);
|
||||
PowerMockito.mockStatic(DocumentStoreUtils.class);
|
||||
PowerMockito.when(DocumentStoreUtils.getCosmosDBDatabaseName(
|
||||
ArgumentMatchers.any(Configuration.class)))
|
||||
.thenReturn("FooBar");
|
||||
PowerMockito.when(DocumentStoreUtils.createCosmosDBAsyncClient(
|
||||
ArgumentMatchers.any(Configuration.class)))
|
||||
.thenReturn(asyncDocumentClient);
|
||||
Configuration conf = Mockito.mock(Configuration.class);
|
||||
mockStatic(DocumentStoreUtils.class);
|
||||
when(DocumentStoreUtils.getCosmosDBDatabaseName(conf)).thenReturn("FooBar");
|
||||
when(DocumentStoreUtils.createCosmosDBAsyncClient(conf)).thenReturn(asyncDocumentClient);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
|
@ -28,14 +28,15 @@
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentMatchers;
|
||||
import org.mockito.Mockito;
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.mockito.Mockito.mockStatic;
|
||||
|
||||
/**
|
||||
* Test case for {@link CosmosDBDocumentStoreWriter}.
|
||||
*/
|
||||
@ -47,13 +48,12 @@ public class TestCosmosDBDocumentStoreWriter {
|
||||
public void setUp() {
|
||||
AsyncDocumentClient asyncDocumentClient =
|
||||
Mockito.mock(AsyncDocumentClient.class);
|
||||
PowerMockito.mockStatic(DocumentStoreUtils.class);
|
||||
PowerMockito.when(DocumentStoreUtils.getCosmosDBDatabaseName(
|
||||
ArgumentMatchers.any(Configuration.class)))
|
||||
.thenReturn("FooBar");
|
||||
PowerMockito.when(DocumentStoreUtils.createCosmosDBAsyncClient(
|
||||
ArgumentMatchers.any(Configuration.class)))
|
||||
.thenReturn(asyncDocumentClient);
|
||||
Configuration conf = Mockito.mock(Configuration.class);
|
||||
mockStatic(DocumentStoreUtils.class);
|
||||
when(DocumentStoreUtils.getCosmosDBDatabaseName(conf)).
|
||||
thenReturn("FooBar");
|
||||
when(DocumentStoreUtils.createCosmosDBAsyncClient(conf)).
|
||||
thenReturn(asyncDocumentClient);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@ -446,7 +446,7 @@
|
||||
<!-- This is needed by HBaseTestingUtility -->
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -170,7 +170,7 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
@ -148,7 +148,7 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -66,7 +66,7 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -274,8 +274,8 @@
|
||||
<!-- TODO: Remove this dependency after upgrading wro4j-maven-plugin to 1.8.1 or later. -->
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>2.18.0</version>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<version>4.11.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<executions>
|
||||
|
Loading…
Reference in New Issue
Block a user