sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1469826 - in /sis/branches/JDK7: sis-metadata/src/main/java/org/apache/sis/metadata/ sis-metadata/src/test/java/org/apache/sis/metadata/ sis-metadata/src/test/java/org/apache/sis/test/suite/ sis-referencing/src/test/java/org/apache/sis/tes...
Date Fri, 19 Apr 2013 13:37:12 GMT
Author: desruisseaux
Date: Fri Apr 19 13:37:11 2013
New Revision: 1469826

URL: http://svn.apache.org/r1469826
Log:
Added more metadata tests, and fixed the checks for utility test list.

Added:
    sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/InformationMapTest.java
  (with props)
    sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/NameMapTest.java
  (with props)
    sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/TypeMapTest.java
  (with props)
Modified:
    sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java
    sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java
    sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyInformation.java
    sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataStandardTest.java
    sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyAccessorTest.java
    sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
    sis/branches/JDK7/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java
    sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/jaxb/IdentifierMapWithSpecialCasesTest.java
    sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/test/AssertTest.java
    sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/test/XMLComparatorTest.java
    sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/test/TestSuite.java
    sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java
    sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/util/LocalesTest.java

Modified: sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java?rev=1469826&r1=1469825&r2=1469826&view=diff
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java
[UTF-8] Fri Apr 19 13:37:11 2013
@@ -520,6 +520,11 @@ public class MetadataStandard {
      *     <ul>
      *       <li>The {@linkplain CheckedContainer#getElementType() element type} is
the type of property values
      *           as defined by {@link TypeValuePolicy#ELEMENT_TYPE}.</li>
+     *
+     *       {@note The rational for implementing <code>CheckedContainer</code>
is to consider each
+     *       <code>ExtendedElementInformation</code> instance as the set of all
possible values for
+     *       the property. If the information had a <code>contains(E)</code>
method, it would return
+     *       <code>true</code> if the given value is valid for that property.}
      *     </ul>
      *   </li>
      * </ul>

Modified: sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java?rev=1469826&r1=1469825&r2=1469826&view=diff
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java
[UTF-8] Fri Apr 19 13:37:11 2013
@@ -36,6 +36,7 @@ import org.apache.sis.util.Classes;
 import org.apache.sis.util.Numbers;
 import org.apache.sis.util.ArraysExt;
 import org.apache.sis.util.Utilities;
+import org.apache.sis.util.Workaround;
 import org.apache.sis.util.CharSequences;
 import org.apache.sis.util.ComparisonMode;
 import org.apache.sis.util.ObjectConverter;
@@ -471,13 +472,20 @@ final class PropertyAccessor {
      *         or {@code null} if the index is out of bounds.
      */
     @SuppressWarnings("fallthrough")
+    @Workaround(library="JDK", version="1.7") // Actually apply to String.intern() below.
     final String name(final int index, final KeyNamePolicy keyPolicy) {
         if (index >= 0 && index < names.length) {
             switch (keyPolicy) {
                 case UML_IDENTIFIER: {
                     final UML uml = getters[index].getAnnotation(UML.class);
                     if (uml != null) {
-                        return uml.identifier();
+                        /*
+                         * Workaround here: I though that annotation strings were interned
like any other
+                         * constants, but it doesn't seem to be the case as of JDK7. To check
if a future
+                         * JDK release still needs this explicit call to String.intern(),
try to remove
+                         * the ".intern()" part and run the NameMapTest.testIntern() method.
+                         */
+                        return uml.identifier().intern();
                     }
                     // Fallthrough
                 }

Modified: sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyInformation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyInformation.java?rev=1469826&r1=1469825&r2=1469826&view=diff
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyInformation.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyInformation.java
[UTF-8] Fri Apr 19 13:37:11 2013
@@ -43,7 +43,12 @@ import org.apache.sis.util.logging.Loggi
  * but other types are allowed), instances of {@code PropertyInformation} are obtained
  * indirectly by the {@link MetadataStandard#asInformationMap(Class, KeyNamePolicy)} method.
  *
- * @param <T> The value type, either the method return type if not a collection,
+ * {@note The rational for implementing <code>CheckedContainer</code> is to consider
each
+ *        <code>ExtendedElementInformation</code> instance as the set of all
possible values
+ *        for the property. If the information had a <code>contains(E)</code>
method, it would
+ *        return <code>true</code> if the given value is valid for that property.}
+ *
+ * @param <E> The value type, either the method return type if not a collection,
  *            or the type of elements in the collection otherwise.
  *
  * @author  Martin Desruisseaux (Geomatys)
@@ -56,8 +61,8 @@ import org.apache.sis.util.logging.Loggi
  * @see <a href="https://issues.apache.org/jira/browse/SIS-80">SIS-80</a>
  */
 @Immutable
-final class PropertyInformation<T> extends SimpleReferenceIdentifier
-        implements ExtendedElementInformation, CheckedContainer<T>
+final class PropertyInformation<E> extends SimpleReferenceIdentifier
+        implements ExtendedElementInformation, CheckedContainer<E>
 {
     /**
      * For cross-versions compatibility.
@@ -78,7 +83,7 @@ final class PropertyInformation<T> exten
      * @see #getDataType()
      * @see #getElementType()
      */
-    private final Class<T> elementType;
+    private final Class<E> elementType;
 
     /**
      * The minimum number of occurrences.
@@ -121,7 +126,7 @@ final class PropertyInformation<T> exten
      */
     @SuppressWarnings({"unchecked","rawtypes"})
     PropertyInformation(final Citation standard, final String property, final Method getter,
-            final Class<T> elementType, final ValueRange range)
+            final Class<E> elementType, final ValueRange range)
     {
         super(standard, property);
         parent = getter.getDeclaringClass();
@@ -247,7 +252,7 @@ final class PropertyInformation<T> exten
      * returns the type of elements in the array or collection.
      */
     @Override
-    public Class<T> getElementType() {
+    public Class<E> getElementType() {
         return elementType;
     }
 

Added: sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/InformationMapTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/InformationMapTest.java?rev=1469826&view=auto
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/InformationMapTest.java
(added)
+++ sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/InformationMapTest.java
[UTF-8] Fri Apr 19 13:37:11 2013
@@ -0,0 +1,91 @@
+/*
+ * 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;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Arrays;
+import java.util.Locale;
+import org.opengis.metadata.ExtendedElementInformation;
+import org.opengis.metadata.acquisition.EnvironmentalRecord;
+import org.opengis.metadata.citation.Citation;
+import org.opengis.metadata.content.ImageDescription;
+import org.apache.sis.test.DependsOn;
+import org.apache.sis.test.TestCase;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+
+/**
+ * Tests the {@link InformationMap} class on instances created by
+ * {@link MetadataStandard#asInformationMap(Class, KeyNamePolicy)}.
+ * Unless otherwise specified, all tests use the {@link MetadataStandard#ISO_19115} constant.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.3 (derived from geotk-3.05)
+ * @version 0.3
+ * @module
+ */
+@DependsOn({PropertyAccessorTest.class, PropertyInformationTest.class})
+public final strictfp class InformationMapTest extends TestCase {
+    /**
+     * Tests the map on a few specific properties of the {@link Citation} type.
+     * This test duplicates {@link PropertyInformationTest}, but is done here again as an
integration test.
+     */
+    @Test
+    public void testSpecificProperty() {
+        final Map<String,ExtendedElementInformation> map = MetadataStandard.ISO_19115.asInformationMap(
+                Citation.class, KeyNamePolicy.JAVABEANS_PROPERTY);
+        PropertyInformationTest.validateTitle(map.get("title"));
+        PropertyInformationTest.validatePresentationForm(map.get("presentationForms"));
+        assertNull("Shall not exists.", map.get("dummy"));
+    }
+
+    /**
+     * Tests the content of the key set of {@link EnvironmentalRecord}.
+     * There is no requirement on the properties order.
+     */
+    @Test
+    public void testKeySet() {
+        final Map<String,ExtendedElementInformation> descriptions = MetadataStandard.ISO_19115.asInformationMap(
+                EnvironmentalRecord.class, KeyNamePolicy.UML_IDENTIFIER);
+
+        final Set<String> expected = new HashSet<>(Arrays.asList(
+            "averageAirTemperature", "maxAltitude", "maxRelativeHumidity", "meteorologicalConditions"
+        ));
+        assertEquals(expected, descriptions.keySet());
+    }
+
+    /**
+     * Tests on {@link ImageDescription} a property defined in the {@link CoverageDescription}
parent class.
+     */
+    @Test
+    public void testInheritance() {
+        final Map<String,ExtendedElementInformation> descriptions = MetadataStandard.ISO_19115.asInformationMap(
+                ImageDescription.class, KeyNamePolicy.UML_IDENTIFIER);
+
+        assertEquals("Testing a property defined directly in the ImageDescription type.",
+                "Area of the dataset obscured by clouds, expressed as a percentage of the
spatial extent.",
+                descriptions.get("cloudCoverPercentage").getDefinition().toString(Locale.ENGLISH));
+
+        assertEquals("Testing a property inherited from the CoverageDescription parent.",
+                "Type of information represented by the cell value.",
+                descriptions.get("contentType").getDefinition().toString(Locale.ENGLISH));
+    }
+}

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

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

Modified: sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataStandardTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataStandardTest.java?rev=1469826&r1=1469825&r2=1469826&view=diff
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataStandardTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataStandardTest.java
[UTF-8] Fri Apr 19 13:37:11 2013
@@ -20,16 +20,8 @@ import java.util.Set;
 import java.util.Map;
 import java.util.HashSet;
 import java.util.Collection;
-import java.util.Date;
-import org.opengis.util.InternationalString;
-import org.opengis.metadata.Identifier;
-import org.opengis.metadata.citation.Series;
 import org.opengis.metadata.citation.Citation;
-import org.opengis.metadata.citation.CitationDate;
-import org.opengis.metadata.citation.ResponsibleParty;
-import org.opengis.metadata.citation.PresentationForm;
 import org.opengis.metadata.quality.Completeness;
-import org.opengis.metadata.ExtendedElementInformation;
 import org.apache.sis.metadata.iso.citation.DefaultCitation;
 import org.apache.sis.metadata.iso.citation.HardCodedCitations;
 import org.apache.sis.metadata.iso.quality.AbstractCompleteness;
@@ -41,19 +33,27 @@ import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
 import static org.opengis.test.Assert.*;
-import static java.util.AbstractMap.SimpleEntry;
 
 
 /**
  * Tests the {@link MetadataStandard} class.
- * Unless otherwise specified, the tests use the {@link MetadataStandard#ISO_19115} constant.
+ * Unless otherwise specified, all tests use the {@link MetadataStandard#ISO_19115} constant.
+ *
+ * <p>The following methods are not tested by this class, because they are tested by
+ * dedicated classes named according the implementation class doing the actual work:</p>
+ *
+ * <ul>
+ *   <li>{@link MetadataStandard#asNameMap(Class, KeyNamePolicy, KeyNamePolicy)}, tested
by {@link NameMapTest}</li>
+ *   <li>{@link MetadataStandard#asTypeMap(Class, KeyNamePolicy, TypeValuePolicy)},
tested by {@link TypeMapTest}</li>
+ *   <li>{@link MetadataStandard#asInformationMap(Class, KeyNamePolicy)}, tested by
{@link InformationMapTest}</li>
+ * </ul>
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3 (derived from geotk-2.4)
  * @version 0.3
  * @module
  */
-@DependsOn({PropertyAccessorTest.class, PropertyInformationTest.class})
+@DependsOn({PropertyAccessorTest.class, NameMapTest.class, TypeMapTest.class, InformationMapTest.class})
 public final strictfp class MetadataStandardTest extends TestCase {
     /**
      * Tests {@link MetadataStandard#getInterface(Class)}.
@@ -124,80 +124,6 @@ public final strictfp class MetadataStan
     }
 
     /**
-     * Tests the {@link MetadataStandard#asName(Class, KeyNamePolicy, KeyNamePolicy)} implementation.
-     * The properties used in this test are listed in {@link PropertyAccessorTest#testConstructor()}.
-     *
-     * @see PropertyAccessorTest#testConstructor()
-     */
-    @Test
-    public void testNameMap() {
-        final Map<String,String> map = MetadataStandard.ISO_19115.asNameMap(
-                Citation.class, KeyNamePolicy.UML_IDENTIFIER, KeyNamePolicy.JAVABEANS_PROPERTY);
-        assertArrayEquals(new Object[] {
-            new SimpleEntry<>("title",                 "title"),
-            new SimpleEntry<>("alternateTitle",        "alternateTitles"),
-            new SimpleEntry<>("date",                  "dates"),
-            new SimpleEntry<>("edition",               "edition"),
-            new SimpleEntry<>("editionDate",           "editionDate"),
-            new SimpleEntry<>("identifier",            "identifiers"),
-            new SimpleEntry<>("citedResponsibleParty", "citedResponsibleParties"),
-            new SimpleEntry<>("presentationForm",      "presentationForms"),
-            new SimpleEntry<>("series",                "series"),
-            new SimpleEntry<>("otherCitationDetails",  "otherCitationDetails"),
-            new SimpleEntry<>("collectiveTitle",       "collectiveTitle"),
-            new SimpleEntry<>("ISBN",                  "ISBN"),
-            new SimpleEntry<>("ISSN",                  "ISSN")
-        }, map.entrySet().toArray());
-
-        assertEquals("alternateTitles", map.get("alternateTitle"));
-        assertNull("Shall not exists.", map.get("dummy"));
-    }
-
-    /**
-     * Tests the {@link MetadataStandard#asType(Class, KeyNamePolicy, TypeValuePolicy)} implementation.
-     * The properties used in this test are listed in {@link PropertyAccessorTest#testConstructor()}.
-     *
-     * @see PropertyAccessorTest#testConstructor()
-     */
-    @Test
-    public void testTypeMap() {
-        final Map<String,Class<?>> map = MetadataStandard.ISO_19115.asTypeMap(
-                Citation.class, KeyNamePolicy.UML_IDENTIFIER, TypeValuePolicy.ELEMENT_TYPE);
-        assertArrayEquals(new Object[] {
-            new SimpleEntry<>("title",                 InternationalString.class),
-            new SimpleEntry<>("alternateTitle",        InternationalString.class),
-            new SimpleEntry<>("date",                  CitationDate.class),
-            new SimpleEntry<>("edition",               InternationalString.class),
-            new SimpleEntry<>("editionDate",           Date.class),
-            new SimpleEntry<>("identifier",            Identifier.class),
-            new SimpleEntry<>("citedResponsibleParty", ResponsibleParty.class),
-            new SimpleEntry<>("presentationForm",      PresentationForm.class),
-            new SimpleEntry<>("series",                Series.class),
-            new SimpleEntry<>("otherCitationDetails",  InternationalString.class),
-            new SimpleEntry<>("collectiveTitle",       InternationalString.class),
-            new SimpleEntry<>("ISBN",                  String.class),
-            new SimpleEntry<>("ISSN",                  String.class)
-        }, map.entrySet().toArray());
-
-        assertEquals(InternationalString.class, map.get("alternateTitle"));
-        assertNull("Shall not exists.", map.get("dummy"));
-    }
-
-    /**
-     * Tests the {@link MetadataStandard#asInformationMap(Class, KeyNamePolicy)} implementation.
-     * Note: this test duplicates {@link PropertyInformationTest}, but is done here again
as an
-     * integration test.
-     */
-    @Test
-    public void testInformationMap() {
-        final Map<String,ExtendedElementInformation> map = MetadataStandard.ISO_19115.asInformationMap(
-                Citation.class, KeyNamePolicy.JAVABEANS_PROPERTY);
-        PropertyInformationTest.validateTitle(map.get("title"));
-        PropertyInformationTest.validatePresentationForm(map.get("presentationForms"));
-        assertNull("Shall not exists.", map.get("dummy"));
-    }
-
-    /**
      * Tests the {@link MetadataStandard#asValueMap(Object, KeyNamePolicy, ValueExistencePolicy)}
implementation.
      * Note: this test duplicates {@link ValueMapTest}, but is done here again as an integration
test.
      */

Added: sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/NameMapTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/NameMapTest.java?rev=1469826&view=auto
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/NameMapTest.java
(added)
+++ sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/NameMapTest.java
[UTF-8] Fri Apr 19 13:37:11 2013
@@ -0,0 +1,125 @@
+/*
+ * 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;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.AbstractMap;
+import org.opengis.metadata.citation.Citation;
+import org.opengis.metadata.acquisition.EnvironmentalRecord;
+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.metadata.KeyNamePolicy.*;
+
+
+/**
+ * Tests the {@link NameMap} class on instances created by
+ * {@link MetadataStandard#asNameMap(Class, KeyNamePolicy, KeyNamePolicy)}.
+ * Unless otherwise specified, all tests use the {@link MetadataStandard#ISO_19115} constant.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.3 (derived from geotk-3.04)
+ * @version 0.3
+ * @module
+ */
+@DependsOn(PropertyAccessorTest.class)
+public final strictfp class NameMapTest extends TestCase {
+    /**
+     * Tests the {@link MetadataStandard#asName(Class, KeyNamePolicy, KeyNamePolicy)} implementation.
+     * The properties used in this test are listed in {@link PropertyAccessorTest#testConstructor()}.
+     *
+     * @see PropertyAccessorTest#testConstructor()
+     */
+    @Test
+    public void testEntrySet() {
+        final Map<String,String> map = MetadataStandard.ISO_19115.asNameMap(
+                Citation.class, KeyNamePolicy.UML_IDENTIFIER, KeyNamePolicy.JAVABEANS_PROPERTY);
+        assertArrayEquals(new Object[] {
+            new AbstractMap.SimpleEntry<>("title",                 "title"),
+            new AbstractMap.SimpleEntry<>("alternateTitle",        "alternateTitles"),
+            new AbstractMap.SimpleEntry<>("date",                  "dates"),
+            new AbstractMap.SimpleEntry<>("edition",               "edition"),
+            new AbstractMap.SimpleEntry<>("editionDate",           "editionDate"),
+            new AbstractMap.SimpleEntry<>("identifier",            "identifiers"),
+            new AbstractMap.SimpleEntry<>("citedResponsibleParty", "citedResponsibleParties"),
+            new AbstractMap.SimpleEntry<>("presentationForm",      "presentationForms"),
+            new AbstractMap.SimpleEntry<>("series",                "series"),
+            new AbstractMap.SimpleEntry<>("otherCitationDetails",  "otherCitationDetails"),
+            new AbstractMap.SimpleEntry<>("collectiveTitle",       "collectiveTitle"),
+            new AbstractMap.SimpleEntry<>("ISBN",                  "ISBN"),
+            new AbstractMap.SimpleEntry<>("ISSN",                  "ISSN")
+        }, map.entrySet().toArray());
+
+        assertEquals("alternateTitles", map.get("alternateTitle"));
+        assertNull("Shall not exists.", map.get("dummy"));
+    }
+
+    /**
+     * Tests the formatting of sentences.
+     */
+    @Test
+    public void testSentences() {
+        final Map<String,String> map, expected = new HashMap<>();
+        map = MetadataStandard.ISO_19115.asNameMap(EnvironmentalRecord.class, JAVABEANS_PROPERTY,
SENTENCE);
+        assertNull(expected.put("averageAirTemperature",    "Average air temperature"));
+        assertNull(expected.put("maxAltitude",              "Max altitude"));
+        assertNull(expected.put("maxRelativeHumidity",      "Max relative humidity"));
+        assertNull(expected.put("meteorologicalConditions", "Meteorological conditions"));
+        assertEquals(expected, map);
+    }
+
+    /**
+     * Ensures that the string are interned. Note that the library will not break if strings
are not interned;
+     * it would just consume more memory than needed. We want to intern those strings because
they usually
+     * match method names or field names, which are already interned by the JVM.
+     *
+     * {@section Explicit calls to <code>String.intern()</code>}
+     * I though that annotation strings were interned like any other constants, but it does
not
+     * seem to be the case as of JDK7. To check if a future JDK release still needs explicit
+     * call to {@link String#intern()}, try to remove the "{@code .intern()}" part in the
+     * {@link PropertyAccessor#name(int, KeyNamePolicy)} method and run this test again.
+     */
+    @Test
+    public void testIntern() {
+        String name;
+        Map<String,String> map;
+        /*
+         * Tests explicit intern.
+         */
+        map = MetadataStandard.ISO_19115.asNameMap(EnvironmentalRecord.class, SENTENCE, JAVABEANS_PROPERTY);
+        name = map.get("Average air temperature");
+        assertEquals("averageAirTemperature", name);
+        assertSame  ("averageAirTemperature", name);
+        /*
+         * Tests implicit intern.
+         */
+        map = MetadataStandard.ISO_19115.asNameMap(EnvironmentalRecord.class, SENTENCE, METHOD_NAME);
+        name = map.get("Average air temperature");
+        assertEquals("getAverageAirTemperature", name);
+        assertSame  ("getAverageAirTemperature", name);
+        /*
+         * Tests an other intern.
+         */
+        map = MetadataStandard.ISO_19115.asNameMap(EnvironmentalRecord.class, SENTENCE, UML_IDENTIFIER);
+        name = map.get("Average air temperature");
+        assertEquals("averageAirTemperature", name);
+        assertSame  ("averageAirTemperature", name);
+    }
+}

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

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

Modified: sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyAccessorTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyAccessorTest.java?rev=1469826&r1=1469825&r2=1469826&view=diff
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyAccessorTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyAccessorTest.java
[UTF-8] Fri Apr 19 13:37:11 2013
@@ -143,11 +143,11 @@ public final strictfp class PropertyAcce
      * Tests the constructor with the {@link DefaultCitation} implementation.
      * The order of properties shall be the order declared in the {@code XmlType.propOrder}
annotation.
      * This test may need to be updated if a future GeoAPI release modifies the {@link Citation}
interface.
-     * Other tests that depends on {@link Citation} property order are {@link MetadataStandardTest#testNameMap()}
-     * and {@link MetadataStandardTest#testTypeMap()}</p>
+     * Other tests that depends on {@link Citation} property order are {@link NameMapTest#testEntrySet()}
+     * and {@link TypeMapTest#testEntrySet()}</p>
      *
-     * @see MetadataStandardTest#testNameMap()
-     * @see MetadataStandardTest#testTypeMap()
+     * @see NameMapTest#testEntrySet()
+     * @see TypeMapTest#testEntrySet()
      */
     @Test
     public void testConstructor() {

Added: sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/TypeMapTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/TypeMapTest.java?rev=1469826&view=auto
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/TypeMapTest.java
(added)
+++ sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/TypeMapTest.java
[UTF-8] Fri Apr 19 13:37:11 2013
@@ -0,0 +1,77 @@
+/*
+ * 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;
+
+import java.util.Map;
+import java.util.AbstractMap;
+import java.util.Date;
+import org.opengis.metadata.Identifier;
+import org.opengis.metadata.citation.Citation;
+import org.opengis.metadata.citation.CitationDate;
+import org.opengis.metadata.citation.PresentationForm;
+import org.opengis.metadata.citation.ResponsibleParty;
+import org.opengis.metadata.citation.Series;
+import org.opengis.util.InternationalString;
+import org.apache.sis.test.DependsOn;
+import org.apache.sis.test.TestCase;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+
+/**
+ * Tests the {@link TypeMap} class on instances created by
+ * {@link MetadataStandard#asTypeMap(Class, KeyNamePolicy, TypeValuePolicy)}.
+ * Unless otherwise specified, all tests use the {@link MetadataStandard#ISO_19115} constant.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.3
+ * @version 0.3
+ * @module
+ */
+@DependsOn(PropertyAccessorTest.class)
+public final strictfp class TypeMapTest extends TestCase {
+    /**
+     * Tests the {@link MetadataStandard#asType(Class, KeyNamePolicy, TypeValuePolicy)} implementation.
+     * The properties used in this test are listed in {@link PropertyAccessorTest#testConstructor()}.
+     *
+     * @see PropertyAccessorTest#testConstructor()
+     */
+    @Test
+    public void testEntrySet() {
+        final Map<String,Class<?>> map = MetadataStandard.ISO_19115.asTypeMap(
+                Citation.class, KeyNamePolicy.UML_IDENTIFIER, TypeValuePolicy.ELEMENT_TYPE);
+        assertArrayEquals(new Object[] {
+            new AbstractMap.SimpleEntry<>("title",                 InternationalString.class),
+            new AbstractMap.SimpleEntry<>("alternateTitle",        InternationalString.class),
+            new AbstractMap.SimpleEntry<>("date",                  CitationDate.class),
+            new AbstractMap.SimpleEntry<>("edition",               InternationalString.class),
+            new AbstractMap.SimpleEntry<>("editionDate",           Date.class),
+            new AbstractMap.SimpleEntry<>("identifier",            Identifier.class),
+            new AbstractMap.SimpleEntry<>("citedResponsibleParty", ResponsibleParty.class),
+            new AbstractMap.SimpleEntry<>("presentationForm",      PresentationForm.class),
+            new AbstractMap.SimpleEntry<>("series",                Series.class),
+            new AbstractMap.SimpleEntry<>("otherCitationDetails",  InternationalString.class),
+            new AbstractMap.SimpleEntry<>("collectiveTitle",       InternationalString.class),
+            new AbstractMap.SimpleEntry<>("ISBN",                  String.class),
+            new AbstractMap.SimpleEntry<>("ISSN",                  String.class)
+        }, map.entrySet().toArray());
+
+        assertEquals(InternationalString.class, map.get("alternateTitle"));
+        assertNull("Shall not exists.", map.get("dummy"));
+    }
+}

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

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

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=1469826&r1=1469825&r2=1469826&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 13:37:11 2013
@@ -18,6 +18,7 @@ package org.apache.sis.test.suite;
 
 import org.apache.sis.test.TestSuite;
 import org.junit.runners.Suite;
+import org.junit.BeforeClass;
 
 
 /**
@@ -32,7 +33,18 @@ import org.junit.runners.Suite;
     org.apache.sis.internal.metadata.MetadataUtilitiesTest.class,
     org.apache.sis.metadata.PropertyInformationTest.class,
     org.apache.sis.metadata.PropertyAccessorTest.class,
+    org.apache.sis.metadata.NameMapTest.class,
+    org.apache.sis.metadata.TypeMapTest.class,
+    org.apache.sis.metadata.InformationMapTest.class,
     org.apache.sis.metadata.MetadataStandardTest.class
 })
 public final strictfp class MetadataTestSuite extends TestSuite {
+    /**
+     * Verifies the list of tests before to run the suite.
+     * See {@link #verifyTestList(Class)} for more information.
+     */
+    @BeforeClass
+    public static void verifyTestList() {
+        verifyTestList(MetadataTestSuite.class);
+    }
 }

Modified: sis/branches/JDK7/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java?rev=1469826&r1=1469825&r2=1469826&view=diff
==============================================================================
--- sis/branches/JDK7/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
[UTF-8] Fri Apr 19 13:37:11 2013
@@ -42,10 +42,11 @@ import org.junit.BeforeClass;
 })
 public final strictfp class ReferencingTestSuite extends TestSuite {
     /**
-     * Verifies the list of tests before the suite is run.
+     * Verifies the list of tests before to run the suite.
+     * See {@link #verifyTestList(Class)} for more information.
      */
     @BeforeClass
     public static void verifyTestList() {
-        verifyTestList(MetadataTestSuite.class);
+        verifyTestList(ReferencingTestSuite.class);
     }
 }

Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java?rev=1469826&r1=1469825&r2=1469826&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java [UTF-8]
(original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java [UTF-8]
Fri Apr 19 13:37:11 2013
@@ -106,7 +106,13 @@ public final class Types extends Static 
             if (uml != null) {
                 final String id = uml.identifier();
                 if (id != null && !id.isEmpty()) {
-                    return id;
+                    /*
+                     * Workaround: I though that annotation strings were interned like any
other constants,
+                     * but it does not seem to be the case as of JDK7.  To verify if this
explicit call to
+                     * String.intern() is still needed in a future JDK release, see the workaround
comment
+                     * in the org.apache.sis.metadata.PropertyAccessor.name(…) method.
+                     */
+                    return id.intern();
                 }
             }
         }

Modified: sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/jaxb/IdentifierMapWithSpecialCasesTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/jaxb/IdentifierMapWithSpecialCasesTest.java?rev=1469826&r1=1469825&r2=1469826&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/jaxb/IdentifierMapWithSpecialCasesTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/jaxb/IdentifierMapWithSpecialCasesTest.java
[UTF-8] Fri Apr 19 13:37:11 2013
@@ -42,7 +42,7 @@ import static org.apache.sis.test.TestUt
  * @version 0.3
  * @module
  */
-@DependsOn(IdentifierMapAdapter.class)
+@DependsOn(IdentifierMapAdapterTest.class)
 public final strictfp class IdentifierMapWithSpecialCasesTest extends IdentifierMapAdapterTest
{
     /**
      * The HREF string to replace by {@link XLink#toString()}.

Modified: sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/test/AssertTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/test/AssertTest.java?rev=1469826&r1=1469825&r2=1469826&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/test/AssertTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/test/AssertTest.java
[UTF-8] Fri Apr 19 13:37:11 2013
@@ -17,6 +17,7 @@
 package org.apache.sis.internal.test;
 
 import org.junit.Test;
+import org.apache.sis.test.TestCase;
 
 import static org.apache.sis.test.Assert.*;
 
@@ -29,7 +30,7 @@ import static org.apache.sis.test.Assert
  * @version 0.3
  * @module
  */
-public final strictfp class AssertTest {
+public final strictfp class AssertTest extends TestCase {
     /**
      * Tests the {@link Assert#assertMultilinesEquals(String, String)} method.
      */

Modified: sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/test/XMLComparatorTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/test/XMLComparatorTest.java?rev=1469826&r1=1469825&r2=1469826&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/test/XMLComparatorTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/test/XMLComparatorTest.java
[UTF-8] Fri Apr 19 13:37:11 2013
@@ -16,6 +16,7 @@
  */
 package org.apache.sis.internal.test;
 
+import org.apache.sis.test.TestCase;
 import org.apache.sis.test.XMLComparator;
 import org.junit.Test;
 
@@ -30,7 +31,7 @@ import static org.junit.Assert.*;
  * @version 0.3
  * @module
  */
-public final strictfp class XMLComparatorTest {
+public final strictfp class XMLComparatorTest extends TestCase {
     /**
      * Tests the {@link XMLComparator#ignoredAttributes} and {@link XMLComparator#ignoredNodes}
      * sets.

Modified: sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/test/TestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/test/TestSuite.java?rev=1469826&r1=1469825&r2=1469826&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/test/TestSuite.java [UTF-8]
(original)
+++ sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/test/TestSuite.java [UTF-8]
Fri Apr 19 13:37:11 2013
@@ -42,6 +42,14 @@ public abstract strictfp class TestSuite
 
     /**
      * Verifies the list of tests before the suite is run.
+     * This method verifies the following conditions:
+     *
+     * <ul>
+     *   <li>Every class shall extend either the SIS {@link TestCase} or the GeoAPI
{@link org.opengis.test.TestCase}.</li>
+     *   <li>No class shall be declared twice.</li>
+     *   <li>If a test depends on another test, then the other test shall be before
the dependant test.</li>
+     * </ul>
+     *
      * Subclasses shall invoke this method as below:
      *
      * {@preformat java
@@ -57,7 +65,7 @@ public abstract strictfp class TestSuite
         final Class<?>[] testCases = suite.getAnnotation(Suite.SuiteClasses.class).value();
         final Map<Class<?>,Boolean> done = new IdentityHashMap<>(testCases.length);
         for (final Class<?> testCase : testCases) {
-            if (!TestCase.class.isAssignableFrom(testCase)) {
+            if (!TestCase.class.isAssignableFrom(testCase) && !org.opengis.test.TestCase.class.isAssignableFrom(testCase))
{
                 fail("Class " + testCase.getCanonicalName() + " does not extends TestCase.");
             }
             final DependsOn dependencies = testCase.getAnnotation(DependsOn.class);

Modified: sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java?rev=1469826&r1=1469825&r2=1469826&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java
[UTF-8] Fri Apr 19 13:37:11 2013
@@ -93,8 +93,8 @@ import org.junit.BeforeClass;
 
     // Converters
     org.apache.sis.internal.converter.AngleConverterTest.class,
-    org.apache.sis.internal.converter.PathConverterTest.class,
     org.apache.sis.internal.converter.StringConverterTest.class,
+    org.apache.sis.internal.converter.PathConverterTest.class,
     org.apache.sis.internal.converter.FallbackConverterTest.class,
     org.apache.sis.internal.converter.ConverterRegistryTest.class,
     org.apache.sis.internal.converter.SystemRegistryTest.class,
@@ -110,10 +110,11 @@ import org.junit.BeforeClass;
 })
 public final strictfp class UtilityTestSuite extends TestSuite {
     /**
-     * Verifies the list of tests before the suite is run.
+     * Verifies the list of tests before to run the suite.
+     * See {@link #verifyTestList(Class)} for more information.
      */
     @BeforeClass
     public static void verifyTestList() {
-        verifyTestList(MetadataTestSuite.class);
+        verifyTestList(UtilityTestSuite.class);
     }
 }

Modified: sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/util/LocalesTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/util/LocalesTest.java?rev=1469826&r1=1469825&r2=1469826&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/util/LocalesTest.java [UTF-8]
(original)
+++ sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/util/LocalesTest.java [UTF-8]
Fri Apr 19 13:37:11 2013
@@ -33,7 +33,7 @@ import static org.junit.Assert.*;
  * @version 0.3
  * @module
  */
-@DependsOn(ArraysExt.class)
+@DependsOn(ArraysExtTest.class)
 public final strictfp class LocalesTest extends TestCase {
     /**
      * Tests the {@link Locales#getAvailableLanguages()} method.



Mime
View raw message