use of org.opendaylight.netconf.sal.connect.util.RemoteDeviceId in project netconf by opendaylight.
the class YangLibrarySchemaYangSourceProviderTest method setUp.
@Before
public void setUp() throws Exception {
final URL url = getClass().getResource("/schemas/config-test-rpc.yang");
workingSid = RevisionSourceIdentifier.create("abc", Optional.empty());
final Map<SourceIdentifier, URL> sourceIdentifierURLMap = Collections.singletonMap(workingSid, url);
final RemoteDeviceId id = new RemoteDeviceId("id", new InetSocketAddress("localhost", 22));
yangLibrarySchemaYangSourceProvider = new YangLibrarySchemaYangSourceProvider(id, sourceIdentifierURLMap);
}
use of org.opendaylight.netconf.sal.connect.util.RemoteDeviceId in project netconf by opendaylight.
the class SchemalessNetconfDeviceTest method testSessionOnMethods.
@Test
public void testSessionOnMethods() throws Exception {
final RemoteDeviceHandler<NetconfSessionPreferences> facade = getFacade();
final NetconfDeviceCommunicator listener = mockCloseableClass(NetconfDeviceCommunicator.class);
final SchemalessMessageTransformer messageTransformer = mock(SchemalessMessageTransformer.class);
final RemoteDeviceId remoteDeviceId = new RemoteDeviceId("test-D", InetSocketAddress.createUnresolved("localhost", 22));
final Throwable throwable = new Throwable();
final SchemalessNetconfDevice device = new SchemalessNetconfDevice(BASE_SCHEMAS, remoteDeviceId, facade, messageTransformer);
final NetconfSessionPreferences sessionCaps = getSessionCaps(true, Lists.newArrayList(TEST_NAMESPACE + "?module=" + TEST_MODULE + "&revision=" + TEST_REVISION));
final NetconfMessage netconfMessage = mock(NetconfMessage.class);
device.onRemoteSessionUp(sessionCaps, listener);
verify(facade).onDeviceConnected(any(MountPointContext.class), any(NetconfSessionPreferences.class), any(DOMRpcService.class));
device.onNotification(netconfMessage);
verify(facade).onNotification(isNull());
device.onRemoteSessionDown();
verify(facade).onDeviceDisconnected();
device.onRemoteSessionFailed(throwable);
verify(facade).onDeviceFailed(throwable);
}
use of org.opendaylight.netconf.sal.connect.util.RemoteDeviceId in project netconf by opendaylight.
the class NetconfDeviceCommunicatorTest method testNetconfDeviceReconnectInCommunicator.
/**
* Test whether reconnect is scheduled properly.
*/
@Test
public void testNetconfDeviceReconnectInCommunicator() {
final RemoteDevice<NetconfSessionPreferences, NetconfMessage, NetconfDeviceCommunicator> device = mock(RemoteDevice.class);
final TimedReconnectStrategy timedReconnectStrategy = 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();
}
});
final EventLoopGroup group = new NioEventLoopGroup();
final Timer time = new HashedWheelTimer();
try {
final NetconfDeviceCommunicator listener = new NetconfDeviceCommunicator(new RemoteDeviceId("test", InetSocketAddress.createUnresolved("localhost", 22)), device, 10);
final NetconfReconnectingClientConfiguration cfg = NetconfReconnectingClientConfigurationBuilder.create().withAddress(new InetSocketAddress("localhost", 65000)).withReconnectStrategy(reconnectStrategy).withConnectStrategyFactory(() -> reconnectStrategy).withAuthHandler(new LoginPasswordHandler("admin", "admin")).withConnectionTimeoutMillis(10000).withProtocol(NetconfClientConfiguration.NetconfClientProtocol.SSH).withSessionListener(listener).build();
listener.initializeRemoteConnection(new NetconfClientDispatcherImpl(group, group, time), cfg);
verify(reconnectStrategy, timeout(TimeUnit.MINUTES.toMillis(4)).times(101)).scheduleReconnect(any(Throwable.class));
} finally {
time.stop();
group.shutdownGracefully();
}
}
use of org.opendaylight.netconf.sal.connect.util.RemoteDeviceId in project netconf by opendaylight.
the class NetconfDataTreeServiceImplTest method getNetconService.
private AbstractNetconfDataTreeService getNetconService() {
NetconfSessionPreferences prefs = NetconfSessionPreferences.fromStrings(Collections.singletonList(NetconfMessageTransformUtil.NETCONF_CANDIDATE_URI.toString()));
final RemoteDeviceId id = new RemoteDeviceId("device-1", InetSocketAddress.createUnresolved("localhost", 17830));
return AbstractNetconfDataTreeService.of(id, new EmptyMountPointContext(SCHEMA_CONTEXT), rpcService, prefs);
}
use of org.opendaylight.netconf.sal.connect.util.RemoteDeviceId in project netconf by opendaylight.
the class NetconfDeviceSalFacadeTest method setUp.
@Before
public void setUp() throws Exception {
final InetSocketAddress address = new InetSocketAddress("127.0.0.1", 8000);
final RemoteDeviceId remoteDeviceId = new RemoteDeviceId("test", address);
deviceFacade = new NetconfDeviceSalFacade(remoteDeviceId, salProvider, dataBroker, "mockTopo");
doReturn(netconfDeviceTopologyAdapter).when(salProvider).getTopologyDatastoreAdapter();
doNothing().when(netconfDeviceTopologyAdapter).updateDeviceData(any(Boolean.class), any(NetconfDeviceCapabilities.class));
doReturn(mountInstance).when(salProvider).getMountInstance();
doNothing().when(mountInstance).onTopologyDeviceDisconnected();
}
Aggregations