DRDE/APIG/client/coretestbucket.cpp

118 lines
4.1 KiB
C++
Raw Normal View History

2014-01-11 19:56:19 +00:00
#include "mdclient.h"
using namespace std;
typedef struct _DE {
char sig;
const char * name; } newDEs;
2014-01-13 01:29:22 +00:00
// Lots to do here, need to complete migration to the EPP context which is
// enoromously better better bounded than the original. In the end will have
// a test suite here that can be generated from the XMLRPC registry.
const char *standardEPPDirectives[8] =
{ "check", "infod", "transfer", "create", "renew, "update", "delete", "transfer" };
2014-01-11 19:56:19 +00:00
const char *randomValues[4] = { "333.333", "111.111", "34.43", "7777.777" };
const char *requiredCmdSubSys[2] = { "SYSTEM", "STATUS" };
string debug1,debug2,success("OK");
void mdCoreAPITestSuite::bucket01(char const *title) {
phase = string("core API test bucket");
2014-01-13 01:29:22 +00:00
int nTests=(sizeof(standardEPPDirectives)/sizeof(char *)),variation;
2014-01-11 19:56:19 +00:00
XmlRpcValue focus,gotten[nTests];
cout << "\nTest Bucket: " << title << endl;
// Get predefined data and test a bogus dataname
for ( variation=0; variation < nTests; variation++) {
2014-01-13 01:29:22 +00:00
cout << ".Get '" << standardEPPDirectives[variation] << "'\n";
gotten[variation] = testState->get(mdServerHandle,standardEPPDirectives[variation]).getStruct();
2014-01-11 19:56:19 +00:00
focus = gotten[variation].structGetValue("dataname");
if (variation < (nTests - 1))
2014-01-13 01:29:22 +00:00
TEST(focus.getString() == string(standardEPPDirectives[variation]));
2014-01-11 19:56:19 +00:00
else TEST(focus.getString() == string("not found"));
}
// Set to some value.
for (variation=0;variation < (nTests - 1);variation++) {
2014-01-13 01:29:22 +00:00
cout << ".Set '" << standardEPPDirectives[variation] << "'\n";
2014-01-11 19:56:19 +00:00
gotten[variation].structSetValue("sValue",XmlRpcValue::makeString(randomValues[variation]));
TEST(string("OK") == testState->set(mdServerHandle,gotten[variation]));
}
// Get and compare.
for ( variation=0; variation < (nTests -1); variation++) {
2014-01-13 01:29:22 +00:00
cout << ".Cmp '" << standardEPPDirectives[variation] << "'\n";
gotten[variation] = testState->get(mdServerHandle,standardEPPDirectives[variation]).getStruct();
2014-01-11 19:56:19 +00:00
focus = gotten[variation].structGetValue("sValue");
debug1 = focus.getString();
debug2 = string(randomValues[variation]);
TEST(focus.getString() == string(randomValues[variation]));
}
}
void mdCoreAPITestSuite::bucket02(char const *title) {
int nRequired=(sizeof(requiredCmdSubSys)/sizeof(char *)),nthCmd=0,i,found=0;
XmlRpcValue response;
cout << "\nTest Bucket: " << title << endl;
response = testBehavior->getCommandList(mdServerHandle,string("")).getArray();
TEST(response.arraySize() >= nRequired);
for (nthCmd = 0; nthCmd < response.arraySize(); nthCmd++) {
for (i=0;i<nRequired;i++)
if (response.arrayGetItem(nthCmd).getString() == string(requiredCmdSubSys[i])) {
cout << ".Has '" << requiredCmdSubSys[i] << "'\n"; // visually check for dups
found++;
}
}
TEST(found == nRequired);
}
void mdCoreAPITestSuite::bucket03(char const *title) {
int nNew=(sizeof(otherP1Elements)/sizeof(newDEs)),nthNew=0;
std::string newType(" ");
XmlRpcValue response;
cout << "\nTest Bucket: " << title << endl;
for (;nthNew < nNew;nthNew++) {
cout << ".Add '" << otherP1Elements[nthNew].name
<< "' with signature: '" << otherP1Elements[nthNew].sig << "'\n";
newType.replace(0,1,1,otherP1Elements[nthNew].sig);
TEST(success == testState->create(mdServerHandle,newType,otherP1Elements[nthNew].name));
}
cout << "Note: you cannot run this bucket again without restarting MD." << endl;
}
void mdCoreAPITestSuite::bucket04(char const *title) {
cout << "\nTest Bucket: " << title << " test variations not implemented yet." << endl;
}
void mdCoreAPITestSuite::bucket05(char const *title) {
cout << "\nTest Bucket: " << title << " test variations not implemented yet." << endl;
}
void mdCoreAPITestSuite::bucket06(char const *title) {
cout << "\nTest Bucket: " << title << " test variations not implemented yet.\n" << endl;
}