import javax.xml.parsers.ParserConfigurationException;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.opendaylight.netconf.api.NetconfMessage;
import org.opendaylight.netconf.api.NetconfTerminationReason;
import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
+@RunWith(MockitoJUnitRunner.StrictStubs.class)
public class NetconfDeviceCommunicatorTest {
private static final Logger LOG = LoggerFactory.getLogger(NetconfDeviceCommunicatorTest.class);
@Before
public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
-
communicator = new NetconfDeviceCommunicator(
new RemoteDeviceId("test", InetSocketAddress.createUnresolved("localhost", 22)), mockDevice, 10);
}
verify(mockChannelFuture).addListener(futureListener.capture());
Future<Void> operationFuture = mock(Future.class);
doReturn(true).when(operationFuture).isSuccess();
- doReturn(true).when(operationFuture).isDone();
futureListener.getValue().operationComplete(operationFuture);
try {
Future<Void> operationFuture = mock(Future.class);
doReturn(false).when(operationFuture).isSuccess();
- doReturn(true).when(operationFuture).isDone();
doReturn(new Exception("mock error")).when(operationFuture).cause();
futureListener.getValue().operationComplete(operationFuture);
* Test whether reconnect is scheduled properly.
*/
@Test
- public void testNetconfDeviceReconnectInCommunicator() throws Exception {
+ public void testNetconfDeviceReconnectInCommunicator() {
final RemoteDevice<NetconfSessionPreferences, NetconfMessage, NetconfDeviceCommunicator> device =
mock(RemoteDevice.class);
new TimedReconnectStrategy(GlobalEventExecutor.INSTANCE, 10000, 0, 1.0, null, 100L, null);
final ReconnectStrategy reconnectStrategy = spy(new ReconnectStrategy() {
@Override
+ @Deprecated
public int getConnectTimeout() throws Exception {
return timedReconnectStrategy.getConnectTimeout();
}
@Override
+ @Deprecated
public Future<Void> scheduleReconnect(final Throwable cause) {
return timedReconnectStrategy.scheduleReconnect(cause);
}
@Override
+ @Deprecated
public void reconnectSuccessful() {
timedReconnectStrategy.reconnectSuccessful();
}
listener.initializeRemoteConnection(new NetconfClientDispatcherImpl(group, group, time), cfg);
verify(reconnectStrategy,
- timeout((int) TimeUnit.MINUTES.toMillis(3)).times(101)).scheduleReconnect(any(Throwable.class));
+ timeout(TimeUnit.MINUTES.toMillis(4)).times(101)).scheduleReconnect(any(Throwable.class));
} finally {
time.stop();
group.shutdownGracefully();