summaryrefslogtreecommitdiffstats
path: root/sca-cpp
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2009-12-26 03:25:16 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2009-12-26 03:25:16 +0000
commitf453584ae0a3ec04f1781fc35b7abe5d139c6679 (patch)
tree6724b533ec950e6dbdd4a6dcd6fafe665aec11e1 /sca-cpp
parent6f0a80fbc621b205f4e1e222a453087006cce668 (diff)
Added timing functions to measure performance, removed unused cache support, refactored and removed some obsolete tests and adjusted build.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@893937 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r--sca-cpp/trunk/components/cache/mcache-client-test.cpp55
-rw-r--r--sca-cpp/trunk/components/cache/mcache-test.cpp40
-rw-r--r--sca-cpp/trunk/configure.ac9
-rw-r--r--sca-cpp/trunk/kernel/Makefile.am18
-rw-r--r--sca-cpp/trunk/kernel/cache-test.cpp79
-rw-r--r--sca-cpp/trunk/kernel/cache.hpp160
-rwxr-xr-xsca-cpp/trunk/kernel/diskcache-test27
-rw-r--r--sca-cpp/trunk/kernel/parallel-test.cpp151
-rw-r--r--sca-cpp/trunk/kernel/perf.hpp68
-rw-r--r--sca-cpp/trunk/kernel/xml-test.cpp165
-rw-r--r--sca-cpp/trunk/modules/http/curl-test.cpp40
-rw-r--r--sca-cpp/trunk/modules/server/Makefile.am9
-rw-r--r--sca-cpp/trunk/modules/server/client-test.cpp205
-rw-r--r--sca-cpp/trunk/test/Makefile.am2
-rw-r--r--sca-cpp/trunk/test/store-function/Makefile.am28
-rw-r--r--sca-cpp/trunk/test/store-function/cart.hpp69
-rw-r--r--sca-cpp/trunk/test/store-function/catalog.hpp54
-rw-r--r--sca-cpp/trunk/test/store-function/catalogs.composite43
-rw-r--r--sca-cpp/trunk/test/store-function/currency-composite.hpp37
-rw-r--r--sca-cpp/trunk/test/store-function/currency.composite32
-rw-r--r--sca-cpp/trunk/test/store-function/currency.hpp59
-rw-r--r--sca-cpp/trunk/test/store-function/item.hpp54
-rw-r--r--sca-cpp/trunk/test/store-function/service.hpp35
-rw-r--r--sca-cpp/trunk/test/store-function/store-composite.hpp47
-rw-r--r--sca-cpp/trunk/test/store-function/store-function-test.cpp50
-rw-r--r--sca-cpp/trunk/test/store-function/store-solution.hpp41
-rw-r--r--sca-cpp/trunk/test/store-function/store-ui.hpp64
-rw-r--r--sca-cpp/trunk/test/store-function/store.composite64
-rw-r--r--sca-cpp/trunk/test/store-object/Makefile.am28
-rw-r--r--sca-cpp/trunk/test/store-object/cart.hpp74
-rw-r--r--sca-cpp/trunk/test/store-object/catalog.hpp65
-rw-r--r--sca-cpp/trunk/test/store-object/catalogs.composite43
-rw-r--r--sca-cpp/trunk/test/store-object/currency-composite.hpp51
-rw-r--r--sca-cpp/trunk/test/store-object/currency.composite32
-rw-r--r--sca-cpp/trunk/test/store-object/currency.hpp60
-rw-r--r--sca-cpp/trunk/test/store-object/item.hpp47
-rw-r--r--sca-cpp/trunk/test/store-object/store-composite.hpp68
-rw-r--r--sca-cpp/trunk/test/store-object/store-object-test.cpp52
-rw-r--r--sca-cpp/trunk/test/store-object/store-solution.hpp62
-rw-r--r--sca-cpp/trunk/test/store-object/store-ui.hpp72
-rw-r--r--sca-cpp/trunk/test/store-object/store.composite64
41 files changed, 561 insertions, 1862 deletions
diff --git a/sca-cpp/trunk/components/cache/mcache-client-test.cpp b/sca-cpp/trunk/components/cache/mcache-client-test.cpp
index 0a560bc05f..2e444250c7 100644
--- a/sca-cpp/trunk/components/cache/mcache-client-test.cpp
+++ b/sca-cpp/trunk/components/cache/mcache-client-test.cpp
@@ -24,14 +24,13 @@
*/
#include <assert.h>
-#include <sys/time.h>
-#include <time.h>
#include <iostream>
#include <string>
#include "list.hpp"
#include "value.hpp"
#include "monad.hpp"
+#include "perf.hpp"
#include "../../modules/http/curl.hpp"
namespace tuscany {
@@ -83,43 +82,33 @@ bool testCache() {
return true;
}
-const double duration(struct timeval start, struct timeval end, int count) {
- long t = (end.tv_sec * 1000 + end.tv_usec / 1000) - (start.tv_sec * 1000 + start.tv_usec / 1000);
- return (double)t / (double)count;
-}
-
-bool testGetLoop(const int count, const value& id, const value& entry, http::CURLSession& cs) {
- if (count == 0)
+struct getLoop {
+ const value id;
+ const value entry;
+ http::CURLSession cs;
+ getLoop(const value& id, const value& entry, http::CURLSession cs) : id(id), entry(entry), cs(cs) {
+ }
+ const bool operator()() const {
+ const failable<value, std::string> val = http::get(url + "/" + std::string(id), cs);
+ assert(hasContent(val));
+ assert(content(val) == entry);
return true;
- const failable<value, std::string> val = http::get(url + "/" + std::string(id), cs);
- assert(hasContent(val));
- assert(content(val) == entry);
- return testGetLoop(count - 1, id, entry, cs);
-}
+ }
+};
bool testGetPerf() {
- const int count = 50;
- struct timeval start;
- struct timeval end;
- {
- const list<value> i = list<value>()
- << (list<value>() << "name" << std::string("Apple"))
- << (list<value>() << "price" << std::string("$4.55"));
- const list<value> a = mklist<value>(std::string("item"), std::string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"), i);
-
- http::CURLSession cs;
- const failable<value, std::string> id = http::post(a, url, cs);
- assert(hasContent(id));
-
- testGetLoop(5, content(id), a, cs);
+ const list<value> i = list<value>()
+ << (list<value>() << "name" << std::string("Apple"))
+ << (list<value>() << "price" << std::string("$4.55"));
+ const value a = mklist<value>(std::string("item"), std::string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"), i);
- gettimeofday(&start, NULL);
+ http::CURLSession cs;
+ const failable<value, std::string> id = http::post(a, url, cs);
+ assert(hasContent(id));
- testGetLoop(count, content(id), a, cs);
+ const lambda<bool()> gl = getLoop(content(id), a, cs);
+ std::cout << "Cache get test " << time(gl, 5, 200) << " ms" << std::endl;
- gettimeofday(&end, NULL);
- std::cout << "Cache get test " << duration(start, end, count) << " ms" << std::endl;
- }
return true;
}
diff --git a/sca-cpp/trunk/components/cache/mcache-test.cpp b/sca-cpp/trunk/components/cache/mcache-test.cpp
index 78f0da0465..dc286687c0 100644
--- a/sca-cpp/trunk/components/cache/mcache-test.cpp
+++ b/sca-cpp/trunk/components/cache/mcache-test.cpp
@@ -24,11 +24,9 @@
*/
#include <assert.h>
-#include <sys/time.h>
-#include <time.h>
#include <iostream>
#include <string>
-#include <fstream>
+#include "perf.hpp"
#include "mcache.hpp"
namespace tuscany {
@@ -47,35 +45,23 @@ bool testMemCached() {
return true;
}
-const double duration(struct timeval start, struct timeval end, int count) {
- long t = (end.tv_sec * 1000 + end.tv_usec / 1000) - (start.tv_sec * 1000 + start.tv_usec / 1000);
- return (double)t / (double)count;
-}
-
-bool testGetLoop(const int count, MemCached& ch) {
- if (count == 0)
+struct getLoop {
+ MemCached& ch;
+ getLoop(MemCached& ch) : ch(ch) {
+ }
+ const bool operator()() const {
+ assert(get("c", ch) == value(std::string("CCC")));
return true;
- assert(get("c", ch) == value(std::string("CCC")));
- return testGetLoop(count - 1, ch);
-}
+ }
+};
bool testGetPerf() {
- const int count = 50;
- struct timeval start;
- struct timeval end;
- {
- MemCached ch;
- assert(hasContent(post("c", std::string("CCC"), ch)));
-
- testGetLoop(5, ch);
-
- gettimeofday(&start, NULL);
+ MemCached ch;
+ assert(hasContent(post("c", std::string("CCC"), ch)));
- testGetLoop(count, ch);
+ const lambda<bool()> gl = getLoop(ch);
+ std::cout << "Memcached get test " << time(gl, 5, 200) << " ms" << std::endl;
- gettimeofday(&end, NULL);
- std::cout << "Memcached get test " << duration(start, end, count) << " ms" << std::endl;
- }
return true;
}
diff --git a/sca-cpp/trunk/configure.ac b/sca-cpp/trunk/configure.ac
index ada22c92e7..1452d7164c 100644
--- a/sca-cpp/trunk/configure.ac
+++ b/sca-cpp/trunk/configure.ac
@@ -172,10 +172,11 @@ AC_ARG_ENABLE(maintainer-mode, [AS_HELP_STRING([--enable-maintainer-mode], [comp
esac ],
[ AC_MSG_RESULT(no)])
if test "$want_maintainer_mode" = "true"; then
- AC_SUBST([CXXFLAGS], ["-D_DEBUG -O0 -g3 -pg -Wall -Wextra -Wno-ignored-qualifiers -Winit-self -Wmissing-include-dirs -Wcast-qual -Wcast-align -Wwrite-strings -Wpointer-arith -Wconversion -Waddress -Wlogical-op -Wredundant-decls -std=c++0x -fmessage-length=0"])
- AC_SUBST([LDFLAGS], ["${LDFLAGS} -pg"])
+ AC_SUBST([CXXFLAGS], [" -D_REENTRANT -D_DEBUG -O0 -g3 -pg -Werror -Wall -Wextra -Wno-ignored-qualifiers -Winit-self -Wmissing-include-dirs -Wcast-qual -Wcast-align -Wwrite-strings -Wpointer-arith -Wconversion -Waddress -Wlogical-op -Wredundant-decls -std=c++0x -fmessage-length=0"])
+ AC_SUBST([LDFLAGS], ["${LDFLAGS} -lpthread -pg"])
else
- AC_SUBST([CXXFLAGS], ["-O3 -std=c++0x -fmessage-length=0"])
+ AC_SUBST([CXXFLAGS], [" -D_REENTRANT -O3 -std=c++0x -fmessage-length=0"])
+ AC_SUBST([LDFLAGS], ["${LDFLAGS} -lpthread -pg"])
fi
# Configure exuberant ctags
@@ -222,8 +223,6 @@ AC_CONFIG_FILES([Makefile
components/store/Makefile
samples/Makefile
test/Makefile
- test/store-object/Makefile
- test/store-function/Makefile
test/store-script/Makefile
doc/Makefile
doc/Doxyfile
diff --git a/sca-cpp/trunk/kernel/Makefile.am b/sca-cpp/trunk/kernel/Makefile.am
index bfaeb2ce9b..4dfc285e90 100644
--- a/sca-cpp/trunk/kernel/Makefile.am
+++ b/sca-cpp/trunk/kernel/Makefile.am
@@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.
-noinst_PROGRAMS = kernel-test cache-test xsd-test
+noinst_PROGRAMS = kernel-test parallel-test xml-test xsd-test
testdir=$(prefix)/test
test_LTLIBRARIES = libdynlib-test.la
@@ -26,18 +26,18 @@ include_HEADERS = *.hpp
INCLUDES = -I. -I$(top_builddir)/kernel -I${LIBXML2_INCLUDE} -I${APR_INCLUDE}
kernel_test_SOURCES = kernel-test.cpp
-kernel_test_CXXFLAGS = $(CXXFLAGS) -D_REENTRANT
-kernel_test_LDADD = -lpthread -L${LIBXML2_LIB} -lxml2 -L${APR_LIB} -lapr-1 -laprutil-1
+kernel_test_LDADD = -L${LIBXML2_LIB} -lxml2 -L${APR_LIB} -lapr-1 -laprutil-1
libdynlib_test_la_SOURCES = dynlib-test.cpp
-libdynlib_test_la_CXXFLAGS = $(CXXFLAGS) -D_REENTRANT
-libdynlib_test_la_LIBADD = -lpthread -L${APR_LIB} -lapr-1 -laprutil-1
+libdynlib_test_la_LIBADD = -L${APR_LIB} -lapr-1 -laprutil-1
-cache_test_SOURCES = cache-test.cpp
-cache_test_LDADD = -L${LIBXML2_LIB} -lxml2 -L${APR_LIB} -lapr-1 -laprutil-1
+parallel_test_SOURCES = parallel-test.cpp
+parallel_test_LDADD = -L${LIBXML2_LIB} -lxml2 -L${APR_LIB} -lapr-1 -laprutil-1
+
+xml_test_SOURCES = xml-test.cpp
+xml_test_LDADD = -L${LIBXML2_LIB} -lxml2 -L${APR_LIB} -lapr-1 -laprutil-1
xsd_test_SOURCES = xsd-test.cpp
xsd_test_LDADD = -L${LIBXML2_LIB} -lxml2 -L${APR_LIB} -lapr-1 -laprutil-1
-TESTS = kernel-test diskcache-test
-
+TESTS = kernel-test parallel-test xml-test
diff --git a/sca-cpp/trunk/kernel/cache-test.cpp b/sca-cpp/trunk/kernel/cache-test.cpp
deleted file mode 100644
index 5391d38cf6..0000000000
--- a/sca-cpp/trunk/kernel/cache-test.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * 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.
- */
-
-/* $Rev$ $Date$ */
-
-/**
- * Test cache functions.
- */
-
-#include <assert.h>
-#include <sys/time.h>
-#include <time.h>
-#include <iostream>
-#include <string>
-#include <fstream>
-#include "slist.hpp"
-#include "cache.hpp"
-
-namespace tuscany {
-
-const std::string fileRead(const std::string path) {
- std::ifstream is(path);
- return car(streamList(is));
-}
-
-bool testCache() {
- const std::string p("tmp/test.txt");
- const lambda<std::string(std::string)> fr(fileRead);
- const lambda<time_t(std::string)> ft(latestFileTime);
-
- const cached<std::string> c(curry(fr, p), curry(ft, p));
-
- {
- std::ofstream os(p);
- os << "initial";
- os.close();
- assert(content(latest(c)) == std::string("initial"));
- }
-
- usleep(1000000);
-
- {
- std::ofstream os(p);
- os << "updated";
- os.close();
- assert(latest(c) != c);
- assert(content(latest(c)) == std::string("updated"));
- assert(latest(c) == latest(c));
- }
- return true;
-}
-
-}
-
-int main() {
- std::cout << "Testing..." << std::endl;
-
- tuscany::testCache();
-
- std::cout << "OK" << std::endl;
-
- return 0;
-}
diff --git a/sca-cpp/trunk/kernel/cache.hpp b/sca-cpp/trunk/kernel/cache.hpp
deleted file mode 100644
index 4cab4e4e9b..0000000000
--- a/sca-cpp/trunk/kernel/cache.hpp
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * 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.
- */
-
-/* $Rev$ $Date$ */
-
-#ifndef tuscany_cache_hpp
-#define tuscany_cache_hpp
-
-/**
- * Simple local cache monad implementation.
- */
-
-#ifdef _REENTRANT
-#include <pthread.h>
-#endif
-#include <sys/stat.h>
-
-#include <string>
-#include "value.hpp"
-#include "monad.hpp"
-
-namespace tuscany {
-
-/**
- * Cached monad. Used to represent a value that can be cached.
- * To get the value in the monad, just cast it to the value type.
- */
-template<typename V> class cached {
-public:
- cached() : mutex(mutex_init()), mtime(0) {
- }
-
- cached(const lambda<V()>& lvalue, const lambda<unsigned long()> ltime) : mutex(mutex_init()), lvalue(lvalue), ltime(ltime), mtime(0) {
- }
-
- cached(const lambda<V()>& lvalue, const lambda<unsigned long()> ltime, const unsigned long mtime, const V& v) : mutex(mutex_init()), lvalue(lvalue), ltime(ltime), mtime(mtime), v(v) {
- }
-
- cached(const cached<V>& c) : mutex(mutex_init()), lvalue(c.lvalue), ltime(c.ltime), mtime(c.mtime), v(c.v) {
- }
-
- ~cached() {
-#ifdef _REENTRANT
- pthread_mutex_destroy(mutex);
-#endif
- }
-
- const cached<V>& operator=(const cached<V>& c) {
- if(this == &c)
- return *this;
-#ifdef _REENTRANT
- pthread_mutex_lock(mutex);
-#endif
- this->lvalue = c.lvalue;
- this->ltime = c.ltime;
- this->mtime = c.mtime;
- this->v = c.v;
-#ifdef _REENTRANT
- pthread_mutex_unlock(mutex);
-#endif
- return *this;
- }
-
- const bool operator!=(const cached<V>& m) const {
- return !this->operator==(m);
- }
-
- const bool operator==(const cached<V>& m) const {
- if (this == &m)
- return true;
-#ifdef _REENTRANT
- pthread_mutex_lock(mutex);
-#endif
- const bool r = mtime == m.mtime && v == m.v;
-#ifdef _REENTRANT
- pthread_mutex_unlock(mutex);
-#endif
- return r;
- }
-
-private:
-#ifdef _REENTRANT
- pthread_mutex_t* mutex;
- pthread_mutex_t* mutex_init() {
- pthread_mutex_t* mx = new pthread_mutex_t();
- pthread_mutex_init(mx, NULL);
- return mx;
- }
-#else
- void* mutex;
- void* mutex_init() {
- return NULL;
- }
-#endif
-
- lambda<V()> lvalue;
- lambda<time_t()> ltime;
- unsigned long mtime;
- V v;
-
- template<typename X> friend const cached<X> latest(const cached<X>& c);
- template<typename X> friend const X content(const cached<X>& c);
- template<typename X> friend std::ostream& operator<<(std::ostream& out, const cached<X>& c);
-};
-
-/**
- * Write a cached monad to a stream.
- */
-template<typename V> std::ostream& operator<<(std::ostream& out, const cached<V>& c) {
- out << c.v;
- return out;
-}
-
-/**
- * Returns the latest value of a cached monad.
- */
-template<typename V> const cached<V> latest(const cached<V>& c) {
- unsigned long nt = c.ltime();
- if (nt == c.mtime)
- return c;
- return cached<V>(c.lvalue, c.ltime, nt, c.lvalue());
-}
-
-/**
- * Returns the content of a cached monad.
- */
-template<typename V> const V content(const cached<V>& c) {
- return c.v;
-}
-
-/**
- * Returns the latest modification time of a file.
- */
-const unsigned long latestFileTime(const std::string& path) {
- struct stat st;
- int rc = stat(path.c_str(), &st);
- if (rc < 0)
- return 0;
- return st.st_mtim.tv_nsec;
-}
-
-}
-
-#endif /* tuscany_cache_hpp */
diff --git a/sca-cpp/trunk/kernel/diskcache-test b/sca-cpp/trunk/kernel/diskcache-test
deleted file mode 100755
index dfcc177496..0000000000
--- a/sca-cpp/trunk/kernel/diskcache-test
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/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.
-
-# Setup
-mkdir -p tmp
-
-# Test
-./cache-test
-rc=$?
-
-return $rc
diff --git a/sca-cpp/trunk/kernel/parallel-test.cpp b/sca-cpp/trunk/kernel/parallel-test.cpp
new file mode 100644
index 0000000000..8ae2eeed2c
--- /dev/null
+++ b/sca-cpp/trunk/kernel/parallel-test.cpp
@@ -0,0 +1,151 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+/**
+ * Test parallel functions.
+ */
+
+#include <assert.h>
+#include <iostream>
+#include <string>
+#include "function.hpp"
+#include "list.hpp"
+#include "perf.hpp"
+#include "parallel.hpp"
+
+namespace tuscany {
+
+int inci = 0;
+
+struct incPerf {
+ incPerf() {
+ }
+ const bool operator()() const {
+ inci = inci + 1;
+ return true;
+ }
+};
+
+int addi = 0;
+
+struct addAndFetchPerf {
+ addAndFetchPerf() {
+ }
+ const bool operator()() const {
+ __sync_add_and_fetch(&addi, 1);
+ return true;
+ }
+};
+
+int muxi = 0;
+
+struct mutexPerf {
+ pthread_mutex_t* mutex;
+ mutexPerf(pthread_mutex_t* mutex) : mutex(mutex) {
+ }
+ const bool operator()() const {
+ pthread_mutex_lock(mutex);
+ muxi = muxi + 1;
+ pthread_mutex_unlock(mutex);
+ return true;
+ }
+};
+
+__thread int tlsi = 0;
+
+struct tlsPerf {
+ tlsPerf() {
+ }
+ const bool operator()() const {
+ tlsi = tlsi + 1;
+ return true;
+ }
+};
+
+bool testAtomicPerf() {
+ const int count = 100000;
+ {
+ const lambda<bool()> l = incPerf();
+ std::cout << "Non-atomic inc test " << time(l, 1000, count) << " ms" << std::endl;
+ assert(inci == count + 1000);
+ }
+ {
+ const lambda<bool()> l = addAndFetchPerf();
+ std::cout << "Atomic inc test " << time(l, 1000, count) << " ms" << std::endl;
+ assert(addi == count + 1000);
+ }
+ {
+ pthread_mutex_t mutex;
+ pthread_mutex_init(&mutex, NULL);
+ const lambda<bool()> l = mutexPerf(&mutex);
+ std::cout << "Locked inc test " << time(l, 1000, count) << " ms" << std::endl;
+ assert(muxi == count + 1000);
+ pthread_mutex_destroy(&mutex);
+ }
+ {
+ const lambda<bool()> l = tlsPerf();
+ std::cout << "Thread local inc test " << time(l, 1000, count) << " ms" << std::endl;
+ assert(tlsi == count + 1000);
+ }
+ return true;
+}
+
+const int mtsquare(const int x) {
+ for(int i = 0; i < 10000000; i++)
+ ;
+ return x * x;
+}
+
+bool testWorker() {
+ worker w(10);
+ {
+ const lambda<int()> func = curry(lambda<int(const int)> (mtsquare), 2);
+ assert(submit(w, func) == 4);
+ }
+ {
+ const int max = 10;
+
+ list<future<int> > r;
+ for(int i = 0; i < max; i++) {
+ const lambda<int()> func = curry(lambda<int(const int)> (mtsquare), i);
+ r = cons(submit(w, func), r);
+ }
+ for(int i = max - 1; i >= 0; i--) {
+ assert(car(r) == i * i);
+ r = cdr(r);
+ }
+ }
+ shutdown(w);
+ return true;
+}
+
+}
+
+int main() {
+ std::cout << "Testing..." << std::endl;
+
+ tuscany::testAtomicPerf();
+ tuscany::testWorker();
+
+ std::cout << "OK" << std::endl;
+
+ return 0;
+}
diff --git a/sca-cpp/trunk/kernel/perf.hpp b/sca-cpp/trunk/kernel/perf.hpp
new file mode 100644
index 0000000000..f5004d015b
--- /dev/null
+++ b/sca-cpp/trunk/kernel/perf.hpp
@@ -0,0 +1,68 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_perf_hpp
+#define tuscany_perf_hpp
+
+/**
+ * Functions to help measure performance.
+ */
+
+#include <sys/time.h>
+#include <time.h>
+
+#include "function.hpp"
+
+namespace tuscany
+{
+
+/**
+ * Measure the time required to perform a function in msec.
+ */
+struct timeLambda {
+ const lambda<bool()> f;
+ timeLambda(const lambda<bool()>& f) : f(f) {
+ }
+ bool operator()(const long count) const {
+ if (count == 0)
+ return true;
+ f();
+ (*this)(count - 1);
+ return true;
+ }
+};
+
+const double time(const lambda<bool()>& f, const long warmup, const long count) {
+ const lambda<bool(long)> tl = timeLambda(f);
+ struct timeval start;
+ struct timeval end;
+
+ tl(warmup);
+ gettimeofday(&start, NULL);
+ tl(count);
+ gettimeofday(&end, NULL);
+
+ const long t = (end.tv_sec * 1000 + end.tv_usec / 1000) - (start.tv_sec * 1000 + start.tv_usec / 1000);
+ return (double)t / (double)count;
+}
+
+}
+#endif /* tuscany_perf_hpp */
diff --git a/sca-cpp/trunk/kernel/xml-test.cpp b/sca-cpp/trunk/kernel/xml-test.cpp
new file mode 100644
index 0000000000..88c476ffef
--- /dev/null
+++ b/sca-cpp/trunk/kernel/xml-test.cpp
@@ -0,0 +1,165 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+/**
+ * Test XML handling functions.
+ */
+
+#include <assert.h>
+#include <iostream>
+#include <string>
+#include <sstream>
+#include "list.hpp"
+#include "value.hpp"
+#include "element.hpp"
+#include "xml.hpp"
+
+namespace tuscany {
+
+const std::string currencyXML =
+"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+"<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200903\" "
+"xmlns:t=\"http://tuscany.apache.org/xmlns/sca/1.1\" "
+"targetNamespace=\"http://services\" "
+"name=\"currency\">"
+"<component name=\"CurrencyConverterWebService\">"
+"<implementation.java class=\"services.CurrencyConverterImpl\"/>"
+"<service name=\"CurrencyConverter\">"
+"<binding.ws/>"
+"</service>"
+"</component>"
+"<component name=\"CurrencyConverterWebService2\">"
+"<implementation.java class=\"services.CurrencyConverterImpl2\"/>"
+"<service name=\"CurrencyConverter2\">"
+"<binding.atom/>"
+"</service>"
+"<property name=\"currency\">US</property>"
+"</component>"
+"</composite>"
+"\n";
+
+const std::string customerXML =
+"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+"<customer>"
+"<name>jdoe</name>"
+"<address><city>san francisco</city><state>ca</state></address>"
+"<account><id>1234</id><balance>1000</balance></account>"
+"<account><id>6789</id><balance>2000</balance></account>"
+"<account><id>4567</id><balance>3000</balance></account>"
+"</customer>"
+"\n";
+
+
+const bool isName(const value& token) {
+ return isTaggedList(token, attribute) && attributeName(token) == "name";
+}
+
+bool testReadXML() {
+ {
+ std::istringstream is(customerXML);
+ const list<value> c = readXML(streamList(is));
+ }
+ {
+ std::istringstream is(currencyXML);
+ const list<value> c = readXML(streamList(is));
+
+ const value composite = car(c);
+ assert(isTaggedList(composite, element));
+ assert(elementName(composite) == "composite");
+ assert(attributeValue(car(filter<value>(isName, elementChildren(composite)))) == std::string("currency"));
+ }
+ return true;
+}
+
+std::ostringstream* xmlWriter(const std::string& s, std::ostringstream* os) {
+ (*os) << s;
+ return os;
+}
+
+bool testWriteXML() {
+ {
+ std::istringstream is(customerXML);
+ const list<value> c = readXML(streamList(is));
+ std::ostringstream os;
+ writeXML<std::ostringstream*>(xmlWriter, &os, c);
+ assert(os.str() == customerXML);
+ }
+ {
+ std::istringstream is(currencyXML);
+ const list<value> c = readXML(streamList(is));
+ std::ostringstream os;
+ writeXML<std::ostringstream*>(xmlWriter, &os, c);
+ assert(os.str() == currencyXML);
+ }
+ return true;
+}
+
+bool testElement() {
+ {
+ const list<value> ad = mklist<value>(mklist<value>("city", std::string("san francisco")), mklist<value>("state", std::string("ca")));
+ const list<value> ac1 = mklist<value>(mklist<value>("id", std::string("1234")), mklist<value>("balance", 1000));
+ const list<value> ac2 = mklist<value>(mklist<value>("id", std::string("6789")), mklist<value>("balance", 2000));
+ const list<value> ac3 = mklist<value>(mklist<value>("id", std::string("4567")), mklist<value>("balance", 3000));
+ {
+ const list<value> c = mklist<value>(mklist<value>("customer", mklist<value>("name", std::string("jdoe")), cons<value>("address", ad), mklist<value>("account", mklist<value>(ac1, ac2, ac3))));
+ const list<value> e = valuesToElements(c);
+ const list<value> v = elementsToValues(e);
+ assert(v == c);
+
+ std::ostringstream os;
+ writeXML<std::ostringstream*>(xmlWriter, &os, e);
+ assert(os.str() == customerXML);
+ }
+ {
+ const list<value> c = mklist<value>(mklist<value>("customer", mklist<value>("name", std::string("jdoe")), cons<value>("address", ad), cons<value>("account", ac1), cons<value>("account", ac2), cons<value>("account", ac3)));
+ const list<value> e = valuesToElements(c);
+ const list<value> v = elementsToValues(e);
+
+ std::ostringstream os;
+ writeXML<std::ostringstream*>(xmlWriter, &os, e);
+ assert(os.str() == customerXML);
+ }
+ }
+ {
+ std::istringstream is(customerXML);
+ const list<value> c = readXML(streamList(is));
+ const list<value> v = elementsToValues(c);
+ const list<value> e = valuesToElements(v);
+ std::ostringstream os;
+ writeXML<std::ostringstream*>(xmlWriter, &os, e);
+ assert(os.str() == customerXML);
+ }
+ return true;
+}
+
+}
+
+int main() {
+ std::cout << "Testing..." << std::endl;
+
+ tuscany::testReadXML();
+ tuscany::testWriteXML();
+ tuscany::testElement();
+
+ std::cout << "OK" << std::endl;
+
+ return 0;
+}
diff --git a/sca-cpp/trunk/modules/http/curl-test.cpp b/sca-cpp/trunk/modules/http/curl-test.cpp
index 59944546a1..01355dd429 100644
--- a/sca-cpp/trunk/modules/http/curl-test.cpp
+++ b/sca-cpp/trunk/modules/http/curl-test.cpp
@@ -24,12 +24,11 @@
*/
#include <assert.h>
-#include <sys/time.h>
-#include <time.h>
#include <iostream>
#include <sstream>
#include <string>
#include "slist.hpp"
+#include "perf.hpp"
#include "curl.hpp"
namespace tuscany {
@@ -39,11 +38,6 @@ const bool contains(const std::string& str, const std::string& pattern) {
return str.find(pattern) != str.npos;
}
-const double duration(struct timeval start, struct timeval end, int count) {
- long t = (end.tv_sec * 1000 + end.tv_usec / 1000) - (start.tv_sec * 1000 + start.tv_usec / 1000);
- return (double)t / (double)count;
-}
-
std::ostringstream* curlWriter(const std::string& s, std::ostringstream* os) {
(*os) << s;
return os;
@@ -66,30 +60,22 @@ const bool testGet() {
return true;
}
-const bool testGetLoop(const int count, CURLSession& ch) {
- if (count == 0)
+struct getLoop {
+ CURLSession& ch;
+ getLoop(CURLSession& ch) : ch(ch) {
+ }
+ const bool operator()() const {
+ const failable<value, std::string> r = get("http://localhost:8090", ch);
+ assert(hasContent(r));
+ assert(contains(content(r), "It works"));
return true;
- const failable<value, std::string> r = get("http://localhost:8090", ch);
- assert(hasContent(r));
- assert(contains(content(r), "It works"));
- return testGetLoop(count - 1, ch);
-}
+ }
+};
const bool testGetPerf() {
- const int count = 50;
CURLSession ch;
- struct timeval start;
- struct timeval end;
- {
- testGetLoop(5, ch);
-
- gettimeofday(&start, NULL);
-
- testGetLoop(count, ch);
-
- gettimeofday(&end, NULL);
- std::cout << "Static GET test " << duration(start, end, count) << " ms" << std::endl;
- }
+ lambda<bool()> gl = getLoop(ch);
+ std::cout << "Static GET test " << time(gl, 5, 200) << " ms" << std::endl;
return true;
}
diff --git a/sca-cpp/trunk/modules/server/Makefile.am b/sca-cpp/trunk/modules/server/Makefile.am
index 0740790ad1..9e28d8602e 100644
--- a/sca-cpp/trunk/modules/server/Makefile.am
+++ b/sca-cpp/trunk/modules/server/Makefile.am
@@ -23,19 +23,16 @@ lib_LTLIBRARIES = libmod_tuscany_eval.la libmod_tuscany_wiring.la
INCLUDES = -I. -I$(top_builddir)/kernel -I${LIBXML2_INCLUDE} -I${HTTPD_INCLUDE} -I${APR_INCLUDE} -I${JS_INCLUDE} -I${CURL_INCLUDE}
libmod_tuscany_eval_la_SOURCES = mod-eval.cpp
-libmod_tuscany_eval_la_CXXFLAGS = $(CXXFLAGS) -D_REENTRANT
-libmod_tuscany_eval_la_LIBADD = -lpthread -L${LIBXML2_LIB} -lxml2 -L${APR_LIB} -lapr-1 -laprutil-1 -L${CURL_LIB} -lcurl -L${JS_LIB} -lmozjs
+libmod_tuscany_eval_la_LIBADD = -L${LIBXML2_LIB} -lxml2 -L${APR_LIB} -lapr-1 -laprutil-1 -L${CURL_LIB} -lcurl -L${JS_LIB} -lmozjs
libmod_tuscany_wiring_la_SOURCES = mod-wiring.cpp
-libmod_tuscany_wiring_la_CXXFLAGS = $(CXXFLAGS) -D_REENTRANT
-libmod_tuscany_wiring_la_LIBADD = -lpthread -L${LIBXML2_LIB} -lxml2 -L${APR_LIB} -lapr-1 -laprutil-1 -L${CURL_LIB} -lcurl -L${JS_LIB} -lmozjs
+libmod_tuscany_wiring_la_LIBADD = -L${LIBXML2_LIB} -lxml2 -L${APR_LIB} -lapr-1 -laprutil-1 -L${CURL_LIB} -lcurl -L${JS_LIB} -lmozjs
testdir=$(prefix)/test
test_LTLIBRARIES = libimpl-test.la
libimpl_test_la_SOURCES = impl-test.cpp
-libimpl_test_la_CXXFLAGS = $(CXXFLAGS) -D_REENTRANT
-libimpl_test_la_LIBADD = -lpthread -L${APR_LIB} -lapr-1 -laprutil-1
+libimpl_test_la_LIBADD = -L${APR_LIB} -lapr-1 -laprutil-1
client_test_SOURCES = client-test.cpp
client_test_LDADD = -L${LIBXML2_LIB} -lxml2 -L${APR_LIB} -lapr-1 -laprutil-1 -L${CURL_LIB} -lcurl -L${JS_LIB} -lmozjs
diff --git a/sca-cpp/trunk/modules/server/client-test.cpp b/sca-cpp/trunk/modules/server/client-test.cpp
index 5888c481e3..496d67f59c 100644
--- a/sca-cpp/trunk/modules/server/client-test.cpp
+++ b/sca-cpp/trunk/modules/server/client-test.cpp
@@ -24,12 +24,12 @@
*/
#include <assert.h>
-#include <sys/time.h>
-#include <time.h>
#include <iostream>
#include <sstream>
#include <string>
#include "slist.hpp"
+#include "parallel.hpp"
+#include "perf.hpp"
#include "../http/curl.hpp"
namespace tuscany {
@@ -39,11 +39,6 @@ const bool contains(const std::string& str, const std::string& pattern) {
return str.find(pattern) != str.npos;
}
-const double duration(struct timeval start, struct timeval end, int count) {
- long t = (end.tv_sec * 1000 + end.tv_usec / 1000) - (start.tv_sec * 1000 + start.tv_usec / 1000);
- return (double)t / (double)count;
-}
-
std::ostringstream* curlWriter(const std::string& s, std::ostringstream* os) {
(*os) << s;
return os;
@@ -66,27 +61,22 @@ const bool testGet() {
return true;
}
-const bool testGetLoop(const int count, http::CURLSession& ch) {
- if (count == 0)
+struct getLoop {
+ http::CURLSession ch;
+ getLoop(http::CURLSession& ch) : ch(ch) {
+ }
+ const bool operator()() const {
+ const failable<value, std::string> r = get("http://localhost:8090", ch);
+ assert(hasContent(r));
+ assert(contains(content(r), "It works"));
return true;
- const failable<value, std::string> r = get("http://localhost:8090", ch);
- assert(hasContent(r));
- assert(contains(content(r), "It works"));
- return testGetLoop(count - 1, ch);
-}
+ }
+};
const bool testGetPerf() {
- const int count = 50;
http::CURLSession ch;
- struct timeval start;
- struct timeval end;
- {
- testGetLoop(5, ch);
- gettimeofday(&start, NULL);
- testGetLoop(count, ch);
- gettimeofday(&end, NULL);
- std::cout << "Static GET test " << duration(start, end, count) << " ms" << std::endl;
- }
+ const lambda<bool()> gl = getLoop(ch);
+ std::cout << "Static GET test " << time(gl, 5, 200) << " ms" << std::endl;
return true;
}
@@ -97,48 +87,37 @@ const bool testEval() {
return true;
}
-const bool testEvalLoop(const int count, http::CURLSession& ch) {
- if (count == 0)
+struct evalLoop {
+ http::CURLSession ch;
+ evalLoop(http::CURLSession& ch) : ch(ch) {
+ }
+ const bool operator()() const {
+ const value val = content(http::evalExpr(mklist<value>(std::string("echo"), std::string("Hello")), "http://localhost:8090/test", ch));
+ assert(val == std::string("Hello"));
return true;
- const value val = content(http::evalExpr(mklist<value>(std::string("echo"), std::string("Hello")), "http://localhost:8090/test", ch));
- assert(val == std::string("Hello"));
- return testEvalLoop(count - 1, ch);
-}
+ }
+};
const value blob(std::string(3000, 'A'));
const list<value> blobs = mklist(blob, blob, blob, blob, blob);
-const bool testBlobEvalLoop(const int count, http::CURLSession& ch) {
- if (count == 0)
- return true;
- const value val = content(http::evalExpr(mklist<value>(std::string("echo"), blobs), "http://localhost:8090/test", ch));
- assert(val == blobs);
- return testBlobEvalLoop(count - 1, ch);
-}
-
-const bool testEvalPerf() {
- const int count = 50;
+struct blobEvalLoop {
http::CURLSession ch;
- struct timeval start;
- struct timeval end;
- {
- testEvalLoop(5, ch);
- gettimeofday(&start, NULL);
- testEvalLoop(count, ch);
- gettimeofday(&end, NULL);
- std::cout << "JSON-RPC eval echo test " << duration(start, end, count) << " ms" << std::endl;
+ blobEvalLoop(http::CURLSession& ch) : ch(ch) {
}
- {
- testBlobEvalLoop(5, ch);
- gettimeofday(&start, NULL);
- testBlobEvalLoop(count, ch);
- gettimeofday(&end, NULL);
- std::cout << "JSON-RPC eval blob test " << duration(start, end, count) << " ms" << std::endl;
+ const bool operator()() const {
+ const value val = content(http::evalExpr(mklist<value>(std::string("echo"), blobs), "http://localhost:8090/test", ch));
+ assert(val == blobs);
+ return true;
}
- return true;
-}
+};
-const bool testFeed() {
+const bool testEvalPerf() {
+ http::CURLSession ch;
+ const lambda<bool()> el = evalLoop(ch);
+ std::cout << "JSON-RPC eval echo test " << time(el, 5, 200) << " ms" << std::endl;
+ const lambda<bool()> bel = blobEvalLoop(ch);
+ std::cout << "JSON-RPC eval blob test " << time(bel, 5, 200) << " ms" << std::endl;
return true;
}
@@ -153,29 +132,27 @@ bool testPost() {
return true;
}
-const bool testPostLoop(const int count, const value& val, http::CURLSession& ch) {
- if (count == 0)
+struct postLoop {
+ const value val;
+ http::CURLSession ch;
+ postLoop(const value& val, http::CURLSession& ch) : val(val), ch(ch) {
+ }
+ const bool operator()() const {
+ const failable<value, std::string> id = http::post(val, "http://localhost:8090/test", ch);
+ assert(hasContent(id));
return true;
- const failable<value, std::string> id = http::post(val, "http://localhost:8090/test", ch);
- assert(hasContent(id));
- return testPostLoop(count - 1, val, ch);
-}
+ }
+};
const bool testPostPerf() {
- const int count = 50;
http::CURLSession ch;
- struct timeval start;
- struct timeval end;
{
const list<value> i = list<value>()
<< (list<value>() << "name" << std::string("Apple"))
<< (list<value>() << "price" << std::string("$2.99"));
const list<value> val = mklist<value>(std::string("item"), std::string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"), i);
- testPostLoop(5, val, ch);
- gettimeofday(&start, NULL);
- testPostLoop(count, val, ch);
- gettimeofday(&end, NULL);
- std::cout << "ATOMPub POST small test " << duration(start, end, count) << " ms" << std::endl;
+ const lambda<bool()> pl = postLoop(val, ch);
+ std::cout << "ATOMPub POST small test " << time(pl, 5, 200) << " ms" << std::endl;
}
{
const list<value> i = list<value>()
@@ -187,12 +164,59 @@ const bool testPostPerf() {
<< (list<value>() << "blob5" << blob)
<< (list<value>() << "price" << std::string("$2.99"));
const list<value> val = mklist<value>(std::string("item"), std::string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"), i);
- testPostLoop(5, val, ch);
- gettimeofday(&start, NULL);
- testPostLoop(count, val, ch);
- gettimeofday(&end, NULL);
- std::cout << "ATOMPub POST blob test " << duration(start, end, count) << " ms" << std::endl;
+ const lambda<bool()> pl = postLoop(val, ch);
+ std::cout << "ATOMPub POST blob test " << time(pl, 5, 200) << " ms" << std::endl;
+ }
+ return true;
+}
+
+const bool postThread(const int count, const value& val) {
+ http::CURLSession ch;
+ const lambda<bool()> pl = postLoop(val, ch);
+ time(pl, 0, count);
+ return true;
+}
+
+const list<future<bool> > startPost(worker& w, const int threads, const lambda<bool()>& l) {
+ if (threads == 0)
+ return list<future<bool> >();
+ return cons(submit(w, l), startPost(w, threads - 1, l));
+}
+
+const bool checkPost(const list<future<bool> >& r) {
+ if (isNil(r))
+ return true;
+ assert(car(r) == true);
+ return checkPost(cdr(r));
+}
+
+struct postThreadLoop {
+ const lambda<bool()> l;
+ const int threads;
+ const gc_ptr<worker> w;
+ postThreadLoop(const lambda<bool()>& l, const int threads) : l(l), threads(threads), w(new worker(threads)) {
+ }
+ const bool operator()() const {
+ list<future<bool> > r = startPost(*w, threads, l);
+ checkPost(r);
+ return true;
}
+};
+
+const bool testPostThreadPerf() {
+ const int count = 50;
+ const int threads = 10;
+
+ const list<value> i = list<value>()
+ << (list<value>() << "name" << std::string("Apple"))
+ << (list<value>() << "price" << std::string("$2.99"));
+ const value val = mklist<value>(std::string("item"), std::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()> ptl = postThreadLoop(pl, threads);
+ double t = time(ptl, 0, 1) / (threads * count);
+ std::cout << "ATOMPub POST thread test " << t << " ms" << std::endl;
+
return true;
}
@@ -221,26 +245,21 @@ const bool testEvalCpp() {
return true;
}
-const bool testEvalCppLoop(const int count, http::CURLSession& ch) {
- if (count == 0)
+struct evalCppLoop {
+ http::CURLSession ch;
+ evalCppLoop(http::CURLSession& ch) : ch(ch) {
+ }
+ const bool operator()() const {
+ const value val = content(http::evalExpr(mklist<value>(std::string("hello"), std::string("world")), "http://localhost:8090/cpp", ch));
+ assert(val == std::string("hello world"));
return true;
- const value val = content(http::evalExpr(mklist<value>(std::string("hello"), std::string("world")), "http://localhost:8090/cpp", ch));
- assert(val == std::string("hello world"));
- return testEvalCppLoop(count - 1, ch);
-}
+ }
+};
const bool testEvalCppPerf() {
- const int count = 50;
http::CURLSession ch;
- struct timeval start;
- struct timeval end;
- {
- testEvalCppLoop(5, ch);
- gettimeofday(&start, NULL);
- testEvalCppLoop(count, ch);
- gettimeofday(&end, NULL);
- std::cout << "JSON-RPC C++ eval test " << duration(start, end, count) << " ms" << std::endl;
- }
+ const lambda<bool()> el = evalCppLoop(ch);
+ std::cout << "JSON-RPC C++ eval test " << time(el, 5, 200) << " ms" << std::endl;
return true;
}
@@ -254,9 +273,9 @@ int main() {
tuscany::server::testGetPerf();
tuscany::server::testPost();
tuscany::server::testPostPerf();
+ tuscany::server::testPostThreadPerf();
tuscany::server::testEval();
tuscany::server::testEvalPerf();
- tuscany::server::testFeed();
tuscany::server::testPut();
tuscany::server::testDel();
tuscany::server::testEvalCpp();
diff --git a/sca-cpp/trunk/test/Makefile.am b/sca-cpp/trunk/test/Makefile.am
index 4a20e27139..521bf3becf 100644
--- a/sca-cpp/trunk/test/Makefile.am
+++ b/sca-cpp/trunk/test/Makefile.am
@@ -15,5 +15,5 @@
# specific language governing permissions and limitations
# under the License.
-SUBDIRS = store-object store-function store-script
+SUBDIRS = store-script
diff --git a/sca-cpp/trunk/test/store-function/Makefile.am b/sca-cpp/trunk/test/store-function/Makefile.am
deleted file mode 100644
index 7645db2273..0000000000
--- a/sca-cpp/trunk/test/store-function/Makefile.am
+++ /dev/null
@@ -1,28 +0,0 @@
-# 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.
-
-noinst_PROGRAMS = store-function-test
-
-noinst_HEADERS = *.hpp
-
-INCLUDES = -I. -I$(top_builddir)/kernel -I${LIBXML2_INCLUDE} -I${APR_INCLUDE}
-
-store_function_test_SOURCES = store-function-test.cpp
-store_function_test_LDADD = -L${LIBXML2_LIB} -lxml2 -L${APR_LIB} -lapr-1 -laprutil-1
-
-TESTS = store-function-test
-
diff --git a/sca-cpp/trunk/test/store-function/cart.hpp b/sca-cpp/trunk/test/store-function/cart.hpp
deleted file mode 100644
index 9ed6474985..0000000000
--- a/sca-cpp/trunk/test/store-function/cart.hpp
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * 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.
- */
-
-/* $Rev$ $Date$ */
-
-#ifndef tuscany_cart_hpp
-#define tuscany_cart_hpp
-
-#include <string>
-#include "service.hpp"
-#include "item.hpp"
-
-namespace store
-{
-
-const double accumTotal(const double total, const ItemType& item) {
- return total + itemPrice(item);
-}
-
-tuscany::list<ItemType> cart;
-
-const tuscany::list<ItemType> shoppingCart_getAll() {
- return cart;
-}
-
-const bool shoppingCart_post(const ItemType& item) {
- cart = cons(item, cart);
- return true;
-}
-
-const bool shoppingCart_deleteAll() {
- cart = tuscany::list<ItemType>();
- return true;
-}
-
-const double shoppingCart_getTotal() {
- return tuscany::reduce<ItemType, double>(accumTotal, 0.0, cart);
-}
-
-const tuscany::value shoppingCart_service(const tuscany::list<tuscany::value>& args) {
- if (car(args) == "getAll")
- return shoppingCart_getAll();
- if (car(args) == "post")
- return shoppingCart_post(cadr(args));
- if (car(args) == "deleteAll")
- return shoppingCart_deleteAll();
- if (car(args) == "getTotal")
- return shoppingCart_getTotal();
- return tuscany::value();
-}
-
-}
-#endif /* tuscany_cart_hpp */
diff --git a/sca-cpp/trunk/test/store-function/catalog.hpp b/sca-cpp/trunk/test/store-function/catalog.hpp
deleted file mode 100644
index c49ebc8fa3..0000000000
--- a/sca-cpp/trunk/test/store-function/catalog.hpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * 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.
- */
-
-/* $Rev$ $Date$ */
-
-#ifndef tuscany_catalog_hpp
-#define tuscany_catalog_hpp
-
-#include <string>
-#include "service.hpp"
-#include "currency.hpp"
-#include "item.hpp"
-
-namespace store
-{
-
-std::string catalog_currencyCode = "USD";
-
-double catalog_convert(const service& currencyConverter, const double price) {
- return currencyConverter(tuscany::mklist<tuscany::value>("convert", "USD", catalog_currencyCode, price));
-}
-
-const tuscany::list<ItemType> catalog_get(const service& currencyConverter) {
- const std::string currencySymbol = currencyConverter_service(tuscany::mklist<tuscany::value>("getSymbol", catalog_currencyCode));
- return tuscany::mklist(
- item("Apple", catalog_currencyCode, currencySymbol, catalog_convert(currencyConverter, 2.99)),
- item("Orange", catalog_currencyCode, currencySymbol, catalog_convert(currencyConverter, 3.55)),
- item("Pear", catalog_currencyCode, currencySymbol, catalog_convert(currencyConverter, 1.55)));
-}
-
-const tuscany::value catalog_service(const service& currencyConverter, const tuscany::list<tuscany::value>& args) {
- if (car(args) == "get")
- return catalog_get(currencyConverter);
- return tuscany::value();
-}
-
-}
-#endif /* tuscany_catalog_hpp */
diff --git a/sca-cpp/trunk/test/store-function/catalogs.composite b/sca-cpp/trunk/test/store-function/catalogs.composite
deleted file mode 100644
index 1638ed0a05..0000000000
--- a/sca-cpp/trunk/test/store-function/catalogs.composite
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- * 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.
--->
-<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
- xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
- targetNamespace="http://services"
- name="catalogs">
-
- <component name="FruitsCatalogWebService">
- <implementation.java class="services.FruitsCatalogImpl"/>
- <service name="Catalog">
- <binding.ws/>
- </service>
- <property name="currencyCode">USD</property>
- <reference name="currencyConverter" target="CurrencyConverterWebService">
- <binding.ws/>
- </reference>
- </component>
-
- <component name="VegetablesCatalogWebService">
- <implementation.java class="services.VegetablesCatalogImpl"/>
- <service name="Catalog">
- <binding.ws/>
- </service>
- </component>
-
-</composite>
diff --git a/sca-cpp/trunk/test/store-function/currency-composite.hpp b/sca-cpp/trunk/test/store-function/currency-composite.hpp
deleted file mode 100644
index ae28471538..0000000000
--- a/sca-cpp/trunk/test/store-function/currency-composite.hpp
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.
- */
-
-/* $Rev$ $Date$ */
-
-#ifndef tuscany_currencycomposite_hpp
-#define tuscany_currencycomposite_hpp
-
-#include <string>
-#include "service.hpp"
-#include "currency.hpp"
-
-namespace store
-{
-
-const tuscany::value currency_service(const tuscany::list<tuscany::value>& args) {
- return currencyConverter_service(args);
-}
-
-}
-#endif /* tuscany_currencycomposite_hpp */
diff --git a/sca-cpp/trunk/test/store-function/currency.composite b/sca-cpp/trunk/test/store-function/currency.composite
deleted file mode 100644
index aefd474f1f..0000000000
--- a/sca-cpp/trunk/test/store-function/currency.composite
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- * 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.
--->
-<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
- xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
- targetNamespace="http://services"
- name="currency">
-
- <component name="CurrencyConverterWebService">
- <implementation.java class="services.CurrencyConverterImpl"/>
- <service name="CurrencyConverter">
- <binding.ws/>
- </service>
- </component>
-
-</composite>
diff --git a/sca-cpp/trunk/test/store-function/currency.hpp b/sca-cpp/trunk/test/store-function/currency.hpp
deleted file mode 100644
index ca4376d2c7..0000000000
--- a/sca-cpp/trunk/test/store-function/currency.hpp
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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.
- */
-
-/* $Rev$ $Date$ */
-
-#ifndef tuscany_currency_hpp
-#define tuscany_currency_hpp
-
-#include <math.h>
-#include <string>
-#include "debug.hpp"
-#include "service.hpp"
-#include "item.hpp"
-
-namespace store
-{
-
-const double currencyConverter_convert(unused const std::string& fromCurrencyCode, const std::string& toCurrencyCode, const double amount) {
- if(toCurrencyCode == "USD")
- return amount;
- if(toCurrencyCode == "EUR")
- return round(amount * 0.7256 * 100) / 100;
- return amount;
-}
-
-const std::string currencyConverter_getSymbol(const std::string& currencyCode) {
- if(currencyCode == "USD")
- return "$";
- if(currencyCode == "EUR")
- return "E";
- return "?";
-}
-
-const tuscany::value currencyConverter_service(const tuscany::list<tuscany::value>& args) {
- if (car(args) == "convert")
- return currencyConverter_convert(cadr(args), car(cdr(cdr(args))), car(cdr(cdr(cdr(args)))));
- if (car(args) == "getSymbol")
- return currencyConverter_getSymbol(cadr(args));
- return tuscany::value();
-}
-
-}
-#endif /* tuscany_currency_hpp */
diff --git a/sca-cpp/trunk/test/store-function/item.hpp b/sca-cpp/trunk/test/store-function/item.hpp
deleted file mode 100644
index fbe29915dc..0000000000
--- a/sca-cpp/trunk/test/store-function/item.hpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * 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.
- */
-
-/* $Rev$ $Date$ */
-
-#ifndef tuscany_item_hpp
-#define tuscany_item_hpp
-
-#include <string>
-#include "service.hpp"
-
-namespace store
-{
-
-typedef tuscany::value ItemType;
-
-const ItemType item(const std::string& name, const std::string& currencyCode, const std::string& currencySymbol, const double price) {
- return tuscany::mklist<tuscany::value>(name, currencyCode, currencySymbol, price);
-}
-
-const std::string itemName(const ItemType& item) {
- return car((tuscany::list<tuscany::value>)item);
-}
-
-const std::string itemCurrencyCode(const ItemType& item) {
- return car(cdr((tuscany::list<tuscany::value>)item));
-}
-
-const std::string itemCurrencySymbol(const ItemType& item) {
- return car(cdr(cdr((tuscany::list<tuscany::value>)item)));
-}
-
-const double itemPrice(const ItemType& item) {
- return car(cdr(cdr(cdr((tuscany::list<tuscany::value>)item))));
-}
-
-}
-#endif /* tuscany_item_hpp */
diff --git a/sca-cpp/trunk/test/store-function/service.hpp b/sca-cpp/trunk/test/store-function/service.hpp
deleted file mode 100644
index b764e87d1a..0000000000
--- a/sca-cpp/trunk/test/store-function/service.hpp
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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.
- */
-
-/* $Rev$ $Date$ */
-
-#ifndef tuscany_service_hpp
-#define tuscany_service_hpp
-
-#include "function.hpp"
-#include "list.hpp"
-#include "value.hpp"
-
-namespace store
-{
-
-typedef tuscany::lambda<tuscany::value(tuscany::list<tuscany::value>)> service;
-
-}
-#endif /* tuscany_service_hpp */
diff --git a/sca-cpp/trunk/test/store-function/store-composite.hpp b/sca-cpp/trunk/test/store-function/store-composite.hpp
deleted file mode 100644
index 351c905eae..0000000000
--- a/sca-cpp/trunk/test/store-function/store-composite.hpp
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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.
- */
-
-/* $Rev$ $Date$ */
-
-#ifndef tuscany_storecomposite_hpp
-#define tuscany_storecomposite_hpp
-
-#include <string>
-#include "service.hpp"
-#include "currency.hpp"
-#include "currency-composite.hpp"
-#include "item.hpp"
-#include "catalog.hpp"
-#include "cart.hpp"
-#include "store-ui.hpp"
-
-namespace store
-{
-
-const tuscany::value store_service(const service& currency, const tuscany::list<tuscany::value>& args) {
- const tuscany::lambda<tuscany::value(service, tuscany::list<tuscany::value>)> catalogService(catalog_service);
- const service catalog(curry(catalogService, currency));
- const service cart(shoppingCart_service);
- const tuscany::lambda<tuscany::value(service, service, tuscany::list<tuscany::value>)> storeUIService(storeUI_service);
- const service configuredStoreUIService(curry(storeUIService, catalog, cart));
- return configuredStoreUIService(args);
-}
-
-}
-#endif /* tuscany_storecomposite_hpp */
diff --git a/sca-cpp/trunk/test/store-function/store-function-test.cpp b/sca-cpp/trunk/test/store-function/store-function-test.cpp
deleted file mode 100644
index 8a6a86eb8a..0000000000
--- a/sca-cpp/trunk/test/store-function/store-function-test.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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.
- */
-
-/* $Rev$ $Date$ */
-
-/**
- * Store Test case.
- */
-
-#include <assert.h>
-#include <iostream>
-#include <string>
-#include "store-solution.hpp"
-
-namespace store
-{
-
-bool testComponentAssembly() {
- const service store(storeSolution_service);
- assert(length((tuscany::list<tuscany::value>)store(tuscany::mklist<tuscany::value>("getCatalog"))) == 3);
- return true;
-}
-
-}
-
-int main() {
-
- std::cout << "Testing..." << std::endl;
-
- store::testComponentAssembly();
- std::cout << "OK" << std::endl;
-
- return 0;
-}
diff --git a/sca-cpp/trunk/test/store-function/store-solution.hpp b/sca-cpp/trunk/test/store-function/store-solution.hpp
deleted file mode 100644
index e0addcba12..0000000000
--- a/sca-cpp/trunk/test/store-function/store-solution.hpp
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.
- */
-
-/* $Rev$ $Date$ */
-
-#ifndef tuscany_storesolution_hpp
-#define tuscany_storesolution_hpp
-
-#include <string>
-#include "service.hpp"
-#include "store-composite.hpp"
-#include "currency-composite.hpp"
-
-namespace store
-{
-
-const tuscany::value storeSolution_service(const tuscany::list<tuscany::value>& args) {
- const service currency(currency_service);
- const tuscany::lambda<tuscany::value(service, tuscany::list<tuscany::value>)> storeService(store_service);
- const service configuredStoreService(curry(storeService, currency));
- return configuredStoreService(args);
-}
-
-}
-#endif /* tuscany_storesolution_hpp */
diff --git a/sca-cpp/trunk/test/store-function/store-ui.hpp b/sca-cpp/trunk/test/store-function/store-ui.hpp
deleted file mode 100644
index 12b28d6a92..0000000000
--- a/sca-cpp/trunk/test/store-function/store-ui.hpp
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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.
- */
-
-/* $Rev$ $Date$ */
-
-#ifndef tuscany_storeui_hpp
-#define tuscany_storeui_hpp
-
-#include <string>
-#include "service.hpp"
-#include "currency.hpp"
-#include "item.hpp"
-#include "catalog.hpp"
-#include "cart.hpp"
-
-namespace store
-{
-
-const tuscany::list<ItemType> storeUI_getCatalog(const service& catalog) {
- return catalog(tuscany::mklist<tuscany::value>("get"));
-}
-
-const tuscany::list<ItemType> storeUI_getCart(const service& cart) {
- return cart(tuscany::mklist<tuscany::value>("getAll"));
-}
-
-const double storeUI_getTotal(const service& cart) {
- return cart(tuscany::mklist<tuscany::value>("getTotal"));
-}
-
-const bool storeUI_post(const service& cart, const ItemType& item) {
- return cart(tuscany::mklist<tuscany::value>("post", item));
-}
-
-const tuscany::value storeUI_service(const service& catalog, const service& cart, const tuscany::list<tuscany::value>& args) {
- if (car(args) == "getCatalog")
- return storeUI_getCatalog(catalog);
- if (car(args) == "getCart")
- return storeUI_getCart(cart);
- if (car(args) == "getTotal")
- return storeUI_getTotal(cart);
- if (car(args) == "post")
- return storeUI_post(cart, cadr(args));
- return tuscany::value();
-}
-
-}
-#endif /* STOREUI_HPP_ */
diff --git a/sca-cpp/trunk/test/store-function/store.composite b/sca-cpp/trunk/test/store-function/store.composite
deleted file mode 100644
index 124adff853..0000000000
--- a/sca-cpp/trunk/test/store-function/store.composite
+++ /dev/null
@@ -1,64 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- * 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.
--->
-<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
- xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
- targetNamespace="http://store"
- name="store">
-
- <component name="Store">
- <t:implementation.widget location="uiservices/store.html"/>
- <service name="Widget">
- <t:binding.http uri="/ui"/>
- </service>
- <reference name="catalog" target="StoreCatalog">
- <t:binding.jsonrpc/>
- </reference>
- <reference name="shoppingCart" target="StoreShoppingCart/Cart">
- <t:binding.atom/>
- </reference>
- <reference name="shoppingTotal" target="StoreShoppingCart/Total">
- <t:binding.jsonrpc/>
- </reference>
- </component>
-
- <component name="StoreCatalog">
- <implementation.java class="services.FruitsCatalogImpl"/>
- <property name="currencyCode">USD</property>
- <service name="Catalog">
- <t:binding.jsonrpc/>
- </service>
- <reference name="currencyConverter" target="StoreCurrencyConverter"/>
- </component>
-
- <component name="StoreShoppingCart">
- <implementation.java class="services.ShoppingCartImpl"/>
- <service name="Cart">
- <t:binding.atom uri="/ShoppingCart/Cart"/>
- </service>
- <service name="Total">
- <t:binding.jsonrpc/>
- </service>
- </component>
-
- <component name="StoreCurrencyConverter">
- <implementation.java class="services.CurrencyConverterImpl"/>
- </component>
-
-</composite>
diff --git a/sca-cpp/trunk/test/store-object/Makefile.am b/sca-cpp/trunk/test/store-object/Makefile.am
deleted file mode 100644
index 83b8bc7d4e..0000000000
--- a/sca-cpp/trunk/test/store-object/Makefile.am
+++ /dev/null
@@ -1,28 +0,0 @@
-# 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.
-
-noinst_PROGRAMS = store-object-test
-
-noinst_HEADERS = *.hpp
-
-INCLUDES = -I. -I$(top_builddir)/kernel -I${LIBXML2_INCLUDE} -I${APR_INCLUDE}
-
-store_object_test_SOURCES = store-object-test.cpp
-store_object_test_LDADD = -L${LIBXML2_LIB} -lxml2 -L${APR_LIB} -lapr-1 -laprutil-1
-
-TESTS = store-object-test
-
diff --git a/sca-cpp/trunk/test/store-object/cart.hpp b/sca-cpp/trunk/test/store-object/cart.hpp
deleted file mode 100644
index f35a5c4527..0000000000
--- a/sca-cpp/trunk/test/store-object/cart.hpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * 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.
- */
-
-/* $Rev$ $Date$ */
-
-#ifndef store_cart_hpp
-#define store_cart_hpp
-
-#include <string>
-#include "function.hpp"
-#include "list.hpp"
-#include "currency.hpp"
-#include "item.hpp"
-#include "catalog.hpp"
-
-namespace store
-{
-
-const double accum(const double total, const Item& item) {
- return total + item.price;
-}
-
-class ShoppingCart {
-public:
- virtual const tuscany::list<Item> getAll() const = 0;
-
- virtual const bool post(const Item& item) = 0;
-
- virtual const bool deleteAll() = 0;
-
- virtual const double getTotal() const = 0;
-};
-
-class ShoppingCartImpl : public ShoppingCart {
-public:
- tuscany::list<Item> cart;
-
- virtual const tuscany::list<Item> getAll() const {
- return cart;
- }
-
- virtual const bool post(const Item& item) {
- cart = cons(item, cart);
- return true;
- }
-
- virtual const bool deleteAll() {
- cart = tuscany::list<Item>();
- return true;
- }
-
- virtual const double getTotal() const {
- return tuscany::reduce<Item, double>(accum, 0.0, cart);
- }
-};
-
-}
-#endif /* store_cart_hpp */
diff --git a/sca-cpp/trunk/test/store-object/catalog.hpp b/sca-cpp/trunk/test/store-object/catalog.hpp
deleted file mode 100644
index fab013cf8e..0000000000
--- a/sca-cpp/trunk/test/store-object/catalog.hpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * 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.
- */
-
-/* $Rev$ $Date$ */
-
-#ifndef store_catalog_hpp
-#define store_catalog_hpp
-
-#include <string>
-#include "list.hpp"
-#include "currency.hpp"
-#include "item.hpp"
-
-namespace store
-{
-
-class Catalog {
-public:
-
- virtual const double convert(const double price) const = 0;
-
- virtual const tuscany::list<Item> get() const = 0;
-};
-
-class CatalogImpl : public Catalog {
-public:
-
- const std::string currencyCode;
- const CurrencyConverter& currencyConverter;
-
- CatalogImpl(const CurrencyConverter& currencyConverter) :
- currencyCode("USD"), currencyConverter(currencyConverter) {
- }
-
- virtual const double convert(const double price) const {
- return currencyConverter.convert("USD", currencyCode, price);
- }
-
- virtual const tuscany::list<Item> get() const {
- const std::string currencySymbol = currencyConverter.getSymbol(currencyCode);
- return tuscany::mklist(
- Item("Apple", currencyCode, currencySymbol, convert(2.99)),
- Item("Orange", currencyCode, currencySymbol, convert(3.55)),
- Item("Pear", currencyCode, currencySymbol, convert(1.55)));
- }
-};
-
-}
-#endif /* store_catalog_hpp */
diff --git a/sca-cpp/trunk/test/store-object/catalogs.composite b/sca-cpp/trunk/test/store-object/catalogs.composite
deleted file mode 100644
index 1638ed0a05..0000000000
--- a/sca-cpp/trunk/test/store-object/catalogs.composite
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- * 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.
--->
-<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
- xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
- targetNamespace="http://services"
- name="catalogs">
-
- <component name="FruitsCatalogWebService">
- <implementation.java class="services.FruitsCatalogImpl"/>
- <service name="Catalog">
- <binding.ws/>
- </service>
- <property name="currencyCode">USD</property>
- <reference name="currencyConverter" target="CurrencyConverterWebService">
- <binding.ws/>
- </reference>
- </component>
-
- <component name="VegetablesCatalogWebService">
- <implementation.java class="services.VegetablesCatalogImpl"/>
- <service name="Catalog">
- <binding.ws/>
- </service>
- </component>
-
-</composite>
diff --git a/sca-cpp/trunk/test/store-object/currency-composite.hpp b/sca-cpp/trunk/test/store-object/currency-composite.hpp
deleted file mode 100644
index 94b52b461e..0000000000
--- a/sca-cpp/trunk/test/store-object/currency-composite.hpp
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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.
- */
-
-/* $Rev$ $Date$ */
-
-#ifndef store_currencycomposite_hpp
-#define store_currencycomposite_hpp
-
-#include <string>
-#include "currency.hpp"
-
-namespace store
-{
-
-class Currency : public CurrencyConverter {
-};
-
-class CurrencyImpl : public Currency {
-public:
- const CurrencyConverterImpl currencyConverter;
-
- CurrencyImpl() : currencyConverter(CurrencyConverterImpl()) {
- }
-
- virtual const double convert(const std::string& fromCurrencyCode, const std::string& toCurrencyCode, const double amount) const {
- return currencyConverter.convert(fromCurrencyCode, toCurrencyCode, amount);
- }
-
- virtual const std::string getSymbol(const std::string& currencyCode) const {
- return currencyConverter.getSymbol(currencyCode);
- }
-};
-
-}
-#endif /* store_currencycomposite_hpp */
diff --git a/sca-cpp/trunk/test/store-object/currency.composite b/sca-cpp/trunk/test/store-object/currency.composite
deleted file mode 100644
index aefd474f1f..0000000000
--- a/sca-cpp/trunk/test/store-object/currency.composite
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- * 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.
--->
-<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
- xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
- targetNamespace="http://services"
- name="currency">
-
- <component name="CurrencyConverterWebService">
- <implementation.java class="services.CurrencyConverterImpl"/>
- <service name="CurrencyConverter">
- <binding.ws/>
- </service>
- </component>
-
-</composite>
diff --git a/sca-cpp/trunk/test/store-object/currency.hpp b/sca-cpp/trunk/test/store-object/currency.hpp
deleted file mode 100644
index 921c0efb3b..0000000000
--- a/sca-cpp/trunk/test/store-object/currency.hpp
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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.
- */
-
-/* $Rev$ $Date$ */
-
-#ifndef store_currency_hpp
-#define store_currency_hpp
-
-#include <math.h>
-#include <string>
-#include "debug.hpp"
-
-namespace store
-{
-
-class CurrencyConverter {
-public:
-
- virtual const double convert(const std::string& fromCurrencyCode, const std::string& toCurrencyCode, const double amount) const = 0;
- virtual const std::string getSymbol(const std::string& currencyCode) const = 0;
-};
-
-class CurrencyConverterImpl : public CurrencyConverter {
-public:
-
- virtual const double convert(unused const std::string& fromCurrencyCode, const std::string& toCurrencyCode, const double amount) const {
- if(toCurrencyCode == "USD")
- return amount;
- if(toCurrencyCode == "EUR")
- return round(amount * 0.7256 * 100) / 100;
- return amount;
- }
-
- virtual const std::string getSymbol(const std::string& currencyCode) const {
- if(currencyCode == "USD")
- return "$";
- if(currencyCode == "EUR")
- return "E";
- return "?";
- }
-};
-
-}
-#endif /* store_currency_hpp */
diff --git a/sca-cpp/trunk/test/store-object/item.hpp b/sca-cpp/trunk/test/store-object/item.hpp
deleted file mode 100644
index ab8e52769b..0000000000
--- a/sca-cpp/trunk/test/store-object/item.hpp
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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.
- */
-
-/* $Rev$ $Date$ */
-
-#ifndef store_item_hpp
-#define store_item_hpp
-
-#include <string>
-
-namespace store
-{
-
-class Item {
-public:
- std::string name;
- double price;
- std::string currencyCode;
- std::string currencySymbol;
-
- Item() {
- }
-
- Item(const std::string& name, const std::string& currencyCode, const std::string& currencySymbol, const double price) :
- name(name), price(price), currencyCode(currencyCode), currencySymbol(currencySymbol) {
- }
-
-};
-
-}
-#endif /* store_item_hpp */
diff --git a/sca-cpp/trunk/test/store-object/store-composite.hpp b/sca-cpp/trunk/test/store-object/store-composite.hpp
deleted file mode 100644
index 8cee5a943f..0000000000
--- a/sca-cpp/trunk/test/store-object/store-composite.hpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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.
- */
-
-/* $Rev$ $Date$ */
-
-#ifndef store_storecomposite_hpp
-#define store_storecomposite_hpp
-
-#include "list.hpp"
-#include "currency.hpp"
-#include "currency-composite.hpp"
-#include "item.hpp"
-#include "catalog.hpp"
-#include "cart.hpp"
-#include "store-ui.hpp"
-
-namespace store
-{
-
-class Store : public StoreUI {
-};
-
-class StoreImpl : public Store {
-public:
- const CatalogImpl catalog;
- ShoppingCartImpl cart;
- StoreUIImpl storeUI;
-
- StoreImpl(const Currency& currency) :
- catalog(CatalogImpl(currency)), cart(ShoppingCartImpl()), storeUI(StoreUIImpl(catalog, cart)) {
- }
-
- virtual const tuscany::list<Item> getCatalog() const {
- return storeUI.getCatalog();
- }
-
- virtual const tuscany::list<Item> getCart() const {
- return storeUI.getCart();
- }
-
- virtual const double getTotal() const {
- return storeUI.getTotal();
- }
-
- virtual const bool post(const Item& item) {
- return storeUI.post(item);
- }
-
-};
-
-}
-#endif /* store_storecomposite_hpp */
diff --git a/sca-cpp/trunk/test/store-object/store-object-test.cpp b/sca-cpp/trunk/test/store-object/store-object-test.cpp
deleted file mode 100644
index bfbf5459ac..0000000000
--- a/sca-cpp/trunk/test/store-object/store-object-test.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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.
- */
-
-/* $Rev$ $Date$ */
-
-/**
- * Store Test case.
- */
-
-#include <assert.h>
-#include <iostream>
-#include "store-solution.hpp"
-
-namespace store
-{
-
-bool testComponentAssembly() {
- StoreSolutionImpl store = StoreSolutionImpl();
- assert(length(store.getCatalog()) == 3);
- assert(store.post(car(store.getCatalog())) == true);
- assert(store.post(cadr(store.getCatalog())) == true);
- assert(length(store.getCart()) == 2);
- assert(store.getTotal() == 6.54);
- return true;
-}
-
-}
-
-int main() {
- std::cout << "Testing..." << std::endl;
-
- store::testComponentAssembly();
- std::cout << "OK" << std::endl;
-
- return 0;
-}
diff --git a/sca-cpp/trunk/test/store-object/store-solution.hpp b/sca-cpp/trunk/test/store-object/store-solution.hpp
deleted file mode 100644
index ecabb18f1c..0000000000
--- a/sca-cpp/trunk/test/store-object/store-solution.hpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * 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.
- */
-
-/* $Rev$ $Date$ */
-
-#ifndef store_storesolution_hpp
-#define store_storesolution_hpp
-
-#include "list.hpp"
-#include "store-composite.hpp"
-#include "currency-composite.hpp"
-
-namespace store
-{
-
-class StoreSolution : public Store {
-};
-
-class StoreSolutionImpl : public StoreSolution {
-public:
- const CurrencyImpl currency;
- StoreImpl store;
-
- StoreSolutionImpl() :
- currency(CurrencyImpl()), store(StoreImpl(currency)) {
- }
-
- virtual const tuscany::list<Item> getCatalog() const {
- return store.getCatalog();
- }
-
- virtual const tuscany::list<Item> getCart() const {
- return store.getCart();
- }
-
- virtual const double getTotal() const {
- return store.getTotal();
- }
-
- virtual const bool post(const Item& item) {
- return store.post(item);
- }
-};
-
-}
-#endif /* store_storesolution_hpp */
diff --git a/sca-cpp/trunk/test/store-object/store-ui.hpp b/sca-cpp/trunk/test/store-object/store-ui.hpp
deleted file mode 100644
index c9d0f4330b..0000000000
--- a/sca-cpp/trunk/test/store-object/store-ui.hpp
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * 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.
- */
-
-/* $Rev$ $Date$ */
-
-#ifndef store_storeui_hpp
-#define store_storeui_hpp
-
-#include "list.hpp"
-#include "currency.hpp"
-#include "item.hpp"
-#include "catalog.hpp"
-#include "cart.hpp"
-
-namespace store
-{
-
-class StoreUI {
-public:
-
- virtual const tuscany::list<Item> getCatalog() const =0;
-
- virtual const tuscany::list<Item> getCart() const = 0;
-
- virtual const double getTotal() const =0;
-
- virtual const bool post(const Item& item) = 0;
-};
-
-class StoreUIImpl : public StoreUI {
-public:
- const Catalog& catalog;
- ShoppingCart& cart;
-
- StoreUIImpl(const Catalog& catalog, ShoppingCart& cart) : catalog(catalog), cart(cart) {
- }
-
- virtual const tuscany::list<Item> getCatalog() const {
- return catalog.get();
- }
-
- virtual const tuscany::list<Item> getCart() const {
- return cart.getAll();
- }
-
- virtual const double getTotal() const {
- return cart.getTotal();
- }
-
- virtual const bool post(const Item& item) {
- return cart.post(item);
- }
-};
-
-}
-#endif /* store_storeui_hpp */
diff --git a/sca-cpp/trunk/test/store-object/store.composite b/sca-cpp/trunk/test/store-object/store.composite
deleted file mode 100644
index 124adff853..0000000000
--- a/sca-cpp/trunk/test/store-object/store.composite
+++ /dev/null
@@ -1,64 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- * 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.
--->
-<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
- xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
- targetNamespace="http://store"
- name="store">
-
- <component name="Store">
- <t:implementation.widget location="uiservices/store.html"/>
- <service name="Widget">
- <t:binding.http uri="/ui"/>
- </service>
- <reference name="catalog" target="StoreCatalog">
- <t:binding.jsonrpc/>
- </reference>
- <reference name="shoppingCart" target="StoreShoppingCart/Cart">
- <t:binding.atom/>
- </reference>
- <reference name="shoppingTotal" target="StoreShoppingCart/Total">
- <t:binding.jsonrpc/>
- </reference>
- </component>
-
- <component name="StoreCatalog">
- <implementation.java class="services.FruitsCatalogImpl"/>
- <property name="currencyCode">USD</property>
- <service name="Catalog">
- <t:binding.jsonrpc/>
- </service>
- <reference name="currencyConverter" target="StoreCurrencyConverter"/>
- </component>
-
- <component name="StoreShoppingCart">
- <implementation.java class="services.ShoppingCartImpl"/>
- <service name="Cart">
- <t:binding.atom uri="/ShoppingCart/Cart"/>
- </service>
- <service name="Total">
- <t:binding.jsonrpc/>
- </service>
- </component>
-
- <component name="StoreCurrencyConverter">
- <implementation.java class="services.CurrencyConverterImpl"/>
- </component>
-
-</composite>