@Test public void testPmaServerContactsServerMessageListenerOnEdit() throws NetconfMessageBuilderException, IOException, SAXException { Map<NetConfResponse, List<Notification>> netConfResponseListMap = m_pmaServer.executeNetconf(m_editRequest); Map.Entry<NetConfResponse, List<Notification>> entry = netConfResponseListMap.entrySet().iterator().next(); NetConfResponse response = entry.getKey(); verify(m_netconfServer).onEditConfig(eq(PMA_USER), eq(m_editRequest), anyObject()); String expect = "<rpc-reply message-id=\"2\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" + " <data>\n" + " <ok/>\n" + " </data>\n" + "</rpc-reply>"; TestUtil.assertXMLEquals(DocumentUtils.stringToDocument(expect).getDocumentElement(), DocumentUtils.stringToDocument(response.responseToString().trim()).getDocumentElement()); verify(m_deviceDataStore).getDeviceXml(); }
@Override public Map<NetConfResponse, List<Notification>> executeNetconf(AbstractNetconfRequest request) { PmaServer.setCurrentDevice(m_device); PmaServer.setCurrentDeviceXmlStore(m_deviceStore); ThreadLocalDSMRegistry.setDsm(m_dsm); ThreadLocalSubsystemRegistry.setSubsystemRegistry(m_stdAdapterContext.getSubSystemRegistry()); ThreadLocalSchemaRegistry.setSchemaRegistry(m_stdAdapterContext.getSchemaRegistry()); m_netconfServer.getDataStore(StandardDataStores.RUNNING).setNamespaceContext(ThreadLocalSchemaRegistry.getRegistry()); ThreadLocalModelNodeHelperRegistry.setModelNodeHelperRegistry(m_stdAdapterContext.getModelNodeHelperRegistry()); ThreadLocalRootModelNodeAggregator.setRootAggregator(m_stdAdapterContext.getRootModelNodeAggregator()); if (request instanceof EditConfigRequest) { PmaServer.setBackupDeviceXmlStore(createBackUpStore(getDeviceStoreBackupFilePath(m_device.getDeviceName()))); } try { List<Notification> notifications = m_msgHandler.processRequest(PMA_USER, request, m_responseChannel); Map<NetConfResponse, List<Notification>> replyMap = new HashMap<>(); replyMap.put(m_responseChannel.getLastResponse(), notifications); return replyMap; } finally { ThreadLocalDSMRegistry.clearDsm(); ThreadLocalSchemaRegistry.clearRegistry(); ThreadLocalSubsystemRegistry.clearRegistry(); ThreadLocalModelNodeHelperRegistry.clearRegistry(); ThreadLocalRootModelNodeAggregator.clearRootAggregator(); PmaServer.clearCurrentDevice(); PmaServer.clearCurrentDeviceXmlStore(); if (request instanceof EditConfigRequest) { PmaServer.clearBackupDeviceXmlStore(); deleteBackupFile(m_device.getDeviceName()); } } }
PmaServerImpl implements PmaServer { @Override public Map<NetConfResponse, List<Notification>> executeNetconf(AbstractNetconfRequest request) { PmaServer.setCurrentDevice(m_device); PmaServer.setCurrentDeviceXmlStore(m_deviceStore); ThreadLocalDSMRegistry.setDsm(m_dsm); ThreadLocalSubsystemRegistry.setSubsystemRegistry(m_stdAdapterContext.getSubSystemRegistry()); ThreadLocalSchemaRegistry.setSchemaRegistry(m_stdAdapterContext.getSchemaRegistry()); m_netconfServer.getDataStore(StandardDataStores.RUNNING).setNamespaceContext(ThreadLocalSchemaRegistry.getRegistry()); ThreadLocalModelNodeHelperRegistry.setModelNodeHelperRegistry(m_stdAdapterContext.getModelNodeHelperRegistry()); ThreadLocalRootModelNodeAggregator.setRootAggregator(m_stdAdapterContext.getRootModelNodeAggregator()); if (request instanceof EditConfigRequest) { PmaServer.setBackupDeviceXmlStore(createBackUpStore(getDeviceStoreBackupFilePath(m_device.getDeviceName()))); } try { List<Notification> notifications = m_msgHandler.processRequest(PMA_USER, request, m_responseChannel); Map<NetConfResponse, List<Notification>> replyMap = new HashMap<>(); replyMap.put(m_responseChannel.getLastResponse(), notifications); return replyMap; } finally { ThreadLocalDSMRegistry.clearDsm(); ThreadLocalSchemaRegistry.clearRegistry(); ThreadLocalSubsystemRegistry.clearRegistry(); ThreadLocalModelNodeHelperRegistry.clearRegistry(); ThreadLocalRootModelNodeAggregator.clearRootAggregator(); PmaServer.clearCurrentDevice(); PmaServer.clearCurrentDeviceXmlStore(); if (request instanceof EditConfigRequest) { PmaServer.clearBackupDeviceXmlStore(); deleteBackupFile(m_device.getDeviceName()); } } } }
PmaServerImpl implements PmaServer { @Override public Map<NetConfResponse, List<Notification>> executeNetconf(AbstractNetconfRequest request) { PmaServer.setCurrentDevice(m_device); PmaServer.setCurrentDeviceXmlStore(m_deviceStore); ThreadLocalDSMRegistry.setDsm(m_dsm); ThreadLocalSubsystemRegistry.setSubsystemRegistry(m_stdAdapterContext.getSubSystemRegistry()); ThreadLocalSchemaRegistry.setSchemaRegistry(m_stdAdapterContext.getSchemaRegistry()); m_netconfServer.getDataStore(StandardDataStores.RUNNING).setNamespaceContext(ThreadLocalSchemaRegistry.getRegistry()); ThreadLocalModelNodeHelperRegistry.setModelNodeHelperRegistry(m_stdAdapterContext.getModelNodeHelperRegistry()); ThreadLocalRootModelNodeAggregator.setRootAggregator(m_stdAdapterContext.getRootModelNodeAggregator()); if (request instanceof EditConfigRequest) { PmaServer.setBackupDeviceXmlStore(createBackUpStore(getDeviceStoreBackupFilePath(m_device.getDeviceName()))); } try { List<Notification> notifications = m_msgHandler.processRequest(PMA_USER, request, m_responseChannel); Map<NetConfResponse, List<Notification>> replyMap = new HashMap<>(); replyMap.put(m_responseChannel.getLastResponse(), notifications); return replyMap; } finally { ThreadLocalDSMRegistry.clearDsm(); ThreadLocalSchemaRegistry.clearRegistry(); ThreadLocalSubsystemRegistry.clearRegistry(); ThreadLocalModelNodeHelperRegistry.clearRegistry(); ThreadLocalRootModelNodeAggregator.clearRootAggregator(); PmaServer.clearCurrentDevice(); PmaServer.clearCurrentDeviceXmlStore(); if (request instanceof EditConfigRequest) { PmaServer.clearBackupDeviceXmlStore(); deleteBackupFile(m_device.getDeviceName()); } } } PmaServerImpl(Device device, NetconfServer netconfServer, Pair<ModelNodeDataStoreManager, DeviceXmlStore>
            dsmStorePair, AdapterContext adapterContext, AdapterContext stdAdapterContext, String deviceFileBaseDirPath); }
PmaServerImpl implements PmaServer { @Override public Map<NetConfResponse, List<Notification>> executeNetconf(AbstractNetconfRequest request) { PmaServer.setCurrentDevice(m_device); PmaServer.setCurrentDeviceXmlStore(m_deviceStore); ThreadLocalDSMRegistry.setDsm(m_dsm); ThreadLocalSubsystemRegistry.setSubsystemRegistry(m_stdAdapterContext.getSubSystemRegistry()); ThreadLocalSchemaRegistry.setSchemaRegistry(m_stdAdapterContext.getSchemaRegistry()); m_netconfServer.getDataStore(StandardDataStores.RUNNING).setNamespaceContext(ThreadLocalSchemaRegistry.getRegistry()); ThreadLocalModelNodeHelperRegistry.setModelNodeHelperRegistry(m_stdAdapterContext.getModelNodeHelperRegistry()); ThreadLocalRootModelNodeAggregator.setRootAggregator(m_stdAdapterContext.getRootModelNodeAggregator()); if (request instanceof EditConfigRequest) { PmaServer.setBackupDeviceXmlStore(createBackUpStore(getDeviceStoreBackupFilePath(m_device.getDeviceName()))); } try { List<Notification> notifications = m_msgHandler.processRequest(PMA_USER, request, m_responseChannel); Map<NetConfResponse, List<Notification>> replyMap = new HashMap<>(); replyMap.put(m_responseChannel.getLastResponse(), notifications); return replyMap; } finally { ThreadLocalDSMRegistry.clearDsm(); ThreadLocalSchemaRegistry.clearRegistry(); ThreadLocalSubsystemRegistry.clearRegistry(); ThreadLocalModelNodeHelperRegistry.clearRegistry(); ThreadLocalRootModelNodeAggregator.clearRootAggregator(); PmaServer.clearCurrentDevice(); PmaServer.clearCurrentDeviceXmlStore(); if (request instanceof EditConfigRequest) { PmaServer.clearBackupDeviceXmlStore(); deleteBackupFile(m_device.getDeviceName()); } } } PmaServerImpl(Device device, NetconfServer netconfServer, Pair<ModelNodeDataStoreManager, DeviceXmlStore>
            dsmStorePair, AdapterContext adapterContext, AdapterContext stdAdapterContext, String deviceFileBaseDirPath); @Override Map<NetConfResponse, List<Notification>> executeNetconf(AbstractNetconfRequest request); boolean isActive(); Device getDevice(); }
PmaServerImpl implements PmaServer { @Override public Map<NetConfResponse, List<Notification>> executeNetconf(AbstractNetconfRequest request) { PmaServer.setCurrentDevice(m_device); PmaServer.setCurrentDeviceXmlStore(m_deviceStore); ThreadLocalDSMRegistry.setDsm(m_dsm); ThreadLocalSubsystemRegistry.setSubsystemRegistry(m_stdAdapterContext.getSubSystemRegistry()); ThreadLocalSchemaRegistry.setSchemaRegistry(m_stdAdapterContext.getSchemaRegistry()); m_netconfServer.getDataStore(StandardDataStores.RUNNING).setNamespaceContext(ThreadLocalSchemaRegistry.getRegistry()); ThreadLocalModelNodeHelperRegistry.setModelNodeHelperRegistry(m_stdAdapterContext.getModelNodeHelperRegistry()); ThreadLocalRootModelNodeAggregator.setRootAggregator(m_stdAdapterContext.getRootModelNodeAggregator()); if (request instanceof EditConfigRequest) { PmaServer.setBackupDeviceXmlStore(createBackUpStore(getDeviceStoreBackupFilePath(m_device.getDeviceName()))); } try { List<Notification> notifications = m_msgHandler.processRequest(PMA_USER, request, m_responseChannel); Map<NetConfResponse, List<Notification>> replyMap = new HashMap<>(); replyMap.put(m_responseChannel.getLastResponse(), notifications); return replyMap; } finally { ThreadLocalDSMRegistry.clearDsm(); ThreadLocalSchemaRegistry.clearRegistry(); ThreadLocalSubsystemRegistry.clearRegistry(); ThreadLocalModelNodeHelperRegistry.clearRegistry(); ThreadLocalRootModelNodeAggregator.clearRootAggregator(); PmaServer.clearCurrentDevice(); PmaServer.clearCurrentDeviceXmlStore(); if (request instanceof EditConfigRequest) { PmaServer.clearBackupDeviceXmlStore(); deleteBackupFile(m_device.getDeviceName()); } } } PmaServerImpl(Device device, NetconfServer netconfServer, Pair<ModelNodeDataStoreManager, DeviceXmlStore>
            dsmStorePair, AdapterContext adapterContext, AdapterContext stdAdapterContext, String deviceFileBaseDirPath); @Override Map<NetConfResponse, List<Notification>> executeNetconf(AbstractNetconfRequest request); boolean isActive(); Device getDevice();  }