/* **************************************************************************** * * get - */ TEST(logTraceTreat, get) { ConnectionInfo ci("/log/traceLevel", "GET", "1.1"); const char* outfile = "orion.logTrace.empty.valid.xml"; std::string out; utInit(); lmTraceSet(NULL); ci.outFormat = XML; 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(); }
/* **************************************************************************** * * notFound - */ TEST(postQueryContext, notFound) { ConnectionInfo ci("/ngsi10/queryContext", "POST", "1.1"); const char* infile = "ngsi10.queryContextRequest.entityIdNotFound.valid.xml"; const char* outfile = "ngsi10.queryContextResponse.entityIdNotFound.valid.xml"; std::string out; utInit(); lmTraceSet("0-255"); 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.outFormat = XML; ci.inFormat = XML; ci.payload = testBuf; ci.payloadSize = strlen(testBuf); out = restService(&ci, rs); EXPECT_STREQ(expectedBuf, out.c_str()); utExit(); }
/* **************************************************************************** * * logTraceTreat - */ std::string logTraceTreat ( ConnectionInfo* ciP, int components, std::vector<std::string>& compV, ParseData* parseDataP ) { std::string out = "OK"; std::string path = ""; for (int ix = 0; ix < components; ++ix) { path += compV[ix]; if (ix != components - 1) path += "/"; } if ((components == 2) && (ciP->method == "DELETE")) { lmTraceSet(NULL); out = orionLogReply(ciP, "tracelevels", "all trace levels off"); } else if ((components == 3) && (ciP->method == "DELETE")) { if (strspn(compV[2].c_str(), "0123456789-,'") != strlen(compV[2].c_str())) { out = orionLogReply(ciP, "tracelevels", "poorly formatted trace level string"); return out; } lmTraceSub(compV[2].c_str()); out = orionLogReply(ciP, "tracelevels_removed", compV[2]); } else if ((components == 2) && (ciP->method == "GET")) { char tLevels[256]; lmTraceGet(tLevels, sizeof(tLevels)); out = orionLogReply(ciP, "tracelevels", tLevels); } else if ((components == 3) && (ciP->method == "PUT")) { if (strspn(compV[2].c_str(), "0123456789-,'") != strlen(compV[2].c_str())) { out = orionLogReply(ciP, "tracelevels", "poorly formatted trace level string"); return out; } lmTraceSet(NULL); lmTraceSet(compV[2].c_str()); out = orionLogReply(ciP, "tracelevels", compV[2]); } else { OrionError error(SccBadRequest, std::string("bad URL/Verb: ") + ciP->method + " " + path); TIMED_RENDER(out = error.toJsonV1()); } return out; }