1 // ANNA - Anna is Not Nothingness Anymore //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
13 #include <EventOperation.hpp>
14 #include <Launcher.hpp>
17 #include <anna/diameter.comm/OriginHost.hpp>
21 //#include <sstream> // std::istringstream
22 //#include <iostream> // std::cout
23 //#include <math.h> // ceil
25 #include <unistd.h> // chdir
29 #include <anna/json/functions.hpp>
30 #include <anna/diameter/codec/Message.hpp>
31 //#include <anna/timex/Engine.hpp>
32 //#include <anna/statistics/Engine.hpp>
33 //#include <anna/diameter/codec/functions.hpp>
34 //#include <anna/diameter/codec/Engine.hpp>
35 //#include <anna/diameter/codec/EngineManager.hpp>
36 //#include <anna/http/Transport.hpp>
37 //#include <anna/diameter/stack/Engine.hpp>
38 #include <anna/diameter/helpers/base/functions.hpp>
39 #include <anna/time/functions.hpp>
40 #include <anna/core/functions.hpp>
41 //#include <anna/diameter.comm/ApplicationMessageOamModule.hpp>
42 //#include <anna/testing/defines.hpp>
43 #include <anna/xml/xml.hpp>
44 //#include <anna/diameter.comm/OriginHost.hpp>
45 //#include <anna/diameter.comm/OriginHostManager.hpp>
46 #include <anna/diameter.comm/Message.hpp>
49 //#include <Launcher.hpp>
50 //#include <Procedure.hpp>
51 //#include <EventOperation.hpp>
52 #include <MyDiameterEngine.hpp>
53 #include <MyLocalServer.hpp>
54 #include <anna/testing/TestManager.hpp>
55 //#include <anna/testing/TestCase.hpp>
61 bool EventOperation::node(std::string &response, const std::string & name) {
63 Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
65 anna::diameter::comm::OriginHost *workingNode;
66 try { workingNode = my_app.getWorkingNode(); } catch(anna::RuntimeException &ex) { ex.trace(); }
69 if (my_app.setWorkingNode(name)) {
70 response = anna::functions::asString("Forced node is now '%s'", name.c_str());
71 my_app.setOperatedHost(my_app.getWorkingNode()); // now is the new one
74 response = anna::functions::asString("Node '%s' invalid. Nothing done", name.c_str());
80 response = anna::functions::encodeBase64(workingNode->asXMLString());
83 response = workingNode->asXMLString();
87 response = "Working node is automatic";
93 bool EventOperation::node_auto(std::string &response) {
95 Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
98 response = "Working node has been set to automatic";
103 ////////////////////////
104 // Parsing operations //
105 ////////////////////////
106 bool EventOperation::code(std::string &response, const std::string & diameterJson) {
109 std::string diameterXml = anna::json::functions::json2xml(diameterJson, success);
111 response += "json to xml failed, unable to encode !";
114 anna::diameter::codec::Message codecMsg; // auxiliary codec message
115 codecMsg.loadXMLString(diameterXml);
116 response = anna::functions::asHexString(codecMsg.code());
121 bool EventOperation::decode(std::string &response, const std::string & diameterHex) {
123 Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
125 anna::DataBlock db_aux(true);
126 anna::functions::fromHexString(diameterHex, db_aux);
127 anna::diameter::codec::Message codecMsg; // auxiliary codec message
129 codecMsg.decode(db_aux);
130 std::string xmlString = codecMsg.asXMLString();
131 response = anna::functions::encodeBase64(xmlString);
133 catch(anna::RuntimeException &ex) { ex.trace(); }
138 bool EventOperation::loadmsg(std::string &response, const std::string & diameterJson) {
141 std::string diameterXml = anna::json::functions::json2xml(diameterJson, success);
143 response += "json to xml failed, unable to load message !";
146 anna::diameter::codec::Message codecMsg; // auxiliary codec message
147 codecMsg.loadXMLString(diameterXml);
148 response = anna::functions::encodeBase64(codecMsg.asXMLString());
156 bool EventOperation::services(std::string &response, const std::string & servicesJson) {
158 Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
161 std::string servicesXml = anna::json::functions::json2xml(servicesJson, success);
163 response += "json to xml failed, unable to load services !";
168 my_app.loadServicesFromXMLString(servicesXml, true /* bind entities */);
170 catch(anna::RuntimeException &ex) {
172 response += "loaded services with errors";
175 response = "loaded services correctly";
180 bool EventOperation::diameterServerSessions(std::string &response, int sessions) {
182 Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
185 my_app.getOperatedServer()->setMaxConnections(sessions);
187 catch(anna::RuntimeException &ex) {
189 response += "fail to operate the server";
192 response = "new sessions successfully established on operated diameter server";
197 bool EventOperation::change_dir(std::string &response, const std::string & directory) {
199 Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
201 std::string dir = directory;
202 if (dir == "") dir = my_app.getInitialWorkingDirectory();
203 bool result = (chdir(dir.c_str()) == 0);
206 response = "New execution directory configured: ";
208 response = "Cannot assign provided execution directory: ";
214 ////////////////////////////////
215 // Client sessions visibility //
216 ////////////////////////////////
217 bool EventOperation::visibility(std::string &response, const std::string & action, const std::string &addressPort, int socket) {
219 Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
223 if(addressPort != "") {
225 std::string key = addressPort;
227 key += anna::functions::asString(socket);
229 if(action == "hide") my_app.getOperatedEngine()->findClientSession(key)->hide();
230 if(action == "show") my_app.getOperatedEngine()->findClientSession(key)->show();
231 if(action == "hidden") response = my_app.getOperatedEngine()->findClientSession(key)->hidden() ? "true" : "false";
232 if(action == "shown") response = my_app.getOperatedEngine()->findClientSession(key)->shown() ? "true" : "false";
236 anna::functions::getAddressAndPortFromSocketLiteral(addressPort, address, port);
238 if(action == "hide") my_app.getOperatedEngine()->findServer(address, port)->hide();
239 if(action == "show") my_app.getOperatedEngine()->findServer(address, port)->show();
240 if(action == "hidden") response = my_app.getOperatedEngine()->findServer(address, port)->hidden() ? "true" : "false";
241 if(action == "shown") response = my_app.getOperatedEngine()->findServer(address, port)->shown() ? "true" : "false";
244 if(action == "hide") my_app.getOperatedEntity()->hide();
245 if(action == "show") my_app.getOperatedEntity()->show();
246 if(action == "hidden") response = my_app.getOperatedEntity()->hidden() ? "true" : "false";
247 if(action == "shown") response = my_app.getOperatedEntity()->shown() ? "true" : "false";
257 bool EventOperation::collect(std::string &response) {
259 Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
261 my_app.resetCounters();
262 my_app.resetStatistics();
263 response = "All process counters & statistic information have been reset";
268 bool EventOperation::context(std::string &response, const std::string & targetFile) {
270 Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
272 std::string contextFile = (targetFile != "") ? targetFile : anna::functions::asString("/var/tmp/anna.context.%05d", my_app.getPid());
273 my_app.writeContext(contextFile);
274 response = anna::functions::asString("Context dumped on file '%s'", contextFile.c_str());
279 bool EventOperation::forceCountersRecord(std::string &response) {
281 Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
283 my_app.forceCountersRecord();
284 response = "Current counters have been dump to disk";
289 bool EventOperation::log_statistics_samples(std::string &response, const std::string & list) {
291 Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
293 my_app.logStatisticsSamples(list);
294 response = anna::functions::asString("Log statistics samples for '%s' concepts", list.c_str());
299 bool EventOperation::show_oam(std::string &response) {
301 Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
303 anna::xml::Node root("root");
304 response = anna::xml::Compiler().apply(my_app.oamAsXML(&root));
306 response = anna::functions::encodeBase64(response);
311 bool EventOperation::show_stats(std::string &response) {
313 Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
315 anna::xml::Node root("root");
316 response = anna::xml::Compiler().apply(my_app.statsAsXML(&root));
318 response = anna::functions::encodeBase64(response);
323 /////////////////////
324 // Flow operations //
325 /////////////////////
326 bool EventOperation::sendmsg_hex_2e(std::string &response, const std::string & diameterJson_or_Hex, bool msg_or_hex) {
328 Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
329 anna::diameter::codec::Message codecMsg; // auxiliary codec message
331 anna::diameter::comm::Message *msg;
334 std::string diameterXml = anna::json::functions::json2xml(diameterJson_or_Hex, success);
336 response += "json to xml failed, unable to send message !";
339 codecMsg.loadXMLString(diameterXml);
341 my_app.updateOperatedOriginHostWithMessage(codecMsg);
342 msg = my_app.getOperatedHost()->createCommMessage();
345 catch(anna::RuntimeException &ex) {
347 response += "invalid operated host";
350 try { codecMsg.valid(); } catch(anna::RuntimeException &ex) { ex.trace(); } // at least we need to see validation errors although it will continue sending (see validation mode configured in launcher)
351 msg->setBody(codecMsg.code());
353 // Get DataBlock from hex content:
354 anna::DataBlock db_aux(true);
355 std::string hexString = diameterJson_or_Hex;
356 hexString.erase(std::remove(hexString.begin(), hexString.end(), ':'), hexString.end());
358 std::string msg = "Hex string (remove colons if exists): ";
360 anna::Logger::debug(msg, ANNA_FILE_LOCATION);
362 anna::functions::fromHexString(hexString, db_aux); // could launch exception
364 my_app.updateOperatedOriginHostWithMessage(db_aux);
365 msg = my_app.getOperatedHost()->createCommMessage();
367 catch(anna::RuntimeException &ex) {
369 response += "invalid operated host";
372 msg->setBody(db_aux);
373 try { if(my_app.getOperatedHost()->logEnabled()) codecMsg.decode(db_aux); } catch(anna::RuntimeException &ex) { ex.trace(); }
376 success = my_app.getOperatedEntity()->send(msg);
377 my_app.getOperatedHost()->releaseCommMessage(msg);
380 if(my_app.getOperatedHost()->logEnabled()) {
381 anna::diameter::comm::Server *usedServer = my_app.getOperatedEntity()->getLastUsedResource();
382 anna::diameter::comm::ClientSession *usedClientSession = usedServer ? usedServer->getLastUsedResource() : NULL;
383 std::string detail = usedClientSession ? usedClientSession->asString() : "<null client session>"; // shouldn't happen
384 my_app.getOperatedHost()->writeLogFile(codecMsg, (success ? "sent2e" : "send2eError"), detail);
388 response = "Operation processed"; // could be failed
392 bool EventOperation::sendmsg_hex_2c(std::string &response, const std::string & diameterJson_or_Hex, bool msg_or_hex) {
394 Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
395 anna::diameter::codec::Message codecMsg; // auxiliary codec message
397 anna::diameter::comm::Message *msg;
400 std::string diameterXml = anna::json::functions::json2xml(diameterJson_or_Hex, success);
402 response += "json to xml failed, unable to send message !";
405 codecMsg.loadXMLString(diameterXml);
407 my_app.updateOperatedOriginHostWithMessage(codecMsg);
408 msg = my_app.getOperatedHost()->createCommMessage();
411 catch(anna::RuntimeException &ex) {
413 response += "invalid operated host";
416 try { codecMsg.valid(); } catch(anna::RuntimeException &ex) { ex.trace(); } // at least we need to see validation errors although it will continue sending (see validation mode configured in launcher)
417 msg->setBody(codecMsg.code());
419 // Get DataBlock from hex content:
420 anna::DataBlock db_aux(true);
421 std::string hexString = diameterJson_or_Hex;
422 hexString.erase(std::remove(hexString.begin(), hexString.end(), ':'), hexString.end());
424 std::string msg = "Hex string (remove colons if exists): ";
426 anna::Logger::debug(msg, ANNA_FILE_LOCATION);
428 anna::functions::fromHexString(hexString, db_aux); // could launch exception
430 my_app.updateOperatedOriginHostWithMessage(db_aux);
431 msg = my_app.getOperatedHost()->createCommMessage();
433 catch(anna::RuntimeException &ex) {
435 response += "invalid operated host";
438 msg->setBody(db_aux);
439 try { if(my_app.getOperatedHost()->logEnabled()) codecMsg.decode(db_aux); } catch(anna::RuntimeException &ex) { ex.trace(); }
442 success = my_app.getOperatedServer()->send(msg);
443 my_app.getOperatedHost()->releaseCommMessage(msg);
446 if(my_app.getOperatedHost()->logEnabled()) {
447 anna::diameter::comm::ServerSession *usedServerSession = my_app.getOperatedServer()->getLastUsedResource();
448 std::string detail = usedServerSession ? usedServerSession->asString() : "<null server session>"; // shouldn't happen
449 my_app.getOperatedHost()->writeLogFile(codecMsg, (success ? "sent2c" : "send2cError"), detail);
453 response = "Operation processed"; // could be failed
457 bool EventOperation::answermsg_action_2e(std::string &response, const std::string & diameterJson_or_action, bool msg_or_action) {
459 Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
460 anna::diameter::codec::Message codecMsg; // auxiliary codec message
461 anna::diameter::codec::Message *message;
466 std::string diameterXml = anna::json::functions::json2xml(diameterJson_or_action, success);
468 response += "json to xml failed, unable to send message !";
471 codecMsg.loadXMLString(diameterXml);
473 my_app.updateOperatedOriginHostWithMessage(codecMsg);
474 message = my_app.getOperatedHost()->getCodecEngine()->createMessage(diameterXml, false /* is xml string */); // loads xml again, lesser of two evils
475 LOGDEBUG(anna::Logger::debug(message->asXMLString(), ANNA_FILE_LOCATION));
477 catch(anna::RuntimeException &ex) {
479 response += "invalid operated host";
483 if(message->isRequest()) {
484 response += "cannot program diameter requests. Answer type must be provided";
488 int code = message->getId().first;
489 LOGDEBUG(anna::Logger::debug("Adding a new programed 'answer to entity' to the FIFO queue corresponding to its message code ...", ANNA_FILE_LOCATION));
490 response = "Added 'answer to entity' to the FIFO queue corresponding to its message code";
491 my_app.getOperatedEntity()->getReactingAnswers()->addMessage(code, message);
495 if(diameterJson_or_action == "list") { // programmed answers FIFO's to stdout
496 response = anna::functions::encodeBase64(my_app.getOperatedEntity()->getReactingAnswers()->asString("ANSWERS TO ENTITY"));
497 } else if (diameterJson_or_action == "rotate") {
498 my_app.getOperatedEntity()->getReactingAnswers()->rotate(true);
500 } else if (diameterJson_or_action == "exhaust") {
501 my_app.getOperatedEntity()->getReactingAnswers()->rotate(false);
502 response = "exhaust";
503 } else if (diameterJson_or_action == "clear") {
504 my_app.getOperatedEntity()->getReactingAnswers()->clear();
506 } else if (diameterJson_or_action == "dump") {
507 my_app.getOperatedEntity()->getReactingAnswers()->dump("programmed_answer");
516 bool EventOperation::answermsg_action_2c(std::string &response, const std::string & diameterJson_or_action, bool msg_or_action) {
518 Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
519 anna::diameter::codec::Message codecMsg; // auxiliary codec message
520 anna::diameter::codec::Message *message;
525 std::string diameterXml = anna::json::functions::json2xml(diameterJson_or_action, success);
527 response += "json to xml failed, unable to send message !";
530 codecMsg.loadXMLString(diameterXml);
532 my_app.updateOperatedOriginHostWithMessage(codecMsg);
533 message = my_app.getOperatedHost()->getCodecEngine()->createMessage(diameterXml, false /* is xml string */); // loads xml again, lesser of two evils
534 LOGDEBUG(anna::Logger::debug(message->asXMLString(), ANNA_FILE_LOCATION));
536 catch(anna::RuntimeException &ex) {
538 response += "invalid operated host";
542 if(message->isRequest()) {
543 response += "cannot program diameter requests. Answer type must be provided";
547 int code = message->getId().first;
548 LOGDEBUG(anna::Logger::debug("Adding a new programed 'answer to client' to the FIFO queue corresponding to its message code ...", ANNA_FILE_LOCATION));
549 my_app.getOperatedServer()->getReactingAnswers()->addMessage(code, message);
550 response = "Added 'answer to client' to the FIFO queue corresponding to its message code";
554 if(diameterJson_or_action == "list") { // programmed answers FIFO's to stdout
555 response = anna::functions::encodeBase64(my_app.getOperatedServer()->getReactingAnswers()->asString("ANSWERS TO CLIENT"));
556 } else if (diameterJson_or_action == "rotate") {
557 my_app.getOperatedServer()->getReactingAnswers()->rotate(true);
559 } else if (diameterJson_or_action == "exhaust") {
560 my_app.getOperatedServer()->getReactingAnswers()->rotate(false);
561 response = "exhaust";
562 } else if (diameterJson_or_action == "clear") {
563 my_app.getOperatedServer()->getReactingAnswers()->clear();
565 } else if (diameterJson_or_action == "dump") {
566 my_app.getOperatedServer()->getReactingAnswers()->dump("programmed_answer");
578 bool EventOperation::test_id__description(std::string &response, unsigned int id, const std::string & description) {
580 Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
581 anna::testing::TestManager &testManager = anna::testing::TestManager::instantiate();
584 testManager.getTestCase(id)->setDescription(description); // creates / reuses
587 catch(anna::RuntimeException &ex) {
589 response += "invalid ip-limit";
596 bool EventOperation::test_id__ip_limit(std::string &response, unsigned int id, int amount) {
598 Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
599 anna::testing::TestManager &testManager = anna::testing::TestManager::instantiate();
602 testManager.getTestCase(id)->addIpLimit(amount); // creates / reuses
605 catch(anna::RuntimeException &ex) {
607 response += "invalid ip-limit";
614 bool EventOperation::test_id__timeout(std::string &response, unsigned int id, int msecs) {
616 Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
617 anna::testing::TestManager &testManager = anna::testing::TestManager::instantiate();
620 anna::Millisecond timeout = my_app.checkTimeMeasure("Test case timeout", anna::functions::asString(msecs));
621 testManager.getTestCase(id)->addTimeout(timeout); // creates / reuses
624 catch(anna::RuntimeException &ex) {
626 response += "invalid timeout";
633 bool EventOperation::test_id__sendmsg2e_2c(std::string &response, unsigned int id, bool _2e_or_2c, const std::string & diameterJson, int stepNumber) {
635 Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
636 anna::testing::TestManager &testManager = anna::testing::TestManager::instantiate();
639 std::string diameterXml = anna::json::functions::json2xml(diameterJson, success);
641 response += "json to xml failed, unable to load message !";
644 anna::diameter::codec::Message codecMsg; // auxiliary codec message
645 codecMsg.loadXMLString(diameterXml);
648 if (!codecMsg.isRequest() && (stepNumber == -1))
649 anna::Logger::warning("Step number has not been provided. Take into account that this answer message will be sent 'as is' and sequence information could be wrong at the remote peer", ANNA_FILE_LOCATION);
653 my_app.updateOperatedOriginHostWithMessage(codecMsg);
655 testManager.getTestCase(id)->addSendDiameterXml2e(codecMsg.code(), my_app.getOperatedHost(), stepNumber); // creates / reuses
657 testManager.getTestCase(id)->addSendDiameterXml2c(codecMsg.code(), my_app.getOperatedHost(), stepNumber); // creates / reuses
661 catch(anna::RuntimeException &ex) {
663 response += "failed";
670 bool EventOperation::test_id__delay(std::string &response, unsigned int id, int msecs) {
672 Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
673 anna::testing::TestManager &testManager = anna::testing::TestManager::instantiate();
676 anna::Millisecond delay = ((msecs == 0 /* special case */) ? (anna::Millisecond)0 : my_app.checkTimeMeasure("Test case delay step", anna::functions::asString(msecs)));
677 testManager.getTestCase(id)->addDelay(delay); // creates / reuses
680 catch(anna::RuntimeException &ex) {
682 response += "invalid delay";
689 bool EventOperation::test_id__sh_command(std::string &response, unsigned int id, const std::string & script) {
691 Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
692 anna::testing::TestManager &testManager = anna::testing::TestManager::instantiate();
695 testManager.getTestCase(id)->addCommand(script); // creates / reuses
698 catch(anna::RuntimeException &ex) {
700 response += "failed";
707 bool EventOperation::test_id__waitfefc_hex(std::string &response, unsigned int id, bool fe_or_fc, const std::string & hex, bool strict) {
709 Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
710 anna::testing::TestManager &testManager = anna::testing::TestManager::instantiate();
712 // Get DataBlock from hex content:
713 anna::DataBlock db_aux(true);
714 std::string hexString = hex;
715 hexString.erase(std::remove(hexString.begin(), hexString.end(), ':'), hexString.end());
717 std::string msg = "Hex string (remove colons if exists): ";
719 anna::Logger::debug(msg, ANNA_FILE_LOCATION);
724 anna::functions::fromHexString(hexString, db_aux); // could launch exception
725 regexp = anna::functions::asHexString(db_aux);
727 catch(anna::RuntimeException &ex) {
729 response += "failed";
735 //// If request, we will ignore sequence data:
736 //if (anna::diameter::codec::functions::requestBit(db_aux))
737 regexp.replace (24, 16, "[0-9A-Fa-f]{16}");
739 regexp.insert(0, "^");
744 testManager.getTestCase(id)->addWaitDiameterRegexpHex(fe_or_fc, regexp);
747 catch(anna::RuntimeException &ex) {
749 response += "failed";
756 bool EventOperation::test_id__waitfefc_msg(std::string &response, unsigned int id, bool fe_or_fc, const std::string & diameterJson, bool strict) {
758 Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
759 anna::testing::TestManager &testManager = anna::testing::TestManager::instantiate();
762 std::string diameterXml = anna::json::functions::json2xml(diameterJson, success);
764 response += "json to xml failed, unable to load message !";
769 anna::diameter::codec::Message codecMsg; // auxiliary codec message
770 codecMsg.loadXMLString(diameterXml);
771 std::string regexp = codecMsg.asXMLString(true /* normalization */);
773 // Now we must insert regular expressions in hop-by-hop, end-to-end and Origin-State-Id:
777 std::string::size_type pos, pos_1, pos_2;
779 pos = regexp.find("end-to-end-id=", 0u);
780 pos = regexp.find("\"", pos);
782 pos = regexp.find("\"", pos+1);
784 regexp.replace(pos_1 + 1, pos_2 - pos_1 - 1, "[0-9]+");
786 pos = regexp.find("hop-by-hop-id=", 0u);
787 pos = regexp.find("\"", pos);
789 pos = regexp.find("\"", pos+1);
791 regexp.replace(pos_1 + 1, pos_2 - pos_1 - 1, "[0-9]+");
793 // For this representation: <avp name="Origin-State-Id" data="1428633668"/>
794 //pos = regexp.find("Origin-State-Id", 0u);
795 //pos = regexp.find("\"", pos);
796 //pos = regexp.find("\"", pos+1);
798 //pos = regexp.find("\"", pos+1);
800 //regexp.replace(pos_1 + 1, pos_2 - pos_1 - 1, "[0-9]+");
801 // But we have this one: <avp data="1428633668" name="Origin-State-Id"/>
802 pos = regexp.find("Origin-State-Id", 0u);
803 pos = regexp.rfind("\"", pos);
804 pos = regexp.rfind("\"", pos-1);
805 pos = regexp.rfind("\"", pos-1);
807 pos = regexp.find("\"", pos+1);
809 regexp.replace(pos_1 + 1, pos_2 - pos_1 - 1, "[0-9]+");
811 //regexp.insert(0, "^");
815 testManager.getTestCase(id)->addWaitDiameterRegexpXml(fe_or_fc, regexp);
818 catch(anna::RuntimeException &ex) {
820 response += "failed";
827 bool EventOperation::test_id__waitfefc(std::string &response, unsigned int id, bool fe_or_fc,
828 const std::string & code,
829 const std::string & bitR,
830 const std::string & hopByHop,
831 const std::string & applicationId,
832 const std::string & sessionId,
833 const std::string & resultCode,
834 const std::string & msisdn,
835 const std::string & imsi,
836 const std::string & serviceContextId) {
838 Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
839 anna::testing::TestManager &testManager = anna::testing::TestManager::instantiate();
841 try { // [code]|[bitR]|[hopByHop]|[applicationId]|[sessionId]|[resultCode]|[msisdn]|[imsi]|[serviceContextId]
842 testManager.getTestCase(id)->addWaitDiameter(fe_or_fc, code, bitR, hopByHop, applicationId, sessionId, resultCode, msisdn, imsi, serviceContextId);
845 catch(anna::RuntimeException &ex) {
847 response += "failed";
854 /////////////////////////
855 // Testcases execution //
856 /////////////////////////
857 bool EventOperation::test__ttps(std::string &response, int amount) {
859 Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
866 bool EventOperation::test__next(std::string &response, int syncAmount) {
868 Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
875 bool EventOperation::test__ip_limit(std::string &response, int amount) {
877 Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
884 bool EventOperation::test__goto(std::string &response, int id) {
886 Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
893 bool EventOperation::test__run(std::string &response, int id) {
895 Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
902 bool EventOperation::test__look(std::string &response, int id) {
904 Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
911 bool EventOperation::test__state(std::string &response, int id) {
913 Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
920 bool EventOperation::test__interact(std::string &response, int amount, unsigned int id) {
922 Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
929 bool EventOperation::test__reset(std::string &response, bool soft_hard, unsigned int id) {
931 Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
938 bool EventOperation::test__repeats(std::string &response, int amount) {
940 Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
947 bool EventOperation::test__auto_reset(std::string &response, bool soft_hard) {
949 Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
956 bool EventOperation::test__initialized(std::string &response) {
958 Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
965 bool EventOperation::test__finished(std::string &response) {
967 Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
974 bool EventOperation::test__clear(std::string &response) {
976 Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
977 anna::testing::TestManager &testManager = anna::testing::TestManager::instantiate();
980 if (testManager.clearPool()) {
981 response = "All the programmed test cases have been dropped";
984 response = "There are not programmed test cases to be removed";
987 catch(anna::RuntimeException &ex) {
989 response += "failed";
996 bool EventOperation::test__junit(std::string &response, const std::string & targetFile) {
998 Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
1005 bool EventOperation::test__summary_counts(std::string &response) {
1007 Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
1014 bool EventOperation::test__summary_states(std::string &response) {
1016 Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
1023 bool EventOperation::test__summary(std::string &response) {
1025 Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
1032 bool EventOperation::test__report(std::string &response, const std::string & state, bool enable) {
1034 Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
1041 bool EventOperation::test__report_hex(std::string &response, bool enable) {
1043 Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
1050 bool EventOperation::test__dump_stdout(std::string &response, bool enable) {
1052 Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());