From fe51d00ab0bc33e4ccbcf13fbb9164d64f5c47d4 Mon Sep 17 00:00:00 2001 From: Lukasz Wojciechowski Date: Mon, 3 Nov 2014 12:33:06 +0100 Subject: [PATCH] Add double request tests These tests send sequentially two requests. In second test connection with service is broken after response to first request is received. Change-Id: Idc319ad58d5755ec8833f899723f1de3800cbfea --- tests/cynara-tests/test_cases_async.cpp | 54 +++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/tests/cynara-tests/test_cases_async.cpp b/tests/cynara-tests/test_cases_async.cpp index 29626e6c..65cd4e6 100644 --- a/tests/cynara-tests/test_cases_async.cpp +++ b/tests/cynara-tests/test_cases_async.cpp @@ -354,6 +354,58 @@ void tca09_disconnect_and_cancel2_func() client.assertStatus(READ); } +void tca10_double_request_func() +{ + std::string testNo("10"); + cynara_check_id id, id2; + Client client; + + RequestEntity callbackData2 = {RequestFunction(), + CYNARA_API_ACCESS_DENIED, + CYNARA_CALL_CAUSE_ANSWER}; + + RequestEntity callbackData = {[&](){client.createRequest({testNo}, id2, callbackData2);}, + CYNARA_API_ACCESS_DENIED, + CYNARA_CALL_CAUSE_ANSWER}; + + + client.createRequest({testNo}, id, callbackData); + client.assertStatus(READWRITE); + + client.process(); + client.process(); + client.process(CYNARA_API_SUCCESS, Client::IGNORE_TIMEOUT); + client.process(CYNARA_API_SUCCESS, Client::IGNORE_TIMEOUT); +} + +void tca11_double_request_with_restart_func() +{ + std::string testNo("11"); + cynara_check_id id, id2; + Client client; + + RequestEntity callbackData2 = {RequestFunction(), + CYNARA_API_ACCESS_DENIED, + CYNARA_CALL_CAUSE_ANSWER}; + + RequestEntity callbackData = {[&](){ + DBusAccess dbusAccess(CynaraTestConsts::SERVICE.c_str()); + dbusAccess.restartService(); + client.createRequest({testNo}, id2, callbackData2); + }, + CYNARA_API_ACCESS_DENIED, + CYNARA_CALL_CAUSE_ANSWER}; + + + client.createRequest({testNo}, id, callbackData); + client.assertStatus(READWRITE); + + client.process(); + client.process(); + client.process(CYNARA_API_SUCCESS, Client::IGNORE_TIMEOUT); + client.process(CYNARA_API_SUCCESS, Client::IGNORE_TIMEOUT); +} + RUNNER_TEST_GROUP_INIT(cynara_async_tests) RUN_CYNARA_TEST(tca01_initialize) @@ -370,3 +422,5 @@ RUN_CYNARA_TEST(tca08_disconnect2) RUN_CYNARA_TEST(tca08_disconnect3) RUN_CYNARA_TEST(tca09_disconnect_and_cancel1) RUN_CYNARA_TEST(tca09_disconnect_and_cancel2) +RUN_CYNARA_TEST(tca10_double_request) +RUN_CYNARA_TEST(tca11_double_request_with_restart) -- 2.7.4