Skip to content

Commit

Permalink
Merge pull request #1719 from FIWARE/hardening/functest-for-context-c…
Browse files Browse the repository at this point in the history
…ache-reload

Added a functest for issue 1708
  • Loading branch information
kzangeli authored Dec 12, 2024
2 parents fe744a2 + 7924a50 commit 98ab745
Show file tree
Hide file tree
Showing 5 changed files with 601 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/lib/logMsg/traceLevels.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ typedef enum TraceLevels
LmtContextDownload, // Context Download
LmtCoreContext, // Core Context
LmtUserContext, // User Context
LmtContextItem, // Item in context cache
LmtExpand, // JSON-LD Expansions
LmtCompact, // JSON-LD Compactions

// GeoJSON
LmtGeoJSON = 110, // GeoJSON ... everything (for now)
Expand Down
6 changes: 4 additions & 2 deletions src/lib/orionld/context/orionldAttributeExpand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include <string.h> // strcmp

#include "logMsg/logMsg.h" // LM_*
#include "logMsg/traceLevels.h" // Lmt*

#include "orionld/context/orionldContextItemAlreadyExpanded.h" // orionldContextItemAlreadyExpanded
#include "orionld/context/orionldContextItemExpand.h" // orionldContextItemExpand
Expand Down Expand Up @@ -67,7 +66,7 @@ char* orionldAttributeExpand
// The implementation needs modifications.
//
// Wait ... what if the @context says it must be a String, a DateTime?
// The @context doesn't distinguish between attributesd and sub-attributes ...
// The @context doesn't distinguish between attributes and sub-attributes ...
// It will need to be a String wherever it is.
//
// We should probably forbid an attribute to have the name 'observedAt'
Expand All @@ -80,7 +79,10 @@ char* orionldAttributeExpand
#endif

if (orionldContextItemAlreadyExpanded(sName) == true)
{
LM_T(LmtExpand, ("Already Expanded: '%s'", sName));
return sName;
}

return orionldContextItemExpand(contextP, sName, useDefaultUrlIfNotFound, contextItemPP);
}
3 changes: 3 additions & 0 deletions src/lib/orionld/context/orionldContextHashTablesFill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ bool orionldContextHashTablesFill(OrionldContext* contextP, KjNode* keyValueTree
return false;
}

LM_T(LmtContextItem, ("Adding '%s' -> '%s' to hash table for context '%s' (step 1)", hiP->name, hiP->id, contextP->url));
khashItemAdd(nameHashTableP, hiP->name, hiP);
}

Expand All @@ -123,6 +124,8 @@ bool orionldContextHashTablesFill(OrionldContext* contextP, KjNode* keyValueTree
hashItemP->id = kaStrdup(&kalloc, hashItemP->id);
khashItemAdd(valueHashTableP, hashItemP->id, hashItemP);

LM_T(LmtContextItem, ("Fixed '%s' -> '%s' in hash table for context '%s' (step 2)", hashItemP->name, hashItemP->id, contextP->url));

itemP = itemP->next;
}
}
Expand Down
13 changes: 10 additions & 3 deletions src/lib/orionld/context/orionldContextItemExpand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include <string.h> // strchr

#include "logMsg/logMsg.h" // LM_*
#include "logMsg/traceLevels.h" // Lmt*

#include "orionld/types/OrionldContextItem.h" // OrionldContextItem
#include "orionld/types/OrionldContext.h" // OrionldContext
Expand Down Expand Up @@ -72,7 +71,11 @@ char* orionldContextItemExpand
contextP = orionldCoreContextP;

if ((colonP = strchr((char*) shortName, ':')) != NULL)
return orionldContextPrefixExpand(contextP, shortName, colonP);
{
char* longName = orionldContextPrefixExpand(contextP, shortName, colonP);
LM_T(LmtExpand, ("Prefix-Expanded '%s' to '%s'", shortName, longName));
return longName;
}

// 1. Lookup in Core Context
if (orionldCoreContextP != NULL)
Expand All @@ -98,17 +101,21 @@ char* orionldContextItemExpand

orionldCoreContextP->expansions += 1; // Really, @vocab expansions of the core context

LM_T(LmtExpand, ("Vocab-Expanded '%s' to '%s'", shortName, longName));
return longName;
}

LM_T(LmtExpand, ("No Expansion found for '%s'", shortName));
return NULL;
}

// 4. Save the pointer to the context item
if (contextItemPP != NULL)
*contextItemPP = contextItemP;

contextP->expansions += 1; // Really, @vocab expansions of the core context
contextP->expansions += 1;

LM_T(LmtExpand, ("Expanded '%s' to '%s'", shortName, contextItemP->id));

return contextItemP->id;
}
Loading

0 comments on commit 98ab745

Please sign in to comment.