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/10/07 14:45:51 UTC

[11/20] celix git commit: CELIX-263: replaced utils cunit tests w/ cpputests

CELIX-263: replaced utils cunit tests w/ cpputests


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

Branch: refs/heads/feature/CELIX-237_rsa-ffi
Commit: c6d2d59f1bcd4443caeb7b0133e1cd2abf54b0aa
Parents: 5ff51e8
Author: Bjoern Petri <bp...@apache.org>
Authored: Tue Oct 6 05:45:58 2015 +0200
Committer: Bjoern Petri <bp...@apache.org>
Committed: Tue Oct 6 05:45:58 2015 +0200

----------------------------------------------------------------------
 .travis.yml                               |   11 +-
 utils/CMakeLists.txt                      |   42 +-
 utils/private/test/array_list_test.c      |  357 ------
 utils/private/test/array_list_test.cpp    |  498 +++++++-
 utils/private/test/celix_threads_test.cpp |  344 ++++++
 utils/private/test/hash_map_test.c        |  478 --------
 utils/private/test/hash_map_test.cpp      | 1492 ++++++++++++++++++++++++
 utils/private/test/hash_map_test_hash.c   |  359 ------
 utils/private/test/linked_list_test.c     |   96 --
 utils/private/test/linked_list_test.cpp   |  794 +++++++++++++
 10 files changed, 3142 insertions(+), 1329 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/c6d2d59f/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index bb53363..df0f48b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,5 +1,7 @@
 language: c
 
+env
+
 before_install:
   - sudo apt-get update -qq
   - sudo apt-get install -y uuid-dev libjansson-dev libxml2-dev
@@ -12,7 +14,12 @@ matrix:
 before_script:  
     - mkdir build install
     - cd build
-    - cmake -DBUILD_DEPLOYMENT_ADMIN=ON -DBUILD_EXAMPLES=ON -DBUILD_LOG_SERVICE=ON -DBUILD_LOG_WRITER=ON -DBUILD_REMOTE_SERVICE_ADMIN=ON -DBUILD_RSA_DISCOVERY_CONFIGURED=ON -DBUILD_RSA_DISCOVERY_ETCD=ON -DBUILD_RSA_DISCOVERY_SHM=ON -DBUILD_RSA_EXAMPLES=ON -DBUILD_RSA_REMOTE_SERVICE_ADMIN_SHM=ON -DBUILD_RSA_REMOTE_SERVICE_ADMIN_HTTP=ON -DBUILD_REMOTE_SHELL=ON -DBUILD_SHELL=ON -DBUILD_SHELL_TUI=ON -DBUILD_DEVICE_ACCESS=ON -DBUILD_DEVICE_ACCESS_EXAMPLE=ON -DCMAKE_INSTALL_PREFIX=../install ..
+    - cmake -DBUILD_DEPLOYMENT_ADMIN=ON -DBUILD_EXAMPLES=ON -DBUILD_LOG_SERVICE=ON -DBUILD_LOG_WRITER=ON -DBUILD_REMOTE_SERVICE_ADMIN=ON -DBUILD_RSA_DISCOVERY_CONFIGURED=ON -DBUILD_RSA_DISCOVERY_ETCD=ON -DBUILD_RSA_DISCOVERY_SHM=ON -DBUILD_RSA_EXAMPLES=ON -DBUILD_RSA_REMOTE_SERVICE_ADMIN_SHM=ON -DBUILD_RSA_REMOTE_SERVICE_ADMIN_HTTP=ON -DBUILD_REMOTE_SHELL=ON -DBUILD_SHELL=ON -DBUILD_SHELL_TUI=ON -DBUILD_DEVICE_ACCESS=ON -DBUILD_DEVICE_ACCESS_EXAMPLE=ON -DBUILD_UTILS_TEST=ON -DCMAKE_INSTALL_PREFIX=../install ..
 
 script: 
-    - make all && make deploy && make install
+    - make all && make deploy && make install-all
+
+after_script:
+    - export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:`pwd`/utils
+    - ./utils/array_list_test && ./utils/celix_threads_test && ./utils/linked_list_test && ./utils/hash_map_test 
+

http://git-wip-us.apache.org/repos/asf/celix/blob/c6d2d59f/utils/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt
index bb27a0c..c786e96 100644
--- a/utils/CMakeLists.txt
+++ b/utils/CMakeLists.txt
@@ -41,6 +41,7 @@ if (UTILS)
 		public/include/exports.h
 		
 		private/src/celix_threads.c
+		public/include/celix_threads.h
 	)
     
     IF(UNIX)
@@ -53,6 +54,7 @@ if (UTILS)
     
     celix_subproject(UTILS-TESTS "Option to build the utilities library tests" "OFF")
     if (UTILS-TESTS)
+		
     	find_package(CppUTest REQUIRED)
 
 	    include_directories(${CUNIT_INCLUDE_DIRS})
@@ -60,27 +62,33 @@ if (UTILS)
 	    include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
 	    include_directories("${PROJECT_SOURCE_DIR}/utils/private/include")
 	    
-	    add_executable(hash_map_test private/test/hash_map_test.c)
-	    target_link_libraries(hash_map_test celix_utils ${CUNIT_LIBRARIES})
-	    
-	    add_executable(hash_map_test_hash private/test/hash_map_test_hash.c)
-	    target_link_libraries(hash_map_test_hash celix_utils ${CUNIT_LIBRARIES})
-	    
-	    add_executable(array_list_test2 private/test/array_list_test.c)
-	    target_link_libraries(array_list_test2 celix_utils ${CUNIT_LIBRARIES})
+	    add_executable(hash_map_test private/test/hash_map_test.cpp)
+	    target_link_libraries(hash_map_test celix_utils ${CPPUTEST_LIBRARY} pthread)
 	    
 	    add_executable(array_list_test private/test/array_list_test.cpp)
-		target_link_libraries(array_list_test celix_utils ${CPPUTEST_LIBRARY})
+	    target_link_libraries(array_list_test celix_utils ${CPPUTEST_LIBRARY} pthread)
+	    
+		add_executable(celix_threads_test private/test/celix_threads_test.cpp)
+	    target_link_libraries(celix_threads_test celix_utils ${CPPUTEST_LIBRARY} pthread)
 	    
-	    add_executable(linked_list_test private/test/linked_list_test.c)
-	    target_link_libraries(linked_list_test celix_utils ${CUNIT_LIBRARIES})
+	    add_executable(linked_list_test private/test/linked_list_test.cpp)
+	    target_link_libraries(linked_list_test celix_utils ${CPPUTEST_LIBRARY} pthread)
 
-	    run_test(array_list_test2)
-	    run_test(hash_map_test)
-	    run_test(hash_map_test_hash)
-	    run_test(linked_list_test)
+	    #run_test(array_list_test)
+	    #run_test(hash_map_test)
+	    #run_test(linked_list_test)
 	    
 	    ADD_TARGET_FOR_TEST(array_list_test)
-        SETUP_TARGET_FOR_COVERAGE(array_list_test_c array_list_test ${CMAKE_BINARY_DIR}/coverage/array_list_test)
-    endif(UTILS-TESTS)
+       SETUP_TARGET_FOR_COVERAGE(array_list array_list_test ${CMAKE_BINARY_DIR}/coverage/array_list_test/array_list_test)
+
+ 	    ADD_TARGET_FOR_TEST(hash_map_test)
+       SETUP_TARGET_FOR_COVERAGE(hash_map hash_map_test ${CMAKE_BINARY_DIR}/coverage/hash_map_test/hash_map_test)
+       
+       ADD_TARGET_FOR_TEST(celix_threads_test)
+       SETUP_TARGET_FOR_COVERAGE(celix_threads celix_threads_test ${CMAKE_BINARY_DIR}/coverage/celix_threads_test/celix_threads_test)
+
+	    ADD_TARGET_FOR_TEST(linked_list_test)
+       SETUP_TARGET_FOR_COVERAGE(linked_list linked_list_test ${CMAKE_BINARY_DIR}/coverage/linked_list_test/linked_list_test)
+
+   endif(UTILS-TESTS)
 endif (UTILS)

http://git-wip-us.apache.org/repos/asf/celix/blob/c6d2d59f/utils/private/test/array_list_test.c
----------------------------------------------------------------------
diff --git a/utils/private/test/array_list_test.c b/utils/private/test/array_list_test.c
deleted file mode 100644
index ba881c1..0000000
--- a/utils/private/test/array_list_test.c
+++ /dev/null
@@ -1,357 +0,0 @@
-/**
- *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.
- */
-/*
- * array_list_test.c
- *
- *  \date       Aug 4, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <CUnit/Automated.h>
-
-#include "celixbool.h"
-
-#include "array_list.h"
-#include "array_list_private.h"
-
-array_list_pt list;
-
-int setup(void) {
-	arrayList_create(&list);
-	if (list == NULL) {
-		return 1;
-	}
-	return 0;
-}
-
-void test_arrayList_create(void) {
-	CU_ASSERT_PTR_NOT_NULL_FATAL(list);
-	CU_ASSERT_EQUAL(list->size, 0);
-}
-
-void test_arrayList_trimToSize(void) {
-	char * entry;
-	arrayList_clear(list);
-
-	entry = "entry";
-	arrayList_add(list, entry);
-	CU_ASSERT_EQUAL(list->size, 1);
-	CU_ASSERT_EQUAL(list->capacity, 10);
-
-	arrayList_trimToSize(list);
-	CU_ASSERT_EQUAL(list->size, 1);
-	CU_ASSERT_EQUAL(list->capacity, 1);
-}
-
-void test_arrayList_ensureCapacity(void) {
-	int i;
-	arrayList_create(&list);
-	arrayList_clear(list);
-	CU_ASSERT_EQUAL(list->capacity, 10);
-	CU_ASSERT_EQUAL(list->size, 0);
-	for (i = 0; i < 100; i++) {
-		arrayList_add(list, "entry");
-	}
-	CU_ASSERT_EQUAL(list->capacity, 133);
-	CU_ASSERT_EQUAL(list->size, 100);
-	arrayList_create(&list);
-}
-
-void test_arrayList_size(void) {
-	char * entry;
-	char * entry2;
-	char * entry3;
-	arrayList_clear(list);
-	CU_ASSERT_EQUAL(list->size, 0);
-
-	entry = "entry";
-	arrayList_add(list, entry);
-	CU_ASSERT_EQUAL(list->size, 1);
-
-	entry2 = "entry";
-	arrayList_add(list, entry2);
-	CU_ASSERT_EQUAL(list->size, 2);
-
-	entry3 = "entry";
-	arrayList_add(list, entry3);
-	CU_ASSERT_EQUAL(list->size, 3);
-}
-
-void test_arrayList_isEmpty(void) {
-	arrayList_clear(list);
-	CU_ASSERT_EQUAL(list->size, 0);
-	CU_ASSERT_TRUE(arrayList_isEmpty(list));
-}
-
-void test_arrayList_contains(void) {
-	char * entry = "entry";
-	char * entry2 = "entry2";
-	char * entry3 = NULL;
-	bool contains;
-
-	arrayList_clear(list);
-
-	arrayList_add(list, entry);
-
-	arrayList_add(list, entry2);
-
-	CU_ASSERT_TRUE(arrayList_contains(list, entry));
-	CU_ASSERT_TRUE(arrayList_contains(list, entry2));
-	contains = arrayList_contains(list, NULL);
-	CU_ASSERT_FALSE(contains);
-
-	arrayList_add(list, entry3);
-
-	CU_ASSERT_TRUE(arrayList_contains(list, entry3));
-}
-
-void test_arrayList_indexOf(void) {
-	char * entry = "entry";
-	char * entry2 = "entry2";
-
-	arrayList_clear(list);
-
-	arrayList_add(list, entry);
-
-	arrayList_add(list, entry2);
-	arrayList_add(list, entry2);
-	arrayList_add(list, entry2);
-	arrayList_add(list, entry2);
-
-	CU_ASSERT_EQUAL(arrayList_indexOf(list, entry), 0);
-	CU_ASSERT_EQUAL(arrayList_indexOf(list, entry2), 1);
-	CU_ASSERT_EQUAL(arrayList_lastIndexOf(list, entry), 0);
-	CU_ASSERT_EQUAL(arrayList_lastIndexOf(list, entry2), 4);
-}
-
-void test_arrayList_get(void) {
-	char * entry = "entry";
-	char * entry2 = "entry2";
-	char * entry3 = NULL;
-	char * get;
-	
-	arrayList_clear(list);
-
-	arrayList_add(list, entry);
-	arrayList_add(list, entry2);
-
-	get = arrayList_get(list, 0);
-	CU_ASSERT_EQUAL(entry, get);
-
-	get = arrayList_get(list, 1);
-	CU_ASSERT_EQUAL(entry2, get);
-
-	arrayList_add(list, entry3);
-
-	get = arrayList_get(list, 2);
-	CU_ASSERT_PTR_NULL(get);
-
-	get = arrayList_get(list, 42);
-	CU_ASSERT_PTR_NULL(get);
-}
-
-void test_arrayList_set(void) {
-	char * entry = "entry";
-	char * entry2 = "entry2";
-	char * entry3 = "entry3";
-	char * get;
-	char * old;
-
-	arrayList_clear(list);
-
-	arrayList_add(list, entry);
-	arrayList_add(list, entry2);
-
-	get = arrayList_get(list, 1);
-	CU_ASSERT_EQUAL(entry2, get);
-
-	old = arrayList_set(list, 1, entry3);
-	CU_ASSERT_EQUAL(entry2, old);
-	get = arrayList_get(list, 1);
-	CU_ASSERT_EQUAL(entry3, get);
-}
-
-void test_arrayList_add(void) {
-	char * entry = "entry";
-	char * entry2 = "entry2";
-	char * entry3 = "entry3";
-	char * get;
-
-	arrayList_clear(list);
-
-	arrayList_add(list, entry);
-	arrayList_add(list, entry2);
-
-	get = arrayList_get(list, 1);
-	CU_ASSERT_EQUAL(entry2, get);
-
-	arrayList_addIndex(list, 1, entry3);
-
-	get = arrayList_get(list, 1);
-	CU_ASSERT_EQUAL(entry3, get);
-
-	get = arrayList_get(list, 2);
-	CU_ASSERT_EQUAL(entry2, get);
-}
-
-void test_arrayList_addAll(void) {
-    char * entry = "entry";
-    char * entry2 = "entry2";
-    char * entry3 = "entry3"; 
-    char * get;
-	array_list_pt toAdd;
-	bool changed;
-	
-	arrayList_clear(list);
-
-	arrayList_create(&toAdd);
-    arrayList_add(toAdd, entry);
-    arrayList_add(toAdd, entry2);
-
-    arrayList_add(list, entry3);
-
-    get = arrayList_get(list, 0);
-    CU_ASSERT_EQUAL(entry3, get);
-
-    changed = arrayList_addAll(list, toAdd);
-    CU_ASSERT_TRUE(changed);
-    CU_ASSERT_EQUAL(arrayList_size(list), 3);
-
-    get = arrayList_get(list, 1);
-    CU_ASSERT_EQUAL(entry, get);
-
-    get = arrayList_get(list, 2);
-    CU_ASSERT_EQUAL(entry2, get);
-}
-
-void test_arrayList_remove(void) {
-	char * entry = "entry";
-	char * entry2 = "entry2";
-	char * entry3 = "entry3";
-	char * get;
-	char * removed;
-
-	arrayList_clear(list);
-
-	arrayList_add(list, entry);
-	arrayList_add(list, entry2);
-
-	get = arrayList_get(list, 1);
-	CU_ASSERT_EQUAL(entry2, get);
-
-	// Remove first entry
-	removed = arrayList_remove(list, 0);
-	CU_ASSERT_EQUAL(entry, removed);
-
-	// Check the new first element
-	get = arrayList_get(list, 0);
-	CU_ASSERT_EQUAL(entry2, get);
-
-	// Add a new element
-	arrayList_add(list, entry3);
-
-	get = arrayList_get(list, 1);
-	CU_ASSERT_EQUAL(entry3, get);
-}
-
-void test_arrayList_removeElement(void) {
-	char * entry = "entry";
-	char * entry2 = "entry2";
-	char * entry3 = "entry3";
-	char * get;
-
-	arrayList_clear(list);
-
-	arrayList_add(list, entry);
-	arrayList_add(list, entry2);
-
-	// Remove entry
-	CU_ASSERT_TRUE(arrayList_removeElement(list, entry));
-
-	// Check the new first element
-	get = arrayList_get(list, 0);
-	CU_ASSERT_EQUAL(entry2, get);
-
-	// Add a new element
-	arrayList_add(list, entry3);
-
-	get = arrayList_get(list, 1);
-	CU_ASSERT_EQUAL(entry3, get);
-}
-
-void test_arrayList_clear(void) {
-	char * entry = "entry";
-	char * entry2 = "entry2";
-
-	arrayList_clear(list);
-
-	arrayList_add(list, entry);
-	arrayList_add(list, entry2);
-
-	CU_ASSERT_EQUAL(arrayList_size(list), 2);
-	arrayList_clear(list);
-	CU_ASSERT_EQUAL(arrayList_size(list), 0);
-}
-
-
-
-int main (int argc, char** argv) {
-	CU_pSuite pSuite = NULL;
-
-	/* initialize the CUnit test registry */
-	if (CUE_SUCCESS != CU_initialize_registry())
-	  return CU_get_error();
-
-	/* add a suite to the registry */
-	pSuite = CU_add_suite("Suite_1", setup, NULL);
-	if (NULL == pSuite) {
-	  CU_cleanup_registry();
-	  return CU_get_error();
-	}
-
-	/* add the tests to the suite */
-	if (NULL == CU_add_test(pSuite, "Array List Creation Test", test_arrayList_create)
-		|| NULL == CU_add_test(pSuite, "Array List Trim Test", test_arrayList_trimToSize)
-		|| NULL == CU_add_test(pSuite, "Array List Capacity Test", test_arrayList_ensureCapacity)
-		|| NULL == CU_add_test(pSuite, "Array List Size Test", test_arrayList_size)
-		|| NULL == CU_add_test(pSuite, "Array List Is Empty Test", test_arrayList_isEmpty)
-		|| NULL == CU_add_test(pSuite, "Array List Contains Test", test_arrayList_contains)
-		|| NULL == CU_add_test(pSuite, "Array List Index Of Test", test_arrayList_indexOf)
-		|| NULL == CU_add_test(pSuite, "Array List Get Test", test_arrayList_get)
-		|| NULL == CU_add_test(pSuite, "Array List Set Test", test_arrayList_set)
-		|| NULL == CU_add_test(pSuite, "Array List Add Test", test_arrayList_add)
-		|| NULL == CU_add_test(pSuite, "Array List Remove Test", test_arrayList_remove)
-		|| NULL == CU_add_test(pSuite, "Array List Remove Element Test", test_arrayList_removeElement)
-		|| NULL == CU_add_test(pSuite, "Array List Clear Test", test_arrayList_clear)
-		|| NULL == CU_add_test(pSuite, "Array List Add All", test_arrayList_addAll)
-	)
-	{
-	  CU_cleanup_registry();
-	  return CU_get_error();
-	}
-
-	CU_set_output_filename(argv[1]);
-	CU_list_tests_to_file();
-	CU_automated_run_tests();
-	CU_cleanup_registry();
-	return CU_get_error();
-}
-

http://git-wip-us.apache.org/repos/asf/celix/blob/c6d2d59f/utils/private/test/array_list_test.cpp
----------------------------------------------------------------------
diff --git a/utils/private/test/array_list_test.cpp b/utils/private/test/array_list_test.cpp
index 3787bfe..fbf09a9 100644
--- a/utils/private/test/array_list_test.cpp
+++ b/utils/private/test/array_list_test.cpp
@@ -19,11 +19,13 @@
 /*
  * array_list_test.cpp
  *
- *  Created on: Jun 6, 2012
- *      Author: alexander
+ * 	\date       Sep 15, 2015
+ *  \author    	Menno van der Graaf & Alexander
+ *  \copyright	Apache License, Version 2.0
  */
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 
 #include "CppUTest/TestHarness.h"
 #include "CppUTest/TestHarness_c.h"
@@ -39,10 +41,19 @@ int main(int argc, char** argv) {
 	return RUN_ALL_TESTS(argc, argv);
 }
 
+static char* my_strdup(const char* s){
+	char *d = (char*) malloc (strlen (s) + 1);
+	if (d == NULL) return NULL;
+	strcpy (d,s);
+	return d;
+}
+
+//----------------------TESTS GROUP DEFINES----------------------
+
 TEST_GROUP(array_list) {
 	array_list_pt list;
 
-	void setup(void) {
+	void setup(){
 		arrayList_create(&list);
 	}
 	void teardown() {
@@ -50,55 +61,73 @@ TEST_GROUP(array_list) {
 	}
 };
 
+TEST_GROUP(array_list_iterator) {
+	array_list_pt list;
+
+	void setup(){
+		arrayList_create(&list);
+	}
+	void teardown() {
+		arrayList_destroy(list);
+	}
+};
+
+//----------------------ARRAY LIST TESTS----------------------
 
 TEST(array_list, create) {
 	CHECK_C(list != NULL);
-    LONGS_EQUAL(0, list->size);
+	LONGS_EQUAL(0, list->size);
 }
 
 TEST(array_list, trimToSize) {
 	bool added;
-	std::string entry;
+	char * entry = my_strdup("entry");
 	arrayList_clear(list);
 
-	entry = "entry";
-	added = arrayList_add(list, (char *) entry.c_str());
-	LONGS_EQUAL(list->size, 1);
-	LONGS_EQUAL(list->capacity, 10);
+	added = arrayList_add(list, entry);
+	LONGS_EQUAL(1, list->size);
+	LONGS_EQUAL(10, list->capacity);
 
 	arrayList_trimToSize(list);
-	LONGS_EQUAL(list->size, 1);
-	LONGS_EQUAL(list->capacity, 1);
+	LONGS_EQUAL(1, list->size);
+	LONGS_EQUAL(1, list->capacity);
+
+	free(entry);
 }
 
 TEST(array_list, ensureCapacity) {
 	int i;
 	arrayList_clear(list);
 
-	LONGS_EQUAL(list->capacity, 10);
-	LONGS_EQUAL(list->size, 0);
+	LONGS_EQUAL(10, list->capacity);
+	LONGS_EQUAL(0, list->size);
 
 	for (i = 0; i < 100; i++) {
 		bool added;
-		std::string entry = "entry";
-		added = arrayList_add(list, (char *) entry.c_str());
+		char * entry = my_strdup("entry");
+		added = arrayList_add(list, entry);
+	}
+	LONGS_EQUAL(133, list->capacity);
+	LONGS_EQUAL(100, list->size);
+
+	for (i = 99; i >= 0; i--) {
+		free(arrayList_remove(list, i));
 	}
-	LONGS_EQUAL(list->capacity, 133);
-	LONGS_EQUAL(list->size, 100);
 }
 
 TEST(array_list, clone) {
 	int i;
 	arrayList_clear(list);
 
-	LONGS_EQUAL(list->capacity, 10);
-	LONGS_EQUAL(list->size, 0);
+	LONGS_EQUAL(10, list->capacity);
+	LONGS_EQUAL(0, list->size);
 
 	for (i = 0; i < 12; i++) {
 		bool added;
 		char entry[11];
 		sprintf(entry, "|%s|%d|", "entry", i);
-		added = arrayList_add(list, entry);
+		added = arrayList_add(list, my_strdup(entry));
+		CHECK(added);
 	}
 	LONGS_EQUAL(16, list->capacity);
 	LONGS_EQUAL(12, list->size);
@@ -119,5 +148,434 @@ TEST(array_list, clone) {
 		STRCMP_EQUAL((char *) entry, entrys);
 	}
 
+	for (i = 11; i >= 0; i--) {
+		free(arrayList_remove(list, i));
+	}
 	arrayList_destroy(clone);
 }
+
+TEST(array_list, size){
+	char * entry = my_strdup("entry");
+	char * entry2 = my_strdup("entry");
+	char * entry3 = my_strdup("entry");
+	arrayList_clear(list);
+	LONGS_EQUAL(0, list->size);
+
+	arrayList_add(list, entry);
+	LONGS_EQUAL(1, list->size);
+
+	arrayList_add(list, entry2);
+	LONGS_EQUAL(2, list->size);
+
+	arrayList_add(list, entry3);
+	LONGS_EQUAL(3, list->size);
+
+	free(entry);
+	free(entry2);
+	free(entry3);
+}
+
+TEST(array_list, isEmpty){
+	arrayList_clear(list);
+	LONGS_EQUAL(0, list->size);
+	CHECK(arrayList_isEmpty(list));
+}
+
+TEST(array_list, contains){
+	char * entry = my_strdup("entry");
+	char * entry2 = my_strdup("entry2");
+	char * entry3 = NULL;
+	bool contains;
+
+	arrayList_clear(list);
+
+	arrayList_add(list, entry);
+
+	arrayList_add(list, entry2);
+
+	CHECK(arrayList_contains(list, entry));
+	CHECK(arrayList_contains(list, entry2));
+	contains = arrayList_contains(list, NULL);
+	CHECK(!contains);
+
+	arrayList_add(list, entry3);
+
+	CHECK(arrayList_contains(list, entry3));
+
+	free(entry);
+	free(entry2);
+}
+
+TEST(array_list, indexOf){
+	char * entry = my_strdup("entry");
+	char * entry2 = my_strdup("entry2");
+
+	arrayList_clear(list);
+
+	arrayList_add(list, entry);
+
+	arrayList_add(list, entry2);
+	arrayList_add(list, entry2);
+	arrayList_add(list, entry2);
+	arrayList_add(list, entry2);
+
+	LONGS_EQUAL(0, arrayList_indexOf(list, entry));
+	LONGS_EQUAL(1, arrayList_indexOf(list, entry2));
+	LONGS_EQUAL(0, arrayList_lastIndexOf(list, entry));
+	LONGS_EQUAL(4, arrayList_lastIndexOf(list, entry2));
+
+	free(entry);
+	free(entry2);
+}
+
+TEST(array_list, get){
+	char * entry = my_strdup("entry");
+	char * entry2 = my_strdup("entry2");
+	char * entry3 = NULL;
+	char * get;
+
+	arrayList_clear(list);
+
+	arrayList_add(list, entry);
+	arrayList_add(list, entry2);
+
+	get = (char*) arrayList_get(list, 0);
+	STRCMP_EQUAL(entry, get);
+
+	get = (char*) arrayList_get(list, 1);
+	STRCMP_EQUAL(entry2, get);
+
+	arrayList_add(list, entry3);
+
+	get = (char*) arrayList_get(list, 2);
+	CHECK(get == NULL);
+
+	get = (char*) arrayList_get(list, 42);
+	CHECK(get == NULL);
+
+	free(entry);
+	free(entry2);
+}
+
+TEST(array_list, set){
+	char * entry = my_strdup("entry");
+	char * entry2 = my_strdup("entry2");
+	char * entry3 = my_strdup("entry3");
+	char * get;
+	char * old;
+
+	arrayList_clear(list);
+
+	arrayList_add(list, entry);
+	arrayList_add(list, entry2);
+
+	get = (char*) arrayList_get(list, 1);
+	STRCMP_EQUAL(entry2, get);
+
+	old = (char*) arrayList_set(list, 1, entry3);
+	STRCMP_EQUAL(entry2, old);
+	get = (char*) arrayList_get(list, 1);
+	STRCMP_EQUAL(entry3, get);
+
+	free(entry);
+	free(entry2);
+	free(entry3);
+}
+
+TEST(array_list, add){
+	char * entry = my_strdup("entry");
+	char * entry2 = my_strdup("entry2");
+	char * entry3 = my_strdup("entry3");
+	char * get;
+
+	arrayList_clear(list);
+
+	arrayList_add(list, entry);
+	arrayList_add(list, entry2);
+
+	get = (char*) arrayList_get(list, 1);
+	STRCMP_EQUAL(entry2, get);
+
+	arrayList_addIndex(list, 1, entry3);
+
+	get = (char*) arrayList_get(list, 1);
+	STRCMP_EQUAL(entry3, get);
+
+	get = (char*) arrayList_get(list, 2);
+	STRCMP_EQUAL(entry2, get);
+
+	free(entry);
+	free(entry2);
+	free(entry3);
+}
+
+TEST(array_list, addAll){
+	char * entry = my_strdup("entry");
+	char * entry2 = my_strdup("entry2");
+	char * entry3 = my_strdup("entry3");
+	char * get;
+	array_list_pt toAdd;
+	bool changed;
+
+	arrayList_clear(list);
+
+	arrayList_create(&toAdd);
+	arrayList_add(toAdd, entry);
+	arrayList_add(toAdd, entry2);
+
+	arrayList_add(list, entry3);
+
+	get = (char*) arrayList_get(list, 0);
+	STRCMP_EQUAL(entry3, get);
+
+	changed = arrayList_addAll(list, toAdd);
+	CHECK(changed);
+	LONGS_EQUAL(3, arrayList_size(list));
+
+	get = (char*) arrayList_get(list, 1);
+	STRCMP_EQUAL(entry, get);
+
+	get = (char*) arrayList_get(list, 2);
+	STRCMP_EQUAL(entry2, get);
+
+	free(entry);
+	free(entry2);
+	free(entry3);
+	arrayList_destroy(toAdd);
+}
+
+TEST(array_list, remove){
+	char * entry = my_strdup("entry");
+	char * entry2 = my_strdup("entry2");
+	char * entry3 = my_strdup("entry3");
+	char * get;
+	char * removed;
+
+	arrayList_clear(list);
+
+	arrayList_add(list, entry);
+	arrayList_add(list, entry2);
+
+	get = (char*) arrayList_get(list, 1);
+	STRCMP_EQUAL(entry2, get);
+
+	// Remove first entry
+	removed = (char*) arrayList_remove(list, 0);
+	STRCMP_EQUAL(entry, removed);
+
+	// Check the new first entry
+	get = (char*) arrayList_get(list, 0);
+	STRCMP_EQUAL(entry2, get);
+
+	// Add a new entry
+	arrayList_add(list, entry3);
+
+	get = (char*) arrayList_get(list, 1);
+	STRCMP_EQUAL(entry3, get);
+
+	free(entry);
+	free(entry2);
+	free(entry3);
+}
+
+TEST(array_list, removeElement){
+	char * entry = my_strdup("entry");
+	char * entry2 = my_strdup("entry2");
+	char * entry3 = my_strdup("entry3");
+	char * get;
+
+	arrayList_clear(list);
+
+	arrayList_add(list, entry);
+	arrayList_add(list, entry2);
+
+	// Remove entry
+	CHECK(arrayList_removeElement(list, entry));
+
+	// Check the new first element
+	get = (char*) arrayList_get(list, 0);
+	STRCMP_EQUAL(entry2, get);
+
+	// Add a new entry
+	arrayList_add(list, entry3);
+
+	get = (char*) arrayList_get(list, 1);
+	STRCMP_EQUAL(entry3, get);
+
+	free(entry);
+	free(entry2);
+	free(entry3);
+}
+
+TEST(array_list, clear){
+	char * entry = my_strdup("entry");
+	char * entry2 = my_strdup("entry2");
+
+	arrayList_clear(list);
+
+	arrayList_add(list, entry);
+	arrayList_add(list, entry2);
+
+	LONGS_EQUAL(2, arrayList_size(list));
+	arrayList_clear(list);
+	LONGS_EQUAL(0, arrayList_size(list));
+
+	free(entry);
+	free(entry2);
+}
+
+//----------------------ARRAY LIST ITERATOR TESTS----------------------
+
+TEST(array_list_iterator, create){
+	array_list_iterator_pt it_list = arrayListIterator_create(list);
+	CHECK(it_list != NULL);
+	POINTERS_EQUAL(list, it_list->list);
+	arrayListIterator_destroy(it_list);
+}
+
+TEST(array_list_iterator, hasNext){
+	char * entry = my_strdup("entry");
+	char * entry2 = my_strdup("entry2");
+	char * entry3 = my_strdup("entry3");
+	array_list_iterator_pt it_list;
+
+	arrayList_add(list, entry);
+	arrayList_add(list, entry2);
+	arrayList_add(list, entry3);
+	it_list = arrayListIterator_create(list);
+	CHECK(arrayListIterator_hasNext(it_list));
+
+	arrayListIterator_next(it_list);
+	CHECK(arrayListIterator_hasNext(it_list));
+
+	arrayListIterator_next(it_list);
+	CHECK(arrayListIterator_hasNext(it_list));
+
+	arrayListIterator_next(it_list);
+	CHECK(!arrayListIterator_hasNext(it_list));
+
+	free(entry);
+	free(entry2);
+	free(entry3);
+	arrayListIterator_destroy(it_list);
+}
+
+TEST(array_list_iterator, hasPrevious){
+	char * entry = my_strdup("entry");
+	char * entry2 = my_strdup("entry2");
+	char * entry3 = my_strdup("entry3");
+	array_list_iterator_pt it_list;
+
+	arrayList_add(list, entry);
+	arrayList_add(list, entry2);
+	arrayList_add(list, entry3);
+
+	it_list = arrayListIterator_create(list);
+	arrayListIterator_next(it_list);
+	arrayListIterator_next(it_list);
+	arrayListIterator_next(it_list);
+	CHECK(arrayListIterator_hasPrevious(it_list));
+
+	arrayListIterator_previous(it_list);
+	CHECK(arrayListIterator_hasPrevious(it_list));
+
+	arrayListIterator_previous(it_list);
+	CHECK(arrayListIterator_hasPrevious(it_list));
+
+	arrayListIterator_previous(it_list);
+	CHECK(!arrayListIterator_hasPrevious(it_list));
+
+	free(entry);
+	free(entry2);
+	free(entry3);
+	arrayListIterator_destroy(it_list);
+}
+
+TEST(array_list_iterator, next){
+	char * entry = my_strdup("entry");
+	char * entry2 = my_strdup("entry2");
+	char * entry3 = my_strdup("entry3");
+	array_list_iterator_pt it_list;
+
+	arrayList_add(list, entry);
+	arrayList_add(list, entry2);
+	arrayList_add(list, entry3);
+	it_list = arrayListIterator_create(list);
+	STRCMP_EQUAL(entry, (char*) arrayListIterator_next(it_list));
+	STRCMP_EQUAL(entry2, (char*) arrayListIterator_next(it_list));
+	STRCMP_EQUAL(entry3, (char*) arrayListIterator_next(it_list));
+	POINTERS_EQUAL(NULL, arrayListIterator_next(it_list));
+
+	//mess up the expected and real changecount, code should check and handle
+	arrayList_add(list, entry);
+	arrayListIterator_next(it_list);
+
+	free(entry);
+	free(entry2);
+	free(entry3);
+	arrayListIterator_destroy(it_list);
+}
+
+TEST(array_list_iterator, previous){
+	char * value = my_strdup("entry");
+	char * value2 = my_strdup("entry2");
+	char * value3 = my_strdup("entry3");
+	array_list_iterator_pt it_list;
+
+	arrayList_add(list, value);
+	arrayList_add(list, value2);
+	arrayList_add(list, value3);
+	it_list = arrayListIterator_create(list);
+
+	arrayListIterator_next(it_list);
+	arrayListIterator_next(it_list);
+	arrayListIterator_next(it_list);
+	STRCMP_EQUAL(value3, (char*) arrayListIterator_previous(it_list));
+	STRCMP_EQUAL(value2, (char*) arrayListIterator_previous(it_list));
+	STRCMP_EQUAL(value, (char*) arrayListIterator_previous(it_list));
+	POINTERS_EQUAL(NULL, arrayListIterator_previous(it_list));
+
+	//mess up the expected and real changecount, code should check and handle
+	arrayListIterator_destroy(it_list);
+	it_list = arrayListIterator_create(list);
+	arrayList_add(list, value);
+	arrayListIterator_previous(it_list);
+
+	free(value);
+	free(value2);
+	free(value3);
+	arrayListIterator_destroy(it_list);
+}
+
+TEST(array_list_iterator, remove){
+	char * value = my_strdup("entry");
+	char * value2 = my_strdup("entry2");
+	char * value3 = my_strdup("entry3");
+	array_list_iterator_pt it_list;
+
+	arrayList_add(list, value);
+	arrayList_add(list, value2);
+	arrayList_add(list, value3);
+	it_list = arrayListIterator_create(list);
+
+	LONGS_EQUAL(3, list->size);
+	STRCMP_EQUAL(value, (char*) arrayList_get(list, 0));
+	STRCMP_EQUAL(value2, (char*) arrayList_get(list, 1));
+	STRCMP_EQUAL(value3, (char*) arrayList_get(list, 2));
+
+	arrayListIterator_next(it_list);
+	arrayListIterator_next(it_list);
+	arrayListIterator_remove(it_list);
+	LONGS_EQUAL(2, list->size);
+	STRCMP_EQUAL(value, (char*) arrayList_get(list, 0));
+	STRCMP_EQUAL(value3, (char*) arrayList_get(list, 1));
+
+	//mess up the expected and real changecount, code should check and handle
+	arrayList_add(list, value);
+	arrayListIterator_remove(it_list);
+
+	free(value);
+	free(value2);
+	free(value3);
+	arrayListIterator_destroy(it_list);
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/c6d2d59f/utils/private/test/celix_threads_test.cpp
----------------------------------------------------------------------
diff --git a/utils/private/test/celix_threads_test.cpp b/utils/private/test/celix_threads_test.cpp
new file mode 100644
index 0000000..b0ddd83
--- /dev/null
+++ b/utils/private/test/celix_threads_test.cpp
@@ -0,0 +1,344 @@
+/**
+ *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.
+ */
+/*
+ * array_list_test.cpp
+ *
+ * 	\date       Sep 15, 2015
+ *  \author    	Menno van der Graaf & Alexander
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+
+#include "CppUTest/TestHarness.h"
+#include "CppUTest/TestHarness_c.h"
+#include "CppUTest/CommandLineTestRunner.h"
+
+extern "C" {
+#include "celix_threads.h"
+}
+
+int main(int argc, char** argv) {
+	return RUN_ALL_TESTS(argc, argv);
+}
+
+static char* my_strdup(const char* s) {
+	char *d = (char*) malloc(strlen(s) + 1);
+	if (d == NULL)
+		return NULL;
+	strcpy(d, s);
+	return d;
+}
+
+//----------------------TEST THREAD FUNCTION DECLARATIONS----------------------
+
+static void * thread_test_func_create(void *);
+static void * thread_test_func_exit(void *);
+static void * thread_test_func_detach(void *);
+static void * thread_test_func_self(void *);
+static void * thread_test_func_lock(void *);
+static void * thread_test_func_cond_wait(void *arg);
+static void * thread_test_func_cond_broadcast(void *arg);
+static int thread_test_func_recur_lock(celix_thread_mutex_t*, int);
+struct func_param{
+	int i, i2;
+	celix_thread_mutex_t mu, mu2;
+	celix_thread_cond_t cond, cond2;
+};
+//----------------------TESTGROUP DEFINES----------------------
+
+TEST_GROUP(celix_thread) {
+	celix_thread thread;
+
+	void setup(void) {
+	}
+
+	void teardown(void) {
+	}
+};
+
+TEST_GROUP(celix_thread_mutex) {
+	celix_thread thread;
+	celix_thread_mutex_t mu;
+
+	void setup(void) {
+	}
+
+	void teardown(void) {
+	}
+};
+
+TEST_GROUP(celix_thread_condition) {
+	celix_thread thread;
+	celix_thread_mutex_t mu;
+	celix_thread_cond_t cond;
+
+	void setup(void) {
+	}
+
+	void teardown(void) {
+	}
+};
+
+//----------------------CELIX THREADS TESTS----------------------
+
+TEST(celix_thread, create) {
+	int ret;
+	char * test_str;
+
+	ret = celixThread_create(&thread, NULL, &thread_test_func_create,
+			&test_str);
+	LONGS_EQUAL(CELIX_SUCCESS, ret);
+	celixThread_join(thread, NULL);
+
+	CHECK(test_str != NULL);
+	STRCMP_EQUAL("SUCCESS", test_str);
+
+	free(test_str);
+}
+
+TEST(celix_thread, exit) {
+	int ret, *status;
+
+	ret = celixThread_create(&thread, NULL, &thread_test_func_exit, NULL);
+	LONGS_EQUAL(CELIX_SUCCESS, ret);
+	celixThread_join(thread, (void**) &status);
+	LONGS_EQUAL(666, *status);
+	free(status);
+}
+
+//HORIBLE TEST
+TEST(celix_thread, detach) {
+	int ret;
+
+	celixThread_create(&thread, NULL, thread_test_func_detach, NULL);
+	ret = celixThread_detach(thread);
+	LONGS_EQUAL(CELIX_SUCCESS, ret);
+}
+
+TEST(celix_thread, self) {
+	celix_thread thread2;
+
+	celixThread_create(&thread, NULL, thread_test_func_self, &thread2);
+	celixThread_join(thread, NULL);
+	CHECK(celixThread_equals(thread, thread2));
+}
+
+TEST(celix_thread, initalized) {
+	CHECK(!celixThread_initalized(thread));
+	celixThread_create(&thread, NULL, thread_test_func_detach, NULL);
+	CHECK(celixThread_initalized(thread));
+	celixThread_detach(thread);
+}
+
+//----------------------CELIX THREADS MUTEX TESTS----------------------
+
+TEST(celix_thread_mutex, create) {
+	LONGS_EQUAL(CELIX_SUCCESS, celixThreadMutex_create(&mu, NULL));
+	LONGS_EQUAL(CELIX_SUCCESS, celixThreadMutex_destroy(&mu));
+}
+
+//check normal lock behaviour
+TEST(celix_thread_mutex, lock) {
+	struct func_param * params = (struct func_param*) calloc(1,
+			sizeof(struct func_param));
+
+	celixThreadMutex_create(&params->mu, NULL);
+
+	celixThreadMutex_lock(&params->mu);
+	celixThread_create(&thread, NULL, thread_test_func_lock, params);
+
+	sleep(2);
+
+	LONGS_EQUAL(0, params->i);
+
+	//possible race condition, not perfect test
+	celixThreadMutex_unlock(&params->mu);
+	celixThreadMutex_lock(&params->mu2);
+	LONGS_EQUAL(666, params->i);
+	celixThreadMutex_unlock(&params->mu2);
+	celixThread_join(thread, NULL);
+	free(params);
+}
+
+TEST(celix_thread_mutex, attrCreate) {
+	celix_thread_mutexattr_t mu_attr;
+	LONGS_EQUAL(CELIX_SUCCESS, celixThreadMutexAttr_create(&mu_attr));
+	LONGS_EQUAL(CELIX_SUCCESS, celixThreadMutexAttr_destroy(&mu_attr));
+}
+
+TEST(celix_thread_mutex, attrSettype) {
+	celix_thread_mutex_t mu;
+	celix_thread_mutexattr_t mu_attr;
+	celixThreadMutexAttr_create(&mu_attr);
+
+	//test recursive mutex
+	celixThreadMutexAttr_settype(&mu_attr, PTHREAD_MUTEX_RECURSIVE);
+	celixThreadMutex_create(&mu, &mu_attr);
+	//if program doesnt deadlock: succes! also check factorial of 10, for reasons unknown
+	LONGS_EQUAL(3628800, thread_test_func_recur_lock(&mu, 10));
+	celixThreadMutex_destroy(&mu);
+
+	//test deadlock check mutex
+	celixThreadMutexAttr_settype(&mu_attr, PTHREAD_MUTEX_ERRORCHECK);
+	celixThreadMutex_create(&mu, &mu_attr);
+	//get deadlock error
+	celixThreadMutex_lock(&mu);
+	CHECK(celixThreadMutex_lock(&mu) != CELIX_SUCCESS);
+	//do not get deadlock error
+	celixThreadMutex_unlock(&mu);
+	LONGS_EQUAL(CELIX_SUCCESS, celixThreadMutex_lock(&mu));
+	//get unlock error
+	celixThreadMutex_unlock(&mu);
+	CHECK(celixThreadMutex_unlock(&mu) != CELIX_SUCCESS);
+
+	celixThreadMutex_destroy(&mu);
+	celixThreadMutexAttr_destroy(&mu_attr);
+}
+
+//----------------------CELIX THREAD CONDITIONS TESTS----------------------
+
+TEST(celix_thread_condition, init) {
+	LONGS_EQUAL(CELIX_SUCCESS, celixThreadCondition_init(&cond, NULL));
+	LONGS_EQUAL(CELIX_SUCCESS, celixThreadCondition_destroy(&cond));
+}
+
+//test wait and signal
+TEST(celix_thread_condition, wait) {
+	struct func_param * param = (struct func_param*) calloc(1,
+			sizeof(struct func_param));
+	celixThreadMutex_create(&param->mu, NULL);
+	celixThreadCondition_init(&param->cond, NULL);
+
+	celixThreadMutex_lock(&param->mu);
+
+	sleep(2);
+
+	celixThread_create(&thread, NULL, thread_test_func_cond_wait, param);
+	LONGS_EQUAL(0, param->i);
+
+	celixThreadCondition_wait(&param->cond, &param->mu);
+	LONGS_EQUAL(666, param->i);
+
+	celixThread_join(thread, NULL);
+	free(param);
+}
+
+//test wait and broadcast on multiple threads
+TEST(celix_thread_condition, broadcast) {
+	celix_thread_t thread2;
+	struct func_param * param = (struct func_param*) calloc(1,sizeof(struct func_param));
+	celixThreadMutex_create(&param->mu, NULL);
+	celixThreadMutex_create(&param->mu2, NULL);
+	celixThreadCondition_init(&param->cond, NULL);
+
+	celixThread_create(&thread, NULL, thread_test_func_cond_broadcast, param);
+	celixThread_create(&thread2, NULL, thread_test_func_cond_broadcast, param);
+
+	sleep(1);
+	celixThreadMutex_lock(&param->mu2);
+	LONGS_EQUAL(0, param->i);
+	celixThreadMutex_unlock(&param->mu2);
+
+	celixThreadMutex_lock(&param->mu);
+	celixThreadCondition_broadcast(&param->cond);
+	celixThreadMutex_unlock(&param->mu);
+	sleep(1);
+	celixThreadMutex_lock(&param->mu2);
+	LONGS_EQUAL(2, param->i);
+	celixThreadMutex_unlock(&param->mu2);
+
+	celixThread_join(thread, NULL);
+	celixThread_join(thread2, NULL);
+	free(param);
+}
+
+//----------------------TEST THREAD FUNCTION DEFINES----------------------
+
+static void * thread_test_func_create(void * arg) {
+	char ** test_str = (char**) arg;
+	*test_str = my_strdup("SUCCESS");
+	celixThread_exit(NULL);
+}
+
+static void * thread_test_func_exit(void *) {
+	int *pi = (int*) calloc(1, sizeof(int));
+	*pi = 666;
+	celixThread_exit(pi);
+}
+
+static void * thread_test_func_detach(void *) {
+	celixThread_exit(NULL);
+}
+
+static void * thread_test_func_self(void * arg) {
+	*((celix_thread*) arg) = celixThread_self();
+	celixThread_exit(NULL);
+}
+
+static void * thread_test_func_lock(void *arg) {
+	struct func_param *param = (struct func_param *) arg;
+
+	celixThreadMutex_lock(&param->mu2);
+	celixThreadMutex_lock(&param->mu);
+	param->i = 666;
+	celixThreadMutex_unlock(&param->mu);
+	celixThreadMutex_unlock(&param->mu2);
+
+	celixThread_exit(NULL);
+}
+
+static void * thread_test_func_cond_wait(void *arg) {
+	struct func_param *param = (struct func_param *) arg;
+
+	celixThreadMutex_lock(&param->mu);
+
+	param->i = 666;
+
+	celixThreadCondition_signal(&param->cond);
+	celixThreadMutex_unlock(&param->mu);
+	celixThread_exit(NULL);
+}
+
+static void * thread_test_func_cond_broadcast(void *arg) {
+	struct func_param *param = (struct func_param *) arg;
+
+	celixThreadMutex_lock(&param->mu);
+	celixThreadCondition_wait(&param->cond, &param->mu);
+	celixThreadMutex_unlock(&param->mu);
+	celixThreadMutex_lock(&param->mu2);
+	param->i++;
+	celixThreadMutex_unlock(&param->mu2);
+	celixThread_exit(NULL);
+}
+
+static int thread_test_func_recur_lock(celix_thread_mutex_t *mu, int i) {
+	int temp;
+	if (i == 1) {
+		return 1;
+	} else {
+		celixThreadMutex_lock(mu);
+		temp = thread_test_func_recur_lock(mu, i - 1);
+		temp *= i;
+		celixThreadMutex_unlock(mu);
+		return temp;
+	}
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/c6d2d59f/utils/private/test/hash_map_test.c
----------------------------------------------------------------------
diff --git a/utils/private/test/hash_map_test.c b/utils/private/test/hash_map_test.c
deleted file mode 100644
index f92ea40..0000000
--- a/utils/private/test/hash_map_test.c
+++ /dev/null
@@ -1,478 +0,0 @@
-/**
- *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.
- */
-/*
- * hash_map_test.c
- *
- *  \date       Jul 25, 2010
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <CUnit/Automated.h>
-#include <stddef.h>
-
-#include "celixbool.h"
-
-#include "hash_map.h"
-#include "hash_map_private.h"
-
-hash_map_pt map;
-
-int setup(void) {
-	printf("test\n");
-	map = hashMap_create(NULL, NULL, NULL, NULL);
-	if(map == NULL) {
-		return 1;
-	}
-	return 0;
-}
-
-void test_hashMap_create(void) {
-	CU_ASSERT_PTR_NOT_NULL_FATAL(map);
-	CU_ASSERT_EQUAL(map->size, 0);
-	// This fails on windows due to dllimport providing a proxy for exported functions.
-	CU_ASSERT_EQUAL(map->equalsKey, hashMap_equals);
-	CU_ASSERT_EQUAL(map->equalsValue, hashMap_equals);
-	CU_ASSERT_EQUAL(map->hashKey, hashMap_hashCode);
-	CU_ASSERT_EQUAL(map->hashValue, hashMap_hashCode);
-}
-
-void test_hashMap_size(void) {
-	char * key = "key";
-	char * value = "value";
-	char * key2 = "key2";
-	char * value2 = "value2";
-	char * key3 = strdup("key2");
-	char * value3 = "value3";
-
-	CU_ASSERT_EQUAL(map->size, 0);
-
-	// Add one entry
-	hashMap_put(map, key, value);
-	CU_ASSERT_EQUAL(map->size, 1);
-
-	// Add second entry
-	hashMap_put(map, key2, value2);
-	CU_ASSERT_EQUAL(map->size, 2);
-
-	// Add entry using the same key, this does not overwrite an existing entry
-	hashMap_put(map, key3, value3);
-	CU_ASSERT_EQUAL(map->size, 3);
-
-	// Clear map
-	hashMap_clear(map, false, false);
-	CU_ASSERT_EQUAL(map->size, 0);
-}
-
-void test_hashMap_isEmpty(void) {
-	char * key = "key";
-	char * value = "value";
-
-	hashMap_clear(map, false, false);
-	CU_ASSERT_EQUAL(map->size, 0);
-	CU_ASSERT_TRUE(hashMap_isEmpty(map));
-
-	// Add one entry
-	hashMap_put(map, key, value);
-	CU_ASSERT_EQUAL(map->size, 1);
-	CU_ASSERT_FALSE(hashMap_isEmpty(map));
-
-	// Remove entry
-	hashMap_remove(map, key);
-	CU_ASSERT_EQUAL(map->size, 0);
-	CU_ASSERT_TRUE(hashMap_isEmpty(map));
-}
-
-void test_hashMap_get(void) {
-	char * key = "key";
-	char * value = "value";
-	char * key2 = "key2";
-	char * value2 = "value2";
-	char * neKey = "notExisting";
-	char * key3 = NULL;
-	char * value3 = "value3";
-    char * get;
-
-	hashMap_clear(map, false, false);
-
-	// Add one entry
-	hashMap_put(map, key, value);
-
-	// Add second entry
-	hashMap_put(map, key2, value2);
-
-	get = hashMap_get(map, key);
-	CU_ASSERT_STRING_EQUAL(get, value);
-
-	get = hashMap_get(map, key2);
-	CU_ASSERT_STRING_EQUAL(get, value2);
-
-	get = hashMap_get(map, neKey);
-	CU_ASSERT_EQUAL(get, NULL);
-
-	get = hashMap_get(map, NULL);
-	CU_ASSERT_EQUAL(get, NULL);
-
-	// Add third entry with NULL key
-	hashMap_put(map, key3, value3);
-
-	get = hashMap_get(map, NULL);
-	CU_ASSERT_STRING_EQUAL(get, value3);
-}
-
-void test_hashMap_containsKey(void) {
-	char * key = "key";
-	char * value = "value";
-	char * key2 = "key2";
-	char * value2 = "value2";
-	char * neKey = "notExisting";
-	char * key3 = NULL;
-	char * value3 = "value3";
-
-	hashMap_clear(map, false, false);
-
-	// Add one entry
-	hashMap_put(map, key, value);
-
-	// Add second entry
-	hashMap_put(map, key2, value2);
-
-	CU_ASSERT_TRUE(hashMap_containsKey(map, key));
-	CU_ASSERT_TRUE(hashMap_containsKey(map, key2));
-	CU_ASSERT_FALSE(hashMap_containsKey(map, neKey));
-	CU_ASSERT_FALSE(hashMap_containsKey(map, NULL));
-
-	// Add third entry with NULL key
-	hashMap_put(map, key3, value3);
-
-	CU_ASSERT_TRUE(hashMap_containsKey(map, key3));
-}
-
-void test_hashMap_getEntry(void) {
-	char * key = "key";
-	char * value = "value";
-	char * key2 = "key2";
-	char * value2 = "value2";
-	char * neKey = "notExisting";
-	char * key3 = NULL;
-	char * value3 = "value3";
-	hash_map_entry_pt entry;
-	
-	hashMap_clear(map, false, false);
-
-	// Add one entry
-	hashMap_put(map, key, value);
-
-	// Add second entry
-	hashMap_put(map, key2, value2);
-	entry = hashMap_getEntry(map, key);
-	CU_ASSERT_STRING_EQUAL(entry->key, key);
-	CU_ASSERT_STRING_EQUAL(entry->value, value);
-
-	entry = hashMap_getEntry(map, key2);
-	CU_ASSERT_STRING_EQUAL(entry->key, key2);
-	CU_ASSERT_STRING_EQUAL(entry->value, value2);
-
-	entry = hashMap_getEntry(map, neKey);
-	CU_ASSERT_EQUAL(entry, NULL);
-
-	entry = hashMap_getEntry(map, NULL);
-	CU_ASSERT_EQUAL(entry, NULL);
-
-	// Add third entry with NULL key
-	hashMap_put(map, key3, value3);
-
-	entry = hashMap_getEntry(map, key3);
-	CU_ASSERT_EQUAL(entry->key, key3);
-	CU_ASSERT_STRING_EQUAL(entry->value, value3);
-}
-
-void test_hashMap_put(void) {
-	char * key = "key";
-	char * value = "value";
-	char * key2 = "key2";
-	char * value2 = "value2";
-	char * nkey2 = strdup("key2");
-	char * nvalue2 = "value3";
-	char * key3 = NULL;
-	char * value3 = "value3";
-	char * key4 = "key4";
-	char * value4 = NULL;
-	char * old;
-	char * get;
-	
-	hashMap_clear(map, false, false);
-
-	// Add one entry
-	hashMap_put(map, key, value);
-
-	// Add second entry
-	hashMap_put(map, key2, value2);
-
-	get = hashMap_get(map, key);
-	CU_ASSERT_STRING_EQUAL(get, value);
-
-	get = hashMap_get(map, key2);
-	CU_ASSERT_STRING_EQUAL(get, value2);
-
-	// Try to add an entry with the same key, since no explicit hash function is used,
-	//   this will not overwrite an existing entry.
-	old = (char *) hashMap_put(map, nkey2, nvalue2);
-	CU_ASSERT_PTR_NULL_FATAL(old);
-
-	// Retrieving the values will return the correct values
-	get = hashMap_get(map, key2);
-	CU_ASSERT_STRING_EQUAL(get, value2);
-	get = hashMap_get(map, nkey2);
-    CU_ASSERT_STRING_EQUAL(get, nvalue2);
-
-	// Add third entry with NULL key
-	hashMap_put(map, key3, value3);
-
-	get = hashMap_get(map, key3);
-	CU_ASSERT_STRING_EQUAL(get, value3);
-
-	// Add fourth entry with NULL value
-	hashMap_put(map, key4, value4);
-
-	get = hashMap_get(map, key4);
-	CU_ASSERT_EQUAL(get, value4);
-}
-
-void test_hashMap_resize(void) {
-	int i;
-	char * k;
-	char key[6];
-	
-	hashMap_clear(map, false, false);
-
-	CU_ASSERT_EQUAL(map->size, 0);
-	CU_ASSERT_EQUAL(map->tablelength, 16);
-	CU_ASSERT_EQUAL(map->treshold, 12);
-	for (i = 0; i < 12; i++) {
-		char key[6];
-		sprintf(key, "key%d", i);
-		k = strdup(key);
-		hashMap_put(map, k, k);
-	}
-	CU_ASSERT_EQUAL(map->size, 12);
-	CU_ASSERT_EQUAL(map->tablelength, 16);
-	CU_ASSERT_EQUAL(map->treshold, 12);
-
-	sprintf(key, "key%d", i);
-	hashMap_put(map, strdup(key), strdup(key));
-	CU_ASSERT_EQUAL(map->size, 13);
-	CU_ASSERT_EQUAL(map->tablelength, 32);
-	CU_ASSERT_EQUAL(map->treshold, 24);
-}
-
-void test_hashMap_remove(void) {
-	char * key = "key";
-	char * value = "value";
-	char * key2 = NULL;
-	char * value2 = "value2";
-	char * removeKey;
-	
-	hashMap_clear(map, false, false);
-
-	// Add one entry
-	hashMap_put(map, key, value);
-
-	// Add second entry with null key
-	hashMap_put(map, key2, value2);
-
-	// Remove unexisting entry for map
-	removeKey = "unexisting";
-	hashMap_remove(map, removeKey);
-	CU_ASSERT_EQUAL(map->size, 2);
-	CU_ASSERT_FALSE(hashMap_isEmpty(map));
-
-	hashMap_remove(map, key);
-	CU_ASSERT_EQUAL(map->size, 1);
-
-	hashMap_remove(map, key2);
-	CU_ASSERT_EQUAL(map->size, 0);
-	CU_ASSERT_TRUE(hashMap_isEmpty(map));
-
-	// Remove unexisting entry for empty map
-	removeKey = "unexisting";
-	hashMap_remove(map, removeKey);
-	CU_ASSERT_EQUAL(map->size, 0);
-	CU_ASSERT_TRUE(hashMap_isEmpty(map));
-}
-
-void test_hashMap_removeMapping(void) {
-	char * key = "key";
-	char * value = "value";
-	char * key2 = NULL;
-	char * value2 = "value2";
-	hash_map_entry_pt entry1;
-	hash_map_entry_pt entry2;
-	hash_map_entry_pt removed;
-
-	hashMap_clear(map, false, false);
-
-	// Add one entry
-	hashMap_put(map, key, value);
-
-	// Add second entry with null key
-	hashMap_put(map, key2, value2);
-
-	entry1 = hashMap_getEntry(map, key);
-	entry2 = hashMap_getEntry(map, key2);
-
-	CU_ASSERT_PTR_NOT_NULL_FATAL(entry1);
-	CU_ASSERT_PTR_NOT_NULL_FATAL(entry2);
-
-	removed = hashMap_removeMapping(map, entry1);
-	CU_ASSERT_PTR_EQUAL(entry1, removed);
-	CU_ASSERT_EQUAL(map->size, 1);
-
-	removed = hashMap_removeMapping(map, entry2);
-	CU_ASSERT_PTR_EQUAL(entry2, removed);
-	CU_ASSERT_EQUAL(map->size, 0);
-
-	// Remove unexisting entry for empty map
-	hashMap_removeMapping(map, NULL);
-	CU_ASSERT_EQUAL(map->size, 0);
-	CU_ASSERT_TRUE(hashMap_isEmpty(map));
-}
-
-void test_hashMap_clear(void) {
-	char * key = "key";
-	char * value = "value";
-	char * key2 = "key2";
-	char * value2 = "value2";
-	char * key3 = NULL;
-	char * value3 = "value3";
-	char * key4 = "key4";
-	char * value4 = NULL;
-
-	hashMap_clear(map, false, false);
-	// Add one entry
-	hashMap_put(map, key, value);
-
-	// Add second entry
-	hashMap_put(map, key2, value2);
-
-	// Add third entry with NULL key
-	hashMap_put(map, key3, value3);
-
-	// Add fourth entry with NULL value
-	hashMap_put(map, key4, value4);
-
-	hashMap_clear(map, false, false);
-	CU_ASSERT_EQUAL(map->size, 0);
-}
-
-void test_hashMap_containsValue(void) {
-	char * key = "key";
-	char * value = "value";
-	char * key2 = "key2";
-	char * value2 = "value2";
-	char * neValue = "notExisting";
-	char * key3 = "key3";
-	char * value3 = NULL;
-
-	hashMap_clear(map, false, false);
-
-	// Add one entry
-	hashMap_put(map, key, value);
-
-	// Add second entry
-	hashMap_put(map, key2, value2);
-
-	CU_ASSERT_TRUE(hashMap_containsValue(map, value));
-	CU_ASSERT_TRUE(hashMap_containsValue(map, value2));
-	CU_ASSERT_FALSE(hashMap_containsValue(map, neValue));
-	CU_ASSERT_FALSE(hashMap_containsValue(map, NULL));
-
-	// Add third entry with NULL value
-	hashMap_put(map, key3, value3);
-
-	CU_ASSERT_TRUE(hashMap_containsValue(map, value3));
-}
-
-void test_hashMapValues_toArray(void) {
-    char * key = "key";
-    char * value = "value";
-    char * key2 = "key2";
-    char * value2 = "value2";
-    char **array;
-    unsigned int size;
-	hash_map_values_pt values;
-
-	hashMap_clear(map, false, false);
-
-    // Add one entry
-    hashMap_put(map, key, value);
-
-    // Add second entry
-    hashMap_put(map, key2, value2);
-
-    values = hashMapValues_create(map);
-    hashMapValues_toArray(values, (void*)&array, &size);
-    CU_ASSERT_EQUAL(size, 2);
-    CU_ASSERT_TRUE(hashMapValues_contains(values, array[0]));
-    CU_ASSERT_TRUE(hashMapValues_contains(values, array[1]));
-}
-
-int main (int argc, char** argv) {
-	CU_pSuite pSuite = NULL;
-
-	/* initialize the CUnit test registry */
-	if (CUE_SUCCESS != CU_initialize_registry())
-	  return CU_get_error();
-
-	/* add a suite to the registry */
-	pSuite = CU_add_suite("Suite_1", setup, NULL);
-	if (NULL == pSuite) {
-	  CU_cleanup_registry();
-	  return CU_get_error();
-	}
-
-	/* add the tests to the suite */
-	if (NULL == CU_add_test(pSuite, "Map Creation Test", test_hashMap_create)
-		|| NULL == CU_add_test(pSuite, "Map Size Test", test_hashMap_size)
-		|| NULL == CU_add_test(pSuite, "Map Is Empty Test", test_hashMap_isEmpty)
-		|| NULL == CU_add_test(pSuite, "Map Get Test", test_hashMap_get)
-		|| NULL == CU_add_test(pSuite, "Map Contains Key Test", test_hashMap_containsKey)
-		|| NULL == CU_add_test(pSuite, "Map Get Entry Test", test_hashMap_getEntry)
-		|| NULL == CU_add_test(pSuite, "Map Put Test", test_hashMap_put)
-		|| NULL == CU_add_test(pSuite, "Map Resize Test", test_hashMap_resize)
-		|| NULL == CU_add_test(pSuite, "Map Remove Test", test_hashMap_remove)
-		|| NULL == CU_add_test(pSuite, "Map Remove Mapping Test", test_hashMap_removeMapping)
-		|| NULL == CU_add_test(pSuite, "Map Clear Test", test_hashMap_clear)
-		|| NULL == CU_add_test(pSuite, "Map Contains Value Test", test_hashMap_containsValue)
-		|| NULL == CU_add_test(pSuite, "Map To Array Test", test_hashMapValues_toArray)
-
-
-	)
-	{
-	  CU_cleanup_registry();
-	  return CU_get_error();
-	}
-
-	CU_set_output_filename(argv[1]);
-	CU_list_tests_to_file();
-	CU_automated_run_tests();
-	CU_cleanup_registry();
-	return CU_get_error();
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/c6d2d59f/utils/private/test/hash_map_test.cpp
----------------------------------------------------------------------
diff --git a/utils/private/test/hash_map_test.cpp b/utils/private/test/hash_map_test.cpp
new file mode 100644
index 0000000..1ef9337
--- /dev/null
+++ b/utils/private/test/hash_map_test.cpp
@@ -0,0 +1,1492 @@
+/**
+ *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.
+ */
+/*
+ * hash_map_test.cpp
+ *
+ * 	\date       Sep 15, 2015
+ *  \author    	Menno van der Graaf & Alexander
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <string.h>
+#include "celixbool.h"
+
+#include "CppUTest/TestHarness.h"
+#include "CppUTest/TestHarness_c.h"
+#include "CppUTest/CommandLineTestRunner.h"
+
+extern "C"
+{
+#include "hash_map.h"
+#include "hash_map_private.h"
+}
+
+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;
+}
+
+//Callback functions
+unsigned int test_hashKeyChar(void * k) {
+	char * str = (char *) k;
+
+	unsigned int hash = 1315423911;
+	unsigned int i    = 0;
+	int len = strlen(str);
+
+	for(i = 0; i < len; str++, i++)
+	{
+		hash ^= ((hash << 5) + (*str) + (hash >> 2));
+	}
+
+	return hash;
+}
+
+unsigned int test_hashValueChar(void * v) {
+	return 0;
+}
+
+int test_equalsKeyChar(void * k, void * o) {
+	return strcmp((char *)k, (char *) o) == 0;
+}
+
+int test_equalsValueChar(void * v, void * o) {
+	return strcmp((char *)v, (char *) o) == 0;
+}
+
+//Tests group defines
+
+TEST_GROUP(hash_map){
+	hash_map_pt map;
+
+	void setup() {
+		map = hashMap_create(NULL, NULL, NULL, NULL);
+	}
+	void teardown() {
+		hashMap_destroy(map, false, false);
+	}
+};
+
+TEST_GROUP(hash_map_iterator){
+	hash_map_pt map;
+	hash_map_iterator_pt it_map;
+
+	void setup() {
+		map = hashMap_create(NULL, NULL, NULL, NULL);
+	}
+	void teardown() {
+		hashMap_destroy(map, false, false);
+	}
+};
+
+TEST_GROUP(hash_map_values){
+	hash_map_pt map;
+	hash_map_values_pt values;
+
+	void setup() {
+		map = hashMap_create(NULL, NULL, NULL, NULL);
+	}
+	void teardown() {
+		hashMap_destroy(map, false, false);
+	}
+};
+
+TEST_GROUP(hash_map_keySet){
+	hash_map_pt map;
+	hash_map_key_set_pt key_set;
+
+	void setup() {
+		map = hashMap_create(NULL, NULL, NULL, NULL);
+	}
+	void teardown() {
+		hashMap_destroy(map, false, false);
+	}
+};
+
+TEST_GROUP(hash_map_entrySet){
+	hash_map_pt map;
+	hash_map_entry_set_pt entry_set;
+
+	void setup() {
+		map = hashMap_create(NULL, NULL, NULL, NULL);
+	}
+	void teardown() {
+		hashMap_destroy(map, false, false);
+	}
+};
+
+TEST_GROUP(hash_map_hash) {
+	hash_map_pt map;
+
+	void setup(void) {
+		map = hashMap_create(test_hashKeyChar, test_hashValueChar, test_equalsKeyChar, test_equalsValueChar);
+	}
+	void teardown() {
+		hashMap_destroy(map, false, false);
+	}
+};
+
+//----------------------HASH MAP DATA MANAGEMENT TEST----------------------
+
+TEST(hash_map, create){
+	CHECK(map != NULL);
+	LONGS_EQUAL(0, map->size);
+	// This fails on windows due to dllimport providing a proxy for exported functions.
+	CHECK_EQUAL(hashMap_equals, map->equalsKey);
+	CHECK_EQUAL(hashMap_equals, map->equalsValue);
+	CHECK_EQUAL(hashMap_hashCode, map->hashKey);
+	CHECK_EQUAL(hashMap_hashCode, map->hashValue);
+}
+
+TEST(hash_map, size){
+	char* key = my_strdup("key");
+	char* value = my_strdup("value");
+	char* key2 = my_strdup("key2");
+	char* value2 = my_strdup("value2");
+	char* key3 = my_strdup("key2");
+	char* value3 = my_strdup("value3");
+
+	LONGS_EQUAL(0, map->size);
+
+	// Add one entry
+	hashMap_put(map, key, value);
+	LONGS_EQUAL(1, map->size);
+
+	// Add second entry
+	hashMap_put(map, key2, value2);
+	LONGS_EQUAL(2, map->size);
+
+	// Add entry using the same key, this does not overwrite an existing entry
+	hashMap_put(map, key3, value3);
+	LONGS_EQUAL(3, map->size);
+
+	// Clear map
+	hashMap_clear(map, true, true);
+	LONGS_EQUAL(0, map->size);
+}
+
+TEST(hash_map, isEmpty){
+	char * key = my_strdup("key");
+	char * value = my_strdup("value");
+
+	LONGS_EQUAL(0, map->size);
+	CHECK(hashMap_isEmpty(map));
+
+	// Add one entry
+	hashMap_put(map, key, value);
+	LONGS_EQUAL(1, map->size);
+	CHECK(!hashMap_isEmpty(map));
+
+	// Remove entry
+	hashMap_remove(map, key);
+	LONGS_EQUAL(0, map->size);
+	CHECK(hashMap_isEmpty(map));
+
+	free(key);
+	free(value);
+}
+
+TEST(hash_map, get){
+	char * key = my_strdup("key");
+	char * value = my_strdup("value");
+	char * key2 = my_strdup("key2");
+	char * value2 = my_strdup("value2");
+	char * neKey = my_strdup("notExisting");
+	char * key3 = NULL;
+	char * value3 = my_strdup("value3");
+	char * get;
+
+	// Add one entry
+	hashMap_put(map, key, value);
+
+	// Add second entry
+	hashMap_put(map, key2, value2);
+
+	get = (char*) (char*) hashMap_get(map, key);
+	STRCMP_EQUAL(value, get);
+
+	get = (char*) hashMap_get(map, key2);
+	STRCMP_EQUAL(value2, get);
+
+	get = (char*) hashMap_get(map, neKey);
+	POINTERS_EQUAL(NULL, get);
+
+	get = (char*) hashMap_get(map, NULL);
+	POINTERS_EQUAL(NULL, get);
+
+	// Add third entry with NULL key
+	hashMap_put(map, key3, value3);
+
+	get = (char*) hashMap_get(map, NULL);
+	STRCMP_EQUAL(value3, get);
+
+	free(neKey);
+	hashMap_clear(map, true, true);
+}
+
+TEST(hash_map, containsKey){
+	char * key = my_strdup("key");
+	char * value = my_strdup("value");
+	char * key2 = my_strdup("key2");
+	char * value2 = my_strdup("value2");
+	char * neKey = my_strdup("notExisting");
+	char * key3 = NULL;
+	char * value3 = my_strdup("value3");
+
+	// Add one entry
+	hashMap_put(map, key, value);
+
+	// Add second entry
+	hashMap_put(map, key2, value2);
+
+	CHECK(hashMap_containsKey(map, key));
+	CHECK(hashMap_containsKey(map, key2));
+	CHECK(!hashMap_containsKey(map, neKey));
+	CHECK(!hashMap_containsKey(map, NULL));
+
+	// Add third entry with NULL key
+	hashMap_put(map, key3, value3);
+
+	CHECK(hashMap_containsKey(map, key3));
+
+	free(neKey);
+	hashMap_clear(map, true, true);
+}
+
+TEST(hash_map, getEntry){
+	char * key = my_strdup("key");
+	char * value = my_strdup("value");
+	char * key2 = my_strdup("key2");
+	char * value2 = my_strdup("value2");
+	char * neKey = my_strdup("notExisting");
+	char * key3 = NULL;
+	char * value3 = my_strdup("value3");
+	hash_map_entry_pt entry;
+
+	// Add one entry
+	hashMap_put(map, key, value);
+
+	// Add second entry
+	hashMap_put(map, key2, value2);
+	entry = hashMap_getEntry(map, key);
+	STRCMP_EQUAL(key, (char*) entry->key);
+	STRCMP_EQUAL(value, (char*)entry->value);
+
+	entry = hashMap_getEntry(map, key2);
+	STRCMP_EQUAL(key2, (char*) entry->key);
+	STRCMP_EQUAL(value2, (char*) entry->value);
+
+	entry = hashMap_getEntry(map, neKey);
+	POINTERS_EQUAL(NULL, entry);
+
+	entry = hashMap_getEntry(map, NULL);
+	POINTERS_EQUAL(NULL, entry);
+
+	// Add third entry with NULL key
+	hashMap_put(map, key3, value3);
+
+	entry = hashMap_getEntry(map, key3);
+	CHECK_EQUAL(key3, entry->key);
+	STRCMP_EQUAL(value3, (char*) entry->value);
+
+	free(neKey);
+	hashMap_clear(map, true, true);
+}
+
+TEST(hash_map, put){
+	char * key = my_strdup("key");
+	char * value = my_strdup("value");
+	char * key2 = my_strdup("key2");
+	char * value2 = my_strdup("value2");
+	char * nkey2 = my_strdup("key2");
+	char * nvalue2 = my_strdup("value3");
+	char * key3 = NULL;
+	char * value3 = my_strdup("value3");
+	char * key4 = my_strdup("key4");
+	char * value4 = NULL;
+	char * old;
+	char * get;
+
+	// Add one entry
+	hashMap_put(map, key, value);
+
+	// Add second entry
+	hashMap_put(map, key2, value2);
+
+	get = (char*) hashMap_get(map, key);
+	STRCMP_EQUAL(value, get);
+
+	get = (char*) hashMap_get(map, key2);
+	STRCMP_EQUAL(value2, get);
+
+	// Try to add an entry with the same key, since no explicit hash function is used,
+	//   this will not overwrite an existing entry.
+	old = (char *) hashMap_put(map, nkey2, nvalue2);
+	POINTERS_EQUAL(NULL, old);
+
+	// Retrieving the values will return the correct values
+	get = (char*) hashMap_get(map, (void*)key2);
+	STRCMP_EQUAL(value2, get);
+	get = (char*) hashMap_get(map, nkey2);
+	STRCMP_EQUAL(nvalue2, get);
+
+	// Add third entry with NULL key
+	hashMap_put(map, key3, value3);
+
+	get = (char*) hashMap_get(map, key3);
+	STRCMP_EQUAL(value3, get);
+
+	// Add fourth entry with NULL value
+	hashMap_put(map, key4, value4);
+
+	get =(char*)hashMap_get(map, key4);
+	CHECK_EQUAL(value4, get);
+
+	hashMap_clear(map, true, true);
+}
+
+TEST(hash_map, resize){
+	int i;
+	char * k;
+	char key[6];
+
+	LONGS_EQUAL(0, map->size);
+	LONGS_EQUAL(16, map->tablelength);
+	LONGS_EQUAL(12, map->treshold);
+	for (i = 0; i < 12; i++) {
+		char key[6];
+		sprintf(key, "key%d", i);
+		hashMap_put(map, my_strdup(key), my_strdup(key));
+	}
+	LONGS_EQUAL(12, map->size);
+	LONGS_EQUAL(16, map->tablelength);
+	LONGS_EQUAL(12, map->treshold);
+
+	sprintf(key, "key%d", i);
+	hashMap_put(map, my_strdup(key), my_strdup(key));
+	LONGS_EQUAL(13, map->size);
+	LONGS_EQUAL(32, map->tablelength);
+	LONGS_EQUAL(24, map->treshold);
+
+	hashMap_clear(map, true, true);
+}
+
+TEST(hash_map, remove){
+	char * key = my_strdup("key");
+	char * value = my_strdup("value");
+	char * key2 = NULL;
+	char * value2 = my_strdup("value2");
+	char * removeKey;
+
+	// Add one entry
+	hashMap_put(map, key, value);
+
+	// Add second entry with null key
+	hashMap_put(map, key2, value2);
+
+	// Remove unexisting entry for map
+	removeKey = my_strdup("unexisting");
+	hashMap_remove(map, removeKey);
+	LONGS_EQUAL(2, map->size);
+	CHECK(!hashMap_isEmpty(map));
+
+	hashMap_remove(map, key);
+	LONGS_EQUAL(1, map->size);
+
+	hashMap_remove(map, key2);
+	LONGS_EQUAL(0, map->size);
+	CHECK(hashMap_isEmpty(map));
+
+	// Remove unexisting entry for empty map
+	hashMap_remove(map, removeKey);
+	LONGS_EQUAL(0, map->size);
+	CHECK(hashMap_isEmpty(map));
+
+	free(key);
+	free(value);
+	free(key2);
+	free(value2);
+	free(removeKey);
+}
+
+TEST(hash_map, removeMapping){
+	char * key = my_strdup("key");
+	char * value = my_strdup("value");
+	char * key2 = NULL;
+	char * value2 = my_strdup("value2");
+	hash_map_entry_pt entry1;
+	hash_map_entry_pt entry2;
+	hash_map_entry_pt removed;
+
+	// Add one entry
+	hashMap_put(map, key, value);
+
+	// Add second entry with null key
+	hashMap_put(map, key2, value2);
+
+	entry1 = hashMap_getEntry(map, key);
+	entry2 = hashMap_getEntry(map, key2);
+
+	CHECK(entry1 != NULL);
+	CHECK(entry2 != NULL);
+
+	removed = hashMap_removeMapping(map, entry1);
+	POINTERS_EQUAL(removed, entry1);
+	LONGS_EQUAL(1, map->size);
+
+	removed = hashMap_removeMapping(map, entry2);
+	POINTERS_EQUAL(removed, entry2);
+	LONGS_EQUAL(0, map->size);
+
+	// Remove unexisting entry for empty map
+	hashMap_removeMapping(map, NULL);
+	LONGS_EQUAL(0, map->size);
+	CHECK(hashMap_isEmpty(map));
+
+	free(key);
+	free(value);
+	free(key2);
+	free(value2);
+	free(entry1);
+	free(entry2);
+}
+
+TEST(hash_map, clear){
+	char * key = my_strdup("key");
+	char * value = my_strdup("value");
+	char * key2 = my_strdup("key2");
+	char * value2 = my_strdup("value2");
+	char * key3 = NULL;
+	char * value3 = my_strdup("value3");
+	char * key4 = my_strdup("key4");
+	char * value4 = NULL;
+
+	// Add one entry
+	hashMap_put(map, key, value);
+
+	// Add second entry
+	hashMap_put(map, key2, value2);
+
+	// Add third entry with NULL key
+	hashMap_put(map, key3, value3);
+
+	// Add fourth entry with NULL value
+	hashMap_put(map, key4, value4);
+
+	// Clear but leave keys and values intact
+	hashMap_clear(map, false, false);
+	LONGS_EQUAL(0, map->size);
+
+	// Add one entry
+	hashMap_put(map, key, value);
+
+	// Add second entry
+	hashMap_put(map, key2, value2);
+
+	// Add third entry with NULL key
+	hashMap_put(map, key3, value3);
+
+	// Add fourth entry with NULL value
+	hashMap_put(map, key4, value4);
+	// Clear and clean up keys and values
+	hashMap_clear(map, true, true);
+	LONGS_EQUAL(0, map->size);
+}
+
+TEST(hash_map, containsValue){
+	char * key = my_strdup("key");
+	char * value = my_strdup("value");
+	char * key2 = my_strdup("key2");
+	char * value2 = my_strdup("value2");
+	char * neValue = my_strdup("notExisting");
+	char * key3 = my_strdup("key3");
+	char * value3 = NULL;
+
+	// Add one entry
+	hashMap_put(map, key, value);
+
+	// Add second entry
+	hashMap_put(map, key2, value2);
+
+	CHECK(hashMap_containsValue(map, value));
+	CHECK(hashMap_containsValue(map, value2));
+	CHECK(!hashMap_containsValue(map, neValue));
+	CHECK(!hashMap_containsValue(map, NULL));
+
+	// Add third entry with NULL value
+	hashMap_put(map, key3, value3);
+
+	CHECK(hashMap_containsValue(map, value3));
+
+	free(neValue);
+	hashMap_clear(map, true, true);
+}
+
+TEST(hash_map, ValuestoArray){
+	char * key = my_strdup("key");
+	char * value = my_strdup("value");
+	char * key2 = my_strdup("key2");
+	char * value2 = my_strdup("value2");
+	char **array;
+	unsigned int size;
+	hash_map_values_pt values;
+
+	// Add one entry
+	hashMap_put(map, key, value);
+
+	// Add second entry
+	hashMap_put(map, key2, value2);
+
+	values = hashMapValues_create(map);
+	hashMapValues_toArray(values, (void***)&array, &size);
+	LONGS_EQUAL(2, size);
+	CHECK(hashMapValues_contains(values, array[0]));
+	CHECK(hashMapValues_contains(values, array[1]));
+
+	free(array);
+	hashMapValues_destroy(values);
+	hashMap_clear(map, true, true);
+}
+
+TEST(hash_map, entryGetKey){
+	char * key = my_strdup("key");
+	char * value = my_strdup("value");
+	char * key2 = my_strdup("key2");
+	char * value2 = my_strdup("value2");
+	char * key3 = NULL;
+	char * value3 = my_strdup("value3");
+	char * get;
+	hash_map_entry_pt entry;
+
+	// Add 2 entrys
+	hashMap_put(map, key, value);
+	hashMap_put(map, key2, value2);
+	hashMap_put(map, key3, value3);
+
+	entry = hashMap_getEntry(map, key);
+	get = (char*) hashMapEntry_getKey(entry);
+	STRCMP_EQUAL(key, get);
+
+	entry = hashMap_getEntry(map, key2);
+	get = (char*) hashMapEntry_getKey(entry);
+	STRCMP_EQUAL(key2, get);
+
+	entry = hashMap_getEntry(map, key3);
+	get = (char*) hashMapEntry_getKey(entry);
+	POINTERS_EQUAL(key3, get);
+
+	hashMap_clear(map, true, true);
+}
+
+TEST(hash_map, entryGetValue){
+	char * key = my_strdup("key");
+	char * value = my_strdup("value");
+	char * key2 = my_strdup("key2");
+	char * value2 = my_strdup("value2");
+	char * key3 = NULL;
+	char * value3 = my_strdup("value3");
+	char * get;
+	hash_map_entry_pt entry;
+
+	// Add 2 entrys
+	hashMap_put(map, key, value);
+	hashMap_put(map, key2, value2);
+	hashMap_put(map, key3, value3);
+
+	entry = hashMap_getEntry(map, key);
+	get = (char*) hashMapEntry_getValue(entry);
+	STRCMP_EQUAL(value, get);
+
+	entry = hashMap_getEntry(map, key2);
+	get = (char*) hashMapEntry_getValue(entry);
+	STRCMP_EQUAL(value2, get);
+
+	entry = hashMap_getEntry(map, key3);
+	get = (char*) hashMapEntry_getValue(entry);
+	POINTERS_EQUAL(value3, get);
+
+	hashMap_clear(map, true, true);
+}
+
+//----------------------HASH MAP ITERATOR TEST----------------------
+
+TEST(hash_map_iterator, create){
+	it_map = hashMapIterator_create(map);
+	CHECK(it_map != NULL);
+	POINTERS_EQUAL(map, it_map->map);
+	POINTERS_EQUAL(it_map->current, NULL);
+	LONGS_EQUAL(map->modificationCount, it_map->expectedModCount);
+
+	hashMapIterator_destroy(it_map);
+}
+
+TEST(hash_map_iterator, hasNext){
+	char * key = my_strdup("key");
+	char * value = my_strdup("value");
+	char * key2 = my_strdup("key2");
+	char * value2 = my_strdup("value2");
+	char * key3 = my_strdup("key3");
+	char * value3 = my_strdup("value3");
+
+	// Add one entry
+	hashMap_put(map, key, value);
+
+	// Add second entry
+	hashMap_put(map, key2, value2);
+
+	// Add third entry
+	hashMap_put(map, key3, value3);
+
+	//create it_map from map
+	it_map = hashMapIterator_create(map);
+
+	//check hasNext
+	CHECK(hashMapIterator_hasNext(it_map));
+
+	hashMapIterator_nextEntry(it_map);
+	CHECK(hashMapIterator_hasNext(it_map));
+
+	hashMapIterator_nextEntry(it_map);
+	CHECK(hashMapIterator_hasNext(it_map));
+
+	//third entry next points to NULL
+	hashMapIterator_nextEntry(it_map);
+	CHECK(!hashMapIterator_hasNext(it_map));
+
+	hashMapIterator_destroy(it_map);
+	hashMap_clear(map, true, true);
+}
+
+TEST(hash_map_iterator, remove){
+	char * key = my_strdup("key");
+	char * value = my_strdup("value");
+	char * key2 = my_strdup("key2");
+	char * value2 = my_strdup("value2");
+	char * key3 = my_strdup("key3");
+	char * value3 = my_strdup("value3");
+
+	// Add 3 entrys
+	hashMap_put(map, key, value);
+	hashMap_put(map, key2, value2);
+	hashMap_put(map, key3, value3);
+
+	//create it_map from map
+	it_map = hashMapIterator_create(map);
+
+	//try to remove current (NULL)
+	hashMapIterator_remove(it_map);
+	LONGS_EQUAL(3, map->size);
+
+	//delete the first and second entry
+	hashMapIterator_nextEntry(it_map);
+	hashMapIterator_remove(it_map);
+	hashMapIterator_nextEntry(it_map);
+	hashMapIterator_remove(it_map);
+	LONGS_EQUAL(1, map->size);
+
+	free(key);
+	free(value);
+	free(key2);
+	free(value2);
+	free(key3);
+	free(value3);
+	hashMapIterator_destroy(it_map);
+}
+
+TEST(hash_map_iterator, nextValue){
+	char * key = my_strdup("key");
+	char * value = my_strdup("value");
+	char * key2 = my_strdup("key2");
+	char * value2 = my_strdup("value2");
+	char * getValue;
+
+	// Add 2 entrys
+	hashMap_put(map, key, value);
+	hashMap_put(map, key2, value2);
+
+	//create it_map from map
+	it_map = hashMapIterator_create(map);
+
+	getValue = (char*) hashMapIterator_nextValue(it_map);
+	CHECK(hashMap_containsValue(map, getValue));
+
+	getValue = (char*) hashMapIterator_nextValue(it_map);
+	CHECK(hashMap_containsValue(map, getValue));
+
+	getValue = (char*) hashMapIterator_nextValue(it_map);
+	POINTERS_EQUAL(NULL, getValue);
+
+	hashMapIterator_destroy(it_map);
+	hashMap_clear(map, true, true);
+}
+
+TEST(hash_map_iterator, nextKey){
+	char * key = my_strdup("key");
+	char * value = my_strdup("value");
+	char * key2 = my_strdup("key2");
+	char * value2 = my_strdup("value2");
+	char * getKey;
+
+	// Add 2 entrys
+	hashMap_put(map, key, value);
+	hashMap_put(map, key2, value2);
+
+	//create it_map from map
+	it_map = hashMapIterator_create(map);
+
+	getKey = (char*) hashMapIterator_nextKey(it_map);
+	CHECK(hashMap_containsKey(map, getKey));
+
+	getKey = (char*) hashMapIterator_nextKey(it_map);
+	CHECK(hashMap_containsKey(map, getKey));
+
+	getKey = (char*) hashMapIterator_nextKey(it_map);
+	POINTERS_EQUAL(NULL, getKey);
+
+	hashMapIterator_destroy(it_map);
+	hashMap_clear(map, true, true);
+}
+
+TEST(hash_map_iterator, nextEntry){
+	char * key = my_strdup("key");
+	char * value = my_strdup("value");
+	char * key2 = my_strdup("key2");
+	char * value2 = my_strdup("value2");
+	char * getValue;
+	hash_map_entry_pt get;
+
+	// Add 2 entrys
+	hashMap_put(map, key, value);
+	hashMap_put(map, key2, value2);
+
+	//create it_map from map
+	it_map = hashMapIterator_create(map);
+
+	get = (hash_map_entry_pt) hashMapIterator_nextEntry(it_map);
+	getValue = (char*) hashMap_get(map, get->key);
+	STRCMP_EQUAL((char*)get->value, (char*)getValue);
+
+	get = (hash_map_entry_pt) hashMapIterator_nextEntry(it_map);
+	getValue = (char*) hashMap_get(map, get->key);
+	STRCMP_EQUAL((char*)get->value, (char*)getValue);
+
+	get = (hash_map_entry_pt) hashMapIterator_nextEntry(it_map);
+	POINTERS_EQUAL(NULL, get);
+
+	hashMapIterator_destroy(it_map);
+	hashMap_clear(map, true, true);
+}
+
+TEST(hash_map_iterator, valuesIterator){
+	hash_map_values_pt values;
+	hash_map_iterator_pt it_val;
+
+	values = hashMapValues_create(map);
+	it_val = hashMapValues_iterator(values);
+
+	POINTERS_EQUAL(map, it_val->map);
+
+	hashMapIterator_destroy(it_val);
+	hashMapValues_destroy(values);
+}
+
+//----------------------HASH MAP VALUES TEST----------------------
+
+TEST(hash_map_values, create){
+	char * key = my_strdup("key");
+	char * value = my_strdup("value");
+	char * key2 = my_strdup("key2");
+	char * value2 = my_strdup("value2");
+
+	// Add 2 entrys
+	hashMap_put(map, key, value);
+	hashMap_put(map, key2, value2);
+
+	//create Values from map
+	values = hashMapValues_create(map);
+
+	CHECK(hashMapValues_contains(values, value));
+	CHECK(hashMapValues_contains(values, value2));
+
+	hashMap_clear(map, true, true);
+	hashMapValues_destroy(values);
+}
+
+TEST(hash_map_values, size){
+	char * key = my_strdup("key");
+	char * value = my_strdup("value");
+	char * key2 = my_strdup("key2");
+	char * value2 = my_strdup("value2");
+
+	// Add 2 entrys
+	hashMap_put(map, key, value);
+	hashMap_put(map, key2, value2);
+
+	//create Values from map
+	values = hashMapValues_create(map);
+
+	LONGS_EQUAL(2, hashMapValues_size(values));
+
+	hashMap_clear(map, true, true);
+	hashMapValues_destroy(values);
+}
+
+TEST(hash_map_values, remove){
+	char * key = my_strdup("key");
+	char * value = my_strdup("value");
+	char * key2 = my_strdup("key2");
+	char * value2 = my_strdup("value2");
+
+	// Add 2 entrys
+	hashMap_put(map, key, value);
+	hashMap_put(map, key2, value2);
+
+	//create Values from map
+	values = hashMapValues_create(map);
+	CHECK(hashMapValues_contains(values, value));
+	CHECK(hashMapValues_contains(values, value2));
+
+	hashMapValues_remove(values, value);
+	CHECK(!hashMapValues_contains(values, value));
+	CHECK(hashMapValues_contains(values, value2));
+
+	hashMapValues_remove(values, value2);
+	CHECK(!hashMapValues_contains(values, value));
+	CHECK(!hashMapValues_contains(values, value2));
+
+	free(key);
+	free(value);
+	free(key2);
+	free(value2);
+	hashMap_clear(map, true, true);
+	hashMapValues_destroy(values);
+}
+
+TEST(hash_map_values, clear){
+	char * key = my_strdup("key");
+	char * value = my_strdup("value");
+	char * key2 = my_strdup("key2");
+	char * value2 = my_strdup("value2");
+
+	// Add 2 entrys
+	hashMap_put(map, key, value);
+	hashMap_put(map, key2, value2);
+
+	//create Values from map
+	values = hashMapValues_create(map);
+
+	CHECK(hashMapValues_contains(values, value));
+	CHECK(hashMapValues_contains(values, value2));
+	LONGS_EQUAL(2, values->map->size);
+
+	hashMapValues_clear(values);
+
+	CHECK(!hashMapValues_contains(values, value));
+	CHECK(!hashMapValues_contains(values, value2));
+	LONGS_EQUAL(0, values->map->size);
+
+	free(key);
+	free(value);
+	free(key2);
+	free(value2);
+	hashMapValues_destroy(values);
+}
+
+TEST(hash_map_values, isEmpty){
+	char * key = my_strdup("key");
+	char * value = my_strdup("value");
+	char * key2 = my_strdup("key2");
+	char * value2 = my_strdup("value2");
+
+	// Add 2 entrys
+	hashMap_put(map, key, value);
+	hashMap_put(map, key2, value2);
+
+	//create Values from map
+	values = hashMapValues_create(map);
+
+	CHECK(!hashMapValues_isEmpty(values));
+
+	hashMapValues_clear(values);
+
+	CHECK(hashMapValues_isEmpty(values));
+
+	free(key);
+	free(value);
+	free(key2);
+	free(value2);
+	hashMapValues_destroy(values);
+}
+
+//----------------------HASH MAP KEYSET TEST----------------------
+
+TEST(hash_map_keySet, create){
+	key_set = hashMapKeySet_create(map);
+
+	POINTERS_EQUAL(map, key_set->map);
+
+	hashMapKeySet_destroy(key_set);
+}
+
+TEST(hash_map_keySet, size){
+	char * key = my_strdup("key");
+	char * key2 = my_strdup("key2");
+
+	key_set = hashMapKeySet_create(map);
+
+	LONGS_EQUAL(0, hashMapKeySet_size(key_set));
+
+	// Add 2 entrys
+	hashMap_put(map, key, NULL);
+	hashMap_put(map, key2, NULL);
+
+
+	LONGS_EQUAL(2, hashMapKeySet_size(key_set));
+
+	hashMap_clear(map, true, true);
+	hashMapKeySet_destroy(key_set);
+}
+
+TEST(hash_map_keySet, contains){
+	char * key = my_strdup("key");
+	char * key2 = my_strdup("key2");
+
+	key_set = hashMapKeySet_create(map);
+
+	CHECK(!hashMapKeySet_contains(key_set, key));
+	CHECK(!hashMapKeySet_contains(key_set, key2));
+
+	// Add 2 entrys
+	hashMap_put(map, key, NULL);
+
+	CHECK(hashMapKeySet_contains(key_set, key));
+	CHECK(!hashMapKeySet_contains(key_set, key2));
+
+	hashMap_put(map, key2, NULL);
+
+	CHECK(hashMapKeySet_contains(key_set, key));
+	CHECK(hashMapKeySet_contains(key_set, key2));
+
+	hashMap_clear(map, true, true);
+	hashMapKeySet_destroy(key_set);
+}
+
+TEST(hash_map_keySet, remove){
+	char * key = my_strdup("key");
+	char * key2 = my_strdup("key2");
+
+	key_set = hashMapKeySet_create(map);
+
+	// Add 2 entrys
+	hashMap_put(map, key, NULL);
+	hashMap_put(map, key2, NULL);
+
+	LONGS_EQUAL(2, key_set->map->size);
+
+	hashMapKeySet_remove(key_set, key);
+
+	LONGS_EQUAL(1, key_set->map->size);
+
+	hashMapKeySet_remove(key_set, key2);
+
+	LONGS_EQUAL(0, key_set->map->size);
+
+	free(key);
+	free(key2);
+	hashMapKeySet_destroy(key_set);
+}
+
+TEST(hash_map_keySet, clear){
+	char * key = my_strdup("key");
+	char * key2 = my_strdup("key2");
+
+	key_set = hashMapKeySet_create(map);
+
+	// Add 2 entrys
+	hashMap_put(map, key, NULL);
+	hashMap_put(map, key2, NULL);
+
+	LONGS_EQUAL(2, key_set->map->size);
+
+	hashMapKeySet_clear(key_set);
+
+	LONGS_EQUAL(0, key_set->map->size);
+
+	free(key);
+	free(key2);
+	hashMapKeySet_destroy(key_set);
+}
+
+TEST(hash_map_keySet, isEmpty){
+	char * key = my_strdup("key");
+	char * key2 = my_strdup("key2");
+
+	key_set = hashMapKeySet_create(map);
+
+	CHECK(hashMapKeySet_isEmpty(key_set));
+
+	// Add 2 entrys
+	hashMap_put(map, key, NULL);
+	hashMap_put(map, key2, NULL);
+
+	CHECK(!hashMapKeySet_isEmpty(key_set));
+
+	hashMapKeySet_clear(key_set);
+
+	CHECK(hashMapKeySet_isEmpty(key_set));
+
+	free(key);
+	free(key2);
+	hashMapKeySet_destroy(key_set);
+}
+
+//----------------------HASH MAP ENTRYSET TEST----------------------
+
+TEST(hash_map_entrySet, create){
+	entry_set = hashMapEntrySet_create(map);
+
+	POINTERS_EQUAL(map, entry_set->map);
+
+	hashMapEntrySet_destroy(entry_set);
+}
+
+TEST(hash_map_entrySet, size){
+	char * key = my_strdup("key");
+	char * value = my_strdup("value");
+	char * key2 = my_strdup("key2");
+	char * value2 = my_strdup("value2");
+
+
+	entry_set = hashMapEntrySet_create(map);
+
+	LONGS_EQUAL(0, hashMapEntrySet_size(entry_set));
+
+	// Add 2 entrys
+	hashMap_put(map, key, value);
+	hashMap_put(map, key2, value2);
+
+
+	LONGS_EQUAL(2, hashMapEntrySet_size(entry_set));
+
+	hashMap_clear(map, true, true);
+	hashMapEntrySet_destroy(entry_set);
+}
+
+TEST(hash_map_entrySet, contains){
+	char * key = my_strdup("key");
+	char * value = my_strdup("value");
+	char * key2 = my_strdup("key2");
+	char * value2 = my_strdup("value2");
+
+	entry_set = hashMapEntrySet_create(map);
+
+	// Add 2 entrys
+	hashMap_put(map, key, value);
+	hashMap_put(map, key2, value2);
+
+	CHECK(!hashMapEntrySet_contains(entry_set, NULL));
+	CHECK(!hashMapEntrySet_contains(entry_set, hashMap_getEntry(map, key)));
+	CHECK(!hashMapEntrySet_contains(entry_set, hashMap_getEntry(map, key2)));
+
+	hashMap_clear(map, true, true);
+	hashMapEntrySet_destroy(entry_set);
+}
+
+TEST(hash_map_entrySet, remove){
+	char * key = my_strdup("key");
+	char * value = my_strdup("value");
+	char * key2 = my_strdup("key2");
+	char * value2 = my_strdup("value2");
+
+	entry_set = hashMapEntrySet_create(map);
+
+	// Add 2 entrys
+	hashMap_put(map, key, value);
+	hashMap_put(map, key2, value2);
+
+	CHECK(!hashMapEntrySet_remove(entry_set, (hash_map_entry_pt) NULL));
+	LONGS_EQUAL(2, entry_set->map->size);
+
+	CHECK(hashMapEntrySet_remove(entry_set, hashMap_getEntry(map, key)));
+	LONGS_EQUAL(1, entry_set->map->size);
+
+	CHECK(hashMapEntrySet_remove(entry_set, hashMap_getEntry(map, key2)));
+	LONGS_EQUAL(0, entry_set->map->size);
+
+	free(key);
+	free(value);
+	free(key2);
+	free(value2);
+	hashMap_clear(map, false, false);
+	hashMapEntrySet_destroy(entry_set);
+}
+
+TEST(hash_map_entrySet, clear){
+	char * key = my_strdup("key");
+	char * value = my_strdup("value");
+	char * key2 = my_strdup("key2");
+	char * value2 = my_strdup("value2");
+
+	entry_set = hashMapEntrySet_create(map);
+
+	// Add 2 entrys
+	hashMap_put(map, key, value);
+	hashMap_put(map, key2, value2);
+
+	LONGS_EQUAL(2, entry_set->map->size);
+
+	hashMapEntrySet_clear(entry_set);
+
+	LONGS_EQUAL(0, entry_set->map->size);
+
+	free(key);
+	free(value);
+	free(key2);
+	free(value2);
+	hashMapEntrySet_destroy(entry_set);
+}
+
+TEST(hash_map_entrySet, isEmpty){
+	char * key = my_strdup("key");
+	char * value = my_strdup("value");
+	char * key2 = my_strdup("key2");
+	char * value2 = my_strdup("value2");
+
+	entry_set = hashMapEntrySet_create(map);
+
+	CHECK(hashMapEntrySet_isEmpty(entry_set));
+
+	// Add 2 entrys
+	hashMap_put(map, key, value);
+	hashMap_put(map, key2, value2);
+
+	CHECK(!hashMapEntrySet_isEmpty(entry_set));
+
+	hashMapEntrySet_clear(entry_set);
+
+	CHECK(hashMapEntrySet_isEmpty(entry_set));
+
+	free(key);
+	free(value);
+	free(key2);
+	free(value2);
+	hashMapEntrySet_destroy(entry_set);
+}
+
+//----------------------HASH MAP HASH TEST----------------------
+
+TEST(hash_map_hash, get){
+	char * key = my_strdup("key");
+	char * value = my_strdup("value");
+	char * key2 = my_strdup("key2");
+	char * value2 = my_strdup("value2");
+	char * getKey = my_strdup("key");
+	char * get;
+	char * neKey = my_strdup("notExisting");
+	char * key3 = NULL;
+	char * value3 = my_strdup("value3");
+
+	hashMap_clear(map, false, false);
+
+	// Add one entry
+	hashMap_put(map, key, value);
+
+	// Add second entry
+	hashMap_put(map, key2, value2);
+
+	// Get with new created key
+	get = (char*) (char*) hashMap_get(map, getKey);
+	CHECK_C(get != NULL);
+	STRCMP_EQUAL(value, get);
+
+	free(getKey);
+	getKey = my_strdup("key2");
+	get = (char*) hashMap_get(map, getKey);
+	CHECK_C(get != NULL);
+	STRCMP_EQUAL(value2, get);
+
+	get = (char*) hashMap_get(map, neKey);
+	POINTERS_EQUAL(NULL, get);
+
+	get = (char*) hashMap_get(map, NULL);
+	POINTERS_EQUAL(NULL,get);
+
+	// Add third entry with NULL key
+	hashMap_put(map, key3, value3);
+
+	get = (char*) hashMap_get(map, NULL);
+	STRCMP_EQUAL(get, value3);
+
+	free(getKey);
+	free(neKey);
+	hashMap_clear(map, true, true);
+}
+
+TEST(hash_map_hash, containsKey) {
+	char * key = my_strdup("key");
+	char * value = my_strdup("value");
+	char * key2 = my_strdup("key2");
+	char * value2 = my_strdup("value2");
+	char * containsKey = my_strdup("key");
+	char * key3 = NULL;
+	char * value3 = my_strdup("value3");
+
+	hashMap_clear(map, false, false);
+
+	// Add one entry
+	hashMap_put(map, key, value);
+
+	// Add second entry
+	hashMap_put(map, key2, value2);
+
+	CHECK(hashMap_containsKey(map, containsKey));
+	free(containsKey);
+	containsKey = my_strdup("key2");
+	CHECK(hashMap_containsKey(map, containsKey));
+	free(containsKey);
+	containsKey = my_strdup("notExisting");
+	CHECK(!hashMap_containsKey(map, containsKey));
+	free(containsKey);
+	containsKey = NULL;
+	CHECK(!hashMap_containsKey(map, containsKey));
+
+	// Add third entry with NULL key
+	hashMap_put(map, key3, value3);
+
+	containsKey = NULL;
+	CHECK(hashMap_containsKey(map, containsKey));
+
+	hashMap_clear(map, true, true);
+}
+
+TEST(hash_map_hash, getEntry){
+	char * key = my_strdup("key");
+	char * value = my_strdup("value");
+	char * key2 = my_strdup("key2");
+	char * value2 = my_strdup("value2");
+	char * getEntryKey;
+	char * key3 = NULL;
+	char * value3 = my_strdup("value3");
+	hash_map_entry_pt entry;
+
+	hashMap_clear(map, false, false);
+
+	// Add one entry
+	hashMap_put(map, key, value);
+
+	// Add second entry
+	hashMap_put(map, key2, value2);
+
+	// Get with new created key
+	getEntryKey = my_strdup("key");
+	entry = hashMap_getEntry(map, getEntryKey);
+	CHECK(entry != NULL);
+	STRCMP_EQUAL(key, (char*) entry->key);
+	STRCMP_EQUAL(value, (char*) entry->value);
+
+	free(getEntryKey);
+	getEntryKey = my_strdup("key2");
+	entry = hashMap_getEntry(map, getEntryKey);
+	CHECK(entry != NULL);
+	STRCMP_EQUAL(key2, (char*) entry->key);
+	STRCMP_EQUAL(value2, (char*) entry->value);
+
+	free(getEntryKey);
+	getEntryKey = my_strdup("notExisting");
+	entry = hashMap_getEntry(map, getEntryKey);
+	POINTERS_EQUAL(NULL, entry);
+
+	free(getEntryKey);
+	getEntryKey = NULL;
+	entry = hashMap_getEntry(map, getEntryKey);
+	POINTERS_EQUAL(NULL, entry);
+
+	// Add third entry with NULL key
+	hashMap_put(map, key3, value3);
+
+	getEntryKey = NULL;
+	entry = hashMap_getEntry(map, getEntryKey);
+	CHECK_EQUAL(key3, entry->key);
+	STRCMP_EQUAL(value3, (char*) entry->value);
+
+	hashMap_clear(map, true, true);
+}
+
+TEST(hash_map_hash, put){
+	char * key = my_strdup("key");
+	char * value = my_strdup("value");
+	char * key2 = my_strdup("key2");
+	char * value2 = my_strdup("value2");
+	char * getKey = my_strdup("key");
+	char * get;
+	char * nkey2 = my_strdup("key2");
+	char * nvalue2 = my_strdup("value3");
+	char * old;
+	char * key3 = NULL;
+	char * value3 = my_strdup("value3");
+	char * key4 = my_strdup("key4");
+	char * value4 = NULL;
+
+	hashMap_clear(map, false, false);
+
+	// Add one entry
+	hashMap_put(map, key, value);
+
+	// Add second entry
+	hashMap_put(map, key2, value2);
+
+	// Get with new key
+	get = (char*) hashMap_get(map, getKey);
+	STRCMP_EQUAL(value, get);
+
+	free(getKey);
+	getKey = my_strdup("key2");
+	get = (char*) hashMap_get(map, getKey);
+	STRCMP_EQUAL(value2, get);
+
+	// Overwrite existing entry
+	old = (char *) hashMap_put(map, nkey2, nvalue2);
+	CHECK(old != NULL);
+	STRCMP_EQUAL(value2, old);
+
+	free(getKey);
+	getKey = my_strdup("key2");
+	get = (char*) hashMap_get(map, key2);
+	STRCMP_EQUAL(nvalue2, get);
+
+	// Add third entry with NULL key
+	hashMap_put(map, key3, value3);
+
+	free(getKey);
+	getKey = NULL;
+	get = (char*) hashMap_get(map, key3);
+	STRCMP_EQUAL(value3, get);
+
+	// Add fourth entry with NULL value
+	hashMap_put(map, key4, value4);
+
+	getKey = my_strdup("key4");
+	get = (char*) hashMap_get(map, key4);
+	CHECK_EQUAL(value4, get);
+
+	free(getKey);
+	free(value2);
+	free(nkey2);
+	hashMap_clear(map, true, true);
+}
+
+TEST(hash_map_hash, remove){
+	char * key = my_strdup("key");
+	char * value = my_strdup("value");
+	char * key2 = NULL;
+	char * value2 = my_strdup("value2");
+	char * removeKey = my_strdup("unexisting");
+
+	hashMap_clear(map, false, false);
+
+	// Add one entry
+	hashMap_put(map, key, value);
+
+	// Add second entry with null key
+	hashMap_put(map, key2, value2);
+
+	// Remove unexisting entry for map
+	hashMap_remove(map, removeKey);
+	LONGS_EQUAL(2, map->size);
+	CHECK(!hashMap_isEmpty(map));
+
+	// Remove entry with new key
+	free(removeKey);
+	removeKey = my_strdup("key");
+	hashMap_remove(map, removeKey);
+	LONGS_EQUAL(1, map->size);
+
+	free(removeKey);
+	removeKey = NULL;
+	hashMap_remove(map, removeKey);
+	LONGS_EQUAL(0, map->size);
+	CHECK(hashMap_isEmpty(map));
+
+	// Remove unexisting entry for empty map
+	removeKey = my_strdup("unexisting");
+	hashMap_remove(map, removeKey);
+	LONGS_EQUAL(0, map->size);
+	CHECK(hashMap_isEmpty(map));
+
+	free(removeKey);
+	free(key);
+	free(value);
+	free(value2);
+	hashMap_clear(map, true, true);
+}
+
+TEST(hash_map_hash, containsValue){
+	char * key = my_strdup("key");
+	char * value = my_strdup("value");
+	char * key2 = my_strdup("key2");
+	char * value2 = my_strdup("value2");
+	char * containsValue = my_strdup("value");
+	char * key3 = my_strdup("key3");
+	char * value3 = NULL;
+
+	hashMap_clear(map, false, false);
+
+	// Add one entry
+	hashMap_put(map, key, value);
+
+	// Add second entry
+	hashMap_put(map, key2, value2);
+
+	CHECK(hashMap_containsValue(map, containsValue));
+	free(containsValue);
+	containsValue = my_strdup("value2");
+	CHECK(hashMap_containsValue(map, containsValue));
+	free(containsValue);
+	containsValue = my_strdup("notExisting");
+	CHECK(!hashMap_containsValue(map, containsValue));
+	free(containsValue);
+	containsValue = NULL;
+	CHECK(!hashMap_containsValue(map, containsValue));
+
+	// Add third entry with NULL value
+	hashMap_put(map, key3, value3);
+
+	containsValue = NULL;
+	CHECK(hashMap_containsValue(map, containsValue));
+
+	hashMap_clear(map, true, true);
+}