check_pubsub_subscribe.c 59 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  4. *
  5. * Copyright (c) 2019 Kalycito Infotech Private Limited
  6. */
  7. #include <open62541/plugin/pubsub_udp.h>
  8. #include <open62541/server_config_default.h>
  9. #include <open62541/server_pubsub.h>
  10. #include <check.h>
  11. #include <time.h>
  12. #include "open62541/types_generated_encoding_binary.h"
  13. #include "ua_pubsub.h"
  14. #include "ua_server_internal.h"
  15. #define UA_SUBSCRIBER_PORT 4801 /* Port for Subscriber*/
  16. #define PUBLISH_INTERVAL 5 /* Publish interval*/
  17. #define DATASET_WRITER_ID 62541 /* DataSet Writer Id*/
  18. #define WRITER_GROUP_ID 100 /* Writer group Id */
  19. #define PUBLISHVARIABLE_NODEID 1000 /* Published data nodeId */
  20. #define SUBSCRIBEOBJECT_NODEID 1001 /* Object nodeId */
  21. #define SUBSCRIBEVARIABLE_NODEID 1002 /* Subscribed data nodeId */
  22. /* Global declaration for test cases */
  23. UA_Server *server = NULL;
  24. UA_ServerConfig *config = NULL;
  25. UA_NodeId connection_test;
  26. UA_NodeId readerGroupTest;
  27. UA_NodeId publishedDataSetTest;
  28. /* setup() is to create an environment for test cases */
  29. static void setup(void) {
  30. /*Add setup by creating new server with valid configuration */
  31. server = UA_Server_new();
  32. config = UA_Server_getConfig(server);
  33. UA_ServerConfig_setMinimal(config, UA_SUBSCRIBER_PORT, NULL);
  34. UA_Server_run_startup(server);
  35. config->pubsubTransportLayers = (UA_PubSubTransportLayer *) UA_malloc(sizeof(UA_PubSubTransportLayer));
  36. if(!config->pubsubTransportLayers) {
  37. UA_ServerConfig_clean(config);
  38. }
  39. config->pubsubTransportLayers[0] = UA_PubSubTransportLayerUDPMP();
  40. config->pubsubTransportLayersSize++;
  41. /* Add connection to the server */
  42. UA_PubSubConnectionConfig connectionConfig;
  43. memset(&connectionConfig, 0, sizeof(UA_PubSubConnectionConfig));
  44. connectionConfig.name = UA_STRING("UADP Test Connection");
  45. UA_NetworkAddressUrlDataType networkAddressUrl = {UA_STRING_NULL, UA_STRING("opc.udp://224.0.0.22:4801/")};
  46. UA_Variant_setScalar(&connectionConfig.address, &networkAddressUrl,
  47. &UA_TYPES[UA_TYPES_NETWORKADDRESSURLDATATYPE]);
  48. connectionConfig.transportProfileUri = UA_STRING("http://opcfoundation.org/UA-Profile/Transport/pubsub-udp-uadp");
  49. UA_Server_addPubSubConnection(server, &connectionConfig, &connection_test);
  50. }
  51. /* teardown() is to delete the environment set for test cases */
  52. static void teardown(void) {
  53. /*Call server delete functions */
  54. UA_Server_run_shutdown(server);
  55. UA_Server_delete(server);
  56. }
  57. START_TEST(AddReaderGroupWithValidConfiguration) {
  58. /* To test if ReaderGroup has been added to the connection with valid configuration */
  59. UA_StatusCode retVal;
  60. UA_ReaderGroupConfig readerGroupConfig;
  61. memset(&readerGroupConfig, 0, sizeof(readerGroupConfig));
  62. readerGroupConfig.name = UA_STRING("ReaderGroup Test");
  63. UA_NodeId localreaderGroup;
  64. retVal = UA_Server_addReaderGroup(server, connection_test, &readerGroupConfig, &localreaderGroup);
  65. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  66. size_t readerGroupCount = 0;
  67. UA_ReaderGroup *readerGroup;
  68. LIST_FOREACH(readerGroup, &UA_PubSubConnection_findConnectionbyId(server, connection_test)->readerGroups, listEntry){
  69. readerGroupCount++;
  70. }
  71. /* Check readerGroup count */
  72. ck_assert_int_eq(readerGroupCount, 1);
  73. /* To Do: RemoveReaderGroup operation should be carried out when UA_Server_delete has been called */
  74. UA_Server_removeReaderGroup(server, localreaderGroup);
  75. } END_TEST
  76. START_TEST(AddReaderGroupWithNullConfig) {
  77. /* Check the status of adding ReaderGroup when NULL configuration is given */
  78. UA_StatusCode retVal = UA_STATUSCODE_GOOD;
  79. retVal |= UA_Server_addReaderGroup(server, connection_test, NULL, NULL);
  80. ck_assert_int_ne(retVal, UA_STATUSCODE_GOOD);
  81. size_t readerGroupCount = 0;
  82. UA_ReaderGroup *readerGroup;
  83. LIST_FOREACH(readerGroup, &UA_PubSubConnection_findConnectionbyId(server, connection_test)->readerGroups, listEntry){
  84. readerGroupCount++;
  85. }
  86. /* Check readerGroup count */
  87. ck_assert_int_eq(readerGroupCount, 0);
  88. } END_TEST
  89. START_TEST(AddReaderGroupWithInvalidConnectionId) {
  90. /* Check status of adding ReaderGroup with invalid connection identifier */
  91. UA_StatusCode retVal = UA_STATUSCODE_GOOD;
  92. UA_ReaderGroupConfig readerGroupConfig;
  93. memset(&readerGroupConfig, 0, sizeof(readerGroupConfig));
  94. readerGroupConfig.name = UA_STRING("ReaderGroup Test");
  95. retVal |= UA_Server_addReaderGroup(server, UA_NODEID_NUMERIC(0, UA_UINT32_MAX), &readerGroupConfig, NULL);
  96. ck_assert_int_ne(retVal, UA_STATUSCODE_GOOD);
  97. size_t readerGroupCount = 0;
  98. UA_ReaderGroup *readerGroup;
  99. LIST_FOREACH(readerGroup, &UA_PubSubConnection_findConnectionbyId(server, connection_test)->readerGroups, listEntry){
  100. readerGroupCount++;
  101. }
  102. /* Check readerGroup count */
  103. ck_assert_int_eq(readerGroupCount, 0);
  104. } END_TEST
  105. START_TEST(RemoveReaderGroupWithInvalidIdentifier) {
  106. /* Check status of removing ReaderGroup when giving invalid ReaderGroup identifier */
  107. UA_StatusCode retVal = UA_STATUSCODE_GOOD;
  108. UA_ReaderGroupConfig readerGroupConfig;
  109. UA_NodeId localreaderGroup;
  110. memset(&readerGroupConfig, 0, sizeof(readerGroupConfig));
  111. readerGroupConfig.name = UA_STRING("ReaderGroup Test");
  112. retVal |= UA_Server_addReaderGroup(server, connection_test, &readerGroupConfig, &localreaderGroup);
  113. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  114. /* Delete the added readerGroup */
  115. retVal |= UA_Server_removeReaderGroup(server, UA_NODEID_NUMERIC(0, UA_UINT32_MAX));
  116. ck_assert_int_ne(retVal, UA_STATUSCODE_GOOD);
  117. size_t readerGroupCount = 0;
  118. UA_ReaderGroup *readerGroup;
  119. LIST_FOREACH(readerGroup, &UA_PubSubConnection_findConnectionbyId(server, connection_test)->readerGroups, listEntry){
  120. readerGroupCount++;
  121. }
  122. /* Check readerGroup count */
  123. ck_assert_int_eq(readerGroupCount, 1);
  124. UA_Server_removeReaderGroup(server, localreaderGroup);
  125. } END_TEST
  126. START_TEST(UpdateReaderGroupWithInvalidIdentifier) {
  127. /* Check status of updating ReaderGroup with invalid identifier */
  128. UA_StatusCode retVal = UA_STATUSCODE_GOOD;
  129. UA_ReaderGroupConfig readerGroupConfig;
  130. UA_NodeId localreaderGroup;
  131. memset(&readerGroupConfig, 0, sizeof(readerGroupConfig));
  132. readerGroupConfig.name = UA_STRING("ReaderGroup Test");
  133. retVal |= UA_Server_addReaderGroup(server, connection_test, &readerGroupConfig, &localreaderGroup);
  134. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  135. retVal |= UA_Server_ReaderGroup_updateConfig(server, UA_NODEID_NUMERIC(0, UA_UINT32_MAX), NULL);
  136. ck_assert_int_ne(retVal, UA_STATUSCODE_GOOD);
  137. UA_Server_removeReaderGroup(server, localreaderGroup);
  138. } END_TEST
  139. START_TEST(GetReaderGroupConfigWithInvalidConfig) {
  140. /* Check status of getting ReaderGroup configuration with invalid configuration */
  141. UA_StatusCode retVal = UA_STATUSCODE_GOOD;
  142. UA_ReaderGroupConfig readerGroupConfig;
  143. UA_NodeId localreaderGroup;
  144. memset(&readerGroupConfig, 0, sizeof(readerGroupConfig));
  145. readerGroupConfig.name = UA_STRING("ReaderGroup Test");
  146. retVal |= UA_Server_addReaderGroup(server, connection_test, &readerGroupConfig, &localreaderGroup);
  147. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  148. retVal |= UA_Server_ReaderGroup_getConfig(server, UA_NODEID_NUMERIC(0, UA_UINT32_MAX), NULL);
  149. ck_assert_int_ne(retVal, UA_STATUSCODE_GOOD);
  150. UA_Server_removeReaderGroup(server, localreaderGroup);
  151. } END_TEST
  152. START_TEST(GetReaderGroupConfigWithInvalidIdentifier) {
  153. /* Check status of getting ReaderGroup configuration with invlaid identifier */
  154. UA_StatusCode retVal = UA_STATUSCODE_GOOD;
  155. UA_ReaderGroupConfig readerGroupConfig;
  156. UA_NodeId localreaderGroup;
  157. memset(&readerGroupConfig, 0, sizeof(readerGroupConfig));
  158. readerGroupConfig.name = UA_STRING("ReaderGroup Test");
  159. retVal |= UA_Server_addReaderGroup(server, connection_test, &readerGroupConfig, &localreaderGroup);
  160. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  161. retVal |= UA_Server_ReaderGroup_getConfig(server, UA_NODEID_NUMERIC(0, UA_UINT32_MAX), &readerGroupConfig);
  162. ck_assert_int_ne(retVal, UA_STATUSCODE_GOOD);
  163. UA_Server_removeReaderGroup(server, localreaderGroup);
  164. } END_TEST
  165. START_TEST(GetReaderGroupConfigWithValidConfig) {
  166. /* Check status of getting ReaderGroup configuration with valid parameters */
  167. UA_StatusCode retVal = UA_STATUSCODE_GOOD;
  168. UA_NodeId localreaderGroup;
  169. UA_ReaderGroupConfig readerGroupConfig;
  170. memset(&readerGroupConfig, 0, sizeof(readerGroupConfig));
  171. readerGroupConfig.name = UA_STRING("ReaderGroup Test");
  172. retVal |= UA_Server_addReaderGroup(server, connection_test, &readerGroupConfig, &localreaderGroup);
  173. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  174. retVal |= UA_Server_ReaderGroup_getConfig(server, localreaderGroup, &readerGroupConfig);
  175. /* To Do: DeleteMembers of readergroup config has to be a separate function */
  176. UA_String_deleteMembers (&readerGroupConfig.name);
  177. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  178. } END_TEST
  179. START_TEST(AddDataSetReaderWithValidConfiguration) {
  180. /* Check status of adding DataSetReader to ReaderGroup with valid parameters*/
  181. UA_StatusCode retVal = UA_STATUSCODE_GOOD;
  182. UA_DataSetReaderConfig dataSetreaderConfig;
  183. UA_NodeId localreaderGroup;
  184. UA_ReaderGroupConfig readerGroupConfig;
  185. UA_NodeId localDataSetreader;
  186. memset(&readerGroupConfig, 0, sizeof(readerGroupConfig));
  187. readerGroupConfig.name = UA_STRING("ReaderGroup Test");
  188. retVal |= UA_Server_addReaderGroup(server, connection_test, &readerGroupConfig, &localreaderGroup);
  189. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  190. memset(&dataSetreaderConfig, 0, sizeof(dataSetreaderConfig));
  191. dataSetreaderConfig.name = UA_STRING("DataSetreader Test");
  192. retVal |= UA_Server_addDataSetReader(server, localreaderGroup, &dataSetreaderConfig, &localDataSetreader);
  193. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  194. } END_TEST
  195. START_TEST(AddDataSetReaderWithNullConfig) {
  196. /* Check status of adding DataSetReader to ReaderGroup with invalid parameters */
  197. UA_StatusCode retVal = UA_STATUSCODE_GOOD;
  198. UA_DataSetReaderConfig dataSetreaderConfig;
  199. UA_NodeId localreaderGroup;
  200. UA_ReaderGroupConfig readerGroupConfig;
  201. memset(&readerGroupConfig, 0, sizeof(readerGroupConfig));
  202. readerGroupConfig.name = UA_STRING("ReaderGroup Test");
  203. retVal |= UA_Server_addReaderGroup(server, connection_test, &readerGroupConfig, &localreaderGroup);
  204. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  205. memset(&dataSetreaderConfig, 0, sizeof(dataSetreaderConfig));
  206. dataSetreaderConfig.name = UA_STRING("DataSetreader Test ");
  207. /* Remove the added DataSetReader */
  208. retVal |= UA_Server_addDataSetReader(server, localreaderGroup, NULL, NULL);
  209. ck_assert_int_ne(retVal, UA_STATUSCODE_GOOD);
  210. } END_TEST
  211. START_TEST(RemoveDataSetReaderWithValidConfiguration) {
  212. /* Check status of adding DataSetReader to ReaderGroup with valid parameters */
  213. UA_StatusCode retVal = UA_STATUSCODE_GOOD;
  214. UA_DataSetReaderConfig dataSetreaderConfig;
  215. UA_NodeId localreaderGroup;
  216. UA_ReaderGroupConfig readerGroupConfig;
  217. UA_NodeId localDataSetreader;
  218. memset(&readerGroupConfig, 0, sizeof(readerGroupConfig));
  219. readerGroupConfig.name = UA_STRING("ReaderGroup Test");
  220. retVal |= UA_Server_addReaderGroup(server, connection_test, &readerGroupConfig, &localreaderGroup);
  221. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  222. memset(&dataSetreaderConfig, 0, sizeof(dataSetreaderConfig));
  223. dataSetreaderConfig.name = UA_STRING("DataSetReader Test ");
  224. retVal |= UA_Server_addDataSetReader(server, localreaderGroup, &dataSetreaderConfig, &localDataSetreader);
  225. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  226. retVal |= UA_Server_removeDataSetReader(server, localDataSetreader);
  227. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  228. } END_TEST
  229. START_TEST(RemoveDataSetReaderWithInvalidIdentifier) {
  230. /* Check status of removing DataSetReader from ReaderGroup with invalid parameters */
  231. UA_StatusCode retVal = UA_STATUSCODE_GOOD;
  232. UA_DataSetReaderConfig dataSetreaderConfig;
  233. UA_NodeId localreaderGroup;
  234. UA_ReaderGroupConfig readerGroupConfig;
  235. memset(&readerGroupConfig, 0, sizeof(readerGroupConfig));
  236. readerGroupConfig.name = UA_STRING("ReaderGroup Test");
  237. retVal |= UA_Server_addReaderGroup(server, connection_test, &readerGroupConfig, &localreaderGroup);
  238. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  239. memset(&dataSetreaderConfig, 0, sizeof(dataSetreaderConfig));
  240. dataSetreaderConfig.name = UA_STRING("DataSetReader Test ");
  241. retVal |= UA_Server_addDataSetReader(server, localreaderGroup, NULL, NULL);
  242. ck_assert_int_ne(retVal, UA_STATUSCODE_GOOD);
  243. /* Remove the added DataSetReader */
  244. retVal |= UA_Server_removeDataSetReader(server, UA_NODEID_NUMERIC(0, UA_UINT32_MAX));
  245. ck_assert_int_ne(retVal, UA_STATUSCODE_GOOD);
  246. } END_TEST
  247. START_TEST(UpdateDataSetReaderConfigWithInvalidId) {
  248. /* Check status of updatting DataSetReader with invalid configuration */
  249. UA_StatusCode retVal = UA_STATUSCODE_GOOD;
  250. UA_DataSetReaderConfig dataSetreaderConfig;
  251. UA_NodeId localreaderGroup;
  252. UA_NodeId localDataSetreader;
  253. UA_ReaderGroupConfig readerGroupConfig;
  254. memset(&readerGroupConfig, 0, sizeof(readerGroupConfig));
  255. readerGroupConfig.name = UA_STRING("ReaderGroup Test");
  256. retVal |= UA_Server_addReaderGroup(server, connection_test, &readerGroupConfig, &localreaderGroup);
  257. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  258. memset(&dataSetreaderConfig, 0, sizeof(dataSetreaderConfig));
  259. retVal |= UA_Server_addDataSetReader(server, localreaderGroup,
  260. &dataSetreaderConfig, &localDataSetreader);
  261. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  262. retVal |= UA_Server_DataSetReader_updateConfig(server, UA_NODEID_NUMERIC(0, UA_UINT32_MAX),
  263. localreaderGroup, &dataSetreaderConfig );
  264. ck_assert_int_ne(retVal, UA_STATUSCODE_GOOD);
  265. } END_TEST
  266. START_TEST(GetDataSetReaderConfigWithValidConfiguration) {
  267. /* Check status of getting DataSetReader with Valid configuration */
  268. UA_StatusCode retVal = UA_STATUSCODE_GOOD;
  269. UA_DataSetReaderConfig dataSetreaderConfig;
  270. UA_NodeId localreaderGroup;
  271. UA_NodeId localDataSetreader;
  272. UA_ReaderGroupConfig readerGroupConfig;
  273. memset(&readerGroupConfig, 0, sizeof(readerGroupConfig));
  274. readerGroupConfig.name = UA_STRING("ReaderGroup Test");
  275. retVal |= UA_Server_addReaderGroup(server, connection_test, &readerGroupConfig, &localreaderGroup);
  276. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  277. memset(&dataSetreaderConfig, 0, sizeof(dataSetreaderConfig));
  278. retVal |= UA_Server_addDataSetReader(server, localreaderGroup, &dataSetreaderConfig, &localDataSetreader);
  279. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  280. retVal |= UA_Server_DataSetReader_getConfig(server, localDataSetreader, &dataSetreaderConfig);
  281. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  282. } END_TEST
  283. START_TEST(GetDataSetReaderConfigWithInvalidConfiguration) {
  284. /* Check status of getting DataSetReader with Invalid configuration */
  285. UA_StatusCode retVal = UA_STATUSCODE_GOOD;
  286. UA_DataSetReaderConfig dataSetreaderConfig;
  287. UA_NodeId localreaderGroup;
  288. UA_NodeId localDataSetreader;
  289. UA_ReaderGroupConfig readerGroupConfig;
  290. memset(&readerGroupConfig, 0, sizeof(readerGroupConfig));
  291. readerGroupConfig.name = UA_STRING("ReaderGroup Test");
  292. retVal |= UA_Server_addReaderGroup(server, connection_test, &readerGroupConfig, &localreaderGroup);
  293. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  294. memset(&dataSetreaderConfig, 0, sizeof(dataSetreaderConfig));
  295. retVal |= UA_Server_addDataSetReader(server, localreaderGroup, &dataSetreaderConfig, &localDataSetreader);
  296. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  297. retVal |= UA_Server_DataSetReader_getConfig(server, localDataSetreader, NULL);
  298. ck_assert_int_ne(retVal, UA_STATUSCODE_GOOD);
  299. } END_TEST
  300. START_TEST(GetDataSetReaderConfigWithInvalidIdentifier) {
  301. /* Check status of getting DataSetReader with Invalid Identifier */
  302. UA_StatusCode retVal = UA_STATUSCODE_GOOD;
  303. UA_DataSetReaderConfig dataSetreaderConfig;
  304. UA_NodeId localreaderGroup;
  305. UA_NodeId localDataSetreader;
  306. UA_ReaderGroupConfig readerGroupConfig;
  307. memset(&readerGroupConfig, 0, sizeof(readerGroupConfig));
  308. readerGroupConfig.name = UA_STRING("ReaderGroup Test");
  309. retVal |= UA_Server_addReaderGroup(server, connection_test, &readerGroupConfig, &localreaderGroup);
  310. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  311. memset(&dataSetreaderConfig, 0, sizeof(dataSetreaderConfig));
  312. retVal |= UA_Server_addDataSetReader(server, localreaderGroup, &dataSetreaderConfig, &localDataSetreader);
  313. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  314. retVal |= UA_Server_DataSetReader_getConfig(server, UA_NODEID_NUMERIC(0, UA_UINT32_MAX), &dataSetreaderConfig);
  315. ck_assert_int_ne(retVal, UA_STATUSCODE_GOOD);
  316. } END_TEST
  317. START_TEST(CreateTargetVariableWithInvalidConfiguration) {
  318. /* Check status to create target variable with invalid configuration */
  319. UA_StatusCode retVal = UA_STATUSCODE_GOOD;
  320. UA_DataSetReaderConfig dataSetreaderConfig;
  321. UA_NodeId localreaderGroup;
  322. UA_NodeId localDataSetreader;
  323. UA_TargetVariablesDataType localTargetVariable;
  324. UA_ReaderGroupConfig readerGroupConfig;
  325. memset(&readerGroupConfig, 0, sizeof(readerGroupConfig));
  326. readerGroupConfig.name = UA_STRING("ReaderGroup Test");
  327. retVal |= UA_Server_addReaderGroup(server, connection_test, &readerGroupConfig, &localreaderGroup);
  328. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  329. memset(&dataSetreaderConfig, 0, sizeof(dataSetreaderConfig));
  330. retVal |= UA_Server_addDataSetReader(server, localreaderGroup, &dataSetreaderConfig, &localDataSetreader);
  331. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  332. retVal |= UA_Server_DataSetReader_createTargetVariables(server, UA_NODEID_NUMERIC(0, UA_UINT32_MAX), &localTargetVariable);
  333. ck_assert_int_ne(retVal, UA_STATUSCODE_GOOD);
  334. } END_TEST
  335. START_TEST(AddTargetVariableWithInvalidConfiguration) {
  336. /* Check status to create target variable with invalid configuration */
  337. UA_StatusCode retVal = UA_STATUSCODE_GOOD;
  338. UA_DataSetReaderConfig dataSetreaderConfig;
  339. UA_NodeId localreaderGroup;
  340. UA_NodeId localDataSetreader;
  341. UA_ReaderGroupConfig readerGroupConfig;
  342. memset(&readerGroupConfig, 0, sizeof(readerGroupConfig));
  343. readerGroupConfig.name = UA_STRING("ReaderGroup Test");
  344. retVal |= UA_Server_addReaderGroup(server, connection_test, &readerGroupConfig, &localreaderGroup);
  345. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  346. memset(&dataSetreaderConfig, 0, sizeof(dataSetreaderConfig));
  347. retVal |= UA_Server_addDataSetReader(server, localreaderGroup, &dataSetreaderConfig, &localDataSetreader);
  348. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  349. retVal |= UA_Server_DataSetReader_addTargetVariables(NULL, &localreaderGroup, localDataSetreader, UA_PUBSUB_SDS_TARGET);
  350. ck_assert_int_ne(retVal, UA_STATUSCODE_GOOD);
  351. } END_TEST
  352. START_TEST(AddTargetVariableWithValidConfiguration) {
  353. /* Check status after creating target variables with Valid configuration */
  354. UA_StatusCode retVal = UA_STATUSCODE_GOOD;
  355. UA_DataSetReaderConfig dataSetReaderConfig;
  356. UA_NodeId folderId;
  357. UA_QualifiedName folderBrowseName;
  358. UA_NodeId localreaderGroupIdentifier;
  359. UA_NodeId localDataSetreaderIdentifier;
  360. UA_ObjectAttributes oAttr = UA_ObjectAttributes_default;
  361. UA_ReaderGroupConfig readerGroupConfig;
  362. memset(&readerGroupConfig, 0, sizeof(readerGroupConfig));
  363. readerGroupConfig.name = UA_STRING("ReaderGroup Test");
  364. retVal |= UA_Server_addReaderGroup(server, connection_test, &readerGroupConfig, &localreaderGroupIdentifier);
  365. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  366. memset(&dataSetReaderConfig, 0, sizeof(UA_DataSetReaderConfig));
  367. UA_DataSetMetaDataType *pMetaData = &dataSetReaderConfig.dataSetMetaData;
  368. UA_DataSetMetaDataType_init (pMetaData);
  369. pMetaData->name = UA_STRING ("DataSet Test");
  370. /* Static definition of number of fields size to 4 to create four different
  371. * targetVariables of distinct datatype */
  372. pMetaData->fieldsSize = 1;
  373. pMetaData->fields = (UA_FieldMetaData*)UA_Array_new (pMetaData->fieldsSize,
  374. &UA_TYPES[UA_TYPES_FIELDMETADATA]);
  375. /* DateTime DataType */
  376. UA_FieldMetaData_init (&pMetaData->fields[0]);
  377. UA_NodeId_copy (&UA_TYPES[UA_TYPES_DATETIME].typeId,
  378. &pMetaData->fields[0].dataType);
  379. pMetaData->fields[0].builtInType = UA_NS0ID_DATETIME;
  380. pMetaData->fields[0].valueRank = -1; /* scalar */
  381. retVal |= UA_Server_addDataSetReader(server, localreaderGroupIdentifier, &dataSetReaderConfig, &localDataSetreaderIdentifier);
  382. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  383. folderBrowseName = UA_QUALIFIEDNAME (1, "Subscribed Variables");
  384. UA_Server_addObjectNode (server, UA_NODEID_NULL,
  385. UA_NODEID_NUMERIC (0, UA_NS0ID_OBJECTSFOLDER),
  386. UA_NODEID_NUMERIC (0, UA_NS0ID_ORGANIZES),
  387. folderBrowseName, UA_NODEID_NUMERIC (0,
  388. UA_NS0ID_BASEOBJECTTYPE), oAttr, NULL, &folderId);
  389. retVal |= UA_Server_DataSetReader_addTargetVariables(server, &folderId, localDataSetreaderIdentifier, UA_PUBSUB_SDS_TARGET);
  390. UA_free(pMetaData->fields);
  391. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  392. } END_TEST
  393. START_TEST(SinglePublishSubscribeDateTime) {
  394. /* To check status after running both publisher and subscriber */
  395. UA_StatusCode retVal = UA_STATUSCODE_GOOD;
  396. UA_PublishedDataSetConfig pdsConfig;
  397. UA_NodeId dataSetWriter;
  398. UA_NodeId readerIdentifier;
  399. UA_NodeId writerGroup;
  400. UA_DataSetReaderConfig readerConfig;
  401. memset(&pdsConfig, 0, sizeof(UA_PublishedDataSetConfig));
  402. pdsConfig.publishedDataSetType = UA_PUBSUB_DATASET_PUBLISHEDITEMS;
  403. pdsConfig.name = UA_STRING("PublishedDataSet Test");
  404. UA_Server_addPublishedDataSet(server, &pdsConfig, &publishedDataSetTest);
  405. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  406. /* Data Set Field */
  407. UA_NodeId dataSetFieldId;
  408. UA_DataSetFieldConfig dataSetFieldConfig;
  409. memset(&dataSetFieldConfig, 0, sizeof(UA_DataSetFieldConfig));
  410. dataSetFieldConfig.dataSetFieldType = UA_PUBSUB_DATASETFIELD_VARIABLE;
  411. dataSetFieldConfig.field.variable.fieldNameAlias = UA_STRING("Server localtime");
  412. dataSetFieldConfig.field.variable.promotedField = UA_FALSE;
  413. dataSetFieldConfig.field.variable.publishParameters.publishedVariable = UA_NODEID_NUMERIC(0, UA_NS0ID_SERVER_LOCALTIME);
  414. dataSetFieldConfig.field.variable.publishParameters.attributeId = UA_ATTRIBUTEID_VALUE;
  415. UA_Server_addDataSetField(server, publishedDataSetTest, &dataSetFieldConfig, &dataSetFieldId);
  416. /* Writer group */
  417. UA_WriterGroupConfig writerGroupConfig;
  418. memset(&writerGroupConfig, 0, sizeof(writerGroupConfig));
  419. writerGroupConfig.name = UA_STRING("WriterGroup Test");
  420. writerGroupConfig.publishingInterval = PUBLISH_INTERVAL;
  421. writerGroupConfig.enabled = UA_FALSE;
  422. writerGroupConfig.writerGroupId = WRITER_GROUP_ID;
  423. writerGroupConfig.encodingMimeType = UA_PUBSUB_ENCODING_UADP;
  424. retVal |= UA_Server_addWriterGroup(server, connection_test, &writerGroupConfig, &writerGroup);
  425. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  426. /* DataSetWriter */
  427. UA_DataSetWriterConfig dataSetWriterConfig;
  428. memset(&dataSetWriterConfig, 0, sizeof(dataSetWriterConfig));
  429. dataSetWriterConfig.name = UA_STRING("DataSetWriter Test");
  430. dataSetWriterConfig.dataSetWriterId = DATASET_WRITER_ID;
  431. dataSetWriterConfig.keyFrameCount = 10;
  432. retVal |= UA_Server_addDataSetWriter(server, writerGroup, publishedDataSetTest, &dataSetWriterConfig, &dataSetWriter);
  433. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  434. /* Reader Group */
  435. UA_ReaderGroupConfig readerGroupConfig;
  436. memset (&readerGroupConfig, 0, sizeof (UA_ReaderGroupConfig));
  437. readerGroupConfig.name = UA_STRING ("ReaderGroup Test");
  438. retVal |= UA_Server_addReaderGroup (server, connection_test, &readerGroupConfig,
  439. &readerGroupTest);
  440. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  441. /* Data Set Reader */
  442. memset (&readerConfig, 0, sizeof (UA_DataSetReaderConfig));
  443. readerConfig.name = UA_STRING ("DataSetReader Test");
  444. readerConfig.dataSetWriterId = DATASET_WRITER_ID;
  445. /* Setting up Meta data configuration in DataSetReader for DateTime DataType */
  446. UA_DataSetMetaDataType *pMetaData = &readerConfig.dataSetMetaData;
  447. /* FilltestMetadata function in subscriber implementation */
  448. UA_DataSetMetaDataType_init (pMetaData);
  449. pMetaData->name = UA_STRING ("DataSet Test");
  450. /* Static definition of number of fields size to 1 to create one
  451. targetVariable */
  452. pMetaData->fieldsSize = 1;
  453. pMetaData->fields = (UA_FieldMetaData*)UA_Array_new (pMetaData->fieldsSize,
  454. &UA_TYPES[UA_TYPES_FIELDMETADATA]);
  455. /* DateTime DataType */
  456. UA_FieldMetaData_init (&pMetaData->fields[0]);
  457. UA_NodeId_copy (&UA_TYPES[UA_TYPES_DATETIME].typeId,
  458. &pMetaData->fields[0].dataType);
  459. pMetaData->fields[0].builtInType = UA_NS0ID_DATETIME;
  460. pMetaData->fields[0].valueRank = -1; /* scalar */
  461. retVal |= UA_Server_addDataSetReader (server, readerGroupTest, &readerConfig,
  462. &readerIdentifier);
  463. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  464. /* Add Subscribed Variables */
  465. UA_NodeId folderId;
  466. UA_String folderName = readerConfig.dataSetMetaData.name;
  467. UA_ObjectAttributes oAttr = UA_ObjectAttributes_default;
  468. UA_QualifiedName folderBrowseName;
  469. if (folderName.length > 0) {
  470. oAttr.displayName.locale = UA_STRING ("en-US");
  471. oAttr.displayName.text = folderName;
  472. folderBrowseName.namespaceIndex = 1;
  473. folderBrowseName.name = folderName;
  474. }
  475. else {
  476. oAttr.displayName = UA_LOCALIZEDTEXT ("en-US", "Subscribed Variables");
  477. folderBrowseName = UA_QUALIFIEDNAME (1, "Subscribed Variables");
  478. }
  479. UA_Server_addObjectNode (server, UA_NODEID_NULL,
  480. UA_NODEID_NUMERIC (0, UA_NS0ID_OBJECTSFOLDER),
  481. UA_NODEID_NUMERIC (0, UA_NS0ID_ORGANIZES),
  482. folderBrowseName, UA_NODEID_NUMERIC (0,
  483. UA_NS0ID_BASEOBJECTTYPE), oAttr, NULL, &folderId);
  484. retVal |= UA_Server_DataSetReader_addTargetVariables (server, &folderId,
  485. readerIdentifier, UA_PUBSUB_SDS_TARGET);
  486. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  487. /* run server - publisher and subscriber */
  488. UA_Server_run_iterate(server,true);
  489. UA_Server_run_iterate(server,true);
  490. UA_free(pMetaData->fields);
  491. }END_TEST
  492. START_TEST(SinglePublishSubscribeInt32) {
  493. /* To check status after running both publisher and subscriber */
  494. UA_StatusCode retVal = UA_STATUSCODE_GOOD;
  495. UA_PublishedDataSetConfig pdsConfig;
  496. UA_NodeId dataSetWriter;
  497. UA_NodeId readerIdentifier;
  498. UA_NodeId writerGroup;
  499. UA_DataSetReaderConfig readerConfig;
  500. /* Published DataSet */
  501. memset(&pdsConfig, 0, sizeof(UA_PublishedDataSetConfig));
  502. pdsConfig.publishedDataSetType = UA_PUBSUB_DATASET_PUBLISHEDITEMS;
  503. pdsConfig.name = UA_STRING("PublishedDataSet Test");
  504. UA_Server_addPublishedDataSet(server, &pdsConfig, &publishedDataSetTest);
  505. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  506. /* Create variable to publish integer data */
  507. UA_NodeId publisherNode;
  508. UA_VariableAttributes attr = UA_VariableAttributes_default;
  509. attr.description = UA_LOCALIZEDTEXT("en-US","Published Int32");
  510. attr.displayName = UA_LOCALIZEDTEXT("en-US","Published Int32");
  511. attr.dataType = UA_TYPES[UA_TYPES_INT32].typeId;
  512. UA_Int32 publisherData = 42;
  513. UA_Variant_setScalar(&attr.value, &publisherData, &UA_TYPES[UA_TYPES_INT32]);
  514. retVal = UA_Server_addVariableNode(server, UA_NODEID_NUMERIC(1, PUBLISHVARIABLE_NODEID),
  515. UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER),
  516. UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES),
  517. UA_QUALIFIEDNAME(1, "Published Int32"),
  518. UA_NODEID_NUMERIC(0, UA_NS0ID_BASEDATAVARIABLETYPE),
  519. attr, NULL, &publisherNode);
  520. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  521. /* Data Set Field */
  522. UA_NodeId dataSetFieldIdent;
  523. UA_DataSetFieldConfig dataSetFieldConfig;
  524. memset(&dataSetFieldConfig, 0, sizeof(UA_DataSetFieldConfig));
  525. dataSetFieldConfig.dataSetFieldType = UA_PUBSUB_DATASETFIELD_VARIABLE;
  526. dataSetFieldConfig.field.variable.fieldNameAlias = UA_STRING("Published Int32");
  527. dataSetFieldConfig.field.variable.promotedField = UA_FALSE;
  528. dataSetFieldConfig.field.variable.publishParameters.publishedVariable = publisherNode;
  529. dataSetFieldConfig.field.variable.publishParameters.attributeId = UA_ATTRIBUTEID_VALUE;
  530. UA_Server_addDataSetField (server, publishedDataSetTest, &dataSetFieldConfig, &dataSetFieldIdent);
  531. /* Writer group */
  532. UA_WriterGroupConfig writerGroupConfig;
  533. memset(&writerGroupConfig, 0, sizeof(writerGroupConfig));
  534. writerGroupConfig.name = UA_STRING("WriterGroup Test");
  535. writerGroupConfig.publishingInterval = PUBLISH_INTERVAL;
  536. writerGroupConfig.enabled = UA_FALSE;
  537. writerGroupConfig.writerGroupId = WRITER_GROUP_ID;
  538. writerGroupConfig.encodingMimeType = UA_PUBSUB_ENCODING_UADP;
  539. retVal |= UA_Server_addWriterGroup(server, connection_test, &writerGroupConfig, &writerGroup);
  540. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  541. /* DataSetWriter */
  542. UA_DataSetWriterConfig dataSetWriterConfig;
  543. memset(&dataSetWriterConfig, 0, sizeof(dataSetWriterConfig));
  544. dataSetWriterConfig.name = UA_STRING("DataSetWriter Test");
  545. dataSetWriterConfig.dataSetWriterId = DATASET_WRITER_ID;
  546. dataSetWriterConfig.keyFrameCount = 10;
  547. retVal |= UA_Server_addDataSetWriter(server, writerGroup, publishedDataSetTest, &dataSetWriterConfig, &dataSetWriter);
  548. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  549. /* Reader Group */
  550. UA_ReaderGroupConfig readerGroupConfig;
  551. memset (&readerGroupConfig, 0, sizeof (UA_ReaderGroupConfig));
  552. readerGroupConfig.name = UA_STRING ("ReaderGroup Test");
  553. retVal |= UA_Server_addReaderGroup(server, connection_test, &readerGroupConfig, &readerGroupTest);
  554. /* Data Set Reader */
  555. /* Parameters to filter received NetworkMessage */
  556. memset (&readerConfig, 0, sizeof (UA_DataSetReaderConfig));
  557. readerConfig.name = UA_STRING ("DataSetReader Test");
  558. readerConfig.dataSetWriterId = DATASET_WRITER_ID;
  559. /* Setting up Meta data configuration in DataSetReader */
  560. UA_DataSetMetaDataType *pMetaData = &readerConfig.dataSetMetaData;
  561. /* FilltestMetadata function in subscriber implementation */
  562. UA_DataSetMetaDataType_init (pMetaData);
  563. pMetaData->name = UA_STRING ("DataSet Test");
  564. /* Static definition of number of fields size to 1 to create one
  565. targetVariable */
  566. pMetaData->fieldsSize = 1;
  567. pMetaData->fields = (UA_FieldMetaData*)UA_Array_new (pMetaData->fieldsSize,
  568. &UA_TYPES[UA_TYPES_FIELDMETADATA]);
  569. /* Unsigned Integer DataType */
  570. UA_FieldMetaData_init (&pMetaData->fields[0]);
  571. UA_NodeId_copy (&UA_TYPES[UA_TYPES_INT32].typeId,
  572. &pMetaData->fields[0].dataType);
  573. pMetaData->fields[0].builtInType = UA_NS0ID_INT32;
  574. pMetaData->fields[0].valueRank = -1; /* scalar */
  575. retVal |= UA_Server_addDataSetReader(server, readerGroupTest, &readerConfig,
  576. &readerIdentifier);
  577. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  578. /* Add Subscribed Variables */
  579. UA_NodeId folderId;
  580. UA_NodeId newnodeId;
  581. UA_String folderName = readerConfig.dataSetMetaData.name;
  582. UA_ObjectAttributes oAttr = UA_ObjectAttributes_default;
  583. UA_QualifiedName folderBrowseName;
  584. if (folderName.length > 0) {
  585. oAttr.displayName.locale = UA_STRING ("en-US");
  586. oAttr.displayName.text = folderName;
  587. folderBrowseName.namespaceIndex = 1;
  588. folderBrowseName.name = folderName;
  589. }
  590. else {
  591. oAttr.displayName = UA_LOCALIZEDTEXT ("en-US", "Subscribed Variables");
  592. folderBrowseName = UA_QUALIFIEDNAME (1, "Subscribed Variables");
  593. }
  594. retVal = UA_Server_addObjectNode(server, UA_NODEID_NUMERIC(1, SUBSCRIBEOBJECT_NODEID),
  595. UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER),
  596. UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES),
  597. folderBrowseName, UA_NODEID_NUMERIC(0,
  598. UA_NS0ID_BASEOBJECTTYPE), oAttr, NULL, &folderId);
  599. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  600. /* Variable to subscribe data */
  601. UA_VariableAttributes vAttr = UA_VariableAttributes_default;
  602. vAttr.description = UA_LOCALIZEDTEXT ("en-US", "Subscribed Int32");
  603. vAttr.displayName = UA_LOCALIZEDTEXT ("en-US", "Subscribed Int32");
  604. vAttr.dataType = UA_TYPES[UA_TYPES_INT32].typeId;
  605. retVal = UA_Server_addVariableNode(server, UA_NODEID_NUMERIC(1, SUBSCRIBEVARIABLE_NODEID),
  606. UA_NODEID_NUMERIC(1, SUBSCRIBEOBJECT_NODEID),
  607. UA_NODEID_NUMERIC(0, UA_NS0ID_HASCOMPONENT), UA_QUALIFIEDNAME(1, "Subscribed Int32"),
  608. UA_NODEID_NUMERIC(0, UA_NS0ID_BASEDATAVARIABLETYPE), vAttr, NULL, &newnodeId);
  609. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  610. UA_TargetVariablesDataType targetVars;
  611. targetVars.targetVariablesSize = 1;
  612. targetVars.targetVariables = (UA_FieldTargetDataType *)
  613. UA_calloc(targetVars.targetVariablesSize,
  614. sizeof(UA_FieldTargetDataType));
  615. /* For creating Targetvariable */
  616. UA_FieldTargetDataType_init(&targetVars.targetVariables[0]);
  617. targetVars.targetVariables[0].attributeId = UA_ATTRIBUTEID_VALUE;
  618. targetVars.targetVariables[0].targetNodeId = newnodeId;
  619. retVal |= UA_Server_DataSetReader_createTargetVariables(server, readerIdentifier,
  620. &targetVars);
  621. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  622. UA_TargetVariablesDataType_deleteMembers(&targetVars);
  623. UA_free(pMetaData->fields);
  624. /* run server - publisher and subscriber */
  625. UA_Server_run_iterate(server,true);
  626. /* Read data sent by the Publisher */
  627. UA_Variant *publishedNodeData = UA_Variant_new();
  628. retVal = UA_Server_readValue(server, UA_NODEID_NUMERIC(1, PUBLISHVARIABLE_NODEID), publishedNodeData);
  629. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  630. /* Read data received by the Subscriber */
  631. UA_Variant *subscribedNodeData = UA_Variant_new();
  632. retVal = UA_Server_readValue(server, UA_NODEID_NUMERIC(1, SUBSCRIBEVARIABLE_NODEID), subscribedNodeData);
  633. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  634. /* Check if data sent from Publisher is being received by Subscriber */
  635. ck_assert_int_eq(*(UA_Int32 *)publishedNodeData->data, *(UA_Int32 *)subscribedNodeData->data);
  636. UA_Variant_delete(subscribedNodeData);
  637. UA_Variant_delete(publishedNodeData);
  638. } END_TEST
  639. START_TEST(SinglePublishSubscribeInt64) {
  640. /* To check status after running both publisher and subscriber */
  641. UA_StatusCode retVal = UA_STATUSCODE_GOOD;
  642. UA_PublishedDataSetConfig pdsConfig;
  643. UA_NodeId dataSetWriter;
  644. UA_NodeId readerIdentifier;
  645. UA_NodeId writerGroup;
  646. UA_DataSetReaderConfig readerConfig;
  647. /* Published DataSet */
  648. memset(&pdsConfig, 0, sizeof(UA_PublishedDataSetConfig));
  649. pdsConfig.publishedDataSetType = UA_PUBSUB_DATASET_PUBLISHEDITEMS;
  650. pdsConfig.name = UA_STRING("PublishedDataSet Test");
  651. UA_Server_addPublishedDataSet(server, &pdsConfig, &publishedDataSetTest);
  652. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  653. /* Create variable to publish integer data */
  654. UA_NodeId publisherNode;
  655. UA_VariableAttributes attr = UA_VariableAttributes_default;
  656. attr.description = UA_LOCALIZEDTEXT("en-US","Published Int64");
  657. attr.displayName = UA_LOCALIZEDTEXT("en-US","Published Int64");
  658. attr.dataType = UA_TYPES[UA_TYPES_INT64].typeId;
  659. UA_Int64 publisherData = 64;
  660. UA_Variant_setScalar(&attr.value, &publisherData, &UA_TYPES[UA_TYPES_INT64]);
  661. retVal = UA_Server_addVariableNode(server, UA_NODEID_NUMERIC(1, PUBLISHVARIABLE_NODEID),
  662. UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER),
  663. UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES),
  664. UA_QUALIFIEDNAME(1, "Published Int64"),
  665. UA_NODEID_NUMERIC(0, UA_NS0ID_BASEDATAVARIABLETYPE),
  666. attr, NULL, &publisherNode);
  667. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  668. /* Data Set Field */
  669. UA_NodeId dataSetFieldIdent;
  670. UA_DataSetFieldConfig dataSetFieldConfig;
  671. memset(&dataSetFieldConfig, 0, sizeof(UA_DataSetFieldConfig));
  672. dataSetFieldConfig.dataSetFieldType = UA_PUBSUB_DATASETFIELD_VARIABLE;
  673. dataSetFieldConfig.field.variable.fieldNameAlias = UA_STRING("Published Int64");
  674. dataSetFieldConfig.field.variable.promotedField = UA_FALSE;
  675. dataSetFieldConfig.field.variable.publishParameters.publishedVariable = publisherNode;
  676. dataSetFieldConfig.field.variable.publishParameters.attributeId = UA_ATTRIBUTEID_VALUE;
  677. UA_Server_addDataSetField (server, publishedDataSetTest, &dataSetFieldConfig, &dataSetFieldIdent);
  678. /* Writer group */
  679. UA_WriterGroupConfig writerGroupConfig;
  680. memset(&writerGroupConfig, 0, sizeof(writerGroupConfig));
  681. writerGroupConfig.name = UA_STRING("WriterGroup Test");
  682. writerGroupConfig.publishingInterval = PUBLISH_INTERVAL;
  683. writerGroupConfig.enabled = UA_FALSE;
  684. writerGroupConfig.writerGroupId = WRITER_GROUP_ID;
  685. writerGroupConfig.encodingMimeType = UA_PUBSUB_ENCODING_UADP;
  686. retVal |= UA_Server_addWriterGroup(server, connection_test, &writerGroupConfig, &writerGroup);
  687. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  688. /* DataSetWriter */
  689. UA_DataSetWriterConfig dataSetWriterConfig;
  690. memset(&dataSetWriterConfig, 0, sizeof(dataSetWriterConfig));
  691. dataSetWriterConfig.name = UA_STRING("DataSetWriter Test");
  692. dataSetWriterConfig.dataSetWriterId = DATASET_WRITER_ID;
  693. dataSetWriterConfig.keyFrameCount = 10;
  694. retVal |= UA_Server_addDataSetWriter(server, writerGroup, publishedDataSetTest, &dataSetWriterConfig, &dataSetWriter);
  695. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  696. /* Reader Group */
  697. UA_ReaderGroupConfig readerGroupConfig;
  698. memset (&readerGroupConfig, 0, sizeof (UA_ReaderGroupConfig));
  699. readerGroupConfig.name = UA_STRING ("ReaderGroup Test");
  700. retVal |= UA_Server_addReaderGroup(server, connection_test, &readerGroupConfig, &readerGroupTest);
  701. /* Data Set Reader */
  702. /* Parameters to filter received NetworkMessage */
  703. memset (&readerConfig, 0, sizeof (UA_DataSetReaderConfig));
  704. readerConfig.name = UA_STRING ("DataSetReader Test");
  705. readerConfig.dataSetWriterId = DATASET_WRITER_ID;
  706. /* Setting up Meta data configuration in DataSetReader */
  707. UA_DataSetMetaDataType *pMetaData = &readerConfig.dataSetMetaData;
  708. /* FilltestMetadata function in subscriber implementation */
  709. UA_DataSetMetaDataType_init (pMetaData);
  710. pMetaData->name = UA_STRING ("DataSet Test");
  711. /* Static definition of number of fields size to 1 to create one
  712. targetVariable */
  713. pMetaData->fieldsSize = 1;
  714. pMetaData->fields = (UA_FieldMetaData*)UA_Array_new (pMetaData->fieldsSize,
  715. &UA_TYPES[UA_TYPES_FIELDMETADATA]);
  716. /* Unsigned Integer DataType */
  717. UA_FieldMetaData_init (&pMetaData->fields[0]);
  718. UA_NodeId_copy (&UA_TYPES[UA_TYPES_INT64].typeId,
  719. &pMetaData->fields[0].dataType);
  720. pMetaData->fields[0].builtInType = UA_NS0ID_INT64;
  721. pMetaData->fields[0].valueRank = -1; /* scalar */
  722. retVal |= UA_Server_addDataSetReader(server, readerGroupTest, &readerConfig,
  723. &readerIdentifier);
  724. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  725. /* Add Subscribed Variables */
  726. UA_NodeId folderId;
  727. UA_NodeId newnodeId;
  728. UA_String folderName = readerConfig.dataSetMetaData.name;
  729. UA_ObjectAttributes oAttr = UA_ObjectAttributes_default;
  730. UA_QualifiedName folderBrowseName;
  731. if (folderName.length > 0) {
  732. oAttr.displayName.locale = UA_STRING ("en-US");
  733. oAttr.displayName.text = folderName;
  734. folderBrowseName.namespaceIndex = 1;
  735. folderBrowseName.name = folderName;
  736. }
  737. else {
  738. oAttr.displayName = UA_LOCALIZEDTEXT ("en-US", "Subscribed Variables");
  739. folderBrowseName = UA_QUALIFIEDNAME (1, "Subscribed Variables");
  740. }
  741. retVal = UA_Server_addObjectNode(server, UA_NODEID_NUMERIC(1, SUBSCRIBEOBJECT_NODEID),
  742. UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER),
  743. UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES),
  744. folderBrowseName, UA_NODEID_NUMERIC(0,
  745. UA_NS0ID_BASEOBJECTTYPE), oAttr, NULL, &folderId);
  746. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  747. /* Variable to subscribe data */
  748. UA_VariableAttributes vAttr = UA_VariableAttributes_default;
  749. vAttr.description = UA_LOCALIZEDTEXT ("en-US", "Subscribed Int64");
  750. vAttr.displayName = UA_LOCALIZEDTEXT ("en-US", "Subscribed Int64");
  751. vAttr.dataType = UA_TYPES[UA_TYPES_INT64].typeId;
  752. retVal = UA_Server_addVariableNode(server, UA_NODEID_NUMERIC(1, SUBSCRIBEVARIABLE_NODEID),
  753. UA_NODEID_NUMERIC(1, SUBSCRIBEOBJECT_NODEID),
  754. UA_NODEID_NUMERIC(0, UA_NS0ID_HASCOMPONENT), UA_QUALIFIEDNAME(1, "Subscribed Int64"),
  755. UA_NODEID_NUMERIC(0, UA_NS0ID_BASEDATAVARIABLETYPE), vAttr, NULL, &newnodeId);
  756. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  757. UA_TargetVariablesDataType targetVars;
  758. targetVars.targetVariablesSize = 1;
  759. targetVars.targetVariables = (UA_FieldTargetDataType *)
  760. UA_calloc(targetVars.targetVariablesSize,
  761. sizeof(UA_FieldTargetDataType));
  762. /* For creating Targetvariable */
  763. UA_FieldTargetDataType_init(&targetVars.targetVariables[0]);
  764. targetVars.targetVariables[0].attributeId = UA_ATTRIBUTEID_VALUE;
  765. targetVars.targetVariables[0].targetNodeId = newnodeId;
  766. retVal |= UA_Server_DataSetReader_createTargetVariables(server, readerIdentifier,
  767. &targetVars);
  768. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  769. UA_TargetVariablesDataType_deleteMembers(&targetVars);
  770. UA_free(pMetaData->fields);
  771. /* run server - publisher and subscriber */
  772. UA_Server_run_iterate(server,true);
  773. /* Read data sent by the Publisher */
  774. UA_Variant *publishedNodeData = UA_Variant_new();
  775. retVal = UA_Server_readValue(server, UA_NODEID_NUMERIC(1, PUBLISHVARIABLE_NODEID), publishedNodeData);
  776. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  777. /* Read data received by the Subscriber */
  778. UA_Variant *subscribedNodeData = UA_Variant_new();
  779. retVal = UA_Server_readValue(server, UA_NODEID_NUMERIC(1, SUBSCRIBEVARIABLE_NODEID), subscribedNodeData);
  780. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  781. /* Check if data sent from Publisher is being received by Subscriber */
  782. ck_assert_int_eq(*(UA_Int64 *)publishedNodeData->data, *(UA_Int64 *)subscribedNodeData->data);
  783. UA_Variant_delete(subscribedNodeData);
  784. UA_Variant_delete(publishedNodeData);
  785. } END_TEST
  786. START_TEST(SinglePublishSubscribeBool) {
  787. /* To check status after running both publisher and subscriber */
  788. UA_StatusCode retVal = UA_STATUSCODE_GOOD;
  789. UA_PublishedDataSetConfig pdsConfig;
  790. UA_NodeId dataSetWriter;
  791. UA_NodeId readerIdentifier;
  792. UA_NodeId writerGroup;
  793. UA_DataSetReaderConfig readerConfig;
  794. /* Published DataSet */
  795. memset(&pdsConfig, 0, sizeof(UA_PublishedDataSetConfig));
  796. pdsConfig.publishedDataSetType = UA_PUBSUB_DATASET_PUBLISHEDITEMS;
  797. pdsConfig.name = UA_STRING("PublishedDataSet Test");
  798. UA_Server_addPublishedDataSet(server, &pdsConfig, &publishedDataSetTest);
  799. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  800. /* Create variable to publish boolean data */
  801. UA_NodeId publisherNode;
  802. UA_VariableAttributes attr = UA_VariableAttributes_default;
  803. attr.description = UA_LOCALIZEDTEXT("en-US","Published Bool");
  804. attr.displayName = UA_LOCALIZEDTEXT("en-US","Published Bool");
  805. attr.dataType = UA_TYPES[UA_TYPES_BOOLEAN].typeId;
  806. UA_Boolean publisherData = UA_FALSE;
  807. UA_Variant_setScalar(&attr.value, &publisherData, &UA_TYPES[UA_TYPES_BOOLEAN]);
  808. retVal = UA_Server_addVariableNode(server, UA_NODEID_NUMERIC(1, PUBLISHVARIABLE_NODEID),
  809. UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER),
  810. UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES),
  811. UA_QUALIFIEDNAME(1, "Published Bool"),
  812. UA_NODEID_NUMERIC(0, UA_NS0ID_BASEDATAVARIABLETYPE),
  813. attr, NULL, &publisherNode);
  814. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  815. /* Data Set Field */
  816. UA_NodeId dataSetFieldIdent;
  817. UA_DataSetFieldConfig dataSetFieldConfig;
  818. memset(&dataSetFieldConfig, 0, sizeof(UA_DataSetFieldConfig));
  819. dataSetFieldConfig.dataSetFieldType = UA_PUBSUB_DATASETFIELD_VARIABLE;
  820. dataSetFieldConfig.field.variable.fieldNameAlias = UA_STRING("Published Bool");
  821. dataSetFieldConfig.field.variable.promotedField = UA_FALSE;
  822. dataSetFieldConfig.field.variable.publishParameters.publishedVariable = publisherNode;
  823. dataSetFieldConfig.field.variable.publishParameters.attributeId = UA_ATTRIBUTEID_VALUE;
  824. UA_Server_addDataSetField (server, publishedDataSetTest, &dataSetFieldConfig, &dataSetFieldIdent);
  825. /* Writer group */
  826. UA_WriterGroupConfig writerGroupConfig;
  827. memset(&writerGroupConfig, 0, sizeof(writerGroupConfig));
  828. writerGroupConfig.name = UA_STRING("WriterGroup Test");
  829. writerGroupConfig.publishingInterval = PUBLISH_INTERVAL;
  830. writerGroupConfig.enabled = UA_FALSE;
  831. writerGroupConfig.writerGroupId = WRITER_GROUP_ID;
  832. writerGroupConfig.encodingMimeType = UA_PUBSUB_ENCODING_UADP;
  833. retVal |= UA_Server_addWriterGroup(server, connection_test, &writerGroupConfig, &writerGroup);
  834. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  835. /* DataSetWriter */
  836. UA_DataSetWriterConfig dataSetWriterConfig;
  837. memset(&dataSetWriterConfig, 0, sizeof(dataSetWriterConfig));
  838. dataSetWriterConfig.name = UA_STRING("DataSetWriter Test");
  839. dataSetWriterConfig.dataSetWriterId = DATASET_WRITER_ID;
  840. dataSetWriterConfig.keyFrameCount = 10;
  841. retVal |= UA_Server_addDataSetWriter(server, writerGroup, publishedDataSetTest, &dataSetWriterConfig, &dataSetWriter);
  842. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  843. /* Reader Group */
  844. UA_ReaderGroupConfig readerGroupConfig;
  845. memset (&readerGroupConfig, 0, sizeof (UA_ReaderGroupConfig));
  846. readerGroupConfig.name = UA_STRING ("ReaderGroup Test");
  847. retVal |= UA_Server_addReaderGroup(server, connection_test, &readerGroupConfig, &readerGroupTest);
  848. /* Data Set Reader */
  849. /* Parameters to filter received NetworkMessage */
  850. memset (&readerConfig, 0, sizeof (UA_DataSetReaderConfig));
  851. readerConfig.name = UA_STRING ("DataSetReader Test");
  852. readerConfig.dataSetWriterId = DATASET_WRITER_ID;
  853. /* Setting up Meta data configuration in DataSetReader */
  854. UA_DataSetMetaDataType *pMetaData = &readerConfig.dataSetMetaData;
  855. /* FilltestMetadata function in subscriber implementation */
  856. UA_DataSetMetaDataType_init (pMetaData);
  857. pMetaData->name = UA_STRING ("DataSet Test");
  858. /* Static definition of number of fields size to 1 to create one
  859. targetVariable */
  860. pMetaData->fieldsSize = 1;
  861. pMetaData->fields = (UA_FieldMetaData*)UA_Array_new (pMetaData->fieldsSize,
  862. &UA_TYPES[UA_TYPES_FIELDMETADATA]);
  863. /* Boolean DataType */
  864. UA_FieldMetaData_init (&pMetaData->fields[0]);
  865. UA_NodeId_copy (&UA_TYPES[UA_TYPES_BOOLEAN].typeId,
  866. &pMetaData->fields[0].dataType);
  867. pMetaData->fields[0].builtInType = UA_NS0ID_BOOLEAN;
  868. pMetaData->fields[0].valueRank = -1; /* scalar */
  869. retVal |= UA_Server_addDataSetReader(server, readerGroupTest, &readerConfig,
  870. &readerIdentifier);
  871. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  872. /* Add Subscribed Variables */
  873. UA_NodeId folderId;
  874. UA_NodeId newnodeId;
  875. UA_String folderName = readerConfig.dataSetMetaData.name;
  876. UA_ObjectAttributes oAttr = UA_ObjectAttributes_default;
  877. UA_QualifiedName folderBrowseName;
  878. if (folderName.length > 0) {
  879. oAttr.displayName.locale = UA_STRING ("en-US");
  880. oAttr.displayName.text = folderName;
  881. folderBrowseName.namespaceIndex = 1;
  882. folderBrowseName.name = folderName;
  883. }
  884. else {
  885. oAttr.displayName = UA_LOCALIZEDTEXT ("en-US", "Subscribed Variables");
  886. folderBrowseName = UA_QUALIFIEDNAME (1, "Subscribed Variables");
  887. }
  888. retVal = UA_Server_addObjectNode(server, UA_NODEID_NUMERIC(1, SUBSCRIBEOBJECT_NODEID),
  889. UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER),
  890. UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES),
  891. folderBrowseName, UA_NODEID_NUMERIC(0,
  892. UA_NS0ID_BASEOBJECTTYPE), oAttr, NULL, &folderId);
  893. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  894. /* Variable to subscribe data */
  895. UA_VariableAttributes vAttr = UA_VariableAttributes_default;
  896. vAttr.description = UA_LOCALIZEDTEXT ("en-US", "Subscribed Bool");
  897. vAttr.displayName = UA_LOCALIZEDTEXT ("en-US", "Subscribed Bool");
  898. vAttr.dataType = UA_TYPES[UA_TYPES_BOOLEAN].typeId;
  899. retVal = UA_Server_addVariableNode(server, UA_NODEID_NUMERIC(1, SUBSCRIBEVARIABLE_NODEID),
  900. UA_NODEID_NUMERIC(1, SUBSCRIBEOBJECT_NODEID),
  901. UA_NODEID_NUMERIC(0, UA_NS0ID_HASCOMPONENT), UA_QUALIFIEDNAME(1, "Subscribed Bool"),
  902. UA_NODEID_NUMERIC(0, UA_NS0ID_BASEDATAVARIABLETYPE), vAttr, NULL, &newnodeId);
  903. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  904. UA_TargetVariablesDataType targetVars;
  905. targetVars.targetVariablesSize = 1;
  906. targetVars.targetVariables = (UA_FieldTargetDataType *)
  907. UA_calloc(targetVars.targetVariablesSize,
  908. sizeof(UA_FieldTargetDataType));
  909. /* For creating Targetvariable */
  910. UA_FieldTargetDataType_init(&targetVars.targetVariables[0]);
  911. targetVars.targetVariables[0].attributeId = UA_ATTRIBUTEID_VALUE;
  912. targetVars.targetVariables[0].targetNodeId = newnodeId;
  913. retVal |= UA_Server_DataSetReader_createTargetVariables(server, readerIdentifier,
  914. &targetVars);
  915. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  916. UA_TargetVariablesDataType_deleteMembers(&targetVars);
  917. UA_free(pMetaData->fields);
  918. /* run server - publisher and subscriber */
  919. UA_Server_run_iterate(server,true);
  920. /* Read data sent by the Publisher */
  921. UA_Variant *publishedNodeData = UA_Variant_new();
  922. retVal = UA_Server_readValue(server, UA_NODEID_NUMERIC(1, PUBLISHVARIABLE_NODEID), publishedNodeData);
  923. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  924. /* Read data received by the Subscriber */
  925. UA_Variant *subscribedNodeData = UA_Variant_new();
  926. retVal = UA_Server_readValue(server, UA_NODEID_NUMERIC(1, SUBSCRIBEVARIABLE_NODEID), subscribedNodeData);
  927. ck_assert_int_eq(retVal, UA_STATUSCODE_GOOD);
  928. /* Check if data sent from Publisher is being received by Subscriber */
  929. ck_assert_int_eq(*(UA_Boolean *)publishedNodeData->data, *(UA_Boolean *)subscribedNodeData->data);
  930. UA_Variant_delete(subscribedNodeData);
  931. UA_Variant_delete(publishedNodeData);
  932. } END_TEST
  933. int main(void) {
  934. TCase *tc_add_pubsub_readergroup = tcase_create("PubSub readerGroup items handling");
  935. tcase_add_checked_fixture(tc_add_pubsub_readergroup, setup, teardown);
  936. /* Test cases for ReaderGroup functionality */
  937. tcase_add_test(tc_add_pubsub_readergroup, AddReaderGroupWithValidConfiguration);
  938. tcase_add_test(tc_add_pubsub_readergroup, AddReaderGroupWithNullConfig);
  939. tcase_add_test(tc_add_pubsub_readergroup, AddReaderGroupWithInvalidConnectionId);
  940. tcase_add_test(tc_add_pubsub_readergroup, RemoveReaderGroupWithInvalidIdentifier);
  941. tcase_add_test(tc_add_pubsub_readergroup, UpdateReaderGroupWithInvalidIdentifier);
  942. tcase_add_test(tc_add_pubsub_readergroup, GetReaderGroupConfigWithInvalidConfig);
  943. tcase_add_test(tc_add_pubsub_readergroup, GetReaderGroupConfigWithInvalidIdentifier);
  944. tcase_add_test(tc_add_pubsub_readergroup, GetReaderGroupConfigWithValidConfig);
  945. /* Test cases for DataSetReader functionality */
  946. tcase_add_test(tc_add_pubsub_readergroup, AddDataSetReaderWithValidConfiguration);
  947. tcase_add_test(tc_add_pubsub_readergroup, AddDataSetReaderWithNullConfig);
  948. tcase_add_test(tc_add_pubsub_readergroup, RemoveDataSetReaderWithValidConfiguration);
  949. tcase_add_test(tc_add_pubsub_readergroup, RemoveDataSetReaderWithInvalidIdentifier);
  950. tcase_add_test(tc_add_pubsub_readergroup, UpdateDataSetReaderConfigWithInvalidId);
  951. tcase_add_test(tc_add_pubsub_readergroup, GetDataSetReaderConfigWithValidConfiguration);
  952. tcase_add_test(tc_add_pubsub_readergroup, GetDataSetReaderConfigWithInvalidConfiguration);
  953. tcase_add_test(tc_add_pubsub_readergroup, GetDataSetReaderConfigWithInvalidIdentifier);
  954. tcase_add_test(tc_add_pubsub_readergroup, CreateTargetVariableWithInvalidConfiguration);
  955. tcase_add_test(tc_add_pubsub_readergroup, AddTargetVariableWithInvalidConfiguration);
  956. tcase_add_test(tc_add_pubsub_readergroup, AddTargetVariableWithValidConfiguration);
  957. /*Test case to run both publisher and subscriber */
  958. TCase *tc_pubsub_publish_subscribe = tcase_create("Publisher publishing and Subscriber subscribing");
  959. tcase_add_checked_fixture(tc_pubsub_publish_subscribe, setup, teardown);
  960. tcase_add_test(tc_pubsub_publish_subscribe, SinglePublishSubscribeDateTime);
  961. tcase_add_test(tc_pubsub_publish_subscribe, SinglePublishSubscribeInt32);
  962. tcase_add_test(tc_pubsub_publish_subscribe, SinglePublishSubscribeInt64);
  963. tcase_add_test(tc_pubsub_publish_subscribe, SinglePublishSubscribeBool);
  964. Suite *suite = suite_create("PubSub readerGroups/reader/Fields handling and publishing");
  965. suite_add_tcase(suite, tc_add_pubsub_readergroup);
  966. suite_add_tcase(suite, tc_pubsub_publish_subscribe);
  967. SRunner *suiteRunner = srunner_create(suite);
  968. srunner_set_fork_status(suiteRunner, CK_NOFORK);
  969. srunner_run_all(suiteRunner,CK_NORMAL);
  970. int number_failed = srunner_ntests_failed(suiteRunner);
  971. srunner_free(suiteRunner);
  972. return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
  973. }