sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1469962 - in /sis/trunk: ./ 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/test/sui...
Date Fri, 19 Apr 2013 17:31:14 GMT
Author: desruisseaux
Date: Fri Apr 19 17:31:14 2013
New Revision: 1469962

URL: http://svn.apache.org/r1469962
Log:
Merge from the JDK6 branch.

Added:
    sis/trunk/sis-metadata/src/test/java/org/apache/sis/metadata/InformationMapTest.java
      - copied unchanged from r1469961, sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/InformationMapTest.java
    sis/trunk/sis-metadata/src/test/java/org/apache/sis/metadata/NameMapTest.java
      - copied unchanged from r1469961, sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/NameMapTest.java
    sis/trunk/sis-metadata/src/test/java/org/apache/sis/metadata/TypeMapTest.java
      - copied unchanged from r1469961, sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/TypeMapTest.java
    sis/trunk/sis-metadata/src/test/java/org/apache/sis/metadata/ValueMapTest.java
      - copied unchanged from r1469961, sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/ValueMapTest.java
Modified:
    sis/trunk/   (props changed)
    sis/trunk/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java
    sis/trunk/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java
    sis/trunk/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyInformation.java
    sis/trunk/sis-metadata/src/main/java/org/apache/sis/metadata/StandardImplementation.java
    sis/trunk/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataStandardTest.java
    sis/trunk/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyAccessorTest.java
    sis/trunk/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
    sis/trunk/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
    sis/trunk/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleReferenceIdentifier.java
    sis/trunk/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java
    sis/trunk/sis-utility/src/main/java/org/apache/sis/util/Numbers.java
    sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/Containers.java
    sis/trunk/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java
    sis/trunk/sis-utility/src/test/java/org/apache/sis/internal/jaxb/IdentifierMapWithSpecialCasesTest.java
    sis/trunk/sis-utility/src/test/java/org/apache/sis/internal/test/AssertTest.java
    sis/trunk/sis-utility/src/test/java/org/apache/sis/internal/test/XMLComparatorTest.java
    sis/trunk/sis-utility/src/test/java/org/apache/sis/test/TestSuite.java
    sis/trunk/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java
    sis/trunk/sis-utility/src/test/java/org/apache/sis/util/LocalesTest.java

Propchange: sis/trunk/
------------------------------------------------------------------------------
  Merged /sis/branches/JDK7:r1469597-1469956
  Merged /sis/branches/JDK6:r1469605-1469961

Modified: sis/trunk/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java?rev=1469962&r1=1469961&r2=1469962&view=diff
==============================================================================
--- sis/trunk/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java [UTF-8]
(original)
+++ sis/trunk/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java [UTF-8]
Fri Apr 19 17:31:14 2013
@@ -32,6 +32,7 @@ import org.apache.sis.util.resources.Err
 import org.apache.sis.util.collection.TreeTable;
 import org.apache.sis.util.collection.CheckedContainer;
 import org.apache.sis.internal.util.SystemListener;
+import org.apache.sis.internal.simple.SimpleCitation;
 
 import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
 
@@ -116,8 +117,8 @@ public class MetadataStandard {
         final String[] acronyms = {"CoordinateSystem", "CS", "CoordinateReferenceSystem",
"CRS"};
         ISO_19111 = new StandardImplementation("ISO 19111", "org.opengis.referencing.", "org.apache.sis.referencing.",
prefix, acronyms);
         ISO_19115 = new StandardImplementation("ISO 19115", "org.opengis.metadata.", "org.apache.sis.metadata.iso.",
prefix, null);
-        ISO_19119 = new StandardImplementation("ISO 19119", "org.opengis.service.",  null,
null, null);
-        ISO_19123 = new StandardImplementation("ISO 19123", "org.opengis.coverage.", null,
null, null);
+        ISO_19119 = new MetadataStandard      ("ISO 19119", "org.opengis.service.");
+        ISO_19123 = new MetadataStandard      ("ISO 19123", "org.opengis.coverage.");
         INSTANCES = new MetadataStandard[] {
             ISO_19111,
             ISO_19115,
@@ -179,8 +180,8 @@ public class MetadataStandard {
      * @param citation         Bibliographical reference to the international standard.
      * @param interfacePackage The root package for metadata interfaces.
      */
-    MetadataStandard(final Citation citation, final String interfacePackage) {
-        this.citation         = citation;
+    MetadataStandard(final String citation, final String interfacePackage) {
+        this.citation         = new SimpleCitation(citation);
         this.interfacePackage = interfacePackage;
         this.accessors        = new IdentityHashMap<Class<?>,Object>();
     }
@@ -520,6 +521,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/trunk/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java?rev=1469962&r1=1469961&r2=1469962&view=diff
==============================================================================
--- sis/trunk/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java [UTF-8]
(original)
+++ sis/trunk/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java [UTF-8]
Fri Apr 19 17:31:14 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.testStringIntern()
method.
+                         */
+                        return uml.identifier().intern();
                     }
                     // Fallthrough
                 }

Modified: sis/trunk/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyInformation.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyInformation.java?rev=1469962&r1=1469961&r2=1469962&view=diff
==============================================================================
--- sis/trunk/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyInformation.java
[UTF-8] (original)
+++ sis/trunk/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyInformation.java
[UTF-8] Fri Apr 19 17:31:14 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;
     }
 

Modified: sis/trunk/sis-metadata/src/main/java/org/apache/sis/metadata/StandardImplementation.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-metadata/src/main/java/org/apache/sis/metadata/StandardImplementation.java?rev=1469962&r1=1469961&r2=1469962&view=diff
==============================================================================
--- sis/trunk/sis-metadata/src/main/java/org/apache/sis/metadata/StandardImplementation.java
[UTF-8] (original)
+++ sis/trunk/sis-metadata/src/main/java/org/apache/sis/metadata/StandardImplementation.java
[UTF-8] Fri Apr 19 17:31:14 2013
@@ -20,7 +20,6 @@ import java.util.Map;
 import java.util.IdentityHashMap;
 import org.apache.sis.util.CharSequences;
 import org.apache.sis.util.logging.Logging;
-import org.apache.sis.internal.simple.SimpleCitation;
 
 
 /**
@@ -79,7 +78,7 @@ final class StandardImplementation exten
     StandardImplementation(final String citation, final String interfacePackage,
             final String implementationPackage, final String[] prefix, final String[] acronyms)
     {
-        super(new SimpleCitation(citation), interfacePackage);
+        super(citation, interfacePackage);
         this.implementationPackage = implementationPackage;
         this.prefix                = prefix;
         this.acronyms              = acronyms;

Modified: sis/trunk/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataStandardTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataStandardTest.java?rev=1469962&r1=1469961&r2=1469962&view=diff
==============================================================================
--- sis/trunk/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataStandardTest.java
[UTF-8] (original)
+++ sis/trunk/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataStandardTest.java
[UTF-8] Fri Apr 19 17:31:14 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,28 @@ 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 (or few) 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, InformationMapTest.class,
+    NameMapTest.class, TypeMapTest.class, ValueMapTest.class})
 public final strictfp class MetadataStandardTest extends TestCase {
     /**
      * Tests {@link MetadataStandard#getInterface(Class)}.
@@ -71,7 +72,7 @@ public final strictfp class MetadataStan
      */
     @Test
     public void testGetWrongInterface() {
-        final MetadataStandard std = new MetadataStandard(HardCodedCitations.ISO, "org.opengis.dummy.");
+        final MetadataStandard std = new MetadataStandard("SIS", "org.apache.sis.dummy.");
         try {
             std.getInterface(DefaultCitation.class);
             fail("No dummy interface expected.");
@@ -124,82 +125,9 @@ 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<String,String>("title",                 "title"),
-            new SimpleEntry<String,String>("alternateTitle",        "alternateTitles"),
-            new SimpleEntry<String,String>("date",                  "dates"),
-            new SimpleEntry<String,String>("edition",               "edition"),
-            new SimpleEntry<String,String>("editionDate",           "editionDate"),
-            new SimpleEntry<String,String>("identifier",            "identifiers"),
-            new SimpleEntry<String,String>("citedResponsibleParty", "citedResponsibleParties"),
-            new SimpleEntry<String,String>("presentationForm",      "presentationForms"),
-            new SimpleEntry<String,String>("series",                "series"),
-            new SimpleEntry<String,String>("otherCitationDetails",  "otherCitationDetails"),
-            new SimpleEntry<String,String>("collectiveTitle",       "collectiveTitle"),
-            new SimpleEntry<String,String>("ISBN",                  "ISBN"),
-            new SimpleEntry<String,String>("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<String,Class<?>>("title",                 InternationalString.class),
-            new SimpleEntry<String,Class<?>>("alternateTitle",        InternationalString.class),
-            new SimpleEntry<String,Class<?>>("date",                  CitationDate.class),
-            new SimpleEntry<String,Class<?>>("edition",               InternationalString.class),
-            new SimpleEntry<String,Class<?>>("editionDate",           Date.class),
-            new SimpleEntry<String,Class<?>>("identifier",            Identifier.class),
-            new SimpleEntry<String,Class<?>>("citedResponsibleParty", ResponsibleParty.class),
-            new SimpleEntry<String,Class<?>>("presentationForm",      PresentationForm.class),
-            new SimpleEntry<String,Class<?>>("series",                Series.class),
-            new SimpleEntry<String,Class<?>>("otherCitationDetails",  InternationalString.class),
-            new SimpleEntry<String,Class<?>>("collectiveTitle",       InternationalString.class),
-            new SimpleEntry<String,Class<?>>("ISBN",                  String.class),
-            new SimpleEntry<String,Class<?>>("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.
+     * This test duplicates {@link ValueMapTest}, but is done here again as an integration
test and because many
+     * {@code MetadataStandard} methods depend on it ({@code equals}, {@code hashCode}, {@code
prune}, <i>etc.</i>).
      */
     @Test
     public void testValueMap() {

Modified: sis/trunk/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyAccessorTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyAccessorTest.java?rev=1469962&r1=1469961&r2=1469962&view=diff
==============================================================================
--- sis/trunk/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyAccessorTest.java
[UTF-8] (original)
+++ sis/trunk/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyAccessorTest.java
[UTF-8] Fri Apr 19 17:31:14 2013
@@ -143,11 +143,12 @@ 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()},
+     * {@link TypeMapTest#testEntrySet()} and most tests in {@link ValueMapTest}.
      *
-     * @see MetadataStandardTest#testNameMap()
-     * @see MetadataStandardTest#testTypeMap()
+     * @see NameMapTest#testEntrySet()
+     * @see TypeMapTest#testEntrySet()
+     * @see ValueMapTest
      */
     @Test
     public void testConstructor() {

Modified: sis/trunk/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java?rev=1469962&r1=1469961&r2=1469962&view=diff
==============================================================================
--- sis/trunk/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
[UTF-8] (original)
+++ sis/trunk/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
[UTF-8] Fri Apr 19 17:31:14 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,19 @@ 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.ValueMapTest.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/trunk/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java?rev=1469962&r1=1469961&r2=1469962&view=diff
==============================================================================
--- sis/trunk/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
[UTF-8] (original)
+++ sis/trunk/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
[UTF-8] Fri Apr 19 17:31:14 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;
 
 
 /**
@@ -40,4 +41,12 @@ import org.junit.runners.Suite;
     org.apache.sis.geometry.Envelope2DTest.class
 })
 public final strictfp class ReferencingTestSuite 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(ReferencingTestSuite.class);
+    }
 }

Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleReferenceIdentifier.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleReferenceIdentifier.java?rev=1469962&r1=1469961&r2=1469962&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleReferenceIdentifier.java
[UTF-8] (original)
+++ sis/trunk/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleReferenceIdentifier.java
[UTF-8] Fri Apr 19 17:31:14 2013
@@ -151,7 +151,7 @@ public class SimpleReferenceIdentifier i
      */
     @Override
     public int hashCode() {
-        return Objects.hash(authority, code);
+        return Objects.hash(authority, code) ^ (int) serialVersionUID;
     }
 
     /**

Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java?rev=1469962&r1=1469961&r2=1469962&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java [UTF-8]
(original)
+++ sis/trunk/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java [UTF-8]
Fri Apr 19 17:31:14 2013
@@ -18,6 +18,7 @@ package org.apache.sis.internal.util;
 
 import java.util.*;
 import org.apache.sis.util.Static;
+import org.apache.sis.util.collection.CodeListSet;
 
 
 /**
@@ -28,7 +29,7 @@ import org.apache.sis.util.Static;
  * <ul>
  *   <li>{@link #toCollection(Object) toCollection} for wrapping or copying arbitrary
objects to
  *       list or collection.</li>
- *   <li>{@link #modifiableCopy(Collection) modifiableCopy} method for taking a snapshot
of an arbitrary
+ *   <li>{@link #copy(Collection, boolean) copy} method for taking a snapshot of an
arbitrary
  *       implementation into an unsynchronized, modifiable, in-memory object.</li>
  *   <li>{@link #unmodifiableOrCopy(Set) unmodifiableOrCopy} methods, which may be
slightly more
  *       compact than the standard {@link Collections#unmodifiableSet(Set)} equivalent
@@ -193,6 +194,8 @@ public final class CollectionsExt extend
      * <tr><td>{@link List} or other {@link Collection}</td><td class="sep">{@link
ArrayList}</td></tr>
      * </table>
      *
+     * This method may not preserve the {@link org.apache.sis.util.collection.CheckedContainer}
interface.
+     *
      * @param  <E> The type of elements in the collection.
      * @param  collection The collection to copy, or {@code null}.
      * @return A copy of the given collection, or {@code null} if the given collection was
null.
@@ -217,6 +220,12 @@ public final class CollectionsExt extend
             if (type == HashSet.class || type == LinkedHashSet.class) {
                 return (Collection<E>) ((HashSet<E>) collection).clone();
             }
+            if (collection instanceof EnumSet<?>) {
+                return ((EnumSet) collection).clone();
+            }
+            if (collection instanceof CodeListSet<?>) {
+                return ((CodeListSet) collection).clone();
+            }
             return new LinkedHashSet<E>(collection);
         }
         if (collection instanceof Queue<?>) {

Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/util/Numbers.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/util/Numbers.java?rev=1469962&r1=1469961&r2=1469962&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/main/java/org/apache/sis/util/Numbers.java [UTF-8] (original)
+++ sis/trunk/sis-utility/src/main/java/org/apache/sis/util/Numbers.java [UTF-8] Fri Apr 19
17:31:14 2013
@@ -61,7 +61,7 @@ public final class Numbers extends Stati
      *        less objects since <code>IdentityHashMap</code> implementation
doesn't need the chain
      *        of objects created by <code>HashMap</code>.}
      */
-    private static final Map<Class<?>,Numbers> MAPPING = new IdentityHashMap<Class<?>,Numbers>(16);
+    private static final Map<Class<?>,Numbers> MAPPING = new IdentityHashMap<Class<?>,Numbers>(11);
     static {
         new Numbers(BigDecimal.class, true, false, BIG_DECIMAL);
         new Numbers(BigInteger.class, false, true, BIG_INTEGER);

Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/Containers.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/Containers.java?rev=1469962&r1=1469961&r2=1469962&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/Containers.java [UTF-8]
(original)
+++ sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/Containers.java [UTF-8]
Fri Apr 19 17:31:14 2013
@@ -216,7 +216,8 @@ public final class Containers extends St
      * for the default <cite>load factor</cite>, which is 0.75.
      *
      * <p>The same calculation can be used for {@link java.util.LinkedHashMap} and
-     * {@link java.util.HashSet} as well, which are built on top of {@code HashMap}.</p>
+     * {@link java.util.HashSet} as well, which are built on top of {@code HashMap}.
+     * However it is not needed for {@link java.util.IdentityHashMap}.</p>
      *
      * @param count The number of elements to be put into the hash map or hash set.
      * @return The minimal initial capacity to be given to the hash map constructor.

Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java?rev=1469962&r1=1469961&r2=1469962&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java [UTF-8] (original)
+++ sis/trunk/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java [UTF-8] Fri Apr
19 17:31:14 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/trunk/sis-utility/src/test/java/org/apache/sis/internal/jaxb/IdentifierMapWithSpecialCasesTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/internal/jaxb/IdentifierMapWithSpecialCasesTest.java?rev=1469962&r1=1469961&r2=1469962&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/test/java/org/apache/sis/internal/jaxb/IdentifierMapWithSpecialCasesTest.java
[UTF-8] (original)
+++ sis/trunk/sis-utility/src/test/java/org/apache/sis/internal/jaxb/IdentifierMapWithSpecialCasesTest.java
[UTF-8] Fri Apr 19 17:31:14 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/trunk/sis-utility/src/test/java/org/apache/sis/internal/test/AssertTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/internal/test/AssertTest.java?rev=1469962&r1=1469961&r2=1469962&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/test/java/org/apache/sis/internal/test/AssertTest.java [UTF-8]
(original)
+++ sis/trunk/sis-utility/src/test/java/org/apache/sis/internal/test/AssertTest.java [UTF-8]
Fri Apr 19 17:31:14 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/trunk/sis-utility/src/test/java/org/apache/sis/internal/test/XMLComparatorTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/internal/test/XMLComparatorTest.java?rev=1469962&r1=1469961&r2=1469962&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/test/java/org/apache/sis/internal/test/XMLComparatorTest.java
[UTF-8] (original)
+++ sis/trunk/sis-utility/src/test/java/org/apache/sis/internal/test/XMLComparatorTest.java
[UTF-8] Fri Apr 19 17:31:14 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/trunk/sis-utility/src/test/java/org/apache/sis/test/TestSuite.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/test/TestSuite.java?rev=1469962&r1=1469961&r2=1469962&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/test/java/org/apache/sis/test/TestSuite.java [UTF-8] (original)
+++ sis/trunk/sis-utility/src/test/java/org/apache/sis/test/TestSuite.java [UTF-8] Fri Apr
19 17:31:14 2013
@@ -16,9 +16,13 @@
  */
 package org.apache.sis.test;
 
+import java.util.Map;
+import java.util.IdentityHashMap;
 import org.junit.runner.RunWith;
 import org.junit.runners.Suite;
 
+import static org.junit.Assert.*;
+
 
 /**
  * Base class of Apache SIS test suites (except the ones that extend GeoAPI suites).
@@ -35,4 +39,47 @@ public abstract strictfp class TestSuite
      */
     protected 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
+     *    &#64;BeforeClass
+     *    public static void verifyTestList() {
+     *        verifyTestList(MetadataTestSuite.class);
+     *    }
+     * }
+     *
+     * @param suite The suite for which to verify order.
+     */
+    protected static void verifyTestList(final Class<? extends TestSuite> suite) {
+        final Class<?>[] testCases = suite.getAnnotation(Suite.SuiteClasses.class).value();
+        final Map<Class<?>,Boolean> done = new IdentityHashMap<Class<?>,Boolean>(testCases.length);
+        for (final Class<?> testCase : testCases) {
+            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);
+            if (dependencies != null) {
+                for (final Class<?> dependency : dependencies.value()) {
+                    if (!done.containsKey(dependency)) {
+                        fail("Class " + testCase.getCanonicalName() + " depends on " + dependency.getCanonicalName()
+                                + ", but the dependency has not been found before the test.");
+                    }
+                }
+            }
+            if (done.put(testCase, Boolean.TRUE) != null) {
+                fail("Class " + testCase.getCanonicalName() + " is declared twice.");
+            }
+        }
+    }
 }

Modified: sis/trunk/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java?rev=1469962&r1=1469961&r2=1469962&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java [UTF-8]
(original)
+++ sis/trunk/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java [UTF-8]
Fri Apr 19 17:31:14 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;
 
 
 /**
@@ -92,8 +93,8 @@ import org.junit.runners.Suite;
 
     // 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,
@@ -108,4 +109,12 @@ import org.junit.runners.Suite;
     org.apache.sis.internal.jaxb.IdentifierMapWithSpecialCasesTest.class
 })
 public final strictfp class UtilityTestSuite 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(UtilityTestSuite.class);
+    }
 }

Modified: sis/trunk/sis-utility/src/test/java/org/apache/sis/util/LocalesTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/util/LocalesTest.java?rev=1469962&r1=1469961&r2=1469962&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/test/java/org/apache/sis/util/LocalesTest.java [UTF-8] (original)
+++ sis/trunk/sis-utility/src/test/java/org/apache/sis/util/LocalesTest.java [UTF-8] Fri Apr
19 17:31:14 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