Repository: celix
Updated Branches:
  refs/heads/develop 109edf4d0 -> 058d79918


Fixes the service ref tests


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

Branch: refs/heads/develop
Commit: 058d7991871e7b081e4837dcea8526cb082da8b3
Parents: 109edf4
Author: Pepijn Noltes <[email protected]>
Authored: Tue Feb 20 17:09:43 2018 +0100
Committer: Pepijn Noltes <[email protected]>
Committed: Tue Feb 20 17:09:43 2018 +0100

----------------------------------------------------------------------
 framework/private/mock/properties_mock.c        |  5 +-
 .../private/test/service_reference_test.cpp     | 75 +++++++++++++-------
 2 files changed, 54 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/058d7991/framework/private/mock/properties_mock.c
----------------------------------------------------------------------
diff --git a/framework/private/mock/properties_mock.c 
b/framework/private/mock/properties_mock.c
index cf873a9..e977100 100644
--- a/framework/private/mock/properties_mock.c
+++ b/framework/private/mock/properties_mock.c
@@ -54,7 +54,10 @@ const char * properties_get(properties_pt properties, const 
char * key) {
 }
 
 const char * properties_getWithDefault(properties_pt properties, const char * 
key, const char * defaultValue) {
-       mock_c()->actualCall("properties_getWithDefault");
+       mock_c()->actualCall("properties_get")
+                       ->withPointerParameters("properties", properties)
+                       ->withStringParameters("key", key)
+                       ->withStringParameters("defaultValue", defaultValue);
        return mock_c()->returnValue().value.pointerValue;
 }
 

http://git-wip-us.apache.org/repos/asf/celix/blob/058d7991/framework/private/test/service_reference_test.cpp
----------------------------------------------------------------------
diff --git a/framework/private/test/service_reference_test.cpp 
b/framework/private/test/service_reference_test.cpp
index 0d49f18..4d5f3c6 100644
--- a/framework/private/test/service_reference_test.cpp
+++ b/framework/private/test/service_reference_test.cpp
@@ -333,9 +333,10 @@ TEST(service_reference, getProperty){
                        .withParameter("registration", registration)
                        .withOutputParameterReturning("properties", &props, 
sizeof(props));
 
-       mock().expectOneCall("properties_get")
+       mock().expectOneCall("properties_getWithDefault")
                        .withParameter("key", key)
                        .withParameter("properties", props)
+                       .ignoreOtherParameters()
                        .andReturnValue(value);
 
        celix_status_t status = serviceReference_getProperty(reference, key, 
&get_value);
@@ -558,43 +559,51 @@ TEST(service_reference, compareTo){
                        .withOutputParameterReturning("properties", &props2, 
sizeof(props2));
 
        //service 1 is higher ranked and has a irrelevant ID
-       mock().expectOneCall("properties_get")
+       mock().expectOneCall("properties_getWithDefault")
                        .withParameter("key", OSGI_FRAMEWORK_SERVICE_ID)
                        .withParameter("properties", props)
+                       .ignoreOtherParameters()
                        .andReturnValue("2");
-       mock().expectOneCall("properties_get")
+       mock().expectOneCall("properties_getWithDefault")
                        .withParameter("key", OSGI_FRAMEWORK_SERVICE_ID)
                        .withParameter("properties", props2)
+                       .ignoreOtherParameters()
                        .andReturnValue("1");
 
-       mock().expectOneCall("properties_get")
+       mock().expectOneCall("properties_getWithDefault")
                        .withParameter("key", OSGI_FRAMEWORK_SERVICE_RANKING)
                        .withParameter("properties", props)
+                       .ignoreOtherParameters()
                        .andReturnValue("2");
-       mock().expectOneCall("properties_get")
+       mock().expectOneCall("properties_getWithDefault")
                        .withParameter("key", OSGI_FRAMEWORK_SERVICE_RANKING)
                        .withParameter("properties", props2)
+                       .ignoreOtherParameters()
                        .andReturnValue("1");
 
        serviceReference_compareTo(reference, reference2, &compare);
        LONGS_EQUAL(1, compare);
 
        //service 1 is equally ranked and has a lower ID
-       mock().expectOneCall("properties_get")
+       mock().expectOneCall("properties_getWithDefault")
                        .withParameter("key", OSGI_FRAMEWORK_SERVICE_ID)
                        .withParameter("properties", props)
+                       .ignoreOtherParameters()
                        .andReturnValue("1");
-       mock().expectOneCall("properties_get")
+       mock().expectOneCall("properties_getWithDefault")
                        .withParameter("key", OSGI_FRAMEWORK_SERVICE_ID)
                        .withParameter("properties", props2)
+                       .ignoreOtherParameters()
                        .andReturnValue("2");
 
-       mock().expectOneCall("properties_get")
+       mock().expectOneCall("properties_getWithDefault")
                        .withParameter("key", OSGI_FRAMEWORK_SERVICE_RANKING)
                        .withParameter("properties", props)
+                       .ignoreOtherParameters()
                        .andReturnValue("1");
-       mock().expectOneCall("properties_get")
+       mock().expectOneCall("properties_getWithDefault")
                        .withParameter("key", OSGI_FRAMEWORK_SERVICE_RANKING)
+                       .ignoreOtherParameters()
                        .withParameter("properties", props2)
                        .andReturnValue("1");
 
@@ -602,21 +611,25 @@ TEST(service_reference, compareTo){
        LONGS_EQUAL(1, compare);
 
        //service 1 is equally ranked and has a higher ID
-       mock().expectOneCall("properties_get")
+       mock().expectOneCall("properties_getWithDefault")
                        .withParameter("key", OSGI_FRAMEWORK_SERVICE_ID)
+                       .ignoreOtherParameters()
                        .withParameter("properties", props)
                        .andReturnValue("2");
-       mock().expectOneCall("properties_get")
+       mock().expectOneCall("properties_getWithDefault")
                        .withParameter("key", OSGI_FRAMEWORK_SERVICE_ID)
                        .withParameter("properties", props2)
+                       .ignoreOtherParameters()
                        .andReturnValue("1");
 
-       mock().expectOneCall("properties_get")
+       mock().expectOneCall("properties_getWithDefault")
                        .withParameter("key", OSGI_FRAMEWORK_SERVICE_RANKING)
+                       .ignoreOtherParameters()
                        .withParameter("properties", props)
                        .andReturnValue("1");
-       mock().expectOneCall("properties_get")
+       mock().expectOneCall("properties_getWithDefault")
                        .withParameter("key", OSGI_FRAMEWORK_SERVICE_RANKING)
+                       .ignoreOtherParameters()
                        .withParameter("properties", props2)
                        .andReturnValue("1");
 
@@ -624,21 +637,25 @@ TEST(service_reference, compareTo){
        LONGS_EQUAL(-1, compare);
 
        //service 1 is lower ranked and has a irrelevant ID
-       mock().expectOneCall("properties_get")
+       mock().expectOneCall("properties_getWithDefault")
                        .withParameter("key", OSGI_FRAMEWORK_SERVICE_ID)
+                       .ignoreOtherParameters()
                        .withParameter("properties", props)
                        .andReturnValue("1");
-       mock().expectOneCall("properties_get")
+       mock().expectOneCall("properties_getWithDefault")
                        .withParameter("key", OSGI_FRAMEWORK_SERVICE_ID)
+                       .ignoreOtherParameters()
                        .withParameter("properties", props2)
                        .andReturnValue("2");
 
-       mock().expectOneCall("properties_get")
+       mock().expectOneCall("properties_getWithDefault")
                        .withParameter("key", OSGI_FRAMEWORK_SERVICE_RANKING)
+                       .ignoreOtherParameters()
                        .withParameter("properties", props)
                        .andReturnValue("1");
-       mock().expectOneCall("properties_get")
+       mock().expectOneCall("properties_getWithDefault")
                        .withParameter("key", OSGI_FRAMEWORK_SERVICE_RANKING)
+                       .ignoreOtherParameters()
                        .withParameter("properties", props2)
                        .andReturnValue("2");
 
@@ -646,21 +663,25 @@ TEST(service_reference, compareTo){
        LONGS_EQUAL(-1, compare);
 
        //service 1 is equal in ID and irrelevantly ranked
-       mock().expectOneCall("properties_get")
+       mock().expectOneCall("properties_getWithDefault")
                        .withParameter("key", OSGI_FRAMEWORK_SERVICE_ID)
+                       .ignoreOtherParameters()
                        .withParameter("properties", props)
                        .andReturnValue("1);");
-       mock().expectOneCall("properties_get")
+       mock().expectOneCall("properties_getWithDefault")
                        .withParameter("key", OSGI_FRAMEWORK_SERVICE_ID)
+                       .ignoreOtherParameters()
                        .withParameter("properties", props2)
                        .andReturnValue("1");
 
-       mock().expectOneCall("properties_get")
+       mock().expectOneCall("properties_getWithDefault")
                        .withParameter("key", OSGI_FRAMEWORK_SERVICE_RANKING)
+                       .ignoreOtherParameters()
                        .withParameter("properties", props)
                        .andReturnValue("1");
-       mock().expectOneCall("properties_get")
+       mock().expectOneCall("properties_getWithDefault")
                        .withParameter("key", OSGI_FRAMEWORK_SERVICE_RANKING)
+                       .ignoreOtherParameters()
                        .withParameter("properties", props2)
                        .andReturnValue("1");
 
@@ -668,21 +689,25 @@ TEST(service_reference, compareTo){
        LONGS_EQUAL(0, compare);
 
        //services have no rank and service 1 has a higher ID
-       mock().expectOneCall("properties_get")
+       mock().expectOneCall("properties_getWithDefault")
                        .withParameter("key", OSGI_FRAMEWORK_SERVICE_ID)
+                       .ignoreOtherParameters()
                        .withParameter("properties", props)
                        .andReturnValue("2");
-       mock().expectOneCall("properties_get")
+       mock().expectOneCall("properties_getWithDefault")
                        .withParameter("key", OSGI_FRAMEWORK_SERVICE_ID)
+                       .ignoreOtherParameters()
                        .withParameter("properties", props2)
                        .andReturnValue("1");
 
-       mock().expectOneCall("properties_get")
+       mock().expectOneCall("properties_getWithDefault")
                        .withParameter("key", OSGI_FRAMEWORK_SERVICE_RANKING)
+                       .ignoreOtherParameters()
                        .withParameter("properties", props)
                        .andReturnValue((void*)NULL);
-       mock().expectOneCall("properties_get")
+       mock().expectOneCall("properties_getWithDefault")
                        .withParameter("key", OSGI_FRAMEWORK_SERVICE_RANKING)
+                       .ignoreOtherParameters()
                        .withParameter("properties", props2)
                        .andReturnValue((void*)NULL);
 

Reply via email to