diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-03-20 08:00:41 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-03-20 08:00:41 (GMT) |
commit | c6c1f3e2e333705bf7d54fffd4b18939a56f4ed8 (patch) | |
tree | 92af8be33c602a68d1912790cad657c2a012e2c0 /test/src/test-url.cpp | |
parent | ccbf595c52fd705ec70abc774a29b153a7281334 (diff) | |
download | uscxml-c6c1f3e2e333705bf7d54fffd4b18939a56f4ed8.zip uscxml-c6c1f3e2e333705bf7d54fffd4b18939a56f4ed8.tar.gz uscxml-c6c1f3e2e333705bf7d54fffd4b18939a56f4ed8.tar.bz2 |
Started Syteminvoker
Diffstat (limited to 'test/src/test-url.cpp')
-rw-r--r-- | test/src/test-url.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/test/src/test-url.cpp b/test/src/test-url.cpp index 344df9f..5d497e3 100644 --- a/test/src/test-url.cpp +++ b/test/src/test-url.cpp @@ -1,5 +1,7 @@ #include "uscxml/URL.h" #include "uscxml/Message.h" +#include "uscxml/server/HTTPServer.h" + #include <assert.h> #include <boost/algorithm/string.hpp> #include <iostream> @@ -7,9 +9,54 @@ using namespace uscxml; using namespace boost; +class TestServlet : public HTTPServlet { +public: + TestServlet(bool adaptPath) : _canAdaptPath(adaptPath) {} + + void httpRecvRequest(const HTTPServer::Request& request) {}; + bool canAdaptPath() { return _canAdaptPath; } + void setURL(const std::string& url) { _actualUrl = url; } + + std::string _actualUrl; + bool _canAdaptPath; +}; + int main(int argc, char** argv) { { + TestServlet* testServlet1 = new TestServlet(false); + TestServlet* testServlet2 = new TestServlet(false); + + assert(HTTPServer::registerServlet("/foo", testServlet1)); + assert(!HTTPServer::registerServlet("/foo", testServlet2)); + HTTPServer::unregisterServlet(testServlet1); + assert(HTTPServer::registerServlet("/foo", testServlet2)); + HTTPServer::unregisterServlet(testServlet1); + + assert(HTTPServer::registerServlet("/foo/bar/", testServlet1)); + assert(!HTTPServer::registerServlet("/foo/bar/", testServlet2)); + HTTPServer::unregisterServlet(testServlet1); + HTTPServer::unregisterServlet(testServlet2); + } + + { + TestServlet* testServlet1 = new TestServlet(true); + TestServlet* testServlet2 = new TestServlet(true); + TestServlet* testServlet3 = new TestServlet(true); + + assert(HTTPServer::registerServlet("/foo", testServlet1)); + assert(HTTPServer::registerServlet("/foo", testServlet2)); + assert(HTTPServer::registerServlet("/foo", testServlet3)); + assert(boost::ends_with(testServlet1->_actualUrl, "foo")); + assert(boost::ends_with(testServlet2->_actualUrl, "foo2")); + assert(boost::ends_with(testServlet3->_actualUrl, "foo3")); + + HTTPServer::unregisterServlet(testServlet1); + HTTPServer::unregisterServlet(testServlet2); + HTTPServer::unregisterServlet(testServlet3); + } + + { Data data = Data::fromJSON("asdf"); std::cout << data << std::endl; } @@ -72,4 +119,5 @@ int main(int argc, char** argv) { assert(iequals(url.pathComponents()[2], "Some Spaces")); assert(iequals(url.pathComponents()[3], "index.txt")); } + }
\ No newline at end of file |