CELIX-237: Small update for launcher + rsa test setup
Project: http://git-wip-us.apache.org/repos/asf/celix/repo Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/87f3fabf Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/87f3fabf Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/87f3fabf Branch: refs/heads/develop Commit: 87f3fabf7f7e97140877faee73c5948319bcbaa7 Parents: 4e3be10 Author: Pepijn Noltes <pepijnnol...@gmail.com> Authored: Sat Aug 1 21:51:05 2015 +0200 Committer: Pepijn Noltes <pepijnnol...@gmail.com> Committed: Sat Aug 1 21:51:05 2015 +0200 ---------------------------------------------------------------------- launcher/private/src/launcher.c | 11 --- launcher/private/src/main.c | 10 +++ .../remote_service_admin_dfi/tst/rsa_tests.cpp | 75 ++++++++++++++++++-- .../remote_service_admin_dfi/tst/run_tests.cpp | 5 +- 4 files changed, 81 insertions(+), 20 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/celix/blob/87f3fabf/launcher/private/src/launcher.c ---------------------------------------------------------------------- diff --git a/launcher/private/src/launcher.c b/launcher/private/src/launcher.c index 4f0f3de..9c021ed 100644 --- a/launcher/private/src/launcher.c +++ b/launcher/private/src/launcher.c @@ -37,8 +37,6 @@ #include "framework.h" #include "linked_list_iterator.h" -static void launcher_shutdown(int signal); - static struct framework * framework; static properties_pt config; @@ -77,8 +75,6 @@ int celixLauncher_launchWithStream(FILE *stream) { apr_status_t s; #endif - (void) signal(SIGINT, launcher_shutdown); - // Before doing anything else, let's setup Curl curl_global_init(CURL_GLOBAL_NOTHING); @@ -193,10 +189,3 @@ struct framework *celixLauncher_getFramework(void) { return framework; } -static void launcher_shutdown(int signal) { - celixLauncher_stop(); -// if (framework_waitForStop(framework) != CELIX_SUCCESS) { -// celix_log("Error waiting for stop."); -// } -// framework_destroy(framework); -} http://git-wip-us.apache.org/repos/asf/celix/blob/87f3fabf/launcher/private/src/main.c ---------------------------------------------------------------------- diff --git a/launcher/private/src/main.c b/launcher/private/src/main.c index b6d3033..00b08bd 100644 --- a/launcher/private/src/main.c +++ b/launcher/private/src/main.c @@ -27,13 +27,18 @@ #include <string.h> #include <curl/curl.h> #include <signal.h> +#include <libgen.h> #include "launcher.h" static void show_usage(char* prog_name); +static void shutdownCelix(int signal); #define DEFAULT_CONFIG_FILE "config.properties" int main(int argc, char *argv[]) { + + (void) signal(SIGINT, shutdownCelix); + // Perform some minimal command-line option parsing... char *opt = NULL; if (argc > 1) { @@ -61,3 +66,8 @@ int main(int argc, char *argv[]) { static void show_usage(char* prog_name) { printf("Usage:\n %s [path/to/config.properties]\n\n", basename(prog_name)); } + +static void shutdownCelix(int signal) { + celixLauncher_stop(); +} + http://git-wip-us.apache.org/repos/asf/celix/blob/87f3fabf/remote_services/remote_service_admin_dfi/tst/rsa_tests.cpp ---------------------------------------------------------------------- diff --git a/remote_services/remote_service_admin_dfi/tst/rsa_tests.cpp b/remote_services/remote_service_admin_dfi/tst/rsa_tests.cpp index b9206da..a5a556a 100644 --- a/remote_services/remote_service_admin_dfi/tst/rsa_tests.cpp +++ b/remote_services/remote_service_admin_dfi/tst/rsa_tests.cpp @@ -14,13 +14,62 @@ extern "C" { #include "launcher.h" #include "framework.h" +#include "remote_service_admin.h" -static void testFindRsaService(void) { +bundle_context_pt context = NULL; +service_reference_pt rsaRef = NULL; +remote_service_admin_service_pt rsa = NULL; + +static void setupContextAndRsa(void) { + int rc = 0; struct framework *fm = celixLauncher_getFramework(); - CHECK(fm != NULL); - //TODO get framework bundle context. lookup service -> test service + bundle_pt bundle = NULL; + rc = framework_getFrameworkBundle(fm, &bundle); + CHECK_EQUAL(CELIX_SUCCESS, rc); + + rc = bundle_getContext(bundle, &context); + CHECK_EQUAL(CELIX_SUCCESS, rc); + + rc = bundleContext_getServiceReference(context, (char *)OSGI_RSA_REMOTE_SERVICE_ADMIN, &rsaRef); + CHECK_EQUAL(CELIX_SUCCESS, rc); + + rc = bundleContext_getService(context, rsaRef, (void **)&rsa); + CHECK_EQUAL(CELIX_SUCCESS, rc); +} + +static void teardownContextAndRsa(void) { + int rc = 0; + rc = bundleContext_ungetService(context, rsaRef, NULL); + CHECK_EQUAL(CELIX_SUCCESS, rc); + rsaRef = NULL; + rsa = NULL; + context = NULL; +} + +static void testInfo(void) { + int rc = 0; + array_list_pt exported = NULL; + array_list_pt imported = NULL; + arrayList_create(&exported); + arrayList_create(&imported); + + rc = rsa->getExportedServices(rsa->admin, &exported); + CHECK_EQUAL(CELIX_SUCCESS, rc); + CHECK_EQUAL(0, arrayList_size(exported)); + + rc = rsa->getImportedEndpoints(rsa->admin, &imported); + CHECK_EQUAL(CELIX_SUCCESS, rc); + CHECK_EQUAL(0, arrayList_size(imported)); +} + +static void testExportService(void) { + //TODO +} + +static void testImportService(void) { + //TODO } } @@ -28,9 +77,25 @@ static void testFindRsaService(void) { TEST_GROUP(RsaDfiTests) { void setup() { + celixLauncher_launch("config.properties"); + setupContextAndRsa(); + } + + void teardown() { + teardownContextAndRsa(); + celixLauncher_stop(); + celixLauncher_waitForShutdown(); } }; -TEST(RsaDfiTests, FindRsaService) { - testFindRsaService(); +TEST(RsaDfiTests, InfoTest) { + testInfo(); +} + +TEST(RsaDfiTests, ExportService) { + testExportService(); +} + +TEST(RsaDfiTests, ImportService) { + testImportService(); } http://git-wip-us.apache.org/repos/asf/celix/blob/87f3fabf/remote_services/remote_service_admin_dfi/tst/run_tests.cpp ---------------------------------------------------------------------- diff --git a/remote_services/remote_service_admin_dfi/tst/run_tests.cpp b/remote_services/remote_service_admin_dfi/tst/run_tests.cpp index dedb70a..81d1908 100644 --- a/remote_services/remote_service_admin_dfi/tst/run_tests.cpp +++ b/remote_services/remote_service_admin_dfi/tst/run_tests.cpp @@ -22,8 +22,5 @@ extern "C" { } int main(int argc, char** argv) { - startCelix(); - int rc = RUN_ALL_TESTS(argc, argv); - stopCelix(); - return rc; + return RUN_ALL_TESTS(argc, argv); } \ No newline at end of file