Exemple #1
0
int /* [rcd] Successful conversion returns NCO_NOERR */
nco_cln_clc_dff /* [fnc] UDUnits1 Difference between two co-ordinate units */
(const char *fl_unt_sng, /* I [ptr] units attribute string from disk  */     
 const char *fl_bs_sng, /* I [ptr] units attribute string from disk  */     
 double crr_val,
 double *og_val) /* O [ptr] */
{
  const char fnc_nm[]="nco_cln_clc_dff()"; /* [sng] Function name */
    
  double slp;
  double incpt;

  int rcd;

  utUnit udu_sct_in; /* UDUnits structure, input units */
  utUnit udu_sct_out; /* UDUnits structure, output units */

  /* Quick return if units identical */
  if(!strcmp(fl_unt_sng,fl_bs_sng) ){
    *og_val=crr_val;  
    return NCO_NOERR;
  } /* endif */

#ifdef UDUNITS_PATH
  /* UDUNITS_PATH macro expands to where autoconf found database file */
  rcd=utInit(UDUNITS_PATH);
#else /* !UDUNITS_PATH */
  /* When empty, utInit() uses environment variable UDUNITS_PATH, if any
     Otherwise it uses default initial location hardcoded when library was built */
  rcd=utInit("");
#endif /* !UDUNITS_PATH */

  if(rcd != UDUNITS_NOERR){
    (void)fprintf(stdout,"%s: %s failed to initialize UDUnits2 library\n",nco_prg_nm_get(),fnc_nm);
    return NCO_ERR;
  } /* end if err */ 

  /* units string to convert from */
  rcd=utScan(fl_unt_sng,&udu_sct_in); 
  if(rcd != UDUNITS_NOERR){
    if(rcd == UT_EINVALID) (void)fprintf(stderr,"ERROR: units attribute \"%s\" is invalid \n",fl_unt_sng);
    if(rcd == UT_ESYNTAX) (void)fprintf(stderr,"ERROR units attribute \"%s\" contains a syntax error",fl_unt_sng);
    if(rcd == UT_EUNKNOWN) (void)fprintf(stderr,"ERROR units attribute \"%s\" is not in udunits database",fl_unt_sng);
    (void)utTerm(); /* Free memory taken by UDUnits library */
    return NCO_ERR;
  } /* endif unkown type */

  /* units string to convert to */
  rcd=utScan(fl_bs_sng,&udu_sct_out); 
  if(rcd != UDUNITS_NOERR){
    if(rcd == UT_EINVALID) (void)fprintf(stderr,"ERROR: units attribute \"%s\" is invalid \n",fl_bs_sng);
    if(rcd == UT_ESYNTAX) (void)fprintf(stderr,"ERROR units attribute \"%s\" contains a syntax error",fl_bs_sng);
    if(rcd == UT_EUNKNOWN) (void)fprintf(stderr,"ERROR units attribute \"%s\" is not in udunits database",fl_bs_sng);
    (void)utTerm(); /* Free memory taken by UDUnits library */
    return NCO_ERR;
  } /* endif unkown type */

  rcd=utConvert(&udu_sct_in,&udu_sct_out,&slp,&incpt);
  if(rcd == UT_ECONVERT){
    (void)fprintf(stderr,"ERROR: user specified unit \"%s\" cannot be converted to units \"%s\"\n",fl_unt_sng,fl_bs_sng);
    (void)utTerm();
    return NCO_ERR;
  } /* endif */

  *og_val=crr_val*slp+incpt;

  /* debug stuff */
  if(nco_dbg_lvl_get() > nco_dbg_std) (void)fprintf(stderr,"%s: %s reports difference between systems \"%s\" and \"%s\" is %f\n",nco_prg_nm_get(),fnc_nm,fl_unt_sng,fl_bs_sng,*og_val);

  (void)utTerm();

  return NCO_NOERR;   
}  /* end UDUnits1 nco_cln_clc_dff() */
/* ****************************************************************************
*
* jsonRender - 
*
* NOTE
*   - providingApplication is MANDATORY inside ContextRegistration
*/
TEST(DiscoverContextAvailabilityResponse, jsonRender)
{
  const char*                           filename1  = "ngsi9.discoverContextAvailabilityResponse.jsonRender1.valid.json";
  const char*                           filename2  = "ngsi9.discoverContextAvailabilityResponse.jsonRender2.valid.json";
  const char*                           filename3  = "ngsi9.discoverContextAvailabilityResponse.jsonRender3.valid.json";
  const char*                           filename4  = "ngsi9.discoverContextAvailabilityResponse.jsonRender4.valid.json";
  const char*                           filename5  = "ngsi9.discoverContextAvailabilityResponse.jsonRender5.valid.json";
  const char*                           filename6  = "ngsi9.discoverContextAvailabilityResponse.jsonRender6.valid.json";
  const char*                           filename7  = "ngsi9.discoverContextAvailabilityResponse.jsonRender7.valid.json";
  const char*                           filename8  = "ngsi9.discoverContextAvailabilityResponse.jsonRender8.valid.json";
  const char*                           filename9  = "ngsi9.discoverContextAvailabilityResponse.jsonRender9.valid.json";
  const char*                           filename10 = "ngsi9.discoverContextAvailabilityResponse.jsonRender10.valid.json";
  const char*                           filename11 = "ngsi9.discoverContextAvailabilityResponse.jsonRender11.valid.json";
  const char*                           filename12 = "ngsi9.discoverContextAvailabilityResponse.jsonRender12.valid.json";
  const char*                           filename13 = "ngsi9.discoverContextAvailabilityResponse.jsonRender13.valid.json";
  const char*                           filename14 = "ngsi9.discoverContextAvailabilityResponse.jsonRender14.valid.json";
  const char*                           filename15 = "ngsi9.discoverContextAvailabilityResponse.jsonRender15.valid.json";
  const char*                           filename16 = "ngsi9.discoverContextAvailabilityResponse.jsonRender16.valid.json";
  const char*                           filename17 = "ngsi9.discoverContextAvailabilityResponse.jsonRender17.valid.json";
  const char*                           filename18 = "ngsi9.discoverContextAvailabilityResponse.jsonRender18.valid.json";
  const char*                           filename19 = "ngsi9.discoverContextAvailabilityResponse.jsonRender19.valid.json";
  const char*                           filename20 = "ngsi9.discoverContextAvailabilityResponse.jsonRender20.valid.json";
  std::string                           rendered;
  DiscoverContextAvailabilityResponse*  dcarP      = new DiscoverContextAvailabilityResponse();
  ContextRegistrationResponse*          crrP;
  EntityId*                             eidP;
  ContextRegistrationAttribute*         attrP;
  Metadata*                             mdP;
  
  utInit();

  // 1. One contextRegistrationResponse - no errorCode inside ContextRegistrationResponse
  crrP = new ContextRegistrationResponse();
  eidP = new EntityId("E01", "EType", "false");

  crrP->contextRegistration.entityIdVector.push_back(eidP);
  crrP->contextRegistration.providingApplication.set("http://tid.test.com/unitTest");
  dcarP->responseVector.push_back(crrP);

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

  dcarP->release();
  rendered = dcarP->render(DiscoverContextAvailability, JSON, "");
  EXPECT_STREQ(EMPTY_JSON, rendered.c_str());
  free(dcarP);


  // 2. One contextRegistrationResponse - errorCode inside ContextRegistrationResponse - only providingApplication in ContextRegistration
  dcarP = new DiscoverContextAvailabilityResponse();
  crrP  = new ContextRegistrationResponse();

  crrP->contextRegistration.providingApplication.set("http://tid.test.com/unitTest2");
  crrP->errorCode.fill(SccBadRequest, "errorCode inside ContextRegistrationResponse");
  dcarP->responseVector.push_back(crrP);

  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), filename2)) << "Error getting test data from '" << filename2 << "'";
  rendered = dcarP->render(DiscoverContextAvailability, JSON, "");
  EXPECT_STREQ(expectedBuf, rendered.c_str());
  // No release here - the data stays - to be used in the following test scenario


  
  // 3. Two contextRegistrationResponses - one with errorCode and one without errorCode
  //    We're reusing the ContextRegistrationResponse from test 2 (it has StatusCode set
  crrP  = new ContextRegistrationResponse();
  crrP->contextRegistration.providingApplication.set("http://tid.test.com/unitTest3");

  dcarP->responseVector.push_back(crrP);

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

  dcarP->release();
  rendered = dcarP->render(DiscoverContextAvailability, JSON, "");
  EXPECT_STREQ(EMPTY_JSON, rendered.c_str());



  // 4.  ContextRegistration: One entityId inside entityIdVector
  crrP  = new ContextRegistrationResponse();
  eidP  = new EntityId("E04", "EType", "false");

  crrP->contextRegistration.entityIdVector.push_back(eidP);
  crrP->contextRegistration.providingApplication.set("http://tid.test.com/unitTest4");
  dcarP->responseVector.push_back(crrP);
  
  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), filename4)) << "Error getting test data from '" << filename4 << "'";
  rendered = dcarP->render(DiscoverContextAvailability, JSON, "");
  EXPECT_STREQ(expectedBuf, rendered.c_str());
  // No release here - the data stays - to be used in the following test scenario
  

  // 5.  ContextRegistration: Two entityIds inside entityIdVector
  eidP  = new EntityId("E05", "EType", "false");

  crrP->contextRegistration.entityIdVector.push_back(eidP);
  crrP->contextRegistration.providingApplication.set("http://tid.test.com/unitTest5");

  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), filename5)) << "Error getting test data from '" << filename5 << "'";
  rendered = dcarP->render(DiscoverContextAvailability, JSON, "");
  EXPECT_STREQ(expectedBuf, rendered.c_str());

  dcarP->release();
  rendered = dcarP->render(DiscoverContextAvailability, JSON, "");
  EXPECT_STREQ(EMPTY_JSON, rendered.c_str());



  // 6.  ContextRegistration: one attribute in contextRegistrationAttributeVector
  crrP  = new ContextRegistrationResponse();
  attrP = new ContextRegistrationAttribute("Attr1", "AType", "false");

  crrP->contextRegistration.contextRegistrationAttributeVector.push_back(attrP);
  crrP->contextRegistration.providingApplication.set("http://tid.test.com/unitTest6");
  dcarP->responseVector.push_back(crrP);
  
  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), filename6)) << "Error getting test data from '" << filename6 << "'";
  rendered = dcarP->render(DiscoverContextAvailability, JSON, "");
  EXPECT_STREQ(expectedBuf, rendered.c_str());
  // No release here - the data stays - to be used in the following test scenario



  // 7.  ContextRegistration: two attributes in contextRegistrationAttributeVector
  attrP = new ContextRegistrationAttribute("Attr2", "AType", "true");

  crrP->contextRegistration.contextRegistrationAttributeVector.push_back(attrP);
  crrP->contextRegistration.providingApplication.set("http://tid.test.com/unitTest7");

  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), filename7)) << "Error getting test data from '" << filename7 << "'";
  rendered = dcarP->render(DiscoverContextAvailability, JSON, "");
  EXPECT_STREQ(expectedBuf, rendered.c_str());

  dcarP->release();
  rendered = dcarP->render(DiscoverContextAvailability, JSON, "");
  EXPECT_STREQ(EMPTY_JSON, rendered.c_str());



  // 8.  ContextRegistration: one metadata in registrationMetadataVector
  crrP  = new ContextRegistrationResponse();
  mdP = new Metadata("M1", "string", "test 8");
  
  crrP->contextRegistration.registrationMetadataVector.push_back(mdP);
  crrP->contextRegistration.providingApplication.set("http://tid.test.com/unitTest8");
  dcarP->responseVector.push_back(crrP);

  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), filename8)) << "Error getting test data from '" << filename8 << "'";
  rendered = dcarP->render(DiscoverContextAvailability, JSON, "");
  EXPECT_STREQ(expectedBuf, rendered.c_str());
  // No release here - the data stays - to be used in the following test scenario



  // 9.  ContextRegistration: two metadatas in registrationMetadataVector
  mdP = new Metadata("M2", "string", "test 9");

  crrP->contextRegistration.registrationMetadataVector.push_back(mdP);
  crrP->contextRegistration.providingApplication.set("http://tid.test.com/unitTest9");

  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), filename9)) << "Error getting test data from '" << filename9 << "'";
  rendered = dcarP->render(DiscoverContextAvailability, JSON, "");
  EXPECT_STREQ(expectedBuf, rendered.c_str());

  dcarP->release();
  rendered = dcarP->render(DiscoverContextAvailability, JSON, "");
  EXPECT_STREQ(EMPTY_JSON, rendered.c_str());



  // 10. !entityIdVector !contextRegistrationAttributeVector !registrationMetadataVector +providingApplication
  crrP = new ContextRegistrationResponse();

  crrP->contextRegistration.providingApplication.set("http://tid.test.com/unitTest10");
  dcarP->responseVector.push_back(crrP);

  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), filename10)) << "Error getting test data from '" << filename10 << "'";
  rendered = dcarP->render(DiscoverContextAvailability, JSON, "");
  EXPECT_STREQ(expectedBuf, rendered.c_str());
  // No release here - the data stays - to be used in the following test scenario



  // 11. !entityIdVector !contextRegistrationAttributeVector +registrationMetadataVector +providingApplication
  mdP = new Metadata("M11", "string", "test 11");

  crrP->contextRegistration.registrationMetadataVector.push_back(mdP);
  crrP->contextRegistration.providingApplication.set("http://tid.test.com/unitTest11");

  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), filename11)) << "Error getting test data from '" << filename11 << "'";
  rendered = dcarP->render(DiscoverContextAvailability, JSON, "");
  EXPECT_STREQ(expectedBuf, rendered.c_str());

  dcarP->release();
  rendered = dcarP->render(DiscoverContextAvailability, JSON, "");
  EXPECT_STREQ(EMPTY_JSON, rendered.c_str());



  // 12. !entityIdVector +contextRegistrationAttributeVector !registrationMetadataVector +providingApplication
  crrP  = new ContextRegistrationResponse();
  attrP = new ContextRegistrationAttribute("Attr12", "AType", "true");

  crrP->contextRegistration.contextRegistrationAttributeVector.push_back(attrP);
  crrP->contextRegistration.providingApplication.set("http://tid.test.com/unitTest12");
  dcarP->responseVector.push_back(crrP);

  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), filename12)) << "Error getting test data from '" << filename12 << "'";
  rendered = dcarP->render(DiscoverContextAvailability, JSON, "");
  EXPECT_STREQ(expectedBuf, rendered.c_str());
  // No release here - the data stays - to be used in the following test scenario



  // 13. !entityIdVector +contextRegistrationAttributeVector +registrationMetadataVector +providingApplication
  mdP = new Metadata("M13", "string", "test 13");

  crrP->contextRegistration.registrationMetadataVector.push_back(mdP);

  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), filename13)) << "Error getting test data from '" << filename13 << "'";
  rendered = dcarP->render(DiscoverContextAvailability, JSON, "");
  EXPECT_STREQ(expectedBuf, rendered.c_str());

  dcarP->release();
  rendered = dcarP->render(DiscoverContextAvailability, JSON, "");
  EXPECT_STREQ(EMPTY_JSON, rendered.c_str());



  // 14. +entityIdVector !contextRegistrationAttributeVector !registrationMetadataVector +providingApplication
  crrP  = new ContextRegistrationResponse();
  eidP  = new EntityId("E14", "EType", "false");

  crrP->contextRegistration.entityIdVector.push_back(eidP);
  crrP->contextRegistration.providingApplication.set("http://tid.test.com/unitTest14");
  dcarP->responseVector.push_back(crrP);

  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), filename14)) << "Error getting test data from '" << filename14 << "'";
  rendered = dcarP->render(DiscoverContextAvailability, JSON, "");
  EXPECT_STREQ(expectedBuf, rendered.c_str());
  // No release here - the data stays - to be used in the following test scenario



  // 15. +entityIdVector !contextRegistrationAttributeVector +registrationMetadataVector +providingApplication
  mdP = new Metadata("M15", "string", "test 15");

  crrP->contextRegistration.registrationMetadataVector.push_back(mdP);
  crrP->contextRegistration.providingApplication.set("http://tid.test.com/unitTest15");

  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), filename15)) << "Error getting test data from '" << filename15 << "'";
  rendered = dcarP->render(DiscoverContextAvailability, JSON, "");
  EXPECT_STREQ(expectedBuf, rendered.c_str());
  // No release here - the data stays - to be used in the following test scenario 17


  // 17. +entityIdVector +contextRegistrationAttributeVector +registrationMetadataVector +providingApplication
  attrP = new ContextRegistrationAttribute("Attr17", "AType", "true");

  crrP->contextRegistration.contextRegistrationAttributeVector.push_back(attrP);
  crrP->contextRegistration.providingApplication.set("http://tid.test.com/unitTest17");

  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), filename17)) << "Error getting test data from '" << filename17 << "'";
  rendered = dcarP->render(DiscoverContextAvailability, JSON, "");
  EXPECT_STREQ(expectedBuf, rendered.c_str());

  dcarP->release();
  rendered = dcarP->render(DiscoverContextAvailability, JSON, "");
  EXPECT_STREQ(EMPTY_JSON, rendered.c_str());



  // 16. +entityIdVector +contextRegistrationAttributeVector !registrationMetadataVector +providingApplication
  crrP  = new ContextRegistrationResponse();
  eidP  = new EntityId("E16", "EType", "false");
  attrP = new ContextRegistrationAttribute("Attr16", "AType", "true");

  crrP->contextRegistration.entityIdVector.push_back(eidP);
  crrP->contextRegistration.contextRegistrationAttributeVector.push_back(attrP);
  crrP->contextRegistration.providingApplication.set("http://tid.test.com/unitTest16");
  dcarP->responseVector.push_back(crrP);

  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), filename16)) << "Error getting test data from '" << filename16 << "'";
  rendered = dcarP->render(DiscoverContextAvailability, JSON, "");
  EXPECT_STREQ(expectedBuf, rendered.c_str());

  dcarP->release();
  rendered = dcarP->render(DiscoverContextAvailability, JSON, "");
  EXPECT_STREQ(EMPTY_JSON, rendered.c_str());



  // 18. StatusCode
  dcarP->errorCode.fill(SccBadRequest, "DiscoverContextAvailabilityResponse Unit Test 18");

  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), filename18)) << "Error getting test data from '" << filename18 << "'";
  rendered = dcarP->render(DiscoverContextAvailability, JSON, "");
  EXPECT_STREQ(expectedBuf, rendered.c_str());

  dcarP->release();
  rendered = dcarP->render(DiscoverContextAvailability, JSON, "");
  EXPECT_STREQ(EMPTY_JSON, rendered.c_str());



  // 19. StatusCode
  dcarP->errorCode.fill(SccBadRequest);

  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), filename19)) << "Error getting test data from '" << filename19 << "'";
  rendered = dcarP->render(DiscoverContextAvailability, JSON, "");
  EXPECT_STREQ(expectedBuf, rendered.c_str());

  dcarP->release();
  rendered = dcarP->render(DiscoverContextAvailability, JSON, "");
  EXPECT_STREQ(EMPTY_JSON, rendered.c_str());


  // 20. Two ContextRegistrationResponses
  crrP = new ContextRegistrationResponse();
  eidP = new EntityId("E01", "EType", "false");

  crrP->contextRegistration.entityIdVector.push_back(eidP);
  crrP->contextRegistration.providingApplication.set("http://tid.test.com/unitTest");
  dcarP->responseVector.push_back(crrP);

  crrP = new ContextRegistrationResponse();
  eidP = new EntityId("E02", "EType", "false");

  crrP->contextRegistration.entityIdVector.push_back(eidP);
  crrP->contextRegistration.providingApplication.set("http://tid.test.com/unitTest2");
  dcarP->responseVector.push_back(crrP);

  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), filename20)) << "Error getting test data from '" << filename20 << "'";
  rendered = dcarP->render(DiscoverContextAvailability, JSON, "");
  EXPECT_STREQ(expectedBuf, rendered.c_str());

  dcarP->release();
  rendered = dcarP->render(DiscoverContextAvailability, JSON, "");
  EXPECT_STREQ(EMPTY_JSON, rendered.c_str());

  free(dcarP);

  utExit();
}
/* ****************************************************************************
*
* put - 
*/
TEST(putAvailabilitySubscriptionConvOp, put)
{
  ConnectionInfo ci1("/ngsi9/contextAvailabilitySubscriptions",  "POST", "1.1");
  ConnectionInfo ci2("/ngsi9/contextAvailabilitySubscriptions",  "GET",  "1.1");
  ConnectionInfo ci3("/ngsi9/contextAvailabilitySubscriptions/111222333444555666777888",  "PUT",     "1.1");
  ConnectionInfo ci4("/ngsi9/contextAvailabilitySubscriptions/111222333444555666777888",  "DELETE",  "1.1");
  ConnectionInfo ci5("/ngsi9/contextAvailabilitySubscriptions/111222333444555666777881",  "PUT",     "1.1");
  ConnectionInfo ci6("/ngsi9/contextAvailabilitySubscriptions/012345678901234567890123",  "XVERB",   "1.1");
  const char*    infile1      = "ngsi9.subscribeContextAvailabilityRequest.ok.valid.xml";
  const char*    infile2      = "ngsi9.updateContextAvailabilitySubscriptionRequest.withSubId.valid.xml";
  const char*    outfile1     = "ngsi9.subscribeContextAvailabilityResponse.ok.middle.xml";
  const char*    outfile3     = "ngsi9.updateContextAvailabilitySubscriptionResponse.putAvailabilitySubscriptionConvOp.notFound.valid.xml";
  const char*    outfile4     = "ngsi9.unsubscribeContextAvailabilityResponse.putAvailabilitySubscriptionConvOp.notFound2.valid.xml";
  const char*    outfile5     = "ngsi9.updateContextAvailabilitySubscriptionResponse.putAvailabilitySubscriptionConvOp.unmatchingSubscriptionId.valid.xml";
  std::string    out;

  utInit();

  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 << "'";

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

  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());


  out = restService(&ci2, rs);
  EXPECT_EQ("", out);
  EXPECT_EQ("Allow", ci2.httpHeader[0]);
  EXPECT_EQ("POST",  ci2.httpHeaderValue[0]);


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

  ci3.payload      = testBuf;
  ci3.payloadSize  = strlen(testBuf);
  out              = restService(&ci3, rs);
  EXPECT_STREQ(expectedBuf, out.c_str());


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


  EXPECT_EQ("OK", testDataFromFile(testBuf, sizeof(testBuf), infile2)) << "Error getting test data from '" << infile2 << "'";
  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), outfile5)) << "Error getting test data from '" << outfile5 << "'";
  ci5.payload      = testBuf;
  ci5.payloadSize  = strlen(testBuf);
  out              = restService(&ci5, rs);
  EXPECT_STREQ(expectedBuf, out.c_str());


  out = restService(&ci6, rs);
  EXPECT_EQ("", out);
  EXPECT_EQ("Allow", ci6.httpHeader[0]);
  EXPECT_EQ("PUT, DELETE", ci6.httpHeaderValue[0]);

  utExit();
}