/* ****************************************************************************
*
* json_ok -
*/
TEST(NotifyContextRequest, json_ok)
{
  ParseData              reqData;
  ConnectionInfo         ci("", "POST", "1.1");
  NotifyContextRequest*  ncrP      = &reqData.ncr.res;
  const char*            infile    = "notifyContextRequest_ok.json";
  const char*            outfile   = "ngsi10.notifyContextRequest_ok.expected1.valid.json";
  std::string            rendered;

  utInit();

  ci.outMimeType = JSON;

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

  ci.inMimeType  = JSON;
  ci.outMimeType = JSON;

  lmTraceLevelSet(LmtDump, true);
  std::string result = jsonTreat(testBuf, &ci, &reqData, NotifyContext, NULL);
  EXPECT_EQ("OK", result);
  lmTraceLevelSet(LmtDump, false);

  //
  // With the data obtained, render, present and release methods are exercised
  //
  std::vector<std::string> emptyV;
  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), outfile)) << "Error getting test data from '" << outfile << "'";
  rendered = ncrP->toJsonV1(false, emptyV, false, emptyV);
  EXPECT_STREQ(expectedBuf, rendered.c_str());

  ncrP->release();

  utExit();
}
/* ****************************************************************************
*
* ok_json - 
*/
TEST(UpdateContextRequest, ok_json)
{
   ParseData       reqData;
   ConnectionInfo  ci("", "POST", "1.1");
   const char*     infile = "ngsi10.updateContext.ok.valid.json";

   utInit();

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

   ci.inFormat  = JSON;
   ci.outFormat = JSON;

   lmTraceLevelSet(LmtDump, true);
   std::string result = jsonTreat(testBuf, &ci, &reqData, UpdateContext, "updateContextRequest", NULL);
   lmTraceLevelSet(LmtDump, false);

   EXPECT_EQ("OK", result);

   //
   // With the data obtained, render, present and release methods are exercised
   //
   UpdateContextRequest*  upcrP = &reqData.upcr.res;

   upcrP->present(""); // No output
   upcrP->release();

   utExit();
}
/* ****************************************************************************
*
* ok_json - 
*/
TEST(NotifyContextAvailabilityRequest, ok_json)
{
  ParseData       parseData;
  const char*     fileName = "ngsi9.notifyContextAvailabilityRequest.ok2.valid.json";
  ConnectionInfo  ci("", "POST", "1.1");
  std::string     out;

  utInit();

  ci.inFormat  = JSON;
  ci.outFormat = JSON;

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

  lmTraceLevelSet(LmtDump, true);
  out = jsonTreat(testBuf, &ci, &parseData, NotifyContextAvailability, "notifyContextAvailabilityRequest", NULL);
  EXPECT_EQ("OK", out);
  lmTraceLevelSet(LmtDump, false);

  NotifyContextAvailabilityRequest* ncarP = &parseData.ncar.res;

  const char*     outfile = "ngsi9.notifyContextAvailabilityRequest.ok.valid.json";

  out = ncarP->render(NotifyContext, JSON, "");
  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), outfile)) << "Error getting test data from '" << outfile << "'";
  EXPECT_STREQ(expectedBuf, out.c_str());

  ncarP->release();
  
  utExit();
}
/* ****************************************************************************
*
* ok_xml - 
*/
TEST(NotifyContextAvailabilityRequest, ok_xml)
{
  ParseData       parseData;
  const char*     inFile  = "ngsi9.notifyContextAvailabilityRequest.ok.valid.xml";
  const char*     outFile = "ngsi9.notifyContextAvailabilityRequestRendered.ok.valid.xml";
  ConnectionInfo  ci("", "POST", "1.1");
  std::string     rendered;

  utInit();

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

  lmTraceLevelSet(LmtDump, true);
  std::string result = xmlTreat(testBuf, &ci, &parseData, NotifyContextAvailability, "notifyContextAvailabilityRequest", NULL);
  EXPECT_EQ("OK", result);
  lmTraceLevelSet(LmtDump, false);

  NotifyContextAvailabilityRequest* ncarP = &parseData.ncar.res;

  rendered = ncarP->render(NotifyContext, XML, "");
  EXPECT_STREQ(expectedBuf, rendered.c_str());

  ncarP->release();
  
  utExit();
}
/* ****************************************************************************
*
* badSubscriptionId_json - 
*/
TEST(UnsubscribeContextAvailabilityRequest, badSubscriptionId_json)
{
  ParseData       reqData;
  ConnectionInfo  ci("", "POST", "1.1");
  const char*     infile  = "ngsi9.unsubscribeContextAvailabilityRequest.badSubscriptionId.invalid.json";
  const char*     outfile = "ngsi9.unsubscribeContextAvailabilityResponse.badSubscriptionId.valid.json";

  utInit();

  EXPECT_EQ("OK", testDataFromFile(testBuf, sizeof(testBuf), infile)) << "Error getting test data from '" << infile << "'";
  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), outfile)) << "Error getting test data from '" << outfile << "'";
  
  ci.inFormat  = JSON;
  ci.outFormat = JSON;
  lmTraceLevelSet(LmtDump, true);
  std::string out = jsonTreat(testBuf, &ci, &reqData, UnsubscribeContextAvailability, "unsubscribeContextAvailabilityRequest", NULL);
  EXPECT_STREQ(expectedBuf, out.c_str());

  lmTraceLevelSet(LmtDump, false);

  UnsubscribeContextAvailabilityRequest*  ucarP = &reqData.ucar.res;

  ucarP->release();

  utExit();
}
/* ****************************************************************************
*
* ok_xml - 
*/
TEST(QueryContextRequest, ok_xml)
{
  ParseData       reqData;
  ConnectionInfo  ci("", "POST", "1.1");
  const char*     infile = "ngsi10.queryContextRequest.ok.valid.xml";

  utInit();

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

  lmTraceLevelSet(LmtDump, true);
  std::string out = xmlTreat(testBuf, &ci, &reqData, QueryContext, "queryContextRequest", NULL);
  lmTraceLevelSet(LmtDump, false);

  EXPECT_EQ("OK", out) << "this test should be OK";

  //
  // With the data obtained, render, present and release methods are exercised
  //
  QueryContextRequest*  qcrP = &reqData.qcr.res;
  const char*  outfile = "ngsi10.queryContextRequest.ok2.valid.xml";
  
  qcrP->present(""); // No output

  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), outfile)) << "Error getting test data from '" << outfile << "'";
  out = qcrP->render(QueryContext, XML, "");
  EXPECT_STREQ(expectedBuf, out.c_str());

  qcrP->release();

  utExit();
}
/* ****************************************************************************
*
* ok_json - 
*/
TEST(SubscribeContextRequest, ok_json)
{
  ParseData       parseData;
  ConnectionInfo  ci("", "POST", "1.1");
  const char*     infile = "ngsi10.subscribeContextRequest.ok.valid.json";

  utInit();

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

  ci.inFormat  = JSON;
  ci.outFormat = JSON;

  lmTraceLevelSet(LmtDump, true);
  std::string result = jsonTreat(testBuf, &ci, &parseData, SubscribeContext, "subscribeContextRequest", NULL);
  EXPECT_EQ("OK", result);
  lmTraceLevelSet(LmtDump, false);


  //
  // With the data obtained, render, present and release methods are exercised
  //
  SubscribeContextRequest*  scrP    = &parseData.scr.res;
  const char*               outfile = "ngsi10.subscribeContextRequest_ok.expected.valid.json";
  
  scrP->present(""); // No output

  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), outfile)) << "Error getting test data from '" << outfile << "'";
  std::string out = scrP->render(SubscribeContext, JSON, "");
  EXPECT_STREQ(expectedBuf, out.c_str());

  scrP->release();

  utExit();
}
/* ****************************************************************************
*
* xml_ok - 
*/
TEST(NotifyContextRequest, xml_ok)
{
  ParseData              reqData;
  ConnectionInfo         ci("", "POST", "1.1");
  std::string            rendered;
  const char*            infile   = "ngsi10.notifyContextRequest.ok.valid.xml";
  const char*            outfile  = "ngsi10.notifyContextResponse.ok.valid.xml";
  NotifyContextRequest*  ncrP     = &reqData.ncr.res;

  utInit();
  
  ci.outFormat = XML;

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

  lmTraceLevelSet(LmtDump, true);
  std::string result = xmlTreat(testBuf, &ci, &reqData, NotifyContext, "notifyContextRequest", NULL);
  EXPECT_EQ("OK", result);
  lmTraceLevelSet(LmtDump, false);

  ncrP->present("");

  rendered = ncrP->render(&ci, NotifyContext, "");
  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), outfile)) << "Error getting test data from '" << outfile << "'";
  EXPECT_STREQ(expectedBuf, rendered.c_str());

  ncrP->present("");
  ncrP->release();

  utExit();
}
/* ****************************************************************************
*
* present - 
*/
TEST(RegisterContextRequest, present)
{
  ParseData       parseData;
  const char*     inFile = "ngsi9.registerContextRequest.ok.valid.xml";
  ConnectionInfo  ci("", "POST", "1.1");

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

  lmTraceLevelSet(LmtDump, true);
  std::string result = xmlTreat(testBuf, &ci, &parseData, RegisterContext, "registerContextRequest", NULL);
  EXPECT_EQ("OK", result) << "this test should be OK";
  lmTraceLevelSet(LmtDump, false);
}
/* ****************************************************************************
*
* ok_xml - 
*/
TEST(DiscoverContextAvailabilityRequest, ok_xml)
{
  ParseData       reqData;
  const char*     inFile = "ngsi9.discoverContextAvailabilityRequest.ok.valid.xml";
  ConnectionInfo  ci("", "POST", "1.1");

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

  lmTraceLevelSet(LmtDump, true);
  std::string result = xmlTreat(testBuf, &ci, &reqData, DiscoverContextAvailability, "discoverContextAvailabilityRequest", NULL);
  EXPECT_EQ("OK", result) << "this test should be OK";
  lmTraceLevelSet(LmtDump, false);
}
/* ****************************************************************************
*
* vectorInvalidAndOk -
*/
TEST(CompoundValueNode, vectorInvalidAndOk)
{
  lmTraceLevelSet(LmtCompoundValueAdd, true);

  orion::CompoundValueNode*  tree     = new orion::CompoundValueNode(orion::ValueTypeObject);
  orion::CompoundValueNode*  vec      = new orion::CompoundValueNode(tree, "/vec", "vec", "", 0, orion::ValueTypeVector, 1);
  orion::CompoundValueNode*  item1    = new orion::CompoundValueNode(vec, std::string("/vec/vecitem1"), "vecitem1",  "a", 0, orion::ValueTypeString, 2);
  const char*                outFile1 = "ngsi.compoundValue.vector.valid.xml";
  const char*                outFile2 = "ngsi.compoundValue.vector.invalid.json";

  utInit();

  ConnectionInfo ci;

  ci.apiVersion = "v1";

  tree->add(vec);
  vec->add(item1);
  vec->add(orion::ValueTypeString, "vecitem", "a");

  tree->finish();
  EXPECT_STREQ("bad tag-name of vector item: /vecitem/, should be /vecitem1/", tree->error.c_str());

  item1->name = "vecitem";
  tree->finish();
  EXPECT_STREQ("OK", tree->error.c_str());

  std::string rendered;

  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), outFile1)) << "Error getting test data from '" << outFile1 << "'";
  rendered = tree->render(&ci, XML, "");
  EXPECT_STREQ(expectedBuf, rendered.c_str());
  
  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), outFile2)) << "Error getting test data from '" << outFile2 << "'";
  rendered = tree->render(&ci, JSON, "");
  EXPECT_STREQ(expectedBuf, rendered.c_str());

  tree->shortShow("");
  tree->show("");

  lmTraceLevelSet(LmtCompoundValueAdd, false);

  delete tree;

  utExit();
}
/* ****************************************************************************
*
* xml_ok -
*/
TEST(UpdateContextAvailabilitySubscriptionRequest, xml_ok)
{
    ParseData       reqData;
    const char*     infile = "ngsi9.updateContextAvailabilitySubscriptionRequest.ok2.valid.xml";
    ConnectionInfo  ci("", "POST", "1.1");

    utInit();

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

    lmTraceLevelSet(LmtDump, true);
    std::string out = xmlTreat(testBuf, &ci, &reqData, UpdateContextAvailabilitySubscription, "updateContextAvailabilitySubscriptionRequest", NULL);
    lmTraceLevelSet(LmtDump, false);
    EXPECT_EQ("OK", out) << "this test should be OK";

    utExit();
}
/* ****************************************************************************
*
* ok_xml - 
*/
TEST(UpdateContextRequest, ok_xml)
{
  ParseData       reqData;
  ConnectionInfo  ci("", "POST", "1.1");
  const char*     infile = "ngsi10.updateContext.valid.xml";

  utInit();

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

  lmTraceLevelSet(LmtDump, true);
  std::string result = xmlTreat(testBuf, &ci, &reqData, UpdateContext, "updateContextRequest", NULL);
  lmTraceLevelSet(LmtDump, false);

  EXPECT_EQ("OK", result);

  //
  // With the data obtained, render, present and release methods are exercised
  //
  UpdateContextRequest*  upcrP = &reqData.upcr.res;
  
  upcrP->present(""); // No output

  std::string out;
  const char* outfile1 = "ngsi10.updateContextRequest.rendered1.valid.xml";
  const char* outfile2 = "ngsi10.updateContextRequest.checked.valid.xml";
  const char* outfile3 = "ngsi10.updateContextRequest.badUpdateActionType.invalid.xml";

  out = upcrP->render(&ci, UpdateContext, "");
  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), outfile1)) << "Error getting test data from '" << outfile1;
  EXPECT_STREQ(expectedBuf, out.c_str());

  out  = upcrP->check(&ci, UpdateContext, "", "FORCED ERROR", 0);
  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), outfile2)) << "Error getting test data from '" << outfile2;
  EXPECT_STREQ(expectedBuf, out.c_str());

  upcrP->updateActionType.set("invalid");
  out  = upcrP->check(&ci, RegisterContext, "", "", 0);
  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), outfile3)) << "Error getting test data from '" << outfile3;
  EXPECT_STREQ(expectedBuf, out.c_str());

  upcrP->release();

  utExit();
}
/* ****************************************************************************
*
* structInvalidAndOk -
*/
TEST(CompoundValueNode, structInvalidAndOk)
{
  lmTraceLevelSet(LmtCompoundValueAdd, true);

  orion::CompoundValueNode*  tree     = new orion::CompoundValueNode(orion::ValueTypeObject);
  orion::CompoundValueNode*  str      = new orion::CompoundValueNode(tree, "/struct", "struct", "", 0, orion::ValueTypeObject, 1);
  orion::CompoundValueNode*  item1    = new orion::CompoundValueNode(str, std::string("/struct/structitem"), "structitem", "a", 0, orion::ValueTypeString, 2);
  orion::CompoundValueNode*  item2    = new orion::CompoundValueNode(str, std::string("/struct/structitem"), "structitem", "a", 1, orion::ValueTypeString, 2);
  const char*                outFile1 = "ngsi.compoundValue.struct.valid.xml";
  const char*                outFile2 = "ngsi.compoundValue.struct.invalid.json";

  utInit();

  ConnectionInfo ci;
  ci.apiVersion = "v1";

  tree->add(str);
  str->add(item1);
  str->add(item2);

  tree->finish();
  EXPECT_STREQ("duplicated tag-name: /structitem/ in path: /struct", tree->error.c_str());

  item2->name = "structitem2";
  tree->finish();
  EXPECT_STREQ("OK", tree->error.c_str());

  std::string rendered;

  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), outFile1)) << "Error getting test data from '" << outFile1 << "'";
  rendered = tree->render(&ci, XML, "");
  EXPECT_STREQ(expectedBuf, rendered.c_str());
  
  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), outFile2)) << "Error getting test data from '" << outFile2 << "'";
  rendered = tree->render(&ci, JSON, "");
  EXPECT_STREQ(expectedBuf, rendered.c_str());

  tree->shortShow("");
  tree->show("");

  delete tree;

  lmTraceLevelSet(LmtCompoundValueAdd, false);
  utExit();
}
/* ****************************************************************************
*
* noRestriction_xml - 
*/
TEST(QueryContextRequest, noRestriction_xml)
{
  ParseData       reqData;
  ConnectionInfo  ci("", "POST", "1.1");
  const char*     infile = "ngsi10.queryContextRequest.noRestriction.valid.xml";

  utInit();

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

  lmTraceLevelSet(LmtDump, true);
  std::string out = xmlTreat(testBuf, &ci, &reqData, QueryContext, "queryContextRequest", NULL);
  lmTraceLevelSet(LmtDump, false);

  EXPECT_EQ("OK", out);

  utExit();
}
/* ****************************************************************************
*
* xml_invalidEntityAttribute -
*/
TEST(UpdateContextAvailabilitySubscriptionRequest, xml_invalidEntityAttribute)
{
    ParseData       reqData;
    const char*     infile  = "ngsi9.updateContextAvailabilitySubscriptionRequest.entityIdAttribute.invalid.xml";
    const char*     outfile = "ngsi9.updateContextAvailabilitySubscriptionResponse.entityIdAttribute.valid.xml";
    ConnectionInfo  ci("", "POST", "1.1");

    utInit();

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

    lmTraceLevelSet(LmtDump, true);
    std::string out = xmlTreat(testBuf, &ci, &reqData, UpdateContextAvailabilitySubscription, "updateContextAvailabilitySubscriptionRequest", NULL);
    lmTraceLevelSet(LmtDump, false);
    EXPECT_STREQ(expectedBuf, out.c_str());

    utExit();
}
/* ****************************************************************************
*
* json_ok - 
*/
TEST(SubscribeContextAvailabilityRequest, json_ok)
{
  ParseData       reqData;
  const char*     infile = "ngsi9.subscribeContextAvailabilityRequest.ok.valid.json";
  ConnectionInfo  ci("", "POST", "1.1");

  utInit();

  ci.inFormat      = JSON;
  ci.outFormat     = JSON;

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

  lmTraceLevelSet(LmtDump, true);
  std::string result = jsonTreat(testBuf, &ci, &reqData, SubscribeContextAvailability, "subscribeContextAvailabilityRequest", NULL);
  lmTraceLevelSet(LmtDump, false);
  EXPECT_EQ("OK", result) << "this test should be OK";

  utExit();
}
/* ****************************************************************************
*
* json_ok -
*/
TEST(UpdateContextAvailabilitySubscriptionRequest, json_ok)
{
  ConnectionInfo  ci("", "POST", "1.1");
  ParseData       parseData;
  const char*     infile    = "ngsi9.updateContextAvailabilitySubscriptionRequest.ok.valid.json";
  const char*     outfile1  = "ngsi9.updateContextAvailabilitySubscriptionRequest.expected1.valid.json";
  const char*     outfile2  = "ngsi9.updateContextAvailabilitySubscriptionRequest.expected2.valid.json";
  const char*     outfile3  = "ngsi9.updateContextAvailabilitySubscriptionRequest.expected3.valid.json";
  std::string     out;

  utInit();

  ci.inMimeType      = JSON;
  ci.outMimeType     = JSON;

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

  lmTraceLevelSet(LmtDump, true);
  out = jsonTreat(testBuf, &ci, &parseData, UpdateContextAvailabilitySubscription, NULL);
  lmTraceLevelSet(LmtDump, false);
  EXPECT_EQ("OK", out) << "this test should be OK";

  UpdateContextAvailabilitySubscriptionRequest* ucasP = &parseData.ucas.res;

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

  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), outfile2)) << "Error getting test data from '" << outfile2 << "'";
  out = ucasP->check("predetected error", 0);
  EXPECT_STREQ(expectedBuf, out.c_str());

  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), outfile3)) << "Error getting test data from '" << outfile3 << "'";
  ucasP->duration.set("eeeee");
  out = ucasP->check("", 0);
  EXPECT_STREQ(expectedBuf, out.c_str());

  utExit();
}
/* ****************************************************************************
*
* invalidDuration_xml - 
*/
TEST(SubscribeContextRequest, invalidDuration_xml)
{
  ParseData       parseData;
  ConnectionInfo  ci("", "POST", "1.1");
  const char*     infile  = "ngsi10.subscribeContextRequest.duration.invalid.xml";
  const char*     outfile = "ngsi10.subscribeContextResponse.invalidDuration.valid.xml";
  XmlRequest*     reqP;

  utInit();

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

  lmTraceLevelSet(LmtDump, true);
  std::string out = xmlTreat(testBuf, &ci, &parseData, SubscribeContext, "subscribeContextRequest", &reqP);
  lmTraceLevelSet(LmtDump, false);

  reqP->release(&parseData);
  EXPECT_STREQ(expectedBuf, out.c_str());

  utExit();
}
/* ****************************************************************************
*
* tree - 
*/
TEST(CompoundValueNode, tree)
{
  orion::CompoundValueNode*  tree  = new orion::CompoundValueNode(orion::ValueTypeObject);
  orion::CompoundValueNode*  vec;
  orion::CompoundValueNode*  vecItem;
  char*                      name  = (char*) "vecItem";

  utInit();

  lmTraceLevelSet(LmtCompoundValueAdd, true);
  vec = tree->add(orion::ValueTypeVector, "vec", "");

  for (int ix = 0; ix < 5; ++ix)
  {
    vecItem = new orion::CompoundValueNode(vec, std::string("/vec/") + name, name, "a", ix, orion::ValueTypeString, 2);
    vec->add(vecItem);
  }

  vecItem = vec->add(orion::ValueTypeString, "vecItem6", "6");

  ASSERT_EQ(1, tree->childV.size());
  ASSERT_EQ(6, vec->childV.size());

  orion::CompoundValueNode* copy = tree->clone();

  ASSERT_EQ(1, copy->childV.size());
  ASSERT_EQ(6, copy->childV[0]->childV.size());
  ASSERT_STREQ("vecItem", copy->childV[0]->childV[0]->name.c_str());
  ASSERT_EQ(3, copy->childV[0]->childV[3]->siblingNo);
  ASSERT_EQ(2, copy->childV[0]->childV[3]->level);

  delete tree;
  delete copy;

  lmTraceLevelSet(LmtCompoundValueAdd, false);
  utExit();
}