+
+ loadMessages();
+
+ setUpTestInitial();
+
+ final AggregatedNetconfOperationServiceFactory factoriesListener = new AggregatedNetconfOperationServiceFactory();
+ final NetconfMonitoringService netconfMonitoringService = getNetconfMonitoringService(factoriesListener);
+ configSubsystemFacadeFactory = new ConfigSubsystemFacadeFactory(configRegistryClient, configRegistryClient, getYangStore());
+ factoriesListener.onAddNetconfOperationServiceFactory(new NetconfOperationServiceFactoryImpl(configSubsystemFacadeFactory));
+ factoriesListener.onAddNetconfOperationServiceFactory(new NetconfMonitoringActivator.NetconfMonitoringOperationServiceFactory(new NetconfMonitoringOperationService(netconfMonitoringService)));
+
+ for (final NetconfOperationServiceFactory netconfOperationServiceFactory : getAdditionalServiceFactories(factoriesListener)) {
+ factoriesListener.onAddNetconfOperationServiceFactory(netconfOperationServiceFactory);
+ }
+
+ serverTcpChannel = startNetconfTcpServer(factoriesListener, netconfMonitoringService);
+ clientDispatcher = new NetconfClientDispatcherImpl(getNettyThreadgroup(), getNettyThreadgroup(), getHashedWheelTimer());
+ }
+
+ /**
+ * Called before setUp method is executed, so test classes can set up resources before setUpAbstractNetconfConfigTest method is called.
+ */
+ protected void setUpTestInitial() throws Exception {}
+
+ 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 AggregatedNetconfOperationServiceFactory listener, final NetconfMonitoringService monitoring) throws Exception {
+ final NetconfServerDispatcherImpl dispatch = createDispatcher(listener, monitoring);
+
+ final ChannelFuture s;
+ if(getTcpServerAddress() instanceof LocalAddress) {
+ s = dispatch.createLocalServer(((LocalAddress) getTcpServerAddress()));
+ } else {
+ s = dispatch.createServer(((InetSocketAddress) getTcpServerAddress()));
+ }
+ s.await(RESOURCE_TIMEOUT_MINUTES, TimeUnit.MINUTES);
+ return s.channel();
+ }
+
+ protected Iterable<NetconfOperationServiceFactory> getAdditionalServiceFactories(final AggregatedNetconfOperationServiceFactory factoriesListener) throws Exception {
+ return Collections.emptySet();
+ }
+
+ protected NetconfMonitoringService getNetconfMonitoringService(final AggregatedNetconfOperationServiceFactory factoriesListener) throws Exception {
+ return new NetconfMonitoringServiceImpl(factoriesListener);
+ }
+
+ protected abstract SocketAddress getTcpServerAddress();
+
+ public NetconfClientDispatcherImpl getClientDispatcher() {
+ return clientDispatcher;