final DocumentedException sendErrorException) {
try {
final Element incommingRpc = incommingDocument.getDocumentElement();
- Preconditions.checkState(incommingRpc.getTagName().equals(XmlNetconfConstants.RPC_KEY),
+ Preconditions.checkState(incommingRpc.getLocalName().equals(XmlNetconfConstants.RPC_KEY),
"Missing %s element", XmlNetconfConstants.RPC_KEY);
final Element rpcReply = errorDocument.getDocumentElement();
package org.opendaylight.netconf.util.messages;
+import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import io.netty.util.concurrent.GenericFutureListener;
import org.junit.Before;
import org.junit.Test;
+import org.mockito.ArgumentCaptor;
import org.opendaylight.controller.config.util.xml.DocumentedException;
import org.opendaylight.netconf.api.NetconfMessage;
import org.opendaylight.netconf.api.NetconfSession;
import org.opendaylight.netconf.util.test.XmlFileLoader;
import org.w3c.dom.Document;
+import org.w3c.dom.Element;
public class SendErrorExceptionUtilTest {
SendErrorExceptionUtil.sendErrorMessage(netconfSession, exception, new NetconfMessage(helloMessage));
verify(channelFuture, times(1)).addListener(any(GenericFutureListener.class));
}
+
+ @Test
+ public void testSendErrorMessage4() throws Exception {
+ Document helloMessage = XmlFileLoader.xmlFileToDocument("netconfMessages/rpc_ns.xml");
+ SendErrorExceptionUtil.sendErrorMessage(netconfSession, exception, new NetconfMessage(helloMessage));
+ final ArgumentCaptor<NetconfMessage> messageCaptor = ArgumentCaptor.forClass(NetconfMessage.class);
+ verify(netconfSession, times(1)).sendMessage(messageCaptor.capture());
+ final Element rpcReply = messageCaptor.getValue().getDocument().getDocumentElement();
+ assertEquals("Invalid value of message-id attribute in the reply message", "a",
+ rpcReply.getAttribute("message-id"));
+ }
}