- 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 testMultipleDependencies() throws Exception {
+ // push first xml, should add parent and d1,d2 dependencies
+ try (TestingNetconfClient netconfClient = createSession(TCP_ADDRESS, "1")) {
+ final Document rpcReply = netconfClient.sendMessage(
+ XmlFileLoader.xmlFileToNetconfMessage("netconfMessages/editConfig_merge_multiple-deps1.xml"))
+ .getDocument();
+ assertIsOK(rpcReply);
+ commit(netconfClient);
+ }
+ // verify that parent.getTestingDeps == d1,d2
+ final MultipleDependenciesModuleMXBean parentProxy = configRegistryClient.newMXBeanProxy(
+ configRegistryClient.lookupConfigBean(MultipleDependenciesModuleFactory.NAME, "parent"),
+ MultipleDependenciesModuleMXBean.class);
+ {
+ final List<ObjectName> testingDeps = parentProxy.getTestingDeps();
+ assertEquals(2, testingDeps.size());
+ final 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(final MultipleDependenciesModuleMXBean parentProxy) throws Exception {
+ try (TestingNetconfClient netconfClient = new TestingNetconfClient(
+ "test " + TCP_ADDRESS.toString(), clientDispatcher, getClientConfiguration(TCP_ADDRESS, 5000))) {
+
+ final Document rpcReply = netconfClient.sendMessage(
+ XmlFileLoader.xmlFileToNetconfMessage("netconfMessages/editConfig_merge_multiple-deps2.xml"))
+ .getDocument();
+ assertIsOK(rpcReply);
+ commit(netconfClient);
+ }
+ {
+ final List<ObjectName> testingDeps = parentProxy.getTestingDeps();
+ assertEquals(3, testingDeps.size());
+ final Set<String> actualRefs = getServiceReferences(testingDeps);
+ assertEquals(Sets.newHashSet("ref_d1", "ref_d2", "ref_d3"), actualRefs);
+ }
+ }
+
+ public Set<String> getServiceReferences(final List<ObjectName> testingDeps) {
+ return new HashSet<>(Lists.transform(testingDeps, new Function<ObjectName, String>() {