X-Git-Url: https://git.teslayout.com/public/public/public/?a=blobdiff_plain;f=include%2Fanna%2Ftesting%2FTestCase.hpp;h=6eab8df655699dd650e33609d4815ca4b316f49d;hb=5a6cba5fde2b2f538a7515f8293cc0a8d9589dfa;hp=b722cac9070040149586bf018941c1a2414c83bd;hpb=d723d5bf571eb48c641b092058eaa38bb6c4fcc8;p=anna.git diff --git a/include/anna/testing/TestCase.hpp b/include/anna/testing/TestCase.hpp index b722cac..6eab8df 100644 --- a/include/anna/testing/TestCase.hpp +++ b/include/anna/testing/TestCase.hpp @@ -15,11 +15,12 @@ #include // Project -#include #include #include -#include +// Diameter-specific +#include +#include namespace anna { @@ -37,11 +38,11 @@ namespace anna { namespace testing { class TestStep; - class TestStepWait; + class TestStepWaitDiameter; class TestCase { - void assertInitialized() const throw(anna::RuntimeException); - void assertMessage(const anna::DataBlock &db, bool toEntity) throw(anna::RuntimeException); + void assertInitialized() const noexcept(false); + void assertMessage(const anna::DataBlock &db, bool toEntity) noexcept(false); public: @@ -55,83 +56,102 @@ public: std::vector a_events; public: - void addHint(const std::string &hint) throw(); - void clear() throw(); - int events() const throw() { return a_events.size(); } - anna::xml::Node* asXML(anna::xml::Node* parent) const throw(); + void addHint(const std::string &hint) ; + void clear() ; + int events() const { return a_events.size(); } + anna::xml::Node* asXML(anna::xml::Node* parent) const ; + std::string asString() const ; }; - TestCase(unsigned int id); + TestCase(unsigned int id, const std::string &description = ""); ~TestCase(); struct State { enum _v { Initialized, InProgress, Failed, Success }; }; - static const char* asText(const State::_v state) throw(); - const State::_v &getState() const throw() { return a_state; } - const anna::Millisecond &getStartTimestamp() const throw() { return a_startTime; } - void addDebugSummaryHint(const std::string &hint) throw() { a_debugSummary.addHint(hint); } - void setState(const State::_v &state) throw(); - bool isFinished() const throw() { return (getState() == State::Failed || getState() == State::Success); } - bool inProgress() const throw() { return (getState() == State::InProgress); } - bool hasSameCondition(const TestCondition &condition) const throw(); + static const char* asText(const State::_v state) ; + const State::_v &getState() const { return a_state; } + const anna::Millisecond &getStartTimestamp() const { return a_startTimestamp; } + const anna::Millisecond &getFinishTimestamp() const { return a_finishTimestamp; } + anna::Millisecond getLapseMs() const ; + anna::Millisecond getProcessingTimeMs() const ; + void addDebugSummaryHint(const std::string &hint) { a_debugSummary.addHint(hint); } + void setState(const State::_v &state) ; + bool isFinished() const { return (getState() == State::Failed || getState() == State::Success); } + bool inProgress() const { return (getState() == State::InProgress); } + bool isFailed() const { return (getState() == State::Failed); } + bool isSuccess() const { return (getState() == State::Success); } + bool hasSameCondition(const TestDiameterCondition &condition) const ; + const DebugSummary & getDebugSummary() const { return a_debugSummary; } // Interactivity: - void makeInteractive(bool yes = true) throw() { a_interactiveAmount = (yes ? 0:-1); } - void addInteractiveAmount(unsigned int amount) throw() { + void makeInteractive(bool yes = true) { a_interactiveAmount = (yes ? 0:-1); } + void addInteractiveAmount(unsigned int amount) { if (a_interactiveAmount == -1) makeInteractive(); if (amount == 0) return; a_interactiveAmount += amount; process(); } - int interactiveAmount() const throw() { return a_interactiveAmount; } - void interactiveExecution() throw() { a_interactiveAmount --; } + int interactiveAmount() const { return a_interactiveAmount; } + void interactiveExecution() { a_interactiveAmount --; } // Step type & information - void addTimeout(const anna::Millisecond &timeout) throw(anna::RuntimeException); - void addSendxml2e(const anna::DataBlock &db, anna::diameter::comm::OriginHost *host, int stepNumber) throw(anna::RuntimeException); - void addSendxml2c(const anna::DataBlock &db, anna::diameter::comm::OriginHost *host, int stepNumber) throw(anna::RuntimeException); - void addDelay(const anna::Millisecond &delay) throw(anna::RuntimeException); - void addWait(bool fromEntity, + void addTimeout(const anna::Millisecond &timeout) noexcept(false); + void addDelay(const anna::Millisecond &delay) noexcept(false); + void addWaitDiameter(bool fromEntity, const std::string &code, const std::string &bitR, const std::string &hopByHop, const std::string &applicationId, const std::string &sessionId, const std::string &resultCode, - const std::string &msisdn, const std::string &imsi, const std::string &serviceContextId) throw(anna::RuntimeException); - void addWaitAnswer(bool fromEntity, int stepNumber) throw(anna::RuntimeException); - void addWaitRegexp(bool fromEntity, const std::string ®exp) throw(anna::RuntimeException); - void addCommand(const std::string &cmd) throw(anna::RuntimeException); + const std::string &msisdn, const std::string &imsi, const std::string &serviceContextId) noexcept(false); + void addCommand(const std::string &cmd) noexcept(false); + void addIpLimit(unsigned int ipLimit) noexcept(false); + + // Diameter-specifc + void addSendDiameterXml2e(const anna::DataBlock &db, anna::diameter::comm::OriginHost *host, int stepNumber) noexcept(false); + void addSendDiameterXml2c(const anna::DataBlock &db, anna::diameter::comm::OriginHost *host, int stepNumber) noexcept(false); + void addWaitDiameterAnswer(bool fromEntity, int stepNumber) noexcept(false); + void addWaitDiameterRegexpHex(bool fromEntity, const std::string ®exp) noexcept(false); + void addWaitDiameterRegexpXml(bool fromEntity, const std::string ®exp) noexcept(false); // Process: - void nextStep() throw() { a_stepsIt++; } - bool done() throw(); - bool process() throw(); // false to stop + void nextStep() { a_stepsIt++; } + bool done() ; + bool process() ; // false to stop // Reset test case and underlaying information (steps context) - bool reset(bool hard /* hard reset includes in-progress test cases */) throw(); + bool reset(bool hard /* hard reset includes in-progress test cases */) ; + + // Check for clear (destroy steps) + bool safeToClear(); // false if something pending (running threads steps) // getters - const anna::Millisecond &getStartTime() const throw() { return a_startTime; } - const unsigned int &getId() const throw() { return a_id; } + const unsigned int &getId() const { return a_id; } + const std::string &getDescription() const { return a_description; } + + // setters + void setDescription(const std::string &description) { a_description = description; } //helpers - int steps() const throw() { return a_steps.size(); } - void addStep(TestStep *step) throw() { a_steps.push_back(step); } + int steps() const { return a_steps.size(); } + void addStep(TestStep *step) { a_steps.push_back(step); } - TestStepWait *searchNextWaitConditionFulfilled(const anna::DataBlock &message, bool waitFromEntity) throw(); + TestStepWaitDiameter *searchNextWaitConditionFulfilled(const anna::DataBlock &message, bool waitFromEntity) ; // When a message arrives, we identify the test case by mean the Session-Id. Then, from the current step iterator (included), // we search for a fulfilling condition for that message. The first found, is 'completed' and then breaks the search. - const TestStep *getStep(int stepNumber) const throw(); + const TestStep *getStep(int stepNumber) const ; - anna::xml::Node* asXML(anna::xml::Node* parent) const throw(); - std::string asXMLString() const throw(); + anna::xml::Node* asXML(anna::xml::Node* parent) const ; + std::string asXMLString() const ; private: // private members: unsigned int a_id; + std::string a_description; std::vector a_steps; std::vector::const_iterator a_stepsIt; std::map a_hopByHops; // for wait-answer State::_v a_state; - anna::Millisecond a_startTime; + anna::Millisecond a_startTimestamp; + anna::Millisecond a_finishTimestamp; DebugSummary a_debugSummary; // used when a test case has failed, uncovered message conditions, and any other hint. int a_interactiveAmount;