sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1470054 - in /sis/branches/JDK7/sis-metadata/src: main/java/org/apache/sis/metadata/iso/ main/java/org/apache/sis/metadata/iso/citation/ main/java/org/apache/sis/metadata/iso/extent/ test/java/org/apache/sis/metadata/iso/citation/ test/jav...
Date Fri, 19 Apr 2013 21:42:07 GMT
Author: desruisseaux
Date: Fri Apr 19 21:42:07 2013
New Revision: 1470054

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

Added:
    sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/DefaultCitationDateTest.java
  (with props)
    sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/DefaultCitationTest.java
  (with props)
Modified:
    sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultIdentifier.java
    sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultCitation.java
    sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultGeographicDescription.java
    sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/HardCodedCitations.java
    sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java

Modified: sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultIdentifier.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultIdentifier.java?rev=1470054&r1=1470053&r2=1470054&view=diff
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultIdentifier.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultIdentifier.java
[UTF-8] Fri Apr 19 21:42:07 2013
@@ -84,14 +84,14 @@ public class DefaultIdentifier extends I
     /**
      * Creates an identifier initialized to the given authority and code.
      *
-     * @param code      The alphanumeric value identifying an instance in the namespace,
-     *                  or {@code null} if none.
      * @param authority The organization or party responsible for definition and maintenance
      *                  of the code, or {@code null} if none.
+     * @param code      The alphanumeric value identifying an instance in the namespace,
+     *                  or {@code null} if none.
      */
-    public DefaultIdentifier(final String code, final Citation authority) {
-        this.code = code;
+    public DefaultIdentifier(final Citation authority, final String code) {
         this.authority = authority;
+        this.code = code;
     }
 
     /**

Modified: sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultCitation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultCitation.java?rev=1470054&r1=1470053&r2=1470054&view=diff
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultCitation.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultCitation.java
[UTF-8] Fri Apr 19 21:42:07 2013
@@ -503,7 +503,7 @@ public class DefaultCitation extends ISO
     @Override
     @XmlElement(name = "ISBN")
     public synchronized String getISBN() {
-        return isNullOrEmpty(identifiers) ? null : getIdentifierMap().getSpecialized(ISBN);
+        return isNullOrEmpty(identifiers) ? null : getIdentifierMap().get(ISBN);
     }
 
     /**
@@ -540,7 +540,7 @@ public class DefaultCitation extends ISO
     @Override
     @XmlElement(name = "ISSN")
     public synchronized String getISSN() {
-        return isNullOrEmpty(identifiers) ? null : getIdentifierMap().getSpecialized(ISSN);
+        return isNullOrEmpty(identifiers) ? null : getIdentifierMap().get(ISSN);
     }
 
     /**

Modified: sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultGeographicDescription.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultGeographicDescription.java?rev=1470054&r1=1470053&r2=1470054&view=diff
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultGeographicDescription.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultGeographicDescription.java
[UTF-8] Fri Apr 19 21:42:07 2013
@@ -66,7 +66,7 @@ public class DefaultGeographicDescriptio
     public DefaultGeographicDescription(final Citation authority, final String code) {
         super(true);
         if (authority != null || code != null) {
-            this.geographicIdentifier = new DefaultIdentifier(code, authority);
+            this.geographicIdentifier = new DefaultIdentifier(authority, code);
         }
     }
 

Added: sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/DefaultCitationDateTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/DefaultCitationDateTest.java?rev=1470054&view=auto
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/DefaultCitationDateTest.java
(added)
+++ sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/DefaultCitationDateTest.java
[UTF-8] Fri Apr 19 21:42:07 2013
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.metadata.iso.citation;
+
+import java.util.Date;
+import org.opengis.metadata.citation.DateType;
+import org.opengis.metadata.citation.CitationDate;
+import org.apache.sis.util.ComparisonMode;
+import org.apache.sis.test.TestCase;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+
+/**
+ * Tests {@link DefaultCitationDate}, especially the copy constructor.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.3 (derived from geotk-3.18)
+ * @version 0.3
+ * @module
+ */
+public final strictfp class DefaultCitationDateTest extends TestCase {
+    /**
+     * Tests the copy constructor.
+     *
+     * @see <a href="http://jira.geotoolkit.org/browse/GEOTK-170">GEOTK-170</a>
+     */
+    @Test
+    public void testShallowCopy() {
+        final CitationDate original = new CitationDate() {
+            @Override public Date     getDate()     {return new Date(1305716658508L);}
+            @Override public DateType getDateType() {return DateType.CREATION;}
+        };
+        final DefaultCitationDate copy = new DefaultCitationDate(original);
+        assertEquals(new Date(1305716658508L), copy.getDate());
+        assertEquals(DateType.CREATION, copy.getDateType());
+        assertTrue (copy.equals(original, ComparisonMode.BY_CONTRACT));
+        assertFalse(copy.equals(original, ComparisonMode.STRICT)); // Opportunist test.
+    }
+}

Propchange: sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/DefaultCitationDateTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/DefaultCitationDateTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Added: sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/DefaultCitationTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/DefaultCitationTest.java?rev=1470054&view=auto
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/DefaultCitationTest.java
(added)
+++ sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/DefaultCitationTest.java
[UTF-8] Fri Apr 19 21:42:07 2013
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.metadata.iso.citation;
+
+import java.util.Arrays;
+import java.util.Collection;
+import org.opengis.metadata.Identifier;
+import org.apache.sis.xml.IdentifierMap;
+import org.apache.sis.metadata.iso.DefaultIdentifier;
+import org.apache.sis.test.TestCase;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+
+/**
+ * Tests {@link DefaultCitation}.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.3 (derived from geotk-3.19)
+ * @version 0.3
+ * @module
+ */
+public final strictfp class DefaultCitationTest extends TestCase {
+    /**
+     * Tests the identifier map, which handles ISBN and ISSN codes in a special way.
+     */
+    @Test
+    public void testIdentifierMap() {
+        final DefaultCitation citation = new DefaultCitation();
+        final Collection<Identifier> identifiers = citation.getIdentifiers();
+        final IdentifierMap identifierMap = citation.getIdentifierMap();
+        assertTrue("Expected an initially empty set of identifiers.", identifiers.isEmpty());
+        /*
+         * Set the ISBN code, and ensure that the the ISBN is reflected in the identifier
map.
+         */
+        citation.setISBN("MyISBN");
+        assertEquals("MyISBN", citation.getISBN());
+        assertEquals("ISBN code shall be included in the set of identifiers.", 1, identifiers.size());
+        assertEquals("{ISBN=“MyISBN”}", identifierMap.toString());
+        /*
+         * Set the identifiers with a list containing ISBN and ISSN codes.
+         * The ISBN code shall be ignored because and ISBN property was already set.
+         * The ISSN code shall be retained because it is a new code.
+         */
+        assertNull("ISSN shall be initially null.", citation.getISSN());
+        citation.setIdentifiers(Arrays.asList(
+                new DefaultIdentifier(HardCodedCitations.OGC,  "MyOGC"),
+                new DefaultIdentifier(HardCodedCitations.EPSG, "MyEPSG"),
+                new DefaultIdentifier(Citations.ISBN, "MyIgnored"),
+                new DefaultIdentifier(Citations.ISSN, "MyISSN")));
+
+        assertEquals("The ISBN value shall not have been overwritten.",    "MyISBN", citation.getISBN());
+        assertEquals("The ISSN value shall have been added, because new.", "MyISSN", citation.getISSN());
+        assertEquals("{OGC=“MyOGC”, EPSG=“MyEPSG”, ISSN=“MyISSN”, ISBN=“MyISBN”}",
identifierMap.toString());
+    }
+}

Propchange: sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/DefaultCitationTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/DefaultCitationTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/HardCodedCitations.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/HardCodedCitations.java?rev=1470054&r1=1470053&r2=1470054&view=diff
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/HardCodedCitations.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/HardCodedCitations.java
[UTF-8] Fri Apr 19 21:42:07 2013
@@ -42,6 +42,22 @@ import static java.util.Collections.sing
  */
 public final strictfp class HardCodedCitations extends Static {
     /**
+     * The <a href="http://www.opengeospatial.org">Open Geospatial consortium</a>
organization.
+     * "Open Geospatial consortium" is the new name for "OpenGIS consortium".
+     * An {@linkplain Citation#getAlternateTitles() alternate title} for this citation is
"OGC"
+     * (according ISO 19115, alternate titles often contain abbreviations).
+     */
+    public static final DefaultCitation OGC;
+    static {
+        final DefaultCitation c = new DefaultCitation("Open Geospatial consortium");
+        c.setAlternateTitles(singleton(new SimpleInternationalString("OGC")));
+        c.setPresentationForms(singleton(PresentationForm.DOCUMENT_DIGITAL));
+        c.getIdentifiers().add(new DefaultIdentifier("OGC"));
+        c.freeze();
+        OGC = c;
+    }
+
+    /**
      * The <a href="http://www.iso.org/">International Organization for Standardization</a>
      * organization. An {@linkplain Citation#getAlternateTitles() alternate title} for this
      * citation is "ISO" (according ISO 19115, alternate titles often contain abbreviations).

Modified: sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java?rev=1470054&r1=1470053&r2=1470054&view=diff
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
[UTF-8] Fri Apr 19 21:42:07 2013
@@ -31,6 +31,10 @@ import org.junit.BeforeClass;
  */
 @Suite.SuiteClasses({
     org.apache.sis.internal.metadata.MetadataUtilitiesTest.class,
+    org.apache.sis.metadata.iso.citation.DefaultCitationDateTest.class,
+    org.apache.sis.metadata.iso.citation.DefaultCitationTest.class,
+
+    // Classes using Java reflection.
     org.apache.sis.metadata.PropertyInformationTest.class,
     org.apache.sis.metadata.PropertyAccessorTest.class,
     org.apache.sis.metadata.NameMapTest.class,



Mime
View raw message