Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

type support for properties #470

Merged
merged 74 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
c28810e
Rename current properties imp to properties_v1.c
pnoltes Dec 31, 2022
1ff603b
Refactor celix properties to be based on celix_string_hash_map.
pnoltes Jan 1, 2023
6156c70
Add initial primitive type support for celix properties entries
pnoltes Jan 2, 2023
02b08a1
Improve celix properties iterator
pnoltes Jan 3, 2023
2c5194f
Add unit test for celix types properties and fix some mem issues
pnoltes Jan 4, 2023
740bbbf
Add properties type support to C++ properties
pnoltes Jan 5, 2023
efa1017
Improve test coverage and fix issues in properties and string/long ha…
pnoltes Jan 7, 2023
ced3279
Refactor and improve properties and string hash map test suite and impl
pnoltes Jan 8, 2023
71daacf
Remove old properties.c file
pnoltes Jan 8, 2023
efb74c1
Fix Properties implementation for C++11 and C++14.
pnoltes Jan 8, 2023
4f86a3d
Improve codecov and replace usage of CELIX_PROPERTIES_FOR_EACH with _…
pnoltes Jan 8, 2023
c15bf71
Adjust short properties optimization values based on some basic testing
pnoltes Jan 8, 2023
1ce505d
Merge remote-tracking branch 'origin/master' into feature/type_suppor…
pnoltes Jan 8, 2023
fe434a0
Fix issue with setting properties with NULL values
pnoltes Jan 8, 2023
17441f7
Merge remote-tracking branch 'origin/master' into feature/type_suppor…
pnoltes May 7, 2023
0c0bf14
Refactor properties and version after merge with master
pnoltes May 7, 2023
78b94d5
Refactor cpputest version ei test to gtest
pnoltes May 7, 2023
717869d
Add missing output param in serviceReference_getPropertyKeys
pnoltes May 7, 2023
ce71cf0
Merge remote-tracking branch 'origin/master' into feature/type_suppor…
pnoltes Aug 23, 2023
e032679
Refactor and correction after merge with master
pnoltes Aug 23, 2023
226a546
Remove cpputest include from gtest
pnoltes Aug 23, 2023
0988291
Fix properties iterator usage in disc zeroconf
pnoltes Aug 24, 2023
74c6b58
Merge remote-tracking branch 'origin/master' into feature/type_suppor…
pnoltes Aug 24, 2023
c0218db
Merge branch 'master' into feature/type_support_for_properties
pnoltes Oct 1, 2023
1f5bf79
#509: Update changes for celix properties with type support
pnoltes Oct 1, 2023
77f212a
#509: Remove deprecated macro (incl usage) CELIX_PROPERTIES_FOR_EACH
pnoltes Oct 7, 2023
1856ced
Merge remote-tracking branch 'origin/feature/type_support_for_propert…
pnoltes Oct 8, 2023
2765f6a
#509: Add CMakeUserPresets.json to gitignore
pnoltes Oct 15, 2023
88e513d
#509: Replace props FOR_EACH to ITERATE macro in rsa shm & zeroconf disc
pnoltes Oct 15, 2023
a652e9b
Merge branch 'master' into feature/type_support_for_properties
pnoltes Oct 15, 2023
bd7aa8b
Remove C++17 constructions from updated Properties.h
pnoltes Oct 15, 2023
6d25c2b
Remove use realloc or calloc define in celix_hash_map.c
pnoltes Oct 15, 2023
747cd8a
Add celix_status_t return to celix properties set functions
pnoltes Oct 15, 2023
3541c67
Refactor celix hash map for alloc failure handling
pnoltes Oct 17, 2023
94e6a3b
Fix some memleaks in properties.c
pnoltes Oct 17, 2023
287d6f0
Extend error injection test for celix properties
pnoltes Oct 22, 2023
770818d
Add error injection for celix_properties_loadFromString
pnoltes Oct 23, 2023
9979697
Add equals for celix string/long hashmap en celix properties
pnoltes Oct 23, 2023
27e9e78
Link test_utils_cxx17tests into test_utils.
PengZheng Nov 1, 2023
bf880fc
Merge branch 'master' into feature/type_support_for_properties
PengZheng Nov 1, 2023
aa51299
Merge branch 'master' into feature/type_support_for_properties
PengZheng Nov 3, 2023
833a5c8
Remove unused functions and fix typo.
PengZheng Nov 5, 2023
b5f25b5
#509: Fix celix string/long hashmap equals functions
pnoltes Nov 6, 2023
97aa3cc
Merge branch 'master' into feature/type_support_for_properties
pnoltes Nov 6, 2023
737773b
Minor typo fix and return value improvement.
PengZheng Nov 7, 2023
71742e8
#509: Remove string_view usage from Version.h and remove deprecated P…
pnoltes Nov 9, 2023
701b5c9
#509: Add the celix properties optimization cache sizes as configurab…
pnoltes Nov 9, 2023
e8c4072
#509: Update properties handling in remote service zeroconf discovery
pnoltes Nov 9, 2023
24eab9c
Update discovery_zeroconf_announcer.c
xuzhenbao Nov 10, 2023
ef6f343
#509: Improve hashmap/properties equals and apply properties equals i…
pnoltes Nov 10, 2023
9930ecb
#509: Add Properties equal operator
pnoltes Nov 10, 2023
f1beb5f
#509: Fix memleak in celix_properties_setWithoutCopy
pnoltes Nov 10, 2023
cb0a8ba
#509: Improve some error handling in celix properties.
pnoltes Nov 10, 2023
be9f0a9
Improve some header doc for string hash map / properties
pnoltes Nov 10, 2023
9d0ad57
Add some error handling for version
pnoltes Nov 10, 2023
4bb275c
Refactor celix_properties_constants.h to celix_utils_private_constants.h
pnoltes Nov 10, 2023
229a90b
Remove incorrect celix_steal_ptr usage.
PengZheng Nov 11, 2023
e981ee4
Minor documentation improvement.
PengZheng Nov 11, 2023
3964e0b
Refactor hash map long hash, load factor and hash function usage base…
pnoltes Nov 12, 2023
468a161
Merge branch 'feature/type_support_for_properties' of github.com:apac…
pnoltes Nov 12, 2023
10e16f6
Fix memleak in hash map by first resizing and then adding entry
pnoltes Nov 12, 2023
8248da5
Update hash map maxLoadFactor documentation.
PengZheng Nov 13, 2023
d1206d9
Refactor celix_properties fill/create entry
pnoltes Nov 17, 2023
038808e
Add an extra byte for the terminating null byte to the value buffer.
PengZheng Nov 18, 2023
804d633
Detect error condition in string formatting.
PengZheng Nov 18, 2023
74f9550
Detect error condition in string formatting and make celix_properties…
PengZheng Nov 18, 2023
3ff7046
Fix initial hash table capacity in celix_properties.
PengZheng Nov 18, 2023
1706890
Fix misplaced documentation and update it.
PengZheng Nov 18, 2023
4d4e9f7
Refactor celix_properties_size return type to size_t
pnoltes Nov 18, 2023
492c457
Fix hash map iterator index tests and behaviour
pnoltes Nov 18, 2023
03731d6
Refactor properties createEntry to use destroyEntry
pnoltes Nov 18, 2023
caedd79
Avoid unnecessary strlen call and check error condition in celix_prop…
PengZheng Nov 19, 2023
78d7879
Remove index field from hashmap and properties iterator
pnoltes Nov 20, 2023
95460e9
Add ftell check and error injection test for properties
pnoltes Nov 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,8 @@ int pubsub_subscriber_recv(void* handle, const char* msgType, unsigned int msgTy
if (metadata == NULL || celix_properties_size(metadata) == 0) {
printf("No metadata\n");
} else {
const char *key;
CELIX_PROPERTIES_FOR_EACH(metadata, key) {
const char *val = celix_properties_get(metadata, key, "!Error!");
printf("%s=%s\n", key, val);
CELIX_PROPERTIES_ITERATE(metadata, iter) {
printf("%s=%s\n", iter.key, iter.entry.value);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,8 @@ class PubSubInterceptorTestSuite : public ::testing::Test {
const auto *msg = static_cast<const msg_t*>(rawMsg);
EXPECT_GE(msg->seqNr, 0);
EXPECT_STREQ(celix_properties_get(metadata, "test", nullptr), "preSend");
const char *key;
CELIX_PROPERTIES_FOR_EACH(metadata, key) {
printf("got property %s=%s\n", key, celix_properties_get(metadata, key, nullptr));
CELIX_PROPERTIES_ITERATE(metadata, iter) {
printf("got property %s=%s\n", iter.key, iter.entry.value);
}
fprintf(stdout, "Got message in postSend interceptor %s/%s for type %s and ser %s with seq nr %i\n", intProps->scope, intProps->topic, intProps->psaType, intProps->serializationType, msg->seqNr);

Expand Down
5 changes: 2 additions & 3 deletions bundles/pubsub/pubsub_admin_udp_mc/src/pubsub_udpmc_admin.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,9 +455,8 @@ static celix_status_t pubsub_udpmcAdmin_connectEndpointToReceiver(pubsub_udpmc_a

if (sockAddress == NULL || sockPort < 0) {
L_WARN("[PSA UPDMC] Error got endpoint without udpmc socket address/port or endpoint type. Properties:");
const char *key = NULL;
CELIX_PROPERTIES_FOR_EACH(endpoint, key) {
L_WARN("[PSA UPDMC] |- %s=%s\n", key, celix_properties_get(endpoint, key, NULL));
CELIX_PROPERTIES_ITERATE(endpoint, iter) {
L_WARN("[PSA UPDMC] |- %s=%s\n", iter.key, iter.entry.value);
}
status = CELIX_BUNDLE_EXCEPTION;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,8 @@ static celix_status_t pubsub_websocketAdmin_connectEndpointToReceiver(pubsub_web

if (publisher && (sockAddress == NULL || sockPort < 0)) {
L_WARN("[PSA WEBSOCKET] Error got endpoint without websocket address/port or endpoint type. Properties:");
const char *key = NULL;
CELIX_PROPERTIES_FOR_EACH(endpoint, key) {
L_WARN("[PSA WEBSOCKET] |- %s=%s\n", key, celix_properties_get(endpoint, key, NULL));
CELIX_PROPERTIES_ITERATE(endpoint, iter) {
L_WARN("[PSA WEBSOCKET] |- %s=%s\n", iter.key, iter.entry.value);
}
status = CELIX_BUNDLE_EXCEPTION;
} else {
Expand Down Expand Up @@ -436,9 +435,8 @@ static celix_status_t pubsub_websocketAdmin_disconnectEndpointFromReceiver(pubsu

if (publisher && (sockAddress == NULL || sockPort < 0)) {
L_WARN("[PSA WEBSOCKET] Error got endpoint without websocket address/port or endpoint type. Properties:");
const char *key = NULL;
CELIX_PROPERTIES_FOR_EACH(endpoint, key) {
L_WARN("[PSA WEBSOCKET] |- %s=%s\n", key, celix_properties_get(endpoint, key, NULL));
CELIX_PROPERTIES_ITERATE(endpoint, iter) {
L_WARN("[PSA WEBSOCKET] |- %s=%s\n", iter.key, iter.entry.value);
}
status = CELIX_BUNDLE_EXCEPTION;
} else if (eTopic != NULL && strncmp(eTopic, topic, 1024 * 1024) == 0) {
Expand Down
6 changes: 2 additions & 4 deletions bundles/pubsub/pubsub_discovery/src/pubsub_discovery_impl.c
Original file line number Diff line number Diff line change
Expand Up @@ -557,10 +557,8 @@ static char* pubsub_discovery_createJsonEndpoint(const celix_properties_t *props
//note props is already check for validity (pubsubEndpoint_isValid)

json_t *jsEndpoint = json_object();
const char* propKey = NULL;
PROPERTIES_FOR_EACH((celix_properties_t*)props, propKey) {
const char* val = celix_properties_get(props, propKey, NULL);
json_object_set_new(jsEndpoint, propKey, json_string(val));
CELIX_PROPERTIES_ITERATE(props, iter) {
json_object_set_new(jsEndpoint, iter.key, json_string(iter.entry.value));
}
char* str = json_dumps(jsEndpoint, JSON_COMPACT);
json_decref(jsEndpoint);
Expand Down
5 changes: 2 additions & 3 deletions bundles/pubsub/pubsub_spi/src/pubsub_endpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ static void pubsubEndpoint_setFields(celix_properties_t *ep, const char* fwUUID,

//copy topic properties
if (topic_props != NULL) {
const char *key = NULL;
CELIX_PROPERTIES_FOR_EACH((celix_properties_t *) topic_props, key) {
celix_properties_set(ep, key, celix_properties_get(topic_props, key, NULL));
CELIX_PROPERTIES_ITERATE((celix_properties_t *) topic_props, iter) {
celix_properties_set(ep, iter.key, iter.entry.value);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,20 +139,15 @@ static celix_status_t endpointDescriptorWriter_writeEndpoint(endpoint_descriptor
} else {
xmlTextWriterStartElement(writer->writer, ENDPOINT_DESCRIPTION);

hash_map_iterator_pt iter = hashMapIterator_create(endpoint->properties);
while (hashMapIterator_hasNext(iter)) {
hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);

void* propertyName = hashMapEntry_getKey(entry);
const xmlChar* propertyValue = (const xmlChar*) hashMapEntry_getValue(entry);

CELIX_PROPERTIES_ITERATE(endpoint->properties, iter) {
const xmlChar* propertyValue = (const xmlChar*) celix_properties_get(endpoint->properties, iter.key, "");
PengZheng marked this conversation as resolved.
Show resolved Hide resolved
xmlTextWriterStartElement(writer->writer, PROPERTY);
xmlTextWriterWriteAttribute(writer->writer, NAME, propertyName);
xmlTextWriterWriteAttribute(writer->writer, NAME, (const xmlChar*)iter.key);

if (strcmp(OSGI_FRAMEWORK_OBJECTCLASS, (char*) propertyName) == 0) {
if (strcmp(OSGI_FRAMEWORK_OBJECTCLASS, (char*) iter.key) == 0) {
// objectClass *must* be represented as array of string values...
endpointDescriptorWriter_writeArrayValue(writer->writer, propertyValue);
} else if (strcmp(OSGI_RSA_ENDPOINT_SERVICE_ID, (char*) propertyName) == 0) {
} else if (strcmp(OSGI_RSA_ENDPOINT_SERVICE_ID, (char*) iter.key) == 0) {
// endpoint.service.id *must* be represented as long value...
endpointDescriptorWriter_writeTypedValue(writer->writer, VALUE_TYPE_LONG, propertyValue);
} else {
Expand All @@ -162,7 +157,6 @@ static celix_status_t endpointDescriptorWriter_writeEndpoint(endpoint_descriptor

xmlTextWriterEndElement(writer->writer);
}
hashMapIterator_destroy(iter);

xmlTextWriterEndElement(writer->writer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -751,10 +751,7 @@ static celix_status_t remoteServiceAdmin_createEndpointDescription(remote_servic
}
}

hash_map_entry_pt entry = hashMap_getEntry(endpointProperties, (void *) OSGI_FRAMEWORK_SERVICE_ID);

char* key = hashMapEntry_getKey(entry);
char *serviceId = (char *) hashMap_remove(endpointProperties, (void *) OSGI_FRAMEWORK_SERVICE_ID);
const char* serviceId = celix_properties_get(endpointProperties, CELIX_FRAMEWORK_SERVICE_ID, "-1");
const char *uuid = NULL;

char buf[512];
Expand All @@ -781,12 +778,9 @@ static celix_status_t remoteServiceAdmin_createEndpointDescription(remote_servic
}

if (props != NULL) {
hash_map_iterator_pt propIter = hashMapIterator_create(props);
while (hashMapIterator_hasNext(propIter)) {
hash_map_entry_pt entry = hashMapIterator_nextEntry(propIter);
celix_properties_set(endpointProperties, (char*)hashMapEntry_getKey(entry), (char*)hashMapEntry_getValue(entry));
CELIX_PROPERTIES_ITERATE(props, iter) {
celix_properties_set(endpointProperties, iter.key, iter.entry.value);
}
hashMapIterator_destroy(propIter);
}

*endpoint = calloc(1, sizeof(**endpoint));
Expand All @@ -800,8 +794,6 @@ static celix_status_t remoteServiceAdmin_createEndpointDescription(remote_servic
(*endpoint)->properties = endpointProperties;
}

free(key);
free(serviceId);
free(keys);

return status;
Expand Down Expand Up @@ -1008,14 +1000,10 @@ static celix_status_t remoteServiceAdmin_send(void *handle, endpoint_description
} else {
struct curl_slist *metadataHeader = NULL;
if (metadata != NULL && celix_properties_size(metadata) > 0) {
const char *key = NULL;
CELIX_PROPERTIES_FOR_EACH(metadata, key) {
const char *val = celix_properties_get(metadata, key, "");
size_t length = strlen(key) + strlen(val) + 18; // "X-RSA-Metadata-key: val\0"

CELIX_PROPERTIES_ITERATE(metadata, iter) {
size_t length = strlen(iter.key) + strlen(iter.entry.value) + 18; // "X-RSA-Metadata-key: val\0"
char header[length];

snprintf(header, length, "X-RSA-Metadata-%s: %s", key, val);
snprintf(header, length, "X-RSA-Metadata-%s: %s", iter.key, iter.entry.value);
metadataHeader = curl_slist_append(metadataHeader, header);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,12 +254,12 @@ static void rsaShm_overlayProperties(celix_properties_t *additionalProperties, c
* A property key in the additional properties map must therefore override any case variant property key in the properties of the specified Service Reference.*/
const char *additionalPropKey = NULL;
const char *servicePropKey = NULL;
PROPERTIES_FOR_EACH(additionalProperties, additionalPropKey) {
CELIX_PROPERTIES_FOR_EACH(additionalProperties, additionalPropKey) {
if (strcmp(additionalPropKey,(char*) OSGI_FRAMEWORK_OBJECTCLASS) != 0
&& strcmp(additionalPropKey,(char*) OSGI_FRAMEWORK_SERVICE_ID) != 0) {
bool propKeyCaseEqual = false;

PROPERTIES_FOR_EACH(serviceProperties, servicePropKey) {
CELIX_PROPERTIES_FOR_EACH(serviceProperties, servicePropKey) {
if (strcasecmp(additionalPropKey,servicePropKey) == 0) {
const char* val = celix_properties_get(additionalProperties,additionalPropKey,NULL);
celix_properties_set(serviceProperties,servicePropKey,val);
Expand All @@ -274,7 +274,6 @@ static void rsaShm_overlayProperties(celix_properties_t *additionalProperties, c
}
}
}
return;
}

static bool rsaShm_isConfigTypeMatched(celix_properties_t *properties) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,7 @@ celix_status_t topologyManager_importScopeChanged(void *handle, char *service_na
hash_map_entry_pt entry = hashMapIterator_nextEntry(importedServicesIterator);
endpoint = hashMapEntry_getKey(entry);

entry = hashMap_getEntry(endpoint->properties, (void *) OSGI_FRAMEWORK_OBJECTCLASS);
char* name = (char *) hashMapEntry_getValue(entry);
const char* name = celix_properties_get(endpoint->properties, OSGI_FRAMEWORK_OBJECTCLASS, "");
// Test if a service with the same name is imported
if (strcmp(name, service_name) == 0) {
found = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,7 @@ extern "C" {
for (unsigned int i = 0; i < arrayList_size(epList); i++) {
endpoint_description_t *ep = (endpoint_description_t *) arrayList_get(epList, i);
celix_properties_t *props = ep->properties;
hash_map_entry_pt entry = hashMap_getEntry(props, (void*)"key2");
char* value = (char*) hashMapEntry_getValue(entry);
const char* value = celix_properties_get(props, "key2", "");
EXPECT_STREQ("inaetics", value);
/*
printf("Service: %s ", ep->service);
Expand Down Expand Up @@ -433,8 +432,7 @@ extern "C" {
for (unsigned int i = 0; i < arrayList_size(epList); i++) {
endpoint_description_t *ep = (endpoint_description_t *) arrayList_get(epList, i);
celix_properties_t *props = ep->properties;
hash_map_entry_pt entry = hashMap_getEntry(props, (void*)"key2");
char* value = (char*) hashMapEntry_getValue(entry);
const char* value = celix_properties_get(props, "key2", "");
EXPECT_STREQ("inaetics", value);
}
printf("End: %s\n", __func__);
Expand All @@ -458,8 +456,7 @@ extern "C" {
for (unsigned int i = 0; i < arrayList_size(epList); i++) {
endpoint_description_t *ep = (endpoint_description_t *) arrayList_get(epList, i);
celix_properties_t *props = ep->properties;
hash_map_entry_pt entry = hashMap_getEntry(props, (void *)"key2");
char* value = (char*) hashMapEntry_getValue(entry);
const char* value = celix_properties_get(props, "key2", "");
EXPECT_STREQ("inaetics", value);
}
printf("End: %s\n", __func__);
Expand Down
6 changes: 2 additions & 4 deletions bundles/shell/shell/src/query_command.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,8 @@ static void queryCommand_callback(void *handle, const celix_bundle_t *bnd) {
if (data->opts->verbose) {
fprintf(data->sout, " |- Is factory: %s\n", entry->factory ? "true" : "false");
fprintf(data->sout, " |- Properties:\n");
const char *key;
CELIX_PROPERTIES_FOR_EACH(entry->serviceProperties, key) {
const char *val = celix_properties_get(entry->serviceProperties, key, "!ERROR!");
fprintf(data->sout, " |- %20s = %s\n", key, val);
CELIX_PROPERTIES_ITERATE(entry->serviceProperties, iter) {
fprintf(data->sout, " |- %20s = %s\n", iter.key, iter.entry.value);
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions libs/framework/include/celix/Exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ namespace celix {
*/
class Exception : public std::exception {
public:
#if __cplusplus >= 201703L //C++17 or higher
explicit Exception(std::string_view msg) : w{msg} {}
#else
explicit Exception(std::string msg) : w{std::move(msg)} {}
#endif

Exception(const Exception&) = default;
Exception(Exception&&) = default;
Expand Down
1 change: 0 additions & 1 deletion libs/framework/include/celix/dm/DependencyManager_Impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ inline celix::dm::DependencyManagerInfo DependencyManager::getInfo() const {
}
}


inline std::vector<celix::dm::DependencyManagerInfo> DependencyManager::getInfos() const {
std::vector<celix::dm::DependencyManagerInfo> result{};
auto* cInfos = celix_dependencyManager_createInfos(cDependencyManager());
Expand Down
33 changes: 19 additions & 14 deletions libs/framework/src/service_reference.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,23 +196,28 @@ celix_status_t serviceReference_getProperty(service_reference_pt ref, const char
}

celix_status_t serviceReference_getPropertyKeys(service_reference_pt ref, char **keys[], unsigned int *size) {
celix_status_t status = CELIX_SUCCESS;
properties_pt props = NULL;
if (!keys || !size) {
return CELIX_ILLEGAL_ARGUMENT;
}

celix_properties_t* props = NULL;
celix_status_t status = serviceRegistration_getProperties(ref->registration, &props);
if (status != CELIX_SUCCESS) {
return status;
}

*size = celix_properties_size(props);
*keys = malloc((*size) * sizeof(**keys));
if (!*keys) {
return ENOMEM;
}

status = serviceRegistration_getProperties(ref->registration, &props);
assert(status == CELIX_SUCCESS);
hash_map_iterator_pt it;
int i = 0;
int vsize = hashMap_size(props);
*size = (unsigned int)vsize;
*keys = malloc(vsize * sizeof(**keys));
it = hashMapIterator_create(props);
while (hashMapIterator_hasNext(it)) {
(*keys)[i] = hashMapIterator_nextKey(it);
i++;
CELIX_PROPERTIES_ITERATE(props, entry) {
(*keys)[i++] = (char*)entry.key;
}
hashMapIterator_destroy(it);
return status;

return CELIX_SUCCESS;
}

celix_status_t serviceReference_invalidateCache(service_reference_pt reference) {
Expand Down
20 changes: 0 additions & 20 deletions libs/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,34 +143,14 @@ if (ENABLE_TESTING)
target_include_directories(linked_list_test PRIVATE include_deprecated)
target_link_libraries(linked_list_test utils_cut CppUTest::CppUTest pthread)

add_executable(properties_test private/test/properties_test.cpp)
target_include_directories(properties_test PRIVATE include_deprecated)
target_link_libraries(properties_test CppUTest::CppUTest CppUTest::CppUTestExt utils_cut pthread)

add_executable(ip_utils_test private/test/ip_utils_test.cpp)
target_include_directories(ip_utils_test PRIVATE include_deprecated)
target_link_libraries(ip_utils_test CppUTest::CppUTest utils_cut pthread)

add_executable(version_test private/test/version_test.cpp)
target_include_directories(version_test PRIVATE include_deprecated)
target_link_libraries(version_test CppUTest::CppUTest utils_cut pthread)


if (LINKER_WRAP_SUPPORTED)
add_executable(version_ei_test private/test/version_ei_test.cc)
target_include_directories(version_ei_test PRIVATE include_deprecated)
target_link_libraries(version_ei_test CppUTest::CppUTest utils_cut Celix::malloc_ei Celix::utils_ei pthread)
add_test(NAME version_ei_test COMMAND version_ei_test)
endif ()

configure_file(private/resources-test/properties.txt ${CMAKE_CURRENT_BINARY_DIR}/resources-test/properties.txt COPYONLY)

add_test(NAME run_array_list_test COMMAND array_list_test)
add_test(NAME run_hash_map_test COMMAND hash_map_test)
add_test(NAME run_linked_list_test COMMAND linked_list_test)
add_test(NAME run_properties_test COMMAND properties_test)
add_test(NAME run_ip_utils_test COMMAND ip_utils_test)
add_test(NAME version_test COMMAND version_test)

setup_target_for_coverage(array_list_test)
setup_target_for_coverage(hash_map_test)
Expand Down
7 changes: 7 additions & 0 deletions libs/utils/gtest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ set(CELIX_UTIL_TEST_SOURCES_FOR_CXX_HEADERS
src/CxxUtilsTestSuite.cc
src/CxxPropertiesTestSuite.cc
src/CxxFilterTestSuite.cc
src/CxxVersionTestSuite.cc
)

add_executable(test_utils
Expand All @@ -33,6 +34,8 @@ add_executable(test_utils
src/FilterTestSuite.cc
src/CelixUtilsTestSuite.cc
src/ConvertUtilsTestSuite.cc
src/PropertiesTestSuite.cc
src/VersionTestSuite.cc
src/ErrTestSuite.cc
src/ThreadsTestSuite.cc
src/CelixErrnoTestSuite.cc
Expand All @@ -43,6 +46,9 @@ target_link_libraries(test_utils PRIVATE utils_cut GTest::gtest GTest::gtest_mai
target_include_directories(test_utils PRIVATE ../src) #for version_private (needs refactoring of test)
celix_deprecated_utils_headers(test_utils)

configure_file(resources/properties.txt ${CMAKE_CURRENT_BINARY_DIR}/resources-test/properties.txt COPYONLY)


####### generating zip file used for testing ##########################################################################
file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/zip_content/top.properties" CONTENT "level=1\n")
file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/zip_content/subdir/sub.properties" CONTENT "level=2\n")
Expand Down Expand Up @@ -87,6 +93,7 @@ if (LINKER_WRAP_SUPPORTED)
src/IpUtilsErrorInjectionTestSuite.cc
src/ArrayListErrorInjectionTestSuite.cc
src/ErrErrorInjectionTestSuite.cc
src/VersionErrorInjectionTestSuite.cc
)
target_link_libraries(test_utils_with_ei PRIVATE Celix::zip_ei Celix::stdio_ei Celix::stat_ei Celix::fts_ei utils_cut Celix::utils_ei Celix::ifaddrs_ei Celix::threads_ei Celix::malloc_ei GTest::gtest GTest::gtest_main)
target_include_directories(test_utils_with_ei PRIVATE ../src) #for version_private (needs refactoring of test)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ TEST_F(ConvertUtilsWithErrorInjectionTestSuite, CovertToBoolTest) {
}

TEST_F(ConvertUtilsWithErrorInjectionTestSuite, ConvertToVersionTest) {
celix_version_t* defaultVersion = celix_version_createVersion(1, 2, 3, "B");
celix_version_t* defaultVersion = celix_version_create(1, 2, 3, "B");
celix_ei_expect_celix_utils_writeOrCreateString(CELIX_EI_UNKNOWN_CALLER, 0, nullptr);
celix_version_t* result = celix_utils_convertStringToVersion("1.2.3", nullptr, nullptr);
EXPECT_EQ(nullptr, result);
Expand Down
Loading