|
@@ -166,12 +166,80 @@ START_TEST(DeleteObjectWithDestructor) {
|
|
/* Delete the object */
|
|
/* Delete the object */
|
|
UA_Server_deleteNode(server, objectid, true);
|
|
UA_Server_deleteNode(server, objectid, true);
|
|
|
|
|
|
- /* Verify that the denstructor was called */
|
|
|
|
|
|
+ /* Verify that the destructor was called */
|
|
ck_assert_int_eq(destructorCalled, true);
|
|
ck_assert_int_eq(destructorCalled, true);
|
|
|
|
|
|
UA_Server_delete(server);
|
|
UA_Server_delete(server);
|
|
} END_TEST
|
|
} END_TEST
|
|
|
|
|
|
|
|
+START_TEST(DeleteObjectAndReferences) {
|
|
|
|
+ UA_Server *server = UA_Server_new(UA_ServerConfig_standard);
|
|
|
|
+
|
|
|
|
+ /* Add an object of the type */
|
|
|
|
+ UA_ObjectAttributes attr;
|
|
|
|
+ UA_ObjectAttributes_init(&attr);
|
|
|
|
+ attr.displayName = UA_LOCALIZEDTEXT("en_US","my object");
|
|
|
|
+ UA_NodeId objectid = UA_NODEID_NUMERIC(0, 23372337);
|
|
|
|
+ UA_StatusCode res;
|
|
|
|
+ res = UA_Server_addObjectNode(server, objectid, UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER),
|
|
|
|
+ UA_NODEID_NUMERIC(0, UA_NS0ID_HASCOMPONENT), UA_QUALIFIEDNAME(0, ""),
|
|
|
|
+ UA_NODEID_NULL, attr, NULL, NULL);
|
|
|
|
+ ck_assert_int_eq(res, UA_STATUSCODE_GOOD);
|
|
|
|
+
|
|
|
|
+ /* Verify that we have a reference to the node from the objects folder */
|
|
|
|
+ UA_BrowseDescription bd;
|
|
|
|
+ UA_BrowseDescription_init(&bd);
|
|
|
|
+ bd.nodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER);
|
|
|
|
+ bd.referenceTypeId = UA_NODEID_NUMERIC(0, UA_NS0ID_HASCOMPONENT);
|
|
|
|
+ bd.browseDirection = UA_BROWSEDIRECTION_FORWARD;
|
|
|
|
+
|
|
|
|
+ UA_BrowseResult br = UA_Server_browse(server, 0, &bd);
|
|
|
|
+ ck_assert_int_eq(br.statusCode, UA_STATUSCODE_GOOD);
|
|
|
|
+ size_t refCount = 0;
|
|
|
|
+ for(size_t i = 0; i < br.referencesSize; ++i) {
|
|
|
|
+ if(UA_NodeId_equal(&br.references[i].nodeId.nodeId, &objectid))
|
|
|
|
+ refCount++;
|
|
|
|
+ }
|
|
|
|
+ ck_assert_int_eq(refCount, 1);
|
|
|
|
+ UA_BrowseResult_deleteMembers(&br);
|
|
|
|
+
|
|
|
|
+ /* Delete the object */
|
|
|
|
+ UA_Server_deleteNode(server, objectid, true);
|
|
|
|
+
|
|
|
|
+ /* Browse again, this time we expect that no reference is found */
|
|
|
|
+ br = UA_Server_browse(server, 0, &bd);
|
|
|
|
+ ck_assert_int_eq(br.statusCode, UA_STATUSCODE_GOOD);
|
|
|
|
+ refCount = 0;
|
|
|
|
+ for(size_t i = 0; i < br.referencesSize; ++i) {
|
|
|
|
+ if(UA_NodeId_equal(&br.references[i].nodeId.nodeId, &objectid))
|
|
|
|
+ refCount++;
|
|
|
|
+ }
|
|
|
|
+ ck_assert_int_eq(refCount, 0);
|
|
|
|
+ UA_BrowseResult_deleteMembers(&br);
|
|
|
|
+
|
|
|
|
+ /* Add an object the second time */
|
|
|
|
+ UA_ObjectAttributes_init(&attr);
|
|
|
|
+ attr.displayName = UA_LOCALIZEDTEXT("en_US","my object");
|
|
|
|
+ objectid = UA_NODEID_NUMERIC(0, 23372337);
|
|
|
|
+ res = UA_Server_addObjectNode(server, objectid, UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER),
|
|
|
|
+ UA_NODEID_NUMERIC(0, UA_NS0ID_HASCOMPONENT), UA_QUALIFIEDNAME(0, ""),
|
|
|
|
+ UA_NODEID_NULL, attr, NULL, NULL);
|
|
|
|
+ ck_assert_int_eq(res, UA_STATUSCODE_GOOD);
|
|
|
|
+
|
|
|
|
+ /* Browse again, this time we expect that a single reference to the node is found */
|
|
|
|
+ refCount = 0;
|
|
|
|
+ br = UA_Server_browse(server, 0, &bd);
|
|
|
|
+ ck_assert_int_eq(br.statusCode, UA_STATUSCODE_GOOD);
|
|
|
|
+ for(size_t i = 0; i < br.referencesSize; ++i) {
|
|
|
|
+ if(UA_NodeId_equal(&br.references[i].nodeId.nodeId, &objectid))
|
|
|
|
+ refCount++;
|
|
|
|
+ }
|
|
|
|
+ ck_assert_int_eq(refCount, 1);
|
|
|
|
+ UA_BrowseResult_deleteMembers(&br);
|
|
|
|
+
|
|
|
|
+ UA_Server_delete(server);
|
|
|
|
+} END_TEST
|
|
|
|
+
|
|
static Suite * testSuite_services_nodemanagement(void) {
|
|
static Suite * testSuite_services_nodemanagement(void) {
|
|
Suite *s = suite_create("services_nodemanagement");
|
|
Suite *s = suite_create("services_nodemanagement");
|
|
|
|
|
|
@@ -183,6 +251,7 @@ static Suite * testSuite_services_nodemanagement(void) {
|
|
|
|
|
|
TCase *tc_deletenodes = tcase_create("deletenodes");
|
|
TCase *tc_deletenodes = tcase_create("deletenodes");
|
|
tcase_add_test(tc_addnodes, DeleteObjectWithDestructor);
|
|
tcase_add_test(tc_addnodes, DeleteObjectWithDestructor);
|
|
|
|
+ tcase_add_test(tc_addnodes, DeleteObjectAndReferences);
|
|
|
|
|
|
suite_add_tcase(s, tc_addnodes);
|
|
suite_add_tcase(s, tc_addnodes);
|
|
suite_add_tcase(s, tc_deletenodes);
|
|
suite_add_tcase(s, tc_deletenodes);
|