tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jsdelf...@apache.org
Subject svn commit: r1043296 - in /tuscany/sca-cpp/trunk: ./ components/ components/filedb/ etc/
Date Wed, 08 Dec 2010 03:52:29 GMT
Author: jsdelfino
Date: Wed Dec  8 03:52:27 2010
New Revision: 1043296

URL: http://svn.apache.org/viewvc?rev=1043296&view=rev
Log:
Add a test file-based database component.

Added:
    tuscany/sca-cpp/trunk/components/filedb/
    tuscany/sca-cpp/trunk/components/filedb/Makefile.am
    tuscany/sca-cpp/trunk/components/filedb/client-test.cpp
    tuscany/sca-cpp/trunk/components/filedb/file-test.cpp
    tuscany/sca-cpp/trunk/components/filedb/filedb-test   (contents, props changed)
      - copied, changed from r1043295, tuscany/sca-cpp/trunk/components/Makefile.am
    tuscany/sca-cpp/trunk/components/filedb/filedb.componentType
    tuscany/sca-cpp/trunk/components/filedb/filedb.composite
    tuscany/sca-cpp/trunk/components/filedb/filedb.cpp
    tuscany/sca-cpp/trunk/components/filedb/filedb.hpp
    tuscany/sca-cpp/trunk/components/filedb/server-test   (contents, props changed)
      - copied, changed from r1043295, tuscany/sca-cpp/trunk/components/Makefile.am
Modified:
    tuscany/sca-cpp/trunk/components/Makefile.am
    tuscany/sca-cpp/trunk/configure.ac
    tuscany/sca-cpp/trunk/etc/git-exclude

Modified: tuscany/sca-cpp/trunk/components/Makefile.am
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/Makefile.am?rev=1043296&r1=1043295&r2=1043296&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/Makefile.am (original)
+++ tuscany/sca-cpp/trunk/components/Makefile.am Wed Dec  8 03:52:27 2010
@@ -15,5 +15,5 @@
 #  specific language governing permissions and limitations
 #  under the License.
 
-SUBDIRS = cache chat log nosqldb queue sqldb webservice
+SUBDIRS = cache chat log nosqldb filedb queue sqldb webservice
 

Added: tuscany/sca-cpp/trunk/components/filedb/Makefile.am
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/filedb/Makefile.am?rev=1043296&view=auto
==============================================================================
--- tuscany/sca-cpp/trunk/components/filedb/Makefile.am (added)
+++ tuscany/sca-cpp/trunk/components/filedb/Makefile.am Wed Dec  8 03:52:27 2010
@@ -0,0 +1,44 @@
+#  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.
+
+INCLUDES = -I${TINYCDB_INCLUDE}
+
+incl_HEADERS = *.hpp
+incldir = $(prefix)/include/components/filedb
+
+compdir=$(prefix)/components/filedb
+
+EXTRA_DIST = filedb.composite filedb.componentType
+
+comp_LTLIBRARIES = libfiledb.la
+noinst_DATA = libfiledb.so
+
+libfiledb_la_SOURCES = filedb.cpp
+libfiledb_la_LDFLAGS = 
+libfiledb.so:
+	ln -s .libs/libfiledb.so
+
+file_test_SOURCES = file-test.cpp
+file_test_LDFLAGS = 
+
+client_test_SOURCES = client-test.cpp
+client_test_LDFLAGS = -lxml2 -lcurl -lmozjs
+
+dist_noinst_SCRIPTS = filedb-test server-test
+noinst_PROGRAMS = file-test client-test
+TESTS = filedb-test server-test
+

Added: tuscany/sca-cpp/trunk/components/filedb/client-test.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/filedb/client-test.cpp?rev=1043296&view=auto
==============================================================================
--- tuscany/sca-cpp/trunk/components/filedb/client-test.cpp (added)
+++ tuscany/sca-cpp/trunk/components/filedb/client-test.cpp Wed Dec  8 03:52:27 2010
@@ -0,0 +1,130 @@
+/*
+ * 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 file database component.
+ */
+
+#include <assert.h>
+#include "stream.hpp"
+#include "string.hpp"
+
+#include "list.hpp"
+#include "value.hpp"
+#include "monad.hpp"
+#include "perf.hpp"
+#include "../../modules/http/http.hpp"
+
+namespace tuscany {
+namespace filedb {
+
+const string uri("http://localhost:8090/filedb");
+
+bool testFileDB() {
+    http::CURLSession cs("", "", "");
+
+    const list<value> i = list<value>()
+            + (list<value>() + "name" + string("Apple"))
+            + (list<value>() + "price" + string("$2.99"));
+    const list<value> a = mklist<value>(string("item"), string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"),
i);
+
+    const failable<value> id = http::post(a, uri, cs);
+    assert(hasContent(id));
+
+    const string p = path(content(id));
+    {
+        const failable<value> val = http::get(uri + p, cs);
+        assert(hasContent(val));
+        assert(content(val) == a);
+    }
+
+    const list<value> j = list<value>()
+            + (list<value>() + "name" + string("Apple"))
+            + (list<value>() + "price" + string("$3.55"));
+    const list<value> b = mklist<value>(string("item"), string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"),
j);
+
+    {
+        const failable<value> r = http::put(b, uri + p, cs);
+        assert(hasContent(r));
+        assert(content(r) == value(true));
+    }
+    {
+        const failable<value> val = http::get(uri + p, cs);
+        assert(hasContent(val));
+        assert(content(val) == b);
+    }
+    {
+        const failable<value> r = http::del(uri + p, cs);
+        assert(hasContent(r));
+        assert(content(r) == value(true));
+    }
+    {
+        const failable<value> val = http::get(uri + p, cs);
+        assert(!hasContent(val));
+    }
+
+    return true;
+}
+
+struct getLoop {
+    const string path;
+    const value entry;
+    http::CURLSession cs;
+    getLoop(const string& path, const value& entry, http::CURLSession cs) : path(path),
entry(entry), cs(cs) {
+    }
+    const bool operator()() const {
+        const failable<value> val = http::get(uri + path, cs);
+        assert(hasContent(val));
+        assert(content(val) == entry);
+        return true;
+    }
+};
+
+bool testGetPerf() {
+    const list<value> i = list<value>()
+            + (list<value>() + "name" + string("Apple"))
+            + (list<value>() + "price" + string("$4.55"));
+    const value a = mklist<value>(string("item"), string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"),
i);
+
+    http::CURLSession cs("", "", "");
+    const failable<value> id = http::post(a, uri, cs);
+    assert(hasContent(id));
+    const string p = path(content(id));
+
+    const lambda<bool()> gl = getLoop(p, a, cs);
+    cout << "FileDB get test " << time(gl, 5, 200) << " ms" << endl;
+
+    return true;
+}
+
+}
+}
+
+int main() {
+    tuscany::cout << "Testing..." << tuscany::endl;
+
+    tuscany::filedb::testFileDB();
+    tuscany::filedb::testGetPerf();
+
+    tuscany::cout << "OK" << tuscany::endl;
+
+    return 0;
+}

Added: tuscany/sca-cpp/trunk/components/filedb/file-test.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/filedb/file-test.cpp?rev=1043296&view=auto
==============================================================================
--- tuscany/sca-cpp/trunk/components/filedb/file-test.cpp (added)
+++ tuscany/sca-cpp/trunk/components/filedb/file-test.cpp Wed Dec  8 03:52:27 2010
@@ -0,0 +1,82 @@
+/*
+ * 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 FileDB access functions.
+ */
+
+#include <assert.h>
+#include "stream.hpp"
+#include "string.hpp"
+#include "perf.hpp"
+#include "filedb.hpp"
+
+namespace tuscany {
+namespace filedb {
+
+bool testFileDB() {
+    FileDB db("tmp/testdb");
+    const value k = mklist<value>("a");
+
+    assert(hasContent(post(k, string("AAA"), db)));
+    assert((get(k, db)) == value(string("AAA")));
+    assert(hasContent(put(k, string("aaa"), db)));
+    assert((get(k, db)) == value(string("aaa")));
+    assert(hasContent(del(k, db)));
+    assert(!hasContent(get(k, db)));
+
+    return true;
+}
+
+struct getLoop {
+    const value k;
+    FileDB& db;
+    getLoop(const value& k, FileDB& db) : k(k), db(db) {
+    }
+    const bool operator()() const {
+        assert((get(k, db)) == value(string("CCC")));
+        return true;
+    }
+};
+
+bool testGetPerf() {
+    const value k = mklist<value>("c");
+    FileDB db("tmp/testdb");
+    assert(hasContent(post(k, string("CCC"), db)));
+
+    const lambda<bool()> gl = getLoop(k, db);
+    cout << "FileDB get test " << time(gl, 5, 10000) << " ms" <<
endl;
+    return true;
+}
+
+}
+}
+
+int main() {
+    tuscany::cout << "Testing..." << tuscany::endl;
+
+    tuscany::filedb::testFileDB();
+    tuscany::filedb::testGetPerf();
+
+    tuscany::cout << "OK" << tuscany::endl;
+
+    return 0;
+}

Copied: tuscany/sca-cpp/trunk/components/filedb/filedb-test (from r1043295, tuscany/sca-cpp/trunk/components/Makefile.am)
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/filedb/filedb-test?p2=tuscany/sca-cpp/trunk/components/filedb/filedb-test&p1=tuscany/sca-cpp/trunk/components/Makefile.am&r1=1043295&r2=1043296&rev=1043296&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/Makefile.am (original)
+++ tuscany/sca-cpp/trunk/components/filedb/filedb-test Wed Dec  8 03:52:27 2010
@@ -1,3 +1,5 @@
+#!/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
@@ -15,5 +17,13 @@
 #  specific language governing permissions and limitations
 #  under the License.
 
-SUBDIRS = cache chat log nosqldb queue sqldb webservice
+# Setup
+mkdir -p tmp
+mkdir -p tmp/testdb
+
+# Test
+./file-test 2>/dev/null
+rc=$?
 
+# Cleanup
+return $rc

Propchange: tuscany/sca-cpp/trunk/components/filedb/filedb-test
------------------------------------------------------------------------------
    svn:executable = *

Added: tuscany/sca-cpp/trunk/components/filedb/filedb.componentType
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/filedb/filedb.componentType?rev=1043296&view=auto
==============================================================================
--- tuscany/sca-cpp/trunk/components/filedb/filedb.componentType (added)
+++ tuscany/sca-cpp/trunk/components/filedb/filedb.componentType Wed Dec  8 03:52:27 2010
@@ -0,0 +1,28 @@
+<?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.    
+-->
+<componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+  xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
+  targetNamespace="http://tuscany.apache.org/xmlns/sca/components">
+        
+    <service name="filedb"/>
+    <property name="dbname" type="xsd:string"/>
+
+</composite>

Added: tuscany/sca-cpp/trunk/components/filedb/filedb.composite
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/filedb/filedb.composite?rev=1043296&view=auto
==============================================================================
--- tuscany/sca-cpp/trunk/components/filedb/filedb.composite (added)
+++ tuscany/sca-cpp/trunk/components/filedb/filedb.composite Wed Dec  8 03:52:27 2010
@@ -0,0 +1,33 @@
+<?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/200912"
+  xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
+  targetNamespace="http://tuscany.apache.org/xmlns/sca/components"
+  name="filedb">
+        
+    <component name="filedb">
+        <implementation.cpp path="." library="libfiledb"/>
+        <property name="dbname">tmp/testdb</property>
+        <service name="filedb">
+            <t:binding.http uri="filedb"/>
+        </service>
+    </component>     
+
+</composite>

Added: tuscany/sca-cpp/trunk/components/filedb/filedb.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/filedb/filedb.cpp?rev=1043296&view=auto
==============================================================================
--- tuscany/sca-cpp/trunk/components/filedb/filedb.cpp (added)
+++ tuscany/sca-cpp/trunk/components/filedb/filedb.cpp Wed Dec  8 03:52:27 2010
@@ -0,0 +1,123 @@
+/*
+ * 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$ */
+
+/**
+ * File based database component implementation.
+ */
+
+#include "string.hpp"
+#include "function.hpp"
+#include "list.hpp"
+#include "value.hpp"
+#include "monad.hpp"
+#include "filedb.hpp"
+
+namespace tuscany {
+namespace filedb {
+
+/**
+ * Get an item from the database.
+ */
+const failable<value> get(const list<value>& params, filedb::FileDB&
db) {
+    return filedb::get(car(params), db);
+}
+
+/**
+ * Post an item to the database.
+ */
+const failable<value> post(const list<value>& params, filedb::FileDB&
db) {
+    const value id = append<value>(car(params), mklist(mkuuid()));
+    const failable<bool> val = filedb::post(id, cadr(params), db);
+    if (!hasContent(val))
+        return mkfailure<value>(reason(val));
+    return id;
+}
+
+/**
+ * Put an item into the database.
+ */
+const failable<value> put(const list<value>& params, filedb::FileDB&
db) {
+    const failable<bool> val = filedb::put(car(params), cadr(params), db);
+    if (!hasContent(val))
+        return mkfailure<value>(reason(val));
+    return value(content(val));
+}
+
+/**
+ * Delete an item from the database.
+ */
+const failable<value> del(const list<value>& params, filedb::FileDB&
db) {
+    const failable<bool> val = filedb::del(car(params), db);
+    if (!hasContent(val))
+        return mkfailure<value>(reason(val));
+    return value(content(val));
+}
+
+/**
+ * Component implementation lambda function.
+ */
+class applyfiledb {
+public:
+    applyfiledb(filedb::FileDB& db) : db(db) {
+    }
+
+    const value operator()(const list<value>& params) const {
+        const value func(car(params));
+        if (func == "get")
+            return get(cdr(params), db);
+        if (func == "post")
+            return post(cdr(params), db);
+        if (func == "put")
+            return put(cdr(params), db);
+        if (func == "delete")
+            return del(cdr(params), db);
+        return tuscany::mkfailure<tuscany::value>();
+    }
+
+private:
+    filedb::FileDB& db;
+};
+
+/**
+ * Start the component.
+ */
+const failable<value> start(unused const list<value>& params) {
+    // Connect to the configured database and table
+    const value dbname = ((lambda<value(list<value>)>)car(params))(list<value>());
+    filedb::FileDB& db = *(new (gc_new<filedb::FileDB>()) filedb::FileDB(dbname));
+
+    // Return the component implementation lambda function
+    return value(lambda<value(const list<value>&)>(applyfiledb(db)));
+}
+
+}
+}
+
+extern "C" {
+
+const tuscany::value apply(const tuscany::list<tuscany::value>& params) {
+    const tuscany::value func(car(params));
+    if (func == "start")
+        return tuscany::filedb::start(cdr(params));
+    return tuscany::mkfailure<tuscany::value>();
+}
+
+}

Added: tuscany/sca-cpp/trunk/components/filedb/filedb.hpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/filedb/filedb.hpp?rev=1043296&view=auto
==============================================================================
--- tuscany/sca-cpp/trunk/components/filedb/filedb.hpp (added)
+++ tuscany/sca-cpp/trunk/components/filedb/filedb.hpp Wed Dec  8 03:52:27 2010
@@ -0,0 +1,142 @@
+/*
+ * 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_filedb_hpp
+#define tuscany_filedb_hpp
+
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/stat.h>
+
+#include "string.hpp"
+#include "list.hpp"
+#include "value.hpp"
+#include "monad.hpp"
+#include "fstream.hpp"
+#include "../../modules/scheme/eval.hpp"
+
+namespace tuscany {
+namespace filedb {
+
+/**
+ * Represents a FileDB connection.
+ */
+class FileDB {
+public:
+    FileDB() : owner(false) {
+    }
+
+    FileDB(const string& name) : owner(true), name(name) {
+    }
+
+    FileDB(const FileDB& c) : owner(false), name(c.name) {
+    }
+
+    ~FileDB() {
+    }
+
+private:
+    bool owner;
+    string name;
+
+    friend const string dbname(const FileDB& db);
+};
+
+/**
+ * Return the name of the database.
+ */
+const string dbname(const FileDB& db) {
+    return db.name;
+}
+
+/**
+ * Convert a key to a file name.
+ */
+const string filename(const value& key, const FileDB& db) {
+    return dbname(db) + "/" + scheme::writeValue(key);
+}
+
+/**
+ * Post a new item to the database.
+ */
+const failable<bool> post(const value& key, const value& val, FileDB& db)
{
+    debug(key, "filedb::post::key");
+    debug(val, "filedb::post::value");
+    debug(dbname(db), "filedb::post::dbname");
+
+    ofstream os(filename(key, db));
+    const string vs(scheme::writeValue(val));
+    os << vs;
+
+    debug(true, "filedb::post::result");
+    return true;
+}
+
+/**
+ * Update an item in the database. If the item doesn't exist it is added.
+ */
+const failable<bool> put(const value& key, const value& val, FileDB& db)
{
+    debug(key, "filedb::put::key");
+    debug(val, "filedb::put::value");
+    debug(dbname(db), "filedb::put::dbname");
+
+    ofstream os(filename(key, db));
+    const string vs(scheme::writeValue(val));
+    os << vs;
+
+    debug(true, "filedb::put::result");
+    return true;
+}
+
+/**
+ * Get an item from the database.
+ */
+const failable<value> get(const value& key, FileDB& db) {
+    debug(key, "filedb::get::key");
+    debug(dbname(db), "filedb::get::dbname");
+
+    ifstream is(filename(key, db));
+    if (is.fail())
+        return mkfailure<value>("Couldn't get file database entry.");
+    const value val(scheme::readValue(is));
+
+    debug(val, "filedb::get::result");
+    return val;
+}
+
+/**
+ * Delete an item from the database
+ */
+const failable<bool> del(const value& key, FileDB& db) {
+    debug(key, "filedb::delete::key");
+    debug(dbname(db), "filedb::delete::dbname");
+
+    const int rc = unlink(c_str(filename(key, db)));
+    if (rc == -1)
+        return mkfailure<bool>("Couldn't delete file database entry.");
+    debug(true, "filedb::delete::result");
+    return true;
+}
+
+}
+}
+
+#endif /* tuscany_filedb_hpp */

Copied: tuscany/sca-cpp/trunk/components/filedb/server-test (from r1043295, tuscany/sca-cpp/trunk/components/Makefile.am)
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/filedb/server-test?p2=tuscany/sca-cpp/trunk/components/filedb/server-test&p1=tuscany/sca-cpp/trunk/components/Makefile.am&r1=1043295&r2=1043296&rev=1043296&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/Makefile.am (original)
+++ tuscany/sca-cpp/trunk/components/filedb/server-test Wed Dec  8 03:52:27 2010
@@ -1,3 +1,5 @@
+#!/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
@@ -15,5 +17,24 @@
 #  specific language governing permissions and limitations
 #  under the License.
 
-SUBDIRS = cache chat log nosqldb queue sqldb webservice
+# Setup
+../../modules/http/httpd-conf tmp localhost 8090 ../../modules/http/htdocs
+../../modules/server/server-conf tmp
+../../modules/server/scheme-conf tmp
+cat >>tmp/conf/httpd.conf <<EOF
+SCAContribution `pwd`/
+SCAComposite filedb.composite
+EOF
+
+mkdir -p tmp/testdb
+../../modules/http/httpd-start tmp
+sleep 2
+
+# Test
+./client-test 2>/dev/null
+rc=$?
 
+# Cleanup
+../../modules/http/httpd-stop tmp
+sleep 2
+return $rc

Propchange: tuscany/sca-cpp/trunk/components/filedb/server-test
------------------------------------------------------------------------------
    svn:executable = *

Modified: tuscany/sca-cpp/trunk/configure.ac
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/configure.ac?rev=1043296&r1=1043295&r2=1043296&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/configure.ac (original)
+++ tuscany/sca-cpp/trunk/configure.ac Wed Dec  8 03:52:27 2010
@@ -905,6 +905,7 @@ AC_CONFIG_FILES([Makefile
                  components/log/Makefile
                  components/chat/Makefile
                  components/nosqldb/Makefile
+                 components/filedb/Makefile
                  components/queue/Makefile
                  components/sqldb/Makefile
                  components/webservice/Makefile

Modified: tuscany/sca-cpp/trunk/etc/git-exclude
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/etc/git-exclude?rev=1043296&r1=1043295&r2=1043296&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/etc/git-exclude (original)
+++ tuscany/sca-cpp/trunk/etc/git-exclude Wed Dec  8 03:52:27 2010
@@ -105,4 +105,5 @@ curl-connect
 rss-test
 scribe-cat
 js-test
+file-test
 



Mime
View raw message