summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/test
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2009-11-30 08:36:32 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2009-11-30 08:36:32 +0000
commitff124040623879bc48a0ba5cf06a841642adef53 (patch)
treee0bee552780b0852c10744017b7826b08f57d377 /sca-cpp/trunk/test
parentcd7dae28b034deebc9c2c2469ed9d8f1f3dab1ed (diff)
Fixes to the http client, httpd modules and memcached component to get the store and shopping cart test case working end to end.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@885349 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-cpp/trunk/test')
-rw-r--r--sca-cpp/trunk/test/store-script/currency-converter.scm1
-rw-r--r--sca-cpp/trunk/test/store-script/fruits-catalog.scm4
-rw-r--r--sca-cpp/trunk/test/store-script/htdocs/store.html14
-rw-r--r--sca-cpp/trunk/test/store-script/shopping-cart.scm52
-rwxr-xr-xsca-cpp/trunk/test/store-script/store-composite-test (renamed from sca-cpp/trunk/test/store-script/store-http-test)13
-rw-r--r--sca-cpp/trunk/test/store-script/store.composite10
-rw-r--r--sca-cpp/trunk/test/store-script/store.scm6
7 files changed, 78 insertions, 22 deletions
diff --git a/sca-cpp/trunk/test/store-script/currency-converter.scm b/sca-cpp/trunk/test/store-script/currency-converter.scm
index 7f58335951..498ac5da5b 100644
--- a/sca-cpp/trunk/test/store-script/currency-converter.scm
+++ b/sca-cpp/trunk/test/store-script/currency-converter.scm
@@ -7,3 +7,4 @@
(define (symbol currency)
(if (equal? currency "EUR") "E" "$")
)
+
diff --git a/sca-cpp/trunk/test/store-script/fruits-catalog.scm b/sca-cpp/trunk/test/store-script/fruits-catalog.scm
index 390068d71a..18128f0137 100644
--- a/sca-cpp/trunk/test/store-script/fruits-catalog.scm
+++ b/sca-cpp/trunk/test/store-script/fruits-catalog.scm
@@ -1,12 +1,9 @@
; Catalog implementation
(define (get converter)
- (display "catalog")
(define (convert price) (converter "convert" "USD" "USD" price))
-
(define code "USD")
(define symbol (converter "symbol" code))
-
(list
(list (list 'javaClass "services.Item") (list 'name "Apple") (list 'currencyCode code) (list 'currencySymbol symbol) (list 'price (convert 2.99)))
(list (list 'javaClass "services.Item") (list 'name "Orange") (list 'currencyCode code) (list 'currencySymbol symbol) (list 'price (convert 3.55)))
@@ -17,3 +14,4 @@
; TODO remove these JSON-RPC specific functions
(define (system.listMethods converter) (list "Service.get"))
(define Service.get get)
+
diff --git a/sca-cpp/trunk/test/store-script/htdocs/store.html b/sca-cpp/trunk/test/store-script/htdocs/store.html
index 4d300f1adb..0378b454cc 100644
--- a/sca-cpp/trunk/test/store-script/htdocs/store.html
+++ b/sca-cpp/trunk/test/store-script/htdocs/store.html
@@ -94,11 +94,15 @@
var j = 0;
for (var i=0; i<items.length; i++)
if (items[i].checked) {
-
- var entry = '<entry xmlns="http://www.w3.org/2005/Atom"><title>item</title><content type="text/xml">' +
- '<Item xmlns="http://services/">' +
- '<name xmlns="">' + catalogItems[i].name + '</name>' + '<price xmlns="">' + catalogItems[i].price + '</price>' +
- '</Item>' + '</content></entry>';
+ var entry = '<entry xmlns="http://www.w3.org/2005/Atom"><title type="text">Item</title><content type="application/xml">' +
+ '<item>' +
+ '<javaClass>' + catalogItems[i].javaClass + '</javaClass>' +
+ '<name>' + catalogItems[i].name + '</name>' +
+ '<currencyCode>' + catalogItems[i].currencyCode + '</currencyCode>' +
+ '<currencySymbol>' + catalogItems[i].currencySymbol + '</currencySymbol>' +
+ '<price>' + catalogItems[i].price + '</price>' +
+ '</item>' +
+ '</content></entry>';
shoppingCart.post(entry, shoppingCart_postResponse);
items[i].checked = false;
}
diff --git a/sca-cpp/trunk/test/store-script/shopping-cart.scm b/sca-cpp/trunk/test/store-script/shopping-cart.scm
index ebb3504e25..01ca62df40 100644
--- a/sca-cpp/trunk/test/store-script/shopping-cart.scm
+++ b/sca-cpp/trunk/test/store-script/shopping-cart.scm
@@ -1,26 +1,58 @@
; Shopping cart implementation
-(define (post item)
- (uuid)
+(define cartId "1234")
+
+; Get the shopping cart from the cache
+; Return an empty cart if not found
+(define (getcart id cache)
+ (define cart (cache "get" id))
+ (if (nul cart)
+ (list)
+ cart)
+)
+
+; Post a new item to the cart, create a new cart if necessary
+(define (post item cache)
+ (define id (uuid))
+ (define cart (cons item (getcart cartId cache)))
+ (cache "put" cartId cart)
+ id
)
-(define (getall)
- (cons "Sample Feed" (cons (uuid) '()))
+; Return the content of the cart
+(define (getall cache)
+ (define cart (getcart cartId cache))
+ (cons "Your Cart" (cons cartId cart))
)
-(define (get id)
+; Get an item from the cart
+(define (get id cache)
(define entry (list (list 'name "Apple") (list 'currencyCode "USD") (list 'currencySymbol "$") (list 'price 2.99)))
(cons "Item" (list id entry))
)
-(define (delete id)
- true
+; Delete the cart
+(define (delete id cache)
+ (cache "delete" cartId)
+)
+
+; Return the price of an item
+(define (price item)
+ (car (cdr (car (cdr (cdr (cdr (cdr (car (cdr (cdr item))))))))))
+)
+
+; Sum the prices of a list of items
+(define (sum items)
+ (if (nul items) 0 (+ (price (car items)) (sum (cdr items))))
)
-(define (gettotal)
- 11.0
+; Return the total price of the items in the cart
+(define (gettotal cache)
+ (define cart (getcart cartId cache))
+ (sum cart)
)
; TODO remove these JSON-RPC specific functions
-(define (system.listMethods) (list "Service.getTotal"))
+(define (system.listMethods cache) (list "Service.getTotal"))
(define Service.getTotal gettotal)
+
diff --git a/sca-cpp/trunk/test/store-script/store-http-test b/sca-cpp/trunk/test/store-script/store-composite-test
index d04eab8a6c..43923fca36 100755
--- a/sca-cpp/trunk/test/store-script/store-http-test
+++ b/sca-cpp/trunk/test/store-script/store-composite-test
@@ -52,6 +52,13 @@ SCAComposite store.composite
SCAComponent CurrencyConverter
</Location>
+<Location /Cache>
+SetHandler mod_tuscany_eval
+SCAContribution `pwd`/
+SCAComposite store.composite
+SCAComponent Cache
+</Location>
+
<Location /references>
SetHandler mod_tuscany_wiring
SCAContribution `pwd`/
@@ -60,6 +67,9 @@ SCAComposite store.composite
EOF
apachectl -k start -d `pwd`/tmp
+
+mc="memcached -l 127.0.0.1 -m 4 -p 11211"
+$mc &
sleep 1
# Test HTTP GET
@@ -69,7 +79,8 @@ rc=$?
# Cleanup
apachectl -k stop -d `pwd`/tmp
-sleep 2
+kill `ps -f | grep -v grep | grep "$mc" | awk '{ print $2 }'`
+sleep 1
if [ "$rc" = "0" ]; then
echo "OK"
fi
diff --git a/sca-cpp/trunk/test/store-script/store.composite b/sca-cpp/trunk/test/store-script/store.composite
index cd34f81840..2cfadf3f71 100644
--- a/sca-cpp/trunk/test/store-script/store.composite
+++ b/sca-cpp/trunk/test/store-script/store.composite
@@ -57,6 +57,9 @@
<service name="Total">
<t:binding.jsonrpc uri="Total"/>
</service>
+ <reference name="cache" target="Cache">
+ <t:binding.atom/>
+ </reference>
</component>
<component name="CurrencyConverter">
@@ -66,4 +69,11 @@
</service>
</component>
+ <component name="Cache">
+ <t:implementation.cpp uri="../../components/cache/.libs/libmcache"/>
+ <service name="Cache">
+ <t:binding.atom uri="Cache"/>
+ </service>
+ </component>
+
</composite>
diff --git a/sca-cpp/trunk/test/store-script/store.scm b/sca-cpp/trunk/test/store-script/store.scm
index 2434b18b51..01f72d0bea 100644
--- a/sca-cpp/trunk/test/store-script/store.scm
+++ b/sca-cpp/trunk/test/store-script/store.scm
@@ -24,8 +24,8 @@
(shoppingCart "delete" id)
)
-(define (system.listMethods) (list "Service.get" "Service.getTotal"))
-
+; TODO remove these JSON-RPC specific functions
+(define (system.listMethods catalog shoppingCart shoppingTotal) (list "Service.get" "Service.getTotal"))
(define Service.getCatalog getcatalog)
-
(define Service.getTotal gettotal)
+