Create cynara_async_tests group 98/28898/7
authorLukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Thu, 16 Oct 2014 17:23:13 +0000 (19:23 +0200)
committerLukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Thu, 30 Oct 2014 10:58:45 +0000 (11:58 +0100)
Create a test group for asynchronous API tests
and add CynaraTestAsync::Client initialization test.

Change-Id: I0e8cc37cd16282a7834cc61dd72e1aa90fb9129e

tests/cynara-tests/CMakeLists.txt
tests/cynara-tests/common/cynara_test_commons.cpp [new file with mode: 0644]
tests/cynara-tests/common/cynara_test_commons.h [new file with mode: 0644]
tests/cynara-tests/test_cases.cpp
tests/cynara-tests/test_cases_async.cpp [new file with mode: 0644]

index b47887199aca575ab5e87bdca7454217cce114e6..05d9c2a2f0c6f85ae20591ef50202b330d549a8f 100644 (file)
@@ -19,9 +19,11 @@ SET(CYNARA_TARGET_TEST_SOURCES
     ${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_commons.cpp
     ${PROJECT_SOURCE_DIR}/tests/cynara-tests/common/cynara_test_env.cpp
     ${PROJECT_SOURCE_DIR}/tests/cynara-tests/cynara-test.cpp
     ${PROJECT_SOURCE_DIR}/tests/cynara-tests/test_cases.cpp
+    ${PROJECT_SOURCE_DIR}/tests/cynara-tests/test_cases_async.cpp
     )
 
 #header directories
diff --git a/tests/cynara-tests/common/cynara_test_commons.cpp b/tests/cynara-tests/common/cynara_test_commons.cpp
new file mode 100644 (file)
index 0000000..74c821e
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * 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_commons.h>
+#include <cynara_test_env.h>
+
+#include <dpl/exception.h>
+#include <dpl/test/test_runner.h>
+
+#include <exception>
+
+void environmentWrap(const char *testName, const std::function<void(void)> &func)
+{
+    CynaraTestEnv env(testName);
+    env.save();
+
+    try {
+        func();
+    } catch (const DPL::Test::TestRunner::TestFailed &e) {
+        env.restore();
+        throw e;
+    } catch (const DPL::Test::TestRunner::Ignored &e) {
+        env.restore();
+        throw e;
+    } catch (const DPL::Exception &e) {
+        env.restore();
+        throw e;
+    } catch (const std::exception &e) {
+        env.restore();
+        throw e;
+    } catch (...) {
+        env.restore();
+        throw std::runtime_error("Unknown exception");
+    }
+    env.restore();
+}
diff --git a/tests/cynara-tests/common/cynara_test_commons.h b/tests/cynara-tests/common/cynara_test_commons.h
new file mode 100644 (file)
index 0000000..2d97103
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ */
+
+/*
+ * @file        cynara_test_commons.h
+ * @author      Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
+ * @version     1.0
+ * @brief       Definition of environment wrap for test cases
+ */
+
+#ifndef CYNARA_TEST_COMMONS_H_
+#define CYNARA_TEST_COMMONS_H_
+
+#include <functional>
+
+void environmentWrap(const char *testName, const std::function<void(void)> &func);
+
+#define RUN_CYNARA_TEST(Proc)                \
+    RUNNER_TEST(Proc)                        \
+    {                                        \
+        environmentWrap(#Proc, Proc##_func); \
+    }
+
+#endif /* CYNARA_TEST_COMMONS_H_ */
index cb32d5f4482f54de52d2b989b4f34f924acb094c..a5c2bc739f0d98fd49a02a64b6ead65ef0dc0116 100644 (file)
  * @file        test_cases.cpp
  * @author      Aleksander Zdyb <a.zdyb@partner.samsung.com>
  * @author      Marcin Niesluchowski <m.niesluchow@samsung.com>
+ * @author      Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
  * @version     1.1
  * @brief       Tests for libcynara-client and libcynara-admin
  */
 
-#include <dpl/exception.h>
+#include <cynara_test_commons.h>
+
 #include <tests_common.h>
 #include <cynara_test_client.h>
 #include <cynara_test_admin.h>
-#include <cynara_test_env.h>
 
-#include <functional>
 #include <climits>
 
-void environmentWrap(const char *testName, const std::function<void(void)> &func)
-{
-    CynaraTestEnv env(testName);
-    env.save();
-
-    try {
-        func();
-    } catch (const DPL::Test::TestRunner::TestFailed &e) {
-        env.restore();
-        throw e;
-    } catch (const DPL::Test::TestRunner::Ignored &e) {
-        env.restore();
-        throw e;
-    } catch (const DPL::Exception &e) {
-        env.restore();
-        throw e;
-    } catch (const std::exception &e) {
-        env.restore();
-        throw e;
-    } catch (...) {
-        env.restore();
-        throw std::runtime_error("Unknown exception");
-    }
-    env.restore();
-}
-
-#define RUN_CYNARA_TEST(Proc)                \
-    RUNNER_TEST(Proc)                        \
-    {                                        \
-        environmentWrap(#Proc, Proc##_func); \
-    }
-
 void tc01_cynara_initialize_func()
 {
     CynaraTestClient();
diff --git a/tests/cynara-tests/test_cases_async.cpp b/tests/cynara-tests/test_cases_async.cpp
new file mode 100644 (file)
index 0000000..74b045c
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ */
+
+/*
+ * @file        test_cases_async.cpp
+ * @author      Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
+ * @version     1.0
+ * @brief       Tests for libcynara-client-async
+ */
+
+#include <cynara_test_commons.h>
+#include <cynara_test_client_async_client.h>
+
+#include <dpl/test/test_runner.h>
+
+void tca01_initialize_func()
+{
+    CynaraTestClientAsync::Client client;
+}
+
+RUNNER_TEST_GROUP_INIT(cynara_async_tests)
+
+RUN_CYNARA_TEST(tca01_initialize)