|
@@ -12,6 +12,7 @@
|
|
|
#include "ua_config_default.h"
|
|
|
#include "ua_client_highlevel.h"
|
|
|
#include "ua_network_tcp.h"
|
|
|
+#include "testing_clock.h"
|
|
|
#include "check.h"
|
|
|
|
|
|
UA_Server *server;
|
|
@@ -99,12 +100,30 @@ START_TEST(Client_read) {
|
|
|
}
|
|
|
END_TEST
|
|
|
|
|
|
+START_TEST(Client_renewSecureChannel) {
|
|
|
+ UA_Client *client = UA_Client_new(UA_ClientConfig_default);
|
|
|
+ UA_StatusCode retval = UA_Client_connect(client, "opc.tcp://localhost:4840");
|
|
|
+ ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD);
|
|
|
+
|
|
|
+ /* Forward the time */
|
|
|
+ UA_sleep((UA_UInt32)((UA_Double)UA_ClientConfig_default.secureChannelLifeTime * 0.8));
|
|
|
+
|
|
|
+ /* Now read */
|
|
|
+ UA_Variant val;
|
|
|
+ UA_NodeId nodeId = UA_NODEID_STRING(1, "my.variable");
|
|
|
+ retval = UA_Client_readValueAttribute(client, nodeId, &val);
|
|
|
+ ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD);
|
|
|
+ UA_Variant_deleteMembers(&val);
|
|
|
+
|
|
|
+ UA_Client_disconnect(client);
|
|
|
+ UA_Client_delete(client);
|
|
|
+
|
|
|
+} END_TEST
|
|
|
|
|
|
START_TEST(Client_reconnect) {
|
|
|
UA_ClientConfig clientConfig = UA_ClientConfig_default;
|
|
|
clientConfig.timeout = 100;
|
|
|
UA_Client *client = UA_Client_new(clientConfig);
|
|
|
- setup();
|
|
|
UA_StatusCode retval = UA_Client_connect(client, "opc.tcp://localhost:4840");
|
|
|
ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD);
|
|
|
|
|
@@ -130,9 +149,7 @@ START_TEST(Client_reconnect) {
|
|
|
|
|
|
UA_Client_disconnect(client);
|
|
|
UA_Client_delete(client);
|
|
|
-
|
|
|
- teardown();
|
|
|
- }
|
|
|
+}
|
|
|
END_TEST
|
|
|
|
|
|
static Suite* testSuite_Client(void) {
|
|
@@ -143,6 +160,8 @@ static Suite* testSuite_Client(void) {
|
|
|
tcase_add_test(tc_client, Client_read);
|
|
|
suite_add_tcase(s,tc_client);
|
|
|
TCase *tc_client_reconnect = tcase_create("Client Reconnect");
|
|
|
+ tcase_add_checked_fixture(tc_client_reconnect, setup, teardown);
|
|
|
+ tcase_add_test(tc_client_reconnect, Client_renewSecureChannel);
|
|
|
tcase_add_test(tc_client_reconnect, Client_reconnect);
|
|
|
suite_add_tcase(s,tc_client_reconnect);
|
|
|
return s;
|