summaryrefslogtreecommitdiffstats
path: root/cpp/sca/modules/http/httpd-test
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xcpp/sca/modules/http/httpd-test57
-rw-r--r--cpp/sca/modules/http/httpd-test.scm33
2 files changed, 81 insertions, 9 deletions
diff --git a/cpp/sca/modules/http/httpd-test b/cpp/sca/modules/http/httpd-test
index 3e4c5f82de..04c584496c 100755
--- a/cpp/sca/modules/http/httpd-test
+++ b/cpp/sca/modules/http/httpd-test
@@ -18,20 +18,59 @@
# under the License.
echo "Testing..."
-mkdir -p tmp
-mkdir -p tmp/conf
-cp test-conf/* tmp/conf
-cat >tmp/conf/httpd.conf <<EOF
-ServerName 127.0.0.1
-Listen 9090
-DocumentRoot `pwd`/test-htdocs
+
+# Setup
+./httpd-conf tmp 8090 htdocs
+cat >>tmp/conf/httpd.conf <<EOF
+<Location /test>
+SetHandler mod_tuscany
+SCAContribution `pwd`/
+SCAComponent httpd-test
+SCAImplementation httpd-test.scm
+</Location>
EOF
-mkdir -p tmp/logs
apachectl -k start -d `pwd`/tmp
sleep 1
-curl http://localhost:9090/index.html 2>&1 | grep "It works" >/dev/null
+
+# Test HTTP GET
+curl http://localhost:8090/index.html 2>/dev/null >tmp/index.html
+diff tmp/index.html htdocs/index.html
rc=$?
+
+# Test ATOMPub
+if [ "$rc" = "0" ]; then
+ curl http://localhost:8090/test/ >tmp/feed.xml 2>/dev/null
+ diff tmp/feed.xml htdocs/feed.xml
+ rc=$?
+fi
+if [ "$rc" = "0" ]; then
+ curl http://localhost:8090/test/111 >tmp/entry.xml 2>/dev/null
+ diff tmp/entry.xml htdocs/entry.xml
+ rc=$?
+fi
+if [ "$rc" = "0" ]; then
+ curl http://localhost:8090/test/ -X POST -H "Content-type: application/atom+xml" --data @htdocs/entry.xml 2>/dev/null
+ rc=$?
+fi
+if [ "$rc" = "0" ]; then
+ curl http://localhost:8090/test/111 -X PUT -H "Content-type: application/atom+xml" --data @htdocs/entry.xml 2>/dev/null
+ rc=$?
+fi
+if [ "$rc" = "0" ]; then
+ curl http://localhost:8090/test/111 -X DELETE 2>/dev/null
+ rc=$?
+fi
+
+# Test JSON-RPC
+if [ "$rc" = "0" ]; then
+ curl http://localhost:8090/test/ -X POST -H "Content-type: application/json-rpc" --data @htdocs/json-request.txt >tmp/json-result.txt 2>/dev/null
+ diff tmp/json-result.txt htdocs/json-result.txt
+ rc=$?
+fi
+
+# Cleanup
apachectl -k stop -d `pwd`/tmp
+sleep 1
if [ "$rc" = "0" ]; then
echo "OK"
fi
diff --git a/cpp/sca/modules/http/httpd-test.scm b/cpp/sca/modules/http/httpd-test.scm
new file mode 100644
index 0000000000..a3ddf8dda8
--- /dev/null
+++ b/cpp/sca/modules/http/httpd-test.scm
@@ -0,0 +1,33 @@
+(; "JSON-RPC test case")
+
+(define (echo x) x)
+
+(; "ATOMPub test case")
+
+(define (getall)
+ '("Sample Feed" "123456789"
+ ("Item" "111" (javaClass "services.Item") (name "Apple") (currency "USD") (symbol "$") (price 2.99))
+ ("Item" "222" (javaClass "services.Item") (name "Orange") (currency "USD") (symbol "$") (price 3.55))
+ ("Item" "333" (javaClass "services.Item") (name "Pear") (currency "USD") (symbol "$") (price 1.55)))
+)
+
+(define (get id)
+ (define entry '((javaClass "services.Item") (name "Apple") (currency "USD") (symbol "$") (price 2.99)))
+ (cons "Item" (list id entry))
+)
+
+(define (post entry)
+ (display entry)
+ "123456789"
+)
+
+(define (put entry)
+ (display entry)
+ true
+)
+
+(define (delete . args)
+ (display args)
+ true
+)
+