summaryrefslogtreecommitdiffstats
path: root/cpp/sca/test
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2009-11-01 05:25:14 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2009-11-01 05:25:14 +0000
commit6b94d489977c1cb2eeddded3ee329fe6b9605d5c (patch)
treef51d8b2373102cb6c8ac9fc0e051b6f1227a414c /cpp/sca/test
parent9f187b46ae761e8275362d6c1533e9fe79028c7b (diff)
Minor refactoring of read/write functions and primitive procs. Added functions to help store data in memcached. Fixes to HTTP support and more tests.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@831640 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r--cpp/sca/test/store-script/htdocs/store.html2
-rw-r--r--cpp/sca/test/store-script/htdocs/store.js4
-rwxr-xr-xcpp/sca/test/store-script/store-http-test60
-rw-r--r--cpp/sca/test/store-script/store-script-test.cpp8
-rw-r--r--cpp/sca/test/store-script/store.scm21
5 files changed, 83 insertions, 12 deletions
diff --git a/cpp/sca/test/store-script/htdocs/store.html b/cpp/sca/test/store-script/htdocs/store.html
index 98d6ec8e8e..4d300f1adb 100644
--- a/cpp/sca/test/store-script/htdocs/store.html
+++ b/cpp/sca/test/store-script/htdocs/store.html
@@ -158,7 +158,7 @@
<br>
<input type="button" onClick="checkoutCart()" value="Checkout">
<input type="button" onClick="deleteCart()" value="Empty">
- <a href="../ShoppingCart/Cart/">(feed)</a>
+ <a href="../ShoppingCart/">(feed)</a>
</form>
</div>
</body>
diff --git a/cpp/sca/test/store-script/htdocs/store.js b/cpp/sca/test/store-script/htdocs/store.js
index 64749ce6c1..9cb09f4b78 100644
--- a/cpp/sca/test/store-script/htdocs/store.js
+++ b/cpp/sca/test/store-script/htdocs/store.js
@@ -651,8 +651,8 @@ tuscany.sca.Property = function (name) {
tuscany.sca.referenceMap = new Object();
tuscany.sca.referenceMap.catalog = new JSONRpcClient("/Catalog").Service;
-tuscany.sca.referenceMap.shoppingCart = new AtomClient("/ShoppingCart/Cart");
-tuscany.sca.referenceMap.shoppingTotal = new JSONRpcClient("/ShoppingCart/Total").Service;
+tuscany.sca.referenceMap.shoppingCart = new AtomClient("/ShoppingCart");
+tuscany.sca.referenceMap.shoppingTotal = new JSONRpcClient("/Total").Service;
tuscany.sca.Reference = function (name) {
return tuscany.sca.referenceMap[name];
}
diff --git a/cpp/sca/test/store-script/store-http-test b/cpp/sca/test/store-script/store-http-test
new file mode 100755
index 0000000000..4a5a3df685
--- /dev/null
+++ b/cpp/sca/test/store-script/store-http-test
@@ -0,0 +1,60 @@
+#!/bin/sh
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+echo "Testing..."
+
+# Setup
+../../modules/http/httpd-conf tmp 8092 htdocs
+cat >>tmp/conf/httpd.conf <<EOF
+<Location /Catalog>
+SetHandler mod_tuscany
+SCAContribution `pwd`/
+SCAComponent store
+SCAImplementation store.scm
+</Location>
+
+<Location /Total>
+SetHandler mod_tuscany
+SCAContribution `pwd`/
+SCAComponent store
+SCAImplementation store.scm
+</Location>
+
+<Location /ShoppingCart>
+SetHandler mod_tuscany
+SCAContribution `pwd`/
+SCAComponent store
+SCAImplementation store.scm
+</Location>
+EOF
+apachectl -k start -d `pwd`/tmp
+sleep 1
+
+# Test HTTP GET
+curl http://localhost:8092/store.html 2>/dev/null >tmp/store.html
+diff tmp/store.html htdocs/store.html
+rc=$?
+
+# Cleanup
+apachectl -k stop -d `pwd`/tmp
+sleep 1
+if [ "$rc" = "0" ]; then
+ echo "OK"
+fi
+return $rc
diff --git a/cpp/sca/test/store-script/store-script-test.cpp b/cpp/sca/test/store-script/store-script-test.cpp
index 5808bd889e..5a29d8caba 100644
--- a/cpp/sca/test/store-script/store-script-test.cpp
+++ b/cpp/sca/test/store-script/store-script-test.cpp
@@ -55,7 +55,7 @@ bool testScript() {
}
const value evalLoop(std::istream& is, const value& req, eval::Env& globalEnv, const gc_pool& pool) {
- value in = eval::read(is);
+ value in = eval::readValue(is);
if(isNil(in))
return eval::evalExpr(req, globalEnv, pool);
eval::evalExpr(in, globalEnv, pool);
@@ -66,13 +66,12 @@ bool testEval() {
{
std::ifstream is("store.scm", std::ios_base::in);
std::ostringstream os;
- eval::setupEvalOut(os);
+ eval::setupDisplay(os);
gc_pool pool;
eval::Env globalEnv = eval::setupEnvironment(pool);
const value req(mklist<value>("storeui_service", std::string("getcatalog")));
const value val = evalLoop(is, req, globalEnv, pool);
- eval::cleanupEnvironment(globalEnv);
std::ostringstream vs;
vs << val;
@@ -82,13 +81,12 @@ bool testEval() {
{
std::ifstream is("store.scm", std::ios_base::in);
std::ostringstream os;
- eval::setupEvalOut(os);
+ eval::setupDisplay(os);
gc_pool pool;
eval::Env globalEnv = eval::setupEnvironment(pool);
const value req(mklist<value>("storeui_service", std::string("gettotal")));
const value res = evalLoop(is, req, globalEnv, pool);
- eval::cleanupEnvironment(globalEnv);
std::ostringstream rs;
rs << res;
diff --git a/cpp/sca/test/store-script/store.scm b/cpp/sca/test/store-script/store.scm
index 99ae33481c..709fd943f1 100644
--- a/cpp/sca/test/store-script/store.scm
+++ b/cpp/sca/test/store-script/store.scm
@@ -32,7 +32,7 @@
(list (list 'javaClass "services.Item") (list 'name "Apple") (list 'currency code) (list 'symbol symbol) (list 'price 2.99))
(list (list 'javaClass "services.Item") (list 'name "Orange") (list 'currency code) (list 'symbol symbol) (list 'price 3.55))
(list (list 'javaClass "services.Item") (list 'name "Pear") (list 'currency code) (list 'symbol symbol) (list 'price 1.55))
- )
+ )
)
(define (catalog_impl converter op args)
@@ -48,11 +48,11 @@
(; "Cart implementation")
(define (cart_post content item)
- (cons (cons "Item" (list "123456789" item)) content)
+ (cons (cons "Item" (list (uuid) item)) content)
)
(define (cart_getall content)
- (cons "Sample Feed" (cons "123" content))
+ (cons "Sample Feed" (cons (uuid) content))
)
(define (cart_getentry id)
@@ -125,13 +125,26 @@
(; "Store UI JSON-RPC interop test case")
(define (system.listMethods) (list "Service.get" "Service.getTotal"))
+
(define (Service.get) (storeui_service "getcatalog"))
+
(define (.get) (storeui_service "getcatalog"))
+
(define (Service.getTotal) (storeui_service "gettotal"))
(; "Store UI ATOMPub interop test case")
(define (getall) (storeui_service "getall" added2))
+
(define (get id) (storeui_service "getentry" id))
-(define (post entry) (display entry))
+
+(define (post entry)
+ (display entry)
+ (uuid)
+)
+
+(define (delete . args)
+ (display args)
+ true
+)