summaryrefslogtreecommitdiffstats
path: root/sca-cpp
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2010-01-06 06:36:49 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2010-01-06 06:36:49 +0000
commit1f9ec7a1b4aa498aa3312e5ef9c2b7b6a42c02c9 (patch)
tree2486b1c1b6c953ef088ec621bf41b83d9da67eb6 /sca-cpp
parent81dc9e22343e6b12f1e4ec5cf71a57d2973cf9bc (diff)
Added a few more python and C++ component test combinations.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@896332 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-cpp')
-rw-r--r--sca-cpp/trunk/kernel/function.hpp2
-rw-r--r--sca-cpp/trunk/modules/server/client-test.cpp138
-rw-r--r--sca-cpp/trunk/modules/server/domain-test.composite11
-rw-r--r--sca-cpp/trunk/modules/server/impl-test.cpp10
-rw-r--r--sca-cpp/trunk/modules/server/server-test.py19
5 files changed, 119 insertions, 61 deletions
diff --git a/sca-cpp/trunk/kernel/function.hpp b/sca-cpp/trunk/kernel/function.hpp
index cfb5a880bb..899443462e 100644
--- a/sca-cpp/trunk/kernel/function.hpp
+++ b/sca-cpp/trunk/kernel/function.hpp
@@ -211,7 +211,7 @@ template<typename R, typename T, typename U, typename... P> const lambda<R(P...)
return curry(curry(f, t), u);
}
-template<typename R, typename T, typename U, typename V, typename... P> const lambda<R(P...)> curry(const lambda<R(T, U, P...)>& f, const T& t, const U& u, const V& v) {
+template<typename R, typename T, typename U, typename V, typename... P> const lambda<R(P...)> curry(const lambda<R(T, U, V, P...)>& f, const T& t, const U& u, const V& v) {
return curry(curry(curry(f, t), u), v);
}
diff --git a/sca-cpp/trunk/modules/server/client-test.cpp b/sca-cpp/trunk/modules/server/client-test.cpp
index 2728cfc6d5..d037aabbf9 100644
--- a/sca-cpp/trunk/modules/server/client-test.cpp
+++ b/sca-cpp/trunk/modules/server/client-test.cpp
@@ -77,19 +77,27 @@ const bool testGetPerf() {
return true;
}
-const bool testEval() {
+const bool testEval(const string& uri) {
http::CURLSession ch;
- const value val = content(http::evalExpr(mklist<value>(string("echo"), string("Hello")), "http://localhost:8090/test", ch));
+ const value val = content(http::evalExpr(mklist<value>(string("echo"), string("Hello")), uri, ch));
assert(val == string("Hello"));
return true;
}
+const bool testEval() {
+ testEval("http://localhost:8090/test");
+ //testEval("http://localhost:8090/cpp");
+ testEval("http://localhost:8090/python");
+ return true;
+}
+
struct evalLoop {
+ const string uri;
http::CURLSession ch;
- evalLoop(http::CURLSession& ch) : ch(ch) {
+ evalLoop(const string& uri, http::CURLSession& ch) : uri(uri), ch(ch) {
}
const bool operator()() const {
- const value val = content(http::evalExpr(mklist<value>(string("echo"), string("Hello")), "http://localhost:8090/test", ch));
+ const value val = content(http::evalExpr(mklist<value>(string("echo"), string("Hello")), uri, ch));
assert(val == string("Hello"));
return true;
}
@@ -99,57 +107,73 @@ const value blob(string(3000, 'A'));
const list<value> blobs = mklist(blob, blob, blob, blob, blob);
struct blobEvalLoop {
+ const string uri;
http::CURLSession ch;
- blobEvalLoop(http::CURLSession& ch) : ch(ch) {
+ blobEvalLoop(const string& uri, http::CURLSession& ch) : uri(uri), ch(ch) {
}
const bool operator()() const {
- const value val = content(http::evalExpr(mklist<value>(string("echo"), blobs), "http://localhost:8090/test", ch));
+ const value val = content(http::evalExpr(mklist<value>(string("echo"), blobs), uri, ch));
assert(val == blobs);
return true;
}
};
-const bool testEvalPerf() {
+const bool testEvalPerf(const string& type, const string& uri) {
http::CURLSession ch;
- const lambda<bool()> el = evalLoop(ch);
- cout << "JSON-RPC eval echo test " << time(el, 5, 200) << " ms" << endl;
- const lambda<bool()> bel = blobEvalLoop(ch);
- cout << "JSON-RPC eval blob test " << time(bel, 5, 200) << " ms" << endl;
+ const lambda<bool()> el = evalLoop(uri, ch);
+ cout << type << " JSON-RPC eval echo test " << time(el, 5, 200) << " ms" << endl;
+ const lambda<bool()> bel = blobEvalLoop(uri, ch);
+ cout << type << " JSON-RPC eval blob test " << time(bel, 5, 200) << " ms" << endl;
return true;
}
-bool testPost() {
+const bool testEvalPerf() {
+ testEvalPerf("Scheme", "http://localhost:8090/test");
+ //testEvalPerf("C++", "http://localhost:8090/cpp");
+ testEvalPerf("Python", "http://localhost:8090/python");
+ return true;
+}
+
+bool testPost(const string& uri) {
const list<value> i = list<value>()
+ (list<value>() + "name" + string("Apple"))
+ (list<value>() + "price" + string("$2.99"));
const list<value> a = mklist<value>(string("item"), string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"), i);
http::CURLSession ch;
- const failable<value> id = http::post(a, "http://localhost:8090/test", ch);
+ const failable<value> id = http::post(a, uri, ch);
assert(hasContent(id));
return true;
}
+const bool testPost() {
+ testPost("http://localhost:8090/test");
+ //testPost("http://localhost:8090/cpp");
+ testPost("http://localhost:8090/python");
+ return true;
+}
+
struct postLoop {
+ const string uri;
const value val;
http::CURLSession ch;
- postLoop(const value& val, http::CURLSession& ch) : val(val), ch(ch) {
+ postLoop(const string& uri, const value& val, http::CURLSession& ch) : uri(uri), val(val), ch(ch) {
}
const bool operator()() const {
- const failable<value> id = http::post(val, "http://localhost:8090/test", ch);
+ const failable<value> id = http::post(val, uri, ch);
assert(hasContent(id));
return true;
}
};
-const bool testPostPerf() {
+const bool testPostPerf(const string& type, const string& uri) {
http::CURLSession ch;
{
const list<value> i = list<value>()
+ (list<value>() + "name" + string("Apple"))
+ (list<value>() + "price" + string("$2.99"));
const list<value> val = mklist<value>(string("item"), string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"), i);
- const lambda<bool()> pl = postLoop(val, ch);
- cout << "ATOMPub POST small test " << time(pl, 5, 200) << " ms" << endl;
+ const lambda<bool()> pl = postLoop(uri, val, ch);
+ cout << type << " ATOMPub POST small test " << time(pl, 5, 200) << " ms" << endl;
}
{
const list<value> i = list<value>()
@@ -161,17 +185,24 @@ const bool testPostPerf() {
+ (list<value>() + "blob5" + blob)
+ (list<value>() + "price" + string("$2.99"));
const list<value> val = mklist<value>(string("item"), string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"), i);
- const lambda<bool()> pl = postLoop(val, ch);
- cout << "ATOMPub POST blob test " << time(pl, 5, 200) << " ms" << endl;
+ const lambda<bool()> pl = postLoop(uri, val, ch);
+ cout << type << " ATOMPub POST blob test " << time(pl, 5, 200) << " ms" << endl;
}
return true;
}
+const bool testPostPerf() {
+ testPostPerf("Scheme", "http://localhost:8090/test");
+ //testPostPerf("C++", "http://localhost:8090/cpp");
+ testPostPerf("Python", "http://localhost:8090/python");
+ return true;
+}
+
#ifdef _REENTRANT
-const bool postThread(const int count, const value& val) {
+const bool postThread(const string& uri, const int count, const value& val) {
http::CURLSession ch;
- const lambda<bool()> pl = postLoop(val, ch);
+ const lambda<bool()> pl = postLoop(uri, val, ch);
time(pl, 0, count);
return true;
}
@@ -202,7 +233,7 @@ struct postThreadLoop {
}
};
-const bool testPostThreadPerf() {
+const bool testPostThreadPerf(const string& type, const string& uri) {
const int count = 50;
const int threads = 10;
@@ -211,11 +242,18 @@ const bool testPostThreadPerf() {
+ (list<value>() + "price" + string("$2.99"));
const value val = mklist<value>(string("item"), string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"), i);
- const lambda<bool()> pl= curry(lambda<bool(const int, const value)>(postThread), count, val);
+ const lambda<bool()> pl= curry(lambda<bool(const string, const int, const value)>(postThread), uri, count, val);
const lambda<bool()> ptl = postThreadLoop(pl, threads);
double t = time(ptl, 0, 1) / (threads * count);
- cout << "ATOMPub POST thread test " << t << " ms" << endl;
+ cout << type << " ATOMPub POST thread test " << t << " ms" << endl;
+
+ return true;
+}
+const bool testPostThreadPerf() {
+ testPostThreadPerf("Scheme", "http://localhost:8090/test");
+ //testPostThreadPerf("C++", "http://localhost:8090/cpp");
+ //testPostThreadPerf("Python", "http://localhost:8090/python");
return true;
}
@@ -260,7 +298,7 @@ struct postForkLoop {
}
};
-const bool testPostForkPerf() {
+const bool testPostForkPerf(const string& type, const string& uri) {
const int count = 50;
const int procs = 10;
@@ -269,7 +307,7 @@ const bool testPostForkPerf() {
+ (list<value>() + "price" + string("$2.99"));
const value val = mklist<value>(string("item"), string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"), i);
- const lambda<bool()> pl= curry(lambda<bool(const int, const value)>(postProc), count, val);
+ const lambda<bool()> pl= curry(lambda<bool(const string, const int, const value)>(postProc), uri, count, val);
const lambda<bool()> ptl = postForkLoop(pl, procs);
double t = time(ptl, 0, 1) / (procs * count);
cout << "ATOMPub POST fork test " << t << " ms" << endl;
@@ -277,48 +315,44 @@ const bool testPostForkPerf() {
return true;
}
+const bool testPostForkPerf() {
+ testPostThreadPerf("Scheme", "http://localhost:8090/test");
+ //testPostThreadPerf("C++", "http://localhost:8090/cpp");
+ testPostThreadPerf("Python", "http://localhost:8090/python");
+ return true;
+}
+
#endif
-const bool testPut() {
+const bool testPut(const string& uri) {
const list<value> i = list<value>()
+ (list<value>() + "name" + string("Apple"))
+ (list<value>() + "price" + string("$2.99"));
const list<value> a = mklist<value>(string("item"), string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"), i);
http::CURLSession ch;
- value rc = content(http::put(a, "http://localhost:8090/test/111", ch));
+ value rc = content(http::put(a, uri, ch));
assert(rc == value(true));
return true;
}
-const bool testDel() {
- http::CURLSession ch;
- value rc = content(http::del("http://localhost:8090/test/123456789", ch));
- assert(rc == value(true));
+const bool testPut() {
+ testPut("http://localhost:8090/test/111");
+ testPut("http://localhost:8090/cpp/111");
+ testPut("http://localhost:8090/python/111");
return true;
}
-const bool testEvalCpp() {
+const bool testDel(const string& uri) {
http::CURLSession ch;
- const value val = content(http::evalExpr(mklist<value>(string("hello"), string("world")), "http://localhost:8090/cpp", ch));
- assert(val == string("hello world"));
+ value rc = content(http::del(uri, ch));
+ assert(rc == value(true));
return true;
}
-struct evalCppLoop {
- http::CURLSession ch;
- evalCppLoop(http::CURLSession& ch) : ch(ch) {
- }
- const bool operator()() const {
- const value val = content(http::evalExpr(mklist<value>(string("hello"), string("world")), "http://localhost:8090/cpp", ch));
- assert(val == string("hello world"));
- return true;
- }
-};
-
-const bool testEvalCppPerf() {
- http::CURLSession ch;
- const lambda<bool()> el = evalCppLoop(ch);
- cout << "JSON-RPC C++ eval test " << time(el, 5, 200) << " ms" << endl;
+const bool testDel() {
+ testDel("http://localhost:8090/test/123456789");
+ testDel("http://localhost:8090/cpp/123456789");
+ testDel("http://localhost:8090/python/123456789");
return true;
}
@@ -341,8 +375,6 @@ int main() {
tuscany::server::testEvalPerf();
tuscany::server::testPut();
tuscany::server::testDel();
- tuscany::server::testEvalCpp();
- tuscany::server::testEvalCppPerf();
tuscany::cout << "OK" << tuscany::endl;
diff --git a/sca-cpp/trunk/modules/server/domain-test.composite b/sca-cpp/trunk/modules/server/domain-test.composite
index 791b2d2f28..c911e9cf07 100644
--- a/sca-cpp/trunk/modules/server/domain-test.composite
+++ b/sca-cpp/trunk/modules/server/domain-test.composite
@@ -22,7 +22,7 @@
targetNamespace="http://domain/test"
name="domain-test">
- <component name="server-test">
+ <component name="scheme-test">
<t:implementation.scheme uri="server-test.scm"/>
<service name="test">
<t:binding.http uri="test"/>
@@ -36,13 +36,20 @@
</service>
</component>
+ <component name="python-test">
+ <t:implementation.python uri="server-test.py"/>
+ <service name="test">
+ <t:binding.http uri="python"/>
+ </service>
+ </component>
+
<component name="client-test">
<!-- <t:implementation.scheme uri="client-test.scm"/> -->
<t:implementation.python uri="client-test.py"/>
<service name="client">
<t:binding.http uri="client"/>
</service>
- <reference name="ref" target="server-test">
+ <reference name="ref" target="scheme-test">
<t:binding.http/>
</reference>
</component>
diff --git a/sca-cpp/trunk/modules/server/impl-test.cpp b/sca-cpp/trunk/modules/server/impl-test.cpp
index 2bbcbc0591..1fd432c7fb 100644
--- a/sca-cpp/trunk/modules/server/impl-test.cpp
+++ b/sca-cpp/trunk/modules/server/impl-test.cpp
@@ -39,7 +39,7 @@ const failable<value> get(unused const list<value>& params) {
}
const failable<value> post(unused const list<value>& params) {
- return value(string("1234"));
+ return value(string("123456789"));
}
const failable<value> put(unused const list<value>& params) {
@@ -50,8 +50,8 @@ const failable<value> del(unused const list<value>& params) {
return value(true);
}
-const failable<value> hello(const list<value>& params) {
- return value(string("hello ") + string(car(params)));
+const failable<value> echo(const list<value>& params) {
+ return value(car(params));
}
}
@@ -69,8 +69,8 @@ const tuscany::value eval(const tuscany::list<tuscany::value>& params) {
return tuscany::server::put(cdr(params));
if (func == "delete")
return tuscany::server::del(cdr(params));
- if (func == "hello")
- return tuscany::server::hello(cdr(params));
+ if (func == "echo")
+ return tuscany::server::echo(cdr(params));
return tuscany::mkfailure<tuscany::value>(tuscany::string("Function not supported: ") + func);
}
diff --git a/sca-cpp/trunk/modules/server/server-test.py b/sca-cpp/trunk/modules/server/server-test.py
new file mode 100644
index 0000000000..c80d800eff
--- /dev/null
+++ b/sca-cpp/trunk/modules/server/server-test.py
@@ -0,0 +1,19 @@
+# JSON-RPC test case
+
+def echo(x):
+ return x
+
+# ATOMPub test case
+
+def post(entry):
+ return "123456789"
+
+def put(id, entry):
+ return true
+
+def deleteall():
+ return true
+
+def delete(id):
+ return true
+