- protected NetconfServerDispatcher createDispatcher(
- NetconfOperationServiceFactoryListenerImpl factoriesListener, SessionMonitoringService sessionMonitoringService,
- DefaultCommitNotificationProducer commitNotifier) {
- SessionIdProvider idProvider = new SessionIdProvider();
+ private void loadMessages() throws Exception {
+ this.getConfig = XmlFileLoader.xmlFileToNetconfMessage("netconfMessages/getConfig.xml");
+ this.get = XmlFileLoader.xmlFileToNetconfMessage("netconfMessages/get.xml");
+ }
+
+ public NetconfMessage getGetConfig() {
+ return getConfig;
+ }
+
+ public NetconfMessage getGet() {
+ return get;
+ }
+
+ private Channel startNetconfTcpServer(final NetconfOperationServiceFactoryListenerImpl factoriesListener) throws Exception {
+ final NetconfServerDispatcher dispatch = createDispatcher(factoriesListener, getNetconfMonitoringService(), getNotificationProducer());
+
+ final ChannelFuture s;
+ if(getTcpServerAddress() instanceof LocalAddress) {
+ s = dispatch.createLocalServer(((LocalAddress) getTcpServerAddress()));
+ } else {
+ s = dispatch.createServer(((InetSocketAddress) getTcpServerAddress()));
+ }
+ s.await();
+ return s.channel();
+ }
+
+ protected DefaultCommitNotificationProducer getNotificationProducer() {
+ final DefaultCommitNotificationProducer notificationProducer = mock(DefaultCommitNotificationProducer.class);
+ doNothing().when(notificationProducer).close();
+ doNothing().when(notificationProducer).sendCommitNotification(anyString(), any(Element.class), anySetOf(String.class));
+ return notificationProducer;
+ }
+
+ protected Iterable<NetconfOperationServiceFactory> getAdditionalServiceFactories() {
+ return Collections.emptySet();
+ }
+
+ protected SessionMonitoringService getNetconfMonitoringService() throws Exception {
+ final NetconfOperationProvider netconfOperationProvider = mock(NetconfOperationProvider.class);
+ final NetconfOperationServiceSnapshotImpl snap = mock(NetconfOperationServiceSnapshotImpl.class);
+ doReturn(Collections.<NetconfOperationService>emptySet()).when(snap).getServices();
+ doReturn(snap).when(netconfOperationProvider).openSnapshot(anyString());
+ return new NetconfMonitoringServiceImpl(netconfOperationProvider);
+ }
+
+ protected abstract SocketAddress getTcpServerAddress();
+
+ public NetconfClientDispatcherImpl getClientDispatcher() {
+ return clientDispatcher;
+ }