Search in sources :

Example 36 with DocumentedException

use of org.opendaylight.netconf.api.DocumentedException in project netconf by opendaylight.

the class NetconfMDSalMappingTest method testEditWithCreate.

@Test
public void testEditWithCreate() throws Exception {
    verifyResponse(edit("messages/mapping/editConfigs/editConfig_create.xml"), RPC_REPLY_OK);
    verifyResponse(getConfigCandidate(), XmlFileLoader.xmlFileToDocument("messages/mapping/editConfig_create_n1_control.xml"));
    final DocumentedException ex = assertThrows(DocumentedException.class, () -> edit("messages/mapping/editConfigs/editConfig_create.xml"));
    assertEquals(ErrorSeverity.ERROR, ex.getErrorSeverity());
    assertEquals(ErrorTag.DATA_EXISTS, ex.getErrorTag());
    assertEquals(ErrorType.PROTOCOL, ex.getErrorType());
    verifyResponse(discardChanges(), RPC_REPLY_OK);
}
Also used : DocumentedException(org.opendaylight.netconf.api.DocumentedException) Test(org.junit.Test)

Example 37 with DocumentedException

use of org.opendaylight.netconf.api.DocumentedException in project netconf by opendaylight.

the class NetconfMDSalMappingTest method testConfigMissing.

@Test
public void testConfigMissing() throws Exception {
    final DocumentedException ex = assertThrows(DocumentedException.class, () -> edit("messages/mapping/editConfigs/editConfig_no_config.xml"));
    assertEquals(ErrorSeverity.ERROR, ex.getErrorSeverity());
    assertEquals(ErrorTag.MISSING_ELEMENT, ex.getErrorTag());
    assertEquals(ErrorType.PROTOCOL, ex.getErrorType());
}
Also used : DocumentedException(org.opendaylight.netconf.api.DocumentedException) Test(org.junit.Test)

Example 38 with DocumentedException

use of org.opendaylight.netconf.api.DocumentedException in project netconf by opendaylight.

the class NetconfMDSalMappingTest method testUnlock.

@Test
public void testUnlock() throws Exception {
    verifyResponse(unlockCandidate(), RPC_REPLY_OK);
    DocumentedException ex = assertThrows(DocumentedException.class, NetconfMDSalMappingTest::unlock);
    assertEquals(ErrorSeverity.ERROR, ex.getErrorSeverity());
    assertEquals(ErrorTag.OPERATION_NOT_SUPPORTED, ex.getErrorTag());
    assertEquals(ErrorType.APPLICATION, ex.getErrorType());
    ex = assertThrows(DocumentedException.class, NetconfMDSalMappingTest::unlockWithoutTarget);
    assertEquals(ErrorSeverity.ERROR, ex.getErrorSeverity());
    assertEquals(ErrorTag.INVALID_VALUE, ex.getErrorTag());
    assertEquals(ErrorType.APPLICATION, ex.getErrorType());
}
Also used : DocumentedException(org.opendaylight.netconf.api.DocumentedException) Test(org.junit.Test)

Example 39 with DocumentedException

use of org.opendaylight.netconf.api.DocumentedException in project netconf by opendaylight.

the class RuntimeRpcTest method testBadNamespaceInRpc.

@Test
public void testBadNamespaceInRpc() throws Exception {
    final RuntimeRpc rpc = new RuntimeRpc(SESSION_ID_FOR_REPORTING, currentSchemaContext, RPC_SERVICE_VOID_INVOKER);
    final Document rpcDocument = XmlFileLoader.xmlFileToDocument("messages/mapping/rpcs/rpc-bad-namespace.xml");
    final DocumentedException e = assertThrows(DocumentedException.class, () -> rpc.handle(rpcDocument, NetconfOperationChainedExecution.EXECUTION_TERMINATION_POINT));
    assertEquals(e.getErrorSeverity(), ErrorSeverity.ERROR);
    assertEquals(e.getErrorTag(), ErrorTag.BAD_ELEMENT);
    assertEquals(e.getErrorType(), ErrorType.APPLICATION);
}
Also used : DocumentedException(org.opendaylight.netconf.api.DocumentedException) Document(org.w3c.dom.Document) Test(org.junit.Test)

Example 40 with DocumentedException

use of org.opendaylight.netconf.api.DocumentedException in project netconf by opendaylight.

the class RuntimeRpcTest method testFailedInvocation.

@Test
public void testFailedInvocation() throws Exception {
    final RuntimeRpc rpc = new RuntimeRpc(SESSION_ID_FOR_REPORTING, currentSchemaContext, RPC_SERVICE_FAILED_INVOCATION);
    final Document rpcDocument = XmlFileLoader.xmlFileToDocument("messages/mapping/rpcs/rpc-nonvoid.xml");
    final HandlingPriority priority = rpc.canHandle(rpcDocument);
    Preconditions.checkState(priority != HandlingPriority.CANNOT_HANDLE);
    final DocumentedException e = assertThrows(DocumentedException.class, () -> rpc.handle(rpcDocument, NetconfOperationChainedExecution.EXECUTION_TERMINATION_POINT));
    assertEquals(e.getErrorSeverity(), ErrorSeverity.ERROR);
    assertEquals(e.getErrorTag(), ErrorTag.OPERATION_FAILED);
    assertEquals(e.getErrorType(), ErrorType.APPLICATION);
}
Also used : DocumentedException(org.opendaylight.netconf.api.DocumentedException) HandlingPriority(org.opendaylight.netconf.mapping.api.HandlingPriority) Document(org.w3c.dom.Document) Test(org.junit.Test)

Aggregations

DocumentedException (org.opendaylight.netconf.api.DocumentedException)54 Test (org.junit.Test)25 XmlElement (org.opendaylight.netconf.api.xml.XmlElement)14 Document (org.w3c.dom.Document)9 NetconfDocumentedException (org.opendaylight.netconf.api.NetconfDocumentedException)6 ExecutionException (java.util.concurrent.ExecutionException)5 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)5 Element (org.w3c.dom.Element)5 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)4 List (java.util.List)3 XMLNamespace (org.opendaylight.yangtools.yang.common.XMLNamespace)3 XmlNodeConverter (io.lighty.codecs.util.XmlNodeConverter)2 DeserializationException (io.lighty.codecs.util.exception.DeserializationException)2 Response (io.lighty.netconf.device.response.Response)2 ResponseData (io.lighty.netconf.device.response.ResponseData)2 Reader (java.io.Reader)2 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 CompletableFuture (java.util.concurrent.CompletableFuture)2