@Test public void testExceptionIsThrownWhenInvalidReqIsSent(){ try{ m_pmaSession.executeNC("<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" > <blah xmlns=\"\" /> </rpc>"); fail("Expected an exception here"); }catch (IllegalArgumentException e){ assertEquals("Invalid netconf request received : <rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" > <blah xmlns=\"\" /> </rpc>", e.getMessage()); } }
@Override public Map<NetConfResponse, List<Notification>> executeNC(String netconfRequest) { try { Document document = null; document = DocumentUtils.stringToDocument(netconfRequest); AbstractNetconfRequest request = DocumentToPojoTransformer.getRequest(document); Future<NetConfResponse> responseFuture = m_connectionManager.executeNetconf(m_device, request); Map<NetConfResponse, List<Notification>> map = new HashMap<>(); map.put(responseFuture.get(), Collections.emptyList()); return map; } catch (NetconfMessageBuilderException e) { throw new IllegalArgumentException(String.format("Invalid netconf request received : %s", netconfRequest), e); } catch (InterruptedException | ExecutionException e) { throw new RuntimeException(String.format("Could not execute request %s on device %s", netconfRequest, m_device), e); } }
TransparentPmaSession implements PmaSession { @Override public Map<NetConfResponse, List<Notification>> executeNC(String netconfRequest) { try { Document document = null; document = DocumentUtils.stringToDocument(netconfRequest); AbstractNetconfRequest request = DocumentToPojoTransformer.getRequest(document); Future<NetConfResponse> responseFuture = m_connectionManager.executeNetconf(m_device, request); Map<NetConfResponse, List<Notification>> map = new HashMap<>(); map.put(responseFuture.get(), Collections.emptyList()); return map; } catch (NetconfMessageBuilderException e) { throw new IllegalArgumentException(String.format("Invalid netconf request received : %s", netconfRequest), e); } catch (InterruptedException | ExecutionException e) { throw new RuntimeException(String.format("Could not execute request %s on device %s", netconfRequest, m_device), e); } } }
TransparentPmaSession implements PmaSession { @Override public Map<NetConfResponse, List<Notification>> executeNC(String netconfRequest) { try { Document document = null; document = DocumentUtils.stringToDocument(netconfRequest); AbstractNetconfRequest request = DocumentToPojoTransformer.getRequest(document); Future<NetConfResponse> responseFuture = m_connectionManager.executeNetconf(m_device, request); Map<NetConfResponse, List<Notification>> map = new HashMap<>(); map.put(responseFuture.get(), Collections.emptyList()); return map; } catch (NetconfMessageBuilderException e) { throw new IllegalArgumentException(String.format("Invalid netconf request received : %s", netconfRequest), e); } catch (InterruptedException | ExecutionException e) { throw new RuntimeException(String.format("Could not execute request %s on device %s", netconfRequest, m_device), e); } } TransparentPmaSession(Device device, NetconfConnectionManager connectionManager); }
TransparentPmaSession implements PmaSession { @Override public Map<NetConfResponse, List<Notification>> executeNC(String netconfRequest) { try { Document document = null; document = DocumentUtils.stringToDocument(netconfRequest); AbstractNetconfRequest request = DocumentToPojoTransformer.getRequest(document); Future<NetConfResponse> responseFuture = m_connectionManager.executeNetconf(m_device, request); Map<NetConfResponse, List<Notification>> map = new HashMap<>(); map.put(responseFuture.get(), Collections.emptyList()); return map; } catch (NetconfMessageBuilderException e) { throw new IllegalArgumentException(String.format("Invalid netconf request received : %s", netconfRequest), e); } catch (InterruptedException | ExecutionException e) { throw new RuntimeException(String.format("Could not execute request %s on device %s", netconfRequest, m_device), e); } } TransparentPmaSession(Device device, NetconfConnectionManager connectionManager); @Override Map<NetConfResponse, List<Notification>> executeNC(String netconfRequest); @Override void forceAlign(); @Override void align(); @Override NetConfResponse getAllPersistCfg(); }
TransparentPmaSession implements PmaSession { @Override public Map<NetConfResponse, List<Notification>> executeNC(String netconfRequest) { try { Document document = null; document = DocumentUtils.stringToDocument(netconfRequest); AbstractNetconfRequest request = DocumentToPojoTransformer.getRequest(document); Future<NetConfResponse> responseFuture = m_connectionManager.executeNetconf(m_device, request); Map<NetConfResponse, List<Notification>> map = new HashMap<>(); map.put(responseFuture.get(), Collections.emptyList()); return map; } catch (NetconfMessageBuilderException e) { throw new IllegalArgumentException(String.format("Invalid netconf request received : %s", netconfRequest), e); } catch (InterruptedException | ExecutionException e) { throw new RuntimeException(String.format("Could not execute request %s on device %s", netconfRequest, m_device), e); } } TransparentPmaSession(Device device, NetconfConnectionManager connectionManager); @Override Map<NetConfResponse, List<Notification>> executeNC(String netconfRequest); @Override void forceAlign(); @Override void align(); @Override NetConfResponse getAllPersistCfg();  }