celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pnol...@apache.org
Subject celix git commit: CELIX-441: Updates bundle ctx and svc registration mocks for update api
Date Tue, 17 Apr 2018 22:06:34 GMT
Repository: celix
Updated Branches:
  refs/heads/develop 0657853e7 -> 3e415537a


CELIX-441: Updates bundle ctx and svc registration mocks for update api


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

Branch: refs/heads/develop
Commit: 3e415537a821fd12e255162a14399505f5ba20f3
Parents: 0657853
Author: Pepijn Noltes <pepijnnoltes@gmail.com>
Authored: Wed Apr 18 00:05:44 2018 +0200
Committer: Pepijn Noltes <pepijnnoltes@gmail.com>
Committed: Wed Apr 18 00:05:44 2018 +0200

----------------------------------------------------------------------
 framework/CMakeLists.txt                        |  4 ++
 framework/include/bundle_context.h              |  4 +-
 framework/private/mock/bundle_context_mock.c    | 40 ++++++++++++++++++++
 framework/private/mock/framework_mock.c         |  4 +-
 .../private/mock/service_registration_mock.c    |  6 +++
 .../private/test/service_registration_test.cpp  | 16 --------
 framework/src/bundle_context.c                  |  4 +-
 7 files changed, 57 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/3e415537/framework/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/framework/CMakeLists.txt b/framework/CMakeLists.txt
index f6967b2..ee2fa5a 100644
--- a/framework/CMakeLists.txt
+++ b/framework/CMakeLists.txt
@@ -116,6 +116,10 @@ if (ENABLE_TESTING AND FRAMEWORK_TESTS)
         private/mock/bundle_mock.c
         private/mock/framework_mock.c
         private/mock/service_registry_mock.c
+        private/mock/service_registration_mock.c
+        private/mock/service_reference_mock.c
+        src/service_tracker.c #TODO make mock for svc tracker
+        src/service_tracker_customizer.c
         src/bundle_context.c
         src/celix_errorcodes.c
         private/mock/celix_log_mock.c)

http://git-wip-us.apache.org/repos/asf/celix/blob/3e415537/framework/include/bundle_context.h
----------------------------------------------------------------------
diff --git a/framework/include/bundle_context.h b/framework/include/bundle_context.h
index 0ca82f4..2844d7d 100644
--- a/framework/include/bundle_context.h
+++ b/framework/include/bundle_context.h
@@ -79,7 +79,7 @@ bundleContext_registerServiceFactory(bundle_context_pt context, const char
*serv
  * @param properties The meta properties assiated with the service. The service registration
will take ownership of the properties
  * @return The serviceId or < 0 if registration was unsuccessful.
  */
-long bundleContext_registerCService(bundle_context_t *ctx, const char *serviceName, const
void *svc, properties_t *properties);
+long bundleContext_registerCService(bundle_context_t *ctx, const char *serviceName, void
*svc, properties_t *properties);
 
 /**
 * Register a service for the specified language to the framework.
@@ -90,7 +90,7 @@ long bundleContext_registerCService(bundle_context_t *ctx, const char *serviceNa
 * @param properties The meta properties assiated with the service. The service registration
will take ownership of the properties
 * @return The serviceId or < 0 if registration was unsuccessful.
 */
-long bundleContext_registerServiceForLang(bundle_context_t *ctx, const char *serviceName,
const void *svc, properties_t *properties, const char* lang);
+long bundleContext_registerServiceForLang(bundle_context_t *ctx, const char *serviceName,
void *svc, properties_t *properties, const char* lang);
 
 /**
  * Unregister the service with service id. The service will only be unregistered if the bundle
of the bundle context

http://git-wip-us.apache.org/repos/asf/celix/blob/3e415537/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 6ec5fae..689f0bb 100644
--- a/framework/private/mock/bundle_context_mock.c
+++ b/framework/private/mock/bundle_context_mock.c
@@ -23,6 +23,7 @@
  *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
  *  \copyright  Apache License, Version 2.0
  */
+#include <CppUTestExt/MockSupport_c.h>
 #include "CppUTestExt/MockSupport_c.h"
 
 #include "bundle_context.h"
@@ -192,3 +193,42 @@ celix_status_t bundleContext_getProperty(bundle_context_pt context, const
char *
 			->withOutputParameter("value", value);
 	return mock_c()->returnValue().value.intValue;
 }
+
+long bundleContext_registerCService(bundle_context_t *ctx, const char *serviceName, void
*svc, properties_t *properties) {
+	mock_c()->actualCall("bundleContext_registerCService")
+			->withPointerParameters("ctx", ctx)
+			->withStringParameters("serviceName", serviceName)
+			->withPointerParameters("svc", svc)
+			->withPointerParameters("properties", properties);
+	return mock_c()->returnValue().value.longIntValue;
+}
+
+long bundleContext_registerServiceForLang(bundle_context_t *ctx, const char *serviceName,
void *svc, properties_t *properties, const char* lang) {
+	mock_c()->actualCall("bundleContext_registerServiceForLang")
+			->withPointerParameters("ctx", ctx)
+			->withStringParameters("serviceName", serviceName)
+			->withConstPointerParameters("svc", svc)
+			->withPointerParameters("properties", properties)
+			->withStringParameters("lang", lang);
+	return mock_c()->returnValue().value.longIntValue;
+}
+
+void bundleContext_unregisterService(bundle_context_t *ctx, long serviceId) {
+	mock_c()->actualCall("bundleContext_unregisterService")
+			->withPointerParameters("ctx", ctx)
+			->withLongIntParameters("serviceId", serviceId);
+}
+
+bool bundleContext_useServiceWithId(
+		bundle_context_t *ctx,
+		long serviceId,
+		void *callbackHandle,
+		void (*use)(void *handle, void* svc, const properties_t *props, const bundle_t *owner)
+) {
+	mock_c()->actualCall("bundleContext_registerServiceForLang")
+			->withPointerParameters("ctx", ctx)
+			->withLongIntParameters("serviceId", serviceId)
+			->withPointerParameters("callbackHandle", callbackHandle)
+			->withPointerParameters("use", use);
+	return mock_c()->returnValue().value.boolValue;
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/3e415537/framework/private/mock/framework_mock.c
----------------------------------------------------------------------
diff --git a/framework/private/mock/framework_mock.c b/framework/private/mock/framework_mock.c
index 399935f..2498fa2 100644
--- a/framework/private/mock/framework_mock.c
+++ b/framework/private/mock/framework_mock.c
@@ -23,6 +23,7 @@
  *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
  *  \copyright  Apache License, Version 2.0
  */
+#include <CppUTestExt/MockSupport_c.h>
 #include "CppUTestExt/MockSupport_c.h"
 
 #include "framework_private.h"
@@ -47,8 +48,9 @@ celix_status_t framework_start(framework_pt framework) {
 		return mock_c()->returnValue().value.intValue;
 }
 
-void framework_stop(framework_pt framework) {
+celix_status_t framework_stop(framework_pt framework) {
 	mock_c()->actualCall("framework_stop");
+	return mock_c()->returnValue().value.intValue;
 }
 
 celix_status_t fw_getProperty(framework_pt framework, const char* name, const char* defaultValue,
const char** value) {

http://git-wip-us.apache.org/repos/asf/celix/blob/3e415537/framework/private/mock/service_registration_mock.c
----------------------------------------------------------------------
diff --git a/framework/private/mock/service_registration_mock.c b/framework/private/mock/service_registration_mock.c
index 934e11b..4bbf0c8 100644
--- a/framework/private/mock/service_registration_mock.c
+++ b/framework/private/mock/service_registration_mock.c
@@ -23,6 +23,7 @@
  *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
  *  \copyright  Apache License, Version 2.0
  */
+#include <CppUTestExt/MockSupport_c.h>
 #include "CppUTestExt/MockSupport_c.h"
 
 #include "service_registration.h"
@@ -138,4 +139,9 @@ void serviceRegistration_release(service_registration_pt registration)
{
 }
 
 
+long serviceRegistration_getServiceId(service_registration_t *registration) {
+	mock_c()->actualCall("serviceRegistration_getServiceId")
+			->withPointerParameters("registration", registration);
+	return mock_c()->returnValue().value.longIntValue;
+}
 

http://git-wip-us.apache.org/repos/asf/celix/blob/3e415537/framework/private/test/service_registration_test.cpp
----------------------------------------------------------------------
diff --git a/framework/private/test/service_registration_test.cpp b/framework/private/test/service_registration_test.cpp
index 916da93..da4420d 100644
--- a/framework/private/test/service_registration_test.cpp
+++ b/framework/private/test/service_registration_test.cpp
@@ -387,22 +387,6 @@ TEST(service_registration, getServiceName) {
 	free(name);
 }
 
-TEST(service_registration, getServiceNameIllegalArgument) {
-	registry_callback_t callback;
-	char * name = my_strdup("sevice_name");
-	service_registration_pt registration = serviceRegistration_create(callback, NULL, name,
0, NULL, NULL);
-	const char *actual = (char *) 0x01;
-
-	mock().expectOneCall("framework_logCode")
-			.withParameter("code", CELIX_ILLEGAL_ARGUMENT);
-
-	celix_status_t status = serviceRegistration_getServiceName(registration, &actual);
-	LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
-
-	serviceRegistration_release(registration);
-	free(name);
-}
-
 TEST(service_registration, getBundle) {
 	registry_callback_t callback;
 	char * name = my_strdup("sevice_name");

http://git-wip-us.apache.org/repos/asf/celix/blob/3e415537/framework/src/bundle_context.c
----------------------------------------------------------------------
diff --git a/framework/src/bundle_context.c b/framework/src/bundle_context.c
index 5cbe67a..904ec51 100644
--- a/framework/src/bundle_context.c
+++ b/framework/src/bundle_context.c
@@ -384,12 +384,12 @@ celix_status_t bundleContext_getPropertyWithDefault(bundle_context_pt
context, c
 }
 
 
-long bundleContext_registerCService(bundle_context_t *ctx, const char *serviceName, const
void *svc, properties_t *properties) {
+long bundleContext_registerCService(bundle_context_t *ctx, const char *serviceName, void
*svc, properties_t *properties) {
     return bundleContext_registerServiceForLang(ctx, serviceName, svc, properties, CELIX_FRAMEWORK_SERVICE_C_LANGUAGE);
 }
 
 
-long bundleContext_registerServiceForLang(bundle_context_t *ctx, const char *serviceName,
const void *svc, properties_t *properties, const char* lang) {
+long bundleContext_registerServiceForLang(bundle_context_t *ctx, const char *serviceName,
void *svc, properties_t *properties, const char* lang) {
     long svcId = -1;
     if (properties == NULL) {
         properties = properties_create();


Mime
View raw message