SET(CYNARA_TARGET_TEST_SOURCES
${PROJECT_SOURCE_DIR}/tests/cynara-tests/common/cynara_test_admin.cpp
${PROJECT_SOURCE_DIR}/tests/cynara-tests/common/cynara_test_client.cpp
+ ${PROJECT_SOURCE_DIR}/tests/cynara-tests/common/cynara_test_client_async_client.cpp
${PROJECT_SOURCE_DIR}/tests/cynara-tests/common/cynara_test_client_async_status_monitor.cpp
${PROJECT_SOURCE_DIR}/tests/cynara-tests/common/cynara_test_env.cpp
${PROJECT_SOURCE_DIR}/tests/cynara-tests/cynara-test.cpp
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <cynara_test_client_async_client.h>
+
+#include <dpl/test/test_runner.h>
+
+#include <cynara-client-async.h>
+
+#include <exception>
+
+namespace CynaraTestClientAsync {
+
+Client::Client()
+ : m_cynara(nullptr)
+{
+ int ret = cynara_async_initialize(&m_cynara, nullptr, StatusMonitor::updateStatus,
+ reinterpret_cast<void*>(&m_statusMonitor));
+ RUNNER_ASSERT_MSG(ret == CYNARA_API_SUCCESS,
+ "cynara_async_initialize() failed. ret = " << ret << ".");
+ RUNNER_ASSERT_MSG(m_cynara != nullptr, "cynara_async struct was not initialized.");
+
+ assertStatus(DISCONNECTED);
+}
+
+Client::~Client() noexcept(false)
+{
+ bool oops = std::uncaught_exception();
+ try {
+ cynara_async_finish(m_cynara);
+ assertStatus(DISCONNECTED);
+ } catch (...) {
+ if (!oops)
+ throw;
+ RUNNER_ERROR_MSG("Error: more exceptions thrown while releasing CynaraTestAsync::Client.");
+ }
+}
+
+void Client::assertStatus(enum SocketStatus expectedStatus)
+{
+ enum SocketStatus currentStatus = m_statusMonitor.getStatus();
+ RUNNER_ASSERT_MSG(currentStatus == expectedStatus,
+ "SocketStatus mismatch: "
+ << " currentStatus = " << currentStatus << ","
+ << " expectedStatus = " << expectedStatus << ".");
+}
+
+}// namespace CynaraTestClientAsync
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef CYNARA_TEST_CLIENT_ASYNC_CLIENT_H
+#define CYNARA_TEST_CLIENT_ASYNC_CLIENT_H
+
+#include <cynara_test_client_async_status_monitor.h>
+
+#include <cynara-client-async.h>
+
+namespace CynaraTestClientAsync {
+
+class Client
+{
+public:
+ Client();
+ ~Client() noexcept(false);
+
+ void assertStatus(enum SocketStatus expectedStatus);
+
+private:
+ struct cynara_async *m_cynara;
+
+ StatusMonitor m_statusMonitor;
+};
+
+}// namespace CynaraTestClientAsync
+
+#endif // CYNARA_TEST_CLIENT_ASYNC_CLIENT_H