tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jsdelf...@apache.org
Subject svn commit: r896332 - in /tuscany/sca-cpp/trunk: kernel/function.hpp modules/server/client-test.cpp modules/server/domain-test.composite modules/server/impl-test.cpp modules/server/server-test.py
Date Wed, 06 Jan 2010 06:36:51 GMT
Author: jsdelfino
Date: Wed Jan  6 06:36:49 2010
New Revision: 896332

URL: http://svn.apache.org/viewvc?rev=896332&view=rev
Log:
Added a few more python and C++ component test combinations.

Added:
    tuscany/sca-cpp/trunk/modules/server/server-test.py
Modified:
    tuscany/sca-cpp/trunk/kernel/function.hpp
    tuscany/sca-cpp/trunk/modules/server/client-test.cpp
    tuscany/sca-cpp/trunk/modules/server/domain-test.composite
    tuscany/sca-cpp/trunk/modules/server/impl-test.cpp

Modified: tuscany/sca-cpp/trunk/kernel/function.hpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/kernel/function.hpp?rev=896332&r1=896331&r2=896332&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/kernel/function.hpp (original)
+++ tuscany/sca-cpp/trunk/kernel/function.hpp Wed Jan  6 06:36:49 2010
@@ -211,7 +211,7 @@
     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);
 }
 

Modified: tuscany/sca-cpp/trunk/modules/server/client-test.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/server/client-test.cpp?rev=896332&r1=896331&r2=896332&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/server/client-test.cpp (original)
+++ tuscany/sca-cpp/trunk/modules/server/client-test.cpp Wed Jan  6 06:36:49 2010
@@ -77,19 +77,27 @@
     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 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 @@
             + (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 @@
     }
 };
 
-const bool testPostThreadPerf() {
+const bool testPostThreadPerf(const string& type, const string& uri) {
     const int count = 50;
     const int threads = 10;
 
@@ -211,11 +242,18 @@
         + (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 @@
     }
 };
 
-const bool testPostForkPerf() {
+const bool testPostForkPerf(const string& type, const string& uri) {
     const int count = 50;
     const int procs = 10;
 
@@ -269,7 +307,7 @@
         + (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 @@
     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 @@
     tuscany::server::testEvalPerf();
     tuscany::server::testPut();
     tuscany::server::testDel();
-    tuscany::server::testEvalCpp();
-    tuscany::server::testEvalCppPerf();
 
     tuscany::cout << "OK" << tuscany::endl;
 

Modified: tuscany/sca-cpp/trunk/modules/server/domain-test.composite
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/server/domain-test.composite?rev=896332&r1=896331&r2=896332&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/server/domain-test.composite (original)
+++ tuscany/sca-cpp/trunk/modules/server/domain-test.composite Wed Jan  6 06:36:49 2010
@@ -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>

Modified: tuscany/sca-cpp/trunk/modules/server/impl-test.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/server/impl-test.cpp?rev=896332&r1=896331&r2=896332&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/server/impl-test.cpp (original)
+++ tuscany/sca-cpp/trunk/modules/server/impl-test.cpp Wed Jan  6 06:36:49 2010
@@ -39,7 +39,7 @@
 }
 
 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 @@
     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 @@
         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);
 }
 

Added: tuscany/sca-cpp/trunk/modules/server/server-test.py
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/server/server-test.py?rev=896332&view=auto
==============================================================================
--- tuscany/sca-cpp/trunk/modules/server/server-test.py (added)
+++ tuscany/sca-cpp/trunk/modules/server/server-test.py Wed Jan  6 06:36:49 2010
@@ -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
+



Mime
View raw message