diff options
Diffstat (limited to 'cpp/sca/modules/scdl')
-rw-r--r-- | cpp/sca/modules/scdl/Makefile.am | 28 | ||||
-rwxr-xr-x | cpp/sca/modules/scdl/scdl-test | bin | 477277 -> 0 bytes | |||
-rw-r--r-- | cpp/sca/modules/scdl/scdl-test.cpp | 119 | ||||
-rw-r--r-- | cpp/sca/modules/scdl/scdl.hpp | 158 | ||||
-rw-r--r-- | cpp/sca/modules/scdl/test.composite | 67 |
5 files changed, 0 insertions, 372 deletions
diff --git a/cpp/sca/modules/scdl/Makefile.am b/cpp/sca/modules/scdl/Makefile.am deleted file mode 100644 index 55a190579c..0000000000 --- a/cpp/sca/modules/scdl/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 = scdl-test - -nobase_include_HEADERS = *.hpp - -INCLUDES = -I. -I$(top_builddir)/kernel -I${LIBXML2_INCLUDE} -I${APR_INCLUDE} - -scdl_test_SOURCES = scdl-test.cpp -scdl_test_LDADD = -lpthread -L${LIBXML2_LIB} -lxml2 -L${APR_LIB} -lapr-1 -laprutil-1 - -TESTS = scdl-test - diff --git a/cpp/sca/modules/scdl/scdl-test b/cpp/sca/modules/scdl/scdl-test Binary files differdeleted file mode 100755 index acef45d225..0000000000 --- a/cpp/sca/modules/scdl/scdl-test +++ /dev/null diff --git a/cpp/sca/modules/scdl/scdl-test.cpp b/cpp/sca/modules/scdl/scdl-test.cpp deleted file mode 100644 index c3da1013a8..0000000000 --- a/cpp/sca/modules/scdl/scdl-test.cpp +++ /dev/null @@ -1,119 +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 SCDL read functions. - */ - -#include <assert.h> -#include <iostream> -#include <sstream> -#include <fstream> -#include <string> -#include "slist.hpp" -#include "scdl.hpp" - -namespace tuscany { -namespace scdl { - -bool testComposite() { - std::ifstream is("test.composite"); - const list<value> c = readXML(streamList(is)); - return true; -} - -bool testComponents() { - std::ifstream is("test.composite"); - const list<value> c = components(readXML(streamList(is))); - assert(length(c) == 4); - - const value store = car(c); - assert(name(store) == std::string("Store")); - const value impl = implementation(store); - assert(uri(impl) == std::string("store.html")); - assert(implementationType(impl) == "t:implementation.widget"); - - const value catalog = named(std::string("Catalog"), c); - assert(name(catalog) == std::string("Catalog")); - return true; -} - -bool testServices() { - std::ifstream is("test.composite"); - const list<value> c = components(readXML(streamList(is))); - const value store = car(c); - - assert(length(services(store)) == 1); - const value widget = car(services(store)); - assert(name(widget) == std::string("Widget")); - - assert(length(bindings(widget)) == 1); - const value binding = car(bindings(widget)); - assert(uri(binding) == std::string("/store")); - assert(bindingType(binding) == "t:binding.http"); - return true; -} - -bool testReferences() { - std::ifstream is("test.composite"); - const list<value> c = components(readXML(streamList(is))); - const value store = car(c); - - assert(length(references(store)) == 3); - const value catalog = car(references(store)); - assert(name(catalog) == std::string("catalog")); - assert(target(catalog) == std::string("Catalog")); - - assert(length(bindings(catalog)) == 1); - const value binding = car(bindings(catalog)); - assert(uri(binding) == value()); - assert(bindingType(binding) == "t:binding.jsonrpc"); - return true; -} - -bool testProperties() { - std::ifstream is("test.composite"); - const list<value> c = components(readXML(streamList(is))); - const value catalog = named(std::string("Catalog"), c); - - assert(length(properties(catalog)) == 1); - const value currencyCode = car(properties(catalog)); - assert(name(currencyCode) == std::string("currencyCode")); - assert(propertyValue(currencyCode) == std::string("USD")); - return true; -} - -} -} - -int main() { - std::cout << "Testing..." << std::endl; - - tuscany::scdl::testComposite(); - tuscany::scdl::testComponents(); - tuscany::scdl::testServices(); - tuscany::scdl::testReferences(); - tuscany::scdl::testProperties(); - - std::cout << "OK" << std::endl; - - return 0; -} diff --git a/cpp/sca/modules/scdl/scdl.hpp b/cpp/sca/modules/scdl/scdl.hpp deleted file mode 100644 index 4d84610fb0..0000000000 --- a/cpp/sca/modules/scdl/scdl.hpp +++ /dev/null @@ -1,158 +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_scdl_hpp -#define tuscany_scdl_hpp - -/** - * SCDL read functions. - */ - -#include <string> -#include "list.hpp" -#include "value.hpp" -#include "monad.hpp" -#include "xml.hpp" - -namespace tuscany { -namespace scdl { - -/** - * Returns a list of components in a composite. - */ -const list<value> components(const value& l) { - const list<value> cs = elementChildren("composite", l); - if (isNil(cs)) - return cs; - return elementChildren("component", car(cs)); -} - -/** - * Returns the name of a component, service or reference. - */ -const value name(const value& l) { - return attributeValue("name", l); -} - -/** - * Returns the scdl declaration with the given name. - */ -struct filterName { - const value n; - filterName(const value& n) : n(n) { - } - const bool operator()(const value& v) const { - return name(v) == n; - } -}; - -const value named(const value& name, const value& l) { - const list<value> c = filter<value>(filterName(name), l); - if (isNil(c)) - return value(); - return car(c); -} - -/** - * Returns the implementation of a component. - */ -const bool filterImplementation(const value& v) { - return isElement(v) && std::string(cadr<value>(v)).find("implementation.") != std::string::npos; -} - -const value implementation(const value& l) { - const list<value> n = filter<value>(filterImplementation, l); - if (isNil(n)) - return value(); - return car(n); -} - -/** - * Returns the URI of a service, reference or implementation. - */ -const value uri(const value& l) { - return attributeValue("uri", l); -} - -/** - * Returns a list of services in a component. - */ -const list<value> services(const value& l) { - return elementChildren("service", l); -} - -/** - * Returns a list of references in a component. - */ -const list<value> references(const value& l) { - return elementChildren("reference", l); -} - -/** - * Returns a list of properties in a component. - */ -const list<value> properties(const value& l) { - return elementChildren("property", l); -} - -/** - * Returns the target of a reference. - */ -const value target(const value& l) { - return attributeValue("target", l); -} - -/** - * Returns a list of bindings in a service or reference. - */ -const bool filterBinding(const value& v) { - return isElement(v) && std::string(cadr<value>(v)).find("binding.") != std::string::npos; -} - -const list<value> bindings(const value& l) { - return filter<value>(filterBinding, l); -} - -/** - * Returns the type of an implementation. - */ -const value implementationType(const value& l) { - return elementName(l); -} - -/** - * Returns the type of a binding. - */ -const value bindingType(const value& l) { - return elementName(l); -} - -/** - * Returns the value of a property. - */ -const value propertyValue(const value& l) { - return elementValue(l); -} - -} -} - -#endif /* tuscany_scdl_hpp */ diff --git a/cpp/sca/modules/scdl/test.composite b/cpp/sca/modules/scdl/test.composite deleted file mode 100644 index b315f23f9a..0000000000 --- a/cpp/sca/modules/scdl/test.composite +++ /dev/null @@ -1,67 +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 uri="store.html"/> - <service name="Widget"> - <t:binding.http uri="/store"/> - </service> - <reference name="catalog" target="Catalog"> - <t:binding.jsonrpc/> - </reference> - <reference name="shoppingCart" target="ShoppingCart/Cart"> - <t:binding.atom/> - </reference> - <reference name="shoppingTotal" target="ShoppingCart/Total"> - <t:binding.jsonrpc/> - </reference> - </component> - - <component name="Catalog"> - <t:implementation.scheme uri="fruits-catalog.scm"/> - <property name="currencyCode">USD</property> - <service name="Catalog"> - <t:binding.jsonrpc/> - </service> - <reference name="currencyConverter" target="CurrencyConverter"/> - </component> - - <component name="ShoppingCart"> - <t:implementation.scheme uri="shopping-cart.scm"/> - <service name="Cart"> - <t:binding.atom uri="/ShoppingCart"/> - </service> - <service name="Total"> - <t:binding.jsonrpc/> - </service> - <reference name="cache"> - <binding.memcached uri="localhost:11311"/> - </reference> - </component> - - <component name="CurrencyConverter"> - <t:implementation.scheme uri="currency-converter.scm"/> - </component> - -</composite> |