Skip to content

Commit

Permalink
Fixed a bug in ftClient
Browse files Browse the repository at this point in the history
  • Loading branch information
kzangeli committed Oct 1, 2024
1 parent 0d7016d commit cbb73b4
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 8 deletions.
52 changes: 48 additions & 4 deletions test/functionalTest/cases/0000_dds/dds_notifications.test
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ echo "===================================================="
payload='{
"i": 2
}'
orionCurl --url '/dds/pub?ddsTopicType=xyz&xyz&entityId=urn:E2&ddsTopicName=P2' --port $FT_PORT --payload "$payload"
orionCurl --url '/dds/pub?ddsTopicType=xyz&entityId=urn:E2&entityType=T&ddsTopicName=P2' --port $FT_PORT --payload "$payload"
echo
echo

Expand All @@ -62,7 +62,7 @@ echo "===================================================="
payload='{
"f": 3.14
}'
orionCurl --url '/dds/pub?ddsTopicType=xyzxyz&entityId=urn:E1&ddsTopicName=P3' --port $FT_PORT --payload "$payload"
orionCurl --url '/dds/pub?ddsTopicType=xyz&entityId=urn:E3&entityType=T&ddsTopicName=P3' --port $FT_PORT --payload "$payload"
echo
echo

Expand Down Expand Up @@ -99,12 +99,34 @@ Date: REGEX(.*)
04. Query the broker for all its entities, see urn:E1 and urn:E2
================================================================
HTTP/1.1 200 OK
Content-Length: 203
Content-Length: 610
Content-Type: application/json
Date: REGEX(.*)
Link: <https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-contextREGEX(.*)

[
{
"P1": {
"type": "Property",
"value": {
"data": {
"0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0": {
"b": false,
"f": 0,
"i": 0,
"ia": [
0,
0
],
"s": "abc"
}
},
"type": "NgsildSample"
}
},
"id": "urn:REGEX(.*)",
"type": "T"
},
{
"P2": {
"type": "Property",
Expand All @@ -124,7 +146,29 @@ Link: <https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-contextREGEX(.*)
"type": "NgsildSample"
}
},
"id": "urn:01.0f.bc.a1.62.42.9a.b8.01.00.01.00",
"id": "urn:REGEX(.*)",
"type": "T"
},
{
"P3": {
"type": "Property",
"value": {
"data": {
"0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0": {
"b": false,
"f": 0,
"i": 3,
"ia": [
0,
0
],
"s": ""
}
},
"type": "NgsildSample"
}
},
"id": "urn:REGEX(.*)",
"type": "T"
}
]
Expand Down
3 changes: 2 additions & 1 deletion test/functionalTest/ftClient/ddsPublish.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,12 @@ void ddsPublishEntity
KT_V("Publishing the entity '%s' in DDS", entityId);

NgsildPublisher* publisherP = new NgsildPublisher(topicType);
usleep(100000);

KT_V("Initializing publisher for topicType '%s', topicName '%s'", topicType, topicName);
if (publisherP->init(topicName))
{
usleep(100000);

char* s = NULL;
int i = 0;
double f = 0;
Expand Down
4 changes: 1 addition & 3 deletions test/functionalTest/ftClient/mhdRequestInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@ MHD_Result uriParamReceive(void* cbDataP, MHD_ValueKind kind, const char* key, c
{
KT_V("Got a URL Parameter: '%s': '%s'", key, value);

if (uriParams == NULL)
uriParams = kjObject(NULL, "params");

KjNode* paramP = kjString(NULL, key, value);
kjChildAdd(uriParams, paramP);

Expand All @@ -91,6 +88,7 @@ MHD_Result mhdRequestInit(MHD_Connection* connection, const char* url, const cha
orionldState.urlPath = (char*) url;

httpHeaders = kjObject(NULL, "headers");
uriParams = kjObject(NULL, "params");

MHD_get_connection_values(connection, MHD_HEADER_KIND, headerReceive, NULL);
MHD_get_connection_values(connection, MHD_GET_ARGUMENT_KIND, uriParamReceive, NULL);
Expand Down
4 changes: 4 additions & 0 deletions test/functionalTest/ftClient/postDdsPub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ extern "C"
}

#include "common/orionldState.h" // orionldState
#include "common/traceLevels.h" // KT_T trace levels
#include "dds/kjTreeLog.h" // kjTreeLog2

#include "ftClient/ddsPublish.h" // ddsPublishEntity
#include "ftClient/ftErrorResponse.h" // ftErrorResponse
Expand All @@ -46,6 +48,8 @@ extern __thread KjNode* uriParams;
//
KjNode* postDdsPub(int* statusCodeP)
{
kjTreeLog2(uriParams, "uriParams", StDds);

KjNode* ddsTopicTypeNodeP = (uriParams != NULL)? kjLookup(uriParams, "ddsTopicType") : NULL;
const char* ddsTopicType = (ddsTopicTypeNodeP != NULL)? ddsTopicTypeNodeP->value.s : NULL;
KjNode* ddsTopicNameNodeP = (uriParams != NULL)? kjLookup(uriParams, "ddsTopicName") : NULL;
Expand Down

0 comments on commit cbb73b4

Please sign in to comment.