void testCheckContent_main_tags_not_existed()
 {
     StringMap content; 
     content["&content-type"] = "text/xml";
     content["&post-data"] = "<request version=\"0.1\" type=\"auth\">\n"
                                 "<login>test_login</login>\n"
                             "</request>";            
     ContentChecker contentChecker;
     CPPUNIT_ASSERT_EQUAL(false, contentChecker.contentIsValid(content));
     CPPUNIT_ASSERT_EQUAL(std::string("pass"), contentChecker.err());
 }
 void testCheckContent_attribute_not_existed()
 {
     StringMap content;  
     content["&content-type"] = "text/xml";
     content["&post-data"] = "<request version=\"0.1\" left_attribute=\"123\">\n"
                                 "<login>test_login</login>\n"
                                 "<pass>test_pass</pass>\n"
                             "</request>";            
     ContentChecker contentChecker;
     CPPUNIT_ASSERT_EQUAL(false, contentChecker.contentIsValid(content));
 }
 void testCheckContent()
 {   
     StringMap content;  
     content["&content-type"] = "text/xml";
     content["&post-data"] = "<request version=\"0.1\" type=\"auth\">\n"
                                 "<login>test_login</login>\n"
                                 "<pass>test_pass</pass>\n"
                             "</request>";
     ContentChecker contentChecker;
     CPPUNIT_ASSERT_EQUAL(true, contentChecker.contentIsValid(content));
     CPPUNIT_ASSERT_EQUAL(int(Auth), contentChecker.requestType());
 }
 void testCheckContent_unknown_type()
 {
     StringMap content;  
     content["&content-type"] = "json";
     content["&post-data"] = "<request version=\"0.1\" type=\"auth\">\n"
                                 "<login>test_login</login>\n"
                                 "<pass>test_pass</pass>\n"
                             "</request>";            
     ContentChecker contentChecker;
     CPPUNIT_ASSERT_EQUAL(false, contentChecker.contentIsValid(content));
     CPPUNIT_ASSERT_EQUAL(std::string("Unknown content type: json"), contentChecker.err());
 }
string
main_handler(const Yb::StringDict &content)
{
    try {
        ContentChecker contentChecker;
        if (!contentChecker.contentIsValid(content))
            throw std::runtime_error(contentChecker.err());
    
        BaseCommand *command = createCommand(contentChecker.requestType(), contentChecker.parsedParams());
        std::string response = command->execute();
        delete command;
        return response;
    }
    catch(const exception &err) {
        logger->error(err.what());
        cout << err.what() << endl;
        return "<status>EXCEPTION</status>";
    }
}