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:56 UTC

[16/20] celix git commit: CELIX-180: Fixed some framework tests

CELIX-180: Fixed some framework tests


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

Branch: refs/heads/feature/CELIX-237_rsa-ffi
Commit: 86e6094e263f9a22a78b7cbd6191448a2705229e
Parents: 673b5c7
Author: Bjoern Petri <bp...@apache.org>
Authored: Tue Oct 6 14:30:40 2015 +0200
Committer: Bjoern Petri <bp...@apache.org>
Committed: Tue Oct 6 14:30:40 2015 +0200

----------------------------------------------------------------------
 framework/CMakeLists.txt                       | 82 ++++++++++-----------
 framework/private/mock/bundle_context_mock.c   | 25 ++-----
 framework/private/mock/bundle_mock.c           | 13 +---
 framework/private/mock/framework_mock.c        |  6 +-
 framework/private/test/bundle_context_test.cpp | 75 ++++++++-----------
 5 files changed, 85 insertions(+), 116 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/86e6094e/framework/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/framework/CMakeLists.txt b/framework/CMakeLists.txt
index 337c82d..0a7452d 100644
--- a/framework/CMakeLists.txt
+++ b/framework/CMakeLists.txt
@@ -92,7 +92,7 @@ if (FRAMEWORK)
             private/src/attribute.c
             private/src/celix_errorcodes.c
             private/src/celix_log.c)
-        target_link_libraries(attribute_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils)
+        target_link_libraries(attribute_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread)
         
         add_executable(bundle_archive_test 
             private/test/bundle_archive_test.cpp
@@ -100,7 +100,7 @@ if (FRAMEWORK)
             private/src/bundle_archive.c
             private/src/celix_errorcodes.c
             private/src/celix_log.c)
-        target_link_libraries(bundle_archive_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils)
+        target_link_libraries(bundle_archive_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread)
         
         add_executable(bundle_cache_test 
             private/test/bundle_cache_test.cpp
@@ -109,8 +109,8 @@ if (FRAMEWORK)
             private/src/bundle_cache.c
             private/src/celix_errorcodes.c
             private/src/celix_log.c)
-        target_link_libraries(bundle_cache_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils)
-	    
+        target_link_libraries(bundle_cache_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread)
+            
         add_executable(bundle_context_test 
             private/test/bundle_context_test.cpp
             private/mock/bundle_mock.c
@@ -118,8 +118,8 @@ if (FRAMEWORK)
             private/src/bundle_context.c
             private/src/celix_errorcodes.c
             private/src/celix_log.c)
-        target_link_libraries(bundle_context_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils)
-	    
+        target_link_libraries(bundle_context_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread)
+            
         add_executable(bundle_revision_test 
             private/test/bundle_revision_test.cpp
             private/mock/miniunz_mock.c
@@ -127,8 +127,8 @@ if (FRAMEWORK)
             private/src/bundle_revision.c
             private/src/celix_errorcodes.c
             private/src/celix_log.c)
-        target_link_libraries(bundle_revision_test ${ZLIB_LIBRARY} ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils)
-	    
+        target_link_libraries(bundle_revision_test ${ZLIB_LIBRARY} ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread)
+            
         add_executable(bundle_test 
             private/test/bundle_test.cpp
             private/mock/framework_mock.c
@@ -141,8 +141,8 @@ if (FRAMEWORK)
             private/src/bundle.c
             private/src/celix_errorcodes.c
             private/src/celix_log.c)
-        target_link_libraries(bundle_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils)
-	    
+        target_link_libraries(bundle_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread)
+            
         add_executable(capability_test 
             private/test/capability_test.cpp
             private/mock/attribute_mock.c
@@ -150,16 +150,16 @@ if (FRAMEWORK)
             private/src/capability.c
             private/src/celix_errorcodes.c
             private/src/celix_log.c)
-        target_link_libraries(capability_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils)
-	    
+        target_link_libraries(capability_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread)
+            
         add_executable(filter_test 
             private/test/filter_test.cpp
             private/mock/properties_mock.c
             private/src/filter.c
             private/src/celix_errorcodes.c
             private/src/celix_log.c)
-        target_link_libraries(filter_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils)
-	    
+        target_link_libraries(filter_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread)
+            
         add_executable(framework_test 
             private/test/framework_test.cpp
             private/mock/properties_mock.c
@@ -179,7 +179,7 @@ if (FRAMEWORK)
             private/src/celix_errorcodes.c
             private/src/celix_log.c
             private/src/framework.c)
-        target_link_libraries(framework_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} ${UUID} celix_utils)
+        target_link_libraries(framework_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} ${UUID} celix_utils pthread dl)
     
         add_executable(manifest_parser_test 
             private/test/manifest_parser_test.cpp
@@ -192,8 +192,8 @@ if (FRAMEWORK)
             private/src/manifest_parser.c
             private/src/celix_errorcodes.c
             private/src/celix_log.c)
-        target_link_libraries(manifest_parser_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils)
-	    
+        target_link_libraries(manifest_parser_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread)
+            
         add_executable(manifest_test 
             private/test/manifest_test.cpp
             private/mock/properties_mock.c
@@ -201,8 +201,8 @@ if (FRAMEWORK)
             private/src/manifest.c
             private/src/celix_errorcodes.c
             private/src/celix_log.c)
-        target_link_libraries(manifest_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils)
-	    
+        target_link_libraries(manifest_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread)
+            
         add_executable(module_test 
             private/test/module_test.cpp
             private/mock/bundle_mock.c
@@ -213,15 +213,15 @@ if (FRAMEWORK)
             private/mock/requirement_mock.c
             private/mock/wire_mock.c
             private/src/module.c)
-        target_link_libraries(module_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils)
-	    
+        target_link_libraries(module_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread)
+            
         add_executable(properties_test 
             private/test/properties_test.cpp
             private/src/utils.c
             private/src/properties.c)
-        target_link_libraries(properties_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils)
-	    
-	    
+        target_link_libraries(properties_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread)
+            
+            
         add_executable(requirement_test 
             private/test/requirement_test.cpp
             private/mock/attribute_mock.c
@@ -230,8 +230,8 @@ if (FRAMEWORK)
             private/src/requirement.c
             private/src/celix_errorcodes.c
             private/src/celix_log.c)
-        target_link_libraries(requirement_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils)
-	    
+        target_link_libraries(requirement_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread)
+            
         add_executable(resolver_test 
             private/test/resolver_test.cpp
             private/mock/bundle_mock.c
@@ -242,8 +242,8 @@ if (FRAMEWORK)
             private/src/resolver.c
             private/src/celix_errorcodes.c
             private/src/celix_log.c)
-        target_link_libraries(resolver_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils)
-	    
+        target_link_libraries(resolver_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread)
+            
         add_executable(service_reference_test 
             private/test/service_reference_test.cpp
             private/mock/properties_mock.c
@@ -252,18 +252,18 @@ if (FRAMEWORK)
             private/src/service_reference.c
             private/src/celix_errorcodes.c
             private/src/celix_log.c)
-        target_link_libraries(service_reference_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils)
-	    
-	    add_executable(service_registration_test 
+        target_link_libraries(service_reference_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread)
+            
+            add_executable(service_registration_test 
             private/test/service_registration_test.cpp
             private/mock/properties_mock.c
             private/mock/service_registry_mock.c
             private/src/service_registration.c
             private/src/celix_errorcodes.c
             private/src/celix_log.c)
-        target_link_libraries(service_registration_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils)
-	    
-	    
+        target_link_libraries(service_registration_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread)
+            
+            
         add_executable(service_registry_test 
             private/test/service_registry_test.cpp
             private/mock/framework_mock.c
@@ -275,16 +275,16 @@ if (FRAMEWORK)
             private/src/service_registry.c
             private/src/celix_errorcodes.c
             private/src/celix_log.c) 
-        target_link_libraries(service_registry_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils)
-	    
+        target_link_libraries(service_registry_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread)
+            
         add_executable(service_tracker_customizer_test 
             private/test/service_tracker_customizer_test.cpp
             private/mock/service_reference_mock.c
             private/src/service_tracker_customizer.c
             private/src/celix_errorcodes.c
             private/src/celix_log.c) 
-        target_link_libraries(service_tracker_customizer_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils)
-	    
+        target_link_libraries(service_tracker_customizer_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread)
+            
         add_executable(service_tracker_test 
             private/test/service_tracker_test.cpp 
             private/mock/bundle_context_mock.c
@@ -293,12 +293,12 @@ if (FRAMEWORK)
             private/src/service_tracker.c
             private/src/celix_errorcodes.c
             private/src/celix_log.c)
-        target_link_libraries(service_tracker_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils)
+        target_link_libraries(service_tracker_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread)
         
         add_executable(utils_test 
             private/test/utils_test.cpp private/src/utils.c)
-        target_link_libraries(utils_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils)
-	    
+        target_link_libraries(utils_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread)
+            
         add_executable(version_range_test 
             private/test/version_range_test.cpp 
             private/src/version_range.c

http://git-wip-us.apache.org/repos/asf/celix/blob/86e6094e/framework/private/mock/bundle_context_mock.c
----------------------------------------------------------------------
diff --git a/framework/private/mock/bundle_context_mock.c b/framework/private/mock/bundle_context_mock.c
index c5bdbdb..9d3d79a 100644
--- a/framework/private/mock/bundle_context_mock.c
+++ b/framework/private/mock/bundle_context_mock.c
@@ -27,12 +27,11 @@
 
 #include "bundle_context.h"
 
-celix_status_t bundleContext_create(apr_pool_t *pool, framework_pt framework, framework_logger_pt logger, bundle_pt bundle, bundle_context_pt *bundle_context) {
-	mock_c()->actualCall("bundleContext_create")
-                ->withPointerParameters("pool", pool)
-			->withPointerParameters("framework", framework)
-			->withPointerParameters("logger", logger)
-			->withPointerParameters("bundle", bundle)
+celix_status_t bundleContext_create(framework_pt framework, framework_logger_pt logger, bundle_pt bundle, bundle_context_pt *bundle_context) {
+        mock_c()->actualCall("bundleContext_create")
+                        ->withPointerParameters("framework", framework)
+                        ->withPointerParameters("logger", logger)
+                        ->withPointerParameters("bundle", bundle)
 			->withOutputParameter("bundle_context", (void **) bundle_context);
 	return mock_c()->returnValue().value.intValue;
 }
@@ -51,20 +50,12 @@ celix_status_t bundleContext_getFramework(bundle_context_pt context, framework_p
 	mock_c()->actualCall("bundleContext_getFramework")
 			->withPointerParameters("context", context)
 			->withOutputParameter("framework", (void **) framework);
-	return mock_c()->returnValue().value.intValue;
+        return mock_c()->returnValue().value.intValue;
 }
 
-celix_status_t bundleContext_getMemoryPool(bundle_context_pt context, apr_pool_t **memory_pool) {
-	mock_c()->actualCall("bundleContext_getMemoryPool")
-			->withPointerParameters("context", context)
-			->withOutputParameter("memory_pool", (void **) memory_pool);
-	return mock_c()->returnValue().value.intValue;
-}
-
-
 celix_status_t bundleContext_installBundle(bundle_context_pt context, char * location, bundle_pt *bundle) {
-	mock_c()->actualCall("bundleContext_installBundle")
-			->withPointerParameters("context", context)
+        mock_c()->actualCall("bundleContext_installBundle")
+                        ->withPointerParameters("context", context)
 			->withStringParameters("location", location)
 			->withOutputParameter("bundle", (void **) bundle);
 	return mock_c()->returnValue().value.intValue;

http://git-wip-us.apache.org/repos/asf/celix/blob/86e6094e/framework/private/mock/bundle_mock.c
----------------------------------------------------------------------
diff --git a/framework/private/mock/bundle_mock.c b/framework/private/mock/bundle_mock.c
index d82e78e..7b304c3 100644
--- a/framework/private/mock/bundle_mock.c
+++ b/framework/private/mock/bundle_mock.c
@@ -196,20 +196,11 @@ celix_status_t bundle_getRegisteredServices(bundle_pt bundle, array_list_pt *lis
 }
 
 celix_status_t bundle_getServicesInUse(bundle_pt bundle, array_list_pt *list) {
-	return mock_c()->returnValue().value.intValue;
+        return mock_c()->returnValue().value.intValue;
 }
 
-
-celix_status_t bundle_getMemoryPool(bundle_pt bundle, apr_pool_t **pool) {
-	mock_c()->actualCall("bundle_getMemoryPool")
-			->withPointerParameters("bundle", bundle)
-			->withOutputParameter("pool", (void **) pool);
-	return mock_c()->returnValue().value.intValue;
-}
-
-
 celix_status_t bundle_setFramework(bundle_pt bundle, framework_pt framework) {
-	return mock_c()->returnValue().value.intValue;
+        return mock_c()->returnValue().value.intValue;
 }
 
 celix_status_t bundle_getFramework(bundle_pt bundle, framework_pt *framework) {

http://git-wip-us.apache.org/repos/asf/celix/blob/86e6094e/framework/private/mock/framework_mock.c
----------------------------------------------------------------------
diff --git a/framework/private/mock/framework_mock.c b/framework/private/mock/framework_mock.c
index 41db4c8..d027df9 100644
--- a/framework/private/mock/framework_mock.c
+++ b/framework/private/mock/framework_mock.c
@@ -27,9 +27,9 @@
 
 #include "framework_private.h"
 
-celix_status_t framework_create(framework_pt *framework, apr_pool_t *memoryPool, properties_pt config) {
-	mock_c()->actualCall("framework_create");
-		return mock_c()->returnValue().value.intValue;
+celix_status_t framework_create(framework_pt *framework, properties_pt config) {
+        mock_c()->actualCall("framework_create");
+                return mock_c()->returnValue().value.intValue;
 }
 
 celix_status_t framework_destroy(framework_pt framework) {

http://git-wip-us.apache.org/repos/asf/celix/blob/86e6094e/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 8b9ed51..db2792d 100644
--- a/framework/private/test/bundle_context_test.cpp
+++ b/framework/private/test/bundle_context_test.cpp
@@ -19,7 +19,7 @@
 /*
  * bundle_context_test.cpp
  *
- *  \date       Feb 11, 2013
+ *  \date       Sep 14, 2015
  *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
  *  \copyright  Apache License, Version 2.0
  */
@@ -56,13 +56,13 @@ TEST_GROUP(bundle_context) {
 
 TEST(bundle_context, create) {
 	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(NULL, 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)
+//      CHECK(context->pool);
 }
 
 TEST(bundle_context, destroy) {
@@ -80,54 +80,41 @@ 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;
-	apr_pool_t *pool = (apr_pool_t *) 0x30;
-	context->framework = framework;
-	context->bundle = bundle;
-	context->pool = pool;
-
-	celix_status_t status;
-	bundle_pt actualBundle = NULL;
+        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);
-
-	apr_pool_t *actualPool = NULL;
-	status = bundleContext_getMemoryPool(context, &actualPool);
-	LONGS_EQUAL(CELIX_SUCCESS, status);
-	POINTERS_EQUAL(pool, actualPool);
-
-	actualBundle = NULL;
-	status = bundleContext_getBundle(NULL, &actualBundle);
-	LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
+        LONGS_EQUAL(CELIX_SUCCESS, status);
+        POINTERS_EQUAL(framework, actualFramework);
 
-	actualFramework = NULL;
-	status = bundleContext_getFramework(NULL, &actualFramework);
-	LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
+        actualBundle = NULL;
+        status = bundleContext_getBundle(NULL, &actualBundle);
+        LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
 
-	actualPool = NULL;
-	status = bundleContext_getMemoryPool(NULL, &actualPool);
-	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;
-	apr_pool_t *pool = (apr_pool_t *) 0x30;
-	context->framework = framework;
-	context->bundle = bundle;
-	context->pool = pool;
-
-	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)