+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testReadTimeout() throws Exception {
+ final ListenableFuture<DOMRpcResult> future = mock(ListenableFuture.class);
+
+ Mockito.when(future.get(Mockito.anyLong(), any(TimeUnit.class))).then(new Answer<DOMRpcResult>() {
+ @Override
+ public DOMRpcResult answer(InvocationOnMock invocation)
+ throws Throwable {
+ throw new TimeoutException("Processing Timeout");
+ }
+ });
+
+ final NetconfBaseOps netconfOps = PowerMockito.mock(NetconfBaseOps.class);
+ Mockito.when(netconfOps.getConfigRunning(any(FutureCallback.class), any(Optional.class))).thenReturn(future);
+
+
+ final ReadOnlyTx readOnlyTx = new ReadOnlyTx(netconfOps, new RemoteDeviceId("a", new InetSocketAddress("localhost", 196)), 100L);
+ Assert.assertNull("Read operation didn't correctly timeout", readOnlyTx.read(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.create()));
+ readOnlyTx.close();
+ }