- 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(){
- @Override
- 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 testIdRef() throws Exception {
+ NetconfMessage editId = XmlFileLoader.xmlFileToNetconfMessage("netconfMessages/editConfig_identities.xml");
+ NetconfMessage commit = XmlFileLoader.xmlFileToNetconfMessage("netconfMessages/commit.xml");
+
+ try (TestingNetconfClient netconfClient = createSession(tcpAddress, "1")) {
+ assertIsOK(netconfClient.sendMessage(editId).getDocument());
+ assertIsOK(netconfClient.sendMessage(commit).getDocument());
+
+ NetconfMessage response = netconfClient.sendMessage(getConfig);
+
+ assertThat(XmlUtil.toString(response.getDocument()), JUnitMatchers.containsString("<afi xmlns:prefix=\"urn:opendaylight:params:xml:ns:yang:controller:config:test:types\">prefix:test-identity1</afi>"));
+ assertThat(XmlUtil.toString(response.getDocument()), JUnitMatchers.containsString("<afi xmlns:prefix=\"urn:opendaylight:params:xml:ns:yang:controller:config:test:types\">prefix:test-identity2</afi>"));
+ assertThat(XmlUtil.toString(response.getDocument()), JUnitMatchers.containsString("<safi xmlns:prefix=\"urn:opendaylight:params:xml:ns:yang:controller:config:test:types\">prefix:test-identity2</safi>"));
+ assertThat(XmlUtil.toString(response.getDocument()), JUnitMatchers.containsString("<safi xmlns:prefix=\"urn:opendaylight:params:xml:ns:yang:controller:config:test:types\">prefix:test-identity1</safi>"));
+
+ } catch (Exception e) {
+ fail(Throwables.getStackTraceAsString(e));
+ }