#include "se/HostInfoResponse.hpp" #include "se/CLTRID.hpp" #include "se/EPPDateFormatter.hpp" #include "xml/XMLParser.hpp" #include "session/Timer.hpp" #include "common/init.hpp" #include "common/Test.hpp" #include using namespace std; void doWork() { init("/home/drde/etc/toolkit2.conf"); const string xml( "Command completed successfullyns1.example.comNS1_EXAMPLE1-REP192.0.2.2192.0.2.291080:0:0:0:8:800:200C:417AClientYClientX1999-04-03T22:00:00.0ZClientX1999-12-03T09:00:00.0Z2000-04-08T09:00:00.0ZABC-1234554322-XYZ"); HostInfoResponse response; XMLParser parser; std::auto_ptr doc(parser.parse(xml)); response.fromXML(doc.get()); { ASSERT_EQ(response.getName(), "ns1.example.com"); const vector& addrs(response.getAddresses()); ASSERT_EQ(addrs.size(), 3); if (addrs.size() != 3) exit(1); ASSERT_EQ("192.0.2.2", addrs[0].getTextRep()); ASSERT_EQ("192.0.2.29", addrs[1].getTextRep()); ASSERT_EQ("1080:0:0:0:8:800:200C:417A", addrs[2].getTextRep()); ASSERT_EQ("v4", addrs[0].getVersion()); ASSERT_EQ("v4", addrs[1].getVersion()); ASSERT_EQ("v6", addrs[2].getVersion()); } { ASSERT_EQ("NS1_EXAMPLE1-REP", response.getROID()); auto_ptr dt( EPPDateFormatter::fromXSDateTime("1999-04-03T22:00:00.0Z")); ASSERT_EQ(EPPDateFormatter::toXSDateTime(*dt), "1999-04-03T22:00:00.0Z"); auto_ptr dt2( EPPDateFormatter::fromXSDateTime("1999-04-03T22:00:00.0Z")); ASSERT_EQ(EPPDateFormatter::toXSDateTime(*dt2), "1999-04-03T22:00:00.0Z"); ASSERT_EQ("ClientX", response.getCreateClient()); ASSERT_EQ("ClientX", response.getUpdateClient()); ASSERT_EQ("ClientY", response.getSponsorClient()); const vector& statuses(response.getStatuses()); ASSERT_EQ(2, statuses.size()); if (statuses.size() != 2) exit(1); ASSERT_EQ("linked", statuses[0].toString()); ASSERT_EQ("clientUpdateProhibited", statuses[1].toString()); ASSERT_EQ("ABC-12345", response.getCLTRID()); } } int main(int argc, char* argv[]) { TEST_run(doWork); return TEST_errorCount(); }