- private void startSSHServer() throws Exception{
- logger.info("Creating SSH server");
- Thread sshServerThread = new Thread(NetconfSSHServer.start(10830,tcpAddress));
- sshServerThread.setDaemon(true);
- sshServerThread.start();
- logger.info("SSH server on");
+ @Test
+ 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));
+ }
+ }
+
+ @Override
+ protected CodecRegistry getCodecRegistry() {
+ final IdentityCodec<?> codec = mock(IdentityCodec.class);
+ doReturn(TestIdentity1.class).when(codec).deserialize(TestIdentity1.QNAME);
+ doReturn(TestIdentity2.class).when(codec).deserialize(TestIdentity2.QNAME);
+
+ final CodecRegistry ret = super.getCodecRegistry();
+ doReturn(codec).when(ret).getIdentityCodec();
+ return ret;