diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestObserverReadProxyProvider.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestObserverReadProxyProvider.java index e3c1a0388b..2c69a102ca 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestObserverReadProxyProvider.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestObserverReadProxyProvider.java @@ -46,7 +46,6 @@ import org.junit.BeforeClass; import org.junit.Test; import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import org.slf4j.event.Level; @@ -59,8 +58,8 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyLong; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.when; @@ -367,8 +366,10 @@ public void testGetHAServiceStateWithTimeout() throws Exception { setupProxyProvider(1, NAMENODE_HA_STATE_PROBE_TIMEOUT_SHORT); final HAServiceState state = HAServiceState.STANDBY; + @SuppressWarnings("unchecked") NNProxyInfo dummyNNProxyInfo = (NNProxyInfo) mock(NNProxyInfo.class); + @SuppressWarnings("unchecked") Future task = mock(Future.class); when(task.get(anyLong(), any(TimeUnit.class))).thenReturn(state); @@ -389,8 +390,10 @@ public void testTimeoutExceptionGetHAServiceStateWithTimeout() throws Exception proxyLog.clearOutput(); setupProxyProvider(1, NAMENODE_HA_STATE_PROBE_TIMEOUT_SHORT); + @SuppressWarnings("unchecked") NNProxyInfo dummyNNProxyInfo = (NNProxyInfo) Mockito.mock(NNProxyInfo.class); + @SuppressWarnings("unchecked") Future task = mock(Future.class); TimeoutException e = new TimeoutException("Timeout"); when(task.get(anyLong(), any(TimeUnit.class))).thenThrow(e); @@ -413,8 +416,10 @@ public void testInterruptedExceptionGetHAServiceStateWithTimeout() throws Except proxyLog.clearOutput(); setupProxyProvider(1, NAMENODE_HA_STATE_PROBE_TIMEOUT_SHORT); + @SuppressWarnings("unchecked") NNProxyInfo dummyNNProxyInfo = (NNProxyInfo) Mockito.mock(NNProxyInfo.class); + @SuppressWarnings("unchecked") Future task = mock(Future.class); InterruptedException e = new InterruptedException("Interrupted"); when(task.get(anyLong(), any(TimeUnit.class))).thenThrow(e); @@ -436,8 +441,10 @@ public void testExecutionExceptionGetHAServiceStateWithTimeout() throws Exceptio proxyLog.clearOutput(); setupProxyProvider(1, NAMENODE_HA_STATE_PROBE_TIMEOUT_SHORT); + @SuppressWarnings("unchecked") NNProxyInfo dummyNNProxyInfo = (NNProxyInfo) Mockito.mock(NNProxyInfo.class); + @SuppressWarnings("unchecked") Future task = mock(Future.class); Exception e = new ExecutionException(new InterruptedException("Interrupted")); when(task.get(anyLong(), any(TimeUnit.class))).thenThrow(e); @@ -452,7 +459,7 @@ public void testExecutionExceptionGetHAServiceStateWithTimeout() throws Exceptio } /** - * Test GetHAServiceState when timeout is disabled (test the else { task.get() } code path) + * Test GetHAServiceState when timeout is disabled (test the else { task.get() } code path). */ @Test public void testGetHAServiceStateWithoutTimeout() throws Exception { @@ -460,8 +467,10 @@ public void testGetHAServiceStateWithoutTimeout() throws Exception { setupProxyProvider(1, 0); final HAServiceState state = HAServiceState.STANDBY; + @SuppressWarnings("unchecked") NNProxyInfo dummyNNProxyInfo = (NNProxyInfo) mock(NNProxyInfo.class); + @SuppressWarnings("unchecked") Future task = mock(Future.class); when(task.get()).thenReturn(state);