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

[9/55] MARMOTTA-106: renamed packages in marmotta-commons

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5f62ec33/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/util/DateUtils.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/util/DateUtils.java b/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/util/DateUtils.java
new file mode 100644
index 0000000..cc329d6
--- /dev/null
+++ b/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/util/DateUtils.java
@@ -0,0 +1,162 @@
+/**
+ * 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.util;
+
+import javax.xml.datatype.DatatypeConfigurationException;
+import javax.xml.datatype.DatatypeFactory;
+import javax.xml.datatype.XMLGregorianCalendar;
+
+import java.text.DateFormat;
+import java.text.DateFormatSymbols;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.Locale;
+import java.util.TimeZone;
+
+/**
+ * @author Sebastian Schaffert
+ *
+ */
+public class DateUtils {
+
+
+    public static final SimpleDateFormat ISO8601FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
+
+    public static final SimpleDateFormat ISO8601FORMAT_TIME = new SimpleDateFormat("HH:mm:ss.SSS'Z'");
+    public static final SimpleDateFormat ISO8601FORMAT_DATE  = new SimpleDateFormat("yyyy-MM-dd");
+
+    public static final SimpleDateFormat FILENAME_FORMAT     = new SimpleDateFormat("yyyyMMdd-HHmmss");
+
+
+    public static final SimpleDateFormat GMTFORMAT = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", new DateFormatSymbols(Locale.US));
+    static {
+        ISO8601FORMAT.setTimeZone(TimeZone.getTimeZone("UTC"));
+        ISO8601FORMAT_TIME.setTimeZone(TimeZone.getTimeZone("UTC"));
+        ISO8601FORMAT_DATE.setTimeZone(TimeZone.getTimeZone("UTC"));
+        GMTFORMAT.setTimeZone(TimeZone.getTimeZone("GMT"));
+    }
+
+    /**
+     * Some parsers will have the date as a ISO-8601 string
+     *  already, and will set that into the Metadata object.
+     * So we can return Date objects for these, this is the
+     *  list (in preference order) of the various ISO-8601
+     *  variants that we try when processing a date based
+     *  property.
+     */
+    private static final DateFormat[] iso8601InputFormats = new DateFormat[] {
+        // GMT
+        createDateFormat("EEE, dd MMM yyyy HH:mm:ss'Z'","GMT"),
+        GMTFORMAT,
+
+        // yyyy-mm-ddThh...
+        createDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ",null),
+        createDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", "UTF"),
+        createDateFormat("yyyy-MM-dd'T'HH:mm:ssZ", null),    // With timezone
+        createDateFormat("yyyy-MM-dd'T'HH:mm:ss", null),     // Without timezone
+        // yyyy-mm-dd hh...
+        createDateFormat("yyyy-MM-dd' 'HH:mm:ss'Z'", "UTF"), // UTC/Zulu
+        createDateFormat("yyyy-MM-dd' 'HH:mm:ssZ", null),    // With timezone
+        createDateFormat("yyyy-MM-dd' 'HH:mm:ss.SZ", null),    // With timezone
+        createDateFormat("yyyy-MM-dd' 'HH:mm:ss", null),     // Without timezone
+        createDateFormat("EEE MMM dd HH:mm:ss z yyyy", null),     // Word documents
+        createDateFormat("EEE MMM d HH:mm:ss z yyyy", null),     // Word documents
+        createDateFormat("dd.MM.yyy' 'HH:mm:ss", null),     // German
+        createDateFormat("dd.MM.yyy' 'HH:mm", null),     // German
+    };
+
+    private static DateFormat createDateFormat(String format, String timezone) {
+        SimpleDateFormat sdf =
+                new SimpleDateFormat(format, new DateFormatSymbols(Locale.US));
+        if (timezone != null) {
+            sdf.setTimeZone(TimeZone.getTimeZone(timezone));
+        }
+        return sdf;
+    }
+
+
+    /**
+     * Parses the given date string. This method is synchronized to prevent
+     * concurrent access to the thread-unsafe date formats.
+     *
+     * Stolen from TIKA to workaround a bug there ...
+     *
+     * @see <a href="https://issues.apache.org/jira/browse/TIKA-495">TIKA-495</a>
+     * @param date date string
+     * @return parsed date, or <code>null</code> if the date can't be parsed
+     */
+    public static synchronized Date parseDate(String date) {
+        if(date == null) {
+            return null;
+        }
+
+        // Java doesn't like timezones in the form ss+hh:mm
+        // It only likes the hhmm form, without the colon
+        int n = date.length();
+        if (n > 2 && date.charAt(n - 3) == ':'
+                && (date.charAt(n - 6) == '+' || date.charAt(n - 6) == '-')) {
+            date = date.substring(0, n - 3) + date.substring(n - 2);
+        }
+
+        // Try several different ISO-8601 variants
+        for (DateFormat format : iso8601InputFormats) {
+            try {
+                return format.parse(date);
+            } catch (ParseException ignore) {
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Transform an XML calendar into a Java date. Useful for working with date literals.
+     * @param calendar
+     * @return
+     */
+    public static Date getDate(XMLGregorianCalendar calendar) {
+        return calendar.toGregorianCalendar().getTime();
+    }
+
+
+    /**
+     * Transform a Java date into a XML calendar. Useful for working with date literals.
+     * @param date
+     * @return
+     */
+    public static XMLGregorianCalendar getXMLCalendar(Date date) {
+        GregorianCalendar c = new GregorianCalendar();
+        c.setTimeZone(TimeZone.getTimeZone("UTC"));
+        c.setTime(date);
+        try {
+            return DatatypeFactory.newInstance().newXMLGregorianCalendar(c).normalize();
+        } catch (DatatypeConfigurationException e) {
+            return null;
+        }
+    }
+
+
+    /**
+     * Cut the fraction part of a date object, since some database systems do not support nanoseconds.
+     * @param date
+     * @return
+     */
+    public static Date getDateWithoutFraction(Date date) {
+        long seconds = date.getTime() / 1000L;
+        return new Date(seconds * 1000L);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5f62ec33/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/util/HashUtils.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/util/HashUtils.java b/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/util/HashUtils.java
new file mode 100644
index 0000000..d89e1fa
--- /dev/null
+++ b/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/util/HashUtils.java
@@ -0,0 +1,66 @@
+/**
+ * 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.util;
+
+import java.io.UnsupportedEncodingException;
+import java.math.BigInteger;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+/**
+ * A static class for generating hash-sums (MD5, SHA-1) out of strings
+ * 
+ * @author Sebastian Schaffert
+ * 
+ */
+public class HashUtils {
+
+    public static final String md5sum(String string) {
+        return calcHash(string, "MD5");
+    }
+
+    public static final String md5sum(byte[] bytes) {
+        return calcHash(bytes, "MD5");
+    }
+
+    public static final String sha1(String string) {
+        return calcHash(string, "SHA-1");
+    }
+
+    public static final String sha1(byte[] bytes) {
+        return calcHash(bytes, "SHA-1");
+    }
+
+    private static String calcHash(String string, String algorithm) {
+        try {
+            return calcHash(string.getBytes("UTF-8"), algorithm);
+        } catch (UnsupportedEncodingException e) {
+            return string;
+        }
+    }
+
+    private static String calcHash(byte[] bytes, String algorithm) {
+        try {
+            MessageDigest m = MessageDigest.getInstance(algorithm);
+            m.update(bytes);
+            return new BigInteger(1,m.digest()).toString(16);
+        } catch(NoSuchAlgorithmException ex) {
+            return "";
+        }
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5f62ec33/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/util/JSONUtils.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/util/JSONUtils.java b/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/util/JSONUtils.java
new file mode 100644
index 0000000..99e2e1a
--- /dev/null
+++ b/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/util/JSONUtils.java
@@ -0,0 +1,172 @@
+/**
+ * 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.util;
+
+import org.openrdf.model.BNode;
+import org.openrdf.model.Literal;
+import org.openrdf.model.Statement;
+import org.openrdf.model.URI;
+import org.openrdf.model.Value;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Utility methods for transforming Sesame objects into in-memory RDF/JSON format using maps and sets.
+ */
+public class JSONUtils {
+
+    private static final String VALUE = "value";
+    private static final String TYPE = "type";
+    private static final String BNODE = "bnode";
+    private static final String URI = "uri";
+    private static final String LITERAL = "literal";
+    private static final String LANG = "lang";
+    private static final String DATATYPE = "datatype";
+
+    /**
+     * Transform node into an in-memory RDF/JSON representation that can be serialised using e.g. the
+     * Jackson ObjectMapper.
+     *
+     * @param node
+     * @return
+     */
+    public static Map<String, String> serializeNodeAsJson(Value node) {
+        Map<String,String> nodeRep = new HashMap<String, String>();
+        if(node instanceof Literal) {
+            Literal literal = (Literal)node;
+            nodeRep.put(TYPE,LITERAL);
+            nodeRep.put(VALUE, literal.stringValue());
+            if(literal.getDatatype() != null) {
+                nodeRep.put(DATATYPE,literal.getDatatype().stringValue());
+            }
+            if(literal.getLanguage() != null) {
+                nodeRep.put(LANG,literal.getLanguage());
+            }
+        } else if(node instanceof URI) {
+            nodeRep.put(TYPE,URI);
+            nodeRep.put(VALUE,node.stringValue());
+        } else if(node instanceof BNode) {
+            nodeRep.put(TYPE,BNODE);
+            nodeRep.put(VALUE,node.stringValue());
+        }
+        return nodeRep;
+    
+    }
+
+    /**
+     * Turn a list of nodes into a dataformat serializable by Jackson (maps and sets)
+     *
+     *
+     * @param nodes
+     * @return
+     */
+    public static Set<Map<String,String>> serializeNodesAsJson(Iterable<? extends Value> nodes) {
+        Set<Map<String,String>> result = new HashSet<Map<String, String>>();
+
+        for(Value objectNode : nodes) {
+            result.add(serializeNodeAsJson(objectNode));
+        }
+        return result;
+    }
+
+    /**
+     * This method wraps triples (Subject,Property,Object) in a dataformat that is serializable
+     * by Jackson (namely maps and sets).
+     *
+     * @param triple
+     * @return
+     */
+    public static Map<String,?> serializeTripleAsJson(Statement triple) {
+
+        Map<String,Map<String,Set<Map<String,String>>>> subjects = new HashMap<String,Map<String,Set<Map<String,String>>>>();
+
+        // get subject key
+        String subjectKey = triple.getSubject().stringValue();
+
+        //add or get predicate map
+        Map<String,Set<Map<String,String>>> predicates;
+        if( subjects.containsKey(subjectKey)) {
+            predicates = subjects.get(subjectKey);
+        } else {
+            predicates = new HashMap<String,Set<Map<String,String>>>();
+            subjects.put(subjectKey,predicates);
+        }
+
+        //get predicate key
+        String predicateKey = triple.getPredicate().stringValue();
+
+        //add or get object set
+        Set<Map<String,String>> objects;
+        if( predicates.containsKey(predicateKey) ) {
+            objects = predicates.get(predicateKey);
+        } else {
+            objects = new HashSet<Map<String,String>>();
+            predicates.put(predicateKey,objects);
+        }
+
+        //add objects
+        objects.add(serializeNodeAsJson(triple.getObject()));
+
+        return subjects;
+    }
+
+
+    /**
+     * This method wraps triples (Subject,Property,Object) in a dataformat that is serializable
+     * by Jackson (namely maps and sets).
+     *
+     * @param triples
+     * @return
+     */
+    public static Map<String,?> serializeTriplesAsJson(Iterable<? extends Statement> triples) {
+
+        Map<String,Map<String,Set<Map<String,String>>>> subjects = new HashMap<String,Map<String,Set<Map<String,String>>>>();
+        for( Statement triple : triples ) {
+
+            // get subject key
+            String subjectKey = triple.getSubject().stringValue();
+
+            //add or get predicate map
+            Map<String,Set<Map<String,String>>> predicates;
+            if( subjects.containsKey(subjectKey)) {
+                predicates = subjects.get(subjectKey);
+            } else {
+                predicates = new HashMap<String,Set<Map<String,String>>>();
+                subjects.put(subjectKey,predicates);
+            }
+
+            //get predicate key
+            String predicateKey = triple.getPredicate().stringValue();
+
+            //add or get object set
+            Set<Map<String,String>> objects;
+            if( predicates.containsKey(predicateKey) ) {
+                objects = predicates.get(predicateKey);
+            } else {
+                objects = new HashSet<Map<String,String>>();
+                predicates.put(predicateKey,objects);
+            }
+
+            //add objects
+            objects.add(serializeNodeAsJson(triple.getObject()));
+
+        }
+        return subjects;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5f62ec33/commons/marmotta-commons/src/test/java/at/newmedialab/sesame/commons/http/ETagGeneratorTest.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-commons/src/test/java/at/newmedialab/sesame/commons/http/ETagGeneratorTest.java b/commons/marmotta-commons/src/test/java/at/newmedialab/sesame/commons/http/ETagGeneratorTest.java
deleted file mode 100644
index 5c29ad9..0000000
--- a/commons/marmotta-commons/src/test/java/at/newmedialab/sesame/commons/http/ETagGeneratorTest.java
+++ /dev/null
@@ -1,120 +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 at.newmedialab.sesame.commons.http;
-
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.junit.Assume.assumeThat;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.openrdf.repository.Repository;
-import org.openrdf.repository.RepositoryConnection;
-import org.openrdf.repository.RepositoryException;
-import org.openrdf.repository.sail.SailRepository;
-import org.openrdf.rio.RDFFormat;
-import org.openrdf.rio.RDFParseException;
-import org.openrdf.sail.memory.MemoryStore;
-
-/**
- * Test the ETag Generator
- * 
- * @author Sergio Fernández
- */
-public class ETagGeneratorTest {
-
-    private static final String TEST_DATA = "/foaf/demo-data.foaf";
-    
-    private static final String URI_1 = "http://localhost:8080/LMF/resource/hans_meier";
-    
-    private static final String URI_2 = "http://localhost:8080/LMF/resource/sepp_huber";
-    
-    private static final String URI_3 = "http://localhost:8080/LMF/resource/anna_schmidt";
-
-    private Repository repository;
-
-    /**
-     * Setup memory repository and load initial data (demo-data.foaf)
-     * @throws RepositoryException
-     */
-    @Before
-    public void setup() throws RepositoryException, IOException, RDFParseException {
-        repository = new SailRepository(new MemoryStore());
-        repository.initialize();
-
-        InputStream rdfXML = this.getClass().getResourceAsStream(TEST_DATA);
-        assumeThat("Could not load testData from '" + TEST_DATA + "'", rdfXML, notNullValue(InputStream.class));
-
-        RepositoryConnection connection = repository.getConnection();
-        try {
-            connection.add(rdfXML, "http://localhost/foaf/", RDFFormat.RDFXML);
-            connection.commit();
-        } finally {
-            connection.close();
-        }
-    }
-
-    /**
-     * Shutdown the repository properly before the next test.
-     *
-     * @throws RepositoryException
-     */
-    @After
-    public void teardown() throws RepositoryException {
-        repository.shutDown();
-    }
-
-    /**
-     * Basic tests
-     */
-    @Test
-    public void runningTest() throws RepositoryException {
-        RepositoryConnection conn = repository.getConnection();
-        String etag = ETagGenerator.getETag(conn, URI_1);
-        Assert.assertNotNull(etag);
-        String wetag = ETagGenerator.getWeakETag(conn, URI_1);
-        Assert.assertNotNull(wetag);
-        conn.close();
-    }
-    
-    /**
-     * Invariant test
-     */
-    @Test
-    public void invariantTest() throws RepositoryException {
-        RepositoryConnection conn1 = repository.getConnection();
-        String etag1 = ETagGenerator.getETag(conn1, URI_1);
-        Assert.assertNotNull(etag1);
-        String wetag1 = ETagGenerator.getWeakETag(conn1, URI_1);
-        Assert.assertNotNull(wetag1);
-        conn1.close();
-        
-        RepositoryConnection conn2 = repository.getConnection();
-        String etag2 = ETagGenerator.getETag(conn2, URI_1);
-        Assert.assertNotNull(etag2);
-        String wetag2 = ETagGenerator.getWeakETag(conn2, URI_1);
-        Assert.assertNotNull(wetag2);
-        conn2.close();
-        
-        Assert.assertEquals(etag1, etag2);
-        Assert.assertEquals(wetag1, wetag2);
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5f62ec33/commons/marmotta-commons/src/test/java/at/newmedialab/sesame/commons/model/LiteralCommonsTest.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-commons/src/test/java/at/newmedialab/sesame/commons/model/LiteralCommonsTest.java b/commons/marmotta-commons/src/test/java/at/newmedialab/sesame/commons/model/LiteralCommonsTest.java
deleted file mode 100644
index 0c4918a..0000000
--- a/commons/marmotta-commons/src/test/java/at/newmedialab/sesame/commons/model/LiteralCommonsTest.java
+++ /dev/null
@@ -1,133 +0,0 @@
-package at.newmedialab.sesame.commons.model;
-/*
- * 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.
- */
-
-import at.newmedialab.sesame.commons.util.DateUtils;
-import org.apache.commons.lang.RandomStringUtils;
-import org.junit.Assert;
-import org.junit.Test;
-import org.openrdf.model.Literal;
-import org.openrdf.model.URI;
-import org.openrdf.model.ValueFactory;
-import org.openrdf.repository.Repository;
-import org.openrdf.repository.sail.SailRepository;
-import org.openrdf.sail.memory.MemoryStore;
-
-import java.util.Date;
-import java.util.Locale;
-
-/**
- * Test the functions of the literal commons
- * <p/>
- * Author: Sebastian Schaffert
- */
-public class LiteralCommonsTest {
-
-    /**
-     * Test the creation of the cache keys for literals. All methods should return the same cache key for the
-     * same input data.
-     *
-     * @throws Exception
-     */
-    @Test
-    public void testCreateCacheKey() throws Exception {
-        Assert.assertNotEquals(LiteralCommons.createCacheKey("abc",null,(String)null), LiteralCommons.createCacheKey("ABC",null,(String)null));
-        Assert.assertNotEquals(LiteralCommons.createCacheKey("abc",null,(URI)null), LiteralCommons.createCacheKey("ABC",null,(URI)null));
-
-        Repository repository = new SailRepository(new MemoryStore());
-        repository.initialize();
-
-        ValueFactory vf = repository.getValueFactory();
-
-        // create a string literal without language and datatype and test if the hash key is correct between
-        // the different methods
-        String value1 = RandomStringUtils.random(128);
-        Literal literal1 = vf.createLiteral(value1);
-
-        Assert.assertEquals(LiteralCommons.createCacheKey(value1,null,(String)null),LiteralCommons.createCacheKey(literal1));
-        Assert.assertEquals(LiteralCommons.createCacheKey(value1,null,(URI)null),LiteralCommons.createCacheKey(literal1));
-
-        // create a string literal with language and without datatype and test if the hash key is correct between
-        // the different methods
-        String value2 = RandomStringUtils.random(128);
-        Locale locale2 = Locale.getDefault();
-        Literal literal2 = vf.createLiteral(value2,locale2.getLanguage().toLowerCase());
-
-        Assert.assertEquals(LiteralCommons.createCacheKey(value2,locale2,(String)null),LiteralCommons.createCacheKey(literal2));
-        Assert.assertEquals(LiteralCommons.createCacheKey(value2,locale2,(URI)null),LiteralCommons.createCacheKey(literal2));
-
-        // create a string literal with datatype and without language and test if the hash key is correct between
-        // the different methods
-        String value3 = RandomStringUtils.randomNumeric(3);
-        String datatype3 = Namespaces.NS_XSD + "integer";
-        Literal literal3 = vf.createLiteral(value3, vf.createURI(datatype3));
-
-        Assert.assertEquals(LiteralCommons.createCacheKey(value3,null,datatype3),LiteralCommons.createCacheKey(literal3));
-
-
-        // create a Date literal and test whether the hash key is correct between the different methods
-        Date value4 = new Date();
-        String datatype4 = LiteralCommons.getXSDType(value4.getClass());
-        Literal literal4 = vf.createLiteral(DateUtils.getXMLCalendar(value4));
-
-        Assert.assertEquals(datatype4,literal4.getDatatype().stringValue());
-        Assert.assertEquals(LiteralCommons.createCacheKey(value4,datatype4), LiteralCommons.createCacheKey(literal4));
-
-        repository.shutDown();
-    }
-
-
-    /**
-     * Test if the getXSDType() method returns the correct datatype for various Java types
-     */
-    @Test
-    public void testGetXSDType() {
-
-        // String
-        Assert.assertEquals(Namespaces.NS_XSD + "string" , LiteralCommons.getXSDType(String.class));
-
-        // int and Integer
-        Assert.assertEquals(Namespaces.NS_XSD + "integer", LiteralCommons.getXSDType(int.class));
-        Assert.assertEquals(Namespaces.NS_XSD + "integer", LiteralCommons.getXSDType(Integer.class));
-
-
-        // long and Long
-        Assert.assertEquals(Namespaces.NS_XSD + "long", LiteralCommons.getXSDType(long.class));
-        Assert.assertEquals(Namespaces.NS_XSD + "long", LiteralCommons.getXSDType(Long.class));
-
-        // double and Double
-        Assert.assertEquals(Namespaces.NS_XSD + "double", LiteralCommons.getXSDType(double.class));
-        Assert.assertEquals(Namespaces.NS_XSD + "double", LiteralCommons.getXSDType(Double.class));
-
-        // float and Float
-        Assert.assertEquals(Namespaces.NS_XSD + "float", LiteralCommons.getXSDType(float.class));
-        Assert.assertEquals(Namespaces.NS_XSD + "float", LiteralCommons.getXSDType(Float.class));
-
-
-        // boolean and Boolean
-        Assert.assertEquals(Namespaces.NS_XSD + "boolean", LiteralCommons.getXSDType(boolean.class));
-        Assert.assertEquals(Namespaces.NS_XSD + "boolean", LiteralCommons.getXSDType(Boolean.class));
-
-
-        // Date
-        Assert.assertEquals(Namespaces.NS_XSD + "dateTime", LiteralCommons.getXSDType(Date.class));
-
-    }
-    
-    public void testGetRDFLangStringType() throws Exception {
-    	Assert.assertEquals(Namespaces.NS_RDF+ "langString", LiteralCommons.getRDFLangStringType());
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5f62ec33/commons/marmotta-commons/src/test/java/at/newmedialab/sesame/commons/model/ResourceUtilsTest.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-commons/src/test/java/at/newmedialab/sesame/commons/model/ResourceUtilsTest.java b/commons/marmotta-commons/src/test/java/at/newmedialab/sesame/commons/model/ResourceUtilsTest.java
deleted file mode 100644
index 8e00d03..0000000
--- a/commons/marmotta-commons/src/test/java/at/newmedialab/sesame/commons/model/ResourceUtilsTest.java
+++ /dev/null
@@ -1,693 +0,0 @@
-package at.newmedialab.sesame.commons.model;
-/*
- * 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.
- */
-
-import static org.hamcrest.CoreMatchers.allOf;
-import static org.hamcrest.CoreMatchers.anyOf;
-import static org.hamcrest.CoreMatchers.hasItem;
-import static org.hamcrest.CoreMatchers.hasItems;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.not;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.Matchers.hasProperty;
-import static org.junit.Assume.assumeThat;
-
-import at.newmedialab.sesame.commons.repository.ResourceUtils;
-import com.google.common.base.Function;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-import org.hamcrest.CoreMatchers;
-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.Resource;
-import org.openrdf.model.Statement;
-import org.openrdf.model.URI;
-import org.openrdf.model.Value;
-import org.openrdf.repository.Repository;
-import org.openrdf.repository.RepositoryConnection;
-import org.openrdf.repository.RepositoryException;
-import org.openrdf.repository.RepositoryResult;
-import org.openrdf.repository.sail.SailRepository;
-import org.openrdf.rio.RDFFormat;
-import org.openrdf.rio.RDFParseException;
-import org.openrdf.sail.memory.MemoryStore;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.List;
-import java.util.Locale;
-
-/**
- * Test the ResourceUtils (issue 108).
- * <p/>
- * Author: Sebastian Schaffert
- */
-public class ResourceUtilsTest {
-
-    private static final String TEST_DATA = "/foaf/demo-data.foaf";
-
-    private Repository repository;
-
-    /**
-     * Setup memory repository and load initial data (demo-data.foaf)
-     * @throws RepositoryException
-     */
-    @Before
-    public void setup() throws RepositoryException, IOException, RDFParseException {
-        repository = new SailRepository(new MemoryStore());
-        repository.initialize();
-
-        // load demo data
-        InputStream rdfXML = this.getClass().getResourceAsStream(TEST_DATA);
-        // assumeThat("Could not load testfiles", Arrays.<Object> asList(vcard, sparql),
-        // everyItem(notNullValue()));
-        assumeThat("Could not load testData from '" + TEST_DATA + "'", rdfXML, notNullValue(InputStream.class));
-
-        RepositoryConnection connection = repository.getConnection();
-        try {
-            connection.add(rdfXML, "http://localhost/foaf/", RDFFormat.RDFXML);
-            connection.commit();
-        } finally {
-            connection.close();
-        }
-    }
-
-    /**
-     * Shutdown the repository properly before the next test.
-     *
-     * @throws RepositoryException
-     */
-    @After
-    public void teardown() throws RepositoryException {
-        repository.shutDown();
-    }
-
-
-    /**
-     * Test if listing resources yields the correct results
-     */
-    @Test
-    public void testListResources() throws RepositoryException {
-        RepositoryConnection connection = repository.getConnection();
-
-        List<String> resources = ImmutableList.copyOf(
-                Iterables.transform(
-                        ResourceUtils.listResources(connection),
-                        new Function<Resource, String>() {
-                            @Override
-                            public String apply(Resource input) {
-                                return input.stringValue();
-                            }
-                        }
-                        )
-                );
-
-        // test if the result has the expected size
-        Assert.assertEquals(4,resources.size());
-
-        // test if the result contains all resources that have been used as subject
-        Assert.assertThat(resources, hasItems(
-                "http://localhost:8080/LMF/resource/hans_meier",
-                "http://localhost:8080/LMF/resource/sepp_huber",
-                "http://localhost:8080/LMF/resource/anna_schmidt"
-                ));
-        connection.close();
-    }
-
-    /**
-     * Test if listing resources yields the correct results
-     */
-    @Test
-    public void testListResourcesByType() throws RepositoryException {
-        RepositoryConnection connection = repository.getConnection();
-
-        URI persons = connection.getValueFactory().createURI(Namespaces.NS_FOAF + "Person");
-
-        List<String> resources = ImmutableList.copyOf(
-                Iterables.transform(
-                        ResourceUtils.listResources(connection,persons),
-                        new Function<Resource, String>() {
-                            @Override
-                            public String apply(Resource input) {
-                                return input.stringValue();
-                            }
-                        }
-                        )
-                );
-
-        // test if the result has the expected size
-        Assert.assertEquals(3,resources.size());
-
-        // test if the result contains all resources that have been used as subject
-        Assert.assertThat(resources, hasItems(
-                "http://localhost:8080/LMF/resource/hans_meier",
-                "http://localhost:8080/LMF/resource/sepp_huber",
-                "http://localhost:8080/LMF/resource/anna_schmidt"
-                ));
-        connection.close();
-    }
-
-
-    /**
-     * Test listing resources with a given prefix.
-     *
-     * @throws RepositoryException
-     */
-    @Test
-    public void testListResourcesByPrefix() throws RepositoryException {
-        RepositoryConnection connection = repository.getConnection();
-
-        try {
-            // Part 1: unlimited listing; we test that the resources with correct prefix are contained and the
-            // resources with incorrect prefix not
-
-            List<String> resources1 = ImmutableList.copyOf(
-                    Iterables.transform(
-                            ResourceUtils.listResourcesByPrefix(connection, "http://localhost:8080/LMF/resource/h"),
-                            new Function<Resource, String>() {
-                                @Override
-                                public String apply(Resource input) {
-                                    return input.stringValue();
-                                }
-                            }
-                            )
-                    );
-
-            // test if the result has the expected size
-            Assert.assertEquals(1,resources1.size());
-
-            // test if the result contains all resources that have been used as subject
-            Assert.assertThat(resources1, hasItems(
-                    "http://localhost:8080/LMF/resource/hans_meier"
-                    ));
-            Assert.assertThat(resources1, not(hasItems(
-                    "http://localhost:8080/LMF/resource/sepp_huber",
-                    "http://localhost:8080/LMF/resource/anna_schmidt"
-                    )));
-
-
-            // Part 2: limited listing; check whether limit and offset work as expected
-            List<String> resources2 = ImmutableList.copyOf(
-                    Iterables.transform(
-                            ResourceUtils.listResourcesByPrefix(connection, "http://localhost:8080/LMF/resource/",0,2),
-                            new Function<Resource, String>() {
-                                @Override
-                                public String apply(Resource input) {
-                                    return input.stringValue();
-                                }
-                            }
-                            )
-                    );
-
-            // test if the result has the expected size
-            Assert.assertEquals(2,resources2.size());
-
-            // test if the result contains some of resources that have been used as subject
-            Assert.assertThat(resources2, anyOf(
-                    hasItem("http://localhost:8080/LMF/resource/hans_meier"),
-                    hasItem("http://localhost:8080/LMF/resource/sepp_huber"),
-                    hasItem("http://localhost:8080/LMF/resource/anna_schmidt")
-                    ));
-
-            // increase offset by 2 (i.e. next batch of resources)
-            List<String> resources3 = ImmutableList.copyOf(
-                    Iterables.transform(
-                            ResourceUtils.listResourcesByPrefix(connection, "http://localhost:8080/LMF/resource/",2,2),
-                            new Function<Resource, String>() {
-                                @Override
-                                public String apply(Resource input) {
-                                    return input.stringValue();
-                                }
-                            }
-                            )
-                    );
-
-            // test if the result has the expected size
-            Assert.assertEquals(1,resources3.size());
-
-            // test if the result contains some of resources that have been used as subject
-            Assert.assertThat(resources3, anyOf(
-                    hasItem("http://localhost:8080/LMF/resource/hans_meier"),
-                    hasItem("http://localhost:8080/LMF/resource/sepp_huber"),
-                    hasItem("http://localhost:8080/LMF/resource/anna_schmidt")
-                    ));
-        } finally {
-            connection.close();
-        }
-
-    }
-
-
-    /**
-     * Test retrieving properties
-     */
-    @Test
-    public void testGetProperty() throws RepositoryException {
-        RepositoryConnection connection = repository.getConnection();
-
-        try {
-            URI sepp = connection.getValueFactory().createURI("http://localhost:8080/LMF/resource/sepp_huber");
-            URI anna = connection.getValueFactory().createURI("http://localhost:8080/LMF/resource/anna_schmidt");
-            URI hans = connection.getValueFactory().createURI("http://localhost:8080/LMF/resource/hans_meier");
-
-            // test if getProperty returns the correct names
-            Assert.assertEquals("Hans Meier", ResourceUtils.getProperty(connection,hans,"foaf:name"));
-            Assert.assertEquals("Sepp Huber", ResourceUtils.getProperty(connection,sepp,"foaf:name"));
-            Assert.assertEquals("Anna Schmidt", ResourceUtils.getProperty(connection,anna,"foaf:name"));
-
-            // firstName not set
-            Assert.assertNull(ResourceUtils.getProperty(connection,hans,"foaf:firstName"));
-        } finally {
-            connection.close();
-        }
-    }
-
-    /**
-     * Test retrieving properties
-     */
-    @Test
-    public void testGetProperties() throws RepositoryException {
-        RepositoryConnection connection = repository.getConnection();
-
-        try {
-            URI sepp = connection.getValueFactory().createURI("http://localhost:8080/LMF/resource/sepp_huber");
-            URI anna = connection.getValueFactory().createURI("http://localhost:8080/LMF/resource/anna_schmidt");
-            URI hans = connection.getValueFactory().createURI("http://localhost:8080/LMF/resource/hans_meier");
-
-            List<String> sepp_names = ImmutableList.copyOf(ResourceUtils.getProperties(connection,sepp,"foaf:name"));
-            List<String> anna_names = ImmutableList.copyOf(ResourceUtils.getProperties(connection,anna,"foaf:name"));
-            List<String> hans_names = ImmutableList.copyOf(ResourceUtils.getProperties(connection,hans,"foaf:name"));
-            List<String> hans_xyz = ImmutableList.copyOf(ResourceUtils.getProperties(connection,hans,"foaf:xyz"));
-
-            Assert.assertEquals(1,sepp_names.size());
-            Assert.assertEquals(1,anna_names.size());
-            Assert.assertEquals(1,hans_names.size());
-            Assert.assertEquals(0,hans_xyz.size());
-
-            Assert.assertThat(sepp_names, hasItem("Sepp Huber"));
-            Assert.assertThat(anna_names, hasItem("Anna Schmidt"));
-            Assert.assertThat(hans_names, hasItem("Hans Meier"));
-
-        } finally {
-            connection.close();
-        }
-    }
-
-
-    /**
-     * Test setting properties
-     */
-    @Test
-    public void testSetProperty() throws RepositoryException {
-        RepositoryConnection connection = repository.getConnection();
-
-        try {
-            URI toni = connection.getValueFactory().createURI("http://localhost:8080/LMF/resource/toni_schneider");
-            URI name = connection.getValueFactory().createURI(Namespaces.NS_FOAF + "name");
-
-            ResourceUtils.setProperty(connection,toni,"foaf:name","Anton Schneider");
-
-            // test if getProperty returns the correct names
-            Assert.assertEquals("Anton Schneider", ResourceUtils.getProperty(connection,toni,"foaf:name"));
-
-            // test if getStatements returns the correct statement
-            RepositoryResult<Statement> triples = connection.getStatements(toni,name,null,true);
-            Assert.assertTrue(triples.hasNext());
-            Assert.assertEquals("Anton Schneider", triples.next().getObject().stringValue());
-            triples.close();
-        } finally {
-            connection.close();
-        }
-    }
-
-
-    /**
-     * Test removing properties
-     */
-    @Test
-    public void testRemoveProperty() throws RepositoryException {
-        RepositoryConnection connection = repository.getConnection();
-
-        try {
-            URI hans = connection.getValueFactory().createURI("http://localhost:8080/LMF/resource/hans_meier");
-
-            // test if getProperty returns the correct names
-            Assert.assertEquals("Hans Meier", ResourceUtils.getProperty(connection,hans,"foaf:name"));
-
-            ResourceUtils.removeProperty(connection,hans, "foaf:name");
-
-            Assert.assertNull(ResourceUtils.getProperty(connection,hans,"foaf:name"));
-        } finally {
-            connection.close();
-        }
-    }
-
-    /**
-     * Test listing outgoing statements
-     */
-    @Test
-    public void testListOutgoingStatements() throws RepositoryException {
-        RepositoryConnection connection = repository.getConnection();
-
-        try {
-            URI hans = connection.getValueFactory().createURI("http://localhost:8080/LMF/resource/hans_meier");
-
-            List<Statement> result = ImmutableList.copyOf(
-                    ResourceUtils.listOutgoing(connection,hans)
-                    );
-
-            // check that the number of results is correct
-            Assert.assertEquals(12,result.size());
-
-            Assert.assertThat(result, allOf(
-                    CoreMatchers.<Statement>hasItem(hasProperty("object", is(connection.getValueFactory().createLiteral("Hans Meier")))),
-                    CoreMatchers.<Statement>hasItem(hasProperty("object", is(connection.getValueFactory().createURI(Namespaces.NS_FOAF + "Person"))))
-                    ));
-
-        } finally {
-            connection.close();
-        }
-    }
-
-    /**
-     * Test listing outgoing nodes
-     */
-    @Test
-    public void testListOutgoingNodes() throws RepositoryException {
-        RepositoryConnection connection = repository.getConnection();
-
-        try {
-            URI hans = connection.getValueFactory().createURI("http://localhost:8080/LMF/resource/hans_meier");
-
-            List<Value> result = ImmutableList.copyOf(
-                    ResourceUtils.listOutgoingNodes(connection, hans, "foaf:name")
-                    );
-
-            // check that the number of results is correct
-            Assert.assertEquals(1,result.size());
-
-            Assert.assertThat(result, hasItems(
-                    (Value) connection.getValueFactory().createLiteral("Hans Meier")
-                    ));
-
-        } finally {
-            connection.close();
-        }
-    }
-
-
-    /**
-     * Test adding outgoing statements (by string label of the property)
-     */
-    @Test
-    public void testaddOutgoingNodeLabel() throws RepositoryException {
-        RepositoryConnection connection = repository.getConnection();
-
-        try {
-            URI toni = connection.getValueFactory().createURI("http://localhost:8080/LMF/resource/toni_schneider");
-            URI name = connection.getValueFactory().createURI(Namespaces.NS_FOAF + "name");
-            String property = "foaf:name";
-            Literal value    = connection.getValueFactory().createLiteral("Anton Schneider");
-
-            ResourceUtils.addOutgoingNode(connection,toni,property,value,null);
-
-            // test if getProperty returns the correct names
-            Assert.assertEquals("Anton Schneider", ResourceUtils.getProperty(connection,toni,"foaf:name"));
-
-            // test if getStatements returns the correct statement
-            RepositoryResult<Statement> triples = connection.getStatements(toni,name,null,true);
-            Assert.assertTrue(triples.hasNext());
-            Assert.assertEquals("Anton Schneider", triples.next().getObject().stringValue());
-            triples.close();
-
-        } finally {
-            connection.close();
-        }
-    }
-
-    /**
-     * Test adding outgoing statements (by string label of the property)
-     */
-    @Test
-    @SuppressWarnings("deprecation")
-    public void testaddOutgoingNodeProperty() throws RepositoryException {
-        RepositoryConnection connection = repository.getConnection();
-
-        try {
-            URI toni = connection.getValueFactory().createURI("http://localhost:8080/LMF/resource/toni_schneider");
-            URI name = connection.getValueFactory().createURI(Namespaces.NS_FOAF + "name");
-            Literal value    = connection.getValueFactory().createLiteral("Anton Schneider");
-
-            ResourceUtils.addOutgoingNode(connection,toni,name,value,null);
-
-            // test if getProperty returns the correct names
-            Assert.assertEquals("Anton Schneider", ResourceUtils.getProperty(connection,toni,"foaf:name"));
-
-            // test if getStatements returns the correct statement
-            RepositoryResult<Statement> triples = connection.getStatements(toni,name,null,true);
-            Assert.assertTrue(triples.hasNext());
-            Assert.assertEquals("Anton Schneider", triples.next().getObject().stringValue());
-            triples.close();
-
-        } finally {
-            connection.close();
-        }
-    }
-
-
-    /**
-     * Test listing outgoing nodes
-     */
-    @Test
-    public void testRemoveOutgoingNodes() throws RepositoryException {
-        RepositoryConnection connection = repository.getConnection();
-
-        try {
-            URI hans = connection.getValueFactory().createURI("http://localhost:8080/LMF/resource/hans_meier");
-
-            List<Value> result1 = ImmutableList.copyOf(
-                    ResourceUtils.listOutgoingNodes(connection, hans, "foaf:name")
-                    );
-
-            // check that the number of results is correct
-            Assert.assertEquals(1,result1.size());
-
-            Assert.assertThat(result1, hasItems(
-                    (Value) connection.getValueFactory().createLiteral("Hans Meier")
-                    ));
-
-            ResourceUtils.removeOutgoingNode(connection,hans,"foaf:name", null, null);
-
-            List<Value> result2 = ImmutableList.copyOf(
-                    ResourceUtils.listOutgoingNodes(connection, hans, "foaf:name")
-                    );
-
-            // check that the number of results is correct
-            Assert.assertEquals(0,result2.size());
-
-
-        } finally {
-            connection.close();
-        }
-    }
-
-    /**
-     * Test listing incoming statements
-     */
-    @Test
-    public void testListIncomingStatements() throws RepositoryException {
-        RepositoryConnection connection = repository.getConnection();
-
-        try {
-            URI hans = connection.getValueFactory().createURI("http://localhost:8080/LMF/resource/sepp_huber");
-
-            List<Statement> result = ImmutableList.copyOf(
-                    ResourceUtils.listIncoming(connection, hans)
-                    );
-
-            // check that the number of results is correct
-            Assert.assertEquals(2,result.size());
-
-            Assert.assertThat(result, allOf(
-                    CoreMatchers.<Statement>hasItem(hasProperty("subject", is(connection.getValueFactory().createURI("http://localhost:8080/LMF/resource/hans_meier")))),
-                    CoreMatchers.<Statement>hasItem(hasProperty("subject", is(connection.getValueFactory().createURI("http://localhost:8080/LMF/resource/anna_schmidt"))))
-                    ));
-
-        } finally {
-            connection.close();
-        }
-    }
-
-    /**
-     * Test listing incoming nodes
-     */
-    @Test
-    public void testListIncomingNodes() throws RepositoryException {
-        RepositoryConnection connection = repository.getConnection();
-
-        try {
-            URI hans = connection.getValueFactory().createURI("http://localhost:8080/LMF/resource/sepp_huber");
-
-            List<Resource> result = ImmutableList.copyOf(
-                    ResourceUtils.listIncomingNodes(connection, hans, "foaf:knows")
-                    );
-
-            // check that the number of results is correct
-            Assert.assertEquals(2,result.size());
-
-            Assert.assertThat(result, hasItems(
-                    (Resource) connection.getValueFactory().createURI("http://localhost:8080/LMF/resource/hans_meier"),
-                    (Resource) connection.getValueFactory().createURI("http://localhost:8080/LMF/resource/anna_schmidt")
-                    ));
-
-        } finally {
-            connection.close();
-        }
-    }
-
-
-    /**
-     * Test getting various forms of labels
-     */
-    @Test
-    public void testGetLabel() throws RepositoryException {
-        RepositoryConnection connection = repository.getConnection();
-
-        try {
-            URI r1 = connection.getValueFactory().createURI("http://localhost:8080/LMF/resource/r1");
-            URI r2 = connection.getValueFactory().createURI("http://localhost:8080/LMF/resource/r2");
-            URI r3 = connection.getValueFactory().createURI("http://localhost:8080/LMF/resource/r3");
-            URI c1 = connection.getValueFactory().createURI("http://localhost:8080/LMF/context/c1");
-
-            URI rdfs_label = connection.getValueFactory().createURI(Namespaces.NS_RDFS + "label");
-            URI dct_title  = connection.getValueFactory().createURI(Namespaces.NS_DC_TERMS + "title");
-            URI skos_label = connection.getValueFactory().createURI(Namespaces.NS_SKOS + "prefLabel");
-
-            connection.add(r1,rdfs_label,connection.getValueFactory().createLiteral("R1"));
-            connection.add(r2,dct_title,connection.getValueFactory().createLiteral("R2","en"));
-            connection.add(r3,skos_label,connection.getValueFactory().createLiteral("R3"),c1);
-
-            Assert.assertEquals("R1", ResourceUtils.getLabel(connection,r1));
-            Assert.assertEquals("R2", ResourceUtils.getLabel(connection,r2));
-            Assert.assertEquals("R3", ResourceUtils.getLabel(connection,r3));
-
-            Assert.assertEquals("r1", ResourceUtils.getLabel(connection,r1, Locale.ENGLISH));
-            Assert.assertEquals("R2", ResourceUtils.getLabel(connection,r2, Locale.ENGLISH));
-            Assert.assertEquals("r3", ResourceUtils.getLabel(connection,r3, Locale.ENGLISH));
-
-            Assert.assertEquals("r1", ResourceUtils.getLabel(connection,r1, c1));
-            Assert.assertEquals("r2", ResourceUtils.getLabel(connection,r2, c1));
-            Assert.assertEquals("R3", ResourceUtils.getLabel(connection,r3, c1));
-        } finally {
-            connection.close();
-        }
-    }
-
-    /**
-     * Test setting labels.
-     *
-     * @throws RepositoryException
-     */
-    @Test
-    public void testSetLabel() throws RepositoryException {
-        RepositoryConnection connection = repository.getConnection();
-
-        try {
-            URI r1 = connection.getValueFactory().createURI("http://localhost:8080/LMF/resource/r1");
-            URI r2 = connection.getValueFactory().createURI("http://localhost:8080/LMF/resource/r2");
-            URI r3 = connection.getValueFactory().createURI("http://localhost:8080/LMF/resource/r3");
-            URI c1 = connection.getValueFactory().createURI("http://localhost:8080/LMF/context/c1");
-
-
-            ResourceUtils.setLabel(connection,r1,"R1");
-            ResourceUtils.setLabel(connection,r2,Locale.ENGLISH,"R2");
-            ResourceUtils.setLabel(connection,r3,"R3",c1);
-
-
-            Assert.assertEquals("R1", ResourceUtils.getLabel(connection,r1));
-            Assert.assertEquals("R2", ResourceUtils.getLabel(connection,r2));
-            Assert.assertEquals("R3", ResourceUtils.getLabel(connection,r3));
-
-            Assert.assertEquals("r1", ResourceUtils.getLabel(connection,r1, Locale.ENGLISH));
-            Assert.assertEquals("R2", ResourceUtils.getLabel(connection,r2, Locale.ENGLISH));
-            Assert.assertEquals("r3", ResourceUtils.getLabel(connection,r3, Locale.ENGLISH));
-
-            Assert.assertEquals("r1", ResourceUtils.getLabel(connection,r1, c1));
-            Assert.assertEquals("r2", ResourceUtils.getLabel(connection,r2, c1));
-            Assert.assertEquals("R3", ResourceUtils.getLabel(connection,r3, c1));
-        } finally {
-            connection.close();
-        }
-
-    }
-
-    /**
-     * Test returning types
-     */
-    @Test
-    public void testGetTypes() throws RepositoryException {
-        RepositoryConnection connection = repository.getConnection();
-
-        try {
-            URI hans = connection.getValueFactory().createURI("http://localhost:8080/LMF/resource/sepp_huber");
-
-            List<Resource> result = ImmutableList.copyOf(
-                    ResourceUtils.getTypes(connection, hans)
-                    );
-
-            // check that the number of results is correct
-            Assert.assertEquals(1,result.size());
-
-            Assert.assertThat(result, hasItem(connection.getValueFactory().createURI(Namespaces.NS_FOAF + "Person")));
-
-        } finally {
-            connection.close();
-        }
-    }
-
-    /**
-     * Test hasType()
-     */
-    @Test
-    public void testHasTypes() throws RepositoryException {
-        RepositoryConnection connection = repository.getConnection();
-
-        try {
-            URI hans = connection.getValueFactory().createURI("http://localhost:8080/LMF/resource/sepp_huber");
-
-            Assert.assertTrue(ResourceUtils.hasType(connection,hans,connection.getValueFactory().createURI(Namespaces.NS_FOAF + "Person")));
-            Assert.assertFalse(ResourceUtils.hasType(connection,hans,connection.getValueFactory().createURI(Namespaces.NS_FOAF + "XYZ")));
-        } finally {
-            connection.close();
-        }
-    }
-
-
-
-    /**
-     * Test if claimed memory resources are properly disposed of when the connection is closed but an iterator is still open
-     *
-     * TODO: How can we check this?
-     *
-     */
-    public void testResultDispose() {
-
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5f62ec33/commons/marmotta-commons/src/test/java/at/newmedialab/sesame/commons/model/URICommonsTest.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-commons/src/test/java/at/newmedialab/sesame/commons/model/URICommonsTest.java b/commons/marmotta-commons/src/test/java/at/newmedialab/sesame/commons/model/URICommonsTest.java
deleted file mode 100644
index e07f17e..0000000
--- a/commons/marmotta-commons/src/test/java/at/newmedialab/sesame/commons/model/URICommonsTest.java
+++ /dev/null
@@ -1,71 +0,0 @@
-package at.newmedialab.sesame.commons.model;
-
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-import org.openrdf.model.URI;
-import org.openrdf.repository.Repository;
-import org.openrdf.repository.RepositoryException;
-import org.openrdf.repository.sail.SailRepository;
-import org.openrdf.sail.memory.MemoryStore;
-
-import java.util.ArrayList;
-import java.util.List;
-
-@RunWith(Parameterized.class)
-public class URICommonsTest {
-
-
-    private final String prefix;
-    private final String local;
-    private URI uri;
-    private String uri_string;
-
-    @Parameters(name = "{0}{1}")
-    public static List<String[]> data() {
-        final ArrayList<String[]> d = new ArrayList<String[]>();
-
-        d.add(new String[] { "http://www.example.com/foo/", "bar" });
-        d.add(new String[] { "http://www.example.com/foo#", "bar" });
-
-        return d;
-    }
-
-    public URICommonsTest(String prefix, String local) {
-        this.prefix = prefix;
-        this.local = local;
-    }
-
-    @Before
-    public void setup() throws RepositoryException {
-        Repository repository = new SailRepository(new MemoryStore());
-        repository.initialize();
-
-        uri_string = prefix + local;
-        uri = repository.getValueFactory().createURI(prefix, local);
-
-        repository.shutDown();
-    }
-
-    @Test
-    public void testSplitNamespace() {
-        String[] split = URICommons.splitNamespace(uri_string);
-
-        assertEquals(2, split.length);
-        Assert.assertThat(split, equalTo(new String[] { prefix, local }));
-    }
-
-    @Test
-    public void testCreateCacheKey() {
-        assertEquals(uri_string, URICommons.createCacheKey(uri));
-        assertEquals(uri.stringValue(), URICommons.createCacheKey(uri_string));
-        assertEquals(URICommons.createCacheKey(uri_string), URICommons.createCacheKey(uri));
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5f62ec33/commons/marmotta-commons/src/test/java/org/apache/marmotta/commons/http/ContentTypeMatchingTest.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-commons/src/test/java/org/apache/marmotta/commons/http/ContentTypeMatchingTest.java b/commons/marmotta-commons/src/test/java/org/apache/marmotta/commons/http/ContentTypeMatchingTest.java
new file mode 100644
index 0000000..fe4347e
--- /dev/null
+++ b/commons/marmotta-commons/src/test/java/org/apache/marmotta/commons/http/ContentTypeMatchingTest.java
@@ -0,0 +1,145 @@
+/*
+ * Copyright (c) 2013 The Apache Software Foundation
+ *
+ *  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.http;
+
+import org.apache.marmotta.commons.http.ContentType;
+import org.apache.marmotta.commons.http.LMFHttpUtils;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Add file description here!
+ * <p/>
+ * Author: Sebastian Schaffert (sschaffert@apache.org)
+ */
+public class ContentTypeMatchingTest {
+
+
+    @Test
+    public void testMatchNormal1() throws Exception {
+        ContentType type1 = new ContentType("application","json");
+        ContentType type2 = new ContentType("application","json");
+
+        Assert.assertTrue(type2.matches(type1));
+        Assert.assertTrue(type1.matches(type2));
+    }
+
+
+    @Test
+    public void testMatchNormal2() throws Exception {
+        ContentType type1 = new ContentType("application","json");
+        ContentType type2 = new ContentType("application","*");
+
+        Assert.assertTrue(type2.matchesWildcard(type1));
+        Assert.assertFalse(type1.matches(type2));
+        Assert.assertFalse(type2.matches(type1));
+    }
+
+    @Test
+    public void testMatchNormal3() throws Exception {
+        ContentType type1 = new ContentType("application","json");
+        ContentType type2 = new ContentType("*","*");
+
+        Assert.assertTrue(type2.matchesWildcard(type1));
+        Assert.assertFalse(type2.matches(type1));
+        Assert.assertFalse(type1.matches(type2));
+    }
+
+    @Test
+    public void testMatchQualifier1() throws Exception {
+        ContentType type1 = new ContentType("application","rdf+json");
+        ContentType type2 = new ContentType("application","json");
+
+        Assert.assertFalse(type2.matches(type1));
+        Assert.assertTrue(type2.matchesSubtype(type1));
+        Assert.assertFalse(type1.matchesSubtype(type2));
+    }
+    @Test
+    public void testMatchQualifier2() throws Exception {
+        ContentType type1 = new ContentType("application","rdf+json");
+        ContentType type2 = new ContentType("application","*");
+
+        Assert.assertTrue(type2.matchesWildcard(type1));
+        Assert.assertFalse(type2.matchesSubtype(type1));
+        Assert.assertFalse(type1.matchesSubtype(type2));
+    }
+
+
+    @Test
+    public void testGetBestMatch1() throws Exception {
+        ContentType offered1 = new ContentType("text","html");
+        ContentType offered2 = new ContentType("application","rdf+json");
+        ContentType offered3 = new ContentType("application","ld+json");
+
+        List<ContentType> offered = new ArrayList<ContentType>(3);
+        offered.add(offered1);
+        offered.add(offered2);
+        offered.add(offered3);
+
+        ContentType accepted1 = new ContentType("application","json");
+        ContentType accepted2 = new ContentType("*","*");
+        List<ContentType> accepted = new ArrayList<ContentType>(2);
+        accepted.add(accepted1);
+        accepted.add(accepted2);
+
+        Assert.assertEquals(offered2, LMFHttpUtils.bestContentType(offered,accepted));
+    }
+
+    @Test
+    public void testGetBestMatch2() throws Exception {
+        ContentType offered1 = new ContentType("text","html");
+        ContentType offered2 = new ContentType("application","rdf+json");
+        ContentType offered3 = new ContentType("application","ld+json");
+
+        List<ContentType> offered = new ArrayList<ContentType>(3);
+        offered.add(offered1);
+        offered.add(offered2);
+        offered.add(offered3);
+
+        ContentType accepted1 = new ContentType("application","xml");
+        ContentType accepted2 = new ContentType("*","*");
+        List<ContentType> accepted = new ArrayList<ContentType>(2);
+        accepted.add(accepted1);
+        accepted.add(accepted2);
+
+        Assert.assertEquals(offered1, LMFHttpUtils.bestContentType(offered,accepted));
+    }
+
+    @Test
+    public void testGetBestMatch3() throws Exception {
+        ContentType offered1 = new ContentType("text","html");
+        ContentType offered2 = new ContentType("application","rdf+json");
+        ContentType offered3 = new ContentType("application","ld+json");
+
+        List<ContentType> offered = new ArrayList<ContentType>(3);
+        offered.add(offered1);
+        offered.add(offered2);
+        offered.add(offered3);
+
+        ContentType accepted1 = new ContentType("application","ld+json");
+        ContentType accepted2 = new ContentType("*","*");
+        List<ContentType> accepted = new ArrayList<ContentType>(2);
+        accepted.add(accepted1);
+        accepted.add(accepted2);
+
+        Assert.assertEquals(offered3, LMFHttpUtils.bestContentType(offered,accepted));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5f62ec33/commons/marmotta-commons/src/test/java/org/apache/marmotta/commons/http/ETagGeneratorTest.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-commons/src/test/java/org/apache/marmotta/commons/http/ETagGeneratorTest.java b/commons/marmotta-commons/src/test/java/org/apache/marmotta/commons/http/ETagGeneratorTest.java
new file mode 100644
index 0000000..fa8868e
--- /dev/null
+++ b/commons/marmotta-commons/src/test/java/org/apache/marmotta/commons/http/ETagGeneratorTest.java
@@ -0,0 +1,121 @@
+/*
+ * 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.http;
+
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.junit.Assume.assumeThat;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.marmotta.commons.http.ETagGenerator;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.openrdf.repository.Repository;
+import org.openrdf.repository.RepositoryConnection;
+import org.openrdf.repository.RepositoryException;
+import org.openrdf.repository.sail.SailRepository;
+import org.openrdf.rio.RDFFormat;
+import org.openrdf.rio.RDFParseException;
+import org.openrdf.sail.memory.MemoryStore;
+
+/**
+ * Test the ETag Generator
+ * 
+ * @author Sergio Fernández
+ */
+public class ETagGeneratorTest {
+
+    private static final String TEST_DATA = "/foaf/demo-data.foaf";
+    
+    private static final String URI_1 = "http://localhost:8080/LMF/resource/hans_meier";
+    
+    private static final String URI_2 = "http://localhost:8080/LMF/resource/sepp_huber";
+    
+    private static final String URI_3 = "http://localhost:8080/LMF/resource/anna_schmidt";
+
+    private Repository repository;
+
+    /**
+     * Setup memory repository and load initial data (demo-data.foaf)
+     * @throws RepositoryException
+     */
+    @Before
+    public void setup() throws RepositoryException, IOException, RDFParseException {
+        repository = new SailRepository(new MemoryStore());
+        repository.initialize();
+
+        InputStream rdfXML = this.getClass().getResourceAsStream(TEST_DATA);
+        assumeThat("Could not load testData from '" + TEST_DATA + "'", rdfXML, notNullValue(InputStream.class));
+
+        RepositoryConnection connection = repository.getConnection();
+        try {
+            connection.add(rdfXML, "http://localhost/foaf/", RDFFormat.RDFXML);
+            connection.commit();
+        } finally {
+            connection.close();
+        }
+    }
+
+    /**
+     * Shutdown the repository properly before the next test.
+     *
+     * @throws RepositoryException
+     */
+    @After
+    public void teardown() throws RepositoryException {
+        repository.shutDown();
+    }
+
+    /**
+     * Basic tests
+     */
+    @Test
+    public void runningTest() throws RepositoryException {
+        RepositoryConnection conn = repository.getConnection();
+        String etag = ETagGenerator.getETag(conn, URI_1);
+        Assert.assertNotNull(etag);
+        String wetag = ETagGenerator.getWeakETag(conn, URI_1);
+        Assert.assertNotNull(wetag);
+        conn.close();
+    }
+    
+    /**
+     * Invariant test
+     */
+    @Test
+    public void invariantTest() throws RepositoryException {
+        RepositoryConnection conn1 = repository.getConnection();
+        String etag1 = ETagGenerator.getETag(conn1, URI_1);
+        Assert.assertNotNull(etag1);
+        String wetag1 = ETagGenerator.getWeakETag(conn1, URI_1);
+        Assert.assertNotNull(wetag1);
+        conn1.close();
+        
+        RepositoryConnection conn2 = repository.getConnection();
+        String etag2 = ETagGenerator.getETag(conn2, URI_1);
+        Assert.assertNotNull(etag2);
+        String wetag2 = ETagGenerator.getWeakETag(conn2, URI_1);
+        Assert.assertNotNull(wetag2);
+        conn2.close();
+        
+        Assert.assertEquals(etag1, etag2);
+        Assert.assertEquals(wetag1, wetag2);
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5f62ec33/commons/marmotta-commons/src/test/java/org/apache/marmotta/commons/http/UriUtilTest.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-commons/src/test/java/org/apache/marmotta/commons/http/UriUtilTest.java b/commons/marmotta-commons/src/test/java/org/apache/marmotta/commons/http/UriUtilTest.java
new file mode 100644
index 0000000..c3ff5fd
--- /dev/null
+++ b/commons/marmotta-commons/src/test/java/org/apache/marmotta/commons/http/UriUtilTest.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2013 The Apache Software Foundation
+ *
+ *  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.http;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.marmotta.commons.http.UriUtil;
+import org.junit.Test;
+
+/**
+ * UriUtil tests
+ * 
+ * @author Sergio Fernández
+ */
+public class UriUtilTest {
+
+
+    private static final String URI_2 = "http://localhost:8080/context/default";
+    private static final String URI_1 = "http://rdfs.org/sioc/ns#Post";
+
+    @Test
+    public void testCommonUris() throws Exception {
+        assertEquals("http://rdfs.org/sioc/ns#", UriUtil.getNamespace(URI_1));
+        assertEquals("Post", UriUtil.getReference(URI_1));
+        assertEquals("http://localhost:8080/context/", UriUtil.getNamespace(URI_2));
+        assertEquals("default", UriUtil.getReference(URI_2));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5f62ec33/commons/marmotta-commons/src/test/java/org/apache/marmotta/commons/http/test/ContentTypeMatchingTest.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-commons/src/test/java/org/apache/marmotta/commons/http/test/ContentTypeMatchingTest.java b/commons/marmotta-commons/src/test/java/org/apache/marmotta/commons/http/test/ContentTypeMatchingTest.java
deleted file mode 100644
index 75f908d..0000000
--- a/commons/marmotta-commons/src/test/java/org/apache/marmotta/commons/http/test/ContentTypeMatchingTest.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Copyright (c) 2013 The Apache Software Foundation
- *
- *  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.http.test;
-
-import org.apache.marmotta.commons.http.ContentType;
-import org.apache.marmotta.commons.http.LMFHttpUtils;
-import org.junit.Assert;
-import org.junit.Test;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Add file description here!
- * <p/>
- * Author: Sebastian Schaffert (sschaffert@apache.org)
- */
-public class ContentTypeMatchingTest {
-
-
-    @Test
-    public void testMatchNormal1() throws Exception {
-        ContentType type1 = new ContentType("application","json");
-        ContentType type2 = new ContentType("application","json");
-
-        Assert.assertTrue(type2.matches(type1));
-        Assert.assertTrue(type1.matches(type2));
-    }
-
-
-    @Test
-    public void testMatchNormal2() throws Exception {
-        ContentType type1 = new ContentType("application","json");
-        ContentType type2 = new ContentType("application","*");
-
-        Assert.assertTrue(type2.matchesWildcard(type1));
-        Assert.assertFalse(type1.matches(type2));
-        Assert.assertFalse(type2.matches(type1));
-    }
-
-    @Test
-    public void testMatchNormal3() throws Exception {
-        ContentType type1 = new ContentType("application","json");
-        ContentType type2 = new ContentType("*","*");
-
-        Assert.assertTrue(type2.matchesWildcard(type1));
-        Assert.assertFalse(type2.matches(type1));
-        Assert.assertFalse(type1.matches(type2));
-    }
-
-    @Test
-    public void testMatchQualifier1() throws Exception {
-        ContentType type1 = new ContentType("application","rdf+json");
-        ContentType type2 = new ContentType("application","json");
-
-        Assert.assertFalse(type2.matches(type1));
-        Assert.assertTrue(type2.matchesSubtype(type1));
-        Assert.assertFalse(type1.matchesSubtype(type2));
-    }
-    @Test
-    public void testMatchQualifier2() throws Exception {
-        ContentType type1 = new ContentType("application","rdf+json");
-        ContentType type2 = new ContentType("application","*");
-
-        Assert.assertTrue(type2.matchesWildcard(type1));
-        Assert.assertFalse(type2.matchesSubtype(type1));
-        Assert.assertFalse(type1.matchesSubtype(type2));
-    }
-
-
-    @Test
-    public void testGetBestMatch1() throws Exception {
-        ContentType offered1 = new ContentType("text","html");
-        ContentType offered2 = new ContentType("application","rdf+json");
-        ContentType offered3 = new ContentType("application","ld+json");
-
-        List<ContentType> offered = new ArrayList<ContentType>(3);
-        offered.add(offered1);
-        offered.add(offered2);
-        offered.add(offered3);
-
-        ContentType accepted1 = new ContentType("application","json");
-        ContentType accepted2 = new ContentType("*","*");
-        List<ContentType> accepted = new ArrayList<ContentType>(2);
-        accepted.add(accepted1);
-        accepted.add(accepted2);
-
-        Assert.assertEquals(offered2, LMFHttpUtils.bestContentType(offered,accepted));
-    }
-
-    @Test
-    public void testGetBestMatch2() throws Exception {
-        ContentType offered1 = new ContentType("text","html");
-        ContentType offered2 = new ContentType("application","rdf+json");
-        ContentType offered3 = new ContentType("application","ld+json");
-
-        List<ContentType> offered = new ArrayList<ContentType>(3);
-        offered.add(offered1);
-        offered.add(offered2);
-        offered.add(offered3);
-
-        ContentType accepted1 = new ContentType("application","xml");
-        ContentType accepted2 = new ContentType("*","*");
-        List<ContentType> accepted = new ArrayList<ContentType>(2);
-        accepted.add(accepted1);
-        accepted.add(accepted2);
-
-        Assert.assertEquals(offered1, LMFHttpUtils.bestContentType(offered,accepted));
-    }
-
-    @Test
-    public void testGetBestMatch3() throws Exception {
-        ContentType offered1 = new ContentType("text","html");
-        ContentType offered2 = new ContentType("application","rdf+json");
-        ContentType offered3 = new ContentType("application","ld+json");
-
-        List<ContentType> offered = new ArrayList<ContentType>(3);
-        offered.add(offered1);
-        offered.add(offered2);
-        offered.add(offered3);
-
-        ContentType accepted1 = new ContentType("application","ld+json");
-        ContentType accepted2 = new ContentType("*","*");
-        List<ContentType> accepted = new ArrayList<ContentType>(2);
-        accepted.add(accepted1);
-        accepted.add(accepted2);
-
-        Assert.assertEquals(offered3, LMFHttpUtils.bestContentType(offered,accepted));
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5f62ec33/commons/marmotta-commons/src/test/java/org/apache/marmotta/commons/http/test/UriUtilTest.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-commons/src/test/java/org/apache/marmotta/commons/http/test/UriUtilTest.java b/commons/marmotta-commons/src/test/java/org/apache/marmotta/commons/http/test/UriUtilTest.java
deleted file mode 100644
index 38c4f5d..0000000
--- a/commons/marmotta-commons/src/test/java/org/apache/marmotta/commons/http/test/UriUtilTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 2013 The Apache Software Foundation
- *
- *  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.http.test;
-
-import static org.junit.Assert.assertEquals;
-
-import org.apache.marmotta.commons.http.UriUtil;
-import org.junit.Test;
-
-/**
- * UriUtil tests
- * 
- * @author Sergio Fernández
- */
-public class UriUtilTest {
-
-
-    private static final String URI_2 = "http://localhost:8080/context/default";
-    private static final String URI_1 = "http://rdfs.org/sioc/ns#Post";
-
-    @Test
-    public void testCommonUris() throws Exception {
-        assertEquals("http://rdfs.org/sioc/ns#", UriUtil.getNamespace(URI_1));
-        assertEquals("Post", UriUtil.getReference(URI_1));
-        assertEquals("http://localhost:8080/context/", UriUtil.getNamespace(URI_2));
-        assertEquals("default", UriUtil.getReference(URI_2));
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5f62ec33/commons/marmotta-commons/src/test/java/org/apache/marmotta/commons/sesame/model/LiteralCommonsTest.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-commons/src/test/java/org/apache/marmotta/commons/sesame/model/LiteralCommonsTest.java b/commons/marmotta-commons/src/test/java/org/apache/marmotta/commons/sesame/model/LiteralCommonsTest.java
new file mode 100644
index 0000000..dba2c04
--- /dev/null
+++ b/commons/marmotta-commons/src/test/java/org/apache/marmotta/commons/sesame/model/LiteralCommonsTest.java
@@ -0,0 +1,135 @@
+package org.apache.marmotta.commons.sesame.model;
+/*
+ * 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.
+ */
+
+import org.apache.commons.lang.RandomStringUtils;
+import org.apache.marmotta.commons.sesame.model.LiteralCommons;
+import org.apache.marmotta.commons.sesame.model.Namespaces;
+import org.apache.marmotta.commons.util.DateUtils;
+import org.junit.Assert;
+import org.junit.Test;
+import org.openrdf.model.Literal;
+import org.openrdf.model.URI;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.repository.Repository;
+import org.openrdf.repository.sail.SailRepository;
+import org.openrdf.sail.memory.MemoryStore;
+
+import java.util.Date;
+import java.util.Locale;
+
+/**
+ * Test the functions of the literal commons
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class LiteralCommonsTest {
+
+    /**
+     * Test the creation of the cache keys for literals. All methods should return the same cache key for the
+     * same input data.
+     *
+     * @throws Exception
+     */
+    @Test
+    public void testCreateCacheKey() throws Exception {
+        Assert.assertNotEquals(LiteralCommons.createCacheKey("abc",null,(String)null), LiteralCommons.createCacheKey("ABC",null,(String)null));
+        Assert.assertNotEquals(LiteralCommons.createCacheKey("abc",null,(URI)null), LiteralCommons.createCacheKey("ABC",null,(URI)null));
+
+        Repository repository = new SailRepository(new MemoryStore());
+        repository.initialize();
+
+        ValueFactory vf = repository.getValueFactory();
+
+        // create a string literal without language and datatype and test if the hash key is correct between
+        // the different methods
+        String value1 = RandomStringUtils.random(128);
+        Literal literal1 = vf.createLiteral(value1);
+
+        Assert.assertEquals(LiteralCommons.createCacheKey(value1,null,(String)null),LiteralCommons.createCacheKey(literal1));
+        Assert.assertEquals(LiteralCommons.createCacheKey(value1,null,(URI)null),LiteralCommons.createCacheKey(literal1));
+
+        // create a string literal with language and without datatype and test if the hash key is correct between
+        // the different methods
+        String value2 = RandomStringUtils.random(128);
+        Locale locale2 = Locale.getDefault();
+        Literal literal2 = vf.createLiteral(value2,locale2.getLanguage().toLowerCase());
+
+        Assert.assertEquals(LiteralCommons.createCacheKey(value2,locale2,(String)null),LiteralCommons.createCacheKey(literal2));
+        Assert.assertEquals(LiteralCommons.createCacheKey(value2,locale2,(URI)null),LiteralCommons.createCacheKey(literal2));
+
+        // create a string literal with datatype and without language and test if the hash key is correct between
+        // the different methods
+        String value3 = RandomStringUtils.randomNumeric(3);
+        String datatype3 = Namespaces.NS_XSD + "integer";
+        Literal literal3 = vf.createLiteral(value3, vf.createURI(datatype3));
+
+        Assert.assertEquals(LiteralCommons.createCacheKey(value3,null,datatype3),LiteralCommons.createCacheKey(literal3));
+
+
+        // create a Date literal and test whether the hash key is correct between the different methods
+        Date value4 = new Date();
+        String datatype4 = LiteralCommons.getXSDType(value4.getClass());
+        Literal literal4 = vf.createLiteral(DateUtils.getXMLCalendar(value4));
+
+        Assert.assertEquals(datatype4,literal4.getDatatype().stringValue());
+        Assert.assertEquals(LiteralCommons.createCacheKey(value4,datatype4), LiteralCommons.createCacheKey(literal4));
+
+        repository.shutDown();
+    }
+
+
+    /**
+     * Test if the getXSDType() method returns the correct datatype for various Java types
+     */
+    @Test
+    public void testGetXSDType() {
+
+        // String
+        Assert.assertEquals(Namespaces.NS_XSD + "string" , LiteralCommons.getXSDType(String.class));
+
+        // int and Integer
+        Assert.assertEquals(Namespaces.NS_XSD + "integer", LiteralCommons.getXSDType(int.class));
+        Assert.assertEquals(Namespaces.NS_XSD + "integer", LiteralCommons.getXSDType(Integer.class));
+
+
+        // long and Long
+        Assert.assertEquals(Namespaces.NS_XSD + "long", LiteralCommons.getXSDType(long.class));
+        Assert.assertEquals(Namespaces.NS_XSD + "long", LiteralCommons.getXSDType(Long.class));
+
+        // double and Double
+        Assert.assertEquals(Namespaces.NS_XSD + "double", LiteralCommons.getXSDType(double.class));
+        Assert.assertEquals(Namespaces.NS_XSD + "double", LiteralCommons.getXSDType(Double.class));
+
+        // float and Float
+        Assert.assertEquals(Namespaces.NS_XSD + "float", LiteralCommons.getXSDType(float.class));
+        Assert.assertEquals(Namespaces.NS_XSD + "float", LiteralCommons.getXSDType(Float.class));
+
+
+        // boolean and Boolean
+        Assert.assertEquals(Namespaces.NS_XSD + "boolean", LiteralCommons.getXSDType(boolean.class));
+        Assert.assertEquals(Namespaces.NS_XSD + "boolean", LiteralCommons.getXSDType(Boolean.class));
+
+
+        // Date
+        Assert.assertEquals(Namespaces.NS_XSD + "dateTime", LiteralCommons.getXSDType(Date.class));
+
+    }
+    
+    public void testGetRDFLangStringType() throws Exception {
+    	Assert.assertEquals(Namespaces.NS_RDF+ "langString", LiteralCommons.getRDFLangStringType());
+	}
+}