You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by pn...@apache.org on 2015/11/09 13:53:47 UTC

[3/5] celix git commit: CELIX-289: Fixes for mocking issues and bugs

http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/src/bundle_context.c
----------------------------------------------------------------------
diff --git a/framework/private/src/bundle_context.c b/framework/private/src/bundle_context.c
index 8a52790..35d27ce 100644
--- a/framework/private/src/bundle_context.c
+++ b/framework/private/src/bundle_context.c
@@ -45,7 +45,6 @@ celix_status_t bundleContext_create(framework_pt framework, framework_logger_pt
         } else {
             context->framework = framework;
             context->bundle = bundle;
-            context->logger = logger;
 
             *bundle_context = context;
         }

http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/src/bundle_revision.c
----------------------------------------------------------------------
diff --git a/framework/private/src/bundle_revision.c b/framework/private/src/bundle_revision.c
index c91976c..6c538f9 100644
--- a/framework/private/src/bundle_revision.c
+++ b/framework/private/src/bundle_revision.c
@@ -34,7 +34,7 @@
 #include "archive.h"
 #include "celix_log.h"
 
-celix_status_t bundleRevision_create(framework_logger_pt loggera, 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 status = CELIX_SUCCESS;
 	bundle_revision_pt revision = NULL;
 
@@ -61,7 +61,6 @@ celix_status_t bundleRevision_create(framework_logger_pt loggera, char *root, ch
                 revision->revisionNr = revisionNr;
                 revision->root = strdup(root);
                 revision->location = strdup(location);
-                revision->logger = loggera;
 
                 *bundle_revision = revision;
 

http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/src/celix_errorcodes.c
----------------------------------------------------------------------
diff --git a/framework/private/src/celix_errorcodes.c b/framework/private/src/celix_errorcodes.c
index ac24c10..ec25cff 100644
--- a/framework/private/src/celix_errorcodes.c
+++ b/framework/private/src/celix_errorcodes.c
@@ -48,7 +48,7 @@ static char *celix_error_string(celix_status_t statcode) {
 	case CELIX_SERVICE_EXCEPTION:
         return "Service exception";
 	}
-	return "Unkown code";
+	return "Unknown code";
 }
 
 char *celix_strerror(celix_status_t errorcode, char *buffer, size_t bufferSize) {

http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/src/framework.c
----------------------------------------------------------------------
diff --git a/framework/private/src/framework.c b/framework/private/src/framework.c
index 5ca35a5..47aabb3 100644
--- a/framework/private/src/framework.c
+++ b/framework/private/src/framework.c
@@ -234,7 +234,7 @@ celix_status_t framework_create(framework_pt *framework, properties_pt config) {
             (*framework)->logger = logger;
 
 
-            status = CELIX_DO_IF(status, bundle_create(&(*framework)->bundle, (*framework)->logger));
+            status = CELIX_DO_IF(status, bundle_create(&(*framework)->bundle));
             status = CELIX_DO_IF(status, arrayList_create(&(*framework)->globalLockWaitersList));
             status = CELIX_DO_IF(status, bundle_setFramework((*framework)->bundle, (*framework)));
             if (status == CELIX_SUCCESS) {
@@ -372,7 +372,7 @@ celix_status_t fw_init(framework_pt framework) {
 	if (status == CELIX_SUCCESS) {
 	    if ((state == OSGI_FRAMEWORK_BUNDLE_INSTALLED) || (state == OSGI_FRAMEWORK_BUNDLE_RESOLVED)) {
 	        bundle_state_e state;
-	        status = CELIX_DO_IF(status, bundleCache_create(framework->configurationMap, framework->logger, &framework->cache));
+	        status = CELIX_DO_IF(status, bundleCache_create(framework->configurationMap,&framework->cache));
 	        status = CELIX_DO_IF(status, bundle_getState(framework->bundle, &state));
 	        if (status == CELIX_SUCCESS) {
 	            if (state == OSGI_FRAMEWORK_BUNDLE_INSTALLED) {

http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/src/module.c
----------------------------------------------------------------------
diff --git a/framework/private/src/module.c b/framework/private/src/module.c
index 15d5c0e..17fea5c 100644
--- a/framework/private/src/module.c
+++ b/framework/private/src/module.c
@@ -258,6 +258,19 @@ void module_removeDependentImporter(module_pt module, module_pt importer) {
     arrayList_removeElement(module->dependentImporters, importer);
 }
 
+//----------------------------------------------------
+//TODO add implementation (functions not implemented but already exported)
+array_list_pt module_getDependentRequirers(module_pt module) {
+	return NULL;
+}
+
+void module_addDependentRequirer(module_pt module, module_pt requirer) {
+}
+
+void module_removeDependentRequirer(module_pt module, module_pt requirer) {
+}
+//----------------------------------------------------
+
 array_list_pt module_getDependents(module_pt module) {
     array_list_pt dependents = NULL;
     arrayList_create(&dependents);

http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/src/service_tracker.c
----------------------------------------------------------------------
diff --git a/framework/private/src/service_tracker.c b/framework/private/src/service_tracker.c
index 1221e0c..b81b4d0 100644
--- a/framework/private/src/service_tracker.c
+++ b/framework/private/src/service_tracker.c
@@ -200,7 +200,7 @@ void *serviceTracker_getServiceByReference(service_tracker_pt tracker, service_r
 	tracked_pt tracked;
 	unsigned int i;
 	for (i = 0; i < arrayList_size(tracker->tracked); i++) {
-		bool equals;
+		bool equals = false;
 		tracked = (tracked_pt) arrayList_get(tracker->tracked, i);
 		serviceReference_equals(reference, tracked->reference, &equals);
 		if (equals) {
@@ -232,7 +232,7 @@ static celix_status_t serviceTracker_track(service_tracker_pt tracker, service_r
 	int found = -1;
 	unsigned int i;
 	for (i = 0; i < arrayList_size(tracker->tracked); i++) {
-		bool equals;
+		bool equals = false;
 		tracked = (tracked_pt) arrayList_get(tracker->tracked, i);
 		serviceReference_equals(reference, tracked->reference, &equals);
 		if (equals) {

http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/src/version_range.c
----------------------------------------------------------------------
diff --git a/framework/private/src/version_range.c b/framework/private/src/version_range.c
index 6f4b598..cc53691 100644
--- a/framework/private/src/version_range.c
+++ b/framework/private/src/version_range.c
@@ -135,7 +135,7 @@ celix_status_t versionRange_parse(char * rangeStr, version_range_pt *range) {
 	celix_status_t status;
 	if (strchr(rangeStr, ',') != NULL) {
 			int vlowL = strcspn(rangeStr+1, ",");
-			char * vlow = (char *) malloc(sizeof(*vlow * (vlowL + 1)));
+			char * vlow = (char *) malloc(sizeof(char) * (vlowL + 1));
 			if (!vlow) {
 				status = CELIX_ENOMEM;
 			} else {
@@ -144,7 +144,7 @@ celix_status_t versionRange_parse(char * rangeStr, version_range_pt *range) {
 				vlow = strncpy(vlow, rangeStr+1, vlowL);
 				vlow[vlowL] = '\0';
 				vhighL = strlen(rangeStr+1) - vlowL - 2;
-				vhigh = (char *) malloc(sizeof(*vhigh * (vhighL+1)));
+				vhigh = (char *) malloc(sizeof(char) * (vhighL+1));
 				if (!vhigh) {
 					status = CELIX_ENOMEM;
 				} else {					
@@ -169,7 +169,10 @@ celix_status_t versionRange_parse(char * rangeStr, version_range_pt *range) {
 								);
 						}
 					}
+					free(vhigh);
 				}
+				free(vlow);
+
 		}
 	} else {
 		version_pt version = NULL;

http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/test/attribute_test.cpp
----------------------------------------------------------------------
diff --git a/framework/private/test/attribute_test.cpp b/framework/private/test/attribute_test.cpp
index 5847c02..c378b3a 100644
--- a/framework/private/test/attribute_test.cpp
+++ b/framework/private/test/attribute_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,17 +36,32 @@ extern "C" {
 #include "attribute_private.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(attribute) {
 	void setup(void) {
-		logger = (framework_logger_pt) malloc(sizeof(*logger));
-		logger->logFunction = frameworkLogger_log;
 	}
 
 	void teardown() {
@@ -55,13 +71,22 @@ TEST_GROUP(attribute) {
 };
 
 TEST(attribute, create) {
-	char key[] = "key";
-	char value[] = "value";
+	char * key = (char*) my_strdup("key");
+	char * value = (char*) my_strdup("value");
 
 	attribute_pt attribute = NULL;
 	celix_status_t status = attribute_create(key, value, &attribute);
 	STRCMP_EQUAL(key, attribute->key);
 	STRCMP_EQUAL(value, attribute->value);
+	LONGS_EQUAL(CELIX_SUCCESS, status);
+
+	mock().expectOneCall("framework_logCode")
+			.withParameter("code", CELIX_ILLEGAL_ARGUMENT);
+
+	status = attribute_create(NULL, NULL, NULL);
+	LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
+
+	attribute_destroy(attribute);
 }
 
 TEST(attribute, getKey) {
@@ -75,6 +100,8 @@ TEST(attribute, getKey) {
 	char *actual = NULL;
 	celix_status_t status = attribute_getKey(attribute, &actual);
 	STRCMP_EQUAL(key, actual);
+
+	free(attribute);
 }
 
 TEST(attribute, getValue) {
@@ -88,4 +115,6 @@ TEST(attribute, getValue) {
 	char *actual = NULL;
 	celix_status_t status = attribute_getValue(attribute, &actual);
 	STRCMP_EQUAL(value, actual);
+
+	free(attribute);
 }

http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/test/bundle_archive_test.cpp
----------------------------------------------------------------------
diff --git a/framework/private/test/bundle_archive_test.cpp b/framework/private/test/bundle_archive_test.cpp
index e8f5f60..f5baa2d 100644
--- a/framework/private/test/bundle_archive_test.cpp
+++ b/framework/private/test/bundle_archive_test.cpp
@@ -25,6 +25,10 @@
  */
 #include <stdlib.h>
 #include <stdio.h>
+#include <sys/stat.h>
+#include <dirent.h>
+#include <unistd.h>
+#include <string.h>
 
 #include "CppUTest/TestHarness.h"
 #include "CppUTest/TestHarness_c.h"
@@ -33,18 +37,100 @@
 
 extern "C" {
 #include "bundle_archive.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;
+}
+
+static int remove_directory_recursive(const char *path) {
+	DIR *d = opendir(path);
+	size_t path_len = strlen(path);
+	int r = -1;
+
+	if (d) {
+		struct dirent *p;
+
+		r = 0;
+
+		while (!r && (p = readdir(d))) {
+			int r2 = -1;
+			char *buf;
+			size_t len;
+
+			/* Skip the names "." and ".." as we don't want to recurse on them. */
+			if (!strcmp(p->d_name, ".") || !strcmp(p->d_name, "..")) {
+				continue;
+			}
+
+			len = path_len + strlen(p->d_name) + 2;
+			buf = (char*) malloc(len);
+
+			if (buf) {
+				struct stat statbuf;
+				snprintf(buf, len, "%s/%s", path, p->d_name);
+
+				if (!stat(buf, &statbuf)) {
+					if (S_ISDIR(statbuf.st_mode)) {
+						r2 = remove_directory_recursive(buf);
+					} else {
+						r2 = unlink(buf);
+					}
+				}
+
+				free(buf);
+			}
+			r = r2;
+		}
+		closedir(d);
+	}
+	if (!r) {
+		r = rmdir(path);
+	}
+	return r;
+}
+
+//----------------------TESTGROUP DEFINES----------------------
+
 TEST_GROUP(bundle_archive) {
+	bundle_archive_pt bundle_archive;
+	char * bundle_path; 			//uses the default build shell bundle
+	char * alternate_bundle_path;//alternative bundle, if shell bundle not found
+	char cache_path[512];				//a local cache folder
+
 	void setup(void) {
-	    logger = (framework_logger_pt) malloc(sizeof(*logger));
-        logger->logFunction = frameworkLogger_log;
+		char cwd[512];
+		bundle_archive = NULL;
+		bundle_path = (char*) "../shell/shell.zip"; //uses the default build shell bundle
+		alternate_bundle_path = (char*) "../log_service/log_service.zip"; //alternative bundle, if shell bundle not found
+		snprintf(cache_path, sizeof(cache_path), "%s/.cache", getcwd(cwd, sizeof(cwd)));							//a local cache folder
+		struct stat file_stat;
+
+		if (stat(bundle_path, &file_stat) < 0) {
+			if (stat(alternate_bundle_path, &file_stat) < 0) {
+				FAIL("failed to find needed test bundle");
+			} else {
+				bundle_path = alternate_bundle_path;
+			}
+		}
 	}
 
 	void teardown() {
@@ -53,6 +139,238 @@ TEST_GROUP(bundle_archive) {
 	}
 };
 
+//----------------------TEST DEFINES----------------------
+//WARNING: if one test fails, it does not clean up properly,
+//causing most if not all of the subsequent tests to also fail
+
+TEST(bundle_archive, create) {
+	mock().expectOneCall("framework_logCode").withParameter("code", CELIX_ILLEGAL_ARGUMENT);
+
+	bundle_archive = (bundle_archive_pt) 0x42;
+	LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, bundleArchive_create(cache_path, 5, bundle_path, NULL, &bundle_archive));
+
+	bundle_archive = NULL;
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_create(cache_path, 5, bundle_path, NULL, &bundle_archive));
+	CHECK(bundle_archive != NULL);
+
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_closeAndDelete(bundle_archive));
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_destroy(bundle_archive));
+}
+
+TEST(bundle_archive, createSystemBundleArchive) {
+	mock().expectOneCall("framework_logCode").withParameter("code", CELIX_ILLEGAL_ARGUMENT);
+
+	bundle_archive = (bundle_archive_pt) 0x42;
+	LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, bundleArchive_createSystemBundleArchive(&bundle_archive ));
+
+	bundle_archive = NULL;
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_createSystemBundleArchive(&bundle_archive));
+	CHECK(bundle_archive != NULL);
+
+	//LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_closeAndDelete(bundle_archive));
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_destroy(bundle_archive));
+}
+
+TEST(bundle_archive, recreate) {
+	char * get_root;
+	char * get_location;
+	bundle_archive_pt recr_archive = NULL;
+
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_create(cache_path, 5, bundle_path, NULL, &bundle_archive));
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_recreate(cache_path, &recr_archive));
+
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_getArchiveRoot(recr_archive, &get_root));
+	STRCMP_EQUAL(cache_path, get_root);
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_getLocation(recr_archive, &get_location));
+	STRCMP_EQUAL(bundle_path, get_location);
+
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_closeAndDelete(bundle_archive));
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_destroy(bundle_archive));
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_destroy(recr_archive));
+}
+
+TEST(bundle_archive, getId) {
+	long get_id;
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_create(cache_path, -42, bundle_path, NULL, &bundle_archive));
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_getId(bundle_archive, &get_id));
+	LONGS_EQUAL(-42, get_id);
+
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_closeAndDelete(bundle_archive));
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_destroy(bundle_archive));
+	bundle_archive = NULL;
+
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_create(cache_path, 666, bundle_path, NULL, &bundle_archive));
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_getId(bundle_archive, &get_id));
+	LONGS_EQUAL(666, get_id);
+
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_closeAndDelete(bundle_archive));
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_destroy(bundle_archive));
+}
+
+TEST(bundle_archive, getLocation) {
+	char * get_loc;
+
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_create(cache_path, 1, bundle_path, NULL, &bundle_archive));
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_getLocation(bundle_archive, &get_loc));
+	STRCMP_EQUAL(bundle_path, get_loc);
+
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_closeAndDelete(bundle_archive));
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_destroy(bundle_archive));
+}
 
+TEST(bundle_archive, getArchiveRoot) {
+	char * get_root;
 
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_create(cache_path, 1, bundle_path, NULL, &bundle_archive));
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_getArchiveRoot(bundle_archive, &get_root));
+	STRCMP_EQUAL(cache_path, get_root);
+
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_closeAndDelete(bundle_archive));
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_destroy(bundle_archive));
+}
+
+TEST(bundle_archive, getCurrentRevisionNumber) {
+	long get_rev_num;
+
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_create(cache_path, 1, bundle_path, NULL, &bundle_archive));
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_getCurrentRevisionNumber(bundle_archive, &get_rev_num));
+	LONGS_EQUAL(0, get_rev_num);
+
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_revise(bundle_archive, bundle_path, NULL));
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_getCurrentRevisionNumber(bundle_archive,
+					&get_rev_num));
+	LONGS_EQUAL(1, get_rev_num);
+
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_revise(bundle_archive, bundle_path, NULL));
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_getCurrentRevisionNumber(bundle_archive, &get_rev_num));
+	LONGS_EQUAL(2, get_rev_num);
+
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_closeAndDelete(bundle_archive));
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_destroy(bundle_archive));
+}
+
+TEST(bundle_archive, getCurrentRevision) {
+	long get_rev_num;
+	bundle_revision_pt get_rev;
+
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_create(cache_path, 1, bundle_path, NULL, &bundle_archive));
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_getCurrentRevision(bundle_archive, &get_rev));
+	bundleRevision_getNumber(get_rev, &get_rev_num);
+	LONGS_EQUAL(0, get_rev_num);
+
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_revise(bundle_archive, bundle_path, NULL));
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_getCurrentRevision(bundle_archive, &get_rev));
+	bundleRevision_getNumber(get_rev, &get_rev_num);
+	LONGS_EQUAL(1, get_rev_num);
+
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_closeAndDelete(bundle_archive));
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_destroy(bundle_archive));
+}
+
+TEST(bundle_archive, getRevision) {
+	long get_rev_num;
+	bundle_revision_pt get_rev;
+
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_create(cache_path, 1, bundle_path, NULL, &bundle_archive));
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_revise(bundle_archive, bundle_path, NULL));
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_revise(bundle_archive, bundle_path, NULL));
+
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_getRevision(bundle_archive, 0, &get_rev));
+	bundleRevision_getNumber(get_rev, &get_rev_num);
+	LONGS_EQUAL(0, get_rev_num);
+
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_getRevision(bundle_archive, 2, &get_rev));
+	bundleRevision_getNumber(get_rev, &get_rev_num);
+	LONGS_EQUAL(2, get_rev_num);
+
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_getRevision(bundle_archive, 1, &get_rev));
+	bundleRevision_getNumber(get_rev, &get_rev_num);
+	LONGS_EQUAL(1, get_rev_num);
+
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_closeAndDelete(bundle_archive));
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_destroy(bundle_archive));
+}
+
+TEST(bundle_archive, set_getPersistentState) {
+	bundle_state_e get;
+
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_create(cache_path, 1, bundle_path, NULL, &bundle_archive));
+
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_setPersistentState(bundle_archive, OSGI_FRAMEWORK_BUNDLE_UNKNOWN));
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_getPersistentState(bundle_archive, &get));
+	LONGS_EQUAL(OSGI_FRAMEWORK_BUNDLE_INSTALLED, get);
+
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_setPersistentState(bundle_archive, OSGI_FRAMEWORK_BUNDLE_ACTIVE));
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_getPersistentState(bundle_archive, &get));
+	LONGS_EQUAL(OSGI_FRAMEWORK_BUNDLE_ACTIVE, get);
+
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_setPersistentState(bundle_archive, OSGI_FRAMEWORK_BUNDLE_STARTING));
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_getPersistentState(bundle_archive, &get));
+	LONGS_EQUAL(OSGI_FRAMEWORK_BUNDLE_STARTING, get);
+
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_setPersistentState(bundle_archive, OSGI_FRAMEWORK_BUNDLE_UNINSTALLED));
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_getPersistentState(bundle_archive, &get));
+	LONGS_EQUAL(OSGI_FRAMEWORK_BUNDLE_UNINSTALLED, get);
+
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_closeAndDelete(bundle_archive));
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_destroy(bundle_archive));
+}
+
+TEST(bundle_archive, set_getRefreshCount) {
+	long get_refresh_num;
+
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_create(cache_path, 1, bundle_path, NULL, &bundle_archive));
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_getRefreshCount(bundle_archive, &get_refresh_num));
+	LONGS_EQUAL(0, get_refresh_num);
+
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_setRefreshCount(bundle_archive));
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_getRefreshCount(bundle_archive, &get_refresh_num));
+	LONGS_EQUAL(0, get_refresh_num);
+
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_closeAndDelete(bundle_archive));
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_destroy(bundle_archive));
+}
+
+TEST(bundle_archive, get_setLastModified) {
+	time_t set_time;
+	time_t get_time;
+
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_create(cache_path, 1, bundle_path, NULL, &bundle_archive));
+
+	time(&set_time);
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_setLastModified(bundle_archive, set_time));
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_getLastModified(bundle_archive, &get_time));
+	CHECK(set_time == get_time);
+
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_closeAndDelete(bundle_archive));
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_destroy(bundle_archive));
+}
+
+//CANT seem to find a way to test this static function
+/*TEST(bundle_archive, readLastModified) {
+	mock().expectOneCall("framework_logCode");
+
+	time_t set_time;
+	time_t get_time;
+	bundle_archive_pt recr_archive = NULL;
+
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_create(cache_path, 1, bundle_path, NULL, &bundle_archive));
+
+	time(&set_time);
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_setLastModified(bundle_archive, set_time));
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_recreate(cache_path, &recr_archive));
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_getLastModified(recr_archive, &get_time));
+	LONGS_EQUAL(set_time, get_time);
+
+	LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_closeAndDelete(bundle_archive));
+	//LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_destroy(bundle_archive));
+}*/
+
+TEST(bundle_archive, rollbackRevise) {
+	bool get;
+	bundleArchive_rollbackRevise(NULL, &get);
+
+	LONGS_EQUAL(true, get);
+
+}
 

http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/test/bundle_cache_test.cpp
----------------------------------------------------------------------
diff --git a/framework/private/test/bundle_cache_test.cpp b/framework/private/test/bundle_cache_test.cpp
index 9043727..71174fe 100644
--- a/framework/private/test/bundle_cache_test.cpp
+++ b/framework/private/test/bundle_cache_test.cpp
@@ -26,6 +26,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <sys/stat.h>
+#include <string.h>
 #include <unistd.h>
 
 #include "CppUTest/TestHarness.h"
@@ -37,17 +38,32 @@ extern "C" {
 #include "bundle_cache_private.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(bundle_cache) {
 	void setup(void) {
-		logger = (framework_logger_pt) malloc(sizeof(*logger));
-        logger->logFunction = frameworkLogger_log;
 	}
 
 	void teardown() {
@@ -65,23 +81,23 @@ TEST(bundle_cache, create) {
 		.andReturnValue((char *) NULL);
 
 	bundle_cache_pt cache = NULL;
-	celix_status_t status = bundleCache_create(configuration, logger, &cache);
-	LONGS_EQUAL(CELIX_SUCCESS, status);
+	LONGS_EQUAL(CELIX_SUCCESS, bundleCache_create(configuration, &cache));
+
+	LONGS_EQUAL(CELIX_SUCCESS, bundleCache_destroy(&cache));
 }
 
 TEST(bundle_cache, deleteTree) {
 	bundle_cache_pt cache = (bundle_cache_pt) malloc(sizeof(*cache));
 	char cacheDir[] = "bundle_cache_test_directory";
-	char cacheFile[] = "bundle_cache_test_directory/temp";
+	char cacheDir2[] = "bundle_cache_test_directory/testdir";
+	char cacheFile[] = "bundle_cache_test_directory/tempXXXXXX";
 	cache->cacheDir = cacheDir;
 
 	mkdir(cacheDir, S_IRWXU);
+	mkdir(cacheDir2, S_IRWXU);
 	mktemp(cacheFile);
 
-	celix_status_t status = bundleCache_delete(cache);
-
-	LONGS_EQUAL(CELIX_SUCCESS, status);
-
+	LONGS_EQUAL(CELIX_SUCCESS, bundleCache_delete(cache));
 }
 
 TEST(bundle_cache, getArchive) {
@@ -102,9 +118,8 @@ TEST(bundle_cache, getArchive) {
 		.andReturnValue(CELIX_SUCCESS);
 
 	array_list_pt archives = NULL;
-	celix_status_t status = bundleCache_getArchives(cache, &archives);
+	LONGS_EQUAL(CELIX_SUCCESS, bundleCache_getArchives(cache, &archives));
 
-	LONGS_EQUAL(CELIX_SUCCESS, status);
 	CHECK(archives);
 	LONGS_EQUAL(1, arrayList_size(archives));
 	POINTERS_EQUAL(archive, arrayList_get(archives, 0));
@@ -112,6 +127,9 @@ TEST(bundle_cache, getArchive) {
 	rmdir(bundle0);
 	rmdir(bundle1);
 	rmdir(cacheDir);
+
+	LONGS_EQUAL(CELIX_SUCCESS, bundleCache_getArchives(cache, &archives));
+	rmdir(cacheDir);
 }
 
 TEST(bundle_cache, createArchive) {
@@ -124,7 +142,6 @@ TEST(bundle_cache, createArchive) {
 	char location[] = "test.zip";
 	bundle_archive_pt archive = (bundle_archive_pt) 0x10;
 	mock().expectOneCall("bundleArchive_create")
-        .withParameter("logger", (void *) NULL)
 		.withParameter("archiveRoot", archiveRoot)
 		.withParameter("id", id)
 		.withParameter("location", location)

http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/test/bundle_context_test.cpp
----------------------------------------------------------------------
diff --git a/framework/private/test/bundle_context_test.cpp b/framework/private/test/bundle_context_test.cpp
index db2792d..fcd6dfa 100644
--- a/framework/private/test/bundle_context_test.cpp
+++ b/framework/private/test/bundle_context_test.cpp
@@ -35,7 +35,7 @@ extern "C" {
 #include "bundle_context_private.h"
 #include "celix_log.h"
 
-framework_logger_pt logger;
+framework_logger_pt logger = (framework_logger_pt) 0x42;
 }
 
 int main(int argc, char** argv) {
@@ -44,8 +44,6 @@ int main(int argc, char** argv) {
 
 TEST_GROUP(bundle_context) {
 	void setup(void) {
-		logger = (framework_logger_pt) malloc(sizeof(*logger));
-        logger->logFunction = frameworkLogger_log;
 	}
 
 	void teardown() {
@@ -55,17 +53,21 @@ TEST_GROUP(bundle_context) {
 };
 
 TEST(bundle_context, create) {
+	mock().expectOneCall("framework_logCode").withParameter("code", CELIX_ILLEGAL_ARGUMENT);
+
 	framework_pt framework = (framework_pt) 0x10;
-        bundle_pt bundle = (bundle_pt) 0x20;
+	bundle_pt bundle = (bundle_pt) 0x20;
 
-        bundle_context_pt context = NULL;
-        bundleContext_create(framework, logger, bundle, &context);
-        POINTERS_EQUAL(framework, context->framework)
-        POINTERS_EQUAL(bundle, context->bundle)
-//      CHECK(context->pool);
+	bundle_context_pt context = NULL;
+	bundleContext_create(framework, logger, bundle, &context);
+	POINTERS_EQUAL(framework, context->framework)
+	POINTERS_EQUAL(bundle, context->bundle)
+
+	bundleContext_create(NULL, logger, NULL, &context);
 }
 
 TEST(bundle_context, destroy) {
+	mock().expectOneCall("framework_logCode").withParameter("code", CELIX_ILLEGAL_ARGUMENT);
 	bundle_context_pt context = (bundle_context_pt) malloc(sizeof(*context));
 	framework_pt framework = (framework_pt) 0x10;
 	bundle_pt bundle = (bundle_pt) 0x20;
@@ -80,41 +82,43 @@ TEST(bundle_context, destroy) {
 }
 
 TEST(bundle_context, getBundle) {
-        bundle_context_pt context = (bundle_context_pt) malloc(sizeof(*context));
-        framework_pt framework = (framework_pt) 0x10;
-        bundle_pt bundle = (bundle_pt) 0x20;
-        context->framework = framework;
-        context->bundle = bundle;
-
-        celix_status_t status;
-        bundle_pt actualBundle = NULL;
+	mock().expectNCalls(2, "framework_logCode").withParameter("code", CELIX_ILLEGAL_ARGUMENT);
+
+	bundle_context_pt context = (bundle_context_pt) malloc(sizeof(*context));
+	framework_pt framework = (framework_pt) 0x10;
+	bundle_pt bundle = (bundle_pt) 0x20;
+	context->framework = framework;
+	context->bundle = bundle;
+
+	celix_status_t status;
+	bundle_pt actualBundle = NULL;
 	status = bundleContext_getBundle(context, &actualBundle);
 	LONGS_EQUAL(CELIX_SUCCESS, status);
 	POINTERS_EQUAL(bundle, actualBundle);
 
 	framework_pt actualFramework = NULL;
 	status = bundleContext_getFramework(context, &actualFramework);
-        LONGS_EQUAL(CELIX_SUCCESS, status);
-        POINTERS_EQUAL(framework, actualFramework);
+	LONGS_EQUAL(CELIX_SUCCESS, status);
+	POINTERS_EQUAL(framework, actualFramework);
 
-        actualBundle = NULL;
-        status = bundleContext_getBundle(NULL, &actualBundle);
-        LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
+	actualBundle = NULL;
+	status = bundleContext_getBundle(NULL, &actualBundle);
+	LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
 
-        actualFramework = NULL;
-        status = bundleContext_getFramework(NULL, &actualFramework);
-        LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
+	actualFramework = NULL;
+	status = bundleContext_getFramework(NULL, &actualFramework);
+	LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
 }
 
 TEST(bundle_context, installBundle) {
-        bundle_context_pt context = (bundle_context_pt) malloc(sizeof(*context));
-        framework_pt framework = (framework_pt) 0x10;
-        bundle_pt bundle = (bundle_pt) 0x20;
-        context->framework = framework;
-        context->bundle = bundle;
-
-        char location[] = "test.zip";
-        bundle_pt installedBundle = (bundle_pt) 0x40;
+	bundle_context_pt context = (bundle_context_pt) malloc(sizeof(*context));
+	framework_pt framework = (framework_pt) 0x10;
+	bundle_pt bundle = (bundle_pt) 0x20;
+	context->framework = framework;
+	context->bundle = bundle;
+
+	char location[] = "test.zip";
+	bundle_pt installedBundle = (bundle_pt) 0x40;
 	mock().expectOneCall("fw_installBundle")
 		.withParameter("framework", framework)
 		.withParameter("location", location)
@@ -129,6 +133,8 @@ TEST(bundle_context, installBundle) {
 }
 
 TEST(bundle_context, installBundle2) {
+	mock().expectOneCall("framework_logCode").withParameter("code", CELIX_ILLEGAL_ARGUMENT);
+
 	bundle_context_pt context = (bundle_context_pt) malloc(sizeof(*context));
 	framework_pt framework = (framework_pt) 0x10;
 	bundle_pt bundle = (bundle_pt) 0x20;
@@ -156,6 +162,8 @@ TEST(bundle_context, installBundle2) {
 }
 
 TEST(bundle_context, registerService) {
+	mock().expectOneCall("framework_logCode").withParameter("code", CELIX_ILLEGAL_ARGUMENT);
+
 	bundle_context_pt context = (bundle_context_pt) malloc(sizeof(*context));
 	framework_pt framework = (framework_pt) 0x10;
 	bundle_pt bundle = (bundle_pt) 0x20;
@@ -187,6 +195,8 @@ TEST(bundle_context, registerService) {
 }
 
 TEST(bundle_context, registerServiceFactory) {
+	mock().expectOneCall("framework_logCode").withParameter("code", CELIX_ILLEGAL_ARGUMENT);
+
 	bundle_context_pt context = (bundle_context_pt) malloc(sizeof(*context));
 	framework_pt framework = (framework_pt) 0x10;
 	bundle_pt bundle = (bundle_pt) 0x20;
@@ -218,6 +228,8 @@ TEST(bundle_context, registerServiceFactory) {
 }
 
 TEST(bundle_context, getServiceReferences) {
+	mock().expectOneCall("framework_logCode").withParameter("code", CELIX_ILLEGAL_ARGUMENT);
+
 	bundle_context_pt context = (bundle_context_pt) malloc(sizeof(*context));
 	framework_pt framework = (framework_pt) 0x10;
 	bundle_pt bundle = (bundle_pt) 0x20;
@@ -247,6 +259,8 @@ TEST(bundle_context, getServiceReferences) {
 }
 
 TEST(bundle_context, getServiceReference) {
+	mock().expectNCalls(3, "framework_logCode").withParameter("code", CELIX_ILLEGAL_ARGUMENT);
+
 	bundle_context_pt context = (bundle_context_pt) malloc(sizeof(*context));
 	framework_pt framework = (framework_pt) 0x10;
 	bundle_pt bundle = (bundle_pt) 0x20;
@@ -268,16 +282,38 @@ TEST(bundle_context, getServiceReference) {
 		.andReturnValue(CELIX_SUCCESS);
 
 	service_reference_pt actualReference = NULL;
-	celix_status_t status = bundleContext_getServiceReference(context, serviceName, &actualReference);
-	LONGS_EQUAL(CELIX_SUCCESS, status);
+	LONGS_EQUAL(CELIX_SUCCESS, bundleContext_getServiceReference(context, serviceName, &actualReference));
 	POINTERS_EQUAL(reference, actualReference);
 
+	LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, bundleContext_getServiceReference(NULL, serviceName, &actualReference));
 	actualReference = NULL;
-	status = bundleContext_getServiceReference(context, NULL, &actualReference);
-	LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
+	LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, bundleContext_getServiceReference(context, NULL, &actualReference));
+}
+
+TEST(bundle_context, ungetServiceReference) {
+	mock().expectOneCall("framework_logCode").withParameter("code", CELIX_ILLEGAL_ARGUMENT);
+
+	bundle_context_pt context = (bundle_context_pt) malloc(sizeof(*context));
+	framework_pt framework = (framework_pt) 0x10;
+	bundle_pt bundle = (bundle_pt) 0x20;
+	context->framework = framework;
+	context->bundle = bundle;
+	service_reference_pt reference = (service_reference_pt) 0x30;
+
+    mock().expectOneCall("framework_ungetServiceReference")
+    		.withParameter("framework", framework)
+    		.withParameter("bundle", bundle)
+    		.withParameter("reference", reference);
+
+	service_reference_pt actualReference = NULL;
+	LONGS_EQUAL(CELIX_SUCCESS, bundleContext_ungetServiceReference(context, reference));
+
+    LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, bundleContext_ungetServiceReference(context, NULL));
 }
 
 TEST(bundle_context, getService) {
+	mock().expectOneCall("framework_logCode").withParameter("code", CELIX_ILLEGAL_ARGUMENT);
+
 	bundle_context_pt context = (bundle_context_pt) malloc(sizeof(*context));
 	framework_pt framework = (framework_pt) 0x10;
 	bundle_pt bundle = (bundle_pt) 0x20;
@@ -306,6 +342,8 @@ TEST(bundle_context, getService) {
 }
 
 TEST(bundle_context, ungetService) {
+	mock().expectOneCall("framework_logCode").withParameter("code", CELIX_ILLEGAL_ARGUMENT);
+
 	bundle_context_pt context = (bundle_context_pt) malloc(sizeof(*context));
 	framework_pt framework = (framework_pt) 0x10;
 	bundle_pt bundle = (bundle_pt) 0x20;
@@ -334,6 +372,8 @@ TEST(bundle_context, ungetService) {
 }
 
 TEST(bundle_context, getBundles) {
+	mock().expectOneCall("framework_logCode").withParameter("code", CELIX_ILLEGAL_ARGUMENT);
+
 	bundle_context_pt context = (bundle_context_pt) malloc(sizeof(*context));
 	framework_pt framework = (framework_pt) 0x10;
 	bundle_pt bundle = (bundle_pt) 0x20;
@@ -357,6 +397,8 @@ TEST(bundle_context, getBundles) {
 }
 
 TEST(bundle_context, getBundleById) {
+	mock().expectOneCall("framework_logCode").withParameter("code", CELIX_ILLEGAL_ARGUMENT);
+
 	bundle_context_pt context = (bundle_context_pt) malloc(sizeof(*context));
 	framework_pt framework = (framework_pt) 0x10;
 	bundle_pt bundle = (bundle_pt) 0x20;
@@ -382,6 +424,8 @@ TEST(bundle_context, getBundleById) {
 }
 
 TEST(bundle_context, addServiceListener) {
+	mock().expectOneCall("framework_logCode").withParameter("code", CELIX_ILLEGAL_ARGUMENT);
+
 	bundle_context_pt context = (bundle_context_pt) malloc(sizeof(*context));
 	framework_pt framework = (framework_pt) 0x10;
 	bundle_pt bundle = (bundle_pt) 0x20;
@@ -407,6 +451,8 @@ TEST(bundle_context, addServiceListener) {
 }
 
 TEST(bundle_context, removeServiceListener) {
+	mock().expectOneCall("framework_logCode").withParameter("code", CELIX_ILLEGAL_ARGUMENT);
+
 	bundle_context_pt context = (bundle_context_pt) malloc(sizeof(*context));
 	framework_pt framework = (framework_pt) 0x10;
 	bundle_pt bundle = (bundle_pt) 0x20;
@@ -430,6 +476,8 @@ TEST(bundle_context, removeServiceListener) {
 }
 
 TEST(bundle_context, addBundleListener) {
+	mock().expectOneCall("framework_logCode").withParameter("code", CELIX_ILLEGAL_ARGUMENT);
+
 	bundle_context_pt context = (bundle_context_pt) malloc(sizeof(*context));
 	framework_pt framework = (framework_pt) 0x10;
 	bundle_pt bundle = (bundle_pt) 0x20;
@@ -453,6 +501,8 @@ TEST(bundle_context, addBundleListener) {
 }
 
 TEST(bundle_context, removeBundleListener) {
+	mock().expectOneCall("framework_logCode").withParameter("code", CELIX_ILLEGAL_ARGUMENT);
+
 	bundle_context_pt context = (bundle_context_pt) malloc(sizeof(*context));
 	framework_pt framework = (framework_pt) 0x10;
 	bundle_pt bundle = (bundle_pt) 0x20;
@@ -475,7 +525,49 @@ TEST(bundle_context, removeBundleListener) {
 	LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
 }
 
+TEST(bundle_context, addFrameworkListener){
+		mock().expectOneCall("framework_logCode").withParameter("code", CELIX_ILLEGAL_ARGUMENT);
+
+		bundle_context_pt context = (bundle_context_pt) malloc(sizeof(*context));
+		framework_pt framework = (framework_pt) 0x10;
+		bundle_pt bundle = (bundle_pt) 0x20;
+		context->framework = framework;
+		context->bundle = bundle;
+		framework_listener_pt listener = (framework_listener_pt) 0x30;
+
+	    mock().expectOneCall("fw_addframeworkListener")
+	    		.withParameter("framework", framework)
+	            .withParameter("bundle", bundle)
+	            .withParameter("listener", listener);
+
+		LONGS_EQUAL(CELIX_SUCCESS, bundleContext_addFrameworkListener(context, listener));
+
+		LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, bundleContext_addFrameworkListener(context, NULL));
+}
+
+TEST(bundle_context, removeFrameworkListener){
+		mock().expectOneCall("framework_logCode").withParameter("code", CELIX_ILLEGAL_ARGUMENT);
+
+		bundle_context_pt context = (bundle_context_pt) malloc(sizeof(*context));
+		framework_pt framework = (framework_pt) 0x10;
+		bundle_pt bundle = (bundle_pt) 0x20;
+		context->framework = framework;
+		context->bundle = bundle;
+		framework_listener_pt listener = (framework_listener_pt) 0x30;
+
+	    mock().expectOneCall("fw_removeframeworkListener")
+	    		.withParameter("framework", framework)
+	            .withParameter("bundle", bundle)
+	            .withParameter("listener", listener);
+
+		LONGS_EQUAL(CELIX_SUCCESS, bundleContext_removeFrameworkListener(context, listener));
+
+		LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, bundleContext_removeFrameworkListener(context, NULL));
+}
+
 TEST(bundle_context, getProperty) {
+	mock().expectOneCall("framework_logCode").withParameter("code", CELIX_ILLEGAL_ARGUMENT);
+
 	bundle_context_pt context = (bundle_context_pt) malloc(sizeof(*context));
 	framework_pt framework = (framework_pt) 0x10;
 	bundle_pt bundle = (bundle_pt) 0x20;

http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/test/bundle_revision_test.cpp
----------------------------------------------------------------------
diff --git a/framework/private/test/bundle_revision_test.cpp b/framework/private/test/bundle_revision_test.cpp
index a71b8df..c9fb567 100644
--- a/framework/private/test/bundle_revision_test.cpp
+++ b/framework/private/test/bundle_revision_test.cpp
@@ -35,7 +35,7 @@ extern "C" {
 #include "bundle_revision_private.h"
 #include "celix_log.h"
 
-framework_logger_pt logger;
+framework_logger_pt logger = (framework_logger_pt) 0x10;
 }
 
 int main(int argc, char** argv) {
@@ -44,8 +44,6 @@ int main(int argc, char** argv) {
 
 TEST_GROUP(bundle_revision) {
 	void setup(void) {
-		logger = (framework_logger_pt) malloc(sizeof(*logger));
-        logger->logFunction = frameworkLogger_log;
 	}
 
 	void teardown() {
@@ -71,11 +69,13 @@ TEST(bundle_revision, create) {
             .andReturnValue(CELIX_SUCCESS);
 
 	bundle_revision_pt revision = NULL;
-	celix_status_t status = bundleRevision_create(logger, root, location, revisionNr, inputFile, &revision);
-	LONGS_EQUAL(CELIX_SUCCESS, status);
+	LONGS_EQUAL(CELIX_SUCCESS, bundleRevision_create(root, location, revisionNr, inputFile, &revision));
 	LONGS_EQUAL(revisionNr, revision->revisionNr);
 	STRCMP_EQUAL(root, revision->root);
 	STRCMP_EQUAL(location, revision->location);
+
+    mock().expectOneCall("manifest_destroy");
+	LONGS_EQUAL(CELIX_SUCCESS, bundleRevision_destroy(revision));
 }
 
 TEST(bundle_revision, createWithInput) {
@@ -96,55 +96,62 @@ TEST(bundle_revision, createWithInput) {
         .andReturnValue(CELIX_SUCCESS);
 
 	bundle_revision_pt revision = NULL;
-	celix_status_t status = bundleRevision_create(logger, root, location, revisionNr, inputFile, &revision);
-	LONGS_EQUAL(CELIX_SUCCESS, status);
+	LONGS_EQUAL(CELIX_SUCCESS, bundleRevision_create(root, location, revisionNr, inputFile, &revision));
 	LONGS_EQUAL(revisionNr, revision->revisionNr);
 	STRCMP_EQUAL(root, revision->root);
 	STRCMP_EQUAL(location, revision->location);
+
+    mock().expectOneCall("manifest_destroy");
+	LONGS_EQUAL(CELIX_SUCCESS, bundleRevision_destroy(revision));
 }
 
 TEST(bundle_revision, getters) {
+	mock().expectNCalls(5, "framework_logCode").withParameter("code", CELIX_ILLEGAL_ARGUMENT);
+
 	bundle_revision_pt revision = (bundle_revision_pt) malloc(sizeof(*revision));
 	char root[] = "bundle_revision_test";
 	char location[] = "test_bundle.zip";
 	long revisionNr = 1l;
-	manifest_pt expected = (manifest_pt) 0x42;
+	manifest_pt expectedManifest = (manifest_pt) 0x42;
+	array_list_pt handles = NULL;
+	arrayList_create(&handles);
 	revision->root = root;
 	revision->location = location;
 	revision->revisionNr = revisionNr;
-	revision->manifest = expected;
+	revision->manifest = expectedManifest;
+	revision->libraryHandles = handles;
 
 	char *actualRoot = NULL;
 	char *actualLocation = NULL;
 	long actualRevisionNr = 0l;
 	manifest_pt actualManifest = NULL;
-	celix_status_t status = CELIX_SUCCESS;
+	array_list_pt actualHandles = NULL;
 
-	status = bundleRevision_getNumber(revision, &actualRevisionNr);
-	LONGS_EQUAL(CELIX_SUCCESS, status);
+	LONGS_EQUAL(CELIX_SUCCESS, bundleRevision_getNumber(revision, &actualRevisionNr));
 	LONGS_EQUAL(revisionNr, actualRevisionNr);
 
-	status = bundleRevision_getLocation(revision, &actualLocation);
-	LONGS_EQUAL(CELIX_SUCCESS, status);
+	LONGS_EQUAL(CELIX_SUCCESS, bundleRevision_getLocation(revision, &actualLocation));
 	STRCMP_EQUAL(location, actualLocation);
 
-	status = bundleRevision_getRoot(revision, &actualRoot);
-	LONGS_EQUAL(CELIX_SUCCESS, status);
+	LONGS_EQUAL(CELIX_SUCCESS, bundleRevision_getRoot(revision, &actualRoot));
 	STRCMP_EQUAL(root, actualRoot);
 
-	status = bundleRevision_getManifest(revision, &actualManifest);
-    LONGS_EQUAL(CELIX_SUCCESS, status);
-    POINTERS_EQUAL(expected, actualManifest);
+	LONGS_EQUAL(CELIX_SUCCESS, bundleRevision_getManifest(revision, &actualManifest));
+    POINTERS_EQUAL(expectedManifest, actualManifest);
+
+    LONGS_EQUAL(CELIX_SUCCESS, bundleRevision_getHandles(revision, &actualHandles));
+    POINTERS_EQUAL(handles, actualHandles);
+
+	LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, bundleRevision_getNumber(NULL, &actualRevisionNr));
+
+	LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, bundleRevision_getLocation(NULL, &actualLocation));
 
-	status = bundleRevision_getNumber(NULL, &actualRevisionNr);
-	LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
+	LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, bundleRevision_getRoot(NULL, &actualRoot));
 
-	status = bundleRevision_getLocation(NULL, &actualLocation);
-	LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
+	LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, bundleRevision_getManifest(NULL, &actualManifest));
 
-	status = bundleRevision_getRoot(NULL, &actualRoot);
-	LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
+	LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, bundleRevision_getHandles(NULL, &actualHandles));
 
-	status = bundleRevision_getManifest(NULL, &actualManifest);
-	LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
+	arrayList_destroy(handles);
+	free(revision);
 }

http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/test/bundle_test.cpp
----------------------------------------------------------------------
diff --git a/framework/private/test/bundle_test.cpp b/framework/private/test/bundle_test.cpp
index 58608ec..29fe5e8 100644
--- a/framework/private/test/bundle_test.cpp
+++ b/framework/private/test/bundle_test.cpp
@@ -30,12 +30,15 @@
 #include "CppUTest/TestHarness_c.h"
 #include "CppUTest/CommandLineTestRunner.h"
 #include "CppUTestExt/MockSupport.h"
+#include "string.h"
 
 extern "C" {
+#include "bundle_revision_private.h"
 #include "bundle_private.h"
+#include "utils.h"
 #include "celix_log.h"
 
-framework_logger_pt logger;
+framework_logger_pt logger = (framework_logger_pt) 0x42;
 }
 
 int main(int argc, char** argv) {
@@ -44,35 +47,48 @@ int main(int argc, char** argv) {
 
 TEST_GROUP(bundle) {
 	void setup(void) {
-		logger = (framework_logger_pt) malloc(sizeof(*logger));
-        logger->logFunction = frameworkLogger_log;
 	}
 
-	void teardown() {
+	void teardown(void) {
 		mock().checkExpectations();
 		mock().clear();
 	}
 };
 
+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(bundle, create) {
 	bundle_archive_pt archive = (bundle_archive_pt) 0x10;
 	mock().expectOneCall("bundleArchive_createSystemBundleArchive")
-			.withParameter("logger", logger)
-			.withOutputParameterReturning("bundle_archive", &archive, sizeof(archive))
-			.andReturnValue(CELIX_SUCCESS);
+							.withOutputParameterReturning("bundle_archive", &archive, sizeof(archive))
+							.andReturnValue(CELIX_SUCCESS);
 
 	module_pt module = (module_pt) 0x20;
 	mock().expectOneCall("module_createFrameworkModule")
-			.ignoreOtherParameters()
-			.andReturnValue(module);
+							.ignoreOtherParameters()
+							.andReturnValue(module);
 
 	mock().expectOneCall("resolver_addModule")
-			.withParameter("module", module);
-	mock().expectOneCall("resolver_addModule")
-			.withParameter("module", module);
+							.withParameter("module", module);
 
 	bundle_pt actual = NULL;
-	celix_status_t status = bundle_create(&actual, logger);
+	celix_status_t status = bundle_create(&actual);
 	LONGS_EQUAL(CELIX_SUCCESS, status);
 	POINTERS_EQUAL(NULL, actual->context);
 	POINTERS_EQUAL(NULL, actual->activator);
@@ -81,10 +97,13 @@ TEST(bundle, create) {
 	POINTERS_EQUAL(archive, actual->archive);
 	CHECK(actual->modules);
 	POINTERS_EQUAL(NULL, actual->manifest);
-//	CHECK(actual->lock)
+	//	CHECK(actual->lock)
 	LONGS_EQUAL(0, actual->lockCount);
 	POINTERS_EQUAL(NULL, actual->lockThread.thread);
 	POINTERS_EQUAL(NULL, actual->framework);
+
+	mock().expectOneCall("module_destroy");
+	bundle_destroy(actual);
 }
 
 TEST(bundle, createFromArchive) {
@@ -94,52 +113,48 @@ TEST(bundle, createFromArchive) {
 	manifest_pt manifest = (manifest_pt) 0x30;
 
 	mock().expectOneCall("bundleArchive_getCurrentRevision")
-        .withParameter("archive", archive)
-        .withOutputParameterReturning("revision", &revision, sizeof(revision))
-        .andReturnValue(CELIX_SUCCESS);
+        				.withParameter("archive", archive)
+        				.withOutputParameterReturning("revision", &revision, sizeof(revision))
+        				.andReturnValue(CELIX_SUCCESS);
 
 	mock().expectOneCall("bundleRevision_getManifest")
-		.withParameter("revision", revision)
-		.withOutputParameterReturning("manifest", &manifest, sizeof(manifest))
-		.andReturnValue(CELIX_SUCCESS);
+						.withParameter("revision", revision)
+						.withOutputParameterReturning("manifest", &manifest, sizeof(manifest))
+						.andReturnValue(CELIX_SUCCESS);
 
-	// CPPUTest has no build in support for longs, which breaks this test.
 	long id = 1;
 	mock().expectOneCall("bundleArchive_getId")
-		.withParameter("archive", archive)
-		.withOutputParameterReturning("id", &id, sizeof(id))
-		.andReturnValue(CELIX_SUCCESS);
+						.withParameter("archive", archive)
+						.withOutputParameterReturning("id", &id, sizeof(id))
+						.andReturnValue(CELIX_SUCCESS);
 
 	module_pt module = (module_pt) 0x40;
 	mock().expectOneCall("module_create")
-		.withParameter("headerMap", manifest)
-//		.withParameter("moduleId", "1.0")
-//		.withParameter("bundle", (void *) 0x40)
-		.ignoreOtherParameters()
-		.andReturnValue(module);
+						.withParameter("headerMap", manifest)
+						//		.withParameter("moduleId", "1.0")
+						//		.withParameter("bundle", (void *) 0x40)
+						.ignoreOtherParameters()
+						.andReturnValue(module);
 
 	version_pt version = (version_pt) 0x50;
 	mock().expectOneCall("module_getVersion")
-		.withParameter("module", module)
-		.andReturnValue(version);
+						.withParameter("module", module)
+						.andReturnValue(version);
 
 	char symbolicName[] = "name";
 	mock().expectOneCall("module_getSymbolicName")
-		.withParameter("module", module)
-		.withOutputParameterReturning("symbolicName", &symbolicName, sizeof(symbolicName))
-		.andReturnValue(CELIX_SUCCESS);
+						.withParameter("module", module)
+						.withOutputParameterReturning("symbolicName", &symbolicName, sizeof(symbolicName))
+						.andReturnValue(CELIX_SUCCESS);
 
 	array_list_pt bundles = NULL;
 	arrayList_create(&bundles);
 	mock().expectOneCall("framework_getBundles")
-		.withParameter("framework", framework)
-		.andReturnValue(bundles);
-
-	mock().expectOneCall("resolver_addModule")
-		.withParameter("module", module);
+						.withParameter("framework", framework)
+						.andReturnValue(bundles);
 
 	mock().expectOneCall("resolver_addModule")
-		.withParameter("module", module);
+						.withParameter("module", module);
 
 	bundle_pt actual = NULL;
 	celix_status_t status = bundle_createFromArchive(&actual, framework, archive);
@@ -151,10 +166,16 @@ TEST(bundle, createFromArchive) {
 	POINTERS_EQUAL(archive, actual->archive);
 	CHECK(actual->modules);
 	POINTERS_EQUAL(NULL, actual->manifest);
-//	CHECK(actual->lock)
+	//	CHECK(actual->lock)
 	LONGS_EQUAL(0, actual->lockCount);
 	POINTERS_EQUAL(NULL, actual->lockThread.thread);
 	POINTERS_EQUAL(framework, actual->framework);
+
+	arrayList_destroy(actual->modules);
+	free(actual);
+
+
+	mock().clear();
 }
 
 TEST(bundle, getArchive) {
@@ -163,13 +184,19 @@ TEST(bundle, getArchive) {
 	bundle->archive = archive;
 
 	bundle_archive_pt actual = NULL;
-	celix_status_t status = bundle_getArchive(bundle, &actual);
-	LONGS_EQUAL(CELIX_SUCCESS, status);
+	LONGS_EQUAL(CELIX_SUCCESS, bundle_getArchive(bundle, &actual));
 	POINTERS_EQUAL(archive, actual);
 
+	mock().expectOneCall("framework_logCode")
+							.withParameter("code", CELIX_ILLEGAL_ARGUMENT);
+
 	actual = NULL;
-	status = bundle_getArchive(NULL, &actual);
-	LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
+	LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, bundle_getArchive(NULL, &actual));
+
+	free(bundle);
+
+
+	mock().clear();
 }
 
 TEST(bundle, getCurrentModule) {
@@ -192,6 +219,9 @@ TEST(bundle, getCurrentModule) {
 	actual = NULL;
 	status = bundle_getCurrentModule(NULL, &actual);
 	LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
+
+	arrayList_destroy(bundle->modules);
+	free(bundle);
 }
 
 TEST(bundle, getModules) {
@@ -201,6 +231,8 @@ TEST(bundle, getModules) {
 
 	array_list_pt actual = bundle_getModules(bundle);
 	POINTERS_EQUAL(modules, actual);
+
+	free(bundle);
 }
 
 TEST(bundle, getHandle) {
@@ -210,6 +242,8 @@ TEST(bundle, getHandle) {
 
 	void *actual = bundle_getHandle(bundle);
 	POINTERS_EQUAL(expected, actual);
+
+	free(bundle);
 }
 
 TEST(bundle, setHandle) {
@@ -218,6 +252,8 @@ TEST(bundle, setHandle) {
 
 	bundle_setHandle(bundle, expected);
 	POINTERS_EQUAL(expected, bundle->handle);
+
+	free(bundle);
 }
 
 TEST(bundle, getActivator) {
@@ -227,6 +263,8 @@ TEST(bundle, getActivator) {
 
 	activator_pt actual = bundle_getActivator(bundle);
 	POINTERS_EQUAL(expected, actual);
+
+	free(bundle);
 }
 
 TEST(bundle, setActivator) {
@@ -236,6 +274,8 @@ TEST(bundle, setActivator) {
 	celix_status_t status = bundle_setActivator(bundle, expected);
 	LONGS_EQUAL(CELIX_SUCCESS, status);
 	POINTERS_EQUAL(expected, bundle->activator);
+
+	free(bundle);
 }
 
 TEST(bundle, getContext) {
@@ -247,6 +287,8 @@ TEST(bundle, getContext) {
 	celix_status_t status = bundle_getContext(bundle, &actual);
 	LONGS_EQUAL(CELIX_SUCCESS, status);
 	POINTERS_EQUAL(expected, actual);
+
+	free(bundle);
 }
 
 TEST(bundle, setContext) {
@@ -256,6 +298,8 @@ TEST(bundle, setContext) {
 	celix_status_t status = bundle_setContext(bundle, expected);
 	LONGS_EQUAL(CELIX_SUCCESS, status);
 	POINTERS_EQUAL(expected, bundle->context);
+
+	free(bundle);
 }
 
 TEST(bundle, getEntry) {
@@ -266,16 +310,18 @@ TEST(bundle, getEntry) {
 	char name[] = "name";
 	char *expected = (char *) 0x20;
 	mock().expectOneCall("framework_getBundleEntry")
-		.withParameter("framework", framework)
-		.withParameter("bundle", bundle)
-		.withParameter("name", name)
-		.withOutputParameterReturning("entry", &expected, sizeof(expected))
-		.andReturnValue(CELIX_SUCCESS);
+						.withParameter("framework", framework)
+						.withParameter("bundle", bundle)
+						.withParameter("name", name)
+						.withOutputParameterReturning("entry", &expected, sizeof(expected))
+						.andReturnValue(CELIX_SUCCESS);
 
 	char *actual = NULL;
 	celix_status_t status = bundle_getEntry(bundle, name, &actual);
 	LONGS_EQUAL(CELIX_SUCCESS, status);
 	POINTERS_EQUAL(expected, actual);
+
+	free(bundle);
 }
 
 TEST(bundle, getState) {
@@ -283,9 +329,14 @@ TEST(bundle, getState) {
 	bundle->state = OSGI_FRAMEWORK_BUNDLE_ACTIVE;
 
 	bundle_state_e actual = OSGI_FRAMEWORK_BUNDLE_UNKNOWN;
-	celix_status_t status = bundle_getState(bundle, &actual);
-	LONGS_EQUAL(CELIX_SUCCESS, status);
+	LONGS_EQUAL(CELIX_SUCCESS, bundle_getState(bundle, &actual));
 	POINTERS_EQUAL(OSGI_FRAMEWORK_BUNDLE_ACTIVE, actual);
+
+	//get unknown bundle's state
+	LONGS_EQUAL(CELIX_BUNDLE_EXCEPTION, bundle_getState((bundle_pt)NULL, &actual));
+	POINTERS_EQUAL(OSGI_FRAMEWORK_BUNDLE_UNKNOWN, actual);
+
+	free(bundle);
 }
 
 TEST(bundle, setState) {
@@ -295,8 +346,115 @@ TEST(bundle, setState) {
 	celix_status_t status = bundle_setState(bundle, OSGI_FRAMEWORK_BUNDLE_INSTALLED);
 	LONGS_EQUAL(CELIX_SUCCESS, status);
 	POINTERS_EQUAL(OSGI_FRAMEWORK_BUNDLE_INSTALLED, bundle->state);
+
+	free(bundle);
 }
 
+/*//declared here, since its non-static, but not actually exported by bundle.h or bundle_private.h
+extern celix_status_t bundle_createModule(bundle_pt bundle, module_pt *module);
+
+TEST(bundle, createModule){
+	bundle_pt bundle = (bundle_pt) malloc(sizeof(*bundle));
+
+	module_pt module = (module_pt) 0x01;
+	module_pt module2 = (module_pt) 0x02;
+	module_pt module3 = (module_pt) 0x03;
+	arrayList_create(&bundle->modules);
+	arrayList_add(bundle->modules, module);
+	arrayList_add(bundle->modules, module2);
+	arrayList_add(bundle->modules, module3);
+
+	framework_pt framework = (framework_pt) 0x04;
+	bundle->framework = framework;
+
+	bundle_archive_pt archive = (bundle_archive_pt) 0x05;
+	bundle->archive = archive;
+
+	module_pt module_new = (module_pt) 0x06;
+	bundle_revision_pt revision = (bundle_revision_pt) 0x07;
+	version_pt version = (version_pt) 0x08;
+	manifest_pt manifest = (manifest_pt) 0x09;
+
+	long id = 666;
+	char * symbolicName = my_strdup("name");
+
+	bundle_pt bundle2 = (bundle_pt) malloc(sizeof(*bundle));
+	module_pt module4 = (module_pt) 0x0A;
+	arrayList_create(&bundle2->modules);
+	arrayList_add(bundle2->modules, module4);
+	bundle2->framework = framework;
+
+	bundle_archive_pt archive2 = (bundle_archive_pt) 0x0B;
+	bundle2->archive = archive2;
+
+	version_pt version2 = (version_pt) 0x0C;
+	long id2 = 667;
+
+	array_list_pt bundles;
+	arrayList_create(&bundles);
+	arrayList_add(bundles, bundle2);
+
+	//expected calls from bundle_createModule
+	mock().expectOneCall("bundleArchive_getCurrentRevision")
+			.withParameter("archive", archive)
+        	.withOutputParameterReturning("revision", &revision, sizeof(revision));
+
+	mock().expectOneCall("bundleRevision_getManifest")
+			.withParameter("revision", revision)
+			.withOutputParameterReturning("manifest", &manifest, sizeof(manifest));
+
+	mock().expectOneCall("bundleArchive_getId")
+			.withParameter("archive", archive)
+			.withOutputParameterReturning("id", &id, sizeof(id));
+
+	mock().expectOneCall("module_create")
+			.withParameter("headerMap", manifest)
+			.withParameter("moduleId", "666.0")
+			.withParameter("bundle", bundle)
+			.andReturnValue(module_new);
+
+	mock().expectOneCall("module_getVersion")
+			.withParameter("module", module_new)
+			.andReturnValue(version);
+
+	mock().expectOneCall("module_getSymbolicName")
+			.withParameter("module", module_new)
+			.withOutputParameterReturning("symbolicName", &symbolicName, sizeof(char*));
+
+	mock().expectOneCall("framework_getBundles")
+			.withParameter("framework", framework)
+			.andReturnValue(bundles);
+
+	mock().expectOneCall("bundleArchive_getId")
+			.withParameter("archive", archive2)
+			.withOutputParameterReturning("id", &id2, sizeof(id2));
+
+	//returning same symbolic name for module_new as for module4
+	mock().expectOneCall("module_getSymbolicName")
+			.withParameter("module", module4)
+			.withOutputParameterReturning("symbolicName", &symbolicName, sizeof(char*));
+
+	//returning different version for module_new as for module4
+	mock().expectOneCall("module_getVersion")
+			.withParameter("module", module4)
+			.andReturnValue(version2);
+
+	int result = 1; //1 means not equal
+	mock().expectOneCall("version_compareTo")
+			.withParameter("version", version)
+			.withParameter("compare", version2)
+			.withOutputParameterReturning("result", &result,sizeof(result));
+
+	LONGS_EQUAL(CELIX_SUCCESS, bundle_createModule(bundle, &module_new));
+
+	arrayList_destroy(bundle->modules);
+	arrayList_destroy(bundle2->modules);
+
+	free(bundle);
+	free(bundle2);
+	free(symbolicName);
+}*/
+
 TEST(bundle, start) {
 	bundle_pt bundle = (bundle_pt) malloc(sizeof(*bundle));
 	framework_pt framework = (framework_pt) 0x10;
@@ -307,19 +465,30 @@ TEST(bundle, start) {
 	int options = 42;
 
 	long id = 1;
-	mock().expectOneCall("bundleArchive_getId")
-        .withParameter("archive", archive)
-        .withOutputParameterReturning("id", &id, sizeof(id))
-        .andReturnValue(CELIX_SUCCESS);
+	mock().expectNCalls(2, "bundleArchive_getId")
+        				.withParameter("archive", archive)
+        				.withOutputParameterReturning("id", &id, sizeof(id))
+        				.andReturnValue(CELIX_SUCCESS);
 
 	mock().expectOneCall("fw_startBundle")
-		.withParameter("framework", framework)
-		.withParameter("bundle", bundle)
-		.withParameter("options", options)
-		.andReturnValue(CELIX_SUCCESS);
+						.withParameter("framework", framework)
+						.withParameter("bundle", bundle)
+						.withParameter("options", options)
+						.andReturnValue(CELIX_SUCCESS);
 
 	celix_status_t status = bundle_startWithOptions(bundle, options);
 	LONGS_EQUAL(CELIX_SUCCESS, status);
+
+	mock().expectOneCall("fw_startBundle")
+						.withParameter("framework", framework)
+						.withParameter("bundle", bundle)
+						.withParameter("options", 0)
+						.andReturnValue(CELIX_SUCCESS);
+
+	status = bundle_start(bundle);
+	LONGS_EQUAL(CELIX_SUCCESS, status);
+
+	free(bundle);
 }
 
 TEST(bundle, update) {
@@ -331,19 +500,21 @@ TEST(bundle, update) {
 
 	long id = 1;
 	mock().expectOneCall("bundleArchive_getId")
-        .withParameter("archive", archive)
-        .withOutputParameterReturning("id", &id, sizeof(id))
-        .andReturnValue(CELIX_SUCCESS);
+        				.withParameter("archive", archive)
+        				.withOutputParameterReturning("id", &id, sizeof(id))
+        				.andReturnValue(CELIX_SUCCESS);
 
 	char input[] = "input";
 	mock().expectOneCall("framework_updateBundle")
-		.withParameter("framework", framework)
-		.withParameter("bundle", bundle)
-		.withParameter("inputFile", input)
-		.andReturnValue(CELIX_SUCCESS);
+						.withParameter("framework", framework)
+						.withParameter("bundle", bundle)
+						.withParameter("inputFile", input)
+						.andReturnValue(CELIX_SUCCESS);
 
 	celix_status_t status = bundle_update(bundle, input);
 	LONGS_EQUAL(CELIX_SUCCESS, status);
+
+	free(bundle);
 }
 
 TEST(bundle, stop) {
@@ -354,43 +525,67 @@ TEST(bundle, stop) {
 	bundle->archive = archive;
 
 	long id = 1;
-	mock().expectOneCall("bundleArchive_getId")
-	        .withParameter("archive", archive)
-	        .withOutputParameterReturning("id", &id, sizeof(id))
-	        .andReturnValue(CELIX_SUCCESS);
+	mock().expectNCalls(2, "bundleArchive_getId")
+	        				.withParameter("archive", archive)
+	        				.withOutputParameterReturning("id", &id, sizeof(id))
+	        				.andReturnValue(CELIX_SUCCESS);
 
 	int options = 1;
 	mock().expectOneCall("fw_stopBundle")
-		.withParameter("framework", framework)
-		.withParameter("bundle", bundle)
-		.withParameter("record", 1)
-		.andReturnValue(CELIX_SUCCESS);
+						.withParameter("framework", framework)
+						.withParameter("bundle", bundle)
+						.withParameter("record", 1)
+						.andReturnValue(CELIX_SUCCESS);
 
 	celix_status_t status = bundle_stopWithOptions(bundle, options);
 	LONGS_EQUAL(CELIX_SUCCESS, status);
+
+	mock().expectOneCall("fw_stopBundle")
+						.withParameter("framework", framework)
+						.withParameter("bundle", bundle)
+						.withParameter("record", 0)
+						.andReturnValue(CELIX_SUCCESS);
+
+	status = bundle_stop(bundle);
+	LONGS_EQUAL(CELIX_SUCCESS, status);
+
+	free(bundle);
 }
 
-//TEST(bundle, uninstall) {
-//	bundle_pt bundle = (bundle_pt) malloc(sizeof(*bundle));
-//	framework_pt framework = (framework_pt) 0x10;
-//	bundle_archive_pt archive = (bundle_archive_pt) 0x20;
-//	bundle->framework = framework;
-//	bundle->archive = archive;
-//
-//	long id = 0;
-//	mock().expectOneCall("bundleArchive_getId")
-//        .withParameter("archive", archive)
-//        .withOutputParameterReturning("id", &id, sizeof(id))
-//        .andReturnValue(CELIX_SUCCESS);
-//
-//	mock().expectOneCall("fw_uninstallBundle")
-//		.withParameter("framework", framework)
-//		.withParameter("bundle", bundle)
-//		.andReturnValue(CELIX_SUCCESS);
-//
-//	celix_status_t status = bundle_uninstall(bundle);
-//	LONGS_EQUAL(CELIX_SUCCESS, status);
-//}
+TEST(bundle, uninstall) {
+	bundle_pt bundle = (bundle_pt) malloc(sizeof(*bundle));
+	framework_pt framework = (framework_pt) 0x10;
+	bundle_archive_pt archive = (bundle_archive_pt) 0x20;
+	bundle->framework = framework;
+	bundle->archive = archive;
+
+	long id = 666;
+	mock().expectOneCall("bundleArchive_getId")
+        				.withParameter("archive", archive)
+        				.withOutputParameterReturning("id", &id, sizeof(id))
+        				.andReturnValue(CELIX_SUCCESS);
+
+	mock().expectOneCall("fw_uninstallBundle")
+		.withParameter("framework", framework)
+		.withParameter("bundle", bundle)
+		.andReturnValue(CELIX_SUCCESS);
+
+	LONGS_EQUAL(CELIX_SUCCESS, bundle_uninstall(bundle));
+
+	//attempt to uninstall framework bundle
+	id = 0;
+	mock().expectOneCall("bundleArchive_getId")
+        				.withParameter("archive", archive)
+        				.withOutputParameterReturning("id", &id, sizeof(id))
+        				.andReturnValue(CELIX_SUCCESS);
+
+	mock().expectOneCall("framework_logCode")
+							.withParameter("code", CELIX_BUNDLE_EXCEPTION);
+
+	LONGS_EQUAL(CELIX_BUNDLE_EXCEPTION, bundle_uninstall(bundle));
+
+	free(bundle);
+}
 
 TEST(bundle, setPersistentStateInactive) {
 	bundle_pt bundle = (bundle_pt) malloc(sizeof(*bundle));
@@ -399,17 +594,18 @@ TEST(bundle, setPersistentStateInactive) {
 
 	long id = 1;
 	mock().expectOneCall("bundleArchive_getId")
-		.withParameter("archive", archive)
-		.withOutputParameterReturning("id", &id, sizeof(id))
-		.andReturnValue(CELIX_SUCCESS);
+						.withParameter("archive", archive)
+						.withOutputParameterReturning("id", &id, sizeof(id))
+						.andReturnValue(CELIX_SUCCESS);
 
 	mock().expectOneCall("bundleArchive_setPersistentState")
-		.withParameter("archive", archive)
-		.withParameter("state", OSGI_FRAMEWORK_BUNDLE_INSTALLED)
-		.andReturnValue(CELIX_SUCCESS);
+						.withParameter("archive", archive)
+						.withParameter("state", OSGI_FRAMEWORK_BUNDLE_INSTALLED)
+						.andReturnValue(CELIX_SUCCESS);
 
-	celix_status_t status = bundle_setPersistentStateInactive(bundle);
-	LONGS_EQUAL(CELIX_SUCCESS, status);
+	LONGS_EQUAL(CELIX_SUCCESS, bundle_setPersistentStateInactive(bundle));
+
+	free(bundle);
 }
 
 TEST(bundle, setPersistentStateUninstalled) {
@@ -419,84 +615,430 @@ TEST(bundle, setPersistentStateUninstalled) {
 
 	long id = 1;
 	mock().expectOneCall("bundleArchive_getId")
-		.withParameter("archive", archive)
-		.withOutputParameterReturning("id", &id, sizeof(id))
-		.andReturnValue(CELIX_SUCCESS);
+						.withParameter("archive", archive)
+						.withOutputParameterReturning("id", &id, sizeof(id))
+						.andReturnValue(CELIX_SUCCESS);
 
 	mock().expectOneCall("bundleArchive_setPersistentState")
-		.withParameter("archive", archive)
-		.withParameter("state", OSGI_FRAMEWORK_BUNDLE_UNINSTALLED)
-		.andReturnValue(CELIX_SUCCESS);
+						.withParameter("archive", archive)
+						.withParameter("state", OSGI_FRAMEWORK_BUNDLE_UNINSTALLED)
+						.andReturnValue(CELIX_SUCCESS);
 
 	celix_status_t status = bundle_setPersistentStateUninstalled(bundle);
 	LONGS_EQUAL(CELIX_SUCCESS, status);
+
+	free(bundle);
 }
 
 TEST(bundle, revise) {
 	bundle_pt bundle = (bundle_pt) malloc(sizeof(*bundle));
-
+	arrayList_create(&bundle->modules);
+	bundle_archive_pt actual_archive = (bundle_archive_pt) 0x02;
+	bundle_revision_pt actual_revision = (bundle_revision_pt) malloc(sizeof(actual_revision));
+	manifest_pt actual_manifest = (manifest_pt) malloc(sizeof(*actual_manifest));
+	int actual_id = 666;
+	const char * actual_module_id = "666.0";
+	bundle->archive = actual_archive;
+	char * symbolic_name = NULL;
 	char location[] = "location";
 	char inputFile[] = "inputFile";
-//	celix_status_t status = bundle_revise(bundle, location, inputFile);
+
+	mock().expectNCalls(2, "bundleArchive_revise");
+
+	mock().expectNCalls(2, "bundleArchive_getCurrentRevision")
+			.withParameter("archive", bundle->archive)
+			.withOutputParameterReturning("revision", &actual_revision, sizeof(actual_revision));
+
+	mock().expectNCalls(2, "bundleRevision_getManifest")
+			.withParameter("revision", actual_revision)
+			.withOutputParameterReturning("manifest", &actual_manifest, sizeof(actual_manifest));
+
+	mock().expectNCalls(2, "bundleArchive_getId")
+			.withParameter("archive", actual_archive)
+			.withOutputParameterReturning("id", &actual_id, sizeof(actual_id));
+
+	mock().expectOneCall("module_create")
+			.withParameter("headerMap", actual_manifest)
+			.withParameter("moduleId", actual_module_id)
+			.withParameter("bundle", bundle);
+
+	//module create returns NULL during test
+	mock().expectOneCall("resolver_addModule")
+			.withParameter("module", (void*)NULL);
+
+	LONGS_EQUAL(CELIX_SUCCESS, bundle_revise(bundle, location, inputFile));
+
+	mock().expectOneCall("module_create")
+			.withParameter("headerMap", actual_manifest)
+			.withParameter("moduleId", actual_module_id)
+			.withParameter("bundle", bundle)
+			.andReturnValue((void*)0x01);
+
+	mock().expectOneCall("module_getVersion")
+			.withParameter("module", (void*)0x01);
+
+	mock().expectOneCall("module_getSymbolicName")
+			.withParameter("module", (void*)0x01)
+			.withOutputParameterReturning("symbolicName", &symbolic_name,sizeof(symbolic_name))
+			.andReturnValue(CELIX_ILLEGAL_ARGUMENT);
+
+	mock().expectOneCall("bundleArchive_rollbackRevise");
+
+	mock().expectOneCall("framework_logCode")
+			.withParameter("code", CELIX_ILLEGAL_ARGUMENT);
+
+	mock().expectOneCall("framework_logCode")
+			.withParameter("code", CELIX_BUNDLE_EXCEPTION);
+
+	LONGS_EQUAL(CELIX_BUNDLE_EXCEPTION, bundle_revise(bundle, location, inputFile));
+
+	arrayList_destroy(bundle->modules);
+	free(bundle);
+	free(actual_revision);
+	free(actual_manifest);
 }
 
 TEST(bundle, isLockable) {
 	bundle_pt bundle = (bundle_pt) malloc(sizeof(*bundle));
 	celixThreadMutex_create(&bundle->lock, NULL);
+	bundle->lockCount = 0;
 
 	bool lockable = false;
 	celix_status_t status = bundle_isLockable(bundle, &lockable);
-//	FAIL("Test not fully implemented");
-}
+	//	FAIL("Test not fully implemented");
 
-TEST(bundle, getLockingThread) {
-//	FAIL("Test not fully implemented");
+	free(bundle);
 }
 
-TEST(bundle, lock) {
-//	FAIL("Test not fully implemented");
-}
 
-TEST(bundle, unlock) {
-//	FAIL("Test not fully implemented");
+TEST(bundle, lockingThread) {
+	bundle_pt bundle = (bundle_pt) malloc(sizeof(*bundle));
+	celixThreadMutex_create(&bundle->lock, NULL);
+	celix_thread_t thread;
+
+	bundle->lockCount = 0;
+
+	bool locked = false;
+	LONGS_EQUAL(CELIX_SUCCESS, bundle_lock(bundle, &locked));
+	CHECK(locked);
+	LONGS_EQUAL(1, bundle->lockCount);
+
+	LONGS_EQUAL(CELIX_SUCCESS, bundle_getLockingThread(bundle, &thread));
+	bool equals;
+	thread_equalsSelf(thread, &equals);
+	CHECK(equals);
+
+	bool unlocked;
+	bundle->lockCount = 1;
+	LONGS_EQUAL(CELIX_SUCCESS, bundle_unlock(bundle, &unlocked));
+	CHECK(unlocked);
+	LONGS_EQUAL(0, bundle->lockCount);
+
+	//try to unlock unlocked lock
+	LONGS_EQUAL(CELIX_SUCCESS, bundle_unlock(bundle, &unlocked));
+	CHECK_FALSE(unlocked);
+	LONGS_EQUAL(0, bundle->lockCount);
+
+	celixThreadMutex_destroy(&bundle->lock);
+	free(bundle);
 }
 
 TEST(bundle, close) {
-//	FAIL("Test not fully implemented");
+	bundle_pt bundle = (bundle_pt) malloc(sizeof(*bundle));
+
+	module_pt module = (module_pt) 0x01;
+	module_pt module2 = (module_pt) 0x02;
+	module_pt module3 = (module_pt) 0x03;
+	arrayList_create(&bundle->modules);
+	arrayList_add(bundle->modules, module);
+	arrayList_add(bundle->modules, module2);
+	arrayList_add(bundle->modules, module3);
+
+	bundle_archive_pt archive = (bundle_archive_pt) 0x05;
+	bundle->archive = archive;
+
+	mock().expectOneCall("resolver_removeModule")
+			.withParameter("module", module);
+
+	mock().expectOneCall("resolver_removeModule")
+			.withParameter("module", module2);
+
+	mock().expectOneCall("resolver_removeModule")
+			.withParameter("module", module3);
+
+	mock().expectNCalls(3, "module_setWires");
+
+	mock().expectOneCall("bundleArchive_close")
+			.withParameter("archive", archive);
+
+	LONGS_EQUAL(CELIX_SUCCESS, bundle_close(bundle));
+
+	arrayList_destroy(bundle->modules);
+	free(bundle);
 }
 
 TEST(bundle, closeAndDelete) {
-//	FAIL("Test not fully implemented");
+	bundle_archive_pt archive = (bundle_archive_pt) 0x10;
+	mock().expectOneCall("bundleArchive_createSystemBundleArchive")
+								.withOutputParameterReturning("bundle_archive", &archive, sizeof(archive))
+								.andReturnValue(CELIX_SUCCESS);
+
+	module_pt module = (module_pt) 0x20;
+	mock().expectOneCall("module_createFrameworkModule")
+								.ignoreOtherParameters()
+								.andReturnValue(module);
+
+	mock().expectOneCall("resolver_addModule")
+								.withParameter("module", module);
+
+	bundle_pt actual = NULL;
+	celix_status_t status = bundle_create(&actual);
+	LONGS_EQUAL(CELIX_SUCCESS, status);
+
+	mock().expectOneCall("resolver_removeModule")
+			.withParameter("module", module);
+
+	mock().expectOneCall("module_setWires");
+
+	mock().expectOneCall("bundleArchive_closeAndDelete");
+
+	status = bundle_closeAndDelete(actual);
+	LONGS_EQUAL(CELIX_SUCCESS, status);
+
+	arrayList_destroy(actual->modules);
+	free(actual);
 }
 
 TEST(bundle, closeModules) {
-//	FAIL("Test not fully implemented");
+	bundle_pt bundle = (bundle_pt) malloc(sizeof(*bundle));
+	module_pt module = (module_pt) 0x01;
+	module_pt module2 = (module_pt) 0x02;
+	module_pt module3 = (module_pt) 0x03;
+
+	arrayList_create(&bundle->modules);
+	arrayList_add(bundle->modules, module);
+	arrayList_add(bundle->modules, module2);
+	arrayList_add(bundle->modules, module3);
+
+	mock().expectOneCall("resolver_removeModule")
+			.withParameter("module", module);
+
+	mock().expectOneCall("resolver_removeModule")
+			.withParameter("module", module2);
+
+	mock().expectOneCall("resolver_removeModule")
+			.withParameter("module", module3);
+
+	mock().expectNCalls(3, "module_setWires");
+
+	bundle_closeModules(bundle);
+
+	arrayList_destroy(bundle->modules);
+	free(bundle);
 }
 
 TEST(bundle, refresh) {
-//	FAIL("Test not fully implemented");
+	bundle_pt bundle = (bundle_pt) malloc(sizeof(*bundle));
+
+	module_pt module = (module_pt) 0x01;
+	module_pt module2 = (module_pt) 0x02;
+	module_pt module3 = (module_pt) 0x03;
+	arrayList_create(&bundle->modules);
+	arrayList_add(bundle->modules, module);
+	arrayList_add(bundle->modules, module2);
+	arrayList_add(bundle->modules, module3);
+
+	framework_pt framework = (framework_pt) 0x04;
+	bundle->framework = framework;
+
+	bundle_archive_pt archive = (bundle_archive_pt) 0x05;
+	bundle->archive = archive;
+
+	module_pt module_new = (module_pt) 0x06;
+	bundle_revision_pt revision = (bundle_revision_pt) 0x07;
+	version_pt version = (version_pt) 0x08;
+	manifest_pt manifest = (manifest_pt) 0x09;
+
+	long id = 666;
+	char * symbolicName = my_strdup("name");
+
+	bundle_pt bundle2 = (bundle_pt) malloc(sizeof(*bundle));
+	module_pt module4 = (module_pt) 0x0A;
+	arrayList_create(&bundle2->modules);
+	arrayList_add(bundle2->modules, module4);
+	bundle2->framework = framework;
+
+	bundle_archive_pt archive2 = (bundle_archive_pt) 0x0B;
+	bundle2->archive = archive2;
+
+	version_pt version2 = (version_pt) 0x0C;
+	long id2 = 667;
+
+	array_list_pt bundles;
+	arrayList_create(&bundles);
+	arrayList_add(bundles, bundle2);
+
+	//expected calls from bundle_refresh
+	mock().expectOneCall("resolver_removeModule")
+			.withParameter("module", module);
+
+	mock().expectOneCall("resolver_removeModule")
+			.withParameter("module", module2);
+
+	mock().expectOneCall("resolver_removeModule")
+			.withParameter("module", module3);
+
+	mock().expectNCalls(3, "module_setWires");
+
+	//expected calls from bundle_createModule
+	mock().expectOneCall("bundleArchive_getCurrentRevision")
+			.withParameter("archive", archive)
+        	.withOutputParameterReturning("revision", &revision, sizeof(revision));
+
+	mock().expectOneCall("bundleRevision_getManifest")
+			.withParameter("revision", revision)
+			.withOutputParameterReturning("manifest", &manifest, sizeof(manifest));
+
+	mock().expectOneCall("bundleArchive_getId")
+			.withParameter("archive", archive)
+			.withOutputParameterReturning("id", &id, sizeof(id));
+
+	mock().expectOneCall("module_create")
+			.withParameter("headerMap", manifest)
+			.withParameter("moduleId", "666.0")
+			.withParameter("bundle", bundle)
+			.andReturnValue(module_new);
+
+	mock().expectOneCall("module_getVersion")
+			.withParameter("module", module_new)
+			.andReturnValue(version);
+
+	mock().expectOneCall("module_getSymbolicName")
+			.withParameter("module", module_new)
+			.withOutputParameterReturning("symbolicName", &symbolicName, sizeof(char*));
+
+	mock().expectOneCall("framework_getBundles")
+			.withParameter("framework", framework)
+			.andReturnValue(bundles);
+
+	mock().expectOneCall("bundleArchive_getId")
+			.withParameter("archive", archive2)
+			.withOutputParameterReturning("id", &id2, sizeof(id2));
+
+	//returning same symbolic name for module_new as for module4
+	mock().expectOneCall("module_getSymbolicName")
+			.withParameter("module", module4)
+			.withOutputParameterReturning("symbolicName", &symbolicName, sizeof(char*));
+
+	//returning different version for module_new as for module4
+	mock().expectOneCall("module_getVersion")
+			.withParameter("module", module4)
+			.andReturnValue(version2);
+
+	int result = 1; //1 means not equal
+	mock().expectOneCall("version_compareTo")
+			.withParameter("version", version)
+			.withParameter("compare", version2)
+			.withOutputParameterReturning("result", &result,sizeof(result));
+
+	//expected calls from bundle_addModule
+	mock().expectOneCall("resolver_addModule")
+			.withParameter("module", module_new);
+
+	LONGS_EQUAL(CELIX_SUCCESS, bundle_refresh(bundle));
+
+	arrayList_destroy(bundle->modules);
+	arrayList_destroy(bundle2->modules);
+
+	free(bundle);
+	free(bundle2);
+	free(symbolicName);
 }
 
 TEST(bundle, getBundleId) {
-//	FAIL("Test not fully implemented");
+	bundle_pt bundle = (bundle_pt) malloc(sizeof(*bundle));
+	bundle_archive_pt actual_archive = (bundle_archive_pt) 0x42;
+	bundle->archive = actual_archive;
+	long actual_id = 666;
+	long get_id = 0;
+
+	mock().expectOneCall("bundleArchive_getId")
+			.withParameter("archive", actual_archive)
+			.withOutputParameterReturning("id", &actual_id, sizeof(actual_id));
+
+	LONGS_EQUAL(CELIX_SUCCESS, bundle_getBundleId(bundle, &get_id));
+	LONGS_EQUAL(actual_id, get_id);
+
+	free(bundle);
 }
 
 TEST(bundle, getRegisteredServices) {
-//	FAIL("Test not fully implemented");
+	bundle_pt bundle = (bundle_pt) malloc(sizeof(*bundle));
+	framework_pt framework = (framework_pt) 0x10;
+	bundle->framework = framework;
+	array_list_pt list = (array_list_pt) 0x20;
+	array_list_pt get = NULL;
+
+	mock().expectOneCall("fw_getBundleRegisteredServices")
+			.withParameter("framework", framework)
+			.withParameter("bundle", bundle)
+			.withOutputParameterReturning("services", &list, sizeof(list));
+
+	LONGS_EQUAL(CELIX_SUCCESS, bundle_getRegisteredServices(bundle, &get));
+	POINTERS_EQUAL(list, get);
+
+	free(bundle);
 }
 
 TEST(bundle, getServicesInUse) {
-//	FAIL("Test not fully implemented");
-}
+	bundle_pt bundle = (bundle_pt) malloc(sizeof(*bundle));
+	framework_pt framework = (framework_pt) 0x10;
+	bundle->framework = framework;
+	array_list_pt list = (array_list_pt) 0x20;
+	array_list_pt get = NULL;
+
+	mock().expectOneCall("fw_getBundleServicesInUse")
+			.withParameter("framework", framework)
+			.withParameter("bundle", bundle)
+			.withOutputParameterReturning("services", &list, sizeof(list));
+
+	LONGS_EQUAL(CELIX_SUCCESS, bundle_getServicesInUse(bundle, &get));
+	POINTERS_EQUAL(list, get);
 
-TEST(bundle, getMemoryPool) {
-//	FAIL("Test not fully implemented");
+	free(bundle);
 }
 
 TEST(bundle, setFramework) {
-//	FAIL("Test not fully implemented");
+	framework_pt framework = (framework_pt) 0x666;
+	bundle_pt bundle = (bundle_pt) malloc(sizeof(*bundle));
+
+	LONGS_EQUAL(CELIX_SUCCESS, bundle_setFramework(bundle, framework));
+	POINTERS_EQUAL(framework, bundle->framework);
+
+	mock().expectOneCall("framework_logCode")
+							.withParameter("code", CELIX_ILLEGAL_ARGUMENT);
+
+	LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, bundle_setFramework(bundle, NULL));
+
+	free(bundle);
 }
 
 TEST(bundle, getFramework) {
-//	FAIL("Test not fully implemented");
+	framework_pt get = NULL;
+	framework_pt actual = (framework_pt) 0x666;
+	bundle_pt bundle = (bundle_pt) malloc(sizeof(*bundle));
+
+	bundle->framework = actual;
+
+	LONGS_EQUAL(CELIX_SUCCESS, bundle_getFramework(bundle, &get));
+
+	free(bundle);
+	bundle = NULL;
+
+	mock().expectOneCall("framework_logCode")
+							.withParameter("code", CELIX_ILLEGAL_ARGUMENT);
+
+	LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, bundle_getFramework(bundle, &get));
+
+	free(bundle);
 }

http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/test/capability_test.cpp
----------------------------------------------------------------------
diff --git a/framework/private/test/capability_test.cpp b/framework/private/test/capability_test.cpp
index 1874dd9..4d9f2eb 100644
--- a/framework/private/test/capability_test.cpp
+++ b/framework/private/test/capability_test.cpp
@@ -33,10 +33,11 @@
 
 extern "C" {
 #include "capability_private.h"
+#include "utils.h"
 #include "attribute.h"
 #include "celix_log.h"
 
-framework_logger_pt logger;
+framework_logger_pt logger = (framework_logger_pt) 0x42;
 }
 
 int main(int argc, char** argv) {
@@ -45,8 +46,6 @@ int main(int argc, char** argv) {
 
 TEST_GROUP(capability) {
 	void setup(void) {
-		logger = (framework_logger_pt) malloc(sizeof(*logger));
-        logger->logFunction = frameworkLogger_log;
 	}
 
 	void teardown() {
@@ -57,8 +56,8 @@ TEST_GROUP(capability) {
 
 TEST(capability, create) {
 	module_pt module = (module_pt) 0x10;
-	hash_map_pt directives = hashMap_create(NULL, NULL, NULL, NULL);
-	hash_map_pt attributes = hashMap_create(NULL, NULL, NULL, NULL);
+	hash_map_pt directives =  hashMap_create(utils_stringHash, NULL, utils_stringEquals, 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);
@@ -90,6 +89,10 @@ TEST(capability, create) {
 
 	capability_pt capability = NULL;
 	celix_status_t status = capability_create(module, directives, attributes, &capability);
+
+	mock().expectNCalls(2, "attribute_destroy");
+	mock().expectOneCall("version_destroy");
+	capability_destroy(capability);
 }
 
 TEST(capability, getServiceName) {
@@ -100,6 +103,8 @@ TEST(capability, getServiceName) {
 	char *actual = NULL;
 	capability_getServiceName(capability, &actual);
 	STRCMP_EQUAL(serviceName, actual);
+
+	free(capability);
 }
 
 TEST(capability, getVersion) {
@@ -110,6 +115,8 @@ TEST(capability, getVersion) {
 	version_pt actual = NULL;
 	capability_getVersion(capability, &actual);
 	POINTERS_EQUAL(version, actual);
+
+	free(capability);
 }
 
 TEST(capability, getModule) {
@@ -120,4 +127,6 @@ TEST(capability, getModule) {
 	module_pt actual = NULL;
 	capability_getModule(capability, &actual);
 	POINTERS_EQUAL(module, actual);
+
+	free(capability);
 }

http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/test/celix_errorcodes_test.cpp
----------------------------------------------------------------------
diff --git a/framework/private/test/celix_errorcodes_test.cpp b/framework/private/test/celix_errorcodes_test.cpp
new file mode 100644
index 0000000..99ed360
--- /dev/null
+++ b/framework/private/test/celix_errorcodes_test.cpp
@@ -0,0 +1,87 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+/*
+ * celix_errorcodes_test.cpp
+ *
+ *  \date       Oct 16, 2015
+ *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "CppUTest/TestHarness.h"
+#include "CppUTest/TestHarness_c.h"
+#include "CppUTest/CommandLineTestRunner.h"
+#include "CppUTestExt/MockSupport.h"
+
+extern "C" {
+#include "celix_errno.h"
+}
+
+int main(int argc, char** argv) {
+	return CommandLineTestRunner::RunAllTests(argc, argv);
+}
+
+TEST_GROUP(celix_errorcodes) {
+	void setup(void){
+	}
+
+	void teardown(void){
+	}
+};
+
+TEST(celix_errorcodes, test_entire_file){
+	char ret_str[100];
+
+	celix_strerror(CELIX_BUNDLE_EXCEPTION, ret_str, 100);
+	STRCMP_EQUAL("Bundle exception", ret_str);
+
+	celix_strerror(CELIX_INVALID_BUNDLE_CONTEXT, ret_str, 100);
+	STRCMP_EQUAL("Invalid bundle context", ret_str);
+
+	celix_strerror(CELIX_ILLEGAL_ARGUMENT, ret_str, 100);
+	STRCMP_EQUAL("Illegal argument", ret_str);
+
+	celix_strerror(CELIX_INVALID_SYNTAX, ret_str, 100);
+	STRCMP_EQUAL("Invalid syntax", ret_str);
+
+	celix_strerror(CELIX_FRAMEWORK_SHUTDOWN, ret_str, 100);
+	STRCMP_EQUAL("Framework shutdown", ret_str);
+
+	celix_strerror(CELIX_ILLEGAL_STATE, ret_str, 100);
+	STRCMP_EQUAL("Illegal state", ret_str);
+
+	celix_strerror(CELIX_FRAMEWORK_EXCEPTION, ret_str, 100);
+	STRCMP_EQUAL("Framework exception", ret_str);
+
+	celix_strerror(CELIX_FILE_IO_EXCEPTION, ret_str, 100);
+	STRCMP_EQUAL("File I/O exception", ret_str);
+
+	celix_strerror(CELIX_SERVICE_EXCEPTION, ret_str, 100);
+	STRCMP_EQUAL("Service exception", ret_str);
+
+	celix_strerror(CELIX_START_ERROR, ret_str, 100);
+	STRCMP_EQUAL("Unknown code", ret_str);
+
+	//test non celix error code
+	STRCMP_EQUAL("Cannot allocate memory",
+				celix_strerror(ENOMEM, ret_str, 100));
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/test/framework_test.cpp
----------------------------------------------------------------------
diff --git a/framework/private/test/framework_test.cpp b/framework/private/test/framework_test.cpp
index e1085f7..81dabf5 100644
--- a/framework/private/test/framework_test.cpp
+++ b/framework/private/test/framework_test.cpp
@@ -19,7 +19,7 @@
 /*
  * framework_test.cpp
  *
- *  \date       Feb 11, 2013
+ *  \date       Sep 28, 2015
  *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
  *  \copyright  Apache License, Version 2.0
  */
@@ -33,22 +33,79 @@
 
 extern "C" {
 #include "framework.h"
+#include "framework_private.h"
 }
 
 int main(int argc, char** argv) {
-	return RUN_ALL_TESTS(argc, argv);
+	return CommandLineTestRunner::RUN_ALL_TESTS(argc, argv);
 }
 
 TEST_GROUP(framework) {
+	properties_pt properties;
+
 	void setup(void) {
+		properties = properties_create();
 	}
 
 	void teardown() {
-		mock().checkExpectations();
-		mock().clear();
+		properties_destroy(properties);
 	}
 };
 
+TEST(framework, create){
+	framework_pt framework = NULL;
+
+	mock().expectOneCall("bundle_create");
+
+	framework_create(&framework, properties);
+
+
+	CHECK(framework != NULL);
+	POINTERS_EQUAL(&properties, framework->configurationMap);
+
+	mock().checkExpectations();
+	mock().clear();
+}
+
+/*TEST(framework, startFw){
+	framework_pt framework = NULL;
+
+	mock().expectOneCall("bundle_create");
+	mock().expectOneCall("framework_logCode")
+			.withParameter("code", CELIX_ILLEGAL_ARGUMENT);
+
+	LONGS_EQUAL(CELIX_SUCCESS,framework_create(&framework, properties));
+
+	LONGS_EQUAL(CELIX_SUCCESS,fw_init(framework));
+
+	LONGS_EQUAL(CELIX_SUCCESS,framework_start(framework));
+
+	framework_stop(framework);
+	framework_destroy(framework);
+
+}
+
+TEST(framework, installBundle){
+	framework_pt framework = NULL;
+
+	mock().expectOneCall("bundle_create");
+	mock().expectOneCall("framework_logCode")
+			.withParameter("code", CELIX_ILLEGAL_ARGUMENT);
+
+	LONGS_EQUAL(CELIX_SUCCESS, framework_create(&framework, properties));
+
+	LONGS_EQUAL(CELIX_SUCCESS,fw_init(framework));
+
+	LONGS_EQUAL(CELIX_SUCCESS,framework_start(framework));
+
+	// fw_installBundle(); // Needs a fake bundle..
+
+	framework_stop(framework);
+	framework_destroy(framework);
+
+}*/
+
+
 
 
 

http://git-wip-us.apache.org/repos/asf/celix/blob/aec12cd9/framework/private/test/manifest_test.cpp
----------------------------------------------------------------------
diff --git a/framework/private/test/manifest_test.cpp b/framework/private/test/manifest_test.cpp
index c90cc90..02422aa 100644
--- a/framework/private/test/manifest_test.cpp
+++ b/framework/private/test/manifest_test.cpp
@@ -56,7 +56,7 @@ TEST_GROUP(manifest) {
 };
 
 TEST(manifest, createFromFile) {
-    char manifestFile[] = "../../celix/framework/private/resources-test/manifest.txt";
+    char manifestFile[] = "resources-test/manifest.txt";
     manifest_pt manifest = NULL;
 //    properties_pt properties = properties_create();
     properties_pt properties = (properties_pt) 0x40;
@@ -98,7 +98,7 @@ TEST(manifest, createFromFile) {
 }
 
 TEST(manifest, createFromFileWithSections) {
-    char manifestFile[] = "../../celix/framework/private/resources-test/manifest_sections.txt";
+    char manifestFile[] = "resources-test/manifest_sections.txt";
     manifest_pt manifest = NULL;
 //    properties_pt properties = properties_create();
     properties_pt properties = (properties_pt) 0x40;