celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pnol...@apache.org
Subject [celix] branch develop updated: Adds a test to check if a timed delay use service call will timeout.
Date Mon, 09 Sep 2019 16:24:27 GMT
This is an automated email from the ASF dual-hosted git repository.

pnoltes pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/celix.git


The following commit(s) were added to refs/heads/develop by this push:
     new 222eb72  Adds a test to check if a timed delay use service call will timeout.
222eb72 is described below

commit 222eb72442a3ce1ff2dd43c3aba7295adb40d92e
Author: Pepijn Noltes <pepijnnoltes@gmail.com>
AuthorDate: Mon Sep 9 18:23:47 2019 +0200

    Adds a test to check if a timed delay use service call will timeout.
---
 libs/framework/tst/bundle_context_services_test.cpp | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/libs/framework/tst/bundle_context_services_test.cpp b/libs/framework/tst/bundle_context_services_test.cpp
index 96e1332..795890a 100644
--- a/libs/framework/tst/bundle_context_services_test.cpp
+++ b/libs/framework/tst/bundle_context_services_test.cpp
@@ -185,10 +185,11 @@ TEST(CelixBundleContextServicesTests, registerAndUseServiceWithTimeout)
{
 
     std::future<bool> result{std::async([&]{
         opts.waitTimeoutInSeconds = 5.0;
+        printf("Trying to call calc with timeout of %f\n", opts.waitTimeoutInSeconds);
         bool calledAsync = celix_bundleContext_useServiceWithOptions(ctx, &opts);
+        printf("returned from use service with timeout. calc called %s.\n", calledAsync ?
"true" : "false");
         return calledAsync;
     })};
-
     long svcId = celix_bundleContext_registerService(ctx, &svc, calcName, nullptr);
     CHECK(svcId >= 0);
 
@@ -197,6 +198,17 @@ TEST(CelixBundleContextServicesTests, registerAndUseServiceWithTimeout)
{
 
 
     celix_bundleContext_unregisterService(ctx, svcId);
+
+
+    //check if timeout is triggered
+    std::future<bool> result2{std::async([&]{
+        opts.waitTimeoutInSeconds = 0.5;
+        printf("Trying to call calc with timeout of %f\n", opts.waitTimeoutInSeconds);
+        bool calledAsync = celix_bundleContext_useServiceWithOptions(ctx, &opts);
+        printf("returned from use service with timeout. calc called %s.\n", calledAsync ?
"true" : "false");
+        return calledAsync;
+    })};
+    CHECK(!result2.get());
 }
 
 TEST(CelixBundleContextServicesTests, registerAndUseWithForcedRaceCondition) {


Mime
View raw message