#include "xml/XMLParser.hpp"
#include "common/init.hpp"
#include "common/Test.hpp"
#include "session/Timer.hpp"
#include "se/DomainKVCommandExtension.hpp"
#include "se/DomainCreateCommand.hpp"
#include "se/DomainUpdateCommand.hpp"
#include "se/StandardCommandType.hpp"
#include "se/CLTRID.hpp"
using namespace std;
void addSampleItemsToExtension(DomainKVCommandExtension &extension, const string &listName);
const static string registrantName = "AusRegistry";
const static string eligibilityType = "Trademark";
const static string policyReason = "1";
void testUpdateSingleKVList()
{
Timer::setTime("20070101.010101");
CLTRID::setClID("JTKUTEST");
DomainKVCommandExtension extension(StandardCommandType::UPDATE());
addSampleItemsToExtension(extension, "ae");
DomainUpdateCommand updateCommand("jtkutest.com.ae");
updateCommand.appendExtension(extension);
const string xml = updateCommand.toXML();
ASSERT_EQ(xml,
"jtkutest.com.ae- Trademark
- 1
- AusRegistry
JTKUTEST.20070101.010101.0"
);
}
void testCreateSingleKVList()
{
Timer::setTime("20070101.010101");
CLTRID::setClID("JTKUTEST");
DomainKVCommandExtension extension(StandardCommandType::CREATE());
addSampleItemsToExtension(extension, "ae");
string registrant("JTKCON");
DomainCreateCommand createCommand("jtkutest.com.ae", "jtkUT3st", ®istrant);
createCommand.appendExtension(extension);
const string xml = createCommand.toXML();
ASSERT_EQ(xml,
"jtkutest.com.aeJTKCONjtkUT3st- Trademark
- 1
- AusRegistry
JTKUTEST.20070101.010101.0"
);
}
void testMultipleKVList()
{
Timer::setTime("20070101.010101");
CLTRID::setClID("JTKUTEST");
DomainKVCommandExtension extension(StandardCommandType::CREATE());
addSampleItemsToExtension(extension, "ae");
addSampleItemsToExtension(extension, "au");
string registrant("JTKCON");
DomainCreateCommand createCommand("jtkutest.com.ae", "jtkUT3st", ®istrant);
createCommand.appendExtension(extension);
const string xml = createCommand.toXML();
ASSERT_EQ(xml,
"jtkutest.com.aeJTKCONjtkUT3st- Trademark
- 1
- AusRegistry
- Trademark
- 1
- AusRegistry
JTKUTEST.20070101.010101.0"
);
}
void addSampleItemsToExtension(DomainKVCommandExtension &extension, const string &listName)
{
extension.addItem(listName, "eligibilityType", eligibilityType);
extension.addItem(listName, "policyReason", policyReason);
extension.addItem(listName, "registrantName", registrantName);
}
int main(int argc, char* argv[])
{
init("/home/drde/etc/toolkit2.conf");
TEST_run(testUpdateSingleKVList);
TEST_run(testCreateSingleKVList);
TEST_run(testMultipleKVList);
return TEST_errorCount();
}