X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fmdsal-netconf-connector%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fmdsal%2Fconnector%2Fops%2FRuntimeRpcTest.java;h=02a9514651a957f2d8a6f7110de18f5233d98f3e;hb=refs%2Fchanges%2F13%2F23413%2F26;hp=040066d91ca4ecbc9a20e6b18361c92672d0ba14;hpb=cbf7f08ade1ef9ea49e8587188ca2fa58e09731c;p=controller.git diff --git a/opendaylight/netconf/mdsal-netconf-connector/src/test/java/org/opendaylight/controller/netconf/mdsal/connector/ops/RuntimeRpcTest.java b/opendaylight/netconf/mdsal-netconf-connector/src/test/java/org/opendaylight/controller/netconf/mdsal/connector/ops/RuntimeRpcTest.java index 040066d91c..02a9514651 100644 --- a/opendaylight/netconf/mdsal-netconf-connector/src/test/java/org/opendaylight/controller/netconf/mdsal/connector/ops/RuntimeRpcTest.java +++ b/opendaylight/netconf/mdsal-netconf-connector/src/test/java/org/opendaylight/controller/netconf/mdsal/connector/ops/RuntimeRpcTest.java @@ -40,20 +40,20 @@ import org.junit.Test; import org.mockito.Mock; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; +import org.opendaylight.controller.config.util.xml.DocumentedException; +import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorSeverity; +import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorTag; +import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorType; +import org.opendaylight.controller.config.util.xml.XmlUtil; import org.opendaylight.controller.md.sal.dom.api.DOMRpcAvailabilityListener; import org.opendaylight.controller.md.sal.dom.api.DOMRpcException; import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult; import org.opendaylight.controller.md.sal.dom.api.DOMRpcService; import org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult; -import org.opendaylight.controller.netconf.api.NetconfDocumentedException; -import org.opendaylight.controller.netconf.api.NetconfDocumentedException.ErrorSeverity; -import org.opendaylight.controller.netconf.api.NetconfDocumentedException.ErrorTag; -import org.opendaylight.controller.netconf.api.NetconfDocumentedException.ErrorType; import org.opendaylight.controller.netconf.mapping.api.HandlingPriority; import org.opendaylight.controller.netconf.mapping.api.NetconfOperationChainedExecution; import org.opendaylight.controller.netconf.mdsal.connector.CurrentSchemaContext; import org.opendaylight.controller.netconf.util.test.XmlFileLoader; -import org.opendaylight.controller.netconf.util.xml.XmlUtil; import org.opendaylight.controller.sal.core.api.model.SchemaService; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.common.RpcError; @@ -225,7 +225,7 @@ public class RuntimeRpcTest { try { rpc.handle(rpcDocument, NetconfOperationChainedExecution.EXECUTION_TERMINATION_POINT); fail("should have failed with rpc invocation not implemented yet"); - } catch (NetconfDocumentedException e) { + } catch (DocumentedException e) { assertTrue(e.getErrorType() == ErrorType.application); assertTrue(e.getErrorSeverity() == ErrorSeverity.error); assertTrue(e.getErrorTag() == ErrorTag.operation_failed); @@ -245,6 +245,21 @@ public class RuntimeRpcTest { verifyResponse(response, RPC_REPLY_OK); } + @Test + public void testBadNamespaceInRpc() throws Exception { + RuntimeRpc rpc = new RuntimeRpc(sessionIdForReporting, currentSchemaContext, rpcServiceVoidInvoke); + Document rpcDocument = XmlFileLoader.xmlFileToDocument("messages/mapping/rpcs/rpc-bad-namespace.xml"); + + try { + rpc.handle(rpcDocument, NetconfOperationChainedExecution.EXECUTION_TERMINATION_POINT); + fail("Should have failed, rpc has bad namespace"); + } catch (DocumentedException e) { + assertTrue(e.getErrorSeverity() == ErrorSeverity.error); + assertTrue(e.getErrorTag() == ErrorTag.bad_element); + assertTrue(e.getErrorType() == ErrorType.application); + } + } + private void verifyResponse(Document response, Document template) throws IOException, TransformerException { DetailedDiff dd = new DetailedDiff(new Diff(response, template)); dd.overrideElementQualifier(new RecursiveElementNameAndTextQualifier());