/* ****************************************************************************
*
* put - 
*/
TEST(putSubscriptionConvOp, put)
{
  ConnectionInfo ci1("/ngsi10/contextSubscriptions/012345678901234567890123",  "DELETE", "1.1");
  ConnectionInfo ci2("/ngsi10/contextSubscriptions/111222333444555666777888",  "PUT",    "1.1");
  ConnectionInfo ci3("/ngsi10/contextSubscriptions/111222333444555666777881",  "PUT",    "1.1");
  ConnectionInfo ci4("/ngsi10/contextSubscriptions/012345678901234567890123",  "XVERB",  "1.1");
  const char*    infile       = "ngsi10.updateContextSubscriptionRequest.subscriptionNotFound.valid.xml";
  const char*    outfile1     = "ngsi10.unsubscribeContextResponse.putSubscriptionConvOp.notFound.valid.xml";
  const char*    outfile2     = "ngsi10.updateContextSubscriptionResponse.putSubscriptionConvOp.notFound.valid.xml";
  const char*    outfile3     = "ngsi10.updateContextSubscriptionResponse.putSubscriptionConvOp.unmatchingSubscriptionId.valid.xml";
  std::string    out;

  utInit();

  EXPECT_EQ("OK", testDataFromFile(testBuf, sizeof(testBuf), infile)) << "Error getting test data from '" << infile << "'";
  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), outfile1)) << "Error getting test data from '" << outfile1 << "'";
  ci1.outFormat    = XML;
  ci1.inFormat     = XML;
  ci1.payload      = NULL;
  ci1.payloadSize  = 0;
  out              = restService(&ci1, rs);
  EXPECT_STREQ(expectedBuf, out.c_str());
  

  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), outfile2)) << "Error getting test data from '" << outfile2 << "'";
  ci2.outFormat    = XML;
  ci2.inFormat     = XML;
  ci2.payload      = testBuf;
  ci2.payloadSize  = strlen(testBuf);
  out              = restService(&ci2, rs);
  EXPECT_STREQ(expectedBuf, out.c_str());


  EXPECT_EQ("OK", testDataFromFile(testBuf, sizeof(testBuf), infile)) << "Error getting test data from '" << infile << "'";
  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), outfile3)) << "Error getting test data from '" << outfile3 << "'";
  ci3.outFormat    = XML;
  ci3.inFormat     = XML;
  ci3.payload      = testBuf;
  ci3.payloadSize  = strlen(testBuf);
  out              = restService(&ci3, rs);
  EXPECT_STREQ(expectedBuf, out.c_str());


  ci4.outFormat    = XML;
  ci4.inFormat     = XML;
  ci4.payload      = NULL;
  ci4.payloadSize  = 0;
  out              = restService(&ci4, rs);
  EXPECT_EQ("", out);
  EXPECT_EQ("Allow",       ci4.httpHeader[0]);
  EXPECT_EQ("PUT, DELETE", ci4.httpHeaderValue[0]);

  utExit();
}
Example #2
0
/* ****************************************************************************
*
* present - no output expected, just exercising the code
*/
TEST(Scope, present)
{
  Scope   scope("Type", "Value");

  utInit();

  scope.present("", -1);
  scope.present("", 0);

  utExit();
}
Example #3
0
/* ****************************************************************************
*
* json -
*/
TEST(restReply, json)
{
    ConnectionInfo  ci("/ngsi/XXX", "GET", "1.1");

    utInit();

    ci.outFormat = JSON;
    restReply(&ci, "123");

    utExit();
}
/* ****************************************************************************
*
* c_str - 
*/
TEST(ProvidingApplication, c_str)
{
  ProvidingApplication  pa;

  utInit();

  pa.set("PA");
  EXPECT_STREQ("PA", pa.c_str());

  utExit();
}
/* ****************************************************************************
*
* c_str -
*/
TEST(RestrictionString, c_str)
{
  RestrictionString   restrictionString;

  utInit();

  restrictionString.set("STR");
  EXPECT_STREQ("STR", restrictionString.c_str());

  utExit();
}
/* ****************************************************************************
*
* present - no output expected, just exercising the code
*/
TEST(Metadata, present)
{
  Metadata     m4("Name", "Type", "Value");

  utInit();

  m4.present("Test", 0, "");
  m4.release();

  utExit();
}
/* ****************************************************************************
*
* check - 
*/
TEST(SubscribeError, check)
{
  SubscribeError  se;
  std::string     checked;

  utInit();

  checked = se.check(SubscribeContext, XML, "", "", 0);
  EXPECT_STREQ("OK", checked.c_str());

  utExit();
}
/* ****************************************************************************
*
* updateTwoStringsJson -
*/
TEST(compoundValue, updateTwoStringsJson)
{
  ParseData                  reqData;
  const char*                inFile  = "ngsi10.updateContextRequest.updateTwoStrings.valid.json";
  ConnectionInfo             ci("/ngsi10/updateContext", "POST", "1.1");
  ContextAttribute*          caP;
  orion::CompoundValueNode*  cvnRootP;
  orion::CompoundValueNode*  childP;
  RestService                restService = { UpdateContext, 2, { "ngsi10", "updateContext" }, NULL };

  utInit();

  EXPECT_EQ("OK", testDataFromFile(testBuf, sizeof(testBuf), inFile)) << "Error getting test data from '" << inFile << "'";

  ci.inMimeType   = JSON;
  ci.outMimeType  = JSON;
  ci.restServiceP = &restService;

  std::string result = jsonTreat(testBuf, &ci, &reqData, UpdateContext, NULL);

  EXPECT_STREQ("OK", result.c_str());

  caP = reqData.upcr.res.entityVector[0]->attributeVector[0];
  EXPECT_TRUE(caP != NULL);
  EXPECT_TRUE(caP->compoundValueP != NULL);

  // Get root of compound value
  cvnRootP = caP->compoundValueP;

  // The root should be a struct in this test case
  EXPECT_EQ(orion::ValueTypeObject, cvnRootP->valueType);

  // The root should have exactly two children
  EXPECT_EQ(2, cvnRootP->childV.size());

  // child 1
  childP = cvnRootP->childV[0];

  EXPECT_EQ("s1",                              childP->name);
  EXPECT_EQ(orion::ValueTypeString,  childP->valueType);
  EXPECT_EQ("STRING",                          childP->stringValue);
  EXPECT_EQ(0,                                 childP->childV.size());

  // child 2
  childP = cvnRootP->childV[1];

  EXPECT_EQ("s2",                              childP->name);
  EXPECT_EQ(orion::ValueTypeString,  childP->valueType);
  EXPECT_EQ("STRING",                          childP->stringValue);
  EXPECT_EQ(0,                                 childP->childV.size());

  utExit();
}
/* ****************************************************************************
*
* present - no output expected, just exercising the code
*/
TEST(ScopeVector, present)
{
  ScopeVector   sV;
  Scope         scope("Type", "Value");

  utInit();

  sV.push_back(&scope);
  sV.present("");

  utExit();
}
/* ****************************************************************************
*
* somethingFound - 
*/
TEST(getContextEntityTypeAttribute, somethingFound)
{
  ConnectionInfo ci1("/ngsi9/registerContext",                                 "POST", "1.1");
  ConnectionInfo ci2("/ngsi9/contextEntityTypes/Room/attributes/temperature",  "GET",  "1.1");
  const char*    registerXmlFile = "ngsi9.registerContextRequest.ok.valid.xml";
  const char*    outfile1        = "ngsi9.registerContextResponse.ok.middle.xml";
  const char*    outfile2        = "ngsi9.discoverContextAvailabilityResponse.ok.valid.xml";
  std::string    out;

  utInit();
  // Avoid forwarding of messages
  extern int fwdPort;
  int saved = fwdPort;

  //
  // 1. Register entities so we have something to find:
  //    - entityId type="Room" isPattern="false", ConferenceRoom
  //    - entityId type="Room" isPattern="false", OfficeRoom
  //
  EXPECT_EQ("OK", testDataFromFile(testBuf, sizeof(testBuf), registerXmlFile)) << "Error getting test data from '" << registerXmlFile << "'";

  ci1.outFormat    = XML;
  ci1.inFormat     = XML;
  ci1.payload      = testBuf;
  ci1.payloadSize  = strlen(testBuf);
  out              = restService(&ci1, rs);

  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), outfile1)) << "Error getting test data from '" << outfile1 << "'";

  char* outStart  = (char*) out.c_str();

  // Remove last char in expectedBuf
  expectedBuf[strlen(expectedBuf) - 1] = 0;

  // Shorten 'out' to be of same length as expectedBuf
  outStart[strlen(expectedBuf)]    = 0;
  EXPECT_STREQ(expectedBuf, out.c_str());


  //
  // Now discover
  //
  ci2.outFormat = XML;
  out           = restService(&ci2, rs);

  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), outfile2)) << "Error getting test data from '" << outfile2 << "'";
  EXPECT_STREQ(expectedBuf, out.c_str());

  // Putting old value back
  fwdPort = saved;

  utExit();
}
/* ****************************************************************************
*
* present - just to exercise the code ...
*/
TEST(ProvidingApplication, present)
{
  ProvidingApplication  pa;

  utInit();

  pa.present("");
  pa.set("PA");
  pa.present("");

  utExit();
}
/* ****************************************************************************
*
* constructors - 
*/
TEST(SubscriptionId, constructors)
{
  SubscriptionId s1;
  SubscriptionId s2("subId");

  utInit();

  EXPECT_EQ("", s1.string);
  EXPECT_EQ("subId", s2.string);

  utExit();
}
/* ****************************************************************************
*
* check_json - 
*/
TEST(AppendContextElementRequest, check_json)
{
   AppendContextElementRequest  acer;
   std::string                  out;
   ContextAttribute             ca("caName", "caType", "121");
   Metadata                     md("mdName", "mdType", "122");
   const char*                  outfile1 = "ngsi10.appendContextElementResponse.predetectedError.valid.json";
   const char*                  outfile2 = "ngsi10.appendContextElementResponse.missingAttributeName.valid.json";
   const char*                  outfile3 = "ngsi10.appendContextElementResponse.missingMetadataName.valid.json";
   ConnectionInfo               ci;

   utInit();

   acer.attributeDomainName.set("ADN");
   acer.contextAttributeVector.push_back(&ca);
   acer.domainMetadataVector.push_back(&md);

   // 1. ok
   ci.outMimeType = JSON;
   out = acer.check(&ci, AppendContextElement, "", "", 0);
   EXPECT_STREQ("OK", out.c_str());


   // 2. Predetected error 
   EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), outfile1)) << "Error getting test data from '" << outfile1 << "'";
   out = acer.check(&ci, AppendContextElement, "", "Error is predetected", 0);
   EXPECT_STREQ(expectedBuf, out.c_str());
   

   // 3. bad ContextAttribute
   ContextAttribute  ca2("", "caType", "121");

   acer.contextAttributeVector.push_back(&ca2);
   out = acer.check(&ci, AppendContextElement, "", "", 0);
   EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), outfile2)) << "Error getting test data from '" << outfile2 << "'";   
   EXPECT_STREQ(expectedBuf, out.c_str());
   ca2.name = "ca2Name";


   // 4. Bad domainMetadata
   Metadata  md2("", "mdType", "122");

   acer.domainMetadataVector.push_back(&md2);
   out = acer.check(&ci, AppendContextElement, "", "", 0);
   EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), outfile3)) << "Error getting test data from '" << outfile3 << "'";   
   EXPECT_STREQ(expectedBuf, out.c_str());


   // 5. Bad attributeDomainName
   // FIXME P3: AttributeDomainName::check always returns "OK"

   utExit();
}
/* ****************************************************************************
*
* noPatternMultiAttr -
*
* Discover:  E1 - (A3, A4, A5)
* Result:    E1 - A3 - http://cr1.com
*            E1 - A4 - http://cr2.com
*/
TEST(mongoContextProvidersUpdateRequest, noPatternMultiAttr)
{
  HttpStatusCode         ms;
  UpdateContextRequest   req;
  UpdateContextResponse  res;

  /* Prepare database */
  utInit();
  prepareDatabase();

  /* Forge the request (from "inside" to "outside") */
  ContextElement ce;
  ce.entityId.fill("E1", "T1", "false");
  ContextAttribute ca1("A3", "TA3", "new_val");
  ContextAttribute ca2("A4", "TA4", "new_val");
  ContextAttribute ca3("A5", "TA5", "new_val");
  ce.contextAttributeVector.push_back(&ca1);
  ce.contextAttributeVector.push_back(&ca2);
  ce.contextAttributeVector.push_back(&ca3);
  req.contextElementVector.push_back(&ce);
  req.updateActionType.set("UPDATE");

  /* Invoke the function in mongoBackend library */
  ms = mongoUpdateContext(&req, &res, "", servicePathVector, uriParams);

  /* Check response is as expected */
  EXPECT_EQ(SccOk, ms);

  EXPECT_EQ(SccNone, res.errorCode.code);
  EXPECT_EQ(0, res.errorCode.reasonPhrase.size());
  EXPECT_EQ(0, res.errorCode.details.size());

  ASSERT_EQ(1, res.contextElementResponseVector.size());
  EXPECT_EQ("E1", RES_CER(0).entityId.id);
  EXPECT_EQ("T1", RES_CER(0).entityId.type);
  EXPECT_EQ("false", RES_CER(0).entityId.isPattern);
  ASSERT_EQ(3, RES_CER(0).contextAttributeVector.size());
  EXPECT_EQ("A3", RES_CER_ATTR(0, 0)->name);
  EXPECT_EQ("TA3", RES_CER_ATTR(0, 0)->type);
  EXPECT_EQ("A4", RES_CER_ATTR(0, 1)->name);
  EXPECT_EQ("TA4", RES_CER_ATTR(0, 1)->type);
  EXPECT_EQ("A5", RES_CER_ATTR(0, 2)->name);
  EXPECT_EQ("TA5", RES_CER_ATTR(0, 2)->type);
  EXPECT_EQ(SccFound, RES_CER_STATUS(0).code);
  EXPECT_EQ("Found", RES_CER_STATUS(0).reasonPhrase);
  EXPECT_EQ("http://cr1.com", RES_CER_STATUS(0).details);

  /* Release connection */
  mongoDisconnect();

  utExit();

}
/* ****************************************************************************
*
* entityTypeWithoutFilter -
*
*/
TEST(mongoQueryContextExistEntity, entityTypeWithoutFilter)
{
    HttpStatusCode         ms;
    QueryContextRequest   req;
    QueryContextResponse  res;

    utInit();

    /* Prepare database */
    prepareDatabase();

    /* Forge the request (from "inside" to "outside") */
    EntityId en("E1", "", "false");
    req.entityIdVector.push_back(&en);

    /* Invoke the function in mongoBackend library */
    ms = mongoQueryContext(&req, &res, "", servicePathVector , uriParams);

    /* Check response is as expected */
    EXPECT_EQ(SccOk, ms);

    EXPECT_EQ(SccNone, res.errorCode.code);
    EXPECT_EQ("", res.errorCode.reasonPhrase);
    EXPECT_EQ("", res.errorCode.details);

    ASSERT_EQ(2, res.contextElementResponseVector.size());
    /* Context Element response # 1 */
    EXPECT_EQ("E1", RES_CER(0).entityId.id);
    EXPECT_EQ("T1", RES_CER(0).entityId.type);
    EXPECT_EQ("false", RES_CER(0).entityId.isPattern);
    ASSERT_EQ(1, RES_CER(0).contextAttributeVector.size());
    EXPECT_EQ("A1", RES_CER_ATTR(0, 0)->name);
    EXPECT_EQ("TA1", RES_CER_ATTR(0, 0)->type);
    EXPECT_EQ("val1", RES_CER_ATTR(0, 0)->stringValue);
    EXPECT_EQ(SccOk, RES_CER_STATUS(0).code);
    EXPECT_EQ("OK", RES_CER_STATUS(0).reasonPhrase);
    EXPECT_EQ("", RES_CER_STATUS(0).details);

    /* Context Element response # 2 */
    EXPECT_EQ("E1", RES_CER(1).entityId.id);
    EXPECT_EQ("", RES_CER(1).entityId.type);
    EXPECT_EQ("false", RES_CER(1).entityId.isPattern);
    ASSERT_EQ(1, RES_CER(1).contextAttributeVector.size());
    EXPECT_EQ("A1", RES_CER_ATTR(1, 0)->name);
    EXPECT_EQ("TA1", RES_CER_ATTR(1, 0)->type);
    EXPECT_EQ("val1b", RES_CER_ATTR(1, 0)->stringValue);
    EXPECT_EQ(SccOk, RES_CER_STATUS(1).code);
    EXPECT_EQ("OK", RES_CER_STATUS(1).reasonPhrase);
    EXPECT_EQ(0, RES_CER_STATUS(1).details.size());
 
    utExit();
}
Example #16
0
/* ****************************************************************************
*
* parseError - 
*/
TEST(xmlRequest, parseError)
{
  ConnectionInfo  ci("/ngsi/registerContext", "POST", "1.1");
  ConnectionInfo  ci2("/ngsi/registerContext123", "POST", "1.1");
  ConnectionInfo  ci3("/ngsi/registerContext", "POST", "1.1");
  ConnectionInfo  ci4("/version", "POST", "1.1");
  ParseData       parseData;
  const char*     infile1  = "ngsi9.registerContextRequest.parseError.invalid.xml"; 
  const char*     infile2  = "ngsi9.registerContextRequest.ok.valid.xml"; 
  const char*     infile3  = "ngsi9.registerContextRequest.errorInFirstLine.invalid.xml";
  const char*     outfile1 = "orion.error.parseError.valid.xml";
  const char*     outfile2 = "orion.error.noRequestTreatingObjectFound.valid.xml";
  const char*     outfile3 = "orion.error.parseError.valid.xml";
  const char*     outfile4 = "ngsi9.registerContextResponse.invalidPayload.valid.xml";
  std::string     out;

  utInit();

  // Parse Error
  EXPECT_EQ("OK", testDataFromFile(testBuf, sizeof(testBuf), infile1)) << "Error getting test data from '" << infile1 << "'";
  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), outfile1)) << "Error getting test data from '" << outfile1 << "'";
  ci.inFormat  = XML;
  ci.outFormat = XML;
  out  = xmlTreat(testBuf, &ci, &parseData, RegisterContext, "registerContextRequest", NULL);
  EXPECT_STREQ(expectedBuf, out.c_str());

  // Request not found
  EXPECT_EQ("OK", testDataFromFile(testBuf, sizeof(testBuf), infile2)) << "Error getting test data from '" << infile2 << "'";
  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), outfile2)) << "Error getting test data from '" << outfile2 << "'";
  ci2.inFormat  = XML;
  ci2.outFormat = XML;
  out  = xmlTreat(testBuf, &ci2, &parseData, (RequestType) (RegisterContext + 1000), "registerContextRequest", NULL);
  EXPECT_STREQ(expectedBuf, out.c_str());

  // Error in first line '<?xml version="1.0" encoding="UTF-8"?>'
  EXPECT_EQ("OK", testDataFromFile(testBuf, sizeof(testBuf), infile3)) << "Error getting test data from '" << infile3 << "'";
  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), outfile3)) << "Error getting test data from '" << outfile3 << "'";
  ci3.inFormat  = XML;
  ci3.outFormat = XML;
  out  = xmlTreat(testBuf, &ci3, &parseData, RegisterContext, "registerContextRequest", NULL);
  EXPECT_STREQ(expectedBuf, out.c_str());

  // Payload word differs
  EXPECT_EQ("OK", testDataFromFile(testBuf, sizeof(testBuf), infile2)) << "Error getting test data from '" << infile2 << "'";
  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), outfile4)) << "Error getting test data from '" << outfile4 << "'";
  ci.inFormat  = XML;
  ci.outFormat = XML;
  out  = xmlTreat(testBuf, &ci, &parseData, RegisterContext, "discovery", NULL);
  EXPECT_STREQ(expectedBuf, out.c_str());

  utExit();
}
/* ****************************************************************************
*
* tenCompounds -
*
*/
TEST(compoundValue, tenCompounds)
{
  ParseData                  reqData;
  UpdateContextRequest*      upcrP;
  std::string                rendered;

  utInit();

  upcrP = &reqData.upcr.res;
  rendered = upcrP->toJsonV1(false);

  utExit();
}
/* ****************************************************************************
*
* render - 
*
*/
TEST(ContextRegistrationVector, render)
{
  ContextRegistrationVector  crv;
  ContextRegistration        cr;
  std::string                out;

  utInit();

  out = crv.render("", false);
  EXPECT_STREQ("", out.c_str());

  utExit();
}
/* ****************************************************************************
*
* ok -
*/
TEST(deleteIndividualContextEntityAttribute, ok)
{
    ConnectionInfo  ci("/ngsi10/contextEntities/entity901/attributes/aa",  "DELETE", "1.1");
    const char*     outfile = "ngsi10.deleteIndividualContextEntityAttribute.valid.xml";

    utInit();

    EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), outfile)) << "Error getting test data from '" << outfile << "'";
    std::string out = restService(&ci, rs);
    EXPECT_STREQ(expectedBuf, out.c_str());

    utExit();
}
/* ****************************************************************************
*
* typeName - 
*/
TEST(CompoundValueNode, typeName)
{
  orion::CompoundValueNode::Type  type[]     = { orion::CompoundValueNode::Unknown, orion::CompoundValueNode::Object, orion::CompoundValueNode::Vector, orion::CompoundValueNode::String };
  const char*                     expected[] = { "Unknown",                         "Object",                         "Vector",                         "String" };

  utInit();

  for (unsigned int ix = 0; ix < sizeof(type) / sizeof(type[0]); ++ix)
    EXPECT_STREQ(expected[ix], orion::CompoundValueNode::typeName(type[ix]));
  EXPECT_STREQ("Invalid", orion::CompoundValueNode::typeName((orion::CompoundValueNode::Type) 55));

  utExit();
}
/* ****************************************************************************
*
* check -
*/
TEST(ContextRegistrationResponse, check)
{
    ContextRegistrationResponse  crr;
    std::string                  checked;
    std::string                  expected = "no providing application";

    utInit();

    checked = crr.check(RegisterContext, XML, "", "", 0);
    EXPECT_STREQ(expected.c_str(), checked.c_str());

    utExit();
}
/* ****************************************************************************
*
* emptyPath - 
*/
TEST(Convenience, emptyPath)
{
  ConnectionInfo            ci("", "GET", "1.1");
  std::string               response;
  std::string               expected = "Empty URL";

  utInit();

  response = restService(&ci, restServiceV);
  EXPECT_STREQ(expected.c_str(), response.c_str());

  utExit();
}
Example #23
0
// Return the name of the type.
char *getTypeName(peGraphType type) {
    switch(type) {
    case SLIDING_WINDOW: return "sliding_window";
    case RAND_CUBED: return "rand_cubed";
    case RAND: return "rand";
    case CATENA: return "catena";
    case SLIDING_REVERSE: return "sliding_reverse";
    case REVERSE: return "reverse";
    default:
        utExit("Unknown graph type");
    }
    return NULL; // Dummy return
}
/* ****************************************************************************
*
* ok - 
*/
TEST(badRequest, ok)
{
  ConnectionInfo ci("/xxx/badbadbad",  "GET", "1.1");
  std::string    out;
  const char*    outfile = "orion.badRequest.valid.xml";

  utInit();

  out = restService(&ci, rs);
  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), outfile)) << "Error getting test data from '" << outfile << "'";
  EXPECT_STREQ(expectedBuf, out.c_str());

  utExit();
}
/* ****************************************************************************
*
* jsonRender -
*
* subscriptionId: MANDATORY
* duration:       Optional
* errorCode:      Optional
*/
TEST(SubscribeContextAvailabilityResponse, jsonRender)
{
  const char*                            filename1  = "ngsi9.subscribeContextAvailabilityResponse.jsonRender1.valid.json";
  const char*                            filename2  = "ngsi9.subscribeContextAvailabilityResponse.jsonRender2.valid.json";
  const char*                            filename3  = "ngsi9.subscribeContextAvailabilityResponse.jsonRender3.valid.json";
  const char*                            filename4  = "ngsi9.subscribeContextAvailabilityResponse.jsonRender4.valid.json";
  SubscribeContextAvailabilityResponse*  scarP;
  std::string                            rendered;
  utInit();

  // Preparations
  scarP = new SubscribeContextAvailabilityResponse();

  // 1. +subscriptionId -duration -errorCode
  scarP->subscriptionId.set("012345678901234567890123");

  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), filename1)) << "Error getting test data from '" << filename1 << "'";
  rendered = scarP->toJsonV1();
  EXPECT_STREQ(expectedBuf, rendered.c_str());


  // 2. +subscriptionId -duration +errorCode
  scarP->errorCode.fill(SccBadRequest);

  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), filename2)) << "Error getting test data from '" << filename2 << "'";
  rendered = scarP->toJsonV1();
  EXPECT_STREQ(expectedBuf, rendered.c_str());


  // 3. +subscriptionId +duration -errorCode
  scarP->errorCode.fill(SccNone);
  scarP->duration.set("PT1H");

  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), filename3)) << "Error getting test data from '" << filename3 << "'";
  rendered = scarP->toJsonV1();
  EXPECT_STREQ(expectedBuf, rendered.c_str());


  // 4. +subscriptionId +duration +errorCode
  scarP->errorCode.fill(SccBadRequest, "no details");

  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), filename4)) << "Error getting test data from '" << filename4 << "'";
  rendered = scarP->toJsonV1();
  EXPECT_STREQ(expectedBuf, rendered.c_str());


  free(scarP);

  utExit();
}
/* ****************************************************************************
*
* getCurrentTime - 
*/
TEST(commonGlobals, getCurrentTime)
{
  int now;

  // 1. No timer
  setTimer(NULL);
  now = getCurrentTime();
  EXPECT_EQ(-1, now);

  utInit();  // timer is set up inside utInit
  now = getCurrentTime();
  EXPECT_TRUE(now != -1);
  utExit();
}
/* ****************************************************************************
*
* badPathNgsi10 - 
*/
TEST(Convenience, badPathNgsi10)
{
  ConnectionInfo            ci("ngsi10/badpathcomponent", "GET", "1.1");
  std::string               out;
  const char*               outfile = "ngsi10.convenience.badPathNgsi10.postponed.xml";

  utInit();

  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), outfile)) << "Error getting test data from '" << outfile << "'";
  out = restService(&ci, restServiceV);
  EXPECT_STREQ(expectedBuf, out.c_str());

  utExit();
}
/* ****************************************************************************
*
* present - just exercise the code
*/
TEST(ContextAttributeResponse, present)
{
  ContextAttribute          ca("caName", "caType", "caValue");
  ContextAttributeResponse  car;

  utInit();

  car.contextAttributeVector.push_back(&ca);
  car.statusCode.fill(SccOk);

  car.present("");

  utExit();
}
/* ****************************************************************************
*
* release - just exercise the code
*/
TEST(ContextAttributeResponse, release)
{
  ContextAttribute*         caP = new ContextAttribute("caName", "caType", "caValue");
  ContextAttributeResponse  car;

  utInit();

  car.contextAttributeVector.push_back(caP);
  car.statusCode.fill(SccOk);

  car.release();

  utExit();
}
/* ****************************************************************************
*
* present - no output expected, just exercising the code
*/
TEST(SubscriptionId, present)
{
  SubscriptionId  sId;

  utInit();

  sId.set("SUB_123");
  sId.present("");

  sId.set("");
  sId.present("");

  utExit();
}