summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/modules
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2010-01-11 08:29:17 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2010-01-11 08:29:17 +0000
commit8015f0d53da53876b65fdcdc712f1dc92835a9b1 (patch)
tree4cffc808317d16435c19289bd2a14d88a357f088 /sca-cpp/trunk/modules
parent11c57b87a39a30904cdf24ef81c770e8f17096a1 (diff)
Minor fixes to server and python evaluator to get python store working. Some changes to python and scheme store test cases to simplify them a bit and make them consistent. Enabled a few more server test combinations.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@897785 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r--sca-cpp/trunk/modules/json/json.hpp12
-rw-r--r--sca-cpp/trunk/modules/python/eval.hpp2
-rw-r--r--sca-cpp/trunk/modules/server/client-test.cpp30
-rw-r--r--sca-cpp/trunk/modules/server/mod-eval.cpp4
-rw-r--r--sca-cpp/trunk/modules/server/server-test.py10
5 files changed, 40 insertions, 18 deletions
diff --git a/sca-cpp/trunk/modules/json/json.hpp b/sca-cpp/trunk/modules/json/json.hpp
index e2f036541a..fc5e512d5e 100644
--- a/sca-cpp/trunk/modules/json/json.hpp
+++ b/sca-cpp/trunk/modules/json/json.hpp
@@ -381,6 +381,18 @@ const failable<list<string> > jsonResult(const value& id, const value& val, JSON
return writeJSON(valuesToElements(mklist<value>(mklist<value>("id", id), mklist<value>("result", val))), cx);
}
+/**
+ * Return a portable function name from a JSON-RPC function name.
+ * Strip the "system." and "Service." prefixes added by some JSON-RPC clients.
+ */
+const string funcName(const string& f) {
+ if (length(f) > 7 && find(f, "system.", 0) == 0)
+ return c_str(f) + 7;
+ if (length(f) > 8 && find(f, "Service.", 0) == 0)
+ return c_str(f) + 8;
+ return f;
+}
+
}
}
diff --git a/sca-cpp/trunk/modules/python/eval.hpp b/sca-cpp/trunk/modules/python/eval.hpp
index b0d793418a..cb6cdea3e2 100644
--- a/sca-cpp/trunk/modules/python/eval.hpp
+++ b/sca-cpp/trunk/modules/python/eval.hpp
@@ -152,7 +152,7 @@ PyObject* valueToPyObject(const value& v) {
case value::Bool:
return (bool)v? Py_True : Py_False;
default:
- return NULL;
+ return Py_None;
}
}
diff --git a/sca-cpp/trunk/modules/server/client-test.cpp b/sca-cpp/trunk/modules/server/client-test.cpp
index d037aabbf9..f46cba5068 100644
--- a/sca-cpp/trunk/modules/server/client-test.cpp
+++ b/sca-cpp/trunk/modules/server/client-test.cpp
@@ -86,7 +86,7 @@ const bool testEval(const string& uri) {
const bool testEval() {
testEval("http://localhost:8090/test");
- //testEval("http://localhost:8090/cpp");
+ testEval("http://localhost:8090/cpp");
testEval("http://localhost:8090/python");
return true;
}
@@ -129,7 +129,7 @@ const bool testEvalPerf(const string& type, const string& uri) {
const bool testEvalPerf() {
testEvalPerf("Scheme", "http://localhost:8090/test");
- //testEvalPerf("C++", "http://localhost:8090/cpp");
+ testEvalPerf("C++", "http://localhost:8090/cpp");
testEvalPerf("Python", "http://localhost:8090/python");
return true;
}
@@ -147,7 +147,7 @@ bool testPost(const string& uri) {
const bool testPost() {
testPost("http://localhost:8090/test");
- //testPost("http://localhost:8090/cpp");
+ testPost("http://localhost:8090/cpp");
testPost("http://localhost:8090/python");
return true;
}
@@ -193,7 +193,7 @@ const bool testPostPerf(const string& type, const string& uri) {
const bool testPostPerf() {
testPostPerf("Scheme", "http://localhost:8090/test");
- //testPostPerf("C++", "http://localhost:8090/cpp");
+ testPostPerf("C++", "http://localhost:8090/cpp");
testPostPerf("Python", "http://localhost:8090/python");
return true;
}
@@ -252,16 +252,16 @@ const bool testPostThreadPerf(const string& type, const string& uri) {
const bool testPostThreadPerf() {
testPostThreadPerf("Scheme", "http://localhost:8090/test");
- //testPostThreadPerf("C++", "http://localhost:8090/cpp");
- //testPostThreadPerf("Python", "http://localhost:8090/python");
+ testPostThreadPerf("C++", "http://localhost:8090/cpp");
+ testPostThreadPerf("Python", "http://localhost:8090/python");
return true;
}
#else
-const bool postProc(const int count, const value& val) {
+const bool postProc(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;
}
@@ -316,9 +316,9 @@ const bool testPostForkPerf(const string& type, const string& uri) {
}
const bool testPostForkPerf() {
- testPostThreadPerf("Scheme", "http://localhost:8090/test");
- //testPostThreadPerf("C++", "http://localhost:8090/cpp");
- testPostThreadPerf("Python", "http://localhost:8090/python");
+ testPostForkPerf("Scheme", "http://localhost:8090/test");
+ //testPostForkPerf("C++", "http://localhost:8090/cpp");
+ testPostForkPerf("Python", "http://localhost:8090/python");
return true;
}
@@ -363,18 +363,18 @@ int main() {
tuscany::cout << "Testing..." << tuscany::endl;
tuscany::server::testGet();
- tuscany::server::testGetPerf();
tuscany::server::testPost();
+ tuscany::server::testPut();
+ tuscany::server::testDel();
+ tuscany::server::testEval();
+ tuscany::server::testGetPerf();
tuscany::server::testPostPerf();
#ifdef _REENTRANT
tuscany::server::testPostThreadPerf();
#else
tuscany::server::testPostForkPerf();
#endif
- tuscany::server::testEval();
tuscany::server::testEvalPerf();
- tuscany::server::testPut();
- tuscany::server::testDel();
tuscany::cout << "OK" << tuscany::endl;
diff --git a/sca-cpp/trunk/modules/server/mod-eval.cpp b/sca-cpp/trunk/modules/server/mod-eval.cpp
index 34c1f00cba..23454e3ceb 100644
--- a/sca-cpp/trunk/modules/server/mod-eval.cpp
+++ b/sca-cpp/trunk/modules/server/mod-eval.cpp
@@ -100,7 +100,7 @@ const failable<int> get(request_rec* r, const lambda<value(const list<value>&)>&
// Extract the request id, method and params
const value id = cadr(ia);
- const value func = c_str(string(cadr(ma)));
+ const value func = c_str(json::funcName(string(cadr(ma))));
// Apply the requested function
const failable<value> val = failableResult(impl(cons(func, httpd::queryParams(args))));
@@ -145,7 +145,7 @@ const failable<int> post(request_rec* r, const lambda<value(const list<value>&)>
// Extract the request id, method and params
const value id = cadr(assoc(value("id"), args));
- const value func = c_str(cadr(assoc(value("method"), args)));
+ const value func = c_str(json::funcName(cadr(assoc(value("method"), args))));
const list<value> params = (list<value>)cadr(assoc(value("params"), args));
// Evaluate the request expression
diff --git a/sca-cpp/trunk/modules/server/server-test.py b/sca-cpp/trunk/modules/server/server-test.py
index c80d800eff..cdef94e116 100644
--- a/sca-cpp/trunk/modules/server/server-test.py
+++ b/sca-cpp/trunk/modules/server/server-test.py
@@ -5,6 +5,16 @@ def echo(x):
# ATOMPub test case
+def getall():
+ return ("Sample Feed", "123456789",
+ ("Item", "111", (("'javaClass", "services.Item"), ("'name", "Apple"), ("'currencyCode", "USD"), ("'currencySymbol", "$"), ("'price", 2.99))),
+ ("Item", "222", (("'javaClass", "services.Item"), ("'name", "Orange"), ("'currencyCode", "USD"), ("'currencySymbol", "$"), ("'price", 3.55))),
+ ("Item", "333", (("'javaClass", "services.Item"), ("name", "Pear"), ("'currencyCode", "USD"), ("'currencySymbol", "$"), ("'price", 1.55))))
+
+def get(id):
+ entry = (("'javaClass", "services.Item"), ("'name", "Apple"), ("'currencyCode", "USD"), ("'currencySymbol", "$"), ("'price", 2.99))
+ return ("Item", id, entry)
+
def post(entry):
return "123456789"