celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pnol...@apache.org
Subject [1/3] celix git commit: CELIX-274: Added test for startup/shutdown single and multiple frameworks
Date Tue, 13 Oct 2015 17:48:02 GMT
Repository: celix
Updated Branches:
  refs/heads/develop 0da1becf6 -> 24d6d1100


CELIX-274: Added test for startup/shutdown single and multiple frameworks


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/32b1d86f
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/32b1d86f
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/32b1d86f

Branch: refs/heads/develop
Commit: 32b1d86fe1e5096f2eee3d4ec4119d70001d4fca
Parents: 353f657
Author: Pepijn Noltes <pepijnnoltes@gmail.com>
Authored: Tue Oct 13 17:09:31 2015 +0200
Committer: Pepijn Noltes <pepijnnoltes@gmail.com>
Committed: Tue Oct 13 17:09:31 2015 +0200

----------------------------------------------------------------------
 framework/CMakeLists.txt                   |  8 +++
 framework/tst/CMakeLists.txt               | 30 +++++++++
 framework/tst/config.properties.in         |  2 +
 framework/tst/framework1.properties.in     |  3 +
 framework/tst/framework2.properties.in     |  3 +
 framework/tst/multiple_frameworks_test.cpp | 88 +++++++++++++++++++++++++
 framework/tst/run_tests.cpp                |  9 +++
 framework/tst/single_framework_test.cpp    | 69 +++++++++++++++++++
 8 files changed, 212 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/32b1d86f/framework/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/framework/CMakeLists.txt b/framework/CMakeLists.txt
index becc338..4ca323c 100644
--- a/framework/CMakeLists.txt
+++ b/framework/CMakeLists.txt
@@ -82,6 +82,14 @@ if (FRAMEWORK)
     INSTALL(FILES ${files} DESTINATION include/celix COMPONENT framework)
     INSTALL(DIRECTORY "${PROJECT_SOURCE_DIR}/cmake/" DESTINATION share/celix/cmake/modules
COMPONENT framework) 
 
+
+    if (ENABLE_TESTING)
+        find_package(CppUTest REQUIRED)
+        include_directories(${CPPUTEST_INCLUDE_DIR})
+        add_subdirectory(tst)
+    endif()
+
+
 	celix_subproject(FRAMEWORK_TESTS "Option to build the framework tests" "OFF" DEPS)
     if (ENABLE_TESTING AND FRAMEWORK_TESTS)
     	find_package(CppUTest REQUIRED)

http://git-wip-us.apache.org/repos/asf/celix/blob/32b1d86f/framework/tst/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/framework/tst/CMakeLists.txt b/framework/tst/CMakeLists.txt
new file mode 100644
index 0000000..9f6a213
--- /dev/null
+++ b/framework/tst/CMakeLists.txt
@@ -0,0 +1,30 @@
+#
+# Licensed under Apache License v2. See LICENSE for more information.
+#
+
+
+include_directories(
+    ${PROJECT_SOURCE_DIR}/framework/public/include
+    ${PROJECT_SOURCE_DIR}/utils/public/include
+    ${PROJECT_SOURCE_DIR}/utils/public/include
+)
+
+
+SET(CMAKE_SKIP_BUILD_RPATH  FALSE) #TODO needed?
+SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) #TODO needed?
+SET(CMAKE_INSTALL_RPATH "${PROJECT_BINARY_DIR}/framework" "${PROJECT_BINARY_DIR}/utils")
+
+add_executable(test_framework
+    run_tests.cpp
+    single_framework_test.cpp
+    multiple_frameworks_test.cpp
+)
+target_link_libraries(test_framework celix_framework celix_utils ${CURL_LIBRARIES} ${CPPUTEST_LIBRARY})
+
+configure_file(config.properties.in config.properties @ONLY)
+configure_file(framework1.properties.in framework1.properties @ONLY)
+configure_file(framework2.properties.in framework2.properties @ONLY)
+
+add_test(NAME run_test_framework COMMAND test_framework)
+SETUP_TARGET_FOR_COVERAGE(test_framework_cov test_framework ${CMAKE_BINARY_DIR}/coverage/framework)
+

http://git-wip-us.apache.org/repos/asf/celix/blob/32b1d86f/framework/tst/config.properties.in
----------------------------------------------------------------------
diff --git a/framework/tst/config.properties.in b/framework/tst/config.properties.in
new file mode 100644
index 0000000..eec9144
--- /dev/null
+++ b/framework/tst/config.properties.in
@@ -0,0 +1,2 @@
+LOGHELPER_ENABLE_STDOUT_FALLBACK=true
+org.osgi.framework.storage.clean=onFirstInit
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/32b1d86f/framework/tst/framework1.properties.in
----------------------------------------------------------------------
diff --git a/framework/tst/framework1.properties.in b/framework/tst/framework1.properties.in
new file mode 100644
index 0000000..a7009c5
--- /dev/null
+++ b/framework/tst/framework1.properties.in
@@ -0,0 +1,3 @@
+LOGHELPER_ENABLE_STDOUT_FALLBACK=true
+org.osgi.framework.storage.clean=onFirstInit
+org.osgi.framework.storage=.cacheFramework1

http://git-wip-us.apache.org/repos/asf/celix/blob/32b1d86f/framework/tst/framework2.properties.in
----------------------------------------------------------------------
diff --git a/framework/tst/framework2.properties.in b/framework/tst/framework2.properties.in
new file mode 100644
index 0000000..029f46b
--- /dev/null
+++ b/framework/tst/framework2.properties.in
@@ -0,0 +1,3 @@
+LOGHELPER_ENABLE_STDOUT_FALLBACK=true
+org.osgi.framework.storage.clean=onFirstInit
+org.osgi.framework.storage=.cacheFramework2
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/32b1d86f/framework/tst/multiple_frameworks_test.cpp
----------------------------------------------------------------------
diff --git a/framework/tst/multiple_frameworks_test.cpp b/framework/tst/multiple_frameworks_test.cpp
new file mode 100644
index 0000000..b732000
--- /dev/null
+++ b/framework/tst/multiple_frameworks_test.cpp
@@ -0,0 +1,88 @@
+/*
+ * Licensed under Apache License v2. See LICENSE for more information.
+ */
+#include <CppUTest/TestHarness.h>
+#include <CppUTest/CommandLineTestRunner.h>
+
+extern "C" {
+
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <unistd.h>
+
+#include "celix_launcher.h"
+#include "framework.h"
+
+    static framework_pt serverFramework = NULL;
+    static bundle_context_pt serverContext = NULL;
+
+    static framework_pt clientFramework = NULL;
+    static bundle_context_pt clientContext = NULL;
+
+    static void setupFm(void) {
+        int rc = 0;
+        bundle_pt bundle = NULL;
+
+        //server
+        rc = celixLauncher_launch("framework1.properties", &serverFramework);
+        CHECK_EQUAL(CELIX_SUCCESS, rc);
+
+        bundle = NULL;
+        rc = framework_getFrameworkBundle(serverFramework, &bundle);
+        CHECK_EQUAL(CELIX_SUCCESS, rc);
+
+        rc = bundle_getContext(bundle, &serverContext);
+        CHECK_EQUAL(CELIX_SUCCESS, rc);
+
+
+        //client
+        rc = celixLauncher_launch("framework2.properties", &clientFramework);
+        CHECK_EQUAL(CELIX_SUCCESS, rc);
+
+        bundle = NULL;
+        rc = framework_getFrameworkBundle(clientFramework, &bundle);
+        CHECK_EQUAL(CELIX_SUCCESS, rc);
+
+        rc = bundle_getContext(bundle, &clientContext);
+        CHECK_EQUAL(CELIX_SUCCESS, rc);
+    }
+
+    static void teardownFm(void) {
+        int rc = 0;
+
+        celixLauncher_stop(serverFramework);
+        celixLauncher_waitForShutdown(serverFramework);
+        celixLauncher_destroy(serverFramework);
+
+        celixLauncher_stop(clientFramework);
+        celixLauncher_waitForShutdown(clientFramework);
+        celixLauncher_destroy(clientFramework);
+
+        serverContext = NULL;
+        serverFramework = NULL;
+        clientContext = NULL;
+        clientFramework = NULL;
+    }
+
+    static void testFrameworks(void) {
+        printf("testing startup/shutdown mutiple frameworks\n");    }
+
+}
+
+
+TEST_GROUP(CelixMutipleFramworks) {
+    void setup() {
+        setupFm();
+    }
+
+    void teardown() {
+        teardownFm();
+    }
+};
+
+TEST(CelixMutipleFramworks, testFrameworks) {
+    testFrameworks();
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/32b1d86f/framework/tst/run_tests.cpp
----------------------------------------------------------------------
diff --git a/framework/tst/run_tests.cpp b/framework/tst/run_tests.cpp
new file mode 100644
index 0000000..c5e960c
--- /dev/null
+++ b/framework/tst/run_tests.cpp
@@ -0,0 +1,9 @@
+/*
+ * Licensed under Apache License v2. See LICENSE for more information.
+ */
+#include <CppUTest/TestHarness.h>
+#include "CppUTest/CommandLineTestRunner.h"
+
+int main(int argc, char** argv) {
+    return RUN_ALL_TESTS(argc, argv);
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/32b1d86f/framework/tst/single_framework_test.cpp
----------------------------------------------------------------------
diff --git a/framework/tst/single_framework_test.cpp b/framework/tst/single_framework_test.cpp
new file mode 100644
index 0000000..5f232a6
--- /dev/null
+++ b/framework/tst/single_framework_test.cpp
@@ -0,0 +1,69 @@
+/*
+ * Licensed under Apache License v2. See LICENSE for more information.
+ */
+#include <CppUTest/TestHarness.h>
+#include <CppUTest/CommandLineTestRunner.h>
+
+extern "C" {
+
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+#include "celix_launcher.h"
+#include "framework.h"
+
+
+    static framework_pt framework = NULL;
+    static bundle_context_pt context = NULL;
+
+    static void setupFm(void) {
+        int rc = 0;
+
+        rc = celixLauncher_launch("config.properties", &framework);
+        CHECK_EQUAL(CELIX_SUCCESS, rc);
+
+        bundle_pt bundle = NULL;
+        rc = framework_getFrameworkBundle(framework, &bundle);
+        CHECK_EQUAL(CELIX_SUCCESS, rc);
+
+        rc = bundle_getContext(bundle, &context);
+        CHECK_EQUAL(CELIX_SUCCESS, rc);
+    }
+
+    static void teardownFm(void) {
+        int rc = 0;
+
+        celixLauncher_stop(framework);
+        celixLauncher_waitForShutdown(framework);
+        celixLauncher_destroy(framework);
+
+        context = NULL;
+        framework = NULL;
+    }
+
+    static void testFramework(void) {
+        //intentional empty. start/shutdown test
+        printf("testing startup/shutdown single framework\n");
+    }
+
+    //TODO test register / use service
+
+}
+
+
+TEST_GROUP(CelixFramework) {
+    void setup() {
+        setupFm();
+    }
+
+    void teardown() {
+        teardownFm();
+    }
+};
+
+TEST(CelixFramework, testFramework) {
+    testFramework();
+}


Mime
View raw message