You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by ja...@apache.org on 2013/02/21 16:30:45 UTC

[18/55] MARMOTTA-106: renamed packages in sesame-facading

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/ee5998d3/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/impl/FacadingInvocationHelper.java
----------------------------------------------------------------------
diff --git a/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/impl/FacadingInvocationHelper.java b/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/impl/FacadingInvocationHelper.java
new file mode 100644
index 0000000..d08c44b
--- /dev/null
+++ b/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/impl/FacadingInvocationHelper.java
@@ -0,0 +1,153 @@
+/**
+ * Copyright (C) 2013 Salzburg Research.
+ *
+ * Licensed 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.
+ */
+package org.apache.marmotta.commons.sesame.facading.impl;
+
+import org.apache.marmotta.commons.sesame.facading.util.FacadeUtils;
+import org.openrdf.model.Literal;
+import org.openrdf.model.Value;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.Locale;
+
+class FacadingInvocationHelper {
+    private FacadingInvocationHelper() {
+        // static Non-Instance Util Class
+    }
+
+    static boolean checkMethodSig(Method method, String name, int argNum) {
+        // Check the name
+        if (!method.getName().equals(name)) { return false; }
+
+        // Check # of arguments
+        final Class<?>[] pTypes = method.getParameterTypes();
+        if (pTypes.length != argNum) { return false; }
+
+        return true;
+    }
+
+    static boolean checkMethodSig(Method method, String name, Class<?>... args) {
+        // Do the basic check
+        if (!checkMethodSig(method, name, args.length)) {
+            return false;
+        }
+
+        // Check for the right parameters
+        final Class<?>[] pTypes = method.getParameterTypes();
+        for (int i = 0; i < pTypes.length; i++) {
+            Class<?> p = pTypes[i], a = args[i];
+            if (!p.isAssignableFrom(a)) { return false; }
+        }
+
+        return true;
+    }
+
+    static <A extends Annotation> A getAnnotation(Method method, Class<A> annotation) {
+        if (method.isAnnotationPresent(annotation)) { return method.getAnnotation(annotation); }
+
+        final String field = getBaseName(method);
+        Class<?> clazz = method.getDeclaringClass();
+
+        for (Method m : clazz.getMethods()) {
+            final boolean multiValue = isMultiValue(m);
+            if (m.isAnnotationPresent(annotation)) {
+                for (String op : FacadingInvocationHandler.OPERATOR.getOperatorPrefixes()) {
+                    if (m.getName().equals(op + field)) {
+                        return m.getAnnotation(annotation);
+                    } else if (multiValue && m.getName().equals(op + field + "s")) {
+                        return m.getAnnotation(annotation);
+                    } else {}
+                }
+            }
+        }
+
+        return null;
+    }
+
+    static String getBaseName(Method method) {
+        final String name = method.getName();
+        final boolean isMultiValue = isMultiValue(method);
+
+        String bName = null;
+        final String[] prefixes = FacadingInvocationHandler.OPERATOR.getLengthSortedOperatorPrefixes();
+        for (String op : prefixes) {
+            if (name.startsWith(op)) {
+                if (isMultiValue && name.endsWith("s")) {
+                    bName = name.substring(op.length(), name.length() - 1);
+                    break;
+                } else {
+                    bName = name.substring(op.length());
+                    break;
+                }
+            }
+        }
+        return bName != null ? bName : name;
+    }
+
+    static boolean isMultiValue(Method method) {
+        final FacadingInvocationHandler.OPERATOR oper = FacadingInvocationHandler.OPERATOR.getOperator(method);
+        final boolean isMultiValue = oper.writeOp && method.getParameterTypes().length == 0 ||
+                FacadeUtils.isCollection(oper.writeOp && oper.numArgs > 0 ? method.getParameterTypes()[0] : method.getReturnType());
+        return isMultiValue;
+    }
+
+    static boolean checkLocale(final Locale loc, final Value object) {
+        // Only literals can have a lang-tag
+        if (!(object instanceof Literal)) { return false; }
+
+        // Empty locale always matches
+        if (loc == null) { return true; }
+
+        return loc.getLanguage().equals(((Literal) object).getLanguage());
+    }
+
+    static <C extends Collection<?>, E> Collection<E> createCollection(Class<C> collectionType, Collection<? extends E> elements)
+            throws IllegalAccessException, InstantiationException {
+
+        final Collection<E> result;
+
+        // If the collectionType is Abstract (or an Interface) we try to guess a valid
+        // implementation...
+        if (Modifier.isAbstract(collectionType.getModifiers())) {
+            // FIXME: Maybe we should add some more implementations here?
+            if (collectionType.isAssignableFrom(HashSet.class)) {
+                result = new HashSet<E>();
+            } else if (collectionType.isAssignableFrom(LinkedList.class)) {
+                result = new LinkedList<E>();
+            } else {
+                throw new InstantiationException("Could not find an implementation of " + collectionType.getName());
+            }
+        } else {
+            result = createInstance(collectionType);
+        }
+
+        if (elements != null) {
+            result.addAll(elements);
+        }
+
+        return result;
+
+    }
+
+    @SuppressWarnings("unchecked")
+    static <E, C extends Collection<?>> Collection<E> createInstance(Class<C> collectionType) throws InstantiationException, IllegalAccessException {
+        return (Collection<E>) collectionType.newInstance();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/ee5998d3/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/impl/FacadingPredicate.java
----------------------------------------------------------------------
diff --git a/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/impl/FacadingPredicate.java b/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/impl/FacadingPredicate.java
new file mode 100644
index 0000000..c90be05
--- /dev/null
+++ b/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/impl/FacadingPredicate.java
@@ -0,0 +1,43 @@
+/**
+ * Copyright (C) 2013 Salzburg Research.
+ *
+ * Licensed 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.
+ */
+package org.apache.marmotta.commons.sesame.facading.impl;
+
+/**
+ * Simple class encapsulating the predicate/property uris.
+ */
+public class FacadingPredicate {
+
+    private final boolean inverse;
+    private final String[] properties;
+
+    public FacadingPredicate(boolean inverse, String... property) {
+        this.inverse = inverse;
+        this.properties = property;
+    }
+
+    public FacadingPredicate(String... property) {
+        this(false, property);
+    }
+
+    public boolean isInverse() {
+        return inverse;
+    }
+
+    public String[] getProperties() {
+        return properties;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/ee5998d3/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/model/AbstractNamespacePropBuilder.java
----------------------------------------------------------------------
diff --git a/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/model/AbstractNamespacePropBuilder.java b/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/model/AbstractNamespacePropBuilder.java
new file mode 100644
index 0000000..4fb832e
--- /dev/null
+++ b/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/model/AbstractNamespacePropBuilder.java
@@ -0,0 +1,33 @@
+/**
+ * Copyright (C) 2013 Salzburg Research.
+ *
+ * Licensed 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.
+ */
+package org.apache.marmotta.commons.sesame.facading.model;
+
+
+import java.lang.reflect.Method;
+
+import org.apache.marmotta.commons.sesame.facading.api.FacadingPredicateBuilder;
+import org.apache.marmotta.commons.sesame.facading.impl.FacadingPredicate;
+
+public abstract class AbstractNamespacePropBuilder implements FacadingPredicateBuilder {
+
+    @Override
+    public FacadingPredicate getFacadingPredicate(String fieldName, Class<? extends Facade> facade, Method method) {
+        return new FacadingPredicate(false, getNamespace() + fieldName);
+    }
+
+    protected abstract String getNamespace();
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/ee5998d3/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/model/Facade.java
----------------------------------------------------------------------
diff --git a/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/model/Facade.java b/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/model/Facade.java
new file mode 100644
index 0000000..4699c42
--- /dev/null
+++ b/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/model/Facade.java
@@ -0,0 +1,39 @@
+/**
+ * Copyright (C) 2013 Salzburg Research.
+ *
+ * Licensed 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.
+ */
+package org.apache.marmotta.commons.sesame.facading.model;
+
+import org.openrdf.model.Resource;
+
+/**
+ * Interface that must be the base interface of all KiWi facades. It defines no methods but has an underlying KiWiResource
+ * that is used by the KiWi client proxy to resolve the associated data in the triple store.
+ * <p/>
+ * An interface that inherits from this interface indicates that it represents a facade that can delegate getters and
+ * setters to properties in the triple store. All getter methods need to be annotated with appropriate @RDF annotations
+ * that map to a property in the triple store.
+
+ * <p/>
+ * User: Sebastian Schaffert
+ */
+public interface Facade {
+
+    /**
+     * Return the resource that is facaded by this KiWiFacade.
+     *
+     * @return
+     */
+    public Resource getDelegate();
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/ee5998d3/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/util/FacadeUtils.java
----------------------------------------------------------------------
diff --git a/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/util/FacadeUtils.java b/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/util/FacadeUtils.java
new file mode 100644
index 0000000..55d5752
--- /dev/null
+++ b/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/util/FacadeUtils.java
@@ -0,0 +1,359 @@
+/**
+ * Copyright (C) 2013 Salzburg Research.
+ *
+ * Licensed 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.
+ */
+package org.apache.marmotta.commons.sesame.facading.util;
+
+
+import org.apache.marmotta.commons.sesame.facading.model.Facade;
+import org.apache.marmotta.commons.util.DateUtils;
+import org.openrdf.model.Resource;
+import org.openrdf.model.Value;
+
+import java.lang.annotation.Annotation;
+import java.text.ParseException;
+import java.util.Collection;
+import java.util.Date;
+import java.util.Locale;
+
+/**
+ * @author Sebastian Schaffert
+ *
+ */
+public class FacadeUtils {
+
+    /**
+     * Check whether a type is a Facade, i.e. inherits from the {@link Facade} interface
+     * 
+     * @param <C>
+     * @param clazz
+     * @return
+     */
+    public static <C> boolean isFacade(Class<C> clazz) {
+        return Facade.class.isAssignableFrom(clazz);
+    }
+
+    /**
+     * Check whether a type is a {@link Value}.
+     * 
+     * @param <C>
+     * @param clazz
+     * @return
+     */
+    public static <C> boolean isValue(Class<C> clazz) {
+        return Value.class.isAssignableFrom(clazz);
+    }
+
+    /**
+     * Check whether a type is a {@link Resource}.
+     * 
+     * @param <C>
+     * @param clazz
+     * @return
+     */
+    public static <C> boolean isResource(Class<C> clazz) {
+        return Resource.class.isAssignableFrom(clazz);
+    }
+
+
+    /**
+     * Check whether a type is a {@link Facade}, i.e. the type or one of its superinterfaces has the
+     * {@link Facade} annotation.
+     * 
+     * @param <C>
+     * @param clazz
+     * @return
+     */
+    public static <C> boolean isFacadeAnnotationPresent(Class<C> clazz, Class<? extends Annotation> annotation) {
+        if (clazz.isAnnotationPresent(annotation)) {
+            return true;
+        } else {
+            for(final Class<?> iface : clazz.getInterfaces()) {
+                if(iface.isAnnotationPresent(annotation)) {
+                    return true;
+                }
+            }
+            if (clazz.getSuperclass() != null) {
+                return isFacadeAnnotationPresent(clazz.getSuperclass(),annotation);
+            }
+            return false;
+        }
+    }
+
+
+    public static <C extends Annotation,D> C getFacadeAnnotation(Class<D> clazz, Class<C> annotation) {
+        if (clazz.isAnnotationPresent(annotation)) {
+            return clazz.getAnnotation(annotation);
+        } else {
+            for(final Class<?> iface : clazz.getInterfaces()) {
+                if(iface.isAnnotationPresent(annotation)) {
+                    return iface.getAnnotation(annotation);
+                }
+            }
+            if (clazz.getSuperclass() != null) {
+                return getFacadeAnnotation(clazz.getSuperclass(),annotation);
+            }
+            return null;
+        }
+
+    }
+
+
+    /**
+     * Returns true if the <code>clazz</code> argument is a {@link Facade}, otherwise it returns
+     * false.
+     * 
+     * @param in
+     *            the argument to test.
+     * @return true if the <code>clazz</code> argument is a {@link Facade}.
+     */
+    public static boolean isFacade(Object in) {
+
+        if (in == null) {
+            return false;
+        }
+
+        final Class<?> clazz = in.getClass();
+        final boolean result = isFacade(clazz);
+
+        return result;
+    }
+
+    /**
+     * Check whether a type is a collection (List, Set, ...).
+     *
+     * @param <C> the type of the class modeled by the
+     *            <code>clazz</code> argument Class object. For
+     *            example, the type of String.class is Class
+     *            &lt;String&gt;
+     * @param clazz the type to test.
+     * @return true if the type to test is a a type is a
+     *         collection (List, Set, ...).
+     */
+    public static <C> boolean isCollection(Class<C> clazz) {
+
+        if (clazz == null) {
+            return false;
+        }
+
+        return Collection.class.isAssignableFrom(clazz);
+    }
+
+
+    /**
+     * Returns true if the <code>clazz</code> argument is a:
+     * <ul>
+     * <li>a primitive
+     * <li>a primitive wrapper
+     * <li>a java.lang.Locale class
+     * <li>a java.lang.Date class
+     * <li>a java.lang.String class
+     * </ul>
+     * otherwise it returns false.
+     * 
+     * @param <C>
+     *            the type of the class modeled by the <code>clazz</code> argument Class object. For
+     *            example, the type of String.class is Class &lt;String&gt.
+     * @param clazz
+     *            the argument to test.
+     * @return true if the <code>clazz</code> argument is a primitive, primitive wrapper, locale,
+     *         date or String.
+     */
+    public static <C> boolean isBaseType(Class<C> clazz) {
+
+        if (clazz == null) {
+            return false;
+        }
+
+        final boolean isPrimitive = clazz.isPrimitive();
+        if (isPrimitive) {
+            return true;
+        }
+
+        // if I compare the Locale.class with the clazz argument
+        // I can avoid the infamous case when the clazz is null,
+        // the Locale.class.equals(null) is false, always - at
+        // least this sustains the theory. The same logic for
+        // the other equals realtions.
+        final boolean isLocale = Locale.class.equals(clazz);
+        if (isLocale) {
+            return true;
+        }
+
+        final boolean isDate = Date.class.equals(clazz);
+        if (isDate) {
+            return true;
+        }
+
+        final boolean isString = String.class.equals(clazz);
+        if (isString) {
+            return true;
+        }
+
+        final boolean isBoolean = Boolean.class.equals(clazz);
+        if (isBoolean) {
+            return true;
+        }
+
+        final Class<? super C> superClass = clazz.getSuperclass();
+        final boolean isNumber = Number.class.equals(superClass);
+        if (isNumber) {
+            return true;
+        }
+
+        // even if the char is a primitive is not a number
+        final boolean isCharacter = Character.class.equals(clazz);
+        if (isCharacter) {
+            return true;
+        }
+
+        return false;
+    }
+
+    /**
+     * Returns true if the <code>clazz</code> argument is a:
+     * <ul>
+     * <li>a primitive
+     * <li>a primitive wrapper
+     * </ul>
+     * otherwise it returns false.
+     *
+     * @param <C> the type of the class modeled by the
+     *            <code>clazz</code> argument Class object. For
+     *            example, the type of String.class is Class
+     *            &lt;String&gt.
+     * @param clazz the argument to test.
+     * @return true if the <code>clazz</code> argument is a
+     *         primitive or primitive wrapper.
+     */
+    public static <C> boolean isPrimitive(Class<C> clazz) {
+
+        if (clazz == null) {
+            return false;
+        }
+
+        final boolean isPrimitive = clazz.isPrimitive();
+        if (isPrimitive) {
+            return true;
+        }
+
+        // even if the char is a primitive is not a number
+        final boolean isCharacter = Character.class.equals(clazz);
+        if (isCharacter) {
+            return true;
+        }
+
+        final Class<? super C> superClass = clazz.getSuperclass();
+        final boolean isNumber = Number.class.equals(superClass);
+        if (isNumber) {
+            return true;
+        }
+
+        return false;
+    }
+
+    /**
+     * Returns true if the <code>in</code> argument is a:
+     * <ul>
+     * <li>a primitive
+     * <li>a primitive wrapper
+     * </ul>
+     * otherwise it returns false.
+     *
+     * @param in the argument to test.
+     * @return true if the <code>clazz</code> argument is a
+     *         primitive or primitive wrapper.
+     */
+    public static boolean isPrimitive(Object in) {
+        if (in == null) {
+            return false;
+        }
+
+        final Class<?> clazz = in.getClass();
+        return isPrimitive(clazz);
+    }
+
+
+    /**
+     * Transform a value passed as string to the base type (i.e. non-complex type) given as argument
+     *
+     * @param <T>
+     * @param value
+     * @param returnType
+     * @return
+     * @throws IllegalArgumentException
+     */
+    public static <T> T transformToBaseType(String value, Class<T> returnType) throws IllegalArgumentException {
+        // transformation to appropriate primitive type
+        if(Integer.class.equals(returnType) || int.class.equals(returnType)) {
+            if(value == null) {
+                return returnType.cast(0);
+            }
+            return returnType.cast(Integer.parseInt(value));
+        } else if(Long.class.equals(returnType) || long.class.equals(returnType)) {
+            if(value == null) {
+                return returnType.cast(0L);
+            }
+            return returnType.cast(Long.parseLong(value));
+        } else if(Double.class.equals(returnType) || double.class.equals(returnType)) {
+            if(value == null) {
+                return returnType.cast(0.0);
+            }
+            return returnType.cast(Double.parseDouble(value));
+        } else if(Float.class.equals(returnType) || float.class.equals(returnType)) {
+            if(value == null) {
+                return returnType.cast(0.0F);
+            }
+            return returnType.cast(Float.parseFloat(value));
+        } else if(Byte.class.equals(returnType) || byte.class.equals(returnType)) {
+            if(value == null) {
+                return returnType.cast((byte) 0);
+            }
+            return returnType.cast(Byte.parseByte(value));
+        } else if(Boolean.class.equals(returnType) || boolean.class.equals(returnType)) {
+            return returnType.cast(Boolean.parseBoolean(value));
+        } else if(Character.class.equals(returnType) || char.class.equals(returnType)) {
+            if(value == null) {
+                return null;
+            } else if(value.length() > 0) {
+                return returnType.cast(value.charAt(0));
+            } else {
+                return null;
+            }
+        } else if (Locale.class.equals(returnType)) {
+            if(value == null) {
+                return null;
+            } else {
+                return returnType.cast(new Locale(value));
+            }
+        } else if (Date.class.equals(returnType)) {
+            if(value == null) {
+                return null;
+            } else {
+                try {
+                    return returnType.cast(DateUtils.ISO8601FORMAT.parse(value));
+                } catch (final ParseException e) {
+                    e.printStackTrace();
+                    return null;
+                }
+            }
+        } else if(String.class.equals(returnType)) {
+            return returnType.cast(value);
+        } else {
+            throw new IllegalArgumentException("primitive type "+returnType.getName()+" not supported by transformation");
+        }
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/ee5998d3/commons/sesame-tools-facading/src/test/java/facading/AbstractFacadingTest.java
----------------------------------------------------------------------
diff --git a/commons/sesame-tools-facading/src/test/java/facading/AbstractFacadingTest.java b/commons/sesame-tools-facading/src/test/java/facading/AbstractFacadingTest.java
deleted file mode 100644
index cd7e475..0000000
--- a/commons/sesame-tools-facading/src/test/java/facading/AbstractFacadingTest.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package facading;
-
-import org.junit.After;
-import org.junit.Before;
-import org.openrdf.repository.Repository;
-import org.openrdf.repository.RepositoryException;
-import org.openrdf.repository.sail.SailRepository;
-import org.openrdf.rio.RDFParseException;
-import org.openrdf.sail.memory.MemoryStore;
-
-import java.io.IOException;
-
-public abstract class AbstractFacadingTest {
-
-    protected Repository repositoryRDF;
-
-    @Before
-    public void setup() throws RepositoryException, IOException, RDFParseException {
-        repositoryRDF = new SailRepository(new MemoryStore());
-        repositoryRDF.initialize();
-    }
-
-    @After
-    public void tearDown() throws RepositoryException {
-        repositoryRDF.shutDown();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/ee5998d3/commons/sesame-tools-facading/src/test/java/facading/builder/FacadingPredicateBuilderTest.java
----------------------------------------------------------------------
diff --git a/commons/sesame-tools-facading/src/test/java/facading/builder/FacadingPredicateBuilderTest.java b/commons/sesame-tools-facading/src/test/java/facading/builder/FacadingPredicateBuilderTest.java
deleted file mode 100644
index 3c78e2c..0000000
--- a/commons/sesame-tools-facading/src/test/java/facading/builder/FacadingPredicateBuilderTest.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (c) 2013 Salzburg Research.
- *
- *  Licensed 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.
- */
-
-package facading.builder;
-
-import static org.hamcrest.CoreMatchers.allOf;
-import static org.hamcrest.CoreMatchers.hasItem;
-
-import at.newmedialab.sesame.facading.FacadingFactory;
-import at.newmedialab.sesame.facading.api.Facading;
-import facading.AbstractFacadingTest;
-import facading.builder.model.ExampleFacade;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.openrdf.model.Literal;
-import org.openrdf.model.URI;
-import org.openrdf.repository.RepositoryConnection;
-import org.openrdf.repository.RepositoryException;
-import org.openrdf.rio.RDFParseException;
-
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.Set;
-
-public class FacadingPredicateBuilderTest extends AbstractFacadingTest {
-
-    private RepositoryConnection connection;
-    private Facading facading;
-
-    @Override
-    @Before
-    public void setup() throws RepositoryException, IOException, RDFParseException {
-        super.setup();
-
-        connection = repositoryRDF.getConnection();
-        facading = FacadingFactory.createFacading(connection);
-    }
-
-    @Test
-    public void testPredicateBuilder() throws RepositoryException {
-        final URI u = connection.getValueFactory().createURI("http://localhost/repository/testResource1");
-        ExampleFacade f = facading.createFacade(u, ExampleFacade.class);
-
-        String title = "Example Title";
-        Set<String> tags = new HashSet<String>();
-        tags.add("Foo");
-        tags.add("Bar");
-
-        f.setTitle(title);
-        f.setTags(tags);
-
-        checkStatement(u, ExampleFacade.NS + "title", title);
-        checkStatement(u, ExampleFacade.NS + "tag", "Foo");
-        checkStatement(u, ExampleFacade.NS + "tag", "Bar");
-
-        Assert.assertEquals(f.getTitle(), title);
-        Assert.assertThat(f.getTags(), allOf(hasItem("Foo"), hasItem("Bar")));
-
-        f.addTag("FooBar");
-        checkStatement(u, ExampleFacade.NS + "tag", "FooBar");
-        Assert.assertThat(f.getTags(), allOf(hasItem("FooBar"), hasItem("Foo"), hasItem("Bar")));
-
-    }
-
-    private void checkStatement(URI s, String prop, String val) throws RepositoryException {
-        final URI propURI = connection.getValueFactory().createURI(prop);
-        final Literal value = connection.getValueFactory().createLiteral(val);
-
-        Assert.assertTrue(String.format("Did not find Statement '<%s> <%s> \"%s\"'", s.stringValue(), prop, val),
-                connection.hasStatement(s, propURI, value, true));
-    }
-
-    @Override
-    @After
-    public void tearDown() throws RepositoryException {
-        if (connection != null) {
-            connection.rollback();
-            connection.close();
-        }
-
-        super.tearDown();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/ee5998d3/commons/sesame-tools-facading/src/test/java/facading/builder/model/ExampleFacade.java
----------------------------------------------------------------------
diff --git a/commons/sesame-tools-facading/src/test/java/facading/builder/model/ExampleFacade.java b/commons/sesame-tools-facading/src/test/java/facading/builder/model/ExampleFacade.java
deleted file mode 100644
index 230d933..0000000
--- a/commons/sesame-tools-facading/src/test/java/facading/builder/model/ExampleFacade.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package facading.builder.model;
-
-import at.newmedialab.sesame.facading.annotations.RDFPropertyBuilder;
-import at.newmedialab.sesame.facading.model.Facade;
-
-import java.util.Set;
-
-@RDFPropertyBuilder(ExamplePropBuilder.class)
-public interface ExampleFacade extends Facade {
-
-    public static final String NS = "http://www.example.com/vocab/test#";
-
-    void setTitle(String title);
-    String getTitle();
-
-    void setTags(Set<String> tags);
-    void addTag(String tag);
-    Set<String> getTags();
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/ee5998d3/commons/sesame-tools-facading/src/test/java/facading/builder/model/ExamplePropBuilder.java
----------------------------------------------------------------------
diff --git a/commons/sesame-tools-facading/src/test/java/facading/builder/model/ExamplePropBuilder.java b/commons/sesame-tools-facading/src/test/java/facading/builder/model/ExamplePropBuilder.java
deleted file mode 100644
index e2ec1a5..0000000
--- a/commons/sesame-tools-facading/src/test/java/facading/builder/model/ExamplePropBuilder.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package facading.builder.model;
-
-import at.newmedialab.sesame.facading.model.AbstractNamespacePropBuilder;
-
-public class ExamplePropBuilder extends AbstractNamespacePropBuilder {
-
-    @Override
-    protected String getNamespace() {
-        return ExampleFacade.NS;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/ee5998d3/commons/sesame-tools-facading/src/test/java/facading/collections/CollectionFacadingTest.java
----------------------------------------------------------------------
diff --git a/commons/sesame-tools-facading/src/test/java/facading/collections/CollectionFacadingTest.java b/commons/sesame-tools-facading/src/test/java/facading/collections/CollectionFacadingTest.java
deleted file mode 100644
index d3c40fa..0000000
--- a/commons/sesame-tools-facading/src/test/java/facading/collections/CollectionFacadingTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-package facading.collections;
-
-import static org.hamcrest.CoreMatchers.hasItems;
-
-import at.newmedialab.sesame.facading.FacadingFactory;
-import at.newmedialab.sesame.facading.api.Facading;
-import facading.AbstractFacadingTest;
-import facading.collections.model.CollectionFacade;
-import org.hamcrest.CoreMatchers;
-import org.junit.Assert;
-import org.junit.Test;
-import org.openrdf.model.URI;
-import org.openrdf.repository.RepositoryConnection;
-import org.openrdf.repository.RepositoryException;
-
-import java.util.Arrays;
-import java.util.Date;
-import java.util.Random;
-import java.util.UUID;
-
-public class CollectionFacadingTest extends AbstractFacadingTest {
-
-    @Test
-    public void testCollectionFacading() throws RepositoryException {
-        final RepositoryConnection connection = repositoryRDF.getConnection();
-
-        final Random rnd = new Random();
-        final Date a, b, c, d, e, now;
-        now = new Date();
-        // Start 10Yrs back;
-        final int tenYrsInSecs = 10 * 365 * 24 * 60 * 60;
-        a = new Date(now.getTime() - tenYrsInSecs * 1000L);
-        b = new Date(a.getTime() + rnd.nextInt(tenYrsInSecs) * 1000L);
-        c = new Date(a.getTime() + rnd.nextInt(tenYrsInSecs) * 1000L);
-        d = new Date(a.getTime() + rnd.nextInt(tenYrsInSecs) * 1000L);
-        e = new Date(a.getTime() + rnd.nextInt(tenYrsInSecs) * 1000L);
-
-        try {
-            final Facading facading = FacadingFactory.createFacading(connection);
-
-            URI uri = connection.getValueFactory().createURI("http://www.example.com/rdf/test/collections");
-            CollectionFacade facade = facading.createFacade(uri, CollectionFacade.class);
-
-            facade.setDates(Arrays.asList(a, b, c));
-            Assert.assertThat(facade.getDates(), hasItems(a, b, c));
-
-            facade.addDate(e);
-            Assert.assertThat(facade.getDates(), hasItems(c, e, b, a));
-
-            facade.setDates(Arrays.asList(a, d, now));
-            Assert.assertThat(facade.getDates(), hasItems(a, d, now));
-            Assert.assertThat(facade.getDates(), CoreMatchers.not(hasItems(c, e, b)));
-
-            facade.deleteDates();
-            Assert.assertEquals(facade.getDates().size(), 0);
-        } finally {
-            connection.close();
-        }
-    }
-
-    @Test
-    public void testAutorFacading() throws RepositoryException {
-        final RepositoryConnection connection = repositoryRDF.getConnection();
-
-        String a1 = UUID.randomUUID().toString(), a2 = UUID.randomUUID().toString(), a3 = UUID.randomUUID().toString();
-
-        try {
-            final Facading facading = FacadingFactory.createFacading(connection);
-
-            URI uri = connection.getValueFactory().createURI("http://www.example.com/rdf/test/document");
-            CollectionFacade facade = facading.createFacade(uri, CollectionFacade.class);
-
-            facade.setAutors(Arrays.asList(a1, a2));
-
-            facade.addAutor(a3);
-
-            connection.commit();
-        } finally {
-            connection.close();
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/ee5998d3/commons/sesame-tools-facading/src/test/java/facading/collections/model/CollectionFacade.java
----------------------------------------------------------------------
diff --git a/commons/sesame-tools-facading/src/test/java/facading/collections/model/CollectionFacade.java b/commons/sesame-tools-facading/src/test/java/facading/collections/model/CollectionFacade.java
deleted file mode 100644
index c851c96..0000000
--- a/commons/sesame-tools-facading/src/test/java/facading/collections/model/CollectionFacade.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package facading.collections.model;
-
-import at.newmedialab.sesame.facading.annotations.RDF;
-import at.newmedialab.sesame.facading.model.Facade;
-
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
-
-public interface CollectionFacade extends Facade {
-
-    @RDF("http://www.example.com/rdf/vocab/date")
-    public List<Date> getDates();
-    public void setDates(List<Date> dates);
-    public void addDate(Date date);
-    public void deleteDates();
-
-    @RDF("http://www.example.com/rdf/vocab/autor")
-    public void addAutor(String autor);
-    public void setAutors(Collection<String> authors);
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/ee5998d3/commons/sesame-tools-facading/src/test/java/facading/foaf/FacadingFoafTest.java
----------------------------------------------------------------------
diff --git a/commons/sesame-tools-facading/src/test/java/facading/foaf/FacadingFoafTest.java b/commons/sesame-tools-facading/src/test/java/facading/foaf/FacadingFoafTest.java
deleted file mode 100644
index fce337b..0000000
--- a/commons/sesame-tools-facading/src/test/java/facading/foaf/FacadingFoafTest.java
+++ /dev/null
@@ -1,256 +0,0 @@
-package facading.foaf;
-
-import static org.hamcrest.CoreMatchers.allOf;
-import static org.hamcrest.CoreMatchers.hasItem;
-import static org.hamcrest.CoreMatchers.hasItems;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.Matchers.hasProperty;
-import static org.junit.Assume.assumeThat;
-
-import at.newmedialab.sesame.facading.FacadingFactory;
-import at.newmedialab.sesame.facading.api.Facading;
-import facading.AbstractFacadingTest;
-import facading.foaf.model.OnlineAccount;
-import facading.foaf.model.Person;
-
-import org.apache.marmotta.commons.sesame.model.Namespaces;
-import org.hamcrest.CoreMatchers;
-import org.junit.Assert;
-import org.junit.Assume;
-import org.junit.Before;
-import org.junit.Test;
-import org.openrdf.model.Resource;
-import org.openrdf.model.Statement;
-import org.openrdf.model.URI;
-import org.openrdf.repository.RepositoryConnection;
-import org.openrdf.repository.RepositoryException;
-import org.openrdf.repository.RepositoryResult;
-import org.openrdf.rio.RDFFormat;
-import org.openrdf.rio.RDFParseException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * Test if facading works for the FOAF examples
- * <p/>
- * Author: Sebastian Schaffert
- */
-public class FacadingFoafTest extends AbstractFacadingTest {
-    private static Logger log = LoggerFactory.getLogger(FacadingFoafTest.class);
-
-    @Before
-    public void loadData() throws RepositoryException, IOException, RDFParseException {
-
-        // load demo data
-        InputStream rdfXML = this.getClass().getResourceAsStream("/foaf/demo-data.foaf");
-        assumeThat("Could not load test-data: demo-data.foaf", rdfXML, notNullValue(InputStream.class));
-
-        RepositoryConnection connectionRDF = repositoryRDF.getConnection();
-        try {
-            connectionRDF.add(rdfXML, "http://localhost/foaf/", RDFFormat.RDFXML);
-            connectionRDF.commit();
-        } finally {
-            connectionRDF.close();
-        }
-    }
-
-    /**
-     * Test if we can access the data contained in a FOAF file via the facading
-     *
-     * @throws Exception
-     */
-    @Test
-    public void testAccessData() throws Exception {
-
-        RepositoryConnection connectionRDF = repositoryRDF.getConnection();
-        try {
-
-            // list all resources contained in the repository and create facades over them
-            Set<Resource> resources = new HashSet<Resource>();
-            RepositoryResult<Statement> triples = connectionRDF.getStatements(null,null,null,true);
-            while(triples.hasNext()) {
-                resources.add(triples.next().getSubject());
-            }
-            triples.close();
-
-            Facading facading = FacadingFactory.createFacading(connectionRDF);
-
-            // test individual resource
-            URI u_hans_meier = connectionRDF.getValueFactory().createURI("http://localhost:8080/LMF/resource/hans_meier");
-            URI u_anna_schmidt = connectionRDF.getValueFactory().createURI("http://localhost:8080/LMF/resource/anna_schmidt");
-            Person hans_meier = facading.createFacade(u_hans_meier,Person.class);
-
-            Assert.assertEquals("Hans Meier",hans_meier.getName());
-            Assert.assertEquals(2,hans_meier.getFriends().size());
-            Assert.assertThat(hans_meier.getOnlineAccounts(),
-                    CoreMatchers.<OnlineAccount> hasItem(hasProperty("accountName", is("Example"))));
-
-            Assert.assertThat(hans_meier.getFriends(), allOf(
-                    CoreMatchers.<Person> hasItem(hasProperty("name", is("Anna Schmidt"))),
-                    CoreMatchers.<Person> hasItem(hasProperty("name", is("Sepp Huber")))
-                    ));
-
-            // test collection
-            Collection<Person> persons = facading.createFacade(resources,Person.class);
-            Assert.assertEquals(3, persons.size());
-            Assert.assertThat(persons,allOf(
-                    CoreMatchers.<Person> hasItem(hasProperty("name", is("Hans Meier"))),
-                    CoreMatchers.<Person> hasItem(hasProperty("name", is("Anna Schmidt"))),
-                    CoreMatchers.<Person> hasItem(hasProperty("name", is("Sepp Huber")))
-                    )
-                    );
-
-            connectionRDF.commit();
-        } finally {
-            connectionRDF.close();
-        }
-    }
-
-    /**
-     * Test if we can access the data contained in a FOAF file via the facading
-     *
-     * @throws Exception
-     */
-    @Test
-    public void testModifyData() throws Exception {
-        RepositoryConnection connectionRDF = repositoryRDF.getConnection();
-        try {
-            // list all resources contained in the repository and create facades over them
-            Set<Resource> resources = new HashSet<Resource>();
-            RepositoryResult<Statement> triples = connectionRDF.getStatements(null,null,null,true);
-            while(triples.hasNext()) {
-                resources.add(triples.next().getSubject());
-            }
-            triples.close();
-
-            Facading facading = FacadingFactory.createFacading(connectionRDF);
-
-            // test individual resource
-            URI u_hans_meier = connectionRDF.getValueFactory().createURI("http://localhost:8080/LMF/resource/hans_meier");
-            Person hans_meier = facading.createFacade(u_hans_meier,Person.class);
-
-            Assert.assertNull(hans_meier.getNick());
-
-            // set nick name and check if it is now set
-            hans_meier.setNick("hansi");
-            Assert.assertNotNull(hans_meier.getNick());
-            Assert.assertEquals("hansi",hans_meier.getNick());
-
-            // check in triple store if the triple is there
-            URI p_foaf_nick = connectionRDF.getValueFactory().createURI(Namespaces.NS_FOAF + "nick");
-            RepositoryResult<Statement> nicknames = connectionRDF.getStatements(u_hans_meier,p_foaf_nick,null,true);
-            Assert.assertTrue(nicknames.hasNext());
-            Assert.assertEquals("hansi",nicknames.next().getObject().stringValue());
-            nicknames.close();
-
-            // test creating a completely new resource
-            URI u_fritz_fischer = connectionRDF.getValueFactory().createURI("http://localhost:8080/LMF/resource/fritz_fischer");
-            Person fritz_fischer = facading.createFacade(u_fritz_fischer,Person.class);
-            fritz_fischer.setName("Fritz Fischer");
-
-            Assert.assertEquals("Fritz Fischer", fritz_fischer.getName());
-
-            // test if it is now there
-            URI p_foaf_name = connectionRDF.getValueFactory().createURI(Namespaces.NS_FOAF + "name");
-            RepositoryResult<Statement> names = connectionRDF.getStatements(u_fritz_fischer,p_foaf_name,null,true);
-            Assert.assertTrue(names.hasNext());
-            Assert.assertEquals("Fritz Fischer",names.next().getObject().stringValue());
-            names.close();
-
-            // test extending a collection
-            Set<Person> hans_friends = hans_meier.getFriends();
-            hans_friends.add(fritz_fischer);
-            hans_meier.setFriends(hans_friends);
-
-            Assert.assertEquals(3,hans_meier.getFriends().size());
-            Assert.assertThat(hans_meier.getFriends(), allOf(
-                    CoreMatchers.<Person> hasItem(hasProperty("name", is("Anna Schmidt"))),
-                    CoreMatchers.<Person> hasItem(hasProperty("name", is("Fritz Fischer"))),
-                    CoreMatchers.<Person> hasItem(hasProperty("name", is("Sepp Huber")))
-                    ));
-
-            Assert.assertTrue(hans_meier.hasFriends());
-
-            connectionRDF.commit();
-        } finally {
-            connectionRDF.close();
-        }
-    }
-
-    @Test
-    public void testReadInverseRDF() throws RepositoryException {
-
-        final RepositoryConnection connection = repositoryRDF.getConnection();
-        try {
-            final Facading facading = FacadingFactory.createFacading(connection);
-
-            URI u_hans_meier = connection.getValueFactory().createURI("http://localhost:8080/LMF/resource/hans_meier");
-            Person hans_meier = facading.createFacade(u_hans_meier, Person.class);
-            Assume.assumeThat("Could not load test-person", hans_meier, notNullValue(Person.class));
-
-            for (OnlineAccount account : hans_meier.getOnlineAccounts()) {
-                Assert.assertNotNull(account);
-                final Resource accountRSC = account.getDelegate();
-                Assert.assertNotNull(accountRSC);
-
-                final OnlineAccount oa = facading.createFacade(accountRSC, OnlineAccount.class);
-                Assert.assertNotNull(oa);
-
-                Assert.assertEquals(hans_meier, oa.getHolder());
-            }
-
-        } finally {
-            connection.close();
-        }
-    }
-
-    @Test
-    public void testWriteInverserRDF() throws RepositoryException {
-        final RepositoryConnection connection = repositoryRDF.getConnection();
-        try {
-            final Facading facading = FacadingFactory.createFacading(connection);
-
-            URI p = connection.getValueFactory().createURI("http://localhost/person");
-            Person person = facading.createFacade(p, Person.class);
-
-            URI a = connection.getValueFactory().createURI("http://localhost/account");
-            OnlineAccount account = facading.createFacade(a, OnlineAccount.class);
-
-            account.setHolder(person);
-
-            connection.commit();
-
-            Assert.assertThat(person.getOnlineAccounts(), CoreMatchers.hasItem(account));
-
-        } finally {
-            connection.close();
-        }
-    }
-
-    @Test
-    public void testAdd() throws RepositoryException {
-        final RepositoryConnection connection = repositoryRDF.getConnection();
-        try {
-            final Facading facading = FacadingFactory.createFacading(connection);
-
-            URI a = connection.getValueFactory().createURI("http://localhost/account");
-            OnlineAccount account = facading.createFacade(a, OnlineAccount.class);
-
-            account.addChatId("foo");
-            Assert.assertThat(account.getChatId(), hasItem("foo"));
-            account.addChatId("bar");
-            Assert.assertThat(account.getChatId(), hasItems("foo", "bar"));
-            Assert.assertThat(account.getChatId(), hasItems("bar", "foo"));
-        } finally {
-            connection.close();
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/ee5998d3/commons/sesame-tools-facading/src/test/java/facading/foaf/model/OnlineAccount.java
----------------------------------------------------------------------
diff --git a/commons/sesame-tools-facading/src/test/java/facading/foaf/model/OnlineAccount.java b/commons/sesame-tools-facading/src/test/java/facading/foaf/model/OnlineAccount.java
deleted file mode 100644
index 872b5ac..0000000
--- a/commons/sesame-tools-facading/src/test/java/facading/foaf/model/OnlineAccount.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- *  Copyright (c) 2012 Salzburg Research.
- *
- *  Licensed 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.
- */
-package facading.foaf.model;
-
-
-import at.newmedialab.sesame.facading.annotations.RDF;
-import at.newmedialab.sesame.facading.annotations.RDFInverse;
-import at.newmedialab.sesame.facading.annotations.RDFType;
-import at.newmedialab.sesame.facading.model.Facade;
-
-import java.util.Date;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.marmotta.commons.sesame.model.Namespaces;
-
-/**
- * @author Stephanie Stroka
- * User: Stephanie Stroka
- * Date: 18.05.2011
- * Time: 11:29:17
- */
-@RDFType(Namespaces.NS_FOAF + "OnlineAccount")
-public interface OnlineAccount extends Facade {
-
-    @RDF(Namespaces.NS_FOAF + "accountServiceHomepage")
-    public String getAccountServiceHomepage();
-    public void setAccountServiceHomepage(String accountServiceHomepage);
-
-    @RDF(Namespaces.NS_FOAF + "accountName")
-    public String getAccountName();
-    public void setAccountName(String accountName);
-
-    @RDFInverse(Namespaces.NS_FOAF + "account")
-    public Person getHolder();
-    public void setHolder(Person holder);
-
-    @RDF(Namespaces.NS_FOAF + "chatId")
-    public Set<String> getChatId();
-    public void addChatId(String chatId);
-
-    @RDF("http://www.example.com/rdf/vocab/login")
-    public List<Date> getLoginDate();
-    public void addLoginDate(Date login);
-    public void setLoginDate(List<Date> logins);
-}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/ee5998d3/commons/sesame-tools-facading/src/test/java/facading/foaf/model/Person.java
----------------------------------------------------------------------
diff --git a/commons/sesame-tools-facading/src/test/java/facading/foaf/model/Person.java b/commons/sesame-tools-facading/src/test/java/facading/foaf/model/Person.java
deleted file mode 100644
index 6ce75bf..0000000
--- a/commons/sesame-tools-facading/src/test/java/facading/foaf/model/Person.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package facading.foaf.model;
-
-
-import at.newmedialab.sesame.facading.annotations.RDF;
-import at.newmedialab.sesame.facading.annotations.RDFFilter;
-import at.newmedialab.sesame.facading.annotations.RDFType;
-import at.newmedialab.sesame.facading.model.Facade;
-
-import org.apache.marmotta.commons.sesame.model.Namespaces;
-import org.openrdf.model.URI;
-
-import java.util.Set;
-
-/**
- * Sample facade to describe a foaf:Person
- * <p/>
- * Author: Sebastian Schaffert
- */
-@RDFType(Namespaces.NS_FOAF + "Person")
-@RDFFilter(Namespaces.NS_FOAF + "Person")
-public interface Person extends Facade {
-
-    @RDF(Namespaces.NS_FOAF + "nick")
-    public String getNick();
-    public void setNick(String nick);
-
-    /**
-     * The  name of the user; mapped to the foaf:name RDF property
-     */
-    @RDF(Namespaces.NS_FOAF + "name")
-    public String getName();
-    public void setName(String firstName);
-
-
-    @RDF(Namespaces.NS_FOAF + "mbox")
-    public String getMbox();
-    public void setMbox(String mbox);
-
-    @RDF(Namespaces.NS_FOAF + "depiction")
-    public URI getDepiciton();
-    public void setDepiction(URI depiction);
-
-    @RDF(Namespaces.NS_FOAF + "account")
-    public Set<OnlineAccount> getOnlineAccounts();
-    public void setOnlineAccounts(Set<OnlineAccount> onlineAccounts);
-
-    @RDF(Namespaces.NS_FOAF + "knows")
-    public Set<Person> getFriends();
-    public void setFriends(Set<Person> friends);
-    public boolean hasFriends();
-}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/ee5998d3/commons/sesame-tools-facading/src/test/java/facading/locale/LocaleFacadingTest.java
----------------------------------------------------------------------
diff --git a/commons/sesame-tools-facading/src/test/java/facading/locale/LocaleFacadingTest.java b/commons/sesame-tools-facading/src/test/java/facading/locale/LocaleFacadingTest.java
deleted file mode 100644
index aa67685..0000000
--- a/commons/sesame-tools-facading/src/test/java/facading/locale/LocaleFacadingTest.java
+++ /dev/null
@@ -1,92 +0,0 @@
-package facading.locale;
-
-
-import static org.hamcrest.CoreMatchers.anyOf;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
-
-import at.newmedialab.sesame.facading.FacadingFactory;
-import at.newmedialab.sesame.facading.api.Facading;
-import facading.AbstractFacadingTest;
-import facading.locale.model.LocaleFacade;
-import org.junit.Test;
-import org.openrdf.model.URI;
-import org.openrdf.repository.RepositoryConnection;
-import org.openrdf.repository.RepositoryException;
-
-import java.util.Locale;
-
-public class LocaleFacadingTest extends AbstractFacadingTest {
-
-    @Test
-    public void testWithLocale() throws RepositoryException {
-        final Locale de = Locale.GERMAN, en = Locale.ENGLISH, fr = Locale.FRENCH, none = new Locale("none");
-
-        final String lbl = "Label",
-                lbl_de = lbl + ": " + de.toString(),
-                lbl_en = lbl + ": " + en.toString(),
-                lbl_fr = lbl + ": " + fr.toString(),
-                lbl_none = lbl + ": " + none.toString();
-
-        final RepositoryConnection connection = repositoryRDF.getConnection();
-        try {
-            final Facading facading = FacadingFactory.createFacading(connection);
-
-            final URI uri = connection.getValueFactory().createURI("http://www.example.com/rdf/test/locale");
-            final LocaleFacade f = facading.createFacade(uri, LocaleFacade.class);
-
-            f.setLabel(lbl);
-            assertEquals(lbl, f.getLabel());
-            assertNull(f.getLabel(none));
-
-            f.setLabel(lbl_de, de);
-            f.setLabel(lbl_en, en);
-            assertEquals(lbl_de, f.getLabel(de));
-            assertEquals(lbl_en, f.getLabel(en));
-            assertNull(f.getLabel(none));
-
-            f.setLabel(null);
-            assertNull(f.getLabel());
-            assertNull(f.getLabel(de));
-            assertNull(f.getLabel(en));
-            assertNull(f.getLabel(fr));
-            assertNull(f.getLabel(none));
-
-            f.setLabel(lbl_de, de);
-            f.setLabel(lbl_en, en);
-            f.setLabel(lbl_fr, fr);
-            f.setLabel(lbl_none, none);
-            assertEquals(lbl_de, f.getLabel(de));
-            assertEquals(lbl_en, f.getLabel(en));
-            assertEquals(lbl_fr, f.getLabel(fr));
-            assertEquals(lbl_none, f.getLabel(none));
-
-            assertThat(f.getLabel(), anyOf(is(lbl_de), is(lbl_en), is(lbl_fr), is(lbl_none)));
-
-            f.deleteLabel(en);
-            assertEquals(lbl_de, f.getLabel(de));
-            assertNull(f.getLabel(en));
-            assertEquals(lbl_fr, f.getLabel(fr));
-            assertEquals(lbl_none, f.getLabel(none));
-
-            f.setLabel(null, fr);
-            assertEquals(lbl_de, f.getLabel(de));
-            assertNull(f.getLabel(en));
-            assertNull(f.getLabel(fr));
-            assertEquals(lbl_none, f.getLabel(none));
-
-            f.setLabel(lbl);
-            assertEquals(lbl, f.getLabel());
-            assertNull(f.getLabel(de));
-            assertNull(f.getLabel(en));
-            assertNull(f.getLabel(fr));
-            assertNull(f.getLabel(none));
-
-        } finally {
-            connection.close();
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/ee5998d3/commons/sesame-tools-facading/src/test/java/facading/locale/model/LocaleFacade.java
----------------------------------------------------------------------
diff --git a/commons/sesame-tools-facading/src/test/java/facading/locale/model/LocaleFacade.java b/commons/sesame-tools-facading/src/test/java/facading/locale/model/LocaleFacade.java
deleted file mode 100644
index 616d56a..0000000
--- a/commons/sesame-tools-facading/src/test/java/facading/locale/model/LocaleFacade.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package facading.locale.model;
-
-import at.newmedialab.sesame.facading.annotations.RDF;
-import at.newmedialab.sesame.facading.model.Facade;
-
-import java.util.Locale;
-
-import org.apache.marmotta.commons.sesame.model.Namespaces;
-
-public interface LocaleFacade extends Facade {
-
-    @RDF(Namespaces.NS_RDFS + "label")
-    public String getLabel();
-    public String getLabel(Locale loc);
-    public void setLabel(String label);
-    public void setLabel(String label, Locale loc);
-    public void deleteLabel();
-    public void deleteLabel(Locale loc);
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/ee5998d3/commons/sesame-tools-facading/src/test/java/org/apache/marmotta/commons/sesame/facading/AbstractFacadingTest.java
----------------------------------------------------------------------
diff --git a/commons/sesame-tools-facading/src/test/java/org/apache/marmotta/commons/sesame/facading/AbstractFacadingTest.java b/commons/sesame-tools-facading/src/test/java/org/apache/marmotta/commons/sesame/facading/AbstractFacadingTest.java
new file mode 100644
index 0000000..cd670db
--- /dev/null
+++ b/commons/sesame-tools-facading/src/test/java/org/apache/marmotta/commons/sesame/facading/AbstractFacadingTest.java
@@ -0,0 +1,28 @@
+package org.apache.marmotta.commons.sesame.facading;
+
+import org.junit.After;
+import org.junit.Before;
+import org.openrdf.repository.Repository;
+import org.openrdf.repository.RepositoryException;
+import org.openrdf.repository.sail.SailRepository;
+import org.openrdf.rio.RDFParseException;
+import org.openrdf.sail.memory.MemoryStore;
+
+import java.io.IOException;
+
+public abstract class AbstractFacadingTest {
+
+    protected Repository repositoryRDF;
+
+    @Before
+    public void setup() throws RepositoryException, IOException, RDFParseException {
+        repositoryRDF = new SailRepository(new MemoryStore());
+        repositoryRDF.initialize();
+    }
+
+    @After
+    public void tearDown() throws RepositoryException {
+        repositoryRDF.shutDown();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/ee5998d3/commons/sesame-tools-facading/src/test/java/org/apache/marmotta/commons/sesame/facading/builder/FacadingPredicateBuilderTest.java
----------------------------------------------------------------------
diff --git a/commons/sesame-tools-facading/src/test/java/org/apache/marmotta/commons/sesame/facading/builder/FacadingPredicateBuilderTest.java b/commons/sesame-tools-facading/src/test/java/org/apache/marmotta/commons/sesame/facading/builder/FacadingPredicateBuilderTest.java
new file mode 100644
index 0000000..77562fc
--- /dev/null
+++ b/commons/sesame-tools-facading/src/test/java/org/apache/marmotta/commons/sesame/facading/builder/FacadingPredicateBuilderTest.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2013 Salzburg Research.
+ *
+ *  Licensed 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.
+ */
+
+package org.apache.marmotta.commons.sesame.facading.builder;
+
+import static org.hamcrest.CoreMatchers.allOf;
+import static org.hamcrest.CoreMatchers.hasItem;
+
+
+import org.apache.marmotta.commons.sesame.facading.AbstractFacadingTest;
+import org.apache.marmotta.commons.sesame.facading.FacadingFactory;
+import org.apache.marmotta.commons.sesame.facading.api.Facading;
+import org.apache.marmotta.commons.sesame.facading.builder.model.ExampleFacade;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.openrdf.model.Literal;
+import org.openrdf.model.URI;
+import org.openrdf.repository.RepositoryConnection;
+import org.openrdf.repository.RepositoryException;
+import org.openrdf.rio.RDFParseException;
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
+
+public class FacadingPredicateBuilderTest extends AbstractFacadingTest {
+
+    private RepositoryConnection connection;
+    private Facading facading;
+
+    @Override
+    @Before
+    public void setup() throws RepositoryException, IOException, RDFParseException {
+        super.setup();
+
+        connection = repositoryRDF.getConnection();
+        facading = FacadingFactory.createFacading(connection);
+    }
+
+    @Test
+    public void testPredicateBuilder() throws RepositoryException {
+        final URI u = connection.getValueFactory().createURI("http://localhost/repository/testResource1");
+        ExampleFacade f = facading.createFacade(u, ExampleFacade.class);
+
+        String title = "Example Title";
+        Set<String> tags = new HashSet<String>();
+        tags.add("Foo");
+        tags.add("Bar");
+
+        f.setTitle(title);
+        f.setTags(tags);
+
+        checkStatement(u, ExampleFacade.NS + "title", title);
+        checkStatement(u, ExampleFacade.NS + "tag", "Foo");
+        checkStatement(u, ExampleFacade.NS + "tag", "Bar");
+
+        Assert.assertEquals(f.getTitle(), title);
+        Assert.assertThat(f.getTags(), allOf(hasItem("Foo"), hasItem("Bar")));
+
+        f.addTag("FooBar");
+        checkStatement(u, ExampleFacade.NS + "tag", "FooBar");
+        Assert.assertThat(f.getTags(), allOf(hasItem("FooBar"), hasItem("Foo"), hasItem("Bar")));
+
+    }
+
+    private void checkStatement(URI s, String prop, String val) throws RepositoryException {
+        final URI propURI = connection.getValueFactory().createURI(prop);
+        final Literal value = connection.getValueFactory().createLiteral(val);
+
+        Assert.assertTrue(String.format("Did not find Statement '<%s> <%s> \"%s\"'", s.stringValue(), prop, val),
+                connection.hasStatement(s, propURI, value, true));
+    }
+
+    @Override
+    @After
+    public void tearDown() throws RepositoryException {
+        if (connection != null) {
+            connection.rollback();
+            connection.close();
+        }
+
+        super.tearDown();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/ee5998d3/commons/sesame-tools-facading/src/test/java/org/apache/marmotta/commons/sesame/facading/builder/model/ExampleFacade.java
----------------------------------------------------------------------
diff --git a/commons/sesame-tools-facading/src/test/java/org/apache/marmotta/commons/sesame/facading/builder/model/ExampleFacade.java b/commons/sesame-tools-facading/src/test/java/org/apache/marmotta/commons/sesame/facading/builder/model/ExampleFacade.java
new file mode 100644
index 0000000..82fea09
--- /dev/null
+++ b/commons/sesame-tools-facading/src/test/java/org/apache/marmotta/commons/sesame/facading/builder/model/ExampleFacade.java
@@ -0,0 +1,21 @@
+package org.apache.marmotta.commons.sesame.facading.builder.model;
+
+
+import java.util.Set;
+
+import org.apache.marmotta.commons.sesame.facading.annotations.RDFPropertyBuilder;
+import org.apache.marmotta.commons.sesame.facading.model.Facade;
+
+@RDFPropertyBuilder(ExamplePropBuilder.class)
+public interface ExampleFacade extends Facade {
+
+    public static final String NS = "http://www.example.com/vocab/test#";
+
+    void setTitle(String title);
+    String getTitle();
+
+    void setTags(Set<String> tags);
+    void addTag(String tag);
+    Set<String> getTags();
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/ee5998d3/commons/sesame-tools-facading/src/test/java/org/apache/marmotta/commons/sesame/facading/builder/model/ExamplePropBuilder.java
----------------------------------------------------------------------
diff --git a/commons/sesame-tools-facading/src/test/java/org/apache/marmotta/commons/sesame/facading/builder/model/ExamplePropBuilder.java b/commons/sesame-tools-facading/src/test/java/org/apache/marmotta/commons/sesame/facading/builder/model/ExamplePropBuilder.java
new file mode 100644
index 0000000..e393ab1
--- /dev/null
+++ b/commons/sesame-tools-facading/src/test/java/org/apache/marmotta/commons/sesame/facading/builder/model/ExamplePropBuilder.java
@@ -0,0 +1,12 @@
+package org.apache.marmotta.commons.sesame.facading.builder.model;
+
+import org.apache.marmotta.commons.sesame.facading.model.AbstractNamespacePropBuilder;
+
+public class ExamplePropBuilder extends AbstractNamespacePropBuilder {
+
+    @Override
+    protected String getNamespace() {
+        return ExampleFacade.NS;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/ee5998d3/commons/sesame-tools-facading/src/test/java/org/apache/marmotta/commons/sesame/facading/collections/CollectionFacadingTest.java
----------------------------------------------------------------------
diff --git a/commons/sesame-tools-facading/src/test/java/org/apache/marmotta/commons/sesame/facading/collections/CollectionFacadingTest.java b/commons/sesame-tools-facading/src/test/java/org/apache/marmotta/commons/sesame/facading/collections/CollectionFacadingTest.java
new file mode 100644
index 0000000..6715ccb
--- /dev/null
+++ b/commons/sesame-tools-facading/src/test/java/org/apache/marmotta/commons/sesame/facading/collections/CollectionFacadingTest.java
@@ -0,0 +1,84 @@
+package org.apache.marmotta.commons.sesame.facading.collections;
+
+import static org.hamcrest.CoreMatchers.hasItems;
+
+
+import org.apache.marmotta.commons.sesame.facading.AbstractFacadingTest;
+import org.apache.marmotta.commons.sesame.facading.FacadingFactory;
+import org.apache.marmotta.commons.sesame.facading.api.Facading;
+import org.apache.marmotta.commons.sesame.facading.collections.model.CollectionFacade;
+import org.hamcrest.CoreMatchers;
+import org.junit.Assert;
+import org.junit.Test;
+import org.openrdf.model.URI;
+import org.openrdf.repository.RepositoryConnection;
+import org.openrdf.repository.RepositoryException;
+
+import java.util.Arrays;
+import java.util.Date;
+import java.util.Random;
+import java.util.UUID;
+
+public class CollectionFacadingTest extends AbstractFacadingTest {
+
+    @Test
+    public void testCollectionFacading() throws RepositoryException {
+        final RepositoryConnection connection = repositoryRDF.getConnection();
+
+        final Random rnd = new Random();
+        final Date a, b, c, d, e, now;
+        now = new Date();
+        // Start 10Yrs back;
+        final int tenYrsInSecs = 10 * 365 * 24 * 60 * 60;
+        a = new Date(now.getTime() - tenYrsInSecs * 1000L);
+        b = new Date(a.getTime() + rnd.nextInt(tenYrsInSecs) * 1000L);
+        c = new Date(a.getTime() + rnd.nextInt(tenYrsInSecs) * 1000L);
+        d = new Date(a.getTime() + rnd.nextInt(tenYrsInSecs) * 1000L);
+        e = new Date(a.getTime() + rnd.nextInt(tenYrsInSecs) * 1000L);
+
+        try {
+            final Facading facading = FacadingFactory.createFacading(connection);
+
+            URI uri = connection.getValueFactory().createURI("http://www.example.com/rdf/test/collections");
+            CollectionFacade facade = facading.createFacade(uri, CollectionFacade.class);
+
+            facade.setDates(Arrays.asList(a, b, c));
+            Assert.assertThat(facade.getDates(), hasItems(a, b, c));
+
+            facade.addDate(e);
+            Assert.assertThat(facade.getDates(), hasItems(c, e, b, a));
+
+            facade.setDates(Arrays.asList(a, d, now));
+            Assert.assertThat(facade.getDates(), hasItems(a, d, now));
+            Assert.assertThat(facade.getDates(), CoreMatchers.not(hasItems(c, e, b)));
+
+            facade.deleteDates();
+            Assert.assertEquals(facade.getDates().size(), 0);
+        } finally {
+            connection.close();
+        }
+    }
+
+    @Test
+    public void testAutorFacading() throws RepositoryException {
+        final RepositoryConnection connection = repositoryRDF.getConnection();
+
+        String a1 = UUID.randomUUID().toString(), a2 = UUID.randomUUID().toString(), a3 = UUID.randomUUID().toString();
+
+        try {
+            final Facading facading = FacadingFactory.createFacading(connection);
+
+            URI uri = connection.getValueFactory().createURI("http://www.example.com/rdf/test/document");
+            CollectionFacade facade = facading.createFacade(uri, CollectionFacade.class);
+
+            facade.setAutors(Arrays.asList(a1, a2));
+
+            facade.addAutor(a3);
+
+            connection.commit();
+        } finally {
+            connection.close();
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/ee5998d3/commons/sesame-tools-facading/src/test/java/org/apache/marmotta/commons/sesame/facading/collections/model/CollectionFacade.java
----------------------------------------------------------------------
diff --git a/commons/sesame-tools-facading/src/test/java/org/apache/marmotta/commons/sesame/facading/collections/model/CollectionFacade.java b/commons/sesame-tools-facading/src/test/java/org/apache/marmotta/commons/sesame/facading/collections/model/CollectionFacade.java
new file mode 100644
index 0000000..b0e94f8
--- /dev/null
+++ b/commons/sesame-tools-facading/src/test/java/org/apache/marmotta/commons/sesame/facading/collections/model/CollectionFacade.java
@@ -0,0 +1,23 @@
+package org.apache.marmotta.commons.sesame.facading.collections.model;
+
+
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+
+import org.apache.marmotta.commons.sesame.facading.annotations.RDF;
+import org.apache.marmotta.commons.sesame.facading.model.Facade;
+
+public interface CollectionFacade extends Facade {
+
+    @RDF("http://www.example.com/rdf/vocab/date")
+    public List<Date> getDates();
+    public void setDates(List<Date> dates);
+    public void addDate(Date date);
+    public void deleteDates();
+
+    @RDF("http://www.example.com/rdf/vocab/autor")
+    public void addAutor(String autor);
+    public void setAutors(Collection<String> authors);
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/ee5998d3/commons/sesame-tools-facading/src/test/java/org/apache/marmotta/commons/sesame/facading/foaf/FacadingFoafTest.java
----------------------------------------------------------------------
diff --git a/commons/sesame-tools-facading/src/test/java/org/apache/marmotta/commons/sesame/facading/foaf/FacadingFoafTest.java b/commons/sesame-tools-facading/src/test/java/org/apache/marmotta/commons/sesame/facading/foaf/FacadingFoafTest.java
new file mode 100644
index 0000000..fb399c8
--- /dev/null
+++ b/commons/sesame-tools-facading/src/test/java/org/apache/marmotta/commons/sesame/facading/foaf/FacadingFoafTest.java
@@ -0,0 +1,256 @@
+package org.apache.marmotta.commons.sesame.facading.foaf;
+
+import static org.hamcrest.CoreMatchers.allOf;
+import static org.hamcrest.CoreMatchers.hasItem;
+import static org.hamcrest.CoreMatchers.hasItems;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.Matchers.hasProperty;
+import static org.junit.Assume.assumeThat;
+
+
+import org.apache.marmotta.commons.sesame.facading.AbstractFacadingTest;
+import org.apache.marmotta.commons.sesame.facading.FacadingFactory;
+import org.apache.marmotta.commons.sesame.facading.api.Facading;
+import org.apache.marmotta.commons.sesame.facading.foaf.model.OnlineAccount;
+import org.apache.marmotta.commons.sesame.facading.foaf.model.Person;
+import org.apache.marmotta.commons.sesame.model.Namespaces;
+import org.hamcrest.CoreMatchers;
+import org.junit.Assert;
+import org.junit.Assume;
+import org.junit.Before;
+import org.junit.Test;
+import org.openrdf.model.Resource;
+import org.openrdf.model.Statement;
+import org.openrdf.model.URI;
+import org.openrdf.repository.RepositoryConnection;
+import org.openrdf.repository.RepositoryException;
+import org.openrdf.repository.RepositoryResult;
+import org.openrdf.rio.RDFFormat;
+import org.openrdf.rio.RDFParseException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Test if facading works for the FOAF examples
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class FacadingFoafTest extends AbstractFacadingTest {
+    private static Logger log = LoggerFactory.getLogger(FacadingFoafTest.class);
+
+    @Before
+    public void loadData() throws RepositoryException, IOException, RDFParseException {
+
+        // load demo data
+        InputStream rdfXML = this.getClass().getResourceAsStream("demo-data.foaf");
+        assumeThat("Could not load test-data: demo-data.foaf", rdfXML, notNullValue(InputStream.class));
+
+        RepositoryConnection connectionRDF = repositoryRDF.getConnection();
+        try {
+            connectionRDF.add(rdfXML, "http://localhost/foaf/", RDFFormat.RDFXML);
+            connectionRDF.commit();
+        } finally {
+            connectionRDF.close();
+        }
+    }
+
+    /**
+     * Test if we can access the data contained in a FOAF file via the facading
+     *
+     * @throws Exception
+     */
+    @Test
+    public void testAccessData() throws Exception {
+
+        RepositoryConnection connectionRDF = repositoryRDF.getConnection();
+        try {
+
+            // list all resources contained in the repository and create facades over them
+            Set<Resource> resources = new HashSet<Resource>();
+            RepositoryResult<Statement> triples = connectionRDF.getStatements(null,null,null,true);
+            while(triples.hasNext()) {
+                resources.add(triples.next().getSubject());
+            }
+            triples.close();
+
+            Facading facading = FacadingFactory.createFacading(connectionRDF);
+
+            // test individual resource
+            URI u_hans_meier = connectionRDF.getValueFactory().createURI("http://localhost:8080/LMF/resource/hans_meier");
+            URI u_anna_schmidt = connectionRDF.getValueFactory().createURI("http://localhost:8080/LMF/resource/anna_schmidt");
+            Person hans_meier = facading.createFacade(u_hans_meier,Person.class);
+
+            Assert.assertEquals("Hans Meier",hans_meier.getName());
+            Assert.assertEquals(2,hans_meier.getFriends().size());
+            Assert.assertThat(hans_meier.getOnlineAccounts(),
+                    CoreMatchers.<OnlineAccount> hasItem(hasProperty("accountName", is("Example"))));
+
+            Assert.assertThat(hans_meier.getFriends(), allOf(
+                    CoreMatchers.<Person> hasItem(hasProperty("name", is("Anna Schmidt"))),
+                    CoreMatchers.<Person> hasItem(hasProperty("name", is("Sepp Huber")))
+                    ));
+
+            // test collection
+            Collection<Person> persons = facading.createFacade(resources,Person.class);
+            Assert.assertEquals(3, persons.size());
+            Assert.assertThat(persons,allOf(
+                    CoreMatchers.<Person> hasItem(hasProperty("name", is("Hans Meier"))),
+                    CoreMatchers.<Person> hasItem(hasProperty("name", is("Anna Schmidt"))),
+                    CoreMatchers.<Person> hasItem(hasProperty("name", is("Sepp Huber")))
+                    )
+                    );
+
+            connectionRDF.commit();
+        } finally {
+            connectionRDF.close();
+        }
+    }
+
+    /**
+     * Test if we can access the data contained in a FOAF file via the facading
+     *
+     * @throws Exception
+     */
+    @Test
+    public void testModifyData() throws Exception {
+        RepositoryConnection connectionRDF = repositoryRDF.getConnection();
+        try {
+            // list all resources contained in the repository and create facades over them
+            Set<Resource> resources = new HashSet<Resource>();
+            RepositoryResult<Statement> triples = connectionRDF.getStatements(null,null,null,true);
+            while(triples.hasNext()) {
+                resources.add(triples.next().getSubject());
+            }
+            triples.close();
+
+            Facading facading = FacadingFactory.createFacading(connectionRDF);
+
+            // test individual resource
+            URI u_hans_meier = connectionRDF.getValueFactory().createURI("http://localhost:8080/LMF/resource/hans_meier");
+            Person hans_meier = facading.createFacade(u_hans_meier,Person.class);
+
+            Assert.assertNull(hans_meier.getNick());
+
+            // set nick name and check if it is now set
+            hans_meier.setNick("hansi");
+            Assert.assertNotNull(hans_meier.getNick());
+            Assert.assertEquals("hansi",hans_meier.getNick());
+
+            // check in triple store if the triple is there
+            URI p_foaf_nick = connectionRDF.getValueFactory().createURI(Namespaces.NS_FOAF + "nick");
+            RepositoryResult<Statement> nicknames = connectionRDF.getStatements(u_hans_meier,p_foaf_nick,null,true);
+            Assert.assertTrue(nicknames.hasNext());
+            Assert.assertEquals("hansi",nicknames.next().getObject().stringValue());
+            nicknames.close();
+
+            // test creating a completely new resource
+            URI u_fritz_fischer = connectionRDF.getValueFactory().createURI("http://localhost:8080/LMF/resource/fritz_fischer");
+            Person fritz_fischer = facading.createFacade(u_fritz_fischer,Person.class);
+            fritz_fischer.setName("Fritz Fischer");
+
+            Assert.assertEquals("Fritz Fischer", fritz_fischer.getName());
+
+            // test if it is now there
+            URI p_foaf_name = connectionRDF.getValueFactory().createURI(Namespaces.NS_FOAF + "name");
+            RepositoryResult<Statement> names = connectionRDF.getStatements(u_fritz_fischer,p_foaf_name,null,true);
+            Assert.assertTrue(names.hasNext());
+            Assert.assertEquals("Fritz Fischer",names.next().getObject().stringValue());
+            names.close();
+
+            // test extending a collection
+            Set<Person> hans_friends = hans_meier.getFriends();
+            hans_friends.add(fritz_fischer);
+            hans_meier.setFriends(hans_friends);
+
+            Assert.assertEquals(3,hans_meier.getFriends().size());
+            Assert.assertThat(hans_meier.getFriends(), allOf(
+                    CoreMatchers.<Person> hasItem(hasProperty("name", is("Anna Schmidt"))),
+                    CoreMatchers.<Person> hasItem(hasProperty("name", is("Fritz Fischer"))),
+                    CoreMatchers.<Person> hasItem(hasProperty("name", is("Sepp Huber")))
+                    ));
+
+            Assert.assertTrue(hans_meier.hasFriends());
+
+            connectionRDF.commit();
+        } finally {
+            connectionRDF.close();
+        }
+    }
+
+    @Test
+    public void testReadInverseRDF() throws RepositoryException {
+
+        final RepositoryConnection connection = repositoryRDF.getConnection();
+        try {
+            final Facading facading = FacadingFactory.createFacading(connection);
+
+            URI u_hans_meier = connection.getValueFactory().createURI("http://localhost:8080/LMF/resource/hans_meier");
+            Person hans_meier = facading.createFacade(u_hans_meier, Person.class);
+            Assume.assumeThat("Could not load test-person", hans_meier, notNullValue(Person.class));
+
+            for (OnlineAccount account : hans_meier.getOnlineAccounts()) {
+                Assert.assertNotNull(account);
+                final Resource accountRSC = account.getDelegate();
+                Assert.assertNotNull(accountRSC);
+
+                final OnlineAccount oa = facading.createFacade(accountRSC, OnlineAccount.class);
+                Assert.assertNotNull(oa);
+
+                Assert.assertEquals(hans_meier, oa.getHolder());
+            }
+
+        } finally {
+            connection.close();
+        }
+    }
+
+    @Test
+    public void testWriteInverserRDF() throws RepositoryException {
+        final RepositoryConnection connection = repositoryRDF.getConnection();
+        try {
+            final Facading facading = FacadingFactory.createFacading(connection);
+
+            URI p = connection.getValueFactory().createURI("http://localhost/person");
+            Person person = facading.createFacade(p, Person.class);
+
+            URI a = connection.getValueFactory().createURI("http://localhost/account");
+            OnlineAccount account = facading.createFacade(a, OnlineAccount.class);
+
+            account.setHolder(person);
+
+            connection.commit();
+
+            Assert.assertThat(person.getOnlineAccounts(), CoreMatchers.hasItem(account));
+
+        } finally {
+            connection.close();
+        }
+    }
+
+    @Test
+    public void testAdd() throws RepositoryException {
+        final RepositoryConnection connection = repositoryRDF.getConnection();
+        try {
+            final Facading facading = FacadingFactory.createFacading(connection);
+
+            URI a = connection.getValueFactory().createURI("http://localhost/account");
+            OnlineAccount account = facading.createFacade(a, OnlineAccount.class);
+
+            account.addChatId("foo");
+            Assert.assertThat(account.getChatId(), hasItem("foo"));
+            account.addChatId("bar");
+            Assert.assertThat(account.getChatId(), hasItems("foo", "bar"));
+            Assert.assertThat(account.getChatId(), hasItems("bar", "foo"));
+        } finally {
+            connection.close();
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/ee5998d3/commons/sesame-tools-facading/src/test/java/org/apache/marmotta/commons/sesame/facading/foaf/model/OnlineAccount.java
----------------------------------------------------------------------
diff --git a/commons/sesame-tools-facading/src/test/java/org/apache/marmotta/commons/sesame/facading/foaf/model/OnlineAccount.java b/commons/sesame-tools-facading/src/test/java/org/apache/marmotta/commons/sesame/facading/foaf/model/OnlineAccount.java
new file mode 100644
index 0000000..533e4e2
--- /dev/null
+++ b/commons/sesame-tools-facading/src/test/java/org/apache/marmotta/commons/sesame/facading/foaf/model/OnlineAccount.java
@@ -0,0 +1,59 @@
+/**
+ *  Copyright (c) 2012 Salzburg Research.
+ *
+ *  Licensed 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.
+ */
+package org.apache.marmotta.commons.sesame.facading.foaf.model;
+
+
+
+import java.util.Date;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.marmotta.commons.sesame.facading.annotations.RDF;
+import org.apache.marmotta.commons.sesame.facading.annotations.RDFInverse;
+import org.apache.marmotta.commons.sesame.facading.annotations.RDFType;
+import org.apache.marmotta.commons.sesame.facading.model.Facade;
+import org.apache.marmotta.commons.sesame.model.Namespaces;
+
+/**
+ * @author Stephanie Stroka
+ * User: Stephanie Stroka
+ * Date: 18.05.2011
+ * Time: 11:29:17
+ */
+@RDFType(Namespaces.NS_FOAF + "OnlineAccount")
+public interface OnlineAccount extends Facade {
+
+    @RDF(Namespaces.NS_FOAF + "accountServiceHomepage")
+    public String getAccountServiceHomepage();
+    public void setAccountServiceHomepage(String accountServiceHomepage);
+
+    @RDF(Namespaces.NS_FOAF + "accountName")
+    public String getAccountName();
+    public void setAccountName(String accountName);
+
+    @RDFInverse(Namespaces.NS_FOAF + "account")
+    public Person getHolder();
+    public void setHolder(Person holder);
+
+    @RDF(Namespaces.NS_FOAF + "chatId")
+    public Set<String> getChatId();
+    public void addChatId(String chatId);
+
+    @RDF("http://www.example.com/rdf/vocab/login")
+    public List<Date> getLoginDate();
+    public void addLoginDate(Date login);
+    public void setLoginDate(List<Date> logins);
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/ee5998d3/commons/sesame-tools-facading/src/test/java/org/apache/marmotta/commons/sesame/facading/foaf/model/Person.java
----------------------------------------------------------------------
diff --git a/commons/sesame-tools-facading/src/test/java/org/apache/marmotta/commons/sesame/facading/foaf/model/Person.java b/commons/sesame-tools-facading/src/test/java/org/apache/marmotta/commons/sesame/facading/foaf/model/Person.java
new file mode 100644
index 0000000..2b4a16e
--- /dev/null
+++ b/commons/sesame-tools-facading/src/test/java/org/apache/marmotta/commons/sesame/facading/foaf/model/Person.java
@@ -0,0 +1,51 @@
+package org.apache.marmotta.commons.sesame.facading.foaf.model;
+
+
+
+import org.apache.marmotta.commons.sesame.facading.annotations.RDF;
+import org.apache.marmotta.commons.sesame.facading.annotations.RDFFilter;
+import org.apache.marmotta.commons.sesame.facading.annotations.RDFType;
+import org.apache.marmotta.commons.sesame.facading.model.Facade;
+import org.apache.marmotta.commons.sesame.model.Namespaces;
+import org.openrdf.model.URI;
+
+import java.util.Set;
+
+/**
+ * Sample facade to describe a foaf:Person
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+@RDFType(Namespaces.NS_FOAF + "Person")
+@RDFFilter(Namespaces.NS_FOAF + "Person")
+public interface Person extends Facade {
+
+    @RDF(Namespaces.NS_FOAF + "nick")
+    public String getNick();
+    public void setNick(String nick);
+
+    /**
+     * The  name of the user; mapped to the foaf:name RDF property
+     */
+    @RDF(Namespaces.NS_FOAF + "name")
+    public String getName();
+    public void setName(String firstName);
+
+
+    @RDF(Namespaces.NS_FOAF + "mbox")
+    public String getMbox();
+    public void setMbox(String mbox);
+
+    @RDF(Namespaces.NS_FOAF + "depiction")
+    public URI getDepiciton();
+    public void setDepiction(URI depiction);
+
+    @RDF(Namespaces.NS_FOAF + "account")
+    public Set<OnlineAccount> getOnlineAccounts();
+    public void setOnlineAccounts(Set<OnlineAccount> onlineAccounts);
+
+    @RDF(Namespaces.NS_FOAF + "knows")
+    public Set<Person> getFriends();
+    public void setFriends(Set<Person> friends);
+    public boolean hasFriends();
+}