diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/CMakeLists.txt | 19 | ||||
-rw-r--r-- | test/src/test-sockets.cpp | 4 | ||||
-rw-r--r-- | test/src/test-vxml-mmi-http.cpp | 25 |
3 files changed, 30 insertions, 18 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index dbc5a15..b879401 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -62,6 +62,16 @@ add_test(test-lifecycle ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-lifecycle) set_target_properties(test-lifecycle PROPERTIES FOLDER "Tests") if (NOT WIN32) + add_executable(test-vxml-mmi-socket src/test-vxml-mmi-socket.cpp) + target_link_libraries(test-vxml-mmi-socket uscxml) + # add_test(test-datamodel ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-sockets) + set_target_properties(test-vxml-mmi-socket PROPERTIES FOLDER "Tests") + + add_executable(test-vxml-mmi-http src/test-vxml-mmi-http.cpp) + target_link_libraries(test-vxml-mmi-http uscxml) + # add_test(test-datamodel ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-sockets) + set_target_properties(test-vxml-mmi-http PROPERTIES FOLDER "Tests") + add_executable(test-trie src/test-trie.cpp) target_link_libraries(test-trie uscxml) add_test(test-trie ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-trie) @@ -141,15 +151,6 @@ target_link_libraries(test-sockets uscxml) # add_test(test-datamodel ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-sockets) set_target_properties(test-sockets PROPERTIES FOLDER "Tests") -add_executable(test-vxml-mmi-socket src/test-vxml-mmi-socket.cpp) -target_link_libraries(test-vxml-mmi-socket uscxml) -# add_test(test-datamodel ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-sockets) -set_target_properties(test-vxml-mmi-socket PROPERTIES FOLDER "Tests") - -add_executable(test-vxml-mmi-http src/test-vxml-mmi-http.cpp) -target_link_libraries(test-vxml-mmi-http uscxml) -# add_test(test-datamodel ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-sockets) -set_target_properties(test-vxml-mmi-http PROPERTIES FOLDER "Tests") # if (NOT WIN32) # add_executable(test-mmi src/test-mmi.cpp) diff --git a/test/src/test-sockets.cpp b/test/src/test-sockets.cpp index ad567f7..993aaff 100644 --- a/test/src/test-sockets.cpp +++ b/test/src/test-sockets.cpp @@ -87,7 +87,7 @@ int main(int argc, char** argv) { client.write(contentSS.str()); while(packetSeq != iterations) - usleep(10000); + tthread::this_thread::sleep_for(tthread::chrono::milliseconds(20)); } if (1) { @@ -105,7 +105,7 @@ int main(int argc, char** argv) { } while(packetSeq != iterations) - usleep(10000); + tthread::this_thread::sleep_for(tthread::chrono::milliseconds(20)); } exit(0); diff --git a/test/src/test-vxml-mmi-http.cpp b/test/src/test-vxml-mmi-http.cpp index 50a8dd0..130441c 100644 --- a/test/src/test-vxml-mmi-http.cpp +++ b/test/src/test-vxml-mmi-http.cpp @@ -31,9 +31,10 @@ std::stringstream name##XMLSS;\ name##XMLSS << name##XML;\ URL name##URL(target);\ + std::cout << name##XMLSS.str();\ name##URL.setOutContent(name##XMLSS.str());\ name##URL.addOutHeader("Content-type", "application/xml");\ - name##URL.download(true);\ + name##URL.download(false);\ } using namespace uscxml; @@ -44,25 +45,34 @@ std::map<std::string, MMIEvent*> Replies; tthread::condition_variable Cond; tthread::mutex Mutex; +std::string context; + class MMIServlet : public HTTPServlet { public: bool httpRecvRequest(const HTTPServer::Request& request) { tthread::lock_guard<tthread::mutex> lock(Mutex); - NameSpacingParser parser = NameSpacingParser::fromXML(request.content); - switch(MMIEvent::getType(parser.getDocument().getDocumentElement())) { + const Arabica::DOM::Document<std::string>& doc = request.data.at("content").node.getOwnerDocument(); +// NameSpacingParser parser = NameSpacingParser::fromXML(request.content); + switch(MMIEvent::getType(doc.getDocumentElement())) { case MMIEvent::NEWCONTEXTRESPONSE: { - NewContextResponse* resp = new NewContextResponse(NewContextResponse::fromXML(parser.getDocument().getDocumentElement())); + NewContextResponse* resp = new NewContextResponse(NewContextResponse::fromXML(doc.getDocumentElement())); + context = resp->context; Replies[resp->requestId] = resp; + break; } case MMIEvent::STARTRESPONSE: { - StartResponse* resp = new StartResponse(StartResponse::fromXML(parser.getDocument().getDocumentElement())); + StartResponse* resp = new StartResponse(StartResponse::fromXML(doc.getDocumentElement())); Replies[resp->requestId] = resp; } default: ; } Cond.notify_all(); + + HTTPServer::Reply reply(request); + HTTPServer::reply(reply); + return true; } void setURL(const std::string& url) { @@ -135,7 +145,7 @@ int main(int argc, char** argv) { NewContextRequest newCtxReq; newCtxReq.source = source; newCtxReq.target = target; - newCtxReq.requestId = UUID::getUUID(); + newCtxReq.requestId = uscxml::UUID::getUUID(); Requests[newCtxReq.requestId] = &newCtxReq; ISSUE_REQUEST(newCtxReq); @@ -144,9 +154,10 @@ int main(int argc, char** argv) { Cond.wait(Mutex); StartRequest startReq; + startReq.context = context; startReq.source = source; startReq.target = target; - startReq.requestId = UUID::getUUID(); + startReq.requestId = uscxml::UUID::getUUID(); startReq.contentURL.href = document; //"https://raw.githubusercontent.com/Roland-Taizun-Azhar/TaskAssistance-Project/master/WebContent/hello.vxml"; |