- public void sshTest() throws Exception {
- startSSHServer();
- logger.info("creating connection");
- Connection conn = new Connection(sshAddress.getHostName(),sshAddress.getPort());
- Assert.assertNotNull(conn);
- logger.info("connection created");
- conn.connect();
- boolean isAuthenticated = conn.authenticateWithPassword(USERNAME,PASSWORD);
- assertTrue(isAuthenticated);
- logger.info("user authenticated");
- final Session sess = conn.openSession();
- sess.startSubSystem("netconf");
- logger.info("user authenticated");
- sess.getStdin().write(XmlUtil.toString(this.getConfig.getDocument()).getBytes());
-
- new Thread(){
- public void run(){
- while (true){
- byte[] bytes = new byte[1024];
- int c = 0;
- try {
- c = sess.getStdout().read(bytes);
- } catch (IOException e) {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- }
- logger.info("got data:"+bytes);
- if (c == 0) break;
- }
- }
- }.join();
+ public void testMultipleDependencies() throws Exception {
+ // push first xml, should add parent and d1,d2 dependencies
+ try (TestingNetconfClient netconfClient = createSession(tcpAddress, "1")) {
+ Document rpcReply = netconfClient.sendMessage(
+ XmlFileLoader.xmlFileToNetconfMessage("netconfMessages/editConfig_merge_multiple-deps1.xml"))
+ .getDocument();
+ assertIsOK(rpcReply);
+ commit(netconfClient);
+ }
+ // verify that parent.getTestingDeps == d1,d2
+ MultipleDependenciesModuleMXBean parentProxy = configRegistryClient.newMXBeanProxy(
+ configRegistryClient.lookupConfigBean(MultipleDependenciesModuleFactory.NAME, "parent"),
+ MultipleDependenciesModuleMXBean.class);
+ {
+ List<ObjectName> testingDeps = parentProxy.getTestingDeps();
+ assertEquals(2, testingDeps.size());
+ Set<String> actualRefs = getServiceReferences(testingDeps);
+ assertEquals(Sets.newHashSet("ref_d1", "ref_d2"), actualRefs);
+ }
+
+ // push second xml, should add d3 to parent's dependencies
+ mergeD3(parentProxy);
+ // push second xml again, to test that d3 is not added again
+ mergeD3(parentProxy);
+ }
+
+ public void mergeD3(MultipleDependenciesModuleMXBean parentProxy) throws Exception {
+ try (TestingNetconfClient netconfClient = new TestingNetconfClient(
+ "test " + tcpAddress.toString(), clientDispatcher, getClientConfiguration(tcpAddress, 5000))) {
+
+ Document rpcReply = netconfClient.sendMessage(
+ XmlFileLoader.xmlFileToNetconfMessage("netconfMessages/editConfig_merge_multiple-deps2.xml"))
+ .getDocument();
+ assertIsOK(rpcReply);
+ commit(netconfClient);
+ }
+ {
+ List<ObjectName> testingDeps = parentProxy.getTestingDeps();
+ assertEquals(3, testingDeps.size());
+ Set<String> actualRefs = getServiceReferences(testingDeps);
+ assertEquals(Sets.newHashSet("ref_d1", "ref_d2", "ref_d3"), actualRefs);
+ }