2 * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 #include <cynara_test_agent.h>
22 #include <dpl/test/test_runner.h>
24 namespace CynaraTestAgent {
29 int ret = cynara_agent_initialize(&m_agent, CynaraTestPlugins::TEST_AGENT_TYPE.c_str());
30 RUNNER_ASSERT_MSG(ret == CYNARA_API_SUCCESS,
31 "cynara_agent_initialize failed. ret: " << ret);
32 RUNNER_ASSERT_MSG(m_agent != nullptr,
33 "cynara_agent struct was not initialized");
38 cynara_agent_finish(m_agent);
41 void Agent::getRequest(AgentRequest &request, int expectedResult)
43 cynara_agent_msg_type type;
44 cynara_agent_req_id id;
48 int ret = cynara_agent_get_request(m_agent, &type, &id, &data, &dataSize);
49 if (ret == CYNARA_API_SUCCESS) {
50 RUNNER_ASSERT_MSG(!data == !dataSize,
51 "cynara_agent_get_request returned contradictory values: "
52 << "data = " << data << " ,"
53 << "size = " << dataSize << ".");
54 request.set(type, id, data, dataSize);
57 RUNNER_ASSERT_MSG(ret == expectedResult,
58 "cynara_agent_get_request returned wrong value: "
59 << ret << " != " << expectedResult << ".");
62 void Agent::putResponse(const AgentResponse &response, int expectedResult)
64 auto size = response.data().size();
65 int ret = cynara_agent_put_response(m_agent,
68 size ? static_cast<const void*>(response.data().data())
72 RUNNER_ASSERT_MSG(ret == expectedResult,
73 "cynara_agent_put_response returned wrong value: "
74 << ret << " != " << expectedResult << "."
75 << "response = " << response);
78 } // namespace CynaraTestAgent