http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/test/module_test.cpp
----------------------------------------------------------------------
diff --git a/framework/private/test/module_test.cpp 
b/framework/private/test/module_test.cpp
index 3a1c780..7936d96 100644
--- a/framework/private/test/module_test.cpp
+++ b/framework/private/test/module_test.cpp
@@ -25,6 +25,7 @@
  */
 #include <stdlib.h>
 #include <stdio.h>
+#include <string.h>
 
 #include "CppUTest/TestHarness.h"
 #include "CppUTest/TestHarness_c.h"
@@ -39,6 +40,23 @@ int main(int argc, char** argv) {
        return RUN_ALL_TESTS(argc, argv);
 }
 
+static char* my_strdup(const char* s) {
+       if (s == NULL) {
+               return NULL;
+       }
+
+       size_t len = strlen(s);
+
+       char *d = (char*) calloc(len + 1, sizeof(char));
+
+       if (d == NULL) {
+               return NULL;
+       }
+
+       strncpy(d, s, len);
+       return d;
+}
+
 TEST_GROUP(module) {
        void setup(void) {
        }
@@ -49,6 +67,270 @@ TEST_GROUP(module) {
        }
 };
 
+TEST(module, create){
+       module_pt module = NULL;
+       manifest_pt actual_manifest = (manifest_pt) 0x01;
+       bundle_pt actual_bundle = (bundle_pt) 0x02;
+       version_pt actual_version = (version_pt) 0x03;
+       linked_list_pt actual_capabilities = NULL;
+       linked_list_pt actual_requirements= NULL;
+       char * actual_name = my_strdup("module");
+       char * actual_id = my_strdup("42");
+
+       linkedList_create(&actual_capabilities);
+       linkedList_create(&actual_requirements);
+       mock().expectOneCall("manifestParser_create");
+       mock().expectOneCall("manifestParser_getSymbolicName")
+                                       
.withOutputParameterReturning("symbolicName", &actual_name, sizeof(actual_name) 
);
+       mock().expectOneCall("manifestParser_getBundleVersion")
+                                       
.withOutputParameterReturning("version", &actual_version, sizeof(version_pt) );
+       mock().expectOneCall("manifestParser_getCapabilities")
+                                       
.withOutputParameterReturning("capabilities", &actual_capabilities, 
sizeof(linked_list_pt) );
+       mock().expectOneCall("manifestParser_getCurrentRequirements")
+                                       
.withOutputParameterReturning("requirements", &actual_requirements, 
sizeof(linked_list_pt) );
+       mock().expectOneCall("manifestParser_destroy");
+
+       module = module_create(actual_manifest, actual_id, actual_bundle);
+       CHECK(module != NULL);
+
+       mock().expectOneCall("version_destroy");
+       module_destroy(module);
+
+       free(actual_id);
+}
+
+TEST(module, createFrameworkModule){
+       module_pt module = NULL;
+       bundle_pt actual_bundle = (bundle_pt) 0x01;
+
+       mock().expectOneCall("version_createVersion");
+
+       module = module_createFrameworkModule(actual_bundle);
+
+       CHECK(module != NULL);
+
+       mock().expectOneCall("version_destroy");
+
+       module_destroy(module);
+}
+
+TEST(module, resolved){
+       module_pt module = NULL;
+       manifest_pt actual_manifest = (manifest_pt) 0x01;
+       bundle_pt actual_bundle = (bundle_pt) 0x02;
+       version_pt actual_version = (version_pt) 0x03;
+       linked_list_pt actual_capabilities = NULL;
+       linked_list_pt actual_requirements= NULL;
+       char * actual_name = my_strdup("module");
+       char * actual_id = my_strdup("42");
+
+       linkedList_create(&actual_capabilities);
+       linkedList_create(&actual_requirements);
+       mock().expectOneCall("manifestParser_create");
+       mock().expectOneCall("manifestParser_getSymbolicName")
+                                       
.withOutputParameterReturning("symbolicName", &actual_name, sizeof(actual_name) 
);
+       mock().expectOneCall("manifestParser_getBundleVersion")
+                                       
.withOutputParameterReturning("version", &actual_version, sizeof(version_pt) );
+       mock().expectOneCall("manifestParser_getCapabilities")
+                                       
.withOutputParameterReturning("capabilities", &actual_capabilities, 
sizeof(linked_list_pt) );
+       mock().expectOneCall("manifestParser_getCurrentRequirements")
+                                       
.withOutputParameterReturning("requirements", &actual_requirements, 
sizeof(linked_list_pt) );
+       mock().expectOneCall("manifestParser_destroy");
+       module = module_create(actual_manifest, actual_id, actual_bundle);
+
+       CHECK_FALSE(module_isResolved(module));
+       module_setResolved(module);
+       CHECK(module_isResolved(module));
+
+       mock().expectOneCall("version_destroy");
+       module_destroy(module);
+
+       free(actual_id);
+}
+
+TEST(module, wires){
+       manifest_pt manifest = (manifest_pt) 0x01;
+       bundle_pt bundle = (bundle_pt) 0x02;
+       version_pt version = (version_pt) 0x03;
+       wire_pt wire = (wire_pt) 0x04;
+       wire_pt wire_new = (wire_pt) 0x05;
+       capability_pt cap = (capability_pt) 0x06;
+       requirement_pt req = (requirement_pt) 0x07;
+       char * service_name = my_strdup("foobar");
+
+       //test var declarations
+       array_list_pt get_list = NULL;
+
+       //module related declares
+       module_pt module = NULL;
+       char * name = my_strdup("module_1");
+       char * id = my_strdup("42");
+       linked_list_pt capabilities = NULL;
+       linked_list_pt requirements = NULL;
+       linked_list_pt wires = NULL;
+       linked_list_pt wires_new = NULL;
+
+       //module2 related declares
+       module_pt module2 = NULL;
+       char * name2 = my_strdup("module_2");
+       char * id2 = my_strdup("43");
+       linked_list_pt capabilities2 = NULL;
+       linked_list_pt requirements2 = NULL;
+       linked_list_pt wires2 = NULL;
+
+       //create module
+       linkedList_create(&capabilities);
+       linkedList_create(&requirements);
+       linkedList_create(&wires);
+       linkedList_addElement(capabilities, cap);
+       linkedList_addElement(requirements, req);
+       linkedList_addElement(wires, wire);
+
+       mock().expectOneCall("manifestParser_create");
+       mock().expectOneCall("manifestParser_getSymbolicName")
+                                               
.withOutputParameterReturning("symbolicName", &name, sizeof(name));
+       mock().expectOneCall("manifestParser_getBundleVersion")
+                                               
.withOutputParameterReturning("version", &version, sizeof(version));
+       mock().expectOneCall("manifestParser_getCapabilities")
+                                               
.withOutputParameterReturning("capabilities", &capabilities, 
sizeof(capabilities));
+       mock().expectOneCall("manifestParser_getCurrentRequirements")
+                                               
.withOutputParameterReturning("requirements", &requirements, 
sizeof(requirements));
+       mock().expectOneCall("manifestParser_destroy");
+       module = module_create(manifest, id, bundle);
+
+       //create module2
+       linkedList_create(&capabilities2);
+       linkedList_create(&requirements2);
+       linkedList_create(&wires_new);
+       linkedList_addElement(wires_new, wire_new);
+       mock().expectOneCall("manifestParser_create");
+       mock().expectOneCall("manifestParser_getSymbolicName")
+                                               
.withOutputParameterReturning("symbolicName", &name2, sizeof(name2));
+       mock().expectOneCall("manifestParser_getBundleVersion")
+                                               
.withOutputParameterReturning("version", &version, sizeof(version));
+       mock().expectOneCall("manifestParser_getCapabilities")
+                                               
.withOutputParameterReturning("capabilities", &capabilities2, 
sizeof(capabilities2));
+       mock().expectOneCall("manifestParser_getCurrentRequirements")
+                                               
.withOutputParameterReturning("requirements", &requirements2, 
sizeof(requirements2));
+       mock().expectOneCall("manifestParser_destroy");
+       module2 = module_create(manifest, id, bundle);
 
+       //test empty wires handling
+       POINTERS_EQUAL(NULL, module_getWire(module, service_name));
 
+       //expect the adding of wire
+       mock().expectOneCall("wire_getExporter")
+                                       .withParameter("wire", wire)
+                                       
.withOutputParameterReturning("exporter", &module2, sizeof(module2));
 
+       //set modules->wires = actual_wires, and register module dependent at 
module2
+       module_setWires(module, wires);
+
+       //expect getting of wire vars
+       mock().expectOneCall("wire_getCapability")
+                       .withParameter("wire", wire)
+                       .withOutputParameterReturning("capability", &cap, 
sizeof(cap));
+
+       mock().expectOneCall("capability_getServiceName")
+                       .withParameter("capability", cap)
+                       .withOutputParameterReturning("serviceName", 
&service_name, sizeof(service_name));
+
+       //test for added wire
+       POINTERS_EQUAL(wire, module_getWire(module, service_name));
+
+       //test added dependent module (method 1 of 2)
+       get_list = module_getDependents(module2);
+       CHECK(arrayList_contains(get_list, module));
+
+       //expect the re-adding of wire
+       //expect the adding of wire
+       mock().expectOneCall("wire_getExporter")
+                                       .withParameter("wire", wire)
+                                       
.withOutputParameterReturning("exporter", &module2, sizeof(module2));
+
+       mock().expectOneCall("wire_destroy");
+
+       mock().expectOneCall("wire_getExporter")
+                                       .withParameter("wire", wire_new)
+                                       
.withOutputParameterReturning("exporter", &module2, sizeof(module2));
+
+       //test clearing of the wires before adding back wire
+       module_setWires(module, wires_new);
+
+       //test added dependent module (method 2 of 2)
+       CHECK(arrayList_contains(module_getDependentImporters(module2),module));
+
+       //check getwires
+       POINTERS_EQUAL(wires_new, module_getWires(module));
+
+       //TODO make tests for possible implementations of the following 
functions
+       module_addDependentRequirer(module, module2);
+       module_getDependentRequirers(module);
+       module_removeDependentRequirer(module, module2);
+
+       //clean up
+       mock().expectNCalls(2, "version_destroy");
+       mock().expectOneCall("wire_destroy");
+       mock().expectOneCall("capability_destroy");
+       mock().expectOneCall("requirement_destroy");
+       module_destroy(module);
+       module_destroy(module2);
+
+       arrayList_destroy(get_list);
+       free(id);
+       free(id2);
+       free(service_name);
+}
+
+TEST(module, get){
+       module_pt module = NULL;
+       manifest_pt actual_manifest = (manifest_pt) 0x01;
+       bundle_pt actual_bundle = (bundle_pt) 0x02;
+       version_pt actual_version = (version_pt) 0x03;
+       linked_list_pt actual_capabilities = NULL;
+       linked_list_pt actual_requirements= NULL;
+       char * actual_name = my_strdup("module");
+       char * actual_id = my_strdup("42");
+       char * get = NULL;
+
+       linkedList_create(&actual_capabilities);
+       linkedList_create(&actual_requirements);
+
+       mock().expectOneCall("manifestParser_create");
+       mock().expectOneCall("manifestParser_getSymbolicName")
+                                       
.withOutputParameterReturning("symbolicName", &actual_name, sizeof(actual_name) 
);
+
+       mock().expectOneCall("manifestParser_getBundleVersion")
+                                       
.withOutputParameterReturning("version", &actual_version, sizeof(version_pt) );
+
+       mock().expectOneCall("manifestParser_getCapabilities")
+                                       
.withOutputParameterReturning("capabilities", &actual_capabilities, 
sizeof(linked_list_pt) );
+
+       mock().expectOneCall("manifestParser_getCurrentRequirements")
+                                       
.withOutputParameterReturning("requirements", &actual_requirements, 
sizeof(linked_list_pt) );
+
+       mock().expectOneCall("manifestParser_destroy");
+
+
+       module = module_create(actual_manifest, actual_id, actual_bundle);
+
+       CHECK(module != NULL);
+
+       POINTERS_EQUAL(actual_bundle, module_getBundle(module));
+       POINTERS_EQUAL(actual_requirements, module_getRequirements(module));
+       POINTERS_EQUAL(actual_capabilities, module_getCapabilities(module));
+       POINTERS_EQUAL(actual_version, module_getVersion(module));
+
+       STRCMP_EQUAL(actual_id, module_getId(module));
+
+       LONGS_EQUAL(CELIX_SUCCESS, module_getSymbolicName(module, &get));
+       STRCMP_EQUAL(actual_name, get);
+
+       LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, module_getSymbolicName(NULL, &get));
+
+       mock().expectOneCall("version_destroy");
+
+       module_destroy(module);
+
+       free(actual_id);
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/test/properties_test.cpp
----------------------------------------------------------------------
diff --git a/framework/private/test/properties_test.cpp 
b/framework/private/test/properties_test.cpp
index c06393e..2be5092 100644
--- a/framework/private/test/properties_test.cpp
+++ b/framework/private/test/properties_test.cpp
@@ -40,6 +40,7 @@ int main(int argc, char** argv) {
 }
 
 TEST_GROUP(properties) {
+       properties_pt properties;
 
        void setup(void) {
        }
@@ -51,25 +52,29 @@ TEST_GROUP(properties) {
 };
 
 TEST(properties, create) {
-       properties_pt properties = properties_create();
+       properties = properties_create();
        CHECK(properties);
+
+       properties_destroy(properties);
 }
 
 TEST(properties, load) {
-       char propertiesFile[] = 
"../../celix/framework/private/resources-test/properties.txt";
-       properties_pt properties = properties_load(propertiesFile);
-       LONGS_EQUAL(2, hashMap_size(properties));
+       char propertiesFile[] = "resources-test/properties.txt";
+       properties = properties_load(propertiesFile);
+       LONGS_EQUAL(3, hashMap_size(properties));
 
        char keyA[] = "a";
        char *valueA = properties_get(properties, keyA);
        STRCMP_EQUAL("b", valueA);
        char keyB[] = "b";
        STRCMP_EQUAL("c", properties_get(properties, keyB));
+
+       properties_destroy(properties);
 }
 
 TEST(properties, store) {
-       char propertiesFile[] = "properties_out.txt";
-       properties_pt properties = properties_create();
+       char propertiesFile[] = "resources-test/properties_out.txt";
+       properties = properties_create();
        char keyA[] = "x";
        char keyB[] = "y";
        char valueA[] = "1";
@@ -77,10 +82,12 @@ TEST(properties, store) {
        properties_set(properties, keyA, valueA);
        properties_set(properties, keyB, valueB);
        properties_store(properties, propertiesFile, NULL);
+
+       properties_destroy(properties);
 }
 
 TEST(properties, getSet) {
-       properties_pt properties = properties_create();
+       properties = properties_create();
        char keyA[] = "x";
        char keyB[] = "y";
        char keyC[] = "z";
@@ -93,5 +100,7 @@ TEST(properties, getSet) {
        STRCMP_EQUAL(valueA, properties_get(properties, keyA));
        STRCMP_EQUAL(valueB, properties_get(properties, keyB));
        STRCMP_EQUAL(valueC, properties_getWithDefault(properties, keyC, 
valueC));
+
+       properties_destroy(properties);
 }
 

http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/test/requirement_test.cpp
----------------------------------------------------------------------
diff --git a/framework/private/test/requirement_test.cpp 
b/framework/private/test/requirement_test.cpp
index fc08a84..b45f844 100644
--- a/framework/private/test/requirement_test.cpp
+++ b/framework/private/test/requirement_test.cpp
@@ -36,8 +36,9 @@ extern "C" {
 #include "attribute.h"
 #include "version_range.h"
 #include "celix_log.h"
+#include "utils.h"
 
-framework_logger_pt logger;
+framework_logger_pt logger = (framework_logger_pt) 0x42;
 }
 
 int main(int argc, char** argv) {
@@ -46,8 +47,6 @@ int main(int argc, char** argv) {
 
 TEST_GROUP(requirement) {
        void setup(void) {
-               logger = (framework_logger_pt) malloc(sizeof(*logger));
-        logger->logFunction = frameworkLogger_log;
        }
 
        void teardown() {
@@ -58,7 +57,7 @@ TEST_GROUP(requirement) {
 
 TEST(requirement, create) {
        hash_map_pt directives = hashMap_create(NULL, NULL, NULL, NULL);
-       hash_map_pt attributes = hashMap_create(NULL, NULL, NULL, NULL);
+       hash_map_pt attributes = hashMap_create(utils_stringHash, NULL, 
utils_stringEquals, NULL);
 
        attribute_pt serviceAttribute = (attribute_pt) 0x01;
        hashMap_put(attributes, (void*) "service", serviceAttribute);
@@ -88,6 +87,11 @@ TEST(requirement, create) {
 
        requirement_pt requirement = NULL;
        requirement_create(directives, attributes, &requirement);
+
+       mock().expectNCalls(2, "attribute_destroy");
+       mock().expectOneCall("versionRange_destroy");
+
+       requirement_destroy(requirement);
 }
 
 TEST(requirement, getVersionRange) {
@@ -98,6 +102,8 @@ TEST(requirement, getVersionRange) {
        version_range_pt actual = NULL;
        requirement_getVersionRange(requirement, &actual);
        POINTERS_EQUAL(versionRange, actual);
+
+       free(requirement);
 }
 
 TEST(requirement, getTargetName) {
@@ -108,6 +114,8 @@ TEST(requirement, getTargetName) {
        char *actual = NULL;
        requirement_getTargetName(requirement, &actual);
        STRCMP_EQUAL(targetName, actual);
+
+       free(requirement);
 }
 
 TEST(requirement, isSatisfied) {
@@ -130,4 +138,6 @@ TEST(requirement, isSatisfied) {
        bool inRange2 = false;
        requirement_isSatisfied(requirement, capability, &inRange2);
        CHECK(inRange2);
+
+       free(requirement);
 }

http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/test/resolver_test.cpp
----------------------------------------------------------------------
diff --git a/framework/private/test/resolver_test.cpp 
b/framework/private/test/resolver_test.cpp
index bf864b2..df8e608 100644
--- a/framework/private/test/resolver_test.cpp
+++ b/framework/private/test/resolver_test.cpp
@@ -25,6 +25,7 @@
  */
 #include <stdlib.h>
 #include <stdio.h>
+#include <string.h>
 
 #include "CppUTest/TestHarness.h"
 #include "CppUTest/TestHarness_c.h"
@@ -35,25 +36,154 @@ extern "C" {
 #include "resolver.h"
 #include "celix_log.h"
 
-framework_logger_pt logger;
+framework_logger_pt logger = (framework_logger_pt) 0x42;
 }
 
 int main(int argc, char** argv) {
        return RUN_ALL_TESTS(argc, argv);
 }
 
+static char* my_strdup(const char* s) {
+       if (s == NULL) {
+               return NULL;
+       }
+
+       size_t len = strlen(s);
+
+       char *d = (char*) calloc(len + 1, sizeof(char));
+
+       if (d == NULL) {
+               return NULL;
+       }
+
+       strncpy(d, s, len);
+       return d;
+}
+
 TEST_GROUP(resolver) {
-       void setup(void) {
-               logger = (framework_logger_pt) malloc(sizeof(*logger));
-               logger->logFunction = frameworkLogger_log;
+       void setup(void){
        }
 
-       void teardown() {
+       void teardown(){
                mock().checkExpectations();
                mock().clear();
        }
 };
 
+TEST(resolver, resolve){
+       module_pt module;
+       module_pt module2;
+       manifest_pt actual_manifest = (manifest_pt) 0x01;
+       bundle_pt actual_bundle = (bundle_pt) 0x02;
+       version_pt actual_version = (version_pt) 0x03;
+       linked_list_pt actual_capabilities = NULL;
+       linked_list_pt actual_requirements= NULL;
+       char * actual_name = my_strdup("module");
+       char * actual_id = my_strdup("42");
+       char * actual_service_name = my_strdup("test_service_foo");
+       char * actual_service_name2 = my_strdup("test_service_bar");
+       requirement_pt req = (requirement_pt) 0x04;
+       requirement_pt req2= (requirement_pt) 0x05;
+       capability_pt cap = (capability_pt) 0x06;
+       capability_pt cap2= (capability_pt) 0x07;
+       linked_list_pt get;
+
+       //creating module
+       linkedList_create(&actual_capabilities);
+       linkedList_create(&actual_requirements);
+
+       linkedList_addElement(actual_requirements, req);
+       linkedList_addElement(actual_requirements, req2);
+       linkedList_addElement(actual_capabilities, cap);
+       linkedList_addElement(actual_capabilities, cap2);
+
+
+       mock().expectNCalls(2, "manifestParser_create");
+       mock().expectNCalls(2,"manifestParser_getSymbolicName")
+                                       
.withOutputParameterReturning("symbolicName", &actual_name, sizeof(actual_name) 
);
+       mock().expectNCalls(2, "manifestParser_getBundleVersion")
+                                       
.withOutputParameterReturning("version", &actual_version, sizeof(version_pt) );
+       mock().expectNCalls(2, "manifestParser_getCapabilities")
+                                       
.withOutputParameterReturning("capabilities", &actual_capabilities, 
sizeof(linked_list_pt) );
+       mock().expectNCalls(2, "manifestParser_getCurrentRequirements")
+                                       
.withOutputParameterReturning("requirements", &actual_requirements, 
sizeof(linked_list_pt) );
+       mock().expectNCalls(2, "manifestParser_destroy");
+
+       module = module_create(actual_manifest, actual_id, actual_bundle);
+       module2 = module_create(actual_manifest, actual_id, actual_bundle);
+
+       mock().expectOneCall("capability_getServiceName")
+                       .withParameter("capability", cap)
+                       .withOutputParameterReturning("serviceName", 
&actual_service_name, sizeof(actual_service_name));
+
+       mock().expectOneCall("capability_getServiceName")
+                       .withParameter("capability", cap2)
+                       .withOutputParameterReturning("serviceName", 
&actual_service_name2, sizeof(actual_service_name2));
+
+       resolver_addModule(module2);
+
+       mock().expectOneCall("requirement_getTargetName")
+                       .withParameter("requirement", req)
+                       .withOutputParameterReturning("targetName", 
&actual_service_name, sizeof(actual_service_name));
+
+       mock().expectOneCall("requirement_getTargetName")
+                       .withParameter("requirement", req2)
+                       .withOutputParameterReturning("targetName", 
&actual_service_name2, sizeof(actual_service_name2));
+
+       bool out = true;
+       mock().expectOneCall("requirement_isSatisfied")
+                       .withParameter("requirement", req)
+                       .withParameter("capability", cap)
+                       .withOutputParameterReturning("inRange", &out, 
sizeof(out));
+
+       mock().expectOneCall("requirement_isSatisfied")
+                       .withParameter("requirement", req2)
+                       .withParameter("capability", cap2)
+                       .withOutputParameterReturning("inRange", &out, 
sizeof(out));
+
+       mock().expectOneCall("capability_getModule")
+                       .withParameter("capability", cap)
+                       .withOutputParameterReturning("module", &module, 
sizeof(module));
+
+       /*mock().expectOneCall("capability_getModule")
+                       .withParameter("capability", cap)
+                       .withOutputParameterReturning("module", &module, 
sizeof(module));*/
+
+       get = resolver_resolve(module);
+       //CHECK(linkedList_contains(get, wire));
+
+       //test resolved module checking
+
+       POINTERS_EQUAL(NULL, resolver_resolve(module));
+
+       mock().expectOneCall("version_destroy");
+       module_destroy(module);
+       module_destroy(module2);
+
+
+       free(actual_id);
+       free(actual_name);
+}
+/*
+TEST(resolver, moduleResolved){
+       module_pt module;
+  resolver_moduleResolved(module);
+}
+
+TEST(resolver, addModule){
+       module_pt module;
+       resolver_addModule(module);
+}
+
+TEST(resolver, removeModule){
+       module_pt module ;
+
+       module = module_create(actual_manifest, actual_id, actual_bundle);
+
+       resolver_removeModule(module);
+}
+*/
+
 
 
 

http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/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 5d8213a..1c383ec 100644
--- a/framework/private/test/service_reference_test.cpp
+++ b/framework/private/test/service_reference_test.cpp
@@ -34,6 +34,7 @@
 extern "C" {
 #include "service_reference_private.h"
 #include "celix_log.h"
+#include "utils.h"
 
 framework_logger_pt logger;
 }

http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/test/service_registration_test.cpp
----------------------------------------------------------------------
diff --git a/framework/private/test/service_registration_test.cpp 
b/framework/private/test/service_registration_test.cpp
index cec1374..cec62ef 100644
--- a/framework/private/test/service_registration_test.cpp
+++ b/framework/private/test/service_registration_test.cpp
@@ -270,7 +270,9 @@ TEST(service_registration, getRegistryIllegalArgument) {
 TEST(service_registration, getServiceReferences) {
        service_registration_pt registration = (service_registration_pt) 
malloc(sizeof(*registration));
        array_list_pt references = NULL;
-       service_registry_pt registry = (service_registry_pt) 0x10;
+       //service_registry_pt registry = (service_registry_pt) 0x10;
+       //service_registry_pt registry = (service_registry_pt) 0x0;
+       service_registry_pt registry = registration->registry;
        bundle_pt bundle = (bundle_pt) 0x20;
 
        
mock().expectOneCall("serviceRegistry_getServiceReferencesForRegistration")

http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/test/service_registry_test.cpp
----------------------------------------------------------------------
diff --git a/framework/private/test/service_registry_test.cpp 
b/framework/private/test/service_registry_test.cpp
index 10a649d..0175f45 100644
--- a/framework/private/test/service_registry_test.cpp
+++ b/framework/private/test/service_registry_test.cpp
@@ -30,12 +30,21 @@
 #include "CppUTest/TestHarness_c.h"
 #include "CppUTest/CommandLineTestRunner.h"
 #include "CppUTestExt/MockSupport.h"
+#include "CppUTestExt/MockSupport_c.h"
 
 extern "C" {
 #include "service_registry_private.h"
 #include "celix_log.h"
 
-framework_logger_pt logger;
+framework_logger_pt logger = (framework_logger_pt) 0x42;
+
+void serviceRegistryTest_serviceChanged(framework_pt framework, 
service_event_type_e eventType, service_registration_pt registration, 
properties_pt oldprops) {
+       mock_c()->actualCall("serviceRegistryTest_serviceChanged")
+                       ->withPointerParameters("framework", framework)
+                       ->withIntParameters("eventType", eventType)
+                       ->withPointerParameters("registration", registration)
+                       ->withPointerParameters("oldprops", oldprops);
+}
 }
 
 int main(int argc, char** argv) {
@@ -44,8 +53,6 @@ int main(int argc, char** argv) {
 
 TEST_GROUP(service_registry) {
        void setup(void) {
-               logger = (framework_logger_pt) malloc(sizeof(*logger));
-        logger->logFunction = frameworkLogger_log;
        }
 
        void teardown() {
@@ -54,11 +61,6 @@ TEST_GROUP(service_registry) {
        }
 };
 
-extern "C" {
-void serviceRegistryTest_serviceChanged(framework_pt framework, 
service_event_type_e eventType, service_registration_pt registration, 
properties_pt oldprops) {
-}
-}
-
 TEST(service_registry, create) {
        framework_pt framework = (framework_pt) 0x10;
        service_registry_pt registry = NULL;
@@ -71,14 +73,20 @@ TEST(service_registry, create) {
        CHECK(registry->inUseMap != NULL);
        CHECK(registry->listenerHooks != NULL);
        //CHECK(registry->mutex != NULL);
-       CHECK(registry->serviceReferences == NULL);
+       CHECK(registry->serviceReferences != NULL);
        CHECK(registry->serviceRegistrations != NULL);
+
+       serviceRegistry_destroy(registry);
 }
 
 TEST(service_registry, getRegisteredServices) {
        service_registry_pt registry = (service_registry_pt) 
malloc(sizeof(*registry));
        registry->serviceRegistrations = hashMap_create(NULL, NULL, NULL, NULL);
-
+       registry->serviceReferences = hashMap_create(NULL, NULL, NULL, NULL);
+       celixThreadMutexAttr_create(&registry->mutexAttr);
+    celixThreadMutexAttr_settype(&registry->mutexAttr, 
CELIX_THREAD_MUTEX_RECURSIVE);
+    celixThreadMutex_create(&registry->mutex, &registry->mutexAttr);
+       celixThreadMutex_create(&registry->referencesMapMutex, NULL);
        array_list_pt registrations = NULL;
        arrayList_create(&registrations);
        service_registration_pt reg = (service_registration_pt) 0x10;
@@ -108,21 +116,28 @@ TEST(service_registry, getRegisteredServices) {
                .withOutputParameterReturning("reference", &ref, sizeof(ref))
                .andReturnValue(CELIX_SUCCESS)
                .ignoreOtherParameters();
-       mock()
+       /*mock()
                .expectOneCall("serviceRegistration_getServiceReferences")
                .withParameter("registration", reg)
                .withOutputParameterReturning("references", &refs, sizeof(refs))
-               .andReturnValue(CELIX_SUCCESS);
+               .andReturnValue(CELIX_SUCCESS);*/
 
        array_list_pt services = NULL;
        serviceRegistry_getRegisteredServices(registry, bundle, &services);
        LONGS_EQUAL(1, arrayList_size(services));
        POINTERS_EQUAL(ref, arrayList_get(services, 0));
+
+       free(registry);
 }
 
 TEST(service_registry, getServicesInUse) {
        service_registry_pt registry = (service_registry_pt) 
malloc(sizeof(*registry));
        registry->inUseMap = hashMap_create(NULL, NULL, NULL, NULL);
+       celixThreadMutexAttr_create(&registry->mutexAttr);
+    celixThreadMutexAttr_settype(&registry->mutexAttr, 
CELIX_THREAD_MUTEX_RECURSIVE);
+    celixThreadMutex_create(&registry->mutex, &registry->mutexAttr);
+
+       celixThreadMutex_create(&registry->referencesMapMutex, NULL);
 
        array_list_pt usages = NULL;
        arrayList_create(&usages);
@@ -137,6 +152,8 @@ TEST(service_registry, getServicesInUse) {
        serviceRegistry_getServicesInUse(registry, bundle, &inUse);
        LONGS_EQUAL(1, arrayList_size(inUse));
        POINTERS_EQUAL(ref, arrayList_get(inUse, 0));
+
+       free(registry);
 }
 
 TEST(service_registry, registerServiceNoProps) {
@@ -167,6 +184,8 @@ TEST(service_registry, registerServiceNoProps) {
        service_registration_pt registration = NULL;
        serviceRegistry_registerService(registry, bundle, (char *) 
serviceName.c_str(), service, NULL, &registration);
        POINTERS_EQUAL(reg, registration);
+
+       free(registry);
 }
 
 TEST(service_registry, registerServiceFactoryNoProps) {
@@ -197,6 +216,8 @@ TEST(service_registry, registerServiceFactoryNoProps) {
        service_registration_pt registration = NULL;
        serviceRegistry_registerServiceFactory(registry, bundle, (char *) 
serviceName.c_str(), factory, NULL, &registration);
        POINTERS_EQUAL(reg, registration);
+
+       free(registry);
 }
 
 TEST(service_registry, unregisterService) {
@@ -243,11 +264,18 @@ TEST(service_registry, unregisterService) {
                .withOutputParameterReturning("references", &references, 
sizeof(references))
                .andReturnValue(CELIX_SUCCESS);
        mock()
+               .expectOneCall("serviceReference_invalidate")
+               .withParameter("reference", reference)
+               .andReturnValue(CELIX_SUCCESS);
+
+       mock()
                .expectOneCall("serviceRegistration_invalidate")
                .withParameter("registration", registration)
                .andReturnValue(CELIX_SUCCESS);
 
        serviceRegistry_unregisterService(registry, bundle, registration);
+
+       free(registry);
 }
 
 TEST(service_registry, unregisterServices) {
@@ -277,14 +305,18 @@ TEST(service_registry, unregisterServices) {
                .andReturnValue(CELIX_SUCCESS);
        serviceRegistry_unregisterServices(registry, bundle);
        LONGS_EQUAL(0, hashMap_size(registry->serviceRegistrations));
+
+       free(registry);
 }
 
-TEST(service_registry, getServiceReferences) {
+TEST(service_registry, getServiceReferencesForRegistration){
+#warning implement this
        service_registry_pt registry = (service_registry_pt) 
malloc(sizeof(*registry));
        registry->inUseMap = hashMap_create(NULL, NULL, NULL, NULL);
        celixThreadMutexAttr_create(&registry->mutexAttr);
     celixThreadMutexAttr_settype(&registry->mutexAttr, 
CELIX_THREAD_MUTEX_RECURSIVE);
     celixThreadMutex_create(&registry->mutex, &registry->mutexAttr);
+       celixThreadMutex_create(&registry->referencesMapMutex, NULL);
        registry->currentServiceId = 1l;
        registry->serviceRegistrations = hashMap_create(NULL, NULL, NULL, NULL);
 
@@ -293,7 +325,34 @@ TEST(service_registry, getServiceReferences) {
        array_list_pt registrations = NULL;
        arrayList_create(&registrations);
        arrayList_add(registrations, registration);
+       registry->serviceReferences = hashMap_create(NULL, NULL, NULL, NULL);
+       hashMap_put(registry->serviceRegistrations, bundle, registrations);
 
+       properties_pt properties = (properties_pt) 0x30;
+       array_list_pt references = NULL;
+       arrayList_create(&references);
+       service_reference_pt reference = (service_reference_pt) 0x40;
+       arrayList_add(references, reference);
+
+       serviceRegistry_getServiceReferencesForRegistration(registry, 
registration, &references);
+}
+
+TEST(service_registry, getServiceReferences) {
+       service_registry_pt registry = (service_registry_pt) 
malloc(sizeof(*registry));
+       registry->inUseMap = hashMap_create(NULL, NULL, NULL, NULL);
+       celixThreadMutexAttr_create(&registry->mutexAttr);
+    celixThreadMutexAttr_settype(&registry->mutexAttr, 
CELIX_THREAD_MUTEX_RECURSIVE);
+    celixThreadMutex_create(&registry->mutex, &registry->mutexAttr);
+       celixThreadMutex_create(&registry->referencesMapMutex, NULL);
+       registry->currentServiceId = 1l;
+       registry->serviceRegistrations = hashMap_create(NULL, NULL, NULL, NULL);
+
+       bundle_pt bundle = (bundle_pt) 0x10;
+       service_registration_pt registration = (service_registration_pt) 0x20;
+       array_list_pt registrations = NULL;
+       arrayList_create(&registrations);
+       arrayList_add(registrations, registration);
+       registry->serviceReferences = hashMap_create(NULL, NULL, NULL, NULL);
        hashMap_put(registry->serviceRegistrations, bundle, registrations);
 
        properties_pt properties = (properties_pt) 0x30;
@@ -330,17 +389,19 @@ TEST(service_registry, getServiceReferences) {
                .withOutputParameterReturning("reference", &reference, 
sizeof(reference))
                .andReturnValue(CELIX_SUCCESS)
                .ignoreOtherParameters();
-       mock()
+       /*mock()
                .expectOneCall("serviceRegistration_getServiceReferences")
                .withParameter("registration", registration)
                .withOutputParameterReturning("references", &references, 
sizeof(references))
-               .andReturnValue(CELIX_SUCCESS);
+               .andReturnValue(CELIX_SUCCESS);*/
 
        array_list_pt actual  = NULL;
 
        serviceRegistry_getServiceReferences(registry, NULL, "test", NULL, 
&actual);
        LONGS_EQUAL(1, arrayList_size(actual));
        POINTERS_EQUAL(reference, arrayList_get(actual, 0));
+
+       free(registry);
 }
 
 TEST(service_registry, getService) {
@@ -379,11 +440,11 @@ TEST(service_registry, getService) {
                .expectOneCall("serviceRegistration_isValid")
                .withParameter("registration", registration)
                .andReturnValue(true);
-       mock()
+       /*mock()
                .expectOneCall("bundle_getCurrentModule")
                .withParameter("bundle", bundle)
                .withOutputParameterReturning("module", &module, sizeof(module))
-               .andReturnValue(CELIX_SUCCESS);
+               .andReturnValue(CELIX_SUCCESS);*/
        mock()
                .expectOneCall("serviceRegistration_getService")
                .withParameter("registration", registration)
@@ -398,10 +459,12 @@ TEST(service_registry, getService) {
        void *actual = NULL;
        serviceRegistry_getService(registry, bundle, reference, &actual);
        POINTERS_EQUAL(service, actual);
+
+       free(registry);
 }
 
 TEST(service_registry, ungetService) {
-       service_registry_pt registry = (service_registry_pt) 
malloc(sizeof(*registry));
+       service_registry_pt registry = (service_registry_pt) 
calloc(1,sizeof(*registry));
        registry->inUseMap = hashMap_create(NULL, NULL, NULL, NULL);
        celixThreadMutexAttr_create(&registry->mutexAttr);
     celixThreadMutexAttr_settype(&registry->mutexAttr, 
CELIX_THREAD_MUTEX_RECURSIVE);
@@ -425,7 +488,7 @@ TEST(service_registry, ungetService) {
 
        array_list_pt usages = NULL;
        arrayList_create(&usages);
-       usage_count_pt usage = (usage_count_pt) malloc(sizeof(*usage));
+       usage_count_pt usage = (usage_count_pt) calloc(1,sizeof(*usage));
        usage->reference = reference;
        arrayList_add(usages, usage);
        hashMap_put(registry->inUseMap, bundle, usages);
@@ -435,18 +498,25 @@ TEST(service_registry, ungetService) {
                .withParameter("reference", reference)
                .withOutputParameterReturning("registration", &registration, 
sizeof(registration))
                .andReturnValue(CELIX_SUCCESS);
+
+       bool out = true;
+       mock()
+                       .expectOneCall("serviceReference_equals")
+                       .withParameter("reference", reference)
+                       .withParameter("compareTo", reference)
+                       .withOutputParameterReturning("equal", &out, 
sizeof(out))
+                       .andReturnValue(CELIX_SUCCESS);
+
        mock()
                .expectOneCall("serviceRegistration_isValid")
                .withParameter("registration", registration)
                .andReturnValue(true);
-       mock()
-           .expectOneCall("serviceReference_destroy")
-           .withParameter("reference", reference)
-           .andReturnValue(CELIX_SUCCESS);
 
        bool result = false;
        serviceRegistry_ungetService(registry, bundle, reference, &result);
        LONGS_EQUAL(1, result);
+
+       free(registry);
 }
 
 TEST(service_registry, ungetServivces) {
@@ -485,27 +555,42 @@ TEST(service_registry, ungetServivces) {
                .withParameter("reference", reference)
                .withOutputParameterReturning("registration", &registration, 
sizeof(registration))
                .andReturnValue(CELIX_SUCCESS);
-//     mock()
-//             .expectOneCall("serviceReference_equals")
-//             .withParameter("reference", reference)
-//             .withParameter("compareTo", reference)
-//             .withOutputParameterReturning("equal", true)
-//             .andReturnValue(CELIX_SUCCESS);
+
+       bool out = true;
+       mock()
+                       .expectOneCall("serviceReference_equals")
+                       .withParameter("reference", reference)
+                       .withParameter("compareTo", reference)
+                       .withOutputParameterReturning("equal", &out, 
sizeof(out))
+                       .andReturnValue(CELIX_SUCCESS);
+
+       out =  true;
+       mock()
+                       .expectOneCall("serviceReference_equals")
+                       .withParameter("reference", reference)
+                       .withParameter("compareTo", reference)
+                       .withOutputParameterReturning("equal", &out, 
sizeof(out))
+                       .andReturnValue(CELIX_SUCCESS);
+
+       mock().expectOneCall("serviceRegistration_ungetService")
+                       .withParameter("registration", registration)
+                       .withParameter("bundle", bundle)
+                       .withOutputParameterReturning("service", &reference, 
sizeof(reference));
+
        mock()
                .expectOneCall("serviceRegistration_isValid")
                .withParameter("registration", registration)
                .andReturnValue(true);
+
        mock()
                .expectOneCall("serviceReference_getServiceRegistration")
                .withParameter("reference", reference)
                .withOutputParameterReturning("registration", &registration, 
sizeof(registration))
                .andReturnValue(CELIX_SUCCESS);
-       mock()
-        .expectOneCall("serviceReference_destroy")
-        .withParameter("reference", reference)
-        .andReturnValue(CELIX_SUCCESS);
 
        serviceRegistry_ungetServices(registry, bundle);
+
+       free(registry);
 }
 
 TEST(service_registry, getUsingBundles) {
@@ -538,9 +623,19 @@ TEST(service_registry, getUsingBundles) {
        arrayList_add(usages, usage);
        hashMap_put(registry->inUseMap, bundle, usages);
 
+       bool out = true;
+       mock()
+                       .expectOneCall("serviceReference_equals")
+                       .withParameter("reference", reference)
+                       .withParameter("compareTo", reference)
+                       .withOutputParameterReturning("equal", &out, 
sizeof(out))
+                       .andReturnValue(CELIX_SUCCESS);
+
        array_list_pt actual = serviceRegistry_getUsingBundles(registry, 
reference);
        LONGS_EQUAL(1, arrayList_size(actual));
        POINTERS_EQUAL(bundle, arrayList_get(actual, 0));
+
+       free(registry);
 }
 
 TEST(service_registry, createServiceReference) {
@@ -549,16 +644,17 @@ TEST(service_registry, createServiceReference) {
        celixThreadMutexAttr_create(&registry->mutexAttr);
     celixThreadMutexAttr_settype(&registry->mutexAttr, 
CELIX_THREAD_MUTEX_RECURSIVE);
        celixThreadMutex_create(&registry->mutex, &registry->mutexAttr);
+       celixThreadMutex_create(&registry->referencesMapMutex, NULL);
        registry->currentServiceId = 1l;
-       registry->serviceRegistrations = hashMap_create(NULL, NULL, NULL, NULL);
+       registry->serviceReferences = hashMap_create(NULL, NULL, NULL, NULL);
 
        bundle_pt bundle = (bundle_pt) 0x10;
        service_registration_pt registration = (service_registration_pt) 0x20;
-//     array_list_pt registrations = NULL;
-//     arrayList_create(&registrations);
-//     arrayList_add(registrations, registration);
-//
-//     hashMap_put(registry->serviceRegistrations, bundle, registrations);
+       /*array_list_pt registrations = NULL;
+       arrayList_create(&registrations);
+       arrayList_add(registrations, registration);
+
+       hashMap_put(registry->serviceRegistrations, bundle, registrations);*/
 
        array_list_pt references = NULL;
        arrayList_create(&references);
@@ -578,22 +674,23 @@ TEST(service_registry, createServiceReference) {
                .withOutputParameterReturning("reference", &reference, 
sizeof(reference))
                .andReturnValue(CELIX_SUCCESS)
                .ignoreOtherParameters();
-       mock()
-               .expectOneCall("serviceRegistration_getServiceReferences")
-               .withParameter("registration", registration)
-               .withOutputParameterReturning("references", &references, 
sizeof(references))
-               .andReturnValue(CELIX_SUCCESS);
 
        service_reference_pt actual  = NULL;
        serviceRegistry_createServiceReference(registry, NULL, registration, 
&actual);
        POINTERS_EQUAL(reference, actual);
+
+       free(registry);
 }
 
 TEST(service_registry, getListenerHooks) {
        service_registry_pt registry = (service_registry_pt) 
malloc(sizeof(*registry));
        registry->listenerHooks = NULL;
        arrayList_create(&registry->listenerHooks);
-
+       celixThreadMutexAttr_create(&registry->mutexAttr);
+       celixThreadMutexAttr_settype(&registry->mutexAttr, 
CELIX_THREAD_MUTEX_RECURSIVE);
+       celixThreadMutex_create(&registry->mutex, &registry->mutexAttr);
+       celixThreadMutex_create(&registry->referencesMapMutex, NULL);
+       registry->serviceReferences = hashMap_create(NULL, NULL, NULL, NULL);
        bundle_pt bundle = (bundle_pt) 0x10;
        service_registration_pt registration = (service_registration_pt) 0x20;
        arrayList_add(registry->listenerHooks, registration);
@@ -616,23 +713,30 @@ TEST(service_registry, getListenerHooks) {
                .withOutputParameterReturning("reference", &reference, 
sizeof(reference))
                .andReturnValue(CELIX_SUCCESS)
                .ignoreOtherParameters();
-       mock()
-               .expectOneCall("serviceRegistration_getServiceReferences")
-               .withParameter("registration", registration)
-               .withOutputParameterReturning("references", &references, 
sizeof(registration))
-               .andReturnValue(CELIX_SUCCESS);
 
        array_list_pt hooks = NULL;
        celix_status_t status = serviceRegistry_getListenerHooks(registry, 
NULL, &hooks);
        LONGS_EQUAL(1, arrayList_size(hooks));
        POINTERS_EQUAL(reference, arrayList_get(hooks, 0));
+
+       free(registry);
 }
 
 TEST(service_registry, servicePropertiesModified) {
        service_registry_pt registry = (service_registry_pt) 
malloc(sizeof(*registry));
        service_registration_pt registration = (service_registration_pt) 0x10;
        properties_pt properties = (properties_pt) 0x20;
+       //test function, defined at top of this test file
+       registry->serviceChanged = serviceRegistryTest_serviceChanged;
+       registry->framework = (framework_pt) 0x30;
+
+       mock().expectOneCall("serviceRegistryTest_serviceChanged")
+               .withParameter("framework", registry->framework)
+               .withParameter("eventType", 
OSGI_FRAMEWORK_SERVICE_EVENT_MODIFIED)
+               .withParameter("registration", registration)
+               .withParameter("oldprops", properties);
 
        serviceRegistry_servicePropertiesModified(registry, registration, 
properties);
-}
 
+       free(registry);
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/test/service_tracker_customizer_test.cpp
----------------------------------------------------------------------
diff --git a/framework/private/test/service_tracker_customizer_test.cpp 
b/framework/private/test/service_tracker_customizer_test.cpp
index be33867..7042182 100644
--- a/framework/private/test/service_tracker_customizer_test.cpp
+++ b/framework/private/test/service_tracker_customizer_test.cpp
@@ -30,7 +30,7 @@
 #include "CppUTest/TestHarness.h"
 #include "CppUTest/TestHarness_c.h"
 #include "CppUTest/CommandLineTestRunner.h"
-//#include "CppUTestExt/MockSupport.h"
+#include "CppUTestExt/MockSupport.h"
 
 extern "C"
 {
@@ -47,13 +47,11 @@ int main(int argc, char** argv) {
 
 TEST_GROUP(service_tracker_customizer) {
        void setup(void) {
-               logger = (framework_logger_pt) malloc(sizeof(*logger));
-        logger->logFunction = frameworkLogger_log;
        }
 
        void teardown() {
-//             mock().checkExpectations();
-//             mock().clear();
+               mock().checkExpectations();
+               mock().clear();
        }
 };
 
@@ -88,9 +86,13 @@ TEST(service_tracker_customizer, create) {
        POINTERS_EQUAL(serviceTrackerCustomizerTest_addedService, 
customizer->addedService);
        POINTERS_EQUAL(serviceTrackerCustomizerTest_modifiedService, 
customizer->modifiedService);
        POINTERS_EQUAL(serviceTrackerCustomizerTest_removedService, 
customizer->removedService);
+
+       serviceTrackerCustomizer_destroy(customizer);
 }
 
 TEST(service_tracker_customizer, createIllegalArgument) {
+       mock().expectOneCall("framework_logCode").withParameter("code", 
CELIX_ILLEGAL_ARGUMENT);
+
        void *handle = (void *) 0x10;
        service_tracker_customizer_pt customizer = NULL;
        celix_status_t status = serviceTrackerCustomizer_create(
@@ -112,6 +114,8 @@ TEST(service_tracker_customizer, getHandle) {
        celix_status_t status = serviceTrackerCustomizer_getHandle(customizer, 
&getHandle);
        LONGS_EQUAL(CELIX_SUCCESS, status);
        POINTERS_EQUAL(handle, getHandle);
+
+       free(customizer);
 }
 
 TEST(service_tracker_customizer, getAddingFunction) {
@@ -123,6 +127,8 @@ TEST(service_tracker_customizer, getAddingFunction) {
        celix_status_t status = 
serviceTrackerCustomizer_getAddingFunction(customizer, &getAdding);
        LONGS_EQUAL(CELIX_SUCCESS, status);
        POINTERS_EQUAL(adding, getAdding);
+
+       free(customizer);
 }
 
 TEST(service_tracker_customizer, getAddedFunction) {
@@ -134,6 +140,8 @@ TEST(service_tracker_customizer, getAddedFunction) {
        celix_status_t status = 
serviceTrackerCustomizer_getAddedFunction(customizer, &getAdded);
        LONGS_EQUAL(CELIX_SUCCESS, status);
        POINTERS_EQUAL(added, getAdded);
+
+       free(customizer);
 }
 
 TEST(service_tracker_customizer, getModifiedFunction) {
@@ -145,6 +153,8 @@ TEST(service_tracker_customizer, getModifiedFunction) {
        celix_status_t status = 
serviceTrackerCustomizer_getModifiedFunction(customizer, &getModified);
        LONGS_EQUAL(CELIX_SUCCESS, status);
        POINTERS_EQUAL(modified, getModified);
+
+       free(customizer);
 }
 
 TEST(service_tracker_customizer, getRemovedFunction) {
@@ -156,5 +166,7 @@ TEST(service_tracker_customizer, getRemovedFunction) {
        celix_status_t status = 
serviceTrackerCustomizer_getRemovedFunction(customizer, &getRemoved);
        LONGS_EQUAL(CELIX_SUCCESS, status);
        POINTERS_EQUAL(removed, getRemoved);
+
+       free(customizer);
 }
 

http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/test/service_tracker_test.cpp
----------------------------------------------------------------------
diff --git a/framework/private/test/service_tracker_test.cpp 
b/framework/private/test/service_tracker_test.cpp
index e3a7911..06c268e 100644
--- a/framework/private/test/service_tracker_test.cpp
+++ b/framework/private/test/service_tracker_test.cpp
@@ -37,7 +37,7 @@ extern "C"
 #include "service_reference_private.h"
 #include "celix_log.h"
 
-framework_logger_pt logger;
+framework_logger_pt logger = (framework_logger_pt) 0x42;
 }
 
 int main(int argc, char** argv) {
@@ -46,8 +46,6 @@ int main(int argc, char** argv) {
 
 TEST_GROUP(service_tracker) {
        void setup(void) {
-               logger = (framework_logger_pt) malloc(sizeof(*logger));
-        logger->logFunction = frameworkLogger_log;
        }
 
        void teardown() {
@@ -69,6 +67,8 @@ TEST(service_tracker, create) {
        POINTERS_EQUAL(NULL, tracker->listener);
        POINTERS_EQUAL(tracker, tracker->tracker);
        STRCMP_EQUAL("(objectClass=service)", tracker->filter);
+
+       serviceTracker_destroy(tracker);
 }
 
 TEST(service_tracker, createWithFilter) {
@@ -84,6 +84,8 @@ TEST(service_tracker, createWithFilter) {
        POINTERS_EQUAL(NULL, tracker->listener);
        POINTERS_EQUAL(tracker, tracker->tracker);
        STRCMP_EQUAL("(objectClass=test)", tracker->filter);
+
+       serviceTracker_destroy(tracker);
 }
 
 TEST(service_tracker, destroy) {
@@ -92,7 +94,7 @@ TEST(service_tracker, destroy) {
        bundle_context_pt ctx = (bundle_context_pt) 0x123;
        std::string filter = "(objectClass=test)";
        status = serviceTracker_createWithFilter(ctx, (char *) filter.c_str(), 
NULL, &tracker);
-       service_listener_pt listener = (service_listener_pt) 0x20;
+       service_listener_pt listener = (service_listener_pt) calloc(1, 
sizeof(serviceListener));
        tracker->listener = listener;
 
        mock()
@@ -139,6 +141,11 @@ TEST(service_tracker, open) {
 
        // No services should be found
        LONGS_EQUAL(0, arrayList_size(tracker->tracked));
+
+       arrayList_destroy(tracked);
+
+       free(tracker->listener);
+       free(tracker);
 }
 
 TEST(service_tracker, open_withRefs) {
@@ -197,6 +204,13 @@ TEST(service_tracker, open_withRefs) {
 
        // One service should be found
        LONGS_EQUAL(1, arrayList_size(tracker->tracked));
+
+       free(arrayList_get(tracked, 0));
+       arrayList_destroy(tracked);
+
+       free(tracker->listener);
+       free(tracker);
+       free(ref);
 }
 
 TEST(service_tracker, open_withRefsAndTracked) {
@@ -238,18 +252,27 @@ TEST(service_tracker, open_withRefsAndTracked) {
                .withParameter("filter", "(objectClass=service)")
                .ignoreOtherParameters()
                .andReturnValue(CELIX_SUCCESS);
+
        bool equal = true;
        mock()
                .expectOneCall("serviceReference_equals")
                .withParameter("reference", ref)
+               .withParameter("compareTo", ref)
                .withOutputParameterReturning("equal", &equal, sizeof(equal))
-               .ignoreOtherParameters()
+               //.ignoreOtherParameters()
                .andReturnValue(CELIX_SUCCESS);
+
        serviceTracker_open(tracker);
        CHECK(tracker->listener != NULL);
 
        // One service should be found
        LONGS_EQUAL(1, arrayList_size(tracker->tracked));
+
+       arrayList_destroy(tracked);
+
+       free(tracker->listener);
+       free(tracker);
+       free(entry);
 }
 
 TEST(service_tracker, close) {
@@ -292,7 +315,16 @@ TEST(service_tracker, close) {
                .withOutputParameterReturning("result", &result, sizeof(result))
                .andReturnValue(CELIX_SUCCESS);
 
+       mock()
+               .expectOneCall("bundleContext_ungetServiceReference")
+               .withParameter("context", ctx)
+               .withParameter("reference", ref)
+               .andReturnValue(CELIX_SUCCESS);
+
        serviceTracker_close(tracker);
+
+       arrayList_destroy(tracked);
+       free(tracker);
 }
 
 TEST(service_tracker, getServiceReference) {
@@ -316,6 +348,12 @@ TEST(service_tracker, getServiceReference) {
 
        service_reference_pt reference = 
serviceTracker_getServiceReference(tracker);
        POINTERS_EQUAL(ref, reference);
+
+       arrayList_destroy(tracked);
+
+       free(tracker);
+       free(entry);
+       free(entry2);
 }
 
 TEST(service_tracker, getServiceReferenceNull) {
@@ -328,6 +366,9 @@ TEST(service_tracker, getServiceReferenceNull) {
 
        service_reference_pt reference = 
serviceTracker_getServiceReference(tracker);
        POINTERS_EQUAL(NULL, reference);
+
+       arrayList_destroy(tracked);
+       free(tracker);
 }
 
 TEST(service_tracker, getServiceReferences) {
@@ -353,6 +394,13 @@ TEST(service_tracker, getServiceReferences) {
        LONGS_EQUAL(2, arrayList_size(references));
        POINTERS_EQUAL(ref, arrayList_get(references, 0));
        POINTERS_EQUAL(ref2, arrayList_get(references, 1));
+
+       arrayList_destroy(references);
+       arrayList_destroy(tracked);
+
+       free(tracker);
+       free(entry);
+       free(entry2);
 }
 
 TEST(service_tracker, getService) {
@@ -376,6 +424,12 @@ TEST(service_tracker, getService) {
 
        void *service = serviceTracker_getService(tracker);
        POINTERS_EQUAL(0x31, service);
+
+       arrayList_destroy(tracked);
+
+       free(entry);
+       free(entry2);
+       free(tracker);
 }
 
 TEST(service_tracker, getServiceNull) {
@@ -388,6 +442,9 @@ TEST(service_tracker, getServiceNull) {
 
        void *service = serviceTracker_getService(tracker);
        POINTERS_EQUAL(NULL, service);
+
+       arrayList_destroy(tracked);
+       free(tracker);
 }
 
 TEST(service_tracker, getServices) {
@@ -413,6 +470,13 @@ TEST(service_tracker, getServices) {
        LONGS_EQUAL(2, arrayList_size(services));
        POINTERS_EQUAL(0x31, arrayList_get(services, 0));
        POINTERS_EQUAL(0x32, arrayList_get(services, 1));
+
+       arrayList_destroy(services);
+       arrayList_destroy(tracked);
+
+       free(entry);
+       free(entry2);
+       free(tracker);
 }
 
 TEST(service_tracker, getServiceByReference) {
@@ -433,12 +497,17 @@ TEST(service_tracker, getServiceByReference) {
        mock()
                .expectOneCall("serviceReference_equals")
                .withParameter("reference", ref)
+               .withParameter("compareTo", ref)
                .withOutputParameterReturning("equal", &equal, sizeof(equal))
-               .ignoreOtherParameters()
-               .andReturnValue(4)
-               .withCallOrder(1);
+               .andReturnValue(4);
+               //.ignoreOtherParameters();
        void *service = serviceTracker_getServiceByReference(tracker, ref);
        POINTERS_EQUAL(0x31, service);
+
+       arrayList_destroy(tracked);
+
+       free(tracker);
+       free(entry);
 }
 
 TEST(service_tracker, getServiceByReferenceNull) {
@@ -465,6 +534,11 @@ TEST(service_tracker, getServiceByReferenceNull) {
                .withCallOrder(1);
        void *service = serviceTracker_getServiceByReference(tracker, ref);
        POINTERS_EQUAL(NULL, service);
+
+       arrayList_destroy(tracked);
+
+       free(tracker);
+       free(entry);
 }
 
 TEST(service_tracker, serviceChangedRegistered) {
@@ -495,6 +569,13 @@ TEST(service_tracker, serviceChangedRegistered) {
                .withOutputParameterReturning("service_instance", &src, 
sizeof(src))
                .andReturnValue(CELIX_SUCCESS);
        serviceTracker_serviceChanged(listener, event);
+
+       free(arrayList_get(tracked, 0));
+       arrayList_destroy(tracked);
+
+       free(event);
+       free(tracker);
+       free(listener);
 }
 
 TEST(service_tracker, serviceChangedModified) {
@@ -530,7 +611,22 @@ TEST(service_tracker, serviceChangedModified) {
                .withOutputParameterReturning("equal", &equal, sizeof(equal))
                .ignoreOtherParameters()
                .andReturnValue(CELIX_SUCCESS);
+
+       mock()
+                       .expectOneCall("bundleContext_getService")
+                       .withParameter("context", ctx)
+                       .withParameter("reference", ref)
+                       .withOutputParameterReturning("service_instance", 
&entry->service, sizeof(entry->service));
+
        serviceTracker_serviceChanged(listener, event);
+
+       free(arrayList_get(tracked, 0));
+       free(arrayList_get(tracked, 1));
+       arrayList_destroy(tracked);
+
+       free(event);
+       free(listener);
+       free(tracker);
 }
 
 TEST(service_tracker, serviceChangedUnregistering) {
@@ -573,7 +669,20 @@ TEST(service_tracker, serviceChangedUnregistering) {
                .withParameter("reference", ref)
                .withOutputParameterReturning("result", &result, sizeof(result))
                .andReturnValue(CELIX_SUCCESS);
+
+       mock()
+               .expectOneCall("bundleContext_ungetServiceReference")
+               .withParameter("context", ctx)
+               .withParameter("reference", ref)
+               .andReturnValue(CELIX_SUCCESS);
+
        serviceTracker_serviceChanged(listener, event);
+
+       arrayList_destroy(tracked);
+
+       free(listener);
+       free(event);
+       free(tracker);
 }
 
 TEST(service_tracker, serviceChangedModifiedEndmatch) {
@@ -602,6 +711,13 @@ TEST(service_tracker, serviceChangedModifiedEndmatch) {
        event->reference = ref;
 
        serviceTracker_serviceChanged(listener, event);
+
+       arrayList_destroy(tracked);
+
+       free(entry);
+       free(listener);
+       free(tracker);
+       free(event);
 }
 
 extern "C" {
@@ -661,6 +777,13 @@ TEST(service_tracker, serviceChangedRegisteredCustomizer) {
                .withOutputParameterReturning("function", &function2, 
sizeof(function))
                .andReturnValue(CELIX_SUCCESS);
        serviceTracker_serviceChanged(listener, event);
+
+       free(arrayList_get(tracked, 0));
+       arrayList_destroy(tracked);
+
+       free(event);
+       free(tracker);
+       free(listener);
 }
 
 
@@ -681,6 +804,8 @@ TEST(service_tracker, serviceChangedModifiedCustomizer) {
        listener->handle = tracker;
        service_tracker_customizer_pt customizer = 
(service_tracker_customizer_pt) 0x20;
        tracker->customizer = customizer;
+       adding_callback_pt adding_func = NULL;
+       added_callback_pt added_func = NULL;
 
        // new tracker->tracked
        array_list_pt tracked = NULL;
@@ -706,17 +831,45 @@ TEST(service_tracker, serviceChangedModifiedCustomizer) {
                .andReturnValue(CELIX_SUCCESS);
        void * handle = (void*) 0x60;
        mock()
-               .expectOneCall("serviceTrackerCustomizer_getHandle")
+               .expectNCalls(2, "serviceTrackerCustomizer_getHandle")
                .withParameter("customizer", customizer)
                .withOutputParameterReturning("handle", &handle, sizeof(handle))
                .andReturnValue(CELIX_SUCCESS);
        void *function = (void *) serviceDependency_modifiedService;
-       mock()
+/*     mock()
                .expectOneCall("serviceTrackerCustomizer_getModifiedFunction")
                .withParameter("customizer", customizer)
                .withOutputParameterReturning("function", &function, 
sizeof(function))
                .andReturnValue(CELIX_SUCCESS);
+*/
+       mock()
+               .expectOneCall("serviceTrackerCustomizer_getAddingFunction")
+               .withParameter("customizer", customizer)
+               .withOutputParameterReturning("function", &adding_func, 
sizeof(adding_func))
+               .andReturnValue(CELIX_SUCCESS);
+
+       mock()
+               .expectOneCall("serviceTrackerCustomizer_getAddedFunction")
+               .withParameter("customizer", customizer)
+               .withOutputParameterReturning("function", &added_func, 
sizeof(added_func));
+
+
+       mock()
+               .expectOneCall("bundleContext_getService")
+               .withParameter("context", ctx)
+               .withParameter("reference", ref)
+               .withOutputParameterReturning("service_instance", 
&entry->service, sizeof(entry->service));
+
+
        serviceTracker_serviceChanged(listener, event);
+
+       free(arrayList_get(tracked, 0));
+       free(arrayList_get(tracked, 1));
+       arrayList_destroy(tracked);
+
+       free(event);
+       free(listener);
+       free(tracker);
 }
 
 extern "C" {
@@ -771,7 +924,19 @@ TEST(service_tracker, 
serviceChangedUnregisteringCustomizer) {
                .withParameter("customizer", customizer)
                .withOutputParameterReturning("function", &function , 
sizeof(function))
                .andReturnValue(CELIX_SUCCESS);
+
+       mock()
+               .expectOneCall("bundleContext_ungetServiceReference")
+               .withParameter("context", ctx)
+               .withParameter("reference", ref)
+               .andReturnValue(CELIX_SUCCESS);
        serviceTracker_serviceChanged(listener, event);
+
+       arrayList_destroy(tracked);
+
+       free(listener);
+       free(event);
+       free(tracker);
 }
 
 TEST(service_tracker, serviceChangedUnregisteringCustomizerNoFunc) {
@@ -827,7 +992,19 @@ TEST(service_tracker, 
serviceChangedUnregisteringCustomizerNoFunc) {
                .withParameter("reference", ref)
                .withOutputParameterReturning("result", &result, sizeof(result))
                .andReturnValue(CELIX_SUCCESS);
+
+       mock()
+               .expectOneCall("bundleContext_ungetServiceReference")
+               .withParameter("context", ctx)
+               .withParameter("reference", ref)
+               .andReturnValue(CELIX_SUCCESS);
+
        serviceTracker_serviceChanged(listener, event);
+
+       arrayList_destroy(tracked);
+       free(listener);
+       free(tracker);
+       free(event);
 }
 
 

http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/test/utils_test.cpp
----------------------------------------------------------------------
diff --git a/framework/private/test/utils_test.cpp 
b/framework/private/test/utils_test.cpp
index 1dfbe9b..27d4a22 100644
--- a/framework/private/test/utils_test.cpp
+++ b/framework/private/test/utils_test.cpp
@@ -23,6 +23,10 @@
  *  \author     <a href="mailto:[email protected]";>Apache Celix Project 
Team</a>
  *  \copyright  Apache License, Version 2.0
  */
+#include "string.h"
+#include <stdlib.h>
+#include <string.h>
+
 #include "CppUTest/TestHarness.h"
 #include "CppUTest/TestHarness_c.h"
 #include "CppUTest/CommandLineTestRunner.h"
@@ -45,17 +49,36 @@ TEST_GROUP(utils) {
        }
 };
 
+static char* my_strdup(const char* s){
+       if(s==NULL){
+               return NULL;
+       }
+
+       size_t len = strlen(s);
+
+       char *d = (char*) calloc (len + 1,sizeof(char));
+
+       if (d == NULL){
+               return NULL;
+       }
+
+       strncpy (d,s,len);
+       return d;
+}
+
 TEST(utils, stringHash) {
-       std::string toHash = "abc";
+       char * toHash = my_strdup("abc");
        unsigned int hash;
-       hash = utils_stringHash((void *) toHash.c_str());
+       hash = utils_stringHash((void *) toHash);
        LONGS_EQUAL(446371745, hash);
 
-       toHash = "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz";
-       hash = utils_stringHash((void *) toHash.c_str());
+       free(toHash);
+       toHash = 
my_strdup("abc123def456ghi789jkl012mno345pqr678stu901vwx234yz");
+       hash = utils_stringHash((void *) toHash);
        LONGS_EQUAL(1508668412, hash);
 
-       toHash = "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+       free(toHash);
+       toHash = my_strdup("abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
                        "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
                        "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
                        "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
@@ -76,34 +99,40 @@ TEST(utils, stringHash) {
                        "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
                        "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
                        "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
-                       "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz";
-       hash = utils_stringHash((void *) toHash.c_str());
+                       "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz");
+       hash = utils_stringHash((void *) toHash);
        LONGS_EQUAL(829630780, hash);
+       free(toHash);
 }
 
 TEST(utils, stringEquals) {
        // Compare with equal strings
-       std::string org = "abc";
-       std::string cmp = "abc";
+       char * org = my_strdup("abc");
+       char * cmp = my_strdup("abc");
 
-       int result = utils_stringEquals((void *) org.c_str(), (void *) 
cmp.c_str());
+       int result = utils_stringEquals((void *) org, (void *) cmp);
        CHECK(result);
 
        // Compare with no equal strings
-       cmp = "abcd";
+       free(cmp);
+       cmp = my_strdup("abcd");
 
-       result = utils_stringEquals((void *) org.c_str(), (void *) cmp.c_str());
-       CHECK(!result);
+       result = utils_stringEquals((void *) org, (void *) cmp);
+       CHECK_FALSE(result);
 
        // Compare with numeric strings
-       org = "123";
-       cmp = "123";
+       free(org);
+       free(cmp);
+       org = my_strdup("123");
+       cmp = my_strdup("123");
 
-       result = utils_stringEquals((void *) org.c_str(), (void *) cmp.c_str());
+       result = utils_stringEquals((void *) org, (void *) cmp);
        CHECK(result);
 
        // Compare with long strings
-       org = "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+       free(org);
+       free(cmp);
+       org = my_strdup("abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
                        "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
                        "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
                        "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
@@ -124,8 +153,8 @@ TEST(utils, stringEquals) {
                        "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
                        "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
                        "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
-                       "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz";
-       cmp = "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+                       "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz");
+       cmp = my_strdup("abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
                        "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
                        "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
                        "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
@@ -146,58 +175,101 @@ TEST(utils, stringEquals) {
                        "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
                        "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
                        "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
-                       "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz";
+                       "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz");
 
-       result = utils_stringEquals((void *) org.c_str(), (void *) cmp.c_str());
+       result = utils_stringEquals((void *) org, (void *) cmp);
        CHECK(result);
+
+       free(org);
+       free(cmp);
+}
+
+TEST(utils, string_ndup){
+       // Compare with equal strings
+       const char * org = "abc";
+       char * cmp = NULL;
+
+       cmp = string_ndup(org, 3);
+       STRCMP_EQUAL(org, cmp);
+       free(cmp);
+
+       org = "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz";
+       cmp = string_ndup(org, 50);
+       STRCMP_EQUAL(org, cmp);
+       free(cmp);
+
+       cmp = string_ndup(org, 25);
+       LONGS_EQUAL(25, strlen(cmp));
+       free(cmp);
 }
 
 TEST(utils, stringTrim) {
        // Multiple whitespaces, before, after and in between
-       std::string toTrim = " a b c ";
-       char *result = utils_stringTrim((char*) toTrim.c_str());
+       char * toTrim = my_strdup(" a b c ");
+       char * result = utils_stringTrim(toTrim);
 
        STRCMP_EQUAL("a b c", result);
 
        // No whitespaces
-       toTrim = "abc";
-       result = utils_stringTrim((char*) toTrim.c_str());
+       free(toTrim);
+       toTrim = my_strdup("abc");
+       result = utils_stringTrim(toTrim);
 
        STRCMP_EQUAL("abc", result);
 
        // Only whitespace before
-       toTrim = "               abc";
-       result = utils_stringTrim((char*) toTrim.c_str());
+       free(toTrim);
+       toTrim = my_strdup("               abc");
+       result = utils_stringTrim(toTrim);
 
        STRCMP_EQUAL("abc", result);
 
        // Only whitespace after
-       toTrim = "abc         ";
-       result = utils_stringTrim((char*) toTrim.c_str());
+       free(toTrim);
+       toTrim = my_strdup("abc         ");
+       result = utils_stringTrim(toTrim);
 
        STRCMP_EQUAL("abc", result);
 
        // Whitespace other then space (tab, cr..).
-       toTrim = "\tabc  \n asdf  \n";
-       result = utils_stringTrim((char*) toTrim.c_str());
+       free(toTrim);
+       toTrim = my_strdup("\tabc  \n asdf  \n");
+       result = utils_stringTrim(toTrim);
 
        STRCMP_EQUAL("abc  \n asdf", result);
+
+       free(toTrim);
+}
+
+TEST(utils, thread_equalsSelf){
+       celix_thread thread = celixThread_self();
+       bool get;
+
+       LONGS_EQUAL(CELIX_SUCCESS, thread_equalsSelf(thread, &get));
+       CHECK(get);
+
+       thread.thread = (pthread_t) 0x42;
+       LONGS_EQUAL(CELIX_SUCCESS, thread_equalsSelf(thread, &get));
+       CHECK_FALSE(get);
 }
 
 TEST(utils, isNumeric) {
        // Check numeric string
-       std::string toCheck = "42";
+       char * toCheck = my_strdup("42");
 
        bool result;
-       celix_status_t status = utils_isNumeric((char *) toCheck.c_str(), 
&result);
+       celix_status_t status = utils_isNumeric(toCheck, &result);
        LONGS_EQUAL(CELIX_SUCCESS, status);
        CHECK_C(result);
 
        // Check non numeric string
-       toCheck = "42b";
-       status = utils_isNumeric((char *) toCheck.c_str(), &result);
+       free(toCheck);
+       toCheck = my_strdup("42b");
+       status = utils_isNumeric(toCheck, &result);
        LONGS_EQUAL(CELIX_SUCCESS, status);
        CHECK_C(!result);
+
+       free(toCheck);
 }
 
 

http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/test/version_range_test.cpp
----------------------------------------------------------------------
diff --git a/framework/private/test/version_range_test.cpp 
b/framework/private/test/version_range_test.cpp
index 5970d6d..95bf1b1 100644
--- a/framework/private/test/version_range_test.cpp
+++ b/framework/private/test/version_range_test.cpp
@@ -28,26 +28,44 @@
 #include "CppUTest/TestHarness_c.h"
 #include "CppUTest/CommandLineTestRunner.h"
 #include "CppUTestExt/MockSupport.h"
+#include "string.h"
 
 extern "C"
 {
-       #include "version_range_private.h"
-       #include "version_private.h"
+#include "version_range_private.h"
+#include "version_private.h"
 
-    #include "celix_log.h"
+#include "celix_log.h"
 
-    framework_logger_pt logger;
+framework_logger_pt logger = (framework_logger_pt) 0x42;
 }
 
 int main(int argc, char** argv) {
        return RUN_ALL_TESTS(argc, argv);
 }
 
+static char* my_strdup(const char* s) {
+       if (s == NULL) {
+               return NULL;
+       }
+
+       size_t len = strlen(s);
+
+       char *d = (char*) calloc(len + 1, sizeof(char));
+
+       if (d == NULL) {
+               return NULL;
+       }
+
+       strncpy(d, s, len);
+       return d;
+}
+
+//----------------------TESTGROUP DEFINES----------------------
+
 TEST_GROUP(version_range) {
 
        void setup(void) {
-               logger = (framework_logger_pt) malloc(sizeof(*logger));
-        logger->logFunction = frameworkLogger_log;
        }
 
        void teardown() {
@@ -68,6 +86,11 @@ TEST(version_range, create) {
        LONGS_EQUAL(false, range->isLowInclusive);
        POINTERS_EQUAL(version, range->low);
        POINTERS_EQUAL(version, range->high);
+
+       mock().expectNCalls(2, "version_destroy");
+
+       versionRange_destroy(range);
+       free(version);
 }
 
 TEST(version_range, createInfinite) {
@@ -79,8 +102,8 @@ TEST(version_range, createInfinite) {
        version->micro = 3;
 
        mock()
-               .expectOneCall("version_createEmptyVersion")
-               .withOutputParameterReturning("version", &version, 
sizeof("version"));
+       .expectOneCall("version_createEmptyVersion")
+       .withOutputParameterReturning("version", &version, sizeof("version"));
        status = versionRange_createInfiniteVersionRange(&range);
        LONGS_EQUAL(CELIX_SUCCESS, status);
        CHECK_C(range != NULL);
@@ -88,10 +111,16 @@ TEST(version_range, createInfinite) {
        LONGS_EQUAL(true, range->isLowInclusive);
        POINTERS_EQUAL(version, range->low);
        POINTERS_EQUAL(NULL, range->high);
+
+       mock().expectOneCall("version_destroy");
+
+       versionRange_destroy(range);
+       free(version);
 }
 
 TEST(version_range, isInRange) {
        celix_status_t status = CELIX_SUCCESS;
+       bool result;
        version_range_pt range = NULL;
        version_pt version = (version_pt) malloc(sizeof(*version));
        version->major = 1;
@@ -108,56 +137,95 @@ TEST(version_range, isInRange) {
        high->minor = 2;
        high->micro = 3;
 
-       versionRange_createVersionRange(low, true, high, true, &range);
-
        int stat = 1;
        mock()
-               .expectOneCall("version_compareTo")
-               .withParameter("version", version)
-               .withParameter("compare", low)
-           .withOutputParameterReturning("result", &stat, sizeof(int));
+       .expectNCalls(5, "version_compareTo")
+       .withParameter("version", version)
+       .withParameter("compare", low)
+       .withOutputParameterReturning("result", &stat, sizeof(int));
        int stat2 = -1;
        mock()
-               .expectOneCall("version_compareTo")
-               .withParameter("version", version)
-               .withParameter("compare", high)
-               .withOutputParameterReturning("result", &stat2, sizeof(int));
+       .expectNCalls(4, "version_compareTo")
+       .withParameter("version", version)
+       .withParameter("compare", high)
+       .withOutputParameterReturning("result", &stat2, sizeof(int));
 
-       bool result;
-       status = versionRange_isInRange(range, version, &result);
-       LONGS_EQUAL(CELIX_SUCCESS, status);
+       versionRange_createVersionRange(low, true, high, true, &range);
+       LONGS_EQUAL(CELIX_SUCCESS, versionRange_isInRange(range, version, 
&result));
+       LONGS_EQUAL(true, result);
+       mock().expectNCalls(2, "version_destroy");
+       versionRange_destroy(range);
+
+       versionRange_createVersionRange(low, true, NULL, true, &range);
+       LONGS_EQUAL(CELIX_SUCCESS, versionRange_isInRange(range, version, 
&result));
+       LONGS_EQUAL(true, result);
+       mock().expectOneCall("version_destroy");
+       versionRange_destroy(range);
+
+       versionRange_createVersionRange(low, false, high, true, &range);
+       LONGS_EQUAL(CELIX_SUCCESS, versionRange_isInRange(range, version, 
&result));
        LONGS_EQUAL(true, result);
+       mock().expectNCalls(2, "version_destroy");
+       versionRange_destroy(range);
+
+       versionRange_createVersionRange(low, true, high, false, &range);
+       LONGS_EQUAL(CELIX_SUCCESS, versionRange_isInRange(range, version, 
&result));
+       LONGS_EQUAL(true, result);
+       mock().expectNCalls(2, "version_destroy");
+       versionRange_destroy(range);
+
+       versionRange_createVersionRange(low, false, high, false, &range);
+       LONGS_EQUAL(CELIX_SUCCESS, versionRange_isInRange(range, version, 
&result));
+       LONGS_EQUAL(true, result);
+       mock().expectNCalls(2, "version_destroy");
+       versionRange_destroy(range);
+
+       free(version);
+       free(high);
+       free(low);
 }
 
-// This test fails due to ordering of expected calls.
-//TEST(version_range, parse) {
-//     celix_status_t status = CELIX_SUCCESS;
-//     version_range_pt range = NULL;
-//     version_pt low = (version_pt) malloc(sizeof(*low));
-//     version_pt high = (version_pt) malloc(sizeof(*high));
-//
-//     low->major = 1;
-//     low->minor = 2;
-//     low->micro = 3;
-//
-//     high->major = 7;
-//     high->minor = 8;
-//     high->micro = 9;
-//
-//     mock().strictOrder();
-//     mock()
-//             .expectOneCall("version_createVersionFromString")
-//             .withParameter("versionStr", "7.8.9")
-//             .withOutputParameterReturning("version", &high, sizeof(high));
-//     mock()
-//        .expectOneCall("version_createVersionFromString")
-//        .withParameter("versionStr", "1.2.3")
-//        .withOutputParameterReturning("version", &low, sizeof(low));
-//
-//     std::string version = "[1.2.3, 7.8.9]";
-//     status = versionRange_parse((char *) version.c_str(), &range);
-//     LONGS_EQUAL(CELIX_SUCCESS, status);
-//}
+TEST(version_range, parse) {
+       celix_status_t status = CELIX_SUCCESS;
+       version_range_pt range = NULL;
+       version_pt low = (version_pt) malloc(sizeof(*low));
+       version_pt high = (version_pt) malloc(sizeof(*high));
+       char * version = my_strdup("[1.2.3,7.8.9]");
+       low->major = 1;
+       low->minor = 2;
+       low->micro = 3;
+
+       high->major = 7;
+       high->minor = 8;
+       high->micro = 9;
+
+       mock().expectNCalls(3, "version_destroy");
+
+       mock().expectOneCall("version_createVersionFromString")
+                  .withParameter("versionStr", "1.2.3")
+                  .withOutputParameterReturning("version", &low, sizeof(low));
+
+       mock().expectOneCall("version_createVersionFromString")
+                       .withParameter("versionStr", "7.8.9")
+                       .withOutputParameterReturning("version", &high, 
sizeof(high));
+
+       LONGS_EQUAL(CELIX_SUCCESS, versionRange_parse(version, &range));
+
+       versionRange_destroy(range);
+       free(version);
+       version = my_strdup("[1.2.3");
+
+       mock().expectOneCall("version_createVersionFromString")
+                       .withParameter("versionStr", "[1.2.3")
+                       .withOutputParameterReturning("version", &low, 
sizeof(low));
+
+       LONGS_EQUAL(CELIX_SUCCESS, versionRange_parse(version, &range));
+
+       versionRange_destroy(range);
+       free(version);
+       free(high);
+       free(low);
+}
 
 
 

http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/test/version_test.cpp
----------------------------------------------------------------------
diff --git a/framework/private/test/version_test.cpp 
b/framework/private/test/version_test.cpp
index 4740f28..51d734d 100644
--- a/framework/private/test/version_test.cpp
+++ b/framework/private/test/version_test.cpp
@@ -28,132 +28,169 @@
 #include "CppUTest/TestHarness.h"
 #include "CppUTest/TestHarness_c.h"
 #include "CppUTest/CommandLineTestRunner.h"
+#include "CppUTestExt/MockSupport.h"
 
 extern "C"
 {
 #include "version_private.h"
 #include "celix_log.h"
 
-framework_logger_pt logger;
+framework_logger_pt logger = (framework_logger_pt) 0x666;
 }
 
 int main(int argc, char** argv) {
        return RUN_ALL_TESTS(argc, argv);
 }
 
+static char* my_strdup(const char* s){
+       if(s==NULL){
+               return NULL;
+       }
+
+       size_t len = strlen(s);
+
+       char *d = (char*) calloc (len + 1,sizeof(char));
+
+       if (d == NULL){
+               return NULL;
+       }
+
+       strncpy (d,s,len);
+       return d;
+}
+
 TEST_GROUP(version) {
 
        void setup(void) {
-               logger = (framework_logger_pt) malloc(sizeof(*logger));
-        logger->logFunction = frameworkLogger_log;
        }
 
        void teardown() {
+               mock().checkExpectations();
+               mock().clear();
        }
 
 };
 
 
 TEST(version, create) {
+       mock().expectNCalls(2, "framework_logCode").withParameter("code", 
CELIX_ILLEGAL_ARGUMENT);
        version_pt version = NULL;
        celix_status_t status = CELIX_SUCCESS;
-       std::string str;
+       char * str;
 
-//     str = "abc";
-//     status = version_createVersion(1, 2, 3, strdup((const char *) 
str.c_str()), &version);
+//     str = my_strdup("abc");
+//     status = version_createVersion(1, 2, 3, str, &version);
 //     LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
 
-       str = "abc";
-       status = version_createVersion(1, 2, 3, strdup((const char *) 
str.c_str()), &version);
-       LONGS_EQUAL(CELIX_SUCCESS, status);
+       str = my_strdup("abc");
+       LONGS_EQUAL(CELIX_SUCCESS, version_createVersion(1, 2, 3, str, 
&version));
        CHECK_C(version != NULL);
     LONGS_EQUAL(1, version->major);
        LONGS_EQUAL(2, version->minor);
        LONGS_EQUAL(3, version->micro);
        STRCMP_EQUAL("abc", version->qualifier);
 
+       version_destroy(version);
        version = NULL;
-       status = version_createVersion(1, 2, 3, NULL, &version);
-       LONGS_EQUAL(CELIX_SUCCESS, status);
+       LONGS_EQUAL(CELIX_SUCCESS, version_createVersion(1, 2, 3, NULL, 
&version));
        CHECK_C(version != NULL);
        LONGS_EQUAL(1, version->major);
        LONGS_EQUAL(2, version->minor);
        LONGS_EQUAL(3, version->micro);
        STRCMP_EQUAL("", version->qualifier);
 
-       str = "abc";
-       status = version_createVersion(1, -2, 3, strdup((const char *) 
str.c_str()), &version);
-       LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
+       mock().expectNCalls(4, "framework_log").ignoreOtherParameters();
 
-       str = "abc|xyz";
-       status = version_createVersion(1, 2, 3, strdup((const char *) 
str.c_str()), &version);
-       LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
+       version_destroy(version);
+       version = NULL;
+       free(str);
+       str = my_strdup("abc");
+       LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, version_createVersion(-1, -2, -3, 
str, &version));
+
+       version_destroy(version);
+       version = NULL;
+       free(str);
+       str = my_strdup("abc|xyz");
+       LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, version_createVersion(1, 2, 3, str, 
&version));
+
+       version_destroy(version);
+       free(str);
 }
 
 TEST(version, clone) {
        version_pt version = NULL, clone = NULL;
        celix_status_t status = CELIX_SUCCESS;
-       std::string str;
+       char * str;
 
-       str = "abc";
-       status = version_createVersion(1, 2, 3, strdup((const char *) 
str.c_str()), &version);
-       LONGS_EQUAL(CELIX_SUCCESS, status);
-       status = version_clone(version, &clone);
-       LONGS_EQUAL(CELIX_SUCCESS, status);
+       str = my_strdup("abc");
+       LONGS_EQUAL(CELIX_SUCCESS, version_createVersion(1, 2, 3, str, 
&version));
+       LONGS_EQUAL(CELIX_SUCCESS, version_clone(version, &clone));
        CHECK_C(version != NULL);
     LONGS_EQUAL(1, clone->major);
        LONGS_EQUAL(2, clone->minor);
        LONGS_EQUAL(3, clone->micro);
        STRCMP_EQUAL("abc", clone->qualifier);
+
+       version_destroy(clone);
+       version_destroy(version);
+       free(str);
 }
 
 TEST(version, createFromString) {
+       mock().expectNCalls(6, "framework_logCode").withParameter("code", 
CELIX_ILLEGAL_ARGUMENT);
        version_pt version = NULL;
        celix_status_t status = CELIX_SUCCESS;
-       std::string str;
+       char * str;
 
-       str = "1";
-       status = version_createVersionFromString(strdup((const char *) 
str.c_str()), &version);
-       LONGS_EQUAL(CELIX_SUCCESS, status);
+       str = my_strdup("1");
+       LONGS_EQUAL(CELIX_SUCCESS, version_createVersionFromString(str, 
&version));
        CHECK_C(version != NULL);
        LONGS_EQUAL(1, version->major);
 
-       str = "a";
-       status = version_createVersionFromString(strdup((const char *) 
str.c_str()), &version);
-       LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
+       version_destroy(version);
+       mock().expectNCalls(4, "framework_log");
 
-       str = "1.a";
-       status = version_createVersionFromString(strdup((const char *) 
str.c_str()), &version);
-       LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
+       free(str);
+       str = my_strdup("a");
+       LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, 
version_createVersionFromString(str, &version));
 
-       str = "1.1.a";
-       status = version_createVersionFromString(strdup((const char *) 
str.c_str()), &version);
-       LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
+       free(str);
+       str = my_strdup("1.a");
+       LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, 
version_createVersionFromString(str, &version));
 
-       str = "-1";
-       status = version_createVersionFromString(strdup((const char *) 
str.c_str()), &version);
-       LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
+       free(str);
+       str = my_strdup("1.1.a");
+       LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, 
version_createVersionFromString(str, &version));
 
-       str = "1.2";
+       free(str);
+       str = my_strdup("-1");
+       LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, 
version_createVersionFromString(str, &version));
+
+       free(str);
+       str = my_strdup("1.2");
        version = NULL;
-       status = version_createVersionFromString(strdup((const char *) 
str.c_str()), &version);
-       LONGS_EQUAL(CELIX_SUCCESS, status);
+       LONGS_EQUAL(CELIX_SUCCESS, version_createVersionFromString(str, 
&version));
        CHECK_C(version != NULL);
        LONGS_EQUAL(1, version->major);
        LONGS_EQUAL(2, version->minor);
 
-       str = "1.2.3";
+       version_destroy(version);
+
+       free(str);
+       str = my_strdup("1.2.3");
        version = NULL;
-       status = version_createVersionFromString(strdup((const char *) 
str.c_str()), &version);
+       status = version_createVersionFromString(str, &version);
        LONGS_EQUAL(CELIX_SUCCESS, status);
        CHECK_C(version != NULL);
        LONGS_EQUAL(1, version->major);
        LONGS_EQUAL(2, version->minor);
        LONGS_EQUAL(3, version->micro);
 
-       str = "1.2.3.abc";
+       version_destroy(version);
+       free(str);
+       str = my_strdup("1.2.3.abc");
        version = NULL;
-       status = version_createVersionFromString(strdup((const char *) 
str.c_str()), &version);
+       status = version_createVersionFromString(str, &version);
        LONGS_EQUAL(CELIX_SUCCESS, status);
        CHECK_C(version != NULL);
     LONGS_EQUAL(1, version->major);
@@ -161,9 +198,11 @@ TEST(version, createFromString) {
        LONGS_EQUAL(3, version->micro);
        STRCMP_EQUAL("abc", version->qualifier);
 
-       str = "1.2.3.abc_xyz";
+       version_destroy(version);
+       free(str);
+       str = my_strdup("1.2.3.abc_xyz");
        version = NULL;
-       status = version_createVersionFromString(strdup((const char *) 
str.c_str()), &version);
+       status = version_createVersionFromString(str, &version);
        LONGS_EQUAL(CELIX_SUCCESS, status);
        CHECK_C(version != NULL);
     LONGS_EQUAL(1, version->major);
@@ -171,9 +210,11 @@ TEST(version, createFromString) {
        LONGS_EQUAL(3, version->micro);
        STRCMP_EQUAL("abc_xyz", version->qualifier);
 
-       str = "1.2.3.abc-xyz";
+       version_destroy(version);
+       free(str);
+       str = my_strdup("1.2.3.abc-xyz");
        version = NULL;
-       status = version_createVersionFromString(strdup((const char *) 
str.c_str()), &version);
+       status = version_createVersionFromString(str, &version);
        LONGS_EQUAL(CELIX_SUCCESS, status);
        CHECK_C(version != NULL);
     LONGS_EQUAL(1, version->major);
@@ -181,9 +222,13 @@ TEST(version, createFromString) {
        LONGS_EQUAL(3, version->micro);
        STRCMP_EQUAL("abc-xyz", version->qualifier);
 
-       str = "1.2.3.abc|xyz";
-       status = version_createVersionFromString(strdup((const char *) 
str.c_str()), &version);
+       version_destroy(version);
+       free(str);
+       str = my_strdup("1.2.3.abc|xyz");
+       status = version_createVersionFromString(str, &version);
        LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
+
+       free(str);
 }
 
 TEST(version, createEmptyVersion) {
@@ -197,17 +242,19 @@ TEST(version, createEmptyVersion) {
        LONGS_EQUAL(0, version->minor);
        LONGS_EQUAL(0, version->micro);
        STRCMP_EQUAL("", version->qualifier);
+
+       version_destroy(version);
 }
 
 TEST(version, getters) {
        version_pt version = NULL;
        celix_status_t status = CELIX_SUCCESS;
-       std::string str;
+       char * str;
        int major, minor, micro;
        char *qualifier;
 
-       str = "abc";
-       status = version_createVersion(1, 2, 3, strdup((const char *) 
str.c_str()), &version);
+       str = my_strdup("abc");
+       status = version_createVersion(1, 2, 3, str, &version);
        LONGS_EQUAL(CELIX_SUCCESS, status);
        CHECK_C(version != NULL);
 
@@ -222,24 +269,28 @@ TEST(version, getters) {
 
        version_getQualifier(version, &qualifier);
        STRCMP_EQUAL("abc", qualifier);
+
+       version_destroy(version);
+       free(str);
 }
 
 TEST(version, compare) {
        version_pt version = NULL, compare = NULL;
        celix_status_t status = CELIX_SUCCESS;
-       std::string str;
+       char * str;
        int result;
 
        // Base version to compare
-       str = "abc";
-       status = version_createVersion(1, 2, 3, strdup((const char *) 
str.c_str()), &version);
+       str = my_strdup("abc");
+       status = version_createVersion(1, 2, 3, str, &version);
        LONGS_EQUAL(CELIX_SUCCESS, status);
        CHECK_C(version != NULL);
 
        // Compare equality
-       str = "abc";
+       free(str);
+       str = my_strdup("abc");
        compare = NULL;
-       status = version_createVersion(1, 2, 3, strdup((const char *) 
str.c_str()), &compare);
+       status = version_createVersion(1, 2, 3, str, &compare);
        LONGS_EQUAL(CELIX_SUCCESS, status);
        CHECK_C(version != NULL);
        status = version_compareTo(version, compare, &result);
@@ -247,9 +298,11 @@ TEST(version, compare) {
        LONGS_EQUAL(0, result);
 
        // Compare against a higher version
-       str = "bcd";
+       free(str);
+       str = my_strdup("bcd");
+       version_destroy(compare);
        compare = NULL;
-       status = version_createVersion(1, 2, 3, strdup((const char *) 
str.c_str()), &compare);
+       status = version_createVersion(1, 2, 3, str, &compare);
        LONGS_EQUAL(CELIX_SUCCESS, status);
        CHECK_C(version != NULL);
        status = version_compareTo(version, compare, &result);
@@ -257,24 +310,30 @@ TEST(version, compare) {
        CHECK(result < 0);
 
        // Compare againts a lower version
-       str = "abc";
+       free(str);
+       str = my_strdup("abc");
+       version_destroy(compare);
        compare = NULL;
-       status = version_createVersion(1, 1, 3, strdup((const char *) 
str.c_str()), &compare);
+       status = version_createVersion(1, 1, 3, str, &compare);
        LONGS_EQUAL(CELIX_SUCCESS, status);
        CHECK_C(version != NULL);
        status = version_compareTo(version, compare, &result);
        LONGS_EQUAL(CELIX_SUCCESS, status);
        CHECK(result > 0);
+
+       version_destroy(compare);
+       version_destroy(version);
+       free(str);
 }
 
 TEST(version, toString) {
        version_pt version = NULL, compare = NULL;
        celix_status_t status = CELIX_SUCCESS;
-       std::string str;
+       char * str;
        char *result = NULL;
 
-       str = "abc";
-       status = version_createVersion(1, 2, 3, strdup((const char *) 
str.c_str()), &version);
+       str = my_strdup("abc");
+       status = version_createVersion(1, 2, 3, str, &version);
        LONGS_EQUAL(CELIX_SUCCESS, status);
        CHECK_C(version != NULL);
 
@@ -282,7 +341,9 @@ TEST(version, toString) {
        LONGS_EQUAL(CELIX_SUCCESS, status);
        CHECK_C(result != NULL);
        STRCMP_EQUAL("1.2.3.abc", result);
+       free(result);
 
+       version_destroy(version);
        version = NULL;
        status = version_createVersion(1, 2, 3, NULL, &version);
        LONGS_EQUAL(CELIX_SUCCESS, status);
@@ -292,6 +353,10 @@ TEST(version, toString) {
        LONGS_EQUAL(CELIX_SUCCESS, status);
        CHECK_C(result != NULL);
        STRCMP_EQUAL("1.2.3", result);
+
+       version_destroy(version);
+       free(result);
+       free(str);
 }
 
 

http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/test/wire_test.cpp
----------------------------------------------------------------------
diff --git a/framework/private/test/wire_test.cpp 
b/framework/private/test/wire_test.cpp
index 7ddfc04..6af4d01 100644
--- a/framework/private/test/wire_test.cpp
+++ b/framework/private/test/wire_test.cpp
@@ -19,13 +19,14 @@
 /*
  * wire_test.cpp
  *
- *  \date       Dec 18, 2012
+ *  \date       Sep 25, 2015
  *  \author     <a href="mailto:[email protected]";>Apache Celix Project 
Team</a>
  *  \copyright  Apache License, Version 2.0
  */
 #include "CppUTest/TestHarness.h"
 #include "CppUTest/TestHarness_c.h"
 #include "CppUTest/CommandLineTestRunner.h"
+#include "CppUTestExt/MockSupport.h"
 
 extern "C"
 {
@@ -37,7 +38,7 @@ extern "C"
 #include "requirement.h"
 #include "capability.h"
 
-framework_logger_pt logger;
+framework_logger_pt logger = (framework_logger_pt) 0x42;
 }
 
 int main(int argc, char** argv) {
@@ -47,30 +48,53 @@ int main(int argc, char** argv) {
 TEST_GROUP(wire) {
 
        void setup(void) {
-           logger = (framework_logger_pt) malloc(sizeof(*logger));
-        logger->logFunction = frameworkLogger_log;
        }
 
        void teardown() {
-           free(logger);
+               mock().checkExpectations();
+               mock().clear();
        }
 };
 
 
 TEST(wire, create) {
+       mock().expectOneCall("framework_logCode").withParameter("code", 
CELIX_ILLEGAL_ARGUMENT);
+
     module_pt module = (module_pt) 0x01;
     capability_pt cap = (capability_pt) 0x02;
     requirement_pt req = (requirement_pt) 0x03;
-
+    celix_status_t status;
     wire_pt wire = NULL;
 
-    wire_create(module, req, module, cap, &wire);
+    LONGS_EQUAL(CELIX_SUCCESS, wire_create(module, req, module, cap, &wire));
 
-       LONGS_EQUAL(1, 1);
+    LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, wire_create(module, req, module, cap, 
&wire));
 
-       wire_destroy(wire);
+    LONGS_EQUAL(CELIX_SUCCESS, wire_destroy(wire));
 }
 
+TEST(wire, get){
+    module_pt importer = (module_pt) 0x01;
+    module_pt exporter = (module_pt) 0x02;
+    capability_pt cap = (capability_pt) 0x03;
+    requirement_pt req = (requirement_pt) 0x04;
+    void * get;
+
+    wire_pt wire = NULL;
+
+    wire_create(importer, req, exporter, cap, &wire);
+
+    wire_getImporter(wire, (module_pt*)&get);
+       POINTERS_EQUAL(importer, get);
+
+    wire_getExporter(wire, (module_pt*)&get);
+       POINTERS_EQUAL(exporter, get);
 
+    wire_getCapability(wire, (capability_pt*)&get);
+       POINTERS_EQUAL(cap, get);
 
+    wire_getRequirement(wire, (requirement_pt*)&get);
+       POINTERS_EQUAL(req, get);
 
+       wire_destroy(wire);
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/public/include/bundle.h
----------------------------------------------------------------------
diff --git a/framework/public/include/bundle.h 
b/framework/public/include/bundle.h
index 0fb4c35..44501cc 100644
--- a/framework/public/include/bundle.h
+++ b/framework/public/include/bundle.h
@@ -40,7 +40,7 @@ typedef struct bundle * bundle_pt;
 #include "celix_log.h"
 #include "celix_threads.h"
 
-FRAMEWORK_EXPORT celix_status_t bundle_create(bundle_pt * bundle, 
framework_logger_pt logger);
+FRAMEWORK_EXPORT celix_status_t bundle_create(bundle_pt * bundle);
 FRAMEWORK_EXPORT celix_status_t bundle_createFromArchive(bundle_pt * bundle, 
framework_pt framework, bundle_archive_pt archive);
 FRAMEWORK_EXPORT celix_status_t bundle_destroy(bundle_pt bundle);
 

http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/public/include/bundle_archive.h
----------------------------------------------------------------------
diff --git a/framework/public/include/bundle_archive.h 
b/framework/public/include/bundle_archive.h
index 2ac43c6..e5f22b3 100644
--- a/framework/public/include/bundle_archive.h
+++ b/framework/public/include/bundle_archive.h
@@ -38,8 +38,8 @@
 
 typedef struct bundleArchive * bundle_archive_pt;
 
-celix_status_t bundleArchive_create(framework_logger_pt logger, char * 
archiveRoot, long id, char * location, char *inputFile, bundle_archive_pt 
*bundle_archive);
-celix_status_t bundleArchive_createSystemBundleArchive(framework_logger_pt 
logger, bundle_archive_pt *bundle_archive);
+celix_status_t bundleArchive_create(char * archiveRoot, long id, char * 
location, char *inputFile, bundle_archive_pt *bundle_archive);
+celix_status_t bundleArchive_createSystemBundleArchive(bundle_archive_pt 
*bundle_archive);
 celix_status_t bundleArchive_recreate(char * archiveRoot, bundle_archive_pt 
*bundle_archive);
 
 celix_status_t bundleArchive_destroy(bundle_archive_pt archive);

http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/public/include/bundle_revision.h
----------------------------------------------------------------------
diff --git a/framework/public/include/bundle_revision.h 
b/framework/public/include/bundle_revision.h
index 3bc0199..6537f64 100644
--- a/framework/public/include/bundle_revision.h
+++ b/framework/public/include/bundle_revision.h
@@ -62,7 +62,7 @@ typedef struct bundleRevision * bundle_revision_pt;
  *             - CELIX_SUCCESS when no errors are encountered.
  *             - CELIX_ENOMEM If allocating memory for 
<code>bundle_revision</code> failed.
  */
-celix_status_t bundleRevision_create(framework_logger_pt logger, char *root, 
char *location, long revisionNr, char *inputFile, bundle_revision_pt 
*bundle_revision);
+celix_status_t bundleRevision_create(char *root, char *location, long 
revisionNr, char *inputFile, bundle_revision_pt *bundle_revision);
 
 celix_status_t bundleRevision_destroy(bundle_revision_pt revision);
 

http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/public/include/service_reference.h
----------------------------------------------------------------------
diff --git a/framework/public/include/service_reference.h 
b/framework/public/include/service_reference.h
index 5eedc30..f1e1427 100644
--- a/framework/public/include/service_reference.h
+++ b/framework/public/include/service_reference.h
@@ -44,6 +44,8 @@ FRAMEWORK_EXPORT celix_status_t 
serviceReference_getUsingBundles(service_referen
 FRAMEWORK_EXPORT celix_status_t 
serviceReference_getProperty(service_reference_pt reference, char *key, char 
**value);
 FRAMEWORK_EXPORT celix_status_t 
serviceReference_getPropertyKeys(service_reference_pt reference, char **keys[], 
unsigned int *size);
 
+FRAMEWORK_EXPORT celix_status_t 
serviceReference_getServiceRegistration(service_reference_pt reference, 
service_registration_pt *registration);
+
 FRAMEWORK_EXPORT celix_status_t serviceReference_equals(service_reference_pt 
reference, service_reference_pt compareTo, bool *equal);
 FRAMEWORK_EXPORT unsigned int serviceReference_hashCode(void *referenceP);
 FRAMEWORK_EXPORT int serviceReference_equals2(void *reference1, void 
*reference2);

Reply via email to