14 #include "ORMFunctionalObjectTest.hpp"
16 HCE::KVDB_TESTS::Document::Document() {}
18 const std::string HCE::KVDB_TESTS::Document::json() {
19 std::string s_type = Poco::NumberFormatter::format(
type);
20 items.set(
"type",s_type);
21 items.set(
"data",item);
22 std::ostringstream oss;
28 void readDocuments(
const std::vector<std::string>& vector_file_names, HCE::KVDB_TESTS::Document& doc)
33 Poco::JSON::Object item;
34 Poco::JSON::Array arr;
35 for(
auto file_name : vector_file_names) {
36 Poco::File xml_file(file_name);
37 Poco::SharedMemory xml(xml_file, Poco::SharedMemory::AM_READ);
41 Poco::XML::DOMParser parser;
42 Poco::XML::AutoPtr<Poco::XML::Document> pDoc = parser.parseString(xml.begin());
44 Poco::XML::NodeIterator it(pDoc, Poco::XML::NodeFilter::SHOW_ALL);
45 Poco::XML::Node* pNode = it.nextNode();
51 Poco::XML::NamedNodeMap* pmap = pNode->attributes();
54 for(
unsigned i=0; i<pmap->length(); ++i) {
55 Poco::XML::Node* p_node = pmap->item(i);
56 if(p_node->nodeName()==
"id") {
57 key = p_node->nodeValue();
59 case HCE::KVDB_TESTS::Document::get :
60 case HCE::KVDB_TESTS::Document::del :
61 case HCE::KVDB_TESTS::Document::check : {
62 Poco::Dynamic::Var var(key);
74 if(doc.type == HCE::KVDB_TESTS::Document::put) {
78 if(pNode->nodeName()==
"sphinx:document") {
80 value = pNode->innerText();
86 pNode = it.nextNode();
89 catch (Poco::Exception& exc)
91 std::cerr << exc.displayText() <<
std::endl;
95 case HCE::KVDB_TESTS::Document::put : {
96 doc.item.set(
"documents",item);
99 case HCE::KVDB_TESTS::Document::get :
100 case HCE::KVDB_TESTS::Document::del :
101 case HCE::KVDB_TESTS::Document::check : {
102 doc.item.set(
"documents",arr);
110 Poco::SharedPtr<HCE::ORMFunctionalObject>
pOrmFuncObj;
117 TEST(ORMFunctionalObject, init)
129 TEST(ORMFunctionalObjectTest, put_documents)
132 HCE::KVDB_TESTS::Document doc;
133 doc.type = HCE::KVDB_TESTS::Document::put;
137 std::cout << pOrmFuncObj->processJSON(doc.json()) <<
std::endl;
140 catch (
const Poco::Exception& ex) {
141 std::cout << ex.displayText() <<
std::endl;
150 TEST(ORMFunctionalObjectTest, get_documents_by_id)
152 HCE::KVDB_TESTS::Document doc;
153 doc.type = HCE::KVDB_TESTS::Document::get;
157 std::cout << pOrmFuncObj->processJSON(doc.json()) <<
std::endl;
165 TEST(ORMFunctionalObjectTest, del_documents_by_id)
167 HCE::KVDB_TESTS::Document doc;
168 doc.type = HCE::KVDB_TESTS::Document::del;
172 std::cout << pOrmFuncObj->processJSON(doc.json()) <<
std::endl;