sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] 01/02: Fix the unmarshalling of <gmd:characterSet> attribute from legacy XML documents. https://issues.apache.org/jira/browse/SIS-402
Date Sun, 05 May 2019 15:40:38 GMT
This is an automated email from the ASF dual-hosted git repository.

desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git

commit f8f18f125834daa0c78cfc9a0198ad15152aa26d
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Sun May 5 16:37:57 2019 +0200

    Fix the unmarshalling of <gmd:characterSet> attribute from legacy XML documents.
    https://issues.apache.org/jira/browse/SIS-402
---
 .../apache/sis/internal/jaxb/cat/CodeListUID.java  |  3 +-
 .../sis/internal/jaxb/code/LegacyCharacterSet.java | 90 ----------------------
 .../apache/sis/metadata/iso/DefaultMetadata.java   | 88 +++++++++++----------
 .../org/apache/sis/metadata/iso/package-info.java  |  2 +-
 .../main/java/org/apache/sis/util/iso/Types.java   |  6 +-
 .../java/org/apache/sis/xml/ValueConverter.java    |  2 +-
 .../org/apache/sis/xml/RenameOnExport.lst          |  2 +-
 .../org/apache/sis/xml/RenameOnImport.lst          |  2 +-
 .../sis/metadata/PropertyConsistencyCheck.java     |  6 +-
 .../sis/metadata/iso/DefaultMetadataTest.java      | 10 ---
 .../apache/sis/test/integration/MetadataTest.java  |  9 ---
 .../apache/sis/internal/storage/xml/StoreTest.java |  2 +
 12 files changed, 61 insertions(+), 161 deletions(-)

diff --git a/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/cat/CodeListUID.java
b/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/cat/CodeListUID.java
index 05d8053..36444c9 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/cat/CodeListUID.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/cat/CodeListUID.java
@@ -171,8 +171,7 @@ public final class CodeListUID {
         } else {
             /*
              * Fallback when no value is defined for the code list. Build a value from the
-             * most descriptive name (excluding the field name), which is usually the UML
-             * name except for CharacterSet in which case it is a string like "UTF-8".
+             * most descriptive name (excluding the field name), which is usually the UML.
              */
             value = Types.getCodeLabel(code);
         }
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/code/LegacyCharacterSet.java
b/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/code/LegacyCharacterSet.java
deleted file mode 100644
index 7d1c950..0000000
--- a/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/code/LegacyCharacterSet.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * 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.internal.jaxb.code;
-
-import javax.xml.bind.annotation.XmlElement;
-import org.opengis.metadata.identification.CharacterSet;
-import org.apache.sis.internal.jaxb.cat.CodeListAdapter;
-import org.apache.sis.internal.jaxb.cat.CodeListUID;
-import org.apache.sis.internal.xml.LegacyNamespaces;
-
-
-/**
- * JAXB adapter for {@link CharacterSet}
- * in order to wrap the value in an XML element as specified by ISO 19115-3 standard.
- * See package documentation for more information about the handling of {@code CodeList}
in ISO 19115-3.
- *
- * @author  Cédric Briançon (Geomatys)
- * @version 1.0
- * @since   0.3
- * @module
- */
-@SuppressWarnings("deprecation")
-public final class LegacyCharacterSet extends CodeListAdapter<LegacyCharacterSet, CharacterSet>
{
-    /**
-     * Empty constructor for JAXB only.
-     */
-    public LegacyCharacterSet() {
-    }
-
-    /**
-     * Creates a new adapter for the given value.
-     */
-    private LegacyCharacterSet(final CodeListUID value) {
-        super(value);
-    }
-
-    /**
-     * {@inheritDoc}
-     *
-     * @return the wrapper for the code list value.
-     */
-    @Override
-    protected LegacyCharacterSet wrap(final CodeListUID value) {
-        return new LegacyCharacterSet(value);
-    }
-
-    /**
-     * {@inheritDoc}
-     *
-     * @return the code list class.
-     */
-    @Override
-    protected Class<CharacterSet> getCodeListClass() {
-        return CharacterSet.class;
-    }
-
-    /**
-     * Invoked by JAXB on marshalling.
-     *
-     * @return the value to be marshalled.
-     */
-    @Override
-    @XmlElement(name = "MD_CharacterSetCode", namespace = LegacyNamespaces.GMD)
-    public CodeListUID getElement() {
-        return identifier;
-    }
-
-    /**
-     * Invoked by JAXB on unmarshalling.
-     *
-     * @param  value  the unmarshalled value.
-     */
-    public void setElement(final CodeListUID value) {
-        identifier = value;
-    }
-}
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultMetadata.java
b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultMetadata.java
index 4347249..92e9b02 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultMetadata.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultMetadata.java
@@ -148,7 +148,7 @@ import org.apache.sis.math.FunctionProperty;
     // Legacy ISO 19115:2003 attributes
     "fileIdentifier",
     "language",
-    "characterSet",
+    "charset",
     "parentIdentifier",
     "hierarchyLevels",
     "hierarchyLevelNames",
@@ -479,30 +479,18 @@ public class DefaultMetadata extends ISOMetadata implements Metadata
{
 
     /**
      * Returns the language(s) and character set(s) used for documenting metadata.
-     * The first element in iteration order is the default language.
-     * All other elements, if any, are alternate language(s) used within the resource.
+     * The first entry in iteration order is the default language and its character set.
+     * All other entries, if any, are alternate language(s) and character set(s) used within
the resource.
      *
      * <p>Unless another locale has been specified with the {@link org.apache.sis.xml.XML#LOCALE}
property,
      * this {@code DefaultMetadata} instance and its children will use the first locale returned
by this method
      * for marshalling {@link org.opengis.util.InternationalString} and {@link org.opengis.util.CodeList}
instances
      * in ISO 19115-2 compliant XML documents.</p>
      *
-     * <div class="section">Relationship with ISO 19115</div>
-     * Each ({@link Locale}, {@link Charset}) entry is equivalent to an instance of ISO {@code
PT_Locale} class.
-     * ISO 19115-1:2014 represents character sets by references to the
-     * <a href="http://www.iana.org/assignments/character-sets">IANA Character Set
register</a>,
-     * which is represented in Java by {@link java.nio.charset.Charset}.
-     * Instances can be obtained by a call to {@link Charset#forName(String)}.
-     *
-     * <div class="note"><b>Examples:</b>
-     * {@code UCS-2}, {@code UCS-4}, {@code UTF-7}, {@code UTF-8}, {@code UTF-16},
-     * {@code ISO-8859-1} (a.k.a. {@code ISO-LATIN-1}), {@code ISO-8859-2}, {@code ISO-8859-3},
{@code ISO-8859-4},
-     * {@code ISO-8859-5}, {@code ISO-8859-6}, {@code ISO-8859-7}, {@code ISO-8859-8}, {@code
ISO-8859-9},
-     * {@code ISO-8859-10}, {@code ISO-8859-11}, {@code ISO-8859-12}, {@code ISO-8859-13},
{@code ISO-8859-14},
-     * {@code ISO-8859-15}, {@code ISO-8859-16},
-     * {@code JIS_X0201}, {@code Shift_JIS}, {@code EUC-JP}, {@code US-ASCII}, {@code EBCDIC},
{@code EUC-KR},
-     * {@code Big5}, {@code GB2312}.
-     * </div>
+     * <p>Each ({@link Locale}, {@link Charset}) entry is equivalent to an instance
of ISO 19115 {@code PT_Locale}
+     * class. The language code and the character set are mandatory elements in ISO standard.
Consequently this map
+     * should not contain null key or null values, but Apache SIS implementations is tolerant
for historical reasons.
+     * The same character set may be associated to many languages.</p>
      *
      * @return language(s) and character set(s) used for documenting metadata.
      *
@@ -542,7 +530,7 @@ public class DefaultMetadata extends ISOMetadata implements Metadata {
      *
      * @since 0.5
      *
-     * @deprecated Replaced by {@code getLocalesAndCharsets().keySet()}.
+     * @deprecated Replaced by <code>{@linkplain #getLocalesAndCharsets()}.keySet()</code>.
      */
     @Deprecated
     @Dependencies("getLocalesAndCharsets")
@@ -573,7 +561,7 @@ public class DefaultMetadata extends ISOMetadata implements Metadata {
      *
      * @return language used for documenting metadata, or {@code null}.
      *
-     * @deprecated As of SIS 0.5, replaced by {@link #getLanguages()}.
+     * @deprecated Replaced by <code>{@linkplain #getLocalesAndCharsets()}.keySet()</code>.
      */
     @Override
     @Deprecated
@@ -598,7 +586,7 @@ public class DefaultMetadata extends ISOMetadata implements Metadata {
      *
      * @param  newValue  the new language.
      *
-     * @deprecated As of SIS 0.5, replaced by {@link #setLanguages(Collection)}.
+     * @deprecated Replaced by <code>{@linkplain #getLocalesAndCharsets()}.put(newValue,
…)</code>.
      */
     @Deprecated
     public void setLanguage(final Locale newValue) {
@@ -610,7 +598,7 @@ public class DefaultMetadata extends ISOMetadata implements Metadata {
      *
      * @return alternatively used localized character string for a linguistic extension.
      *
-     * @deprecated As of SIS 0.5, replaced by {@link #getLanguages()}.
+     * @deprecated Replaced by <code>{@linkplain #getLocalesAndCharsets()}.keySet()</code>.
      */
     @Override
     @Deprecated
@@ -657,7 +645,7 @@ public class DefaultMetadata extends ISOMetadata implements Metadata {
      *
      * @since 0.5
      *
-     * @deprecated Replaced by {@code getLocalesAndCharsets().values()}.
+     * @deprecated Replaced by <code>{@linkplain #getLocalesAndCharsets()}.values()</code>.
      */
     @Deprecated
     @Dependencies("getLocalesAndCharsets")
@@ -686,27 +674,25 @@ public class DefaultMetadata extends ISOMetadata implements Metadata
{
      *
      * @return character coding standard used for the metadata, or {@code null}.
      *
-     * @deprecated As of SIS 0.5, replaced by {@link #getCharacterSets()}.
+     * @deprecated Replaced by <code>{@linkplain #getLocalesAndCharsets()}.values()</code>.
      */
     @Override
     @Deprecated
     @Dependencies("getLocalesAndCharsets")
-    @XmlElement(name = "characterSet", namespace = LegacyNamespaces.GMD)
+    // @XmlElement at the end of this class.
     public CharacterSet getCharacterSet() {
-        if (FilterByVersion.LEGACY_METADATA.accept()) {
-            final Charset cs = LegacyPropertyAdapter.getSingleton(getCharacterSets(),
-                    Charset.class, null, DefaultMetadata.class, "getCharacterSet");
-            if (cs != null) {
-                final String name = cs.name();
-                for (final CharacterSet candidate : CharacterSet.values()) {
-                    for (final String n : candidate.names()) {
-                        if (name.equals(n)) {
-                            return candidate;
-                        }
+        final Charset cs = LegacyPropertyAdapter.getSingleton(getCharacterSets(),
+                Charset.class, null, DefaultMetadata.class, "getCharacterSet");
+        if (cs != null) {
+            final String name = cs.name();
+            for (final CharacterSet candidate : CharacterSet.values()) {
+                for (final String n : candidate.names()) {
+                    if (name.equals(n)) {
+                        return candidate;
                     }
                 }
-                return CharacterSet.valueOf(name);
             }
+            return CharacterSet.valueOf(name);
         }
         return null;
     }
@@ -716,7 +702,7 @@ public class DefaultMetadata extends ISOMetadata implements Metadata {
      *
      * @param  newValue  the new character set.
      *
-     * @deprecated As of SIS 0.5, replaced by {@link #setCharacterSets(Collection)}.
+     * @deprecated Replaced by <code>{@linkplain #getLocalesAndCharsets()}.put(…,
newValue)</code>.
      */
     @Deprecated
     public void setCharacterSet(final CharacterSet newValue) {
@@ -1621,7 +1607,7 @@ public class DefaultMetadata extends ISOMetadata implements Metadata
{
     }
 
     /**
-     * Gets the default locale for this record (used in ISO 19115-3 format).
+     * Gets the default locale for this record (used in ISO 19115-3:2016 format).
      */
     @XmlElement(name = "defaultLocale")
     private PT_Locale getDefaultLocale() {
@@ -1629,14 +1615,14 @@ public class DefaultMetadata extends ISOMetadata implements Metadata
{
     }
 
     /**
-     * Sets the default locale for this record (used in ISO 19115-3 format).
+     * Sets the default locale for this record (used in ISO 19115-3:2016 format).
      */
     private void setDefaultLocale(final PT_Locale newValue) {
         setLocalesAndCharsets(OtherLocales.setFirst(locales, newValue));
     }
 
     /**
-     * Gets the other locales for this record (used in ISO 19115-3 format).
+     * Gets the other locales for this record (used in ISO 19115-3:2016 format).
      */
     @XmlElement(name = "otherLocale")
     private Collection<PT_Locale> getOtherLocales() {
@@ -1644,6 +1630,26 @@ public class DefaultMetadata extends ISOMetadata implements Metadata
{
     }
 
     /**
+     * Returns the character coding for the metadata set (used in legacy ISO 19157 format).
+     */
+    @Dependencies("getLocalesAndCharsets")
+    @XmlElement(name = "characterSet", namespace = LegacyNamespaces.GMD)
+    private Charset getCharset() {
+        if (FilterByVersion.LEGACY_METADATA.accept()) {
+            return LegacyPropertyAdapter.getSingleton(getCharacterSets(),
+                    Charset.class, null, DefaultMetadata.class, "getCharacterSet");
+        }
+        return null;
+    }
+
+    /**
+     * Sets the character coding standard for the metadata set (used in legacy ISO 19157
format).
+     */
+    private void setCharset(final Charset newValue) {
+        setCharacterSets(LegacyPropertyAdapter.asCollection(newValue));
+    }
+
+    /**
      * Invoked by JAXB at both marshalling and unmarshalling time.
      * This attribute has been added by ISO 19115:2014 standard.
      * If (and only if) marshalling an older standard version, we omit this attribute.
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/package-info.java
b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/package-info.java
index 70c9f1e..b630224 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/package-info.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/package-info.java
@@ -109,6 +109,7 @@
     @XmlJavaTypeAdapter(GO_Integer.class),
     @XmlJavaTypeAdapter(LI_Lineage.class),
     @XmlJavaTypeAdapter(MD_ApplicationSchemaInformation.class),
+    @XmlJavaTypeAdapter(MD_CharacterSetCode.class),
     @XmlJavaTypeAdapter(MD_Constraints.class),
     @XmlJavaTypeAdapter(MD_ContentInformation.class),
     @XmlJavaTypeAdapter(MD_DatatypeCode.class),
@@ -124,7 +125,6 @@
     @XmlJavaTypeAdapter(MD_SpatialRepresentation.class),
     @XmlJavaTypeAdapter(MI_AcquisitionInformation.class),
     @XmlJavaTypeAdapter(RS_ReferenceSystem.class),
-    @XmlJavaTypeAdapter(LegacyCharacterSet.class),
 
     // Java types, primitive types and basic OGC types handling
     @XmlJavaTypeAdapter(StringAdapter.class),
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/util/iso/Types.java b/core/sis-metadata/src/main/java/org/apache/sis/util/iso/Types.java
index 930e1c0..2c22494 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/util/iso/Types.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/util/iso/Types.java
@@ -168,7 +168,7 @@ public final class Types extends Static {
      * <ul>
      *   <li>{@code getListName(ParameterDirection.IN_OUT)}      returns {@code "SV_ParameterDirection"}.</li>
      *   <li>{@code getListName(AxisDirection.NORTH)}            returns {@code "CS_AxisDirection"}.</li>
-     *   <li>{@code getListName(CharacterSet.UTF_8)}             returns {@code "MD_CharacterSetCode"}.</li>
+     *   <li>{@code getListName(TopicCategory.INLAND_WATERS)}    returns {@code "MD_TopicCategoryCode"}.</li>
      *   <li>{@code getListName(ImagingCondition.BLURRED_IMAGE)} returns {@code "MD_ImagingConditionCode"}.</li>
      * </ul>
      * </div>
@@ -193,7 +193,7 @@ public final class Types extends Static {
      * <ul>
      *   <li>{@code getCodeName(ParameterDirection.IN_OUT)}      returns {@code "in/out"}.</li>
      *   <li>{@code getCodeName(AxisDirection.NORTH)}            returns {@code "north"}.</li>
-     *   <li>{@code getCodeName(CharacterSet.UTF_8)}             returns {@code "utf8"}.</li>
+     *   <li>{@code getCodeName(TopicCategory.INLAND_WATERS)}    returns {@code "inlandWaters"}.</li>
      *   <li>{@code getCodeName(ImagingCondition.BLURRED_IMAGE)} returns {@code "blurredImage"}.</li>
      * </ul>
      * </div>
@@ -227,7 +227,7 @@ public final class Types extends Static {
      * <div class="note"><b>Examples:</b>
      * <ul>
      *   <li>{@code getCodeLabel(AxisDirection.NORTH)} returns {@code "North"}.</li>
-     *   <li>{@code getCodeLabel(CharacterSet.UTF_8)} returns {@code "UTF-8"}.</li>
+     *   <li>{@code getCodeLabel(TopicCategory.INLAND_WATERS)} returns {@code "Inland
waters"}.</li>
      *   <li>{@code getCodeLabel(ImagingCondition.BLURRED_IMAGE)} returns {@code "Blurred
image"}.</li>
      * </ul>
      * </div>
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/xml/ValueConverter.java b/core/sis-metadata/src/main/java/org/apache/sis/xml/ValueConverter.java
index d4c0dcb..9a1a779 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/xml/ValueConverter.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/xml/ValueConverter.java
@@ -65,7 +65,7 @@ import static org.apache.sis.util.CharSequences.trimWhitespaces;
  * See the {@link XML#CONVERTER} javadoc for an example of registering a custom
  * {@code ValueConverter} to a (un)marshaller.
  *
- * @author Martin Desruisseaux (Geomatys)
+ * @author  Martin Desruisseaux (Geomatys)
  * @version 0.5
  * @since   0.3
  * @module
diff --git a/core/sis-metadata/src/main/resources/org/apache/sis/xml/RenameOnExport.lst b/core/sis-metadata/src/main/resources/org/apache/sis/xml/RenameOnExport.lst
index 2ea16d3..864de96 100644
--- a/core/sis-metadata/src/main/resources/org/apache/sis/xml/RenameOnExport.lst
+++ b/core/sis-metadata/src/main/resources/org/apache/sis/xml/RenameOnExport.lst
@@ -1,7 +1,7 @@
 # Licensed to the Apache Software Foundation (ASF) under one or more contributor license
agreements;
 # and to You under the Apache License, Version 2.0.
 #
-# See readme.html is source code for the syntax of this file.
+# See readme.html in Java source code directory for the syntax of this file.
 #
 http://www.isotc211.org/2005/gmd
  MD_Georectified
diff --git a/core/sis-metadata/src/main/resources/org/apache/sis/xml/RenameOnImport.lst b/core/sis-metadata/src/main/resources/org/apache/sis/xml/RenameOnImport.lst
index 8687283..9ba0fb4 100644
--- a/core/sis-metadata/src/main/resources/org/apache/sis/xml/RenameOnImport.lst
+++ b/core/sis-metadata/src/main/resources/org/apache/sis/xml/RenameOnImport.lst
@@ -1,7 +1,7 @@
 # Licensed to the Apache Software Foundation (ASF) under one or more contributor license
agreements;
 # and to You under the Apache License, Version 2.0.
 #
-# See readme.html is source code for the syntax of this file.
+# See readme.html in Java source code directory for the syntax of this file.
 #
 # Apply to:
 * http://standards.iso.org/iso/19115/-2/gmi/1.0
diff --git a/core/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyConsistencyCheck.java
b/core/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyConsistencyCheck.java
index 4f73282..b9c6cea 100644
--- a/core/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyConsistencyCheck.java
+++ b/core/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyConsistencyCheck.java
@@ -22,6 +22,7 @@ import java.util.Random;
 import java.util.Collection;
 import java.util.Map;
 import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
 import org.opengis.util.CodeList;
 import org.opengis.util.ControlledVocabulary;
 import org.apache.sis.util.Numbers;
@@ -374,11 +375,12 @@ public abstract strictfp class PropertyConsistencyCheck extends AnnotationConsis
                             names = standard.asNameMap(type, KeyNamePolicy.JAVABEANS_PROPERTY,
KeyNamePolicy.METHOD_NAME);
                         }
                         /*
-                         * Currently, @Dependencies is applied only on deprecated getter
methods.
+                         * Currently, @Dependencies is applied mostly on deprecated getter
methods.
                          * However this policy may change in future Apache SIS versions.
                          */
                         assertTrue(name, name.startsWith("get"));
-                        assertTrue(name, method.isAnnotationPresent(Deprecated.class));
+                        assertTrue(name, method.isAnnotationPresent(Deprecated.class)
+                                         || Modifier.isPrivate(method.getModifiers()));
                         /*
                          * All dependencies shall be non-deprecated methods. Combined with
above
                          * restriction about @Dependencies applied only on deprected methods,
this
diff --git a/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/DefaultMetadataTest.java
b/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/DefaultMetadataTest.java
index 8fd3d7f..4d0102a 100644
--- a/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/DefaultMetadataTest.java
+++ b/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/DefaultMetadataTest.java
@@ -56,16 +56,6 @@ import static org.apache.sis.test.TestUtilities.getSingleton;
 @DependsOn(org.apache.sis.internal.jaxb.lan.OtherLocalesTest.class)
 public final strictfp class DefaultMetadataTest extends TestCase {
     /**
-     * A flag for tracing workarounds for allowing some tests to pass despite regression.
-     * This boolean should be set to {@code false} and removed after the following issues
has been fixed:
-     *
-     * <ul>
-     *   <li><a href="https://issues.apache.org/jira/browse/SIS-402">SIS-402</a></li>
-     * </ul>
-     */
-    public static final boolean REGRESSION = true;
-
-    /**
      * Tests unmarshalling of a metadata having a collection that contains no element.
      * This was used to cause a {@code NullPointerException} prior SIS-139 fix.
      *
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/test/integration/MetadataTest.java
b/core/sis-referencing/src/test/java/org/apache/sis/test/integration/MetadataTest.java
index 0e7c530..67cc8ee 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/test/integration/MetadataTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/test/integration/MetadataTest.java
@@ -88,7 +88,6 @@ import org.junit.Test;
 
 import static org.apache.sis.test.Assert.*;
 import static org.apache.sis.test.TestUtilities.getSingleton;
-import static org.apache.sis.metadata.iso.DefaultMetadataTest.REGRESSION;
 
 
 /**
@@ -452,10 +451,6 @@ public strictfp class MetadataTest extends TestCase {
         final Unmarshaller unmarshaller = pool.acquireUnmarshaller();
         final DefaultMetadata metadata = (DefaultMetadata) unmarshaller.unmarshal(getResource());
         pool.recycle(unmarshaller);
-        if (REGRESSION) {
-            assertTrue("Maybe SIS-402 has been fixed and this anti-regression hack can be
removed?",
-                       metadata.getCharacterSets().add(StandardCharsets.UTF_8));
-        }
         final DefaultMetadata expected = createHardCoded();
         assertTrue(metadata.equals(expected, ComparisonMode.DEBUG));
         loggings.skipNextLogIfContains("sis-temporal");
@@ -469,10 +464,6 @@ public strictfp class MetadataTest extends TestCase {
     @Test
     public void testMetadataWithVerticalCRS() throws JAXBException {
         final Metadata metadata = unmarshalFile(Metadata.class, VERTICAL_CRS_XML);
-        if (REGRESSION) {
-            assertTrue("Maybe SIS-402 has been fixed and this anti-regression hack can be
removed?",
-                       ((DefaultMetadata) metadata).getCharacterSets().add(StandardCharsets.UTF_8));
-        }
         assertEquals("fileIdentifier", "20090901",                     metadata.getMetadataIdentifier().getCode());
         assertEquals("language",       Locale.ENGLISH,                 getSingleton(metadata.getLocalesAndCharsets().keySet()));
         assertEquals("characterSet",   StandardCharsets.UTF_8,         getSingleton(metadata.getLocalesAndCharsets().values()));
diff --git a/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/xml/StoreTest.java
b/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/xml/StoreTest.java
index 6155e3b..bc72797 100644
--- a/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/xml/StoreTest.java
+++ b/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/xml/StoreTest.java
@@ -18,6 +18,7 @@ package org.apache.sis.internal.storage.xml;
 
 import java.util.Locale;
 import java.io.StringReader;
+import java.nio.charset.StandardCharsets;
 import org.opengis.metadata.Metadata;
 import org.opengis.metadata.citation.*;
 import org.apache.sis.xml.Namespaces;
@@ -102,6 +103,7 @@ public final strictfp class StoreTest extends TestCase {
 
         assertInstanceOf("party", Organisation.class, party);
         assertEquals(Locale.ENGLISH,              getSingleton(metadata.getLocalesAndCharsets().keySet()));
+        assertEquals(StandardCharsets.UTF_8,      getSingleton(metadata.getLocalesAndCharsets().values()));
         assertEquals(Role.PRINCIPAL_INVESTIGATOR, resp.getRole());
         assertEquals("Apache SIS",                String.valueOf(party.getName()));
         assertEquals("http://sis.apache.org",     String.valueOf(resource.getLinkage()));


Mime
View raw message