+
+ public static void main(String[] args) throws Exception {
+ HashedWheelTimer hashedWheelTimer = new HashedWheelTimer();
+ NioEventLoopGroup nettyGroup = new NioEventLoopGroup();
+ NetconfClientDispatcherImpl netconfClientDispatcher = new NetconfClientDispatcherImpl(nettyGroup, nettyGroup, hashedWheelTimer);
+ LoginPassword authHandler = new LoginPassword("admin", "admin");
+ TestingNetconfClient client = new TestingNetconfClient("client", netconfClientDispatcher, getClientConfig("127.0.0.1", 1830, true, Optional.of(authHandler)));
+ System.out.println(client.getCapabilities());
+ }
+
+ private static NetconfClientConfiguration getClientConfig(String host ,int port, boolean ssh, Optional<? extends AuthenticationHandler> maybeAuthHandler) throws UnknownHostException {
+ InetSocketAddress netconfAddress = new InetSocketAddress(InetAddress.getByName(host), port);
+ final NetconfClientConfigurationBuilder b = NetconfClientConfigurationBuilder.create();
+ b.withAddress(netconfAddress);
+ b.withSessionListener(new SimpleNetconfClientSessionListener());
+ b.withReconnectStrategy(new NeverReconnectStrategy(GlobalEventExecutor.INSTANCE,
+ NetconfClientConfigurationBuilder.DEFAULT_CONNECTION_TIMEOUT_MILLIS));
+ if (ssh) {
+ b.withProtocol(NetconfClientProtocol.SSH);
+ b.withAuthHandler(maybeAuthHandler.get());
+ } else {
+ b.withProtocol(NetconfClientProtocol.TCP);
+ }
+ return b.build();
+ }
+}