diff options
author | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-23 05:25:33 +0000 |
---|---|---|
committer | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-23 05:25:33 +0000 |
commit | 585f81b9436e137c3ed784d9a91efa9e6e792e03 (patch) | |
tree | f40f0179601320ace0b454698dc76aaeddfc6a5d /sca-cpp/trunk/modules/http/curl-test.cpp | |
parent | 3c6b7d709c7197078f8261f8e3464b0f217c988e (diff) |
Refactored httpd server integration, split http support and server logic in two modules. Added functions to load component implementations packaged as dynamic libraries. Minor monad code cleanup, converted cast operators to separate functions.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@883249 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-cpp/trunk/modules/http/curl-test.cpp')
-rw-r--r-- | sca-cpp/trunk/modules/http/curl-test.cpp | 161 |
1 files changed, 8 insertions, 153 deletions
diff --git a/sca-cpp/trunk/modules/http/curl-test.cpp b/sca-cpp/trunk/modules/http/curl-test.cpp index 863aa98828..0a6fbcd8a6 100644 --- a/sca-cpp/trunk/modules/http/curl-test.cpp +++ b/sca-cpp/trunk/modules/http/curl-test.cpp @@ -53,16 +53,15 @@ const bool testGet() { CURLHandle ch; { std::ostringstream os; - const failable<list<std::ostringstream*>, std::string> r = get<std::ostringstream*>(curlWriter, &os, "http://localhost:8091", ch); - assert(hasValue(r)); + const failable<list<std::ostringstream*>, std::string> r = get<std::ostringstream*>(curlWriter, &os, "http://localhost:8090", ch); + assert(hasContent(r)); assert(contains(os.str(), "HTTP/1.1 200 OK")); assert(contains(os.str(), "It works")); } { - const failable<value, std::string> r = get("http://localhost:8091", ch); - assert(hasValue(r)); - const value val = r; - assert(contains(val, "It works")); + const failable<value, std::string> r = get("http://localhost:8090", ch); + assert(hasContent(r)); + assert(contains(content(r), "It works")); } return true; } @@ -70,10 +69,9 @@ const bool testGet() { const bool testGetLoop(const int count, CURLHandle& ch) { if (count == 0) return true; - const failable<value, std::string> r = get("http://localhost:8091", ch); - assert(hasValue(r)); - const value val = r; - assert(contains(val, "It works")); + const failable<value, std::string> r = get("http://localhost:8090", ch); + assert(hasContent(r)); + assert(contains(content(r), "It works")); return testGetLoop(count - 1, ch); } @@ -95,142 +93,6 @@ const bool testGetPerf() { return true; } -const bool testEval() { - CURLHandle ch; - const value val = evalExpr(mklist<value>(std::string("echo"), std::string("Hello")), "http://localhost:8091/test", ch); - assert(val == std::string("Hello")); - return true; -} - -const bool testEvalLoop(const int count, CURLHandle& ch) { - if (count == 0) - return true; - const value val = evalExpr(mklist<value>(std::string("echo"), std::string("Hello")), "http://localhost:8091/test", ch); - assert(val == std::string("Hello")); - return testEvalLoop(count - 1, ch); -} - -const value blob(std::string(3000, 'A')); -const list<value> blobs = mklist(blob, blob, blob, blob, blob); - -const bool testBlobEvalLoop(const int count, CURLHandle& ch) { - if (count == 0) - return true; - const value val = evalExpr(mklist<value>(std::string("echo"), blobs), "http://localhost:8091/test", ch); - assert(val == blobs); - return testBlobEvalLoop(count - 1, ch); -} - -const bool testEvalPerf() { - const int count = 50; - CURLHandle ch; - struct timeval start; - struct timeval end; - { - testEvalLoop(5, ch); - - gettimeofday(&start, NULL); - - testEvalLoop(count, ch); - - gettimeofday(&end, NULL); - std::cout << "JSON-RPC eval echo test " << duration(start, end, count) << " ms" << std::endl; - } - { - testBlobEvalLoop(5, ch); - - gettimeofday(&start, NULL); - - testBlobEvalLoop(count, ch); - - gettimeofday(&end, NULL); - std::cout << "JSON-RPC eval blob test " << duration(start, end, count) << " ms" << std::endl; - } - return true; -} - -const bool testFeed() { - return true; -} - -bool testPost() { - const list<value> i = list<value>() - << (list<value>() << "name" << std::string("Apple")) - << (list<value>() << "price" << std::string("$2.99")); - const list<value> a = mklist<value>(std::string("item"), std::string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"), i); - CURLHandle ch; - value rc = post(a, "http://localhost:8091/test", ch); - assert(rc == value(true)); - return true; -} - -const bool testPostLoop(const int count, const value& val, CURLHandle& ch) { - if (count == 0) - return true; - const value rc = post(val, "http://localhost:8091/test", ch); - assert(rc == value(true)); - return testPostLoop(count - 1, val, ch); -} - -const bool testPostPerf() { - const int count = 50; - CURLHandle ch; - struct timeval start; - struct timeval end; - { - const list<value> i = list<value>() - << (list<value>() << "name" << std::string("Apple")) - << (list<value>() << "price" << std::string("$2.99")); - const list<value> val = mklist<value>(std::string("item"), std::string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"), i); - testPostLoop(5, val, ch); - - gettimeofday(&start, NULL); - - testPostLoop(count, val, ch); - - gettimeofday(&end, NULL); - std::cout << "ATOMPub POST small test " << duration(start, end, count) << " ms" << std::endl; - } - { - const list<value> i = list<value>() - << (list<value>() << "name" << std::string("Apple")) - << (list<value>() << "blob1" << blob) - << (list<value>() << "blob2" << blob) - << (list<value>() << "blob3" << blob) - << (list<value>() << "blob4" << blob) - << (list<value>() << "blob5" << blob) - << (list<value>() << "price" << std::string("$2.99")); - const list<value> val = mklist<value>(std::string("item"), std::string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"), i); - testPostLoop(5, val, ch); - - gettimeofday(&start, NULL); - - testPostLoop(count, val, ch); - - gettimeofday(&end, NULL); - std::cout << "ATOMPub POST blob test " << duration(start, end, count) << " ms" << std::endl; - } - return true; -} - -const bool testPut() { - const list<value> i = list<value>() - << (list<value>() << "name" << std::string("Apple")) - << (list<value>() << "price" << std::string("$2.99")); - const list<value> a = mklist<value>(std::string("item"), std::string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"), i); - CURLHandle ch; - value rc = put(a, "http://localhost:8091/test/111", ch); - assert(rc == value(true)); - return true; -} - -const bool testDel() { - CURLHandle ch; - value rc = del("http://localhost:8091/test/123456789", ch); - assert(rc == value(true)); - return true; -} - } } @@ -239,13 +101,6 @@ int main() { tuscany::http::testGet(); tuscany::http::testGetPerf(); - tuscany::http::testPost(); - tuscany::http::testPostPerf(); - tuscany::http::testEval(); - tuscany::http::testEvalPerf(); - tuscany::http::testFeed(); - tuscany::http::testPut(); - tuscany::http::testDel(); std::cout << "OK" << std::endl; |