#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 clear() throw();
int events() const throw() { return a_events.size(); }
anna::xml::Node* asXML(anna::xml::Node* parent) const throw();
+ std::string asString() const throw();
};
- 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; }
+ const anna::Millisecond &getStartTimestamp() const throw() { return a_startTimestamp; }
+ const anna::Millisecond &getFinishTimestamp() const throw() { return a_finishTimestamp; }
+ anna::Millisecond getLapseMs() const throw();
+ anna::Millisecond getProcessingTimeMs() const throw();
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();
+ bool isFailed() const throw() { return (getState() == State::Failed); }
+ bool hasSameCondition(const TestDiameterCondition &condition) const throw();
+ const DebugSummary & getDebugSummary() const throw() { return a_debugSummary; }
// Interactivity:
void makeInteractive(bool yes = true) throw() { a_interactiveAmount = (yes ? 0:-1); }
// 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 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);
+ void addIpLimit(unsigned int ipLimit) throw(anna::RuntimeException);
+
+ // Diameter-specifc
+ void addSendDiameterXml2e(const anna::DataBlock &db, anna::diameter::comm::OriginHost *host, int stepNumber) throw(anna::RuntimeException);
+ void addSendDiameterXml2c(const anna::DataBlock &db, anna::diameter::comm::OriginHost *host, int stepNumber) throw(anna::RuntimeException);
+ void addWaitDiameterAnswer(bool fromEntity, int stepNumber) throw(anna::RuntimeException);
+ void addWaitDiameterRegexpHex(bool fromEntity, const std::string ®exp) throw(anna::RuntimeException);
+ void addWaitDiameterRegexpXml(bool fromEntity, const std::string ®exp) throw(anna::RuntimeException);
// Process:
bool reset(bool hard /* hard reset includes in-progress test cases */) throw();
// getters
- const anna::Millisecond &getStartTime() const throw() { return a_startTime; }
const unsigned int &getId() const throw() { return a_id; }
+ const std::string &getDescription() const throw() { return a_description; }
+
+ // setters
+ void setDescription(const std::string &description) throw() { a_description = description; }
//helpers
int steps() const throw() { return a_steps.size(); }
void addStep(TestStep *step) throw() { a_steps.push_back(step); }
- TestStepWait *searchNextWaitConditionFulfilled(const anna::DataBlock &message, bool waitFromEntity) throw();
+ TestStepWaitDiameter *searchNextWaitConditionFulfilled(const anna::DataBlock &message, bool waitFromEntity) throw();
// 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();
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;