sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1519081 - in /sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing: AbstractIdentifiedObjectTest.java AbstractReferenceSystemTest.java
Date Fri, 30 Aug 2013 20:35:57 GMT
Author: desruisseaux
Date: Fri Aug 30 20:35:57 2013
New Revision: 1519081

URL: http://svn.apache.org/r1519081
Log:
Added more tests.

Modified:
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractIdentifiedObjectTest.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractReferenceSystemTest.java

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractIdentifiedObjectTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractIdentifiedObjectTest.java?rev=1519081&r1=1519080&r2=1519081&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractIdentifiedObjectTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractIdentifiedObjectTest.java
[UTF-8] Fri Aug 30 20:35:57 2013
@@ -20,11 +20,13 @@ import java.util.Map;
 import java.util.HashMap;
 import java.util.Locale;
 import org.opengis.test.Validators;
+import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
-import static org.junit.Assert.*;
+import static org.apache.sis.test.Assert.*;
+import static org.apache.sis.metadata.iso.citation.HardCodedCitations.EPSG;
 
 
 /**
@@ -56,10 +58,59 @@ public final strictfp class AbstractIden
         assertEquals("name",       "This is a name",      object.getName().getCode());
         assertNull  ("codeSpace",                         object.getName().getCodeSpace());
         assertNull  ("version",                           object.getName().getVersion());
-        assertEquals("remarks",    "There is remarks",    object.getRemarks().toString(Locale.ENGLISH));
-        assertEquals("remarks_fr", "Voici des remarques", object.getRemarks().toString(Locale.FRENCH));
+        assertTrue  ("aliases",                           object.getAlias().isEmpty());
         assertTrue  ("identifiers",                       object.getIdentifiers().isEmpty());
         assertNull  ("identifier",                        object.getIdentifier());
-        assertTrue  ("aliases",                           object.getAlias().isEmpty());
+        assertEquals("ID",         "Thisisaname",         object.getID());
+        assertEquals("remarks",    "There is remarks",    object.getRemarks().toString(Locale.ENGLISH));
+        assertEquals("remarks_fr", "Voici des remarques", object.getRemarks().toString(Locale.FRENCH));
+    }
+
+    /**
+     * Tests identifiers getter. The methods of interest to this test are:
+     *
+     * <ul>
+     *   <li>{@link AbstractIdentifiedObject#getIdentifiers()}</li>
+     *   <li>{@link AbstractIdentifiedObject#getIdentifier()}</li>
+     *   <li>{@link AbstractIdentifiedObject#getID()}</li>
+     * </ul>
+     *
+     * Note that {@code getID()} were also tested in {@link #testCreateFromMap()}
+     * but in the absence of identifiers.
+     */
+    @Test
+    @DependsOnMethod("testCreateFromMap")
+    public void testGetIdentifiers() {
+        final Map<String,Object> properties = new HashMap<>(8);
+        assertNull(properties.put("name", "WGS 84"));
+        assertNull(properties.put("identifiers", new NamedIdentifier[] {
+            new NamedIdentifier(EPSG, "4326"),
+            new NamedIdentifier(EPSG, "IgnoreMe")
+        }));
+
+        final AbstractIdentifiedObject object = new AbstractIdentifiedObject(properties);
+        Validators.validate(object);
+
+        assertEquals("name",        "WGS 84",                     object.getName().getCode());
+        assertEquals("identifiers", "[EPSG:4326, EPSG:IgnoreMe]", object.getIdentifiers().toString());
+        assertEquals("identifier",  "EPSG:4326",                  object.getIdentifier().toString());
+        assertEquals("ID",          "EPSG4326",                   object.getID());
+    }
+
+    /**
+     * Tests serialization.
+     */
+    @Test
+    @DependsOnMethod("testCreateFromMap")
+    public void testSerialization() {
+        final Map<String,Object> properties = new HashMap<>(8);
+        assertNull(properties.put("code",      "4326"));
+        assertNull(properties.put("codeSpace", "EPSG"));
+        assertNull(properties.put("remarks",   "There is remarks"));
+
+        final AbstractIdentifiedObject object = new AbstractIdentifiedObject(properties);
+        Validators.validate(object);
+
+        assertNotSame(object, assertSerializedEquals(object));
     }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractReferenceSystemTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractReferenceSystemTest.java?rev=1519081&r1=1519080&r2=1519081&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractReferenceSystemTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractReferenceSystemTest.java
[UTF-8] Fri Aug 30 20:35:57 2013
@@ -20,11 +20,12 @@ import java.util.Map;
 import java.util.HashMap;
 import java.util.Locale;
 import org.opengis.test.Validators;
+import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
-import static org.junit.Assert.*;
+import static org.apache.sis.test.Assert.*;
 
 
 /**
@@ -41,7 +42,7 @@ public final strictfp class AbstractRefe
      * Tests {@link AbstractReferenceSystem}.
      */
     @Test
-    public void testReferenceSystem() {
+    public void testCreateFromMap() {
         final Map<String,Object> properties = new HashMap<>();
         assertNull(properties.put("name",       "This is a name"));
         assertNull(properties.put("scope",      "This is a scope"));
@@ -58,4 +59,23 @@ public final strictfp class AbstractRefe
         assertEquals("remarks",    "There is remarks",       reference.getRemarks().toString(Locale.ENGLISH));
         assertEquals("remarks_fr", "Voici des remarques",    reference.getRemarks().toString(Locale.FRENCH));
     }
+
+    /**
+     * Tests serialization.
+     */
+    @Test
+    @DependsOnMethod("testCreateFromMap")
+    public void testSerialization() {
+        final Map<String,Object> properties = new HashMap<>(8);
+        assertNull(properties.put("code",       "4326"));
+        assertNull(properties.put("codeSpace",  "EPSG"));
+        assertNull(properties.put("scope",      "This is a scope"));
+        assertNull(properties.put("remarks",    "There is remarks"));
+        assertNull(properties.put("remarks_fr", "Voici des remarques"));
+
+        final AbstractReferenceSystem object = new AbstractReferenceSystem(properties);
+        Validators.validate(object);
+
+        assertNotSame(object, assertSerializedEquals(object));
+    }
 }



Mime
View raw message