Modified: sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/DefaultMetadataTest.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/DefaultMetadataTest.java?rev=1826246&r1=1826245&r2=1826246&view=diff ============================================================================== --- sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/DefaultMetadataTest.java [UTF-8] (original) +++ sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/DefaultMetadataTest.java [UTF-8] Thu Mar 8 15:30:28 2018 @@ -21,17 +21,12 @@ import java.util.Locale; import java.util.Arrays; import java.util.Iterator; import java.util.Collection; -import java.util.logging.LogRecord; import java.net.URISyntaxException; -import javax.xml.bind.Unmarshaller; import javax.xml.bind.JAXBException; import org.opengis.metadata.citation.Citation; import org.opengis.metadata.citation.DateType; import org.opengis.metadata.maintenance.ScopeCode; -import org.apache.sis.xml.XML; import org.apache.sis.xml.Namespaces; -import org.apache.sis.xml.MarshallerPool; -import org.apache.sis.util.logging.WarningListener; import org.apache.sis.util.iso.SimpleInternationalString; import org.apache.sis.metadata.iso.citation.DefaultCitation; import org.apache.sis.metadata.iso.citation.DefaultCitationDate; @@ -58,7 +53,7 @@ import static org.apache.sis.test.TestUt * @module */ @DependsOn(org.apache.sis.internal.metadata.OtherLocalesTest.class) -public final strictfp class DefaultMetadataTest extends XMLTestCase implements WarningListener<Object> { +public final strictfp class DefaultMetadataTest extends XMLTestCase { /** * 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: @@ -70,55 +65,6 @@ public final strictfp class DefaultMetad public static final boolean REGRESSION = true; /** - * The resource key for the message of the warning that occurred while unmarshalling a XML fragment, - * or {@code null} if none. - */ - private Object resourceKey; - - /** - * The parameter of the warning that occurred while unmarshalling a XML fragment, or {@code null} if none. - */ - private Object[] parameters; - - /** - * For internal {@code DefaultMetadata} usage. - * - * @return {@code Object.class}. - */ - @Override - public Class<Object> getSourceClass() { - return Object.class; - } - - /** - * Invoked when a warning occurred while unmarshalling a test XML fragment. This method ensures that no other - * warning occurred before this method call (i.e. each test is allowed to cause at most one warning), then - * remember the warning parameters for verification by the test method. - * - * @param source ignored. - * @param warning the warning. - */ - @Override - public void warningOccured(final Object source, final LogRecord warning) { - assertNull(resourceKey); - assertNull(parameters); - assertNotNull(resourceKey = warning.getMessage()); - assertNotNull(parameters = warning.getParameters()); - } - - /** - * Unmarshalls the given XML fragment. - */ - private DefaultMetadata unmarshal(final String xml) throws JAXBException { - final MarshallerPool pool = getMarshallerPool(); - final Unmarshaller unmarshaller = pool.acquireUnmarshaller(); - unmarshaller.setProperty(XML.WARNING_LISTENER, this); - final Object c = unmarshal(unmarshaller, xml); - pool.recycle(unmarshaller); - return (DefaultMetadata) c; - } - - /** * Tests unmarshalling of a metadata having a collection that contains no element. * This was used to cause a {@code NullPointerException} prior SIS-139 fix. * @@ -128,7 +74,7 @@ public final strictfp class DefaultMetad */ @Test public void testEmptyCollection() throws JAXBException { - final DefaultMetadata metadata = unmarshal( + final DefaultMetadata metadata = unmarshal(DefaultMetadata.class, "<mdb:MD_Metadata xmlns:mdb=\"" + Namespaces.MDB + "\">\n" + " <mdb:contact/>\n" + "</mdb:MD_Metadata>"); @@ -136,11 +82,6 @@ public final strictfp class DefaultMetad * Verify metadata property. */ assertTrue(metadata.getContacts().isEmpty()); - /* - * Verify warning message emitted during unmarshalling. - */ - assertEquals("warning", "NullCollectionElement_1", resourceKey); - assertArrayEquals("warning", new String[] {"CheckedArrayList<ResponsibleParty>"}, parameters); } /**
Modified: sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/DefaultResponsibilityTest.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/DefaultResponsibilityTest.java?rev=1826246&r1=1826245&r2=1826246&view=diff ============================================================================== --- sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/DefaultResponsibilityTest.java [UTF-8] (original) +++ sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/DefaultResponsibilityTest.java [UTF-8] Thu Mar 8 15:30:28 2018 @@ -23,7 +23,7 @@ import org.apache.sis.internal.jaxb.Lega import org.junit.Test; import static java.util.Collections.singleton; -import static org.apache.sis.test.Assert.*; +import static org.apache.sis.test.MetadataAssert.*; /** Modified: sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/constraint/DefaultLegalConstraintsTest.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/constraint/DefaultLegalConstraintsTest.java?rev=1826246&r1=1826245&r2=1826246&view=diff ============================================================================== --- sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/constraint/DefaultLegalConstraintsTest.java [UTF-8] (original) +++ sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/constraint/DefaultLegalConstraintsTest.java [UTF-8] Thu Mar 8 15:30:28 2018 @@ -16,20 +16,15 @@ */ package org.apache.sis.metadata.iso.constraint; -import java.util.logging.LogRecord; -import javax.xml.bind.Unmarshaller; import javax.xml.bind.JAXBException; import org.opengis.metadata.constraint.Restriction; -import org.apache.sis.xml.XML; import org.apache.sis.xml.Namespaces; -import org.apache.sis.xml.MarshallerPool; -import org.apache.sis.util.logging.WarningListener; import org.apache.sis.internal.jaxb.LegacyNamespaces; import org.apache.sis.test.XMLTestCase; import org.junit.Test; import static java.util.Collections.singleton; -import static org.apache.sis.test.Assert.*; +import static org.apache.sis.test.MetadataAssert.*; import static org.apache.sis.test.TestUtilities.getSingleton; @@ -42,56 +37,7 @@ import static org.apache.sis.test.TestUt * @since 0.4 * @module */ -public final strictfp class DefaultLegalConstraintsTest extends XMLTestCase implements WarningListener<Object> { - /** - * The resource key for the message of the warning that occurred while unmarshalling a XML fragment, - * or {@code null} if none. - */ - private Object resourceKey; - - /** - * The parameter of the warning that occurred while unmarshalling a XML fragment, or {@code null} if none. - */ - private Object[] parameters; - - /** - * For internal {@code DefaultLegalConstraints} usage. - * - * @return {@code Object.class}. - */ - @Override - public Class<Object> getSourceClass() { - return Object.class; - } - - /** - * Invoked when a warning occurred while unmarshalling a test XML fragment. This method ensures that no other - * warning occurred before this method call (i.e. each test is allowed to cause at most one warning), then - * remember the warning parameters for verification by the test method. - * - * @param source ignored. - * @param warning the warning. - */ - @Override - public void warningOccured(final Object source, final LogRecord warning) { - assertNull(resourceKey); - assertNull(parameters); - assertNotNull(resourceKey = warning.getMessage()); - assertNotNull(parameters = warning.getParameters()); - } - - /** - * Unmarshals the given XML fragment. - */ - private DefaultLegalConstraints unmarshal(final String xml) throws JAXBException { - final MarshallerPool pool = getMarshallerPool(); - final Unmarshaller unmarshaller = pool.acquireUnmarshaller(); - unmarshaller.setProperty(XML.WARNING_LISTENER, this); - final Object c = unmarshal(unmarshaller, xml); - pool.recycle(unmarshaller); - return (DefaultLegalConstraints) c; - } - +public final strictfp class DefaultLegalConstraintsTest extends XMLTestCase { /** * Tests unmarshalling of an element containing an empty {@code codeListValue} attribute. * This was used to cause a {@code NullPointerException} prior SIS-157 fix. @@ -102,7 +48,7 @@ public final strictfp class DefaultLegal */ @Test public void testUnmarshallEmptyCodeListValue() throws JAXBException { - final DefaultLegalConstraints c = unmarshal( + final DefaultLegalConstraints c = unmarshal(DefaultLegalConstraints.class, "<mco:MD_LegalConstraints xmlns:mco=\"" + Namespaces.MCO + "\">\n" + " <mco:accessConstraints>\n" + " <mco:MD_RestrictionCode codeListValue=\"intellectualPropertyRights\" codeList=\"http://standards.iso.org/iso/19115/resources/Codelist/cat/codelists.xml#MD_RestrictionCode\"/>\n" + @@ -116,11 +62,6 @@ public final strictfp class DefaultLegal */ assertEquals("accessConstraints", Restriction.INTELLECTUAL_PROPERTY_RIGHTS, getSingleton(c.getAccessConstraints())); assertTrue("useConstraints", c.getUseConstraints().isEmpty()); - /* - * Verify warning message emitted during unmarshalling. - */ - assertEquals("warning", "NullCollectionElement_1", resourceKey); - assertArrayEquals("warning", new String[] {"CodeListSet<Restriction>"}, parameters); } /** @@ -144,7 +85,7 @@ public final strictfp class DefaultLegal final DefaultLegalConstraints c = new DefaultLegalConstraints(); c.setUseConstraints(singleton(Restriction.LICENSE)); assertXmlEquals(xml, marshal(c), "xmlns:*"); - DefaultLegalConstraints actual = unmarshal(xml); + DefaultLegalConstraints actual = unmarshal(DefaultLegalConstraints.class, xml); assertSame(Restriction.LICENSE, getSingleton(actual.getUseConstraints())); assertEquals(c, actual); /* @@ -161,7 +102,7 @@ public final strictfp class DefaultLegal "</gmd:MD_LegalConstraints>\n"; assertXmlEquals(xml, marshal(c, VERSION_2007), "xmlns:*"); - actual = unmarshal(xml); + actual = unmarshal(DefaultLegalConstraints.class, xml); assertSame(Restriction.LICENSE, getSingleton(actual.getUseConstraints())); assertEquals(c, actual); } Modified: sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/extent/DefaultExtentTest.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/extent/DefaultExtentTest.java?rev=1826246&r1=1826245&r2=1826246&view=diff ============================================================================== --- sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/extent/DefaultExtentTest.java [UTF-8] (original) +++ sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/extent/DefaultExtentTest.java [UTF-8] Thu Mar 8 15:30:28 2018 @@ -29,7 +29,7 @@ import org.apache.sis.test.XMLTestCase; import org.apache.sis.test.DependsOn; import org.junit.Test; -import static org.apache.sis.test.Assert.*; +import static org.apache.sis.test.MetadataAssert.*; import static org.apache.sis.test.TestUtilities.date; Modified: sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultBrowseGraphicTest.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultBrowseGraphicTest.java?rev=1826246&r1=1826245&r2=1826246&view=diff ============================================================================== --- sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultBrowseGraphicTest.java [UTF-8] (original) +++ sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultBrowseGraphicTest.java [UTF-8] Thu Mar 8 15:30:28 2018 @@ -33,7 +33,7 @@ import org.apache.sis.test.XMLTestCase; import org.apache.sis.test.DependsOnMethod; import org.junit.Test; -import static org.apache.sis.test.Assert.*; +import static org.apache.sis.test.MetadataAssert.*; import static java.util.Collections.singletonMap; Modified: sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultRepresentativeFractionTest.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultRepresentativeFractionTest.java?rev=1826246&r1=1826245&r2=1826246&view=diff ============================================================================== --- sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultRepresentativeFractionTest.java [UTF-8] (original) +++ sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultRepresentativeFractionTest.java [UTF-8] Thu Mar 8 15:30:28 2018 @@ -25,7 +25,7 @@ import org.apache.sis.test.XMLTestCase; import org.apache.sis.test.DependsOnMethod; import org.junit.Test; -import static org.apache.sis.test.Assert.*; +import static org.apache.sis.test.MetadataAssert.*; /** Modified: sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultResolutionTest.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultResolutionTest.java?rev=1826246&r1=1826245&r2=1826246&view=diff ============================================================================== --- sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultResolutionTest.java [UTF-8] (original) +++ sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultResolutionTest.java [UTF-8] Thu Mar 8 15:30:28 2018 @@ -29,7 +29,7 @@ import org.junit.After; import org.junit.Rule; import org.junit.Test; -import static org.apache.sis.test.Assert.*; +import static org.apache.sis.test.MetadataAssert.*; /** Modified: sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/lineage/DefaultLineageTest.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/lineage/DefaultLineageTest.java?rev=1826246&r1=1826245&r2=1826246&view=diff ============================================================================== --- sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/lineage/DefaultLineageTest.java [UTF-8] (original) +++ sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/lineage/DefaultLineageTest.java [UTF-8] Thu Mar 8 15:30:28 2018 @@ -27,7 +27,7 @@ import org.apache.sis.test.TestUtilities import org.apache.sis.test.XMLTestCase; import org.junit.Test; -import static org.apache.sis.test.Assert.*; +import static org.apache.sis.test.MetadataAssert.*; /** Modified: sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/quality/AbstractPositionalAccuracyTest.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/quality/AbstractPositionalAccuracyTest.java?rev=1826246&r1=1826245&r2=1826246&view=diff ============================================================================== --- sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/quality/AbstractPositionalAccuracyTest.java [UTF-8] (original) +++ sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/quality/AbstractPositionalAccuracyTest.java [UTF-8] Thu Mar 8 15:30:28 2018 @@ -20,7 +20,7 @@ import java.util.Locale; import javax.xml.bind.JAXBException; import org.opengis.metadata.quality.Result; import org.opengis.util.InternationalString; -import org.apache.sis.xml.FreeTextMarshallingTest; +import org.apache.sis.internal.jaxb.lan.FreeTextMarshallingTest; import org.apache.sis.util.Version; import org.apache.sis.test.XMLTestCase; import org.apache.sis.test.DependsOn; Modified: sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/test/MetadataAssert.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/test/MetadataAssert.java?rev=1826246&r1=1826245&r2=1826246&view=diff ============================================================================== --- sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/test/MetadataAssert.java [UTF-8] (original) +++ sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/test/MetadataAssert.java [UTF-8] Thu Mar 8 15:30:28 2018 @@ -17,12 +17,17 @@ package org.apache.sis.test; import java.util.Locale; +import java.io.IOException; +import org.xml.sax.SAXException; +import javax.xml.parsers.ParserConfigurationException; import org.opengis.util.InternationalString; import org.opengis.metadata.citation.Citation; import org.opengis.referencing.IdentifiedObject; import org.apache.sis.io.wkt.Symbols; import org.apache.sis.io.wkt.WKTFormat; import org.apache.sis.io.wkt.Convention; +import org.apache.sis.xml.Namespaces; +import org.apache.sis.internal.jaxb.LegacyNamespaces; // Branch-specific imports import org.apache.sis.metadata.iso.citation.DefaultCitation; @@ -34,7 +39,7 @@ import org.apache.sis.metadata.iso.citat * from other modules and libraries. * * @author Martin Desruisseaux (Geomatys) - * @version 0.8 + * @version 1.0 * @since 0.4 * @module */ @@ -155,4 +160,100 @@ public strictfp class MetadataAssert ext } } } + + /** + * Parses two XML trees as DOM documents, and compares the nodes. + * The inputs given to this method can be any of the following types: + * + * <ul> + * <li>{@link org.w3c.dom.Node}: used directly without further processing.</li> + * <li>{@link java.io.File}, {@link java.net.URL} or {@link java.net.URI}: the + * stream is opened and parsed as a XML document.</li> + * <li>{@link String}: The string content is parsed directly as a XML document.</li> + * </ul> + * + * The comparison will ignore comments and the optional attributes given in arguments. + * + * <div class="section">Ignored attributes substitution</div> + * For convenience, this method replaces some well known prefixes in the {@code ignoredAttributes} + * array by their full namespace URLs. For example this method replaces{@code "xsi:schemaLocation"} + * by {@code "http://www.w3.org/2001/XMLSchema-instance:schemaLocation"}. + * If such substitution is not desired, consider using {@link XMLComparator} directly instead. + * + * <p>The current substitution map is as below (may be expanded in any future SIS version):</p> + * + * <table class="sis"> + * <caption>Predefined prefix mapping</caption> + * <tr><th>Prefix</th> <th>URL</th></tr> + * <tr><td>xmlns</td> <td>{@code "http://www.w3.org/2000/xmlns"}</td></tr> + * <tr><td>xlink</td> <td>{@value Namespaces#XLINK}</td></tr> + * <tr><td>xsi</td> <td>{@value Namespaces#XSI}</td></tr> + * <tr><td>gml</td> <td>{@value Namespaces#GML}</td></tr> + * <tr><td>gco</td> <td>{@value Namespaces#GCO}</td></tr> + * <tr><td>gmd</td> <td>{@value LegacyNamespaces#GMD}</td></tr> + * <tr><td>gmx</td> <td>{@value LegacyNamespaces#GMX}</td></tr> + * <tr><td>gmi</td> <td>{@value LegacyNamespaces#GMI}</td></tr> + * </table> + * + * <p>For example in order to ignore the namespace, type and schema location declaration, + * the following strings can be given to the {@code ignoredAttributes} argument:</p> + * + * {@preformat text + * "xmlns:*", "xsi:schemaLocation", "xsi:type" + * } + * + * @param expected the expected XML document. + * @param actual the XML document to compare. + * @param ignoredAttributes the fully-qualified names of attributes to ignore + * (typically {@code "xmlns:*"} and {@code "xsi:schemaLocation"}). + * + * @see XMLComparator + */ + public static void assertXmlEquals(final Object expected, final Object actual, final String... ignoredAttributes) { + assertXmlEquals(expected, actual, TestCase.STRICT, null, ignoredAttributes); + } + + /** + * Parses two XML trees as DOM documents, and compares the nodes with the given tolerance + * threshold for numerical values. The inputs given to this method can be any of the types + * documented {@linkplain #assertXmlEquals(Object, Object, String[]) above}. This method + * will ignore comments and the optional attributes given in arguments as documented in the + * above method. + * + * @param expected the expected XML document. + * @param actual the XML document to compare. + * @param tolerance the tolerance threshold for comparison of numerical values. + * @param ignoredNodes the fully-qualified names of the nodes to ignore, or {@code null} if none. + * @param ignoredAttributes the fully-qualified names of attributes to ignore + * (typically {@code "xmlns:*"} and {@code "xsi:schemaLocation"}). + * + * @see XMLComparator + */ + public static void assertXmlEquals(final Object expected, final Object actual, + final double tolerance, final String[] ignoredNodes, final String[] ignoredAttributes) + { + final XMLComparator comparator; + try { + comparator = new XMLComparator(expected, actual); + } catch (IOException | ParserConfigurationException | SAXException e) { + // We don't throw directly those exceptions since failing to parse the XML file can + // be considered as part of test failures and the JUnit exception for such failures + // is AssertionError. Having no checked exception in "assert" methods allow us to + // declare the checked exceptions only for the library code being tested. + throw new AssertionError(e); + } + comparator.tolerance = tolerance; + comparator.ignoreComments = true; + if (ignoredNodes != null) { + for (final String node : ignoredNodes) { + comparator.ignoredNodes.add(XMLComparator.substitutePrefix(node)); + } + } + if (ignoredAttributes != null) { + for (final String attribute : ignoredAttributes) { + comparator.ignoredAttributes.add(XMLComparator.substitutePrefix(attribute)); + } + } + comparator.compare(); + } } Modified: sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/test/mock/IdentifiedObjectMock.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/test/mock/IdentifiedObjectMock.java?rev=1826246&r1=1825489&r2=1826246&view=diff ============================================================================== --- sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/test/mock/IdentifiedObjectMock.java [UTF-8] (original) +++ sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/test/mock/IdentifiedObjectMock.java [UTF-8] Thu Mar 8 15:30:28 2018 @@ -25,9 +25,9 @@ import javax.xml.bind.annotation.XmlRoot import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import org.opengis.util.GenericName; import org.opengis.util.InternationalString; -import org.opengis.metadata.Identifier; import org.opengis.metadata.citation.Citation; import org.opengis.referencing.IdentifiedObject; +import org.opengis.referencing.ReferenceIdentifier; import org.apache.sis.internal.util.CollectionsExt; import org.apache.sis.internal.jaxb.gco.GO_GenericName; @@ -44,7 +44,7 @@ import org.apache.sis.internal.jaxb.gco. */ @SuppressWarnings("serial") @XmlRootElement(name = "IO_IdentifiedObject") -public strictfp class IdentifiedObjectMock implements IdentifiedObject, Identifier, Serializable { +public strictfp class IdentifiedObjectMock implements IdentifiedObject, ReferenceIdentifier, Serializable { /** * The object name to be returned by {@link #getCode()}. */ @@ -102,7 +102,7 @@ public strictfp class IdentifiedObjectMo * @return the name of this object, or {@code null} if none. */ @Override - public final Identifier getName() { + public final ReferenceIdentifier getName() { return (code != null) ? this : null; } @@ -162,19 +162,7 @@ public strictfp class IdentifiedObjectMo * @return the identifiers of this object. */ @Override - public final Set<Identifier> getIdentifiers() { - return null; - } - - /** - * Returns the description (currently null). - * - * @return the description associated to this object. - * - * @since 0.5 - */ - @Override - public InternationalString getDescription() { + public final Set<ReferenceIdentifier> getIdentifiers() { return null; } Modified: sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java?rev=1826246&r1=1826245&r2=1826246&view=diff ============================================================================== --- sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java [UTF-8] (original) +++ sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java [UTF-8] Thu Mar 8 15:30:28 2018 @@ -25,7 +25,7 @@ import org.junit.BeforeClass; * All tests from the {@code sis-metadata} module, in approximative dependency order. * * @author Martin Desruisseaux (Geomatys) - * @version 0.8 + * @version 1.0 * @since 0.3 * @module */ @@ -56,15 +56,46 @@ import org.junit.BeforeClass; org.apache.sis.internal.metadata.MergerTest.class, // XML marshalling. - org.apache.sis.internal.jaxb.code.EnumMarshallingTest.class, - org.apache.sis.internal.jaxb.code.CodeListMarshallingTest.class, - org.apache.sis.internal.jaxb.code.PT_LocaleTest.class, - org.apache.sis.xml.FreeTextMarshallingTest.class, + org.apache.sis.internal.test.XMLComparatorTest.class, + org.apache.sis.xml.NamespacesTest.class, + org.apache.sis.xml.XLinkTest.class, + org.apache.sis.xml.NilReasonTest.class, + org.apache.sis.xml.LegacyCodesTest.class, + org.apache.sis.xml.ValueConverterTest.class, + org.apache.sis.xml.OGCNamespacePrefixMapperTest.class, + org.apache.sis.xml.MarshallerPoolTest.class, + org.apache.sis.xml.TransformingNamespacesTest.class, + org.apache.sis.internal.jaxb.XmlUtilitiesTest.class, + org.apache.sis.internal.jaxb.IdentifierMapAdapterTest.class, + org.apache.sis.internal.jaxb.ModifiableIdentifierMapTest.class, + org.apache.sis.internal.jaxb.gco.StringAdapterTest.class, + org.apache.sis.internal.jaxb.gco.PropertyTypeTest.class, + org.apache.sis.internal.jaxb.lan.PT_LocaleTest.class, + org.apache.sis.internal.jaxb.lan.LanguageCodeTest.class, + org.apache.sis.internal.jaxb.lan.FreeTextMarshallingTest.class, + org.apache.sis.internal.jaxb.cat.EnumAdapterTest.class, + org.apache.sis.internal.jaxb.cat.EnumMarshallingTest.class, + org.apache.sis.internal.jaxb.cat.CodeListMarshallingTest.class, + org.apache.sis.internal.jaxb.gml.TimePeriodTest.class, + org.apache.sis.internal.jaxb.gml.MeasureTest.class, org.apache.sis.xml.NilReasonMarshallingTest.class, org.apache.sis.xml.CharSequenceSubstitutionTest.class, org.apache.sis.xml.UUIDMarshallingTest.class, org.apache.sis.xml.XLinkMarshallingTest.class, + // GeoAPI most basic types. + org.apache.sis.internal.simple.SimpleIdentifierTest.class, + org.apache.sis.util.iso.TypesTest.class, + org.apache.sis.util.iso.DefaultLocalNameTest.class, + org.apache.sis.util.iso.DefaultScopedNameTest.class, + org.apache.sis.util.iso.DefaultNameFactoryTest.class, + org.apache.sis.util.iso.NamesTest.class, + org.apache.sis.util.iso.TypeNamesTest.class, + org.apache.sis.util.iso.DefaultRecordTypeTest.class, + org.apache.sis.util.iso.DefaultRecordSchemaTest.class, + org.apache.sis.util.iso.DefaultRecordTest.class, + org.apache.sis.util.iso.NameMarshallingTest.class, + // ISO implementations. org.apache.sis.metadata.iso.citation.DefaultContactTest.class, org.apache.sis.metadata.iso.citation.DefaultResponsibilityTest.class, Modified: sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/util/iso/TypesTest.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/util/iso/TypesTest.java?rev=1826246&r1=1825489&r2=1826246&view=diff ============================================================================== --- sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/util/iso/TypesTest.java [UTF-8] (original) +++ sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/util/iso/TypesTest.java [UTF-8] Thu Mar 8 15:30:28 2018 @@ -30,11 +30,11 @@ import org.opengis.metadata.content.Imag import org.opengis.referencing.datum.Datum; import org.opengis.referencing.datum.PixelInCell; import org.opengis.referencing.cs.AxisDirection; -import org.opengis.parameter.ParameterDirection; import org.apache.sis.test.TestCase; import org.junit.Test; import static org.opengis.test.Assert.*; +import static org.apache.sis.test.Assert.PENDING_NEXT_GEOAPI_RELEASE; /** @@ -108,7 +108,7 @@ public final strictfp class TypesTest ex /** * Tests the {@link Types#forEnumName(Class, String)} method with an enumeration from the JDK. - * Such enumerations do not implement the {@link org.opengis.util.ControlledVocabulary} interface. + * Such enumerations do not implement the {@code org.opengis.util.ControlledVocabulary} interface. * * @since 0.5 */ @@ -122,21 +122,6 @@ public final strictfp class TypesTest ex } /** - * Tests the {@link Types#forEnumName(Class, String)} method with an enumeration from GeoAPI. - * Such enumerations implement the {@link org.opengis.util.ControlledVocabulary} interface. - * - * @since 0.5 - */ - @Test - public void testForGeoapiEnumName() { - assertSame(ParameterDirection.IN_OUT, Types.forEnumName(ParameterDirection.class, "IN_OUT")); - assertSame(ParameterDirection.IN_OUT, Types.forEnumName(ParameterDirection.class, "INOUT")); - assertSame(ParameterDirection.IN_OUT, Types.forEnumName(ParameterDirection.class, "in out")); - assertSame(ParameterDirection.IN_OUT, Types.forEnumName(ParameterDirection.class, "in/out")); - assertNull(Types.forEnumName(ParameterDirection.class, "out/in")); - } - - /** * Tests the {@link Types#forCodeName(Class, String, boolean)} method. */ @Test @@ -151,8 +136,11 @@ public final strictfp class TypesTest ex assertSame(PixelInCell.CELL_CORNER, Types.forCodeName(PixelInCell.class, "cellCorner", false)); assertSame(PixelInCell.CELL_CENTER, Types.forCodeName(PixelInCell.class, "cell center", false)); assertSame(PixelInCell.CELL_CENTER, Types.forCodeName(PixelInCell.class, "cellCenter", false)); - assertSame(PixelInCell.CELL_CENTER, Types.forCodeName(PixelInCell.class, "cell centre", false)); - assertSame(PixelInCell.CELL_CENTER, Types.forCodeName(PixelInCell.class, "cellCentre", false)); + + if (PENDING_NEXT_GEOAPI_RELEASE) { + assertSame(PixelInCell.CELL_CENTER, Types.forCodeName(PixelInCell.class, "cell centre", false)); + assertSame(PixelInCell.CELL_CENTER, Types.forCodeName(PixelInCell.class, "cellCentre", false)); + } } /** @@ -190,7 +178,7 @@ public final strictfp class TypesTest ex } /** - * Tests the {@link Types#getDescription(ControlledVocabulary)} method. + * Tests the {@code Types.getDescription(ControlledVocabulary)} method. */ @Test public void testGetCodeDescription() { @@ -204,29 +192,27 @@ public final strictfp class TypesTest ex } /** - * Tests the examples given in {@link Types#getListName(ControlledVocabulary)} javadoc. + * Tests the examples given in {@code Types.getListName(ControlledVocabulary)} javadoc. */ @Test public void testGetListName() { - assertEquals("SV_ParameterDirection", Types.getListName(ParameterDirection.IN_OUT)); assertEquals("CS_AxisDirection", Types.getListName(AxisDirection .NORTH)); assertEquals("CI_OnLineFunctionCode", Types.getListName(OnLineFunction .DOWNLOAD)); assertEquals("MD_ImagingConditionCode", Types.getListName(ImagingCondition .BLURRED_IMAGE)); } /** - * Tests the examples given in {@link Types#getCodeName(ControlledVocabulary)} javadoc. + * Tests the examples given in {@code Types.getCodeName(ControlledVocabulary)} javadoc. */ @Test public void testGetCodeName() { - assertEquals("in/out", Types.getCodeName(ParameterDirection.IN_OUT)); assertEquals("north", Types.getCodeName(AxisDirection .NORTH)); assertEquals("download", Types.getCodeName(OnLineFunction .DOWNLOAD)); assertEquals("blurredImage", Types.getCodeName(ImagingCondition .BLURRED_IMAGE)); } /** - * Tests the examples given in {@link Types#getCodeLabel(ControlledVocabulary)} javadoc. + * Tests the examples given in {@code Types.getCodeLabel(ControlledVocabulary)} javadoc. */ @Test public void testGetCodeLabel() { @@ -236,7 +222,7 @@ public final strictfp class TypesTest ex } /** - * Tests {@link Types#getCodeTitle(ControlledVocabulary)}. + * Tests {@code Types.getCodeTitle(ControlledVocabulary)}. * Also opportunistically tests {@link Types#forCodeTitle(CharSequence)}. */ @Test Modified: sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/xml/CharSequenceSubstitutionTest.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/xml/CharSequenceSubstitutionTest.java?rev=1826246&r1=1826245&r2=1826246&view=diff ============================================================================== --- sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/xml/CharSequenceSubstitutionTest.java [UTF-8] (original) +++ sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/xml/CharSequenceSubstitutionTest.java [UTF-8] Thu Mar 8 15:30:28 2018 @@ -29,7 +29,7 @@ import org.apache.sis.test.DependsOnMeth import org.apache.sis.test.XMLTestCase; import org.junit.Test; -import static org.apache.sis.test.Assert.*; +import static org.apache.sis.test.MetadataAssert.*; // Branch-dependent imports import org.opengis.referencing.ReferenceIdentifier; Copied: sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/xml/NilReasonTest.java (from r1825489, sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/xml/NilReasonTest.java) URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/xml/NilReasonTest.java?p2=sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/xml/NilReasonTest.java&p1=sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/xml/NilReasonTest.java&r1=1825489&r2=1826246&rev=1826246&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/xml/NilReasonTest.java [UTF-8] (original) +++ sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/xml/NilReasonTest.java [UTF-8] Thu Mar 8 15:30:28 2018 @@ -19,7 +19,7 @@ package org.apache.sis.xml; import java.net.URISyntaxException; import org.opengis.util.InternationalString; import org.opengis.metadata.citation.Citation; -import org.opengis.metadata.citation.Responsibility; +import org.opengis.metadata.citation.ResponsibleParty; import org.apache.sis.util.LenientComparable; import org.apache.sis.util.ComparisonMode; import org.apache.sis.util.ArraysExt; @@ -288,7 +288,7 @@ public final strictfp class NilReasonTes assertTrue (c.equals(e2, ComparisonMode.DEBUG)); // Following object should alway be different because it does not implement the same interface. - final Responsibility r1 = NilReason.TEMPLATE.createNilObject(Responsibility.class); + final ResponsibleParty r1 = NilReason.TEMPLATE.createNilObject(ResponsibleParty.class); assertFalse(c.equals(r1, ComparisonMode.STRICT)); assertFalse(c.equals(r1, ComparisonMode.BY_CONTRACT)); assertFalse(c.equals(r1, ComparisonMode.IGNORE_METADATA)); Modified: sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/xml/XLinkMarshallingTest.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/xml/XLinkMarshallingTest.java?rev=1826246&r1=1826245&r2=1826246&view=diff ============================================================================== --- sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/xml/XLinkMarshallingTest.java [UTF-8] (original) +++ sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/xml/XLinkMarshallingTest.java [UTF-8] Thu Mar 8 15:30:28 2018 @@ -29,7 +29,7 @@ import org.apache.sis.test.DependsOn; import org.apache.sis.test.XMLTestCase; import org.junit.Test; -import static org.apache.sis.test.Assert.*; +import static org.apache.sis.test.MetadataAssert.*; import static org.apache.sis.test.TestUtilities.getSingleton; @@ -44,7 +44,7 @@ import static org.apache.sis.test.TestUt * @since 0.4 * @module */ -@DependsOn(NilReasonMarshallingTest.class) +@DependsOn({XLinkTest.class, NilReasonMarshallingTest.class}) public final strictfp class XLinkMarshallingTest extends XMLTestCase { /** * A XML with a {@code xlink:href} without element definition. Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/NamedIdentifier.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/NamedIdentifier.java?rev=1826246&r1=1826245&r2=1826246&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/NamedIdentifier.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/NamedIdentifier.java [UTF-8] Thu Mar 8 15:30:28 2018 @@ -281,7 +281,7 @@ public class NamedIdentifier extends Imm return c; } /* - * May happen if the user gave us an instance of 'org.apache.sis.internal.jaxb.gmx.Anchor' class + * May happen if the user gave us an instance of 'org.apache.sis.internal.jaxb.gcx.Anchor' class * (maybe he got the instance indirectly) and the construction of that instance is not completed. */ throw new IllegalArgumentException(Errors.format(Errors.Keys.IllegalArgumentClass_2, "code", code.getClass())); Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/internal/jaxb/referencing/SecondDefiningParameterTest.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/internal/jaxb/referencing/SecondDefiningParameterTest.java?rev=1826246&r1=1826245&r2=1826246&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/internal/jaxb/referencing/SecondDefiningParameterTest.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/internal/jaxb/referencing/SecondDefiningParameterTest.java [UTF-8] Thu Mar 8 15:30:28 2018 @@ -23,7 +23,7 @@ import org.apache.sis.referencing.datum. import org.apache.sis.test.XMLTestCase; import org.junit.Test; -import static org.apache.sis.test.Assert.*; +import static org.apache.sis.test.MetadataAssert.*; /** Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/test/integration/MetadataTest.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/test/integration/MetadataTest.java?rev=1826246&r1=1826245&r2=1826246&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/test/integration/MetadataTest.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/test/integration/MetadataTest.java [UTF-8] Thu Mar 8 15:30:28 2018 @@ -61,7 +61,7 @@ import org.apache.sis.referencing.cs.Def import org.apache.sis.referencing.crs.DefaultVerticalCRS; import org.apache.sis.internal.jaxb.metadata.replace.ReferenceSystemMetadata; import org.apache.sis.internal.jaxb.LegacyNamespaces; -import org.apache.sis.internal.jaxb.gmx.Anchor; +import org.apache.sis.internal.jaxb.gcx.Anchor; import org.apache.sis.internal.system.Loggers; import org.apache.sis.referencing.NamedIdentifier; import org.apache.sis.util.iso.SimpleInternationalString; Modified: sis/trunk/core/sis-utility/pom.xml URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/pom.xml?rev=1826246&r1=1826245&r2=1826246&view=diff ============================================================================== --- sis/trunk/core/sis-utility/pom.xml (original) +++ sis/trunk/core/sis-utility/pom.xml Thu Mar 8 15:30:28 2018 @@ -160,14 +160,6 @@ Miscellaneous utilities. <groupId>javax</groupId> <artifactId>javaee-api</artifactId> </dependency> - - <!-- Allows compiler to use a JAXB class which should exist on the JVM. --> - <dependency> - <groupId>com.googlecode.jaxb-namespaceprefixmapper-interfaces</groupId> - <artifactId>JAXBNamespacePrefixMapper</artifactId> - <version>2.2.4</version> - <scope>provided</scope> - </dependency> </dependencies> </project> Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/converter/StringConverter.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/converter/StringConverter.java?rev=1826246&r1=1826245&r2=1826246&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/converter/StringConverter.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/converter/StringConverter.java [UTF-8] Thu Mar 8 15:30:28 2018 @@ -31,7 +31,7 @@ import org.apache.sis.util.CharSequences import org.apache.sis.util.ObjectConverter; import org.apache.sis.util.UnconvertibleObjectException; import org.apache.sis.util.iso.SimpleInternationalString; -import org.apache.sis.util.iso.Types; +import org.apache.sis.internal.util.CodeLists; import org.apache.sis.measure.Units; @@ -354,7 +354,7 @@ abstract class StringConverter<T> extend /** Converts the given string to the target type of this converter. */ @Override T doConvert(final String source) { - final T code = Types.forCodeName(targetClass, source, false); + final T code = CodeLists.forName(targetClass, source, false); if (code == null) { throw new UnconvertibleObjectException(formatErrorMessage(source)); } @@ -386,7 +386,7 @@ abstract class StringConverter<T> extend /** Converts the given string to the target type of this converter. */ @Override T doConvert(final String source) { - final T code = Types.forEnumName(targetClass, source); + final T code = CodeLists.forName(targetClass, source); if (code == null) { throw new UnconvertibleObjectException(formatErrorMessage(source)); } Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/CheckedArrayList.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/CheckedArrayList.java?rev=1826246&r1=1826245&r2=1826246&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/CheckedArrayList.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/CheckedArrayList.java [UTF-8] Thu Mar 8 15:30:28 2018 @@ -21,7 +21,6 @@ import java.util.AbstractList; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import org.apache.sis.internal.jaxb.Context; import org.apache.sis.util.Classes; import org.apache.sis.util.ArraysExt; import org.apache.sis.util.NullArgumentException; @@ -47,7 +46,7 @@ import static org.apache.sis.util.Argume * holes are known to exist in use cases like {@code sublist(…).set(…)} or when using the list iterator. * * @author Martin Desruisseaux (Geomatys) - * @version 0.5 + * @version 1.0 * * @param <E> the type of elements in the list. * @@ -149,6 +148,14 @@ public final class CheckedArrayList<E> e * @see <a href="https://issues.apache.org/jira/browse/SIS-157">SIS-157</a> */ public static String illegalElement(final Collection<?> collection, final Object element, final Class<?> expectedType) { + /* + * Ignore if the current thread is in process of unmarshalling a XML document. + * This happen when an XML element is empty (e.g. "<cit:contact/>"), in which + * case JAXB tries to add a null element. + */ + if (MetadataServices.getInstance().isUnmarshalling()) { + return null; + } final short key; final Object[] arguments; if (element == null) { @@ -160,13 +167,7 @@ public final class CheckedArrayList<E> e key = Errors.Keys.IllegalArgumentClass_3; arguments = new Object[] {"element", expectedType, element.getClass()}; } - final Context context = Context.current(); - if (context != null) { - Context.warningOccured(context, collection.getClass(), "add", Errors.class, key, arguments); - return null; - } else { - return Errors.format(key, arguments); - } + return Errors.format(key, arguments); } /** Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java?rev=1826246&r1=1826245&r2=1826246&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java [UTF-8] Thu Mar 8 15:30:28 2018 @@ -23,14 +23,11 @@ import java.util.Objects; import org.opengis.metadata.Identifier; import org.opengis.metadata.citation.Citation; import org.opengis.util.InternationalString; -import org.apache.sis.xml.IdentifierSpace; import org.apache.sis.util.CharSequences; import org.apache.sis.util.Characters; import org.apache.sis.util.Deprecable; import org.apache.sis.util.Static; -import static org.apache.sis.util.iso.DefaultNameSpace.DEFAULT_SEPARATOR; - // Branch-dependent imports import org.opengis.referencing.ReferenceIdentifier; @@ -53,6 +50,14 @@ public final class Citations extends Sta } /** + * The default separator, which is {@code ':'}. The separator is inserted between + * the code space and the code in identifiers. + * + * @see org.apache.sis.util.iso.DefaultNameSpace#DEFAULT_SEPARATOR + */ + public static final char DEFAULT_SEPARATOR = ':'; + + /** * Returns {@code true} if the given code is {@code "EPSG"} while the codespace is {@code "IOGP"} or {@code "OGP"} * (ignoring case). This particular combination of code and codespace is handled in a special way. * @@ -378,6 +383,13 @@ public final class Citations extends Sta * {@link org.apache.sis.metadata.iso.citation.Citations#getUnicodeIdentifier(Citation)}.</li> * </ul> * + * Use {@code getUnicodeIdentifier(…)} method when assigning values to be returned by methods like + * {@link ReferenceIdentifier#getCodeSpace()}, since those values are likely to be compared without special + * care about ignorable identifier characters. But if the intent is to format a more complex string + * like WKT or {@code toString()}, then we suggest to use {@code getIdentifier(citation, true)} instead, + * which will produce the same result but preserving the ignorable characters, which can be useful + * for formatting purpose. + * * @param citation the citation for which to get the identifier, or {@code null}. * @param strict {@code true} for returning a non-null value only if the identifier is a valid Unicode identifier. * @return a non-empty identifier for the given citation without leading or trailing whitespaces, @@ -481,32 +493,6 @@ public final class Citations extends Sta } /** - * Infers a valid Unicode identifier from the given citation, or returns {@code null} if none. - * This method removes {@linkplain Character#isIdentifierIgnorable(int) ignorable characters}. - * See {@link org.apache.sis.metadata.iso.citation.Citations#getUnicodeIdentifier(Citation)} - * for the public documentation of this method. - * - * <div class="section">When to use</div> - * Use this method when assigning values to be returned by methods like {@code Identifier.getCodeSpace()}, - * since those values are likely to be compared without special care about ignorable identifier characters. - * But if the intent is to format a more complex string like WKT or {@code toString()}, then we suggest to - * use {@code getIdentifier(citation, true)} instead, which will produce the same result but preserving the - * ignorable characters, which can be useful for formatting purpose. - * - * @param citation the citation for which to get the Unicode identifier, or {@code null}. - * @return a non-empty Unicode identifier for the given citation without leading or trailing whitespaces, - * or {@code null} if the given citation is null or does not have any Unicode identifier or title. - * - * @since 0.6 - * - * @deprecated Implementation will be moved to {@link org.apache.sis.metadata.iso.citation.Citations} - * after we moved the {@code sis-utility} code that use this method. - */ - public static String getUnicodeIdentifier(final Citation citation) { - return removeIgnorableCharacters(getIdentifier(citation, true)); - } - - /** * Removes characters that are ignorable according Unicode specification. * * @param identifier the character sequence from which to remove ignorable characters, or {@code null}. @@ -553,34 +539,4 @@ public final class Citations extends Sta } return identifier; } - - /** - * Infers a code space from the given citation, or returns {@code null} if none. - * This method is very close to {@link #getUnicodeIdentifier(Citation)}, except that it looks for - * {@link IdentifierSpace#getName()} before to scan the identifiers and titles. The result should - * be the same in most cases, except some cases like the {@link org.apache.sis.metadata.iso.citation.Citations} - * constant for {@code "Proj.4"} in which case this method returns {@code "Proj4"} instead of {@code null}. - * As a side effect, using this method also avoid constructing {@code DefaultCitation} objects which were deferred. - * - * <p>We do not put this method in public API for now because the actions performed by this method could be - * revisited in any future SIS version depending on the experience gained. However we should try to keep the - * behavior of this method close to the behavior of {@link #getUnicodeIdentifier(Citation)}, which is the - * method having a public facade.</p> - * - * @param citation the citation for which to infer the code space, or {@code null}. - * @return a non-empty code space for the given citation without leading or trailing whitespaces, - * or {@code null} if the given citation is null or does not have any Unicode identifier or title. - * - * @since 0.6 - * - * @deprecated Implementation will be moved to {@link org.apache.sis.metadata.iso.citation.Citations} - * after we moved the {@code sis-utility} code that use this method. - */ - public static String getCodeSpace(final Citation citation) { - if (citation instanceof IdentifierSpace<?>) { - return ((IdentifierSpace<?>) citation).getName(); - } else { - return getUnicodeIdentifier(citation); - } - } } Copied: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/CodeLists.java (from r1825489, sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/CodeLists.java) URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/CodeLists.java?p2=sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/CodeLists.java&p1=sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/CodeLists.java&r1=1825489&r2=1826246&rev=1826246&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/CodeLists.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/CodeLists.java [UTF-8] Thu Mar 8 15:30:28 2018 @@ -20,7 +20,6 @@ import java.lang.reflect.Array; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.UndeclaredThrowableException; import org.opengis.util.CodeList; -import org.opengis.util.ControlledVocabulary; import org.apache.sis.util.CharSequences; import org.apache.sis.util.Characters.Filter; @@ -130,19 +129,9 @@ public final class CodeLists implements if (values == null) { throw e; } - if (values instanceof ControlledVocabulary[]) { - for (final ControlledVocabulary code : (ControlledVocabulary[]) values) { - for (final String candidate : code.names()) { - if (accept(candidate, name)) { - return enumType.cast(code); - } - } - } - } else { - for (final Enum<?> code : values) { - if (accept(code.name(), name)) { - return enumType.cast(code); - } + for (final Enum<?> code : values) { + if (accept(code.name(), name)) { + return enumType.cast(code); } } } @@ -159,7 +148,7 @@ public final class CodeLists implements * @see org.apache.sis.util.iso.Types#getCodeValues(Class) */ @SuppressWarnings("unchecked") - public static <T extends ControlledVocabulary> T[] values(final Class<T> codeType) { + public static <T extends CodeList<?>> T[] values(final Class<T> codeType) { Object values; try { values = codeType.getMethod("values", (Class<?>[]) null).invoke(null, (Object[]) null); Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/MetadataServices.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/MetadataServices.java?rev=1826246&r1=1826245&r2=1826246&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/MetadataServices.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/MetadataServices.java [UTF-8] Thu Mar 8 15:30:28 2018 @@ -19,10 +19,15 @@ package org.apache.sis.internal.util; import java.text.Format; import java.util.Locale; import java.util.TimeZone; -import org.opengis.metadata.citation.Citation; -import org.apache.sis.internal.simple.CitationConstant; +import java.util.ResourceBundle; +import java.util.MissingResourceException; +import org.opengis.annotation.UML; import org.apache.sis.internal.system.Modules; import org.apache.sis.internal.system.OptionalDependency; +import org.apache.sis.util.CharSequences; + +// Branch-dependent imports +import org.opengis.util.CodeList; /** @@ -31,7 +36,7 @@ import org.apache.sis.internal.system.Op * implementation using Java reflection. * * @author Martin Desruisseaux (Geomatys) - * @version 0.8 + * @version 1.0 * @since 0.6 * @module */ @@ -92,28 +97,41 @@ public class MetadataServices extends Op } /** - * Returns the constant defined in the {@link org.apache.sis.metadata.iso.citation.Citations} class for the - * given name. This is used at {@link org.apache.sis.internal.simple.CitationConstant} deserialization time, - * for which the two citations of interest are {@code "ISBN"} (International Standard Book Number) and - * {@code "ISSN"} (International Standard Serial Number) citation. + * {@code true} if this thread is in the process of reading a XML document with JAXB. * - * @param name the name of one of the citation constants defined in the {@code Citations} class. - * @return the requested citation, or {@code null} if the {@code sis-metadata} module is not available. + * @return if XML unmarshalling is in progress in current thread. */ - public CitationConstant getCitationConstant(final String name) { - return null; + public boolean isUnmarshalling() { + return false; } /** - * Returns the build-in citation for the given primary key, or {@code null} if none. - * The metadata module will search in a database for information like a descriptive - * title, abbreviations, identifiers, URL to a web site, <i>etc</i>. - * - * @param key the primary key of the desired citation. - * @return the requested citation, or {@code null} if the {@code sis-metadata} module is not available. - */ - public Citation createCitation(final String key) { - return null; + * Returns the title of the given enumeration or code list value. + * + * @param code the code for which to get the title. + * @param locale desired locale for the title. + * @return the title. + * + * @see org.apache.sis.util.iso.Types#getCodeTitle(CodeList) + */ + public String getCodeTitle(final CodeList<?> code, final Locale locale) { + /* + * Following code reproduces the work done by org.apache.sis.util.iso.Types.getCodeList(…) + * with less handling of special cases. It is executed only if the sis-metadata module is + * not on the classpath, otherwise the sis-metadata implementation will be used. + */ + final UML uml = code.getClass().getAnnotation(UML.class); + if (uml != null) try { + return ResourceBundle.getBundle(CodeLists.RESOURCES, locale, UML.class.getClassLoader()) + .getString(uml.identifier() + '.' + code.identifier()); + } catch (MissingResourceException e) { + /* + * Ignore. The reason for not finding the resource may because of above code not covering enough cases. + * Usually the sis-metadata module will be present on the classpath, in which case this implementation + * will not be used. We need just enough code for allowing sis-utility tests to pass. + */ + } + return CharSequences.camelCaseToSentence(code.identifier()).toString(); } /** @@ -142,8 +160,6 @@ public class MetadataServices extends Op * @param locale the locale for the new {@code Format}, or {@code null} for {@code Locale.ROOT}. * @param timezone the timezone, or {@code null} for UTC. * @return a {@link org.apache.sis.geometry.CoordinateFormat}. - * - * @since 0.8 */ public Format createCoordinateFormat(final Locale locale, final TimeZone timezone) { throw moduleNotFound(); Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/package-info.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/package-info.java?rev=1826246&r1=1826245&r2=1826246&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/package-info.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/package-info.java [UTF-8] Thu Mar 8 15:30:28 2018 @@ -30,7 +30,7 @@ * so some serialized classes still exist in this package. * * @author Martin Desruisseaux (Geomatys) - * @version 0.3 + * @version 1.0 * @since 0.3 * @module */ Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/IdentifiedObjectFormat.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/IdentifiedObjectFormat.java?rev=1826246&r1=1826245&r2=1826246&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/IdentifiedObjectFormat.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/IdentifiedObjectFormat.java [UTF-8] Thu Mar 8 15:30:28 2018 @@ -24,7 +24,6 @@ import org.opengis.util.GenericName; import org.opengis.referencing.IdentifiedObject; import org.opengis.referencing.ReferenceIdentifier; import org.apache.sis.internal.util.Citations; -import org.apache.sis.util.iso.DefaultNameSpace; import org.apache.sis.util.resources.Vocabulary; @@ -74,7 +73,7 @@ final class IdentifiedObjectFormat exten cs = Citations.getIdentifier(identifier.getAuthority(), true); } if (cs != null) { - toAppendTo.append(cs).append(DefaultNameSpace.DEFAULT_SEPARATOR); + toAppendTo.append(cs).append(Citations.DEFAULT_SEPARATOR); } return toAppendTo.append(code); } Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/Statistics.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/Statistics.java?rev=1826246&r1=1826245&r2=1826246&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/Statistics.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/Statistics.java [UTF-8] Thu Mar 8 15:30:28 2018 @@ -21,8 +21,8 @@ import java.io.Serializable; import java.util.function.LongConsumer; import java.util.function.DoubleConsumer; import org.opengis.util.InternationalString; +import org.apache.sis.util.iso.SimpleInternationalString; import org.apache.sis.util.ArgumentChecks; -import org.apache.sis.util.iso.Types; import static java.lang.Math.*; import static java.lang.Double.NaN; @@ -84,7 +84,7 @@ import static java.lang.Double.doubleToL * } * * @author Martin Desruisseaux (MPO, IRD, Geomatys) - * @version 0.3 + * @version 1.0 * @since 0.3 * @module */ @@ -160,7 +160,11 @@ public class Statistics implements Doubl * formatted by {@link StatisticsFormat}. */ public Statistics(final CharSequence name) { - this.name = Types.toInternationalString(name); + if (name == null || name instanceof InternationalString) { + this.name = (InternationalString) name; + } else { + this.name = new SimpleInternationalString(name.toString()); + } } /** @@ -192,8 +196,6 @@ public class Statistics implements Doubl * <li><i>etc</i>.</li> * </ul> * - * - * * @param name the phenomenon for which this object is collecting statistics, or {@code null} * if none. If non-null, then this name will be shown as column header in the table * formatted by {@link StatisticsFormat}. @@ -548,12 +550,12 @@ public class Statistics implements Doubl public boolean equals(final Object object) { if (object != null && getClass() == object.getClass()) { final Statistics cast = (Statistics) object; - return Objects.equals(name, cast.name) - && count == cast.count && countNaN == cast.countNaN + return count == cast.count && countNaN == cast.countNaN && doubleToLongBits(minimum) == doubleToLongBits(cast.minimum) && doubleToLongBits(maximum) == doubleToLongBits(cast.maximum) && doubleToLongBits(sum) == doubleToLongBits(cast.sum) - && doubleToLongBits(squareSum) == doubleToLongBits(cast.squareSum); + && doubleToLongBits(squareSum) == doubleToLongBits(cast.squareSum) + && Objects.equals(name, cast.name); } return false; } Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/UnitFormat.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/UnitFormat.java?rev=1826246&r1=1826245&r2=1826246&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/UnitFormat.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/UnitFormat.java [UTF-8] Thu Mar 8 15:30:28 2018 @@ -32,6 +32,7 @@ import java.io.IOException; import javax.measure.Dimension; import javax.measure.Unit; import javax.measure.format.ParserException; +import org.apache.sis.internal.util.Citations; import org.apache.sis.internal.util.Constants; import org.apache.sis.internal.util.DefinitionURI; import org.apache.sis.internal.util.XPaths; @@ -43,7 +44,6 @@ import org.apache.sis.util.Localized; import org.apache.sis.util.resources.Errors; import org.apache.sis.util.CorruptedObjectException; import org.apache.sis.util.collection.WeakValueHashMap; -import org.apache.sis.util.iso.DefaultNameSpace; /** @@ -966,7 +966,7 @@ public class UnitFormat extends Format i failure = e; } throw (ParserException) new ParserException(Errors.format(Errors.Keys.UnknownUnit_1, - Constants.EPSG + DefaultNameSpace.DEFAULT_SEPARATOR + code), + Constants.EPSG + Citations.DEFAULT_SEPARATOR + code), symbols, start + Math.max(0, uom.lastIndexOf(code))).initCause(failure); } /* Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/CodeListSet.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/CodeListSet.java?rev=1826246&r1=1826245&r2=1826246&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/CodeListSet.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/CodeListSet.java [UTF-8] Thu Mar 8 15:30:28 2018 @@ -24,7 +24,7 @@ import java.util.NoSuchElementException; import java.io.Serializable; import java.lang.reflect.Modifier; import org.opengis.util.CodeList; -import org.apache.sis.util.iso.Types; +import org.apache.sis.internal.util.CodeLists; import org.apache.sis.util.resources.Errors; import org.apache.sis.util.NullArgumentException; import org.apache.sis.internal.util.CheckedArrayList; @@ -138,7 +138,7 @@ public class CodeListSet<E extends CodeL public CodeListSet(final Class<E> elementType, final boolean fill) throws IllegalArgumentException { this(elementType); if (fill) { - codes = POOL.unique(Types.getCodeValues(elementType)); + codes = POOL.unique(CodeLists.values(elementType)); int n = codes.length; if (n < Long.SIZE) { values = (1L << n) - 1; @@ -169,7 +169,7 @@ public class CodeListSet<E extends CodeL final E valueOf(final int ordinal) { E[] array = codes; if (array == null || ordinal >= array.length) { - codes = array = POOL.unique(Types.getCodeValues(elementType)); + codes = array = POOL.unique(CodeLists.values(elementType)); } return array[ordinal]; } Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/TableColumn.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/TableColumn.java?rev=1826246&r1=1826245&r2=1826246&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/TableColumn.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/TableColumn.java [UTF-8] Thu Mar 8 15:30:28 2018 @@ -22,9 +22,9 @@ import java.io.Serializable; import java.io.ObjectStreamException; import java.io.InvalidObjectException; import org.opengis.util.InternationalString; -import org.apache.sis.util.iso.Types; import org.apache.sis.util.ArgumentChecks; import org.apache.sis.util.resources.Vocabulary; +import org.apache.sis.util.iso.SimpleInternationalString; /** @@ -92,7 +92,7 @@ import org.apache.sis.util.resources.Voc * The constants defined in this class use a similar approach for providing serialization support. * * @author Martin Desruisseaux (Geomatys) - * @version 0.3 + * @version 1.0 * * @param <V> base type of all values in the column identified by this instance. * @@ -277,7 +277,11 @@ public class TableColumn<V> implements C * @return the text to display as column header. */ public synchronized InternationalString getHeader() { - final InternationalString i18n = Types.toInternationalString(header); + CharSequence t = header; + if (t == null || t instanceof InternationalString) { + return (InternationalString) t; + } + final InternationalString i18n = new SimpleInternationalString(t.toString()); header = i18n; return i18n; } Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTableFormat.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTableFormat.java?rev=1826246&r1=1826245&r2=1826246&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTableFormat.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTableFormat.java [UTF-8] Thu Mar 8 15:30:28 2018 @@ -41,13 +41,13 @@ import org.apache.sis.io.LineAppender; import org.apache.sis.io.TableAppender; import org.apache.sis.io.TabularFormat; import org.apache.sis.io.CompoundFormat; -import org.apache.sis.util.iso.Types; import org.apache.sis.util.Workaround; import org.apache.sis.util.CharSequences; import org.apache.sis.util.ArgumentChecks; import org.apache.sis.util.resources.Errors; import org.apache.sis.util.resources.Vocabulary; import org.apache.sis.internal.util.Acyclic; +import org.apache.sis.internal.util.MetadataServices; import org.apache.sis.internal.util.LocalizedParseException; import static org.apache.sis.util.Characters.NO_BREAK_SPACE; @@ -680,7 +680,7 @@ public class TreeTableFormat extends Tab } else if (value instanceof CharSequence) { text = value.toString(); } else if (value instanceof CodeList<?>) { - text = Types.getCodeTitle((CodeList<?>) value).toString(getDisplayLocale()); + text = MetadataServices.getInstance().getCodeTitle((CodeList<?>) value, getDisplayLocale()); } else if (value instanceof Enum<?>) { text = CharSequences.upperCaseToSentence(((Enum<?>) value).name()); } else if (value instanceof Type) { Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java?rev=1826246&r1=1826245&r2=1826246&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java [UTF-8] Thu Mar 8 15:30:28 2018 @@ -37,9 +37,9 @@ import org.apache.sis.util.Classes; import org.apache.sis.util.Localized; import org.apache.sis.util.Exceptions; import org.apache.sis.util.CharSequences; -import org.apache.sis.util.iso.Types; import org.apache.sis.util.logging.Logging; import org.apache.sis.internal.system.Loggers; +import org.apache.sis.internal.util.MetadataServices; /** @@ -417,7 +417,7 @@ public class IndexedResourceBundle exten } else if (element instanceof Class<?>) { replacement = Classes.getShortName(getPublicType((Class<?>) element)); } else if (element instanceof CodeList<?>) { - replacement = Types.getCodeTitle((CodeList<?>) element).toString(getLocale()); + replacement = MetadataServices.getInstance().getCodeTitle((CodeList<?>) element, getLocale()); } /* * No need to check for Numbers or Dates instances, since they are Copied: sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/util/CitationMock.java (from r1825489, sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/internal/util/CitationMock.java) URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/util/CitationMock.java?p2=sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/util/CitationMock.java&p1=sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/internal/util/CitationMock.java&r1=1825489&r2=1826246&rev=1826246&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/internal/util/CitationMock.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/util/CitationMock.java [UTF-8] Thu Mar 8 15:30:28 2018 @@ -23,11 +23,10 @@ import java.util.List; import org.opengis.metadata.Identifier; import org.opengis.metadata.citation.Citation; import org.opengis.metadata.citation.CitationDate; -import org.opengis.metadata.citation.OnlineResource; import org.opengis.metadata.citation.PresentationForm; -import org.opengis.metadata.citation.Responsibility; +import org.opengis.metadata.citation.ResponsibleParty; import org.opengis.metadata.citation.Series; -import org.opengis.metadata.identification.BrowseGraphic; +import org.opengis.referencing.ReferenceIdentifier; import org.opengis.util.InternationalString; import org.apache.sis.util.iso.SimpleInternationalString; import org.apache.sis.util.Debug; @@ -43,7 +42,7 @@ import org.apache.sis.util.Debug; * @module */ @SuppressWarnings("ReturnOfCollectionOrArrayField") -final strictfp class CitationMock implements Citation, Identifier { +final strictfp class CitationMock implements Citation, ReferenceIdentifier { /** * The title to be returned by {@link #getTitle()}. */ @@ -84,13 +83,10 @@ final strictfp class CitationMock implem @Override public String getCode() {return code;} @Override public String getCodeSpace() {return codeSpace;} @Override public String getVersion() {return null;} - @Override public InternationalString getDescription() {return null;} - @Override public Collection<Responsibility> getCitedResponsibleParties() {return Collections.emptyList();} + @Override public Collection<ResponsibleParty> getCitedResponsibleParties() {return Collections.emptyList();} @Override public Collection<PresentationForm> getPresentationForms() {return Collections.emptyList();} @Override public Series getSeries() {return null;} - @Override public Collection<InternationalString> getOtherCitationDetails() {return Collections.emptyList();} - @Override public Collection<OnlineResource> getOnlineResources() {return Collections.emptyList();} - @Override public Collection<BrowseGraphic> getGraphics() {return Collections.emptyList();} + @Override public InternationalString getOtherCitationDetails() {return null;} @Override public String getISBN() {return null;} @Override public String getISSN() {return null;} @Deprecated Modified: sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/util/CitationsTest.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/util/CitationsTest.java?rev=1826246&r1=1826245&r2=1826246&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/util/CitationsTest.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/util/CitationsTest.java [UTF-8] Thu Mar 8 15:30:28 2018 @@ -21,8 +21,6 @@ import java.util.ArrayList; import java.util.Arrays; import org.opengis.metadata.Identifier; import org.opengis.metadata.citation.Citation; -import org.apache.sis.internal.simple.SimpleCitation; -import org.apache.sis.internal.simple.SimpleIdentifier; import org.apache.sis.test.TestCase; import org.junit.Test; @@ -41,25 +39,17 @@ public final strictfp class CitationsTes /** * Creates a citation with the given title and the given identifiers. */ - @SuppressWarnings("serial") - private static SimpleCitation citation(final String title, final Identifier... identifiers) { - return new SimpleCitation(title) { - @Override public List<Identifier> getIdentifiers() { - return Arrays.asList(identifiers); - } - }; + private static CitationMock citation(final String title, final Identifier... identifiers) { + CitationMock cit = new CitationMock(title, null, null); + cit.identifiers = Arrays.asList(identifiers); + return cit; } /** * Creates an identifier with a code space. */ - @SuppressWarnings("serial") private static Identifier identifier(final String codeSpace, final String code) { - return new SimpleIdentifier(null, code, false) { - @Override public String getCodeSpace() { - return codeSpace; - } - }; + return new CitationMock(null, codeSpace, code); } /** @@ -97,11 +87,11 @@ public final strictfp class CitationsTes */ @Test public void testGetIdentifier() { - SimpleCitation citation = new SimpleCitation(" Not an identifier "); + CitationMock citation = new CitationMock(" Not an identifier ", null, null); assertEquals("Not an identifier", Citations.getIdentifier(citation, false)); assertNull(Citations.getIdentifier(citation, true)); - citation = new SimpleCitation(" ValidIdentifier "); + citation = new CitationMock(" ValidIdentifier ", null, null); assertEquals("ValidIdentifier", Citations.getIdentifier(citation, false)); assertEquals("ValidIdentifier", Citations.getIdentifier(citation, true)); /* Modified: sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/util/LocalizedParseExceptionTest.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/util/LocalizedParseExceptionTest.java?rev=1826246&r1=1826245&r2=1826246&view=diff ============================================================================== --- sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/util/LocalizedParseExceptionTest.java [UTF-8] (original) +++ sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/util/LocalizedParseExceptionTest.java [UTF-8] Thu Mar 8 15:30:28 2018 @@ -22,7 +22,6 @@ import java.text.ParsePosition; import org.apache.sis.measure.Angle; import org.apache.sis.util.resources.Errors; import org.apache.sis.util.Exceptions; -import org.apache.sis.test.DependsOn; import org.apache.sis.test.TestCase; import org.junit.Test; @@ -37,7 +36,6 @@ import static org.junit.Assert.*; * @since 0.3 * @module */ -@DependsOn(org.apache.sis.util.resources.IndexedResourceBundleTest.class) public final strictfp class LocalizedParseExceptionTest extends TestCase { /** * Tests the {@link LocalizedParseException} constructor using the default string.
