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());
}
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());
}
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());
}
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();
}
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());
}
Aggregations