X-Git-Url: https://git.teslayout.com/public/public/public/?a=blobdiff_plain;f=example%2Fdiameter%2Flauncher%2FEventOperation.cpp;h=cab0e83b2ed0b26ad092ec0bac6237a6b62d3026;hb=e14f6ba5183403d7bbf589ef87b0643b12a0f72c;hp=4d80410f542953b23c02be25899777b16cf91a03;hpb=e782294456d0877aa8fc05aa931291ac79808eb3;p=anna.git
diff --git a/example/diameter/launcher/EventOperation.cpp b/example/diameter/launcher/EventOperation.cpp
index 4d80410..cab0e83 100644
--- a/example/diameter/launcher/EventOperation.cpp
+++ b/example/diameter/launcher/EventOperation.cpp
@@ -465,23 +465,23 @@ bool EventOperation::answermsg_action_2e(std::string &response, const std::strin
int code = message->getId().first;
LOGDEBUG(anna::Logger::debug("Adding a new programed 'answer to entity' to the FIFO queue corresponding to its message code ...", ANNA_FILE_LOCATION));
response = "Added 'answer to entity' to the FIFO queue corresponding to its message code";
- my_app.getOperatedEntity()->getReactingAnswers()->addMessage(code, message);
+ my_app.getOperatedHost()->getReactingAnswers()->addMessage(code, message);
}
else { // action
if(diameterJson_or_action == "list") { // programmed answers FIFO's to stdout
- response = anna::functions::encodeBase64(my_app.getOperatedEntity()->getReactingAnswers()->asString("ANSWERS TO ENTITY"));
+ response = anna::functions::encodeBase64(my_app.getOperatedHost()->getReactingAnswers()->asString("ANSWERS TO ENTITY"));
} else if (diameterJson_or_action == "rotate") {
- my_app.getOperatedEntity()->getReactingAnswers()->rotate(true);
+ my_app.getOperatedHost()->getReactingAnswers()->rotate(true);
response = "rotate";
} else if (diameterJson_or_action == "exhaust") {
- my_app.getOperatedEntity()->getReactingAnswers()->rotate(false);
+ my_app.getOperatedHost()->getReactingAnswers()->rotate(false);
response = "exhaust";
} else if (diameterJson_or_action == "clear") {
- my_app.getOperatedEntity()->getReactingAnswers()->clear();
+ my_app.getOperatedHost()->getReactingAnswers()->clear();
response = "clear";
} else if (diameterJson_or_action == "dump") {
- my_app.getOperatedEntity()->getReactingAnswers()->dump("programmed_answer");
+ my_app.getOperatedHost()->getReactingAnswers()->dump("programmed_answer");
response = "dump";
}
}
@@ -523,24 +523,24 @@ bool EventOperation::answermsg_action_2c(std::string &response, const std::strin
int code = message->getId().first;
LOGDEBUG(anna::Logger::debug("Adding a new programed 'answer to client' to the FIFO queue corresponding to its message code ...", ANNA_FILE_LOCATION));
- my_app.getOperatedServer()->getReactingAnswers()->addMessage(code, message);
+ my_app.getOperatedHost()->getReactingAnswers()->addMessage(code, message);
response = "Added 'answer to client' to the FIFO queue corresponding to its message code";
}
else { // action
if(diameterJson_or_action == "list") { // programmed answers FIFO's to stdout
- response = anna::functions::encodeBase64(my_app.getOperatedServer()->getReactingAnswers()->asString("ANSWERS TO CLIENT"));
+ response = anna::functions::encodeBase64(my_app.getOperatedHost()->getReactingAnswers()->asString("ANSWERS TO CLIENT"));
} else if (diameterJson_or_action == "rotate") {
- my_app.getOperatedServer()->getReactingAnswers()->rotate(true);
+ my_app.getOperatedHost()->getReactingAnswers()->rotate(true);
response = "rotate";
} else if (diameterJson_or_action == "exhaust") {
- my_app.getOperatedServer()->getReactingAnswers()->rotate(false);
+ my_app.getOperatedHost()->getReactingAnswers()->rotate(false);
response = "exhaust";
} else if (diameterJson_or_action == "clear") {
- my_app.getOperatedServer()->getReactingAnswers()->clear();
+ my_app.getOperatedHost()->getReactingAnswers()->clear();
response = "clear";
} else if (diameterJson_or_action == "dump") {
- my_app.getOperatedServer()->getReactingAnswers()->dump("programmed_answer");
+ my_app.getOperatedHost()->getReactingAnswers()->dump("programmed_answer");
response = "dump";
}
}
@@ -558,8 +558,9 @@ bool EventOperation::test_id__description(std::string &response, unsigned int id
anna::testing::TestManager &testManager = anna::testing::TestManager::instantiate();
try {
- testManager.getTestCase(id)->setDescription(description); // creates / reuses
- response = "Done";
+ anna::testing::TestCase *tc = testManager.getTestCase(id); // creates / reuses
+ tc->setDescription(description);
+ response = std::to_string(tc->getId());
}
catch(anna::RuntimeException &ex) {
ex.trace();
@@ -576,8 +577,9 @@ bool EventOperation::test_id__ip_limit(std::string &response, unsigned int id, i
anna::testing::TestManager &testManager = anna::testing::TestManager::instantiate();
try {
- testManager.getTestCase(id)->addIpLimit(amount); // creates / reuses
- response = "Done";
+ anna::testing::TestCase *tc = testManager.getTestCase(id); // creates / reuses
+ tc->addIpLimit(amount);
+ response = std::to_string(tc->getId());
}
catch(anna::RuntimeException &ex) {
ex.trace();
@@ -595,8 +597,9 @@ bool EventOperation::test_id__timeout(std::string &response, unsigned int id, in
try {
anna::Millisecond timeout = my_app.checkTimeMeasure("Test case timeout", anna::functions::asString(msecs));
- testManager.getTestCase(id)->addTimeout(timeout); // creates / reuses
- response = "Done";
+ anna::testing::TestCase *tc = testManager.getTestCase(id); // creates / reuses
+ tc->addTimeout(timeout);
+ response = std::to_string(tc->getId());
}
catch(anna::RuntimeException &ex) {
ex.trace();
@@ -627,13 +630,14 @@ bool EventOperation::test_id__sendmsg2e_2c(std::string &response, unsigned int i
);
try {
+ anna::testing::TestCase *tc = testManager.getTestCase(id); // creates / reuses
my_app.updateOperatedOriginHostWithMessage(codecMsg);
if (_2e_or_2c)
- testManager.getTestCase(id)->addSendDiameterXml2e(codecMsg.code(), my_app.getOperatedHost(), stepNumber); // creates / reuses
+ tc->addSendDiameterXml2e(codecMsg.code(), my_app.getOperatedHost(), stepNumber);
else
- testManager.getTestCase(id)->addSendDiameterXml2c(codecMsg.code(), my_app.getOperatedHost(), stepNumber); // creates / reuses
+ tc->addSendDiameterXml2c(codecMsg.code(), my_app.getOperatedHost(), stepNumber);
- response = "Done";
+ response = std::to_string(tc->getId());
}
catch(anna::RuntimeException &ex) {
ex.trace();
@@ -650,9 +654,10 @@ bool EventOperation::test_id__delay(std::string &response, unsigned int id, int
anna::testing::TestManager &testManager = anna::testing::TestManager::instantiate();
try {
+ anna::testing::TestCase *tc = testManager.getTestCase(id); // creates / reuses
anna::Millisecond delay = ((msecs == 0 /* special case */) ? (anna::Millisecond)0 : my_app.checkTimeMeasure("Test case delay step", anna::functions::asString(msecs)));
- testManager.getTestCase(id)->addDelay(delay); // creates / reuses
- response = "Done";
+ tc->addDelay(delay); // creates / reuses
+ response = std::to_string(tc->getId());
}
catch(anna::RuntimeException &ex) {
ex.trace();
@@ -669,8 +674,9 @@ bool EventOperation::test_id__sh_command(std::string &response, unsigned int id,
anna::testing::TestManager &testManager = anna::testing::TestManager::instantiate();
try {
- testManager.getTestCase(id)->addCommand(script); // creates / reuses
- response = "Done";
+ anna::testing::TestCase *tc = testManager.getTestCase(id); // creates / reuses
+ tc->addCommand(script); // creates / reuses
+ response = std::to_string(tc->getId());
}
catch(anna::RuntimeException &ex) {
ex.trace();
@@ -718,8 +724,9 @@ bool EventOperation::test_id__waitfefc_hex(std::string &response, unsigned int i
}
try {
- testManager.getTestCase(id)->addWaitDiameterRegexpHex(fe_or_fc, regexp);
- response = "Done";
+ anna::testing::TestCase *tc = testManager.getTestCase(id); // creates / reuses
+ tc->addWaitDiameterRegexpHex(fe_or_fc, regexp);
+ response = std::to_string(tc->getId());
}
catch(anna::RuntimeException &ex) {
ex.trace();
@@ -754,18 +761,22 @@ bool EventOperation::test_id__waitfefc_msg(std::string &response, unsigned int i
std::string::size_type pos, pos_1, pos_2;
pos = regexp.find("end-to-end-id=", 0u);
- pos = regexp.find("\"", pos);
- pos_1 = pos;
- pos = regexp.find("\"", pos+1);
- pos_2 = pos;
- regexp.replace(pos_1 + 1, pos_2 - pos_1 - 1, "[0-9]+");
+ if (pos != std::string::npos) {
+ pos = regexp.find("\"", pos);
+ pos_1 = pos;
+ pos = regexp.find("\"", pos+1);
+ pos_2 = pos;
+ regexp.replace(pos_1 + 1, pos_2 - pos_1 - 1, "[0-9]+");
+ }
pos = regexp.find("hop-by-hop-id=", 0u);
- pos = regexp.find("\"", pos);
- pos_1 = pos;
- pos = regexp.find("\"", pos+1);
- pos_2 = pos;
- regexp.replace(pos_1 + 1, pos_2 - pos_1 - 1, "[0-9]+");
+ if (pos != std::string::npos) {
+ pos = regexp.find("\"", pos);
+ pos_1 = pos;
+ pos = regexp.find("\"", pos+1);
+ pos_2 = pos;
+ regexp.replace(pos_1 + 1, pos_2 - pos_1 - 1, "[0-9]+");
+ }
// For this representation:
//pos = regexp.find("Origin-State-Id", 0u);
@@ -777,20 +788,23 @@ bool EventOperation::test_id__waitfefc_msg(std::string &response, unsigned int i
//regexp.replace(pos_1 + 1, pos_2 - pos_1 - 1, "[0-9]+");
// But we have this one:
pos = regexp.find("Origin-State-Id", 0u);
- pos = regexp.rfind("\"", pos);
- pos = regexp.rfind("\"", pos-1);
- pos = regexp.rfind("\"", pos-1);
- pos_1 = pos;
- pos = regexp.find("\"", pos+1);
- pos_2 = pos;
- regexp.replace(pos_1 + 1, pos_2 - pos_1 - 1, "[0-9]+");
+ if (pos != std::string::npos) {
+ pos = regexp.rfind("\"", pos);
+ pos = regexp.rfind("\"", pos-1);
+ pos = regexp.rfind("\"", pos-1);
+ pos_1 = pos;
+ pos = regexp.find("\"", pos+1);
+ pos_2 = pos;
+ regexp.replace(pos_1 + 1, pos_2 - pos_1 - 1, "[0-9]+");
+ }
//regexp.insert(0, "^");
//regexp += "$";
}
- testManager.getTestCase(id)->addWaitDiameterRegexpXml(fe_or_fc, regexp);
- response = "Done";
+ anna::testing::TestCase *tc = testManager.getTestCase(id); // creates / reuses
+ tc->addWaitDiameterRegexpXml(fe_or_fc, regexp);
+ response = std::to_string(tc->getId());
}
catch(anna::RuntimeException &ex) {
ex.trace();
@@ -816,8 +830,9 @@ bool EventOperation::test_id__waitfefc(std::string &response, unsigned int id, b
anna::testing::TestManager &testManager = anna::testing::TestManager::instantiate();
try { // [code]|[bitR]|[hopByHop]|[applicationId]|[sessionId]|[resultCode]|[msisdn]|[imsi]|[serviceContextId]
- testManager.getTestCase(id)->addWaitDiameter(fe_or_fc, code, bitR, hopByHop, applicationId, sessionId, resultCode, msisdn, imsi, serviceContextId);
- response = "Done";
+ anna::testing::TestCase *tc = testManager.getTestCase(id); // creates / reuses
+ tc->addWaitDiameter(fe_or_fc, code, bitR, hopByHop, applicationId, sessionId, resultCode, msisdn, imsi, serviceContextId);
+ response = std::to_string(tc->getId());
}
catch(anna::RuntimeException &ex) {
ex.trace();
@@ -1090,12 +1105,23 @@ bool EventOperation::test__finished(std::string &response) {
return true; // OK
}
-bool EventOperation::test__clear(std::string &response) {
+bool EventOperation::test__clear(std::string &response, int id) {
Launcher& my_app = static_cast (anna::app::functions::getApp());
anna::testing::TestManager &testManager = anna::testing::TestManager::instantiate();
- return testManager.clearPool(response);
+ if (id == -1) {
+ return testManager.clearPool(response);
+ }
+
+ if (!testManager.findTestCase(id)) {
+ response += "cannot found test id (";
+ response += anna::functions::asString(id);
+ response += ")";
+ return false;
+ }
+
+ return testManager.clearTestCase(response, id);
}
bool EventOperation::test__junit(std::string &response, const std::string & targetFile) {