Skip to content

Commit

Permalink
CELIX-289: Fixes for mocking issues and bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
pnoltes committed Nov 9, 2015
1 parent 79f8239 commit aec12cd
Show file tree
Hide file tree
Showing 76 changed files with 3,053 additions and 748 deletions.
2 changes: 1 addition & 1 deletion deployment_admin/private/src/deployment_admin_activator.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context)
}

celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
celix_status_t status;
celix_status_t status = CELIX_SUCCESS;

bundle_activator_pt activator = (bundle_activator_pt) userData;

Expand Down
2 changes: 1 addition & 1 deletion deployment_admin/private/src/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ celix_status_t log_destroy(log_pt *log) {
}

celix_status_t log_log(log_pt log, unsigned int type, properties_pt properties) {
celix_status_t status;
celix_status_t status = CELIX_SUCCESS;

log_event_pt event = NULL;

Expand Down
5 changes: 3 additions & 2 deletions examples/mongoose/private/src/mongoose.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include <ctype.h>
#include <limits.h>
#include <stdio.h>
#include <sys/wait.h>

#if defined(_WIN32) // Windows specific #includes and #defines
#define _WIN32_WINNT 0x0400 // To make it link in VS2005
Expand Down Expand Up @@ -3622,10 +3623,10 @@ static void close_connection(struct mg_connection *conn) {
}

static void discard_current_request_from_buffer(struct mg_connection *conn) {
char *buffered;
//char *buffered;
int buffered_len, body_len;

buffered = conn->buf + conn->request_len;
//buffered = conn->buf + conn->request_len;
buffered_len = conn->data_len - conn->request_len;
assert(buffered_len >= 0);

Expand Down
213 changes: 119 additions & 94 deletions framework/CMakeLists.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion framework/private/include/bundle_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ typedef struct bundleCache *bundle_cache_pt;
* - CELIX_ILLEGAL_ARGUMENT If <code>bundle_cache</code> not is null.
* - CELIX_ENOMEM If allocating memory for <code>bundle_cache</code> failed.
*/
celix_status_t bundleCache_create(properties_pt configurationMap, framework_logger_pt logger, bundle_cache_pt *bundle_cache);
celix_status_t bundleCache_create(properties_pt configurationMap, bundle_cache_pt *bundle_cache);

/**
* Frees the bundle_cache memory allocated in bundleCache_create
Expand Down
1 change: 0 additions & 1 deletion framework/private/include/bundle_cache_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
struct bundleCache {
properties_pt configurationMap;
char * cacheDir;
framework_logger_pt logger;
};


Expand Down
1 change: 0 additions & 1 deletion framework/private/include/bundle_context_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ struct bundleContext {
#endif
struct framework * framework;
struct bundle * bundle;
framework_logger_pt logger;
};


Expand Down
1 change: 0 additions & 1 deletion framework/private/include/bundle_revision_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ struct bundleRevision {
char *root;
char *location;
manifest_pt manifest;
framework_logger_pt logger;

array_list_pt libraryHandles;
};
Expand Down
2 changes: 0 additions & 2 deletions framework/private/include/service_reference_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,4 @@ celix_status_t serviceReference_destroy(service_reference_pt *reference);
celix_status_t serviceReference_invalidate(service_reference_pt reference);
celix_status_t serviceRefernce_isValid(service_reference_pt reference, bool *result);

celix_status_t serviceReference_getServiceRegistration(service_reference_pt reference, service_registration_pt *registration);

#endif /* SERVICE_REFERENCE_PRIVATE_H_ */
2 changes: 1 addition & 1 deletion framework/private/include/service_registration_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void serviceRegistration_invalidate(service_registration_pt registration);

celix_status_t serviceRegistration_getService(service_registration_pt registration, bundle_pt bundle, void **service);
celix_status_t serviceRegistration_ungetService(service_registration_pt registration, bundle_pt bundle, void **service);
celix_status_t serviceRegistration_getProperties(service_registration_pt registration, properties_pt *properties);

celix_status_t serviceRegistration_getRegistry(service_registration_pt registration, service_registry_pt *registry);
celix_status_t serviceRegistration_getBundle(service_registration_pt registration, bundle_pt *bundle);
celix_status_t serviceRegistration_getServiceName(service_registration_pt registration, char **serviceName);
Expand Down
28 changes: 13 additions & 15 deletions framework/private/integration-test/test_bundle1/src/activator.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
*/
#include <stdlib.h>
#include <stdio.h>
#include <apr_general.h>

#include "bundle_activator.h"
#include "bundle_context.h"
Expand All @@ -38,27 +37,20 @@ struct userData {
celix_status_t test_frameworkEvent(void *listener, framework_event_pt event);

celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
apr_pool_t *pool;
celix_status_t status = bundleContext_getMemoryPool(context, &pool);
if (status == CELIX_SUCCESS) {
*userData = apr_palloc(pool, sizeof(struct userData));
((struct userData *)(*userData))->listener = NULL;
} else {
status = CELIX_START_ERROR;
*userData = calloc(1, sizeof(struct userData));
if(*userData == NULL){
return CELIX_ENOMEM;
}
return CELIX_SUCCESS;
}

celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
struct userData * activator = (struct userData *) userData;
apr_pool_t *pool;

bundleContext_getMemoryPool(context, &pool);

activator->listener = apr_palloc(pool, sizeof(*activator->listener));
activator->listener->handle = activator;
activator->listener->frameworkEvent = test_frameworkEvent;
bundleContext_addFrameworkListener(context, activator->listener);
activator->listener = calloc(1, sizeof(*activator->listener));
activator->listener->handle = activator;
activator->listener->frameworkEvent = test_frameworkEvent;
bundleContext_addFrameworkListener(context, activator->listener);

return CELIX_SUCCESS;
}
Expand All @@ -72,6 +64,12 @@ celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context)
}

celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
struct userData * activator = (struct userData *) userData;
if(activator->listener != NULL){
free(activator->listener);
}

free(activator);
return CELIX_SUCCESS;
}

Expand Down
3 changes: 2 additions & 1 deletion framework/private/mock/attribute_mock.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ celix_status_t attribute_create(char * key, char * value, attribute_pt *attribut
}

celix_status_t attribute_destroy(attribute_pt attribute) {
mock_c()->actualCall("attribute_destroy");
mock_c()->actualCall("attribute_destroy")
->withPointerParameters("attribute", attribute);
return mock_c()->returnValue().value.intValue;
}

Expand Down
9 changes: 4 additions & 5 deletions framework/private/mock/bundle_archive_mock.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@

#include "bundle_archive.h"

celix_status_t bundleArchive_create(framework_logger_pt logger, char * archiveRoot, long id, char * location, char *inputFile, bundle_archive_pt *bundle_archive) {
celix_status_t bundleArchive_create(char * archiveRoot, long id, char * location, char *inputFile, bundle_archive_pt *bundle_archive) {
mock_c()->actualCall("bundleArchive_create")
->withPointerParameters("logger", logger)
->withStringParameters("archiveRoot", archiveRoot)
->withIntParameters("id", id)
->withStringParameters("location", location)
Expand All @@ -38,9 +37,8 @@ celix_status_t bundleArchive_create(framework_logger_pt logger, char * archiveRo
return mock_c()->returnValue().value.intValue;
}

celix_status_t bundleArchive_createSystemBundleArchive(framework_logger_pt logger, bundle_archive_pt *bundle_archive) {
celix_status_t bundleArchive_createSystemBundleArchive(bundle_archive_pt *bundle_archive) {
mock_c()->actualCall("bundleArchive_createSystemBundleArchive")
->withPointerParameters("logger", logger)
->withOutputParameter("bundle_archive", (void **) bundle_archive);
return mock_c()->returnValue().value.intValue;
}
Expand Down Expand Up @@ -112,7 +110,8 @@ celix_status_t bundleArchive_setRefreshCount(bundle_archive_pt archive) {
}

celix_status_t bundleArchive_close(bundle_archive_pt archive) {
mock_c()->actualCall("bundleArchive_close");
mock_c()->actualCall("bundleArchive_close")
->withPointerParameters("archive", archive);
return mock_c()->returnValue().value.intValue;
}

Expand Down
10 changes: 5 additions & 5 deletions framework/private/mock/bundle_cache_mock.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@

#include "bundle_cache.h"

celix_status_t bundleCache_create(properties_pt configurationMap, framework_logger_pt logger, bundle_cache_pt *bundle_cache) {
mock_c()->actualCall("bundle_getCurrentModule");
celix_status_t bundleCache_create(properties_pt configurationMap, bundle_cache_pt *bundle_cache) {
mock_c()->actualCall("bundleCache_create");
return mock_c()->returnValue().value.intValue;
}

Expand All @@ -38,17 +38,17 @@ celix_status_t bundleCache_destroy(bundle_cache_pt *cache) {
}

celix_status_t bundleCache_getArchives(bundle_cache_pt cache, array_list_pt *archives) {
mock_c()->actualCall("bundle_getCurrentModule");
mock_c()->actualCall("bundleCache_getArchives");
return mock_c()->returnValue().value.intValue;
}

celix_status_t bundleCache_createArchive(bundle_cache_pt cache, long id, char * location, char *inputFile, bundle_archive_pt *archive) {
mock_c()->actualCall("bundle_getCurrentModule");
mock_c()->actualCall("bundleCache_createArchive");
return mock_c()->returnValue().value.intValue;
}

celix_status_t bundleCache_delete(bundle_cache_pt cache) {
mock_c()->actualCall("bundle_getCurrentModule");
mock_c()->actualCall("bundleCache_delete");
return mock_c()->returnValue().value.intValue;
}

Expand Down
Loading

0 comments on commit aec12cd

Please sign in to comment.