You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by rw...@apache.org on 2011/01/14 12:39:27 UTC

svn commit: r1058959 [2/4] - in /incubator/stanbol/trunk/rick: ./ generic/core/ generic/core/src/main/java/eu/iksproject/rick/core/model/ generic/core/src/main/java/eu/iksproject/rick/core/site/ generic/core/src/main/java/eu/iksproject/rick/core/utils/...

Modified: incubator/stanbol/trunk/rick/generic/servicesapi/src/main/java/eu/iksproject/rick/servicesapi/model/Text.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rick/generic/servicesapi/src/main/java/eu/iksproject/rick/servicesapi/model/Text.java?rev=1058959&r1=1058958&r2=1058959&view=diff
==============================================================================
--- incubator/stanbol/trunk/rick/generic/servicesapi/src/main/java/eu/iksproject/rick/servicesapi/model/Text.java (original)
+++ incubator/stanbol/trunk/rick/generic/servicesapi/src/main/java/eu/iksproject/rick/servicesapi/model/Text.java Fri Jan 14 11:39:26 2011
@@ -1,24 +1,33 @@
 package eu.iksproject.rick.servicesapi.model;
 
 /**
- * Defines a natural language text in a given language.
+ * Defines a natural language text in a given language.<p>
+ * The text MUST NOT be <code>null</code> nor an empty {@link String}. The
+ * language may be <code>null</code> (indicating the default language) or any
+ * kind of value. It is recommended to use ISO 639-1 codes (two Letter codes).
+ * By definition it is also allowed to use empty strings as language. However
+ * implementations of this interface are free to convert the empty language to
+ * <code>null</code>.<p>
+ * Implementations of that interface MUST BE immutable
+ * 
  * @author Rupert Westenthaler
  */
 public interface Text {
     /**
-     * Getter for the text (not <code>null</code>)
+     * Getter for the text (not <code>null</code> nor empty)
      * @return the text
      */
     String getText();
     /**
-     * Getter for the language. <code>null</code> indicates, that the text
-     * is not specific to a language (e.g. the name of a person)
+     * Getter for the language. <code>null</code> or an empty string indicate, 
+     * that the text is not specific to a language (e.g. the name of a person).
+     * Note that implementation can change empty values to <code>null</code> but.
      * @return the language
      */
     String getLanguage();
     /**
      * The text without language information - this is the same as returned
-     * by {@link #getText()}
+     * by {@link #getText()}.
      * @return the text
      */
     String toString();

Modified: incubator/stanbol/trunk/rick/generic/servicesapi/src/main/java/eu/iksproject/rick/servicesapi/model/UnsupportedTypeException.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rick/generic/servicesapi/src/main/java/eu/iksproject/rick/servicesapi/model/UnsupportedTypeException.java?rev=1058959&r1=1058958&r2=1058959&view=diff
==============================================================================
--- incubator/stanbol/trunk/rick/generic/servicesapi/src/main/java/eu/iksproject/rick/servicesapi/model/UnsupportedTypeException.java (original)
+++ incubator/stanbol/trunk/rick/generic/servicesapi/src/main/java/eu/iksproject/rick/servicesapi/model/UnsupportedTypeException.java Fri Jan 14 11:39:26 2011
@@ -1,23 +1,28 @@
 package eu.iksproject.rick.servicesapi.model;
 
 /**
- * Indicates, that the type of a source value is not compatible with the requested
- * DataType of the requested target value.
+ * Indicates, that the requested type is not supported. <p>
+ * The definition of the model requires some types to be supported.
+ * Implementation may support additional types. Components that use a specific
+ * implementation may therefore use types that are not required to be supported.
+ * However such components should also be able to deal with this kind of
+ * exceptions.
+ * 
  * @author Rupert Westenthaler
  *
  */
-public class UnsupportedTypeException extends RuntimeException {
+public class UnsupportedTypeException extends IllegalArgumentException {
 
     /**
      * uses the default serialVersionUID
      */
     private static final long serialVersionUID = 1L;
 
-    protected UnsupportedTypeException(Class<?> type,String dataType) {
+    public UnsupportedTypeException(Class<?> type,String dataType) {
         this(type,dataType,null);
     }
 
-    protected UnsupportedTypeException(Class<?> type,String dataType, Throwable cause) {
+    public UnsupportedTypeException(Class<?> type,String dataType, Throwable cause) {
         super(String.format("Values of Type \"%s\" are not supported for data type \"%s\"",
                 type,dataType),cause);
     }

Modified: incubator/stanbol/trunk/rick/generic/servicesapi/src/main/java/eu/iksproject/rick/servicesapi/model/ValueFactory.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rick/generic/servicesapi/src/main/java/eu/iksproject/rick/servicesapi/model/ValueFactory.java?rev=1058959&r1=1058958&r2=1058959&view=diff
==============================================================================
--- incubator/stanbol/trunk/rick/generic/servicesapi/src/main/java/eu/iksproject/rick/servicesapi/model/ValueFactory.java (original)
+++ incubator/stanbol/trunk/rick/generic/servicesapi/src/main/java/eu/iksproject/rick/servicesapi/model/ValueFactory.java Fri Jan 14 11:39:26 2011
@@ -1,5 +1,8 @@
 package eu.iksproject.rick.servicesapi.model;
 
+import java.net.URI;
+import java.net.URL;
+
 import eu.iksproject.rick.servicesapi.model.Sign.SignTypeEnum;
 
 /**
@@ -17,33 +20,50 @@ public interface ValueFactory {
      * @return the Text instance for the parsed object
      * @throws UnsupportedTypeException if the type of the parsed object is not
      * can not be used to create Text instances
+     * @throws IllegalArgumentException If the parsed instance type is supported, but
+     * the parsed instance can not be used to create a text instance
+     * @throws NullPointerException If <code>null</code> is parsed
      */
-    Text createText(Object value) throws UnsupportedTypeException;
+    Text createText(Object value) throws UnsupportedTypeException, IllegalArgumentException,NullPointerException;
     /**
      * Creates a Text instance for a language
      * @param text the text
      * @param language the language or <code>null</code>.
      * @return the Text instance
+     * @throws IllegalArgumentException if the parsed parameter can not be used to create a Text instance
+     * @throws NullPointerException if <code>null</code> is parsed as text.
      */
-    Text createText(String text,String language);
+    Text createText(String text,String language) throws IllegalArgumentException, NullPointerException;
     /**
      * Creates a reference instance for the parsed value. Implementations might
      * support special support for specific classes. As an default the
      * {@link Object#toString()} method is used to get the unicode representation
-     * of the reference.
+     * of the reference.<p>
+     * Implementation MUST support at least the following types:<ul>
+     * <li> {@link String}: The parsed string need not be be checked for a valid
+     *      IRI, URI or URL in any form. However in case of an empty String a 
+     *      {@link IllegalArgumentException} MUST BE thrown)
+     * <li> {@link URI}: Any valid URI MUST BE accepted
+     * <li> {@link URL}: any valid URL MUST BE accepted
+     * </ul>
      * @param value the unicode representation of the reference
      * @return the reference instance
      * @throws UnsupportedTypeException if the type of the parsed object can
      * not be converted to a Reference.
+     * @throws IllegalArgumentException if the parsed value can not be used to
+     * create a valid Reference (e.g. when parsing an empty String)
+     * @throws NullPointerException if the parsed value is <code>null</code>
      */
-    Reference createReference(Object value) throws UnsupportedTypeException;
+    Reference createReference(Object value) throws UnsupportedTypeException, IllegalArgumentException, NullPointerException;
     /**
      * Creates an empty representation instance of with the type {@link SignTypeEnum#Sign}
-     * for the parsed ID
+     * for the parsed ID. The id MUST not be <code>null</code> nor empty
      * @param id The id of the representation
      * @return the representation
+     * @throws NullPointerException If <code>null</code> is parsed as ID
+     * @throws IllegalArgumentException if an empty string is parsed as ID
      */
-    Representation createRepresentation(String id);
+    Representation createRepresentation(String id) throws NullPointerException, IllegalArgumentException;
 //    /**
 //     * Creates a value of the parsed data type for the parsed object
 //     * @param dataTypeUri the data type of the created object

Modified: incubator/stanbol/trunk/rick/generic/test/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rick/generic/test/pom.xml?rev=1058959&r1=1058958&r2=1058959&view=diff
==============================================================================
--- incubator/stanbol/trunk/rick/generic/test/pom.xml (original)
+++ incubator/stanbol/trunk/rick/generic/test/pom.xml Fri Jan 14 11:39:26 2011
@@ -30,6 +30,7 @@
 	  <dependency>
 	      <groupId>junit</groupId>
 	      <artifactId>junit</artifactId>
+	      <scope>provided</scope>
 	  </dependency>
       <dependency>
           <groupId>eu.iksproject</groupId>

Added: incubator/stanbol/trunk/rick/generic/test/src/main/java/eu/iksproject/rick/test/model/RepresentationTest.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rick/generic/test/src/main/java/eu/iksproject/rick/test/model/RepresentationTest.java?rev=1058959&view=auto
==============================================================================
--- incubator/stanbol/trunk/rick/generic/test/src/main/java/eu/iksproject/rick/test/model/RepresentationTest.java (added)
+++ incubator/stanbol/trunk/rick/generic/test/src/main/java/eu/iksproject/rick/test/model/RepresentationTest.java Fri Jan 14 11:39:26 2011
@@ -0,0 +1,1032 @@
+package eu.iksproject.rick.test.model;
+
+import static junit.framework.Assert.*;
+
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.Vector;
+
+import org.junit.Test;
+
+import eu.iksproject.rick.servicesapi.model.Reference;
+import eu.iksproject.rick.servicesapi.model.Representation;
+import eu.iksproject.rick.servicesapi.model.Text;
+import eu.iksproject.rick.servicesapi.model.UnsupportedTypeException;
+import eu.iksproject.rick.servicesapi.model.ValueFactory;
+
+public abstract class RepresentationTest {
+    /**
+     * Subclasses must implement this method and provide a {@link ValueFactory}
+     * instance that is used to test the actual model implementation
+     * @return the {@link ValueFactory} for the RICK model implementation to be
+     * tested
+     */
+    protected abstract ValueFactory getValueFactory();
+    /**
+     * Getter for an instance of an unsupported type. For add/set operation such
+     * values are converted to the lexical form by using the
+     * {@link Object#toString()} method. For {@link Representation#get(String, Class)}
+     * and {@link Representation#getFirst(String, Class)} an 
+     * {@link UnsupportedTypeException} need to be thrown when requesting values
+     * of the {@link Object#getClass()} of the returned instance.
+     * @return An instance of a class that is not supported by the 
+     * tested {@link Representation} implementation or <code>null</code> if the
+     * tested implementation does support any type (this will deactivate such
+     * kind of tests).
+     */
+    protected abstract Object getUnsupportedValueInstance();
+    
+    /*--------------------------------------------------------------------------
+     * Set of Tests that check if all Methods correctly throw a NullPointerException
+     * when parsing null as field!
+     *  - important to prevent NULL fields within the RICK
+     *--------------------------------------------------------------------------
+     */
+    @Test(expected=NullPointerException.class)
+    public void testNullFieldAdd(){
+        Representation rep = createRepresentation(null);
+        rep.add(null, "test");
+    }
+    @Test(expected=NullPointerException.class)
+    public void testNullFieldAddNaturalText(){
+        Representation rep = createRepresentation(null);
+        rep.addNaturalText(null, "test");
+    }
+    @Test(expected=NullPointerException.class)
+    public void testNullFieldAddReference(){
+        Representation rep = createRepresentation(null);
+        rep.addReference(null, "urn:test");
+    }
+    @Test(expected=NullPointerException.class)
+    public void testNullFieldGet(){
+        Representation rep = createRepresentation(null);
+        rep.get(null);
+    }
+    @Test(expected=NullPointerException.class)
+    public void testNullFieldGetDataType(){
+        Representation rep = createRepresentation(null);
+        rep.get(null, Integer.class);
+    }
+    @Test(expected=NullPointerException.class)
+    public void testNullFieldGetNaturalLanguateText(){
+        Representation rep = createRepresentation(null);
+        rep.get(null,"en");
+    }
+    @Test(expected=NullPointerException.class)
+    public void testNullFieldGetFirst(){
+        Representation rep = createRepresentation(null);
+        rep.getFirst(null);
+    }
+    @Test(expected=NullPointerException.class)
+    public void testNullFieldGetFirstReference(){
+        Representation rep = createRepresentation(null);
+        rep.getFirstReference(null);
+    }
+    @Test(expected=NullPointerException.class)
+    public void testNullFieldGetFirstDataType(){
+        Representation rep = createRepresentation(null);
+        rep.getFirst(null, Integer.class);
+    }
+    @Test(expected=NullPointerException.class)
+    public void testNullFieldGetFirstNaturalLanguage(){
+        Representation rep = createRepresentation(null);
+        rep.getFirst(null, "en");
+    }
+    @Test(expected=NullPointerException.class)
+    public void testNullFieldGetReferences(){
+        Representation rep = createRepresentation(null);
+        rep.getReferences(null);
+    }
+    @Test(expected=NullPointerException.class)
+    public void testNullFieldGetText(){
+        Representation rep = createRepresentation(null);
+        rep.getText(null);
+    }
+    @Test(expected=NullPointerException.class)
+    public void testNullFieldRemove(){
+        Representation rep = createRepresentation(null);
+        rep.remove(null, "test");
+    }
+    @Test(expected=NullPointerException.class)
+    public void testNullFieldRemoveAll(){
+        Representation rep = createRepresentation(null);
+        rep.removeAll(null);
+    }
+    @Test(expected=NullPointerException.class)
+    public void testNullFieldRemoveAllNaturalText(){
+        Representation rep = createRepresentation(null);
+        rep.removeAllNaturalText(null, "de");
+    }
+    @Test(expected=NullPointerException.class)
+    public void testNullFieldRemoveNaturalText(){
+        Representation rep = createRepresentation(null);
+        rep.removeNaturalText(null, "test");
+    }
+    @Test(expected=NullPointerException.class)
+    public void testNullFieldRemoveReference(){
+        Representation rep = createRepresentation(null);
+        rep.removeReference(null, "urn:test");
+    }
+    @Test(expected=NullPointerException.class)
+    public void testNullFieldSet(){
+        Representation rep = createRepresentation(null);
+        rep.set(null, "test");
+    }
+    @Test(expected=NullPointerException.class)
+    public void testNullFieldSetNaturalText(){
+        Representation rep = createRepresentation(null);
+        rep.setNaturalText(null, "test");
+    }
+    @Test(expected=NullPointerException.class)
+    public void testNullFieldSetReference(){
+        Representation rep = createRepresentation(null);
+        rep.setReference(null, "urn:test");
+    }
+    /*--------------------------------------------------------------------------
+     * Set of Tests that check if all Methods correctly throw a IllegalArgumentExceptions
+     * when parsing an empty string as field
+     *  - important to prevent "" fields within the RICK
+     *--------------------------------------------------------------------------
+     */
+    @Test(expected=IllegalArgumentException.class)
+    public void testEmptyFieldAdd(){
+        Representation rep = createRepresentation(null);
+        rep.add("", "test");
+    }
+    @Test(expected=IllegalArgumentException.class)
+    public void testEmptyFieldAddNaturalText(){
+        Representation rep = createRepresentation(null);
+        rep.addNaturalText("", "test");
+    }
+    @Test(expected=IllegalArgumentException.class)
+    public void testEmptyFieldAddReference(){
+        Representation rep = createRepresentation(null);
+        rep.addReference("", "urn:test");
+    }
+    @Test(expected=IllegalArgumentException.class)
+    public void testEmptyFieldGet(){
+        Representation rep = createRepresentation(null);
+        rep.get("");
+    }
+    @Test(expected=IllegalArgumentException.class)
+    public void testEmptyFieldGetDataType(){
+        Representation rep = createRepresentation(null);
+        rep.get("", Integer.class);
+    }
+    @Test(expected=IllegalArgumentException.class)
+    public void testEmptyFieldGetNaturalLanguateText(){
+        Representation rep = createRepresentation(null);
+        rep.get("","en");
+    }
+    @Test(expected=IllegalArgumentException.class)
+    public void testEmptyFieldGetFirst(){
+        Representation rep = createRepresentation(null);
+        rep.getFirst("");
+    }
+    @Test(expected=IllegalArgumentException.class)
+    public void testEmptyFieldGetFirstReference(){
+        Representation rep = createRepresentation(null);
+        rep.getFirstReference("");
+    }
+    @Test(expected=IllegalArgumentException.class)
+    public void testEmptyFieldGetFirstDataType(){
+        Representation rep = createRepresentation(null);
+        rep.getFirst("", Integer.class);
+    }
+    @Test(expected=IllegalArgumentException.class)
+    public void testEmptyFieldGetFirstNaturalLanguage(){
+        Representation rep = createRepresentation(null);
+        rep.getFirst("", "en");
+    }
+    @Test(expected=IllegalArgumentException.class)
+    public void testEmptyFieldGetReferences(){
+        Representation rep = createRepresentation(null);
+        rep.getReferences("");
+    }
+    @Test(expected=IllegalArgumentException.class)
+    public void testEmptyFieldGetText(){
+        Representation rep = createRepresentation(null);
+        rep.getText("");
+    }
+    @Test(expected=IllegalArgumentException.class)
+    public void testEmptyFieldRemove(){
+        Representation rep = createRepresentation(null);
+        rep.remove("", "test");
+    }
+    @Test(expected=IllegalArgumentException.class)
+    public void testEmptyFieldRemoveAll(){
+        Representation rep = createRepresentation(null);
+        rep.removeAll("");
+    }
+    @Test(expected=IllegalArgumentException.class)
+    public void testEmptyFieldRemoveAllNaturalText(){
+        Representation rep = createRepresentation(null);
+        rep.removeAllNaturalText("", "de");
+    }
+    @Test(expected=IllegalArgumentException.class)
+    public void testEmptyFieldRemoveNaturalText(){
+        Representation rep = createRepresentation(null);
+        rep.removeNaturalText("", "test");
+    }
+    @Test(expected=IllegalArgumentException.class)
+    public void testEmptyFieldRemoveReference(){
+        Representation rep = createRepresentation(null);
+        rep.removeReference("", "urn:test");
+    }
+    @Test(expected=IllegalArgumentException.class)
+    public void testEmptyFieldSet(){
+        Representation rep = createRepresentation(null);
+        rep.set("", "test");
+    }
+    @Test(expected=IllegalArgumentException.class)
+    public void testEmptyFieldSetNaturalText(){
+        Representation rep = createRepresentation(null);
+        rep.setNaturalText("", "test");
+    }
+    @Test(expected=IllegalArgumentException.class)
+    public void testEmptyFieldSetReference(){
+        Representation rep = createRepresentation(null);
+        rep.setReference("", "urn:test");
+    }
+    /**
+     * Tests if value iterators for non existing fields return an Iterator
+     * with no elements (Here it is important, that in such cases methods do
+     * not return <code>null</code>).
+     */
+    @Test
+    public void testNonExistingFields(){
+        String field = "urn:this.field:does.not:exist";
+        //Iterators MUST NOT be NULL but MUST NOT contain any element
+        Representation rep = createRepresentation(null);
+        Iterator<String> fieldIt = rep.getFieldNames();
+        assertNotNull(fieldIt);
+        assertFalse(fieldIt.hasNext());
+        Iterator<Object> valueIt = rep.get(field);
+        assertNotNull(valueIt);
+        assertFalse(valueIt.hasNext());
+        Iterator<Reference> refIt = rep.getReferences(field);
+        assertNotNull(refIt);
+        assertFalse(refIt.hasNext());
+        Iterator<Text> textIt = rep.get(field,(String[])null);
+        assertNotNull(textIt);
+        assertFalse(textIt.hasNext());
+    }    
+    /*--------------------------------------------------------------------------
+     * Set of Tests that check if all add methods correctly throw an 
+     * IllegalArgumentExceptions when parsing NULL as value
+     *  - important to prevent NULL values within RICK
+     *--------------------------------------------------------------------------
+     */    
+    @Test(expected=IllegalArgumentException.class)
+    public void testAddNullReference(){
+        String field = "urn:the.field:used.for.this.Test";
+        Representation rep = createRepresentation(null);
+        rep.addReference(field, null);
+    }
+    @Test(expected=IllegalArgumentException.class)
+    public void testAddNullText(){
+        String field = "urn:the.field:used.for.this.Test";
+        Representation rep = createRepresentation(null);
+        rep.addNaturalText(field, null);
+    }
+    @Test(expected=IllegalArgumentException.class)
+    public void testAddNullObject(){
+        String field = "urn:the.field:used.for.this.Test";
+        Representation rep = createRepresentation(null);
+        rep.add(field, null);
+    }
+    /*--------------------------------------------------------------------------
+     * Set of Tests that check if Methods correctly process UnsupportedTypes
+     * This means that the toString Method is used to get the lexical
+     * representation of such types
+     *--------------------------------------------------------------------------
+     */ 
+    /**
+     * Adding an unsupported type should use the {@link Object#toString()}
+     * to store the parsed instance
+     */
+    @Test
+    public void testAddUnsupportedType(){
+        String field = "urn:the.field:used.for.this.Test";
+        Representation rep = createRepresentation(null);
+        Object value = getUnsupportedValueInstance();
+        if(value == null){ //any type is supported by the representation
+            return; //this test is not needed
+        }
+        rep.add(field, value);
+        Iterator<Object> valueIterator = rep.get(field);
+        assertNotNull(valueIterator);
+        assertTrue(valueIterator.hasNext());
+        Object repValue = valueIterator.next();
+        assertEquals(value.toString(), repValue.toString());
+    }
+    @Test
+    public void testSetUnsupportedType(){
+        String field = "urn:the.field:used.for.this.Test";
+        Representation rep = createRepresentation(null);
+        Object value = getUnsupportedValueInstance();
+        if(value == null){ //any type is supported by the representation
+            return; //this test is not needed
+        }
+        rep.set(field, value); //this does not test that set removes previous values
+        Iterator<Object> valueIterator = rep.get(field);
+        assertNotNull(valueIterator);
+        assertTrue(valueIterator.hasNext());
+        Object repValue = valueIterator.next();
+        assertEquals(value.toString(), repValue.toString());
+    }
+    @Test(expected=UnsupportedTypeException.class)
+    public void testGetValueWithUnsupportedType(){
+        String field = "urn:the.field:used.for.this.Test";
+        Representation rep = createRepresentation(null);
+        Object value = getUnsupportedValueInstance();
+        if(value == null){ //any type is supported by the representation
+           //this test is not needed therefore return an dummy Exception
+            throw new UnsupportedTypeException(Object.class,
+                "dummy exception to successfully complete this unnecessary test");
+        } else {
+            Class<?> unsupported = value.getClass();
+            rep.get(field, unsupported);
+        }
+    }
+    @Test(expected=UnsupportedTypeException.class)
+    public void testGetFirstValueWithUnsupportedType(){
+        String field = "urn:the.field:used.for.this.Test";
+        Representation rep = createRepresentation(null);
+        Object value = getUnsupportedValueInstance();
+        if(value == null){ //any type is supported by the representation
+           //this test is not needed therefore return an dummy Exception
+            throw new UnsupportedTypeException(Object.class,
+                "dummy exception to successfully complete this unnecessary test");
+        } else {
+            Class<?> unsupported = value.getClass();
+            rep.getFirst(field, unsupported);
+        }
+    }
+
+    /**
+     * If <code>null</code> is parsed as value for any setter method, than all 
+     * values need to be removed for the field. this means that
+     * <code>set**(field,null)</code> has the same effect as
+     * <code>{@link Representation#removeAll(String) removeAll(field)} </code> 
+     */
+    @Test
+    public void testSetToNullAsRemoveAll(){
+        String field = "urn:the.field:used.for.this.Test";
+        String testReference = "http://www.test.org/test";
+        String testText = "This is a Test";
+        Integer testValue = 42;
+        Representation rep = createRepresentation(null);
+        rep.add(field, testValue);
+        rep.addNaturalText(field, testText, "en");
+        rep.addReference(field, testReference);
+        rep.set(field, null); //need to remove all values
+        Iterator<Object> values = rep.get(field);
+        assertNotNull(values);
+        assertFalse(values.hasNext());
+        //test specific setter (also specific setters need to remove all values)
+        rep.add(field, testValue);
+        rep.addNaturalText(field, testText, "en");
+        rep.addReference(field, testReference);
+        rep.setNaturalText(field, null);
+        assertNotNull(values);
+        assertFalse(values.hasNext());
+
+        rep.add(field, testValue);
+        rep.addNaturalText(field, testText, "en");
+        rep.addReference(field, testReference);
+        rep.setReference(field, null);
+        assertNotNull(values);
+        assertFalse(values.hasNext());
+    }
+    
+    @Test
+    public void testFieldRemoval() throws URISyntaxException{
+        String field = "urn:the.field:used.for.this.Test";
+        ValueFactory vf = getValueFactory();
+        Representation rep = createRepresentation(null);
+        //Test removal for References
+        String strRef = "urn:testValue";
+        rep.addReference(field, strRef);
+        assertTrue(asCollection(rep.getFieldNames()).contains(field));
+        rep.removeReference(field, strRef);
+        assertFalse(asCollection(rep.getFieldNames()).contains(field));
+        
+        Reference ref = vf.createReference("urn:testValue2");
+        rep.add(field, ref);
+        assertTrue(asCollection(rep.getFieldNames()).contains(field));
+        rep.remove(field, ref);
+        assertFalse(asCollection(rep.getFieldNames()).contains(field));
+
+        //test removal for texts (with and without language)
+        String strText = "test text";
+        String strTextLang = "en";
+        rep.addNaturalText(field, strText, strTextLang);
+        assertTrue(asCollection(rep.getFieldNames()).contains(field));
+        rep.removeNaturalText(field, strText, strTextLang);
+        assertFalse(asCollection(rep.getFieldNames()).contains(field));
+
+        String strTextNoLang = "test text without lang";
+        rep.addNaturalText(field, strTextNoLang);
+        assertTrue(asCollection(rep.getFieldNames()).contains(field));
+        rep.removeNaturalText(field, strTextNoLang);
+        assertFalse(asCollection(rep.getFieldNames()).contains(field));
+        
+        //there is also the possibility to explicitly parse null as language
+        //could internally case differences however externally this is the same
+        rep.addNaturalText(field, strTextNoLang,(String)null);
+        assertTrue(asCollection(rep.getFieldNames()).contains(field));
+        rep.removeNaturalText(field, strTextNoLang,(String)null);
+        assertFalse(asCollection(rep.getFieldNames()).contains(field));
+        
+        Text text = vf.createText("Das ist ein Text zum testen des Text Objektes","de");
+        rep.add(field, text);
+        assertTrue(asCollection(rep.getFieldNames()).contains(field));
+        rep.remove(field, text);
+        assertFalse(asCollection(rep.getFieldNames()).contains(field));
+        
+        //Test a dataTypes values
+        Integer intValue = 42;
+        rep.add(field, intValue);
+        assertTrue(asCollection(rep.getFieldNames()).contains(field));
+        rep.remove(field, intValue);
+        assertFalse(asCollection(rep.getFieldNames()).contains(field));
+        
+        //Some Values are converted by the add(String field,Object value) Method
+        //to other data types. This MUST also be assured for removal
+        // NOTE: testing the conversions is done in other test methods!
+        URI testURI = new URI("http://www.test.org/test");
+        rep.add(field, testURI);
+        assertTrue(asCollection(rep.getFieldNames()).contains(field));
+        rep.remove(field, testURI);
+        assertFalse(asCollection(rep.getFieldNames()).contains(field));
+    }
+    /**
+     * Tests if {@link Reference} instances are correctly generated for {@link URI}.
+     * This test also depends on the correct implementation of the
+     * {@link Reference#equals(Object)} method
+     * @throws URISyntaxException
+     */
+    @Test
+    public void testURIToReferenceConversion() throws URISyntaxException{
+        String field = "urn:the.field:used.for.this.Test";
+        URI uri = new URI("http://www.test.org/uriTest");
+        ValueFactory vf = getValueFactory();
+        Representation rep = createRepresentation(null);
+        //test conversion
+        rep.add(field, uri);
+        Iterator<Reference> refs = rep.getReferences(field);
+        assertTrue(refs.hasNext());
+        assertEquals(refs.next().getReference(),uri.toString());
+        assertFalse(refs.hasNext());
+        //test multiple adds do not generate duplicate References
+        rep.add(field, uri);
+        assertTrue(asCollection(rep.get(field)).size() == 1);
+        //test adding a equivalent reference
+        rep.add(field, vf.createReference(uri.toString()));
+        assertTrue(asCollection(rep.get(field)).size() == 1);
+        //test removing
+        rep.remove(field, uri);
+        assertFalse(rep.get(field).hasNext());
+    }
+    /**
+     * Tests if {@link Reference} instances are correctly generated for {@link URL}.
+     * This test also depends on the correct implementation of the
+     * {@link Reference#equals(Object)} method
+     * @throws MalformedURLException
+     */
+    @Test
+    public void testURLToReferenceConversion() throws MalformedURLException{
+        String field = "urn:the.field:used.for.this.Test";
+        URL url = new URL("http://www.test.org/urlTest");
+        ValueFactory vf = getValueFactory();
+        Representation rep = createRepresentation(null);
+        //test conversion
+        rep.add(field, url);
+        Iterator<Reference> refs = rep.getReferences(field);
+        assertTrue(refs.hasNext());
+        assertEquals(refs.next().getReference(),url.toString());
+        assertFalse(refs.hasNext());
+        //test multiple adds do not generate duplicate References
+        rep.add(field, url);
+        assertTrue(asCollection(rep.get(field)).size() == 1);
+        //test adding a equivalent reference
+        rep.add(field, vf.createReference(url.toString()));
+        assertTrue(asCollection(rep.get(field)).size() == 1);
+        //test removing
+        rep.remove(field, url);
+        assertFalse(rep.get(field).hasNext());
+        
+    }
+    /**
+     * Parsing a String Array with null as first element MUST NOT add a value
+     * (because null values are not supported by {@link Representation}).
+     */
+    @Test
+    public void testStringArrayWithNullTextConversion(){
+        String field = "urn:the.field:used.for.this.Test";
+        Representation rep = createRepresentation(null);
+        rep.add(field, new String[]{null,"en"});
+        assertFalse(rep.get(field).hasNext());
+    }
+    /**
+     * Checks if {@link Text} instances are correctly generated for String[].
+     * This test depends also on the correct implementation of the
+     * {@link Text#equals(Object)} method
+     */
+    @Test
+    public void testStringArrayToTextConversion(){
+        String field = "urn:the.field:used.for.this.Test";
+        ValueFactory vf = getValueFactory();
+        Representation rep = createRepresentation(null);
+        //test conversion of String[] with language as second element
+        String[] textWithLang = new String[]{"Test text with language","en"};
+        rep.add(field, textWithLang);
+        Iterator<Text> refs = rep.get(field,(String[])null);
+        assertTrue(refs.hasNext());
+        Text test = refs.next();
+        assertEquals(textWithLang[1],test.getLanguage());
+        assertEquals(textWithLang[0],test.getText());
+        assertFalse(refs.hasNext());
+        //test multiple adds do not generate duplicate References
+        rep.add(field, textWithLang);
+        assertTrue(asCollection(rep.get(field)).size() == 1);
+        //test adding a equivalent reference
+        rep.add(field, vf.createText(textWithLang[0], textWithLang[1]));
+        assertTrue(asCollection(rep.get(field)).size() == 1);
+        //test removing
+        rep.remove(field, textWithLang);
+        assertFalse(rep.get(field).hasNext());
+
+        //test conversion of String[] with only one element (default language)
+        String[] textWithoutLang = new String[]{"Test text without language"};
+        rep.add(field, textWithoutLang);
+        refs = rep.get(field,(String[])null);
+        assertTrue(refs.hasNext());
+        test = refs.next();
+        assertNull(test.getLanguage());
+        assertEquals(textWithoutLang[0],test.getText());
+        assertFalse(refs.hasNext());
+        //test multiple adds do not generate duplicate References
+        rep.add(field, textWithoutLang);
+        assertTrue(asCollection(rep.get(field)).size() == 1);
+        //test adding a equivalent reference
+        rep.add(field, vf.createText(textWithoutLang[0]));
+        assertTrue(asCollection(rep.get(field)).size() == 1);
+        //test removing
+        rep.remove(field, textWithoutLang);
+        assertFalse(rep.get(field).hasNext());
+
+        //test conversion of String[] with null as second element (default language)
+        String[] textWithDefaultLang = new String[]{"Test text with default language",null};
+        rep.add(field, textWithDefaultLang);
+        refs = rep.get(field,(String[])null);
+        assertTrue(refs.hasNext());
+        test = refs.next();
+        assertNull(test.getLanguage());
+        assertEquals(textWithDefaultLang[0],test.getText());
+        assertFalse(refs.hasNext());
+        //test multiple adds do not generate duplicate References
+        rep.add(field, textWithDefaultLang);
+        assertTrue(asCollection(rep.get(field)).size() == 1);
+        //test adding a equivalent reference
+        rep.add(field, vf.createText(textWithDefaultLang[0], null));
+        assertTrue(asCollection(rep.get(field)).size() == 1);
+        //test removing
+        rep.remove(field, textWithDefaultLang);
+        assertFalse(rep.get(field).hasNext());
+        
+        //finally test if additional Elements are correctly ignored
+        String[] ignoreAdditionalElements = new String[]{"Test if additional elements are ignored","en","ignored1","ignored2",null,"ignored4"};
+        String[] sameText = new String[]{"Test if additional elements are ignored","en"};
+        rep.add(field, ignoreAdditionalElements);
+        refs = rep.get(field,(String[])null);
+        assertTrue(refs.hasNext());
+        test = refs.next();
+        assertEquals(ignoreAdditionalElements[1],test.getLanguage());
+        assertEquals(ignoreAdditionalElements[0],test.getText());
+        assertFalse(refs.hasNext());
+        //test multiple adds do not generate duplicate References
+        rep.add(field, ignoreAdditionalElements);
+        assertTrue(asCollection(rep.get(field)).size() == 1);
+        //test if an Array with only the first two elements generate the same Text
+        rep.add(field, sameText);
+        assertTrue(asCollection(rep.get(field)).size() == 1);
+        //test removing
+        rep.remove(field, ignoreAdditionalElements);
+        assertFalse(rep.get(field).hasNext());
+    }
+    @Test
+    public void testMultipleAddAndRemove() throws MalformedURLException, URISyntaxException{
+        String field = "urn:the.field:used.for.this.Test";
+        ValueFactory vf = getValueFactory();
+        Representation rep = createRepresentation(null);
+        Reference ref = vf.createReference("http://www.test.org/test");
+        Text text = vf.createText("test", "en");
+        Integer i = 42;
+        Double d = Math.PI;
+        URI uri = new URI("http://www.test.org/uriTest");
+        URL url = new URL("http://www.test.org/urlTest");
+        String[] textAsArray = new String[]{"Test text as Array","en"};
+        Collection<Object> values = Arrays.asList(ref,text,i,d);
+        Collection<Object> convertedValues = Arrays.asList((Object)url,uri,textAsArray);
+        Collection<Object> allValues = Arrays.asList(ref,text,i,d,uri,url,textAsArray);
+        //test adding of collections
+        rep.add(field, values);
+        assertTrue(asCollection(rep.get(field)).size() == 4);
+        rep.remove(field, values);
+        assertFalse(rep.get(field).hasNext());
+        //test adding of Iterators
+        rep.add(field, values.iterator());
+        assertTrue(asCollection(rep.get(field)).size() == 4);
+        rep.remove(field, values.iterator());
+        assertFalse(rep.get(field).hasNext());
+        //test adding of Enumerations
+        Vector<Object> v = new Vector<Object>(values);
+        rep.add(field, v.elements());
+        assertTrue(asCollection(rep.get(field)).size() == 4);
+        rep.remove(field, v.elements());
+        assertFalse(rep.get(field).hasNext());
+        //test adding and removing elements that need to be converted
+        // only for collections this time -> want to test only converting is
+        // applied for both add and remove
+        rep.add(field, convertedValues);
+        assertTrue(asCollection(rep.get(field)).size() == 3);
+        rep.remove(field, convertedValues);
+        assertFalse(rep.get(field).hasNext());
+        //a final test to ensure, that remove does not only delete all values
+        rep.add(field, allValues);
+        assertTrue(asCollection(rep.get(field)).size() == 7);
+        rep.remove(field,convertedValues);
+        assertTrue(asCollection(rep.get(field)).size() == 4);
+    }
+    @Test
+    public void testReferences(){
+        String field = "urn:the.field:used.for.this.Test";
+        Set<String> refs = new HashSet<String>(Arrays.asList(
+            "http://www.test.org/test1",
+            "urn:test.org:test.1"));
+        Representation rep = createRepresentation(null);
+        for(String ref:refs){
+            rep.addReference(field, ref);
+        }
+        Iterator<Reference> refIterator = rep.getReferences(field);
+        assertNotNull(refIterator);
+        while(refIterator.hasNext()){
+            Reference ref = refIterator.next();
+            assertTrue(refs.remove(ref.getReference()));
+        }
+        assertTrue(refs.isEmpty());
+    }
+
+    private static final String NL_TEST_string = "String value that has to be treated similar as texts with no language";
+    private static final String NL_TEST_noLang = "kani ofie sfgoeyd";
+    private static final String NL_TEST_en = "This is an English text";
+    private static final String NL_TEST_en2 = "A second English text";
+    private static final String NL_TEST_de = "Das ist ein Deutscher Text";
+    private static final String NL_TEST_de_AT = "Saig kent ma bei uns a nu ois Deutsch durch geh loss'n";
+    private static final Collection<String> NL_TEST_all = Arrays.asList(NL_TEST_string,NL_TEST_noLang,NL_TEST_en,NL_TEST_en2,NL_TEST_de,NL_TEST_de_AT);
+    
+    /**
+     * Internally used to initialise the representation used for the various
+     * tests for natural language texts.
+     * Tests using this initialisation method expect the current configuration. 
+     * If one changes the values one needs also do adapt the according tests.
+     * @param field the field used to add the test values
+     * @param valueSet if not <code>null</code> the added values are added to this set
+     * @return the initialised representation
+     */
+    private Representation initNaturalLanguageTest(String field){
+        Representation rep = createRepresentation(null);
+        rep.add(field, NL_TEST_string);
+        rep.addNaturalText(field, NL_TEST_noLang);
+        rep.addNaturalText(field, NL_TEST_en, "en");
+        rep.addNaturalText(field, NL_TEST_en2, "en");
+        rep.addNaturalText(field, NL_TEST_de, "de");
+        rep.addNaturalText(field, NL_TEST_de_AT, "de-AT");
+        return rep;
+    }
+    @Test
+    public void testGetNaturalTextWithNoLanguage(){
+        String field = "urn:the.field:used.for.this.Test";
+        Representation rep = initNaturalLanguageTest(field);
+        //Note that also String values need to be converted to texts with no language
+        Set<String> textSet = new HashSet<String>(NL_TEST_all);
+        Text text;
+        Iterator<Text> noLangTexts = rep.get(field, (String)null);
+        assertNotNull(noLangTexts);
+        while(noLangTexts.hasNext()){
+            text = noLangTexts.next();
+            assertNull(text.getLanguage());
+            assertTrue(textSet.remove(text.getText()));
+        }
+        assertTrue(textSet.size() == 4); //check that both text where found
+    }
+    @Test
+    public void testGetNaturalTextWithLanguage(){
+        String field = "urn:the.field:used.for.this.Test";
+        Representation rep = initNaturalLanguageTest(field);
+        //test de texts
+        Iterator<Text> deTexts = rep.get(field, "de");
+        assertNotNull(deTexts);
+        assertTrue(deTexts.hasNext()); //there is one German text in the test set
+        Text text = deTexts.next();
+        assertEquals(text.getLanguage(), "de"); //"de" lang
+        assertEquals(text.getText(), NL_TEST_de); //the de lang text
+        assertFalse(deTexts.hasNext());//only one Result
+        //test en labels (2 results)
+        Iterator<Text> enTexts = rep.get(field, "en");
+        assertNotNull(enTexts);
+        Set<String> textSet = new HashSet<String>(Arrays.asList(NL_TEST_en,NL_TEST_en2));
+        while(enTexts.hasNext()){
+            text = enTexts.next();
+            assertEquals("en", text.getLanguage());
+            assertTrue(textSet.remove(text.getText())); //remove the found
+        }
+        assertTrue(textSet.isEmpty()); //all texts found
+    }
+    @Test
+    public void testGetNaturalTextWithMultipleLanguages(){
+        String field = "urn:the.field:used.for.this.Test";
+        Representation rep = initNaturalLanguageTest(field);
+        //test multiple language query
+        Iterator<Text> allDeTexts = rep.get(field, "de","de-AT");
+        assertNotNull(allDeTexts);
+        Set<String> textSet = new HashSet<String>(Arrays.asList(NL_TEST_de,NL_TEST_de_AT));
+        while(allDeTexts.hasNext()){
+            Text text = allDeTexts.next();
+            assertTrue(text.getLanguage().equals("de") || text.getLanguage().equals("de-AT"));
+            assertTrue(textSet.remove(text.getText())); //remove the found
+        }
+        assertTrue(textSet.isEmpty()); //all texts found
+    }
+    @Test
+    public void testGetNaturalTextWithLanguagesWithoutValues(){
+        String field = "urn:the.field:used.for.this.Test";
+        Representation rep = initNaturalLanguageTest(field);
+        //test not present language
+        Iterator<Text> esTexts = rep.get(field, "es");
+        assertNotNull(esTexts);
+        assertFalse(esTexts.hasNext());
+        //test multiple not present languages
+        Iterator<Text> frItTexts = rep.get(field, "fr","it");
+        assertNotNull(frItTexts);
+        assertFalse(frItTexts.hasNext());
+    }
+    @Test
+    public void testGetNaturalTextWithAnyLanguageByParsingAnEmptyArray(){
+        String field = "urn:the.field:used.for.this.Test";
+        Representation rep = initNaturalLanguageTest(field);
+        //test Iterator for any language (by parsing an empty list)
+        Iterator<Text> allTexts = rep.get(field, new String[]{});
+        assertNotNull(allTexts);
+        assertTrue(asCollection(allTexts).size() == NL_TEST_all.size());
+    }
+    @Test
+    public void testGetNaturalTextWithAnyLanguageByParsingNullAsArray(){
+        String field = "urn:the.field:used.for.this.Test";
+        Representation rep = initNaturalLanguageTest(field);
+        //test Iterator for any language (by parsing null)
+        Iterator<Text> allTexts = rep.get(field, (String[])null);
+        assertNotNull(allTexts);
+        assertTrue(asCollection(allTexts).size() == NL_TEST_all.size());
+    }
+    @Test
+    public void testRemoveNaturalTextWithWrongLanguage(){
+        String field = "urn:the.field:used.for.this.Test";
+        Representation rep = initNaturalLanguageTest(field);
+        //Test removal of natural language
+        //remove a specific test, but wrong language -> no effect
+        rep.removeNaturalText(field, NL_TEST_en2, "de");
+        assertTrue(asCollection(rep.get(field)).size() == NL_TEST_all.size());
+    }
+    @Test
+    public void testRemoveNaturalTextWithWrongNullLanguage(){
+        String field = "urn:the.field:used.for.this.Test";
+        Representation rep = initNaturalLanguageTest(field);
+        //remove a specific text, but with wrong null language -> also no effect
+        rep.removeNaturalText(field, NL_TEST_de, (String)null);
+        assertTrue(asCollection(rep.get(field)).size() == NL_TEST_all.size());
+    }
+    @Test
+    public void testRemoveNaturalTextWithCorrectAndWrongLanguage(){
+        String field = "urn:the.field:used.for.this.Test";
+        Representation rep = initNaturalLanguageTest(field);
+        //remove a specific text, parse one correct and one wrong lang
+        rep.removeNaturalText(field, NL_TEST_en2, "de","en");
+        Set<String> textSet = new HashSet<String>(NL_TEST_all);
+        //remove all remaining values
+        for(Iterator<Text> texts = rep.getText(field);texts.hasNext();textSet.remove(texts.next().getText()));
+        //and check that the value we expect to be removed is still in the set
+        assertTrue(textSet.size() == 1);
+        System.out.println("TextSet: "+textSet);
+        assertTrue(textSet.contains(NL_TEST_en2));
+    }
+    /**
+     * String values are treated the same as natural language values with the
+     * default (<code>null</code>) language. <br>
+     * Removing a natural language value with parsing null as language MUST 
+     * therefore also remove a string value with the parse same text.
+     */
+    @Test
+    public void testRemoveStringValuesByRemovingNaturalLanguageTextsWithNullLanguage(){
+        String field = "urn:the.field:used.for.this.Test";
+        Representation rep = initNaturalLanguageTest(field);
+        Set<String> textSet = new HashSet<String>(NL_TEST_all);
+
+        //remove a string value by parsing the text and null as language
+        rep.removeNaturalText(field, NL_TEST_string, (String)null);
+        for(Iterator<Text> texts = rep.getText(field);texts.hasNext();textSet.remove(texts.next().getText()));
+        assertTrue(textSet.size() == 1); //only one element should be removed
+        assertTrue(textSet.remove(NL_TEST_string)); //and this should be the stringTest
+    }
+    /**
+     * String values are treated the same as natural language values with the
+     * default (<code>null</code>) language. <br>
+     * Removing a natural language value with no defined language MUST 
+     * therefore also remove a string value with the parse same text.
+     */
+    @Test
+    public void testRemoveStringValuesByRemovingNaturalLanguageTextsWithNoLanguage(){
+        String field = "urn:the.field:used.for.this.Test";
+        Representation rep = initNaturalLanguageTest(field);
+        Set<String> textSet = new HashSet<String>(NL_TEST_all);
+        //remove a string value by parsing only the text
+        rep.removeNaturalText(field, NL_TEST_string);
+        textSet.addAll(Arrays.asList(NL_TEST_string,NL_TEST_noLang,NL_TEST_en,NL_TEST_en2,NL_TEST_de,NL_TEST_de_AT));
+        for(Iterator<Text> texts = rep.getText(field);texts.hasNext();textSet.remove(texts.next().getText()));
+        assertTrue(textSet.size() == 1); //only one element should be removed
+        assertTrue(textSet.remove(NL_TEST_string)); //and this should be the stringTest
+    }
+    /**
+     * String values are treated the same as natural language values with the
+     * default (<code>null</code>) language. <br>
+     * Removing a natural language value with an empty language array MUST be
+     * interpreted as default language and therefore remove the String value.
+     */
+    @Test
+    public void testRemoveStringValuesByRemovingNaturalLanguageTextsWithEmptyLanguageArray(){
+        String field = "urn:the.field:used.for.this.Test";
+        Representation rep = initNaturalLanguageTest(field);
+        Set<String> textSet = new HashSet<String>(NL_TEST_all);
+        //remove a string value by parsing an empty list of languages
+        rep.removeNaturalText(field, NL_TEST_string, new String[]{});
+        textSet.addAll(Arrays.asList(NL_TEST_string,NL_TEST_noLang,NL_TEST_en,NL_TEST_en2,NL_TEST_de,NL_TEST_de_AT));
+        for(Iterator<Text> texts = rep.getText(field);texts.hasNext();textSet.remove(texts.next().getText()));
+        assertTrue(textSet.size() == 1); //only one element should be removed
+        assertTrue(textSet.remove(NL_TEST_string)); //and this should be the stringTest
+        rep.add(field, NL_TEST_string); //re add the value for further tests
+    }
+    /**
+     * Tests the feature to add one and the same natural language text for
+     * multiple languages
+     */
+    public void testAddNaturalLanguageTextForMultipleLanguages(){
+        String field = "urn:the.field:used.for.this.Test";
+        Representation rep = createRepresentation(null);
+        //add the same label for multiple language
+        String[] languageArray = new String []{"en","de",null};
+        rep.addNaturalText(field, NL_TEST_noLang, languageArray);
+        Set<String> languages = new HashSet<String>(Arrays.asList(languageArray));
+        Iterator<Text> texts = rep.get(field, (String[])null);
+        while(texts.hasNext()){
+            Text text = texts.next();
+            assertTrue(languages.remove(text.getLanguage()));
+            assertEquals(NL_TEST_noLang, text.getText());
+        }
+        assertTrue(languages.isEmpty());
+    }
+    /**
+     * Tests the feature to remove one and the same natural language text for
+     * multiple languages
+     */
+    public void testRemoveNaturalLanguageValueInMultipleLanguages(){
+        String field = "urn:the.field:used.for.this.Test";
+        Representation rep = createRepresentation(null);
+        //add the same label for multiple languages
+        rep.addNaturalText(field, NL_TEST_noLang, "en","de",null);
+        rep.removeNaturalText(field, NL_TEST_noLang, "en",null);
+        Iterator<Text> texts = rep.get(field, (String[])null);
+        assertTrue(texts.hasNext());
+        Text text = texts.next();
+        assertFalse(texts.hasNext());
+        assertEquals("de", text.getLanguage());
+        assertEquals(NL_TEST_noLang, text.getText());
+    }
+    @Test
+    public void testRemoveAllTextsOfALanguage(){
+        String field = "urn:the.field:used.for.this.Test";
+        Representation rep = initNaturalLanguageTest(field);
+        Set<String> textSet = new HashSet<String>(NL_TEST_all);
+        //remove all texts of a specific language
+        rep.removeAllNaturalText(field, "en");
+        for(Iterator<Text> texts = rep.getText(field);texts.hasNext();textSet.remove(texts.next().getText()));
+        assertTrue(textSet.size() == 2);
+        assertTrue(textSet.remove(NL_TEST_en2));
+        assertTrue(textSet.remove(NL_TEST_en));
+    }
+    @Test
+    public void testRemoveAllTextsOfMultipleLanguages(){
+        //remove all texts of multiple languages
+        String field = "urn:the.field:used.for.this.Test";
+        Representation rep = initNaturalLanguageTest(field);
+        Set<String> textSet = new HashSet<String>(NL_TEST_all);
+        rep.removeAllNaturalText(field, "de","de-AT");
+        for(Iterator<Text> texts = rep.getText(field);texts.hasNext();textSet.remove(texts.next().getText()));
+        assertTrue(textSet.size() == 2);
+        assertTrue(textSet.remove(NL_TEST_de));
+        assertTrue(textSet.remove(NL_TEST_de_AT));
+    }
+    @Test
+    public void testRemoveAllTextsWithNullLanguage(){
+        String field = "urn:the.field:used.for.this.Test";
+        Representation rep = initNaturalLanguageTest(field);
+        Set<String> textSet = new HashSet<String>(NL_TEST_all);
+        //test removal of null language
+        rep.removeAllNaturalText(field, (String)null);
+        for(Iterator<Text> texts = rep.getText(field);texts.hasNext();textSet.remove(texts.next().getText()));
+        assertTrue(textSet.size() == 2);
+        assertTrue(textSet.remove(NL_TEST_noLang));
+        assertTrue(textSet.remove(NL_TEST_string)); //and this should be the stringTest
+    }
+    @Test
+    public void testRemoveAllNaturalLanguageValues(){
+        String field = "urn:the.field:used.for.this.Test";
+        Representation rep = initNaturalLanguageTest(field);
+        //add a reference to ensure that only texts (and strings) are removed
+        String testReference = "http://www.test.org/test";
+        rep.addReference(field, testReference); 
+        //test removal of all natural language values by parsing no languages
+        rep.removeAllNaturalText(field);
+        Iterator<Text> texts = rep.get(field, (String[])null);
+        assertFalse(texts.hasNext()); //not texts any more
+        assertTrue(rep.get(field).hasNext()); //but still a reference!
+    }
+    @Test
+    public void testRemoveAllNaturalLanguageValuesByParsingAnEmptyArray(){
+        String field = "urn:the.field:used.for.this.Test";
+        Representation rep = initNaturalLanguageTest(field);
+        //add a reference to ensure that only texts (and strings) are removed
+        String testReference = "http://www.test.org/test";
+        rep.addReference(field, testReference); 
+        //test removal of all natural language values by parsing an empty language array
+        rep.removeAllNaturalText(field, new String[]{});
+        Iterator<Text> texts = rep.get(field, (String[])null);
+        assertFalse(texts.hasNext());
+        assertTrue(rep.get(field).hasNext()); //text of the added reference is still present
+    }
+    @Test
+    public void testRemoveAllNaturalLanguageValuesByParsingNullAsLanguageArray(){
+        String field = "urn:the.field:used.for.this.Test";
+        Representation rep = initNaturalLanguageTest(field);
+        //add a reference to ensure that only texts (and strings) are removed
+        String testReference = "http://www.test.org/test";
+        rep.addReference(field, testReference); 
+        //test removal of all natural language values by parsing only a single argument
+        rep.removeAllNaturalText(field);
+        Iterator<Text> texts = rep.get(field, (String[])null);
+        assertFalse(texts.hasNext());
+        assertTrue(rep.get(field).hasNext()); //text of the added reference is still present
+    }
+
+    /**
+     * Default ID for {@link Representation} used for testing
+     */
+    private static final String DEFAULT_REPRESENTATION_ID = "urm:test:representation.defaultId";
+    /**
+     * Creates a {@link Representation} instance by using the parsed ID or 
+     * {@link RepresentationTest#DEFAULT_REPRESENTATION_ID} if <code>null</code>
+     * is parsed as ID.
+     * @param id The ID or <code>null</code> to use the default ID
+     * @return the Representation.
+     */
+    protected Representation createRepresentation(String id){
+        if(id == null){
+            id = DEFAULT_REPRESENTATION_ID;
+        }
+        return getValueFactory().createRepresentation(id);
+    }
+    /**
+     * Converts an Iterator to a Collection by iterating over all elements and
+     * adding them to a List.
+     * @param <T>
+     * @param it the iterator
+     * @return the collection containing all elements of the iterator
+     */
+    protected static <T> Collection<T> asCollection(Iterator<T> it){
+        Collection<T> c = new ArrayList<T>();
+        while(it.hasNext()){
+            c.add(it.next());
+        }
+        return c;
+    };
+
+}

Propchange: incubator/stanbol/trunk/rick/generic/test/src/main/java/eu/iksproject/rick/test/model/RepresentationTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/stanbol/trunk/rick/generic/test/src/main/java/eu/iksproject/rick/test/model/ValueFactoryTest.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rick/generic/test/src/main/java/eu/iksproject/rick/test/model/ValueFactoryTest.java?rev=1058959&view=auto
==============================================================================
--- incubator/stanbol/trunk/rick/generic/test/src/main/java/eu/iksproject/rick/test/model/ValueFactoryTest.java (added)
+++ incubator/stanbol/trunk/rick/generic/test/src/main/java/eu/iksproject/rick/test/model/ValueFactoryTest.java Fri Jan 14 11:39:26 2011
@@ -0,0 +1,219 @@
+package eu.iksproject.rick.test.model;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertFalse;
+import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertNotSame;
+import static junit.framework.Assert.assertNull;
+import static junit.framework.Assert.assertTrue;
+
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import org.junit.Test;
+
+import eu.iksproject.rick.servicesapi.model.Reference;
+import eu.iksproject.rick.servicesapi.model.Representation;
+import eu.iksproject.rick.servicesapi.model.Text;
+import eu.iksproject.rick.servicesapi.model.UnsupportedTypeException;
+import eu.iksproject.rick.servicesapi.model.ValueFactory;
+import eu.iksproject.rick.servicesapi.yard.Yard;
+
+/**
+ * General tests for instantiation of model instances by using the different
+ * value factory methods.
+ * This also tests the construction of implementation of {@link Reference},
+ * {@link Text} and {@link Representation}.
+ * For the immutable {@link Text} and {@link Reference} this tests are sufficient.
+ * For Representations there is an own Test class
+ * @author Rupert Westenthaler
+ *
+ */
+public abstract class ValueFactoryTest {
+    /**
+     * Subclasses must implement this method and provide a {@link ValueFactory}
+     * instance that is used to test the actual model implementation
+     * @return the {@link ValueFactory} for the RICK model implementation to be
+     * tested
+     */
+    protected abstract ValueFactory getValueFactory();
+    /**
+     * Returns an instance of a unsupported Type to be parsed to 
+     * {@link ValueFactory#createReference(Object)}. Used to check if this
+     * Method correctly throws an {@link UnsupportedTypeException}
+     * @return an instance of an unsupported type or <code>null</code> if all
+     * types are supported
+     */
+    protected abstract Object getUnsupportedReferenceType();
+    /**
+     * Returns an instance of a unsupported Type to be parsed to
+     * {@link ValueFactory#createText(Object)}. Used to check if this Method
+     * correctly throws an {@link UnsupportedTypeException}
+     * @return an instance of an unsupported type or <code>null</code> if all
+     * types are supported
+     */
+    protected abstract Object getUnsupportedTextType();
+    
+    @Test(expected=NullPointerException.class)
+    public void testNullReference(){
+        testRef(null);
+    }
+    @Test(expected=UnsupportedTypeException.class)
+    public void testUnsupportedReferenceType(){
+        Object unsupported = getUnsupportedReferenceType();
+        if(unsupported != null){
+            testRef(unsupported);
+        } else {
+            // no unsupported types ... this test is not necessary 
+            // -> create a dummy exception
+            //TODO: is there a way to deactivate a test if not valid
+            throw new UnsupportedTypeException(Object.class, 
+                "dummy exception to successfully complete this unnecessary test");
+        }
+    }
+    @Test(expected=IllegalArgumentException.class)
+    public void testEmptyStringReference(){
+        testRef("");
+    }
+    @Test
+    public void testStringReference(){
+        Object refObject = "urn:test.1";
+        Reference ref = testRef(refObject);
+        assertEquals(ref.getReference(), refObject);
+    }
+    @Test
+    public void testUriReference() throws URISyntaxException {
+        URI refObject = new URI("http://www.test.org/uriTest");
+        Reference ref = testRef(refObject);
+        assertEquals(ref.getReference(), refObject.toString());
+    }
+    @Test
+    public void testURLReference() throws MalformedURLException {
+        URL refObject = new URL("http://www.test.org/urlTest");
+        Reference ref = testRef(refObject);
+        assertEquals(ref.getReference(), refObject.toString());
+    }
+    @Test(expected=NullPointerException.class)
+    public void testNullText(){
+        testText(null, "en");
+    }
+    @Test
+    public void testNullLanguage(){
+        testText("test", null);
+    }
+    @Test(expected=UnsupportedTypeException.class)
+    public void testUnsupportedTextType(){
+        Object unsupported  =getUnsupportedTextType();
+        if(unsupported != null){
+            getValueFactory().createText(unsupported);
+        } else {
+            // no unsupported types ... this test is not necessary 
+            // -> create a dummy exception
+            //TODO: is there a way to deactivate a test if not valid
+            throw new UnsupportedTypeException(Object.class, 
+                "dummy exception to successfully complete this unnecessary test");
+        }
+    }
+    @Test
+    public void testNormalText(){
+        testText("test","en");
+    }
+    /**
+     * Some Systems use an empty string for the default language,
+     * other use <code>null</code>. Text does currently not define that
+     * <code>null</code> need to be used as default language. However it does
+     * define that <code>null</code> is a valid value for the language!<p>
+     * Based on that RICK allows implementations to convert an empty language to
+     * <code>null</code> but does NOT allow to to convert <code>null</code> to
+     * an empty string.<p>
+     * This test currently assures, that parsing an empty string as language
+     * results in an empty string OR <code>null</code>. It also tests that
+     * parsing an empty string as language does not result in an Exception.
+     */
+    @Test
+    public void testEmptyLanguageText(){
+        testText("test","");
+    }
+    /**
+     * One can not create a Representation with <code>null</code> as ID.
+     * NOTE: automatic generation of IDs is supported by the {@link Yard#create()}
+     * but not by the {@link Representation} itself.
+     */
+    @Test(expected=NullPointerException.class)
+    public void testNullIdRepresentation(){
+        testRepresentation(null);
+    }
+    /**
+     * One can not create a Representation with an emtpy ID
+     */
+    @Test(expected=IllegalArgumentException.class)
+    public void testEmptyIdRepresentation(){
+        testRepresentation("");
+    }
+    @Test
+    public void testMultipleInstanceForSameID(){
+        Representation rep = testRepresentation("urn:testSameId");
+        Representation rep1 = testRepresentation("urn:testSameId");
+        //check that multiple calls with the same ID create different instances
+        // -> this is very important to allow mapping of Representations (e.g.
+        //    when they are stored within a cache
+        assertNotSame(rep, rep1);
+        //if an ID is parsed, than the two instance should be equal
+        assertTrue(rep.equals(rep1));
+        assertTrue(rep.hashCode() == rep1.hashCode()); //check the hash code
+    }
+    
+    private Representation testRepresentation(String id){
+        ValueFactory vf = getValueFactory();
+        Representation rep = vf.createRepresentation(id);
+        assertNotNull(rep);
+        assertNotNull(rep.getId());
+        if(id != null){
+            assertEquals(rep.getId(), id);
+        }
+        return rep;
+    }
+    /**
+     * Internally used to create and text {@link Text}s for the different tests
+     * @param textString the natural language text as string
+     * @param language the language
+     * @return the created {@link Text} instance that can be used to perform
+     * further tests.
+     */
+    private Text testText(String textString,String language){
+        ValueFactory vf = getValueFactory();
+        Text text = vf.createText(textString, language);
+        assertNotNull(text.getText());
+        assertNotNull(text.getText());
+        assertEquals(text.getText(), textString);
+        if(language == null){
+            assertTrue(text.getLanguage() == null);
+        } else if(language.isEmpty()){
+            //implementations are free to change an empty language string to null
+            //NOTE that it is not allowed to change NULL to an empty String!
+            assertTrue(text.getLanguage() == null || text.getLanguage().isEmpty());
+        } else {
+            assertNotNull(text.getLanguage());
+            assertEquals(text.getLanguage(), language);
+        }
+        return text;
+    }
+    /**
+     * Internally used to create and test {@link Reference}s for the different tests
+     * @param refObject the object representing the reference
+     * @return the created {@link Reference} that can be used to perform further
+     * tests.
+     */
+    private Reference testRef(Object refObject){
+        ValueFactory vf = getValueFactory();
+        Reference ref = vf.createReference(refObject);
+        //check not null
+        assertNotNull(ref);
+        //check reference is not null
+        assertNotNull(ref.getReference());
+        return ref;
+    }
+
+}

Propchange: incubator/stanbol/trunk/rick/generic/test/src/main/java/eu/iksproject/rick/test/model/ValueFactoryTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Propchange: incubator/stanbol/trunk/rick/indexing/dbPedia/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Jan 14 11:39:26 2011
@@ -0,0 +1,7 @@
+dbPedia-rdf-data
+
+data
+
+incoming-counts.tsv
+
+target

Modified: incubator/stanbol/trunk/rick/indexing/dbPedia/src/main/java/eu/iksproject/rick/indexing/dbPedia/cli/CommandLineRunner.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rick/indexing/dbPedia/src/main/java/eu/iksproject/rick/indexing/dbPedia/cli/CommandLineRunner.java?rev=1058959&r1=1058958&r2=1058959&view=diff
==============================================================================
--- incubator/stanbol/trunk/rick/indexing/dbPedia/src/main/java/eu/iksproject/rick/indexing/dbPedia/cli/CommandLineRunner.java (original)
+++ incubator/stanbol/trunk/rick/indexing/dbPedia/src/main/java/eu/iksproject/rick/indexing/dbPedia/cli/CommandLineRunner.java Fri Jan 14 11:39:26 2011
@@ -236,7 +236,7 @@ public class CommandLineRunner {
         //50% of the entities are indexed!
         if(line.hasOption("r")){
             //resume makes only really sense with the RANKING BASED MODE
-            indexingConfig.put(KEY_ENTITY_RANKING_BASED_INDEXING_MODE, Boolean.TRUE);
+            indexingConfig.put(KEY_INDEXING_MODE, IndexingMode.RANKING_MAP_BASED);
             //set the RESUME MODE
             indexingConfig.put(KEY_RESUME_MODE, Boolean.TRUE);
         }

Modified: incubator/stanbol/trunk/rick/indexing/genericRdf/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rick/indexing/genericRdf/pom.xml?rev=1058959&r1=1058958&r2=1058959&view=diff
==============================================================================
--- incubator/stanbol/trunk/rick/indexing/genericRdf/pom.xml (original)
+++ incubator/stanbol/trunk/rick/indexing/genericRdf/pom.xml Fri Jan 14 11:39:26 2011
@@ -26,7 +26,8 @@
   <version>0.1-SNAPSHOT</version>
   <name>IKS RICK Indexing for rdf Resource</name>
   <description>This indexes all kind of RDF sources by using a prased
-  configuration (FieldMapper to define index fields and field values and a set of indexed rdf:types) configuration for processing Resources in the Graph.
+  configuration (FieldMapper to define index fields and field values and a set 
+  of indexed rdf:types) configuration for processing Resources in the Graph.
   </description>
   <dependencies>
     <dependency>
@@ -44,50 +45,21 @@
         <version>0.1-SNAPSHOT</version>
     </dependency>
     <dependency>
-        <groupId>eu.iksproject</groupId>
-        <artifactId>eu.iksproject.rick.core</artifactId>
-        <version>0.1-SNAPSHOT</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.clerezza</groupId>
-      <artifactId>org.apache.clerezza.rdf.utils</artifactId>
-      <version>0.13-incubating-SNAPSHOT</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.clerezza</groupId>
-      <artifactId>org.apache.clerezza.rdf.core</artifactId>
-      <version>0.12-incubating-SNAPSHOT</version>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.clerezza</groupId>
-      <artifactId>org.apache.clerezza.jaxrs.rdf.providers</artifactId>
-      <version>0.13-incubating-SNAPSHOT</version>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.clerezza</groupId>
-      <artifactId>org.apache.clerezza.rdf.jena.tdb.storage</artifactId>
-      <version>0.5-incubating-SNAPSHOT</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.clerezza</groupId>
-      <artifactId>org.apache.clerezza.rdf.jena.serializer</artifactId>
-      <version>0.9-incubating-SNAPSHOT</version>
-      <scope>provided</scope>
-    </dependency>
-     <dependency>
-      <groupId>org.apache.clerezza</groupId>
-      <artifactId>org.apache.clerezza.rdf.jena.parser</artifactId>
-      <version>0.10-incubating-SNAPSHOT</version>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.clerezza</groupId>
-      <artifactId>org.apache.clerezza.rdf.rdfjson</artifactId>
-      <version>0.3-incubating-SNAPSHOT</version>
-      <scope>provided</scope>
-    </dependency>
+      <groupId>com.hp.hpl.jena</groupId>
+      <artifactId>jena</artifactId>
+      <version>2.6.4</version>
+      <exclusions>
+        <exclusion>
+          <artifactId>slf4j-log4j12</artifactId>
+          <groupId>org.slf4j</groupId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+	<dependency>
+      <groupId>com.hp.hpl.jena</groupId>
+	  <artifactId>tdb</artifactId>
+	  <version>0.8.8</version>
+    </dependency>  
     <dependency>
       <groupId>org.apache.commons</groupId>
       <artifactId>commons-compress</artifactId>