Search in sources :

Example 11 with DocumentedException

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

the class NetconfMDSalMappingTest method testIncorrectGet.

@Test
public void testIncorrectGet() throws Exception {
    DocumentedException ex = assertThrows(DocumentedException.class, () -> executeOperation(new GetConfig(SESSION_ID_FOR_REPORTING, getCurrentSchemaContext(), getTransactionProvider()), "messages/mapping/bad_getConfig.xml"));
    assertEquals(ErrorSeverity.ERROR, ex.getErrorSeverity());
    assertEquals(ErrorTag.OPERATION_FAILED, ex.getErrorTag());
    assertEquals(ErrorType.APPLICATION, ex.getErrorType());
    ex = assertThrows(DocumentedException.class, () -> executeOperation(new GetConfig(SESSION_ID_FOR_REPORTING, getCurrentSchemaContext(), getTransactionProvider()), "messages/mapping/bad_namespace_getConfig.xml"));
    assertEquals(ErrorSeverity.ERROR, ex.getErrorSeverity());
    assertEquals(ErrorTag.OPERATION_FAILED, ex.getErrorTag());
    assertEquals(ErrorType.APPLICATION, ex.getErrorType());
}
Also used : GetConfig(org.opendaylight.netconf.mdsal.connector.ops.get.GetConfig) DocumentedException(org.opendaylight.netconf.api.DocumentedException) Test(org.junit.Test)

Example 12 with DocumentedException

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

the class NetconfMDSalMappingTest method testLock.

@Test
public void testLock() throws Exception {
    verifyResponse(lockCandidate(), RPC_REPLY_OK);
    DocumentedException ex = assertThrows(DocumentedException.class, NetconfMDSalMappingTest::lock);
    assertEquals(ErrorSeverity.ERROR, ex.getErrorSeverity());
    assertEquals(ErrorTag.OPERATION_NOT_SUPPORTED, ex.getErrorTag());
    assertEquals(ErrorType.APPLICATION, ex.getErrorType());
    ex = assertThrows(DocumentedException.class, NetconfMDSalMappingTest::lockWithoutTarget);
    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 13 with DocumentedException

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

the class NetconfMDSalMappingTest method testDeleteNonExisting.

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

Example 14 with DocumentedException

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

the class NetconfMDSalMappingTest method testEditConfigWithMultipleOperations.

@Test
public void testEditConfigWithMultipleOperations() throws Exception {
    deleteDatastore();
    verifyResponse(edit("messages/mapping/editConfigs/editConfig_merge_multiple_operations_setup.xml"), RPC_REPLY_OK);
    verifyResponse(edit("messages/mapping/editConfigs/editConfig_merge_multiple_operations_1.xml"), RPC_REPLY_OK);
    verifyResponse(edit("messages/mapping/editConfigs/editConfig_merge_multiple_operations_2.xml"), RPC_REPLY_OK);
    verifyResponse(getConfigCandidate(), XmlFileLoader.xmlFileToDocument("messages/mapping/editConfigs/editConfig_merge_multiple_operations_2_control.xml"));
    verifyResponse(edit("messages/mapping/editConfigs/editConfig_merge_multiple_operations_3_leaf_operations.xml"), RPC_REPLY_OK);
    verifyResponse(getConfigCandidate(), XmlFileLoader.xmlFileToDocument("messages/mapping/editConfigs/editConfig_merge_multiple_operations_3_control.xml"));
    deleteDatastore();
    verifyResponse(edit("messages/mapping/editConfigs/editConfig_merge_multiple_operations_4_setup.xml"), RPC_REPLY_OK);
    verifyResponse(edit("messages/mapping/editConfigs/editConfig_merge_multiple_operations_4_default-replace.xml"), RPC_REPLY_OK);
    DocumentedException ex = assertThrows(DocumentedException.class, () -> edit("messages/mapping/editConfigs/editConfig_merge_multiple_operations_4_create_existing.xml"));
    assertEquals(ErrorSeverity.ERROR, ex.getErrorSeverity());
    assertEquals(ErrorTag.DATA_EXISTS, ex.getErrorTag());
    assertEquals(ErrorType.PROTOCOL, ex.getErrorType());
    verifyResponse(edit("messages/mapping/editConfigs/editConfig_merge_multiple_operations_4_delete_children_operations.xml"), RPC_REPLY_OK);
    verifyResponse(getConfigCandidate(), XmlFileLoader.xmlFileToDocument("messages/mapping/editConfigs/" + "editConfig_merge_multiple_operations_4_delete_children_operations_control.xml"));
    verifyResponse(edit("messages/mapping/editConfigs/editConfig_merge_multiple_operations_4_remove-non-existing.xml"), RPC_REPLY_OK);
    ex = assertThrows(DocumentedException.class, () -> edit("messages/mapping/editConfigs/editConfig_merge_multiple_operations_4_delete-non-existing.xml"));
    assertEquals(ErrorSeverity.ERROR, ex.getErrorSeverity());
    assertEquals(ErrorTag.DATA_MISSING, ex.getErrorTag());
    assertEquals(ErrorType.PROTOCOL, ex.getErrorType());
    verifyResponse(edit("messages/mapping/editConfigs/editConfig_merge_multiple_operations_5_choice_setup.xml"), RPC_REPLY_OK);
    verifyResponse(getConfigCandidate(), XmlFileLoader.xmlFileToDocument("messages/mapping/editConfigs/editConfig_merge_multiple_operations_5_choice_setup-control.xml"));
    // Test files have been modified. RFC6020 requires that at most once case inside a choice is present at any time
    verifyResponse(edit("messages/mapping/editConfigs/editConfig_merge_multiple_operations_5_choice_setup2.xml"), RPC_REPLY_OK);
    verifyResponse(getConfigCandidate(), XmlFileLoader.xmlFileToDocument("messages/mapping/editConfigs/editConfig_merge_multiple_operations_5_choice_setup2-control.xml"));
    verifyResponse(edit("messages/mapping/editConfigs/editConfig_merge_multiple_operations_5_choice_delete.xml"), RPC_REPLY_OK);
    verifyResponse(getConfigCandidate(), XmlFileLoader.xmlFileToDocument("messages/mapping/editConfigs" + "/editConfig_merge_multiple_operations_4_delete_children_operations_control.xml"));
    deleteDatastore();
}
Also used : DocumentedException(org.opendaylight.netconf.api.DocumentedException) Test(org.junit.Test)

Example 15 with DocumentedException

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

the class ValidateTest method testValidateUnsupported.

@Test
public void testValidateUnsupported() throws Exception {
    whenValidatorIsNotDefined();
    final DocumentedException e = assertThrows(DocumentedException.class, () -> validate("messages/mapping/validate/validate.xml"));
    assertEquals(ErrorSeverity.ERROR, e.getErrorSeverity());
    assertEquals(ErrorTag.OPERATION_NOT_SUPPORTED, e.getErrorTag());
    assertEquals(ErrorType.PROTOCOL, e.getErrorType());
}
Also used : DocumentedException(org.opendaylight.netconf.api.DocumentedException) 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