#include <map>
// Project
-#include <anna/diameter/defines.hpp>
#include <anna/core/DataBlock.hpp>
#include <anna/core/util/Millisecond.hpp>
-#include <anna/testing/TestCondition.hpp>
+// Diameter-specific
+#include <anna/diameter/defines.hpp>
+#include <anna/testing/TestDiameterCondition.hpp>
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:
std::vector<event_t> 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 addWaitRegexpHex(bool fromEntity, const std::string ®exp) throw(anna::RuntimeException);
- void addWaitRegexpXml(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<TestStep*> a_steps;
std::vector<TestStep*>::const_iterator a_stepsIt;
std::map<anna::diameter::HopByHop, TestStep*> 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;