IetfYangLibrary implements GlobalRequestProcessor { @Override public String processRequest(NetconfClientInfo clientInfo, String netconfRequest) throws DispatchException { LOGGER.info(netconfRequest); try { YangLibraryMessage yangLibraryMessage = new YangLibraryMessage(netconfRequest); buildPayload(yangLibraryMessage); return yangLibraryMessage.buildRpcReplyResponse(); } catch (JAXBException ex) { throw new DispatchException(ex); } } private  IetfYangLibrary();  IetfYangLibrary(Aggregator aggregator); void init(); void destroy(); @Override String processRequest(NetconfClientInfo clientInfo, String netconfRequest); Aggregator getAggregator();  }
@Test public void processRequest() throws Exception { String request = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"152026367257\">\n" + " <get>\n" + " <source>\n" + " <running />\n" + " </source>\n" + " <filter type=\"subtree\">\n" + " <yang-library xmlns=\"urn:ietf:params:xml:ns:yang:ietf-yang-library\">\n" + " </yang-library>\n" + " <modules-state xmlns=\"urn:ietf:params:xml:ns:yang:ietf-yang-library\">\n" + " </modules-state>\n" + " </filter>\n" + " </get>\n" + "</rpc>\n"; String response = ietfYangLibrary.processRequest(m_clientInfo, request); assertTrue(response.contains("yang-library")); }
@Test public void processRequestModulesState() throws Exception { String request = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"152026367257\">\n" + " <get>\n" + " <source>\n" + " <running />\n" + " </source>\n" + " <filter type=\"subtree\">\n" + " <modules-state xmlns=\"urn:ietf:params:xml:ns:yang:ietf-yang-library\">\n" + " </modules-state>\n" + " </filter>\n" + " </get>\n" + "</rpc>\n"; String response = ietfYangLibrary.processRequest(m_clientInfo, request); assertTrue(response.contains("modules-state")); }
@Test public void processRequestModulesStateFilter() throws Exception { String request = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"152026367257\">\n" + " <get>\n" + " <source>\n" + " <running />\n" + " </source>\n" + " <filter type=\"subtree\">\n" + " <modules-state xmlns=\"urn:ietf:params:xml:ns:yang:ietf-yang-library\">\n" + " <module-set-id>all</module-set-id>\n" + " </modules-state>\n" + " </filter>\n" + " </get>\n" + "</rpc>\n"; String response = ietfYangLibrary.processRequest(m_clientInfo, request); assertTrue(response.contains("modules-state")); }
@Test public void processRequestFilter() throws Exception { String request = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"152026367257\">\n" + " <get>\n" + " <source>\n" + " <running />\n" + " </source>\n" + " <filter type=\"subtree\">\n" + " <yang-library xmlns=\"urn:ietf:params:xml:ns:yang:ietf-yang-library\">\n" + " <modules>\n" + " <module>\n" + " <id>urn:ietf:params:xml:ns:yang:ietf-yang-library?module=ietf-yang-library&amp;revision=2017-10-30</id>\n" + " </module>\n" + " </modules>\n" + " <module-sets>\n" + " <module-set>\n" + " <id>System-global</id>\n" + " </module-set>\n" + " </module-sets>\n" + " </yang-library>\n" + " <modules-state xmlns=\"urn:ietf:params:xml:ns:yang:ietf-yang-library\">\n" + " </modules-state>\n" + " </filter>\n" + " </get>\n" + "</rpc>\n"; String response = ietfYangLibrary.processRequest(m_clientInfo, request); assertTrue(response.contains("yang-library")); }