sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1819991 - in /sis/branches/ISO-19115-3/core/sis-utility/src/test/java/org/apache/sis: internal/jaxb/gmd/LanguageCodeTest.java test/mock/MetadataMock.java util/iso/NameMarshallingTest.java
Date Wed, 03 Jan 2018 17:14:43 GMT
Author: desruisseaux
Date: Wed Jan  3 17:14:43 2018
New Revision: 1819991

URL: http://svn.apache.org/viewvc?rev=1819991&view=rev
Log:
Adaptation of commit dac622016fb6a480a4c39a9ff39c4e71916c1322 from Image Matter
(fix a few more issues with tests)

The project at this revision can be built but is known to have test failure.
Tests will pass only after we completed the port of all ISO 19115-3 work.

Modified:
    sis/branches/ISO-19115-3/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gmd/LanguageCodeTest.java
    sis/branches/ISO-19115-3/core/sis-utility/src/test/java/org/apache/sis/test/mock/MetadataMock.java
    sis/branches/ISO-19115-3/core/sis-utility/src/test/java/org/apache/sis/util/iso/NameMarshallingTest.java

Modified: sis/branches/ISO-19115-3/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gmd/LanguageCodeTest.java
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gmd/LanguageCodeTest.java?rev=1819991&r1=1819990&r2=1819991&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gmd/LanguageCodeTest.java
[UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gmd/LanguageCodeTest.java
[UTF-8] Wed Jan  3 17:14:43 2018
@@ -25,9 +25,9 @@ import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBException;
 import org.opengis.metadata.Metadata;
 import org.apache.sis.xml.XML;
-import org.apache.sis.xml.Namespaces;
 import org.apache.sis.xml.MarshallerPool;
 import org.apache.sis.internal.jaxb.Schemas;
+import org.apache.sis.internal.jaxb.LegacyNamespaces;
 import org.apache.sis.test.XMLTestCase;
 import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.mock.MetadataMock;
@@ -44,7 +44,7 @@ import static org.apache.sis.internal.ut
  * Tests the XML marshaling of {@code Locale} when used for a language.
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 0.4
+ * @version 1.0
  * @since   0.3
  * @module
  */
@@ -63,7 +63,7 @@ public final strictfp class LanguageCode
      * XML fragment using the {@code <gmd:LanguageCode>} construct with attributes.
      */
     private static final String LANGUAGE_CODE = "<gmd:LanguageCode" +
-            " codeList=\"" + Schemas.METADATA_ROOT + Schemas.CODELISTS_PATH + "#LanguageCode\""
+
+            " codeList=\"" + Schemas.METADATA_ROOT_LEGACY + Schemas.CODELISTS_PATH_LEGACY
+ "#LanguageCode\"" +
             " codeListValue=\"jpn\">Japanese</gmd:LanguageCode>";
 
     /**
@@ -112,8 +112,8 @@ public final strictfp class LanguageCode
      */
     private static String getMetadataXML(final String languageCode) {
         return "<gmd:MD_Metadata" +
-               " xmlns:gmd=\"" + Namespaces.GMD + '"' +
-               " xmlns:gco=\"" + Namespaces.GCO + "\">\n" +
+               " xmlns:gmd=\"" + LegacyNamespaces.GMD + '"' +
+               " xmlns:gco=\"" + LegacyNamespaces.GCO + "\">\n" +
                "  <gmd:language>\n" +
                "    " + languageCode + '\n' +
                "  </gmd:language>\n" +
@@ -133,6 +133,7 @@ public final strictfp class LanguageCode
         final MetadataMock metadata = new MetadataMock(Locale.JAPANESE);
         final Marshaller marshaller = pool.acquireMarshaller();
         assertNull(marshaller.getProperty(XML.STRING_SUBSTITUTES));
+        marshaller.setProperty(XML.METADATA_VERSION, LegacyNamespaces.ISO_19139);
         assertXmlEquals(getMetadataXML(LANGUAGE_CODE), marshal(marshaller, metadata), "xmlns:*");
         pool.recycle(marshaller);
     }
@@ -196,6 +197,7 @@ public final strictfp class LanguageCode
     public void testMarshallCharacterString() throws JAXBException {
         final MetadataMock metadata = new MetadataMock(Locale.JAPANESE);
         final Marshaller marshaller = pool.acquireMarshaller();
+        marshaller.setProperty(XML.METADATA_VERSION, LegacyNamespaces.ISO_19139);
         marshaller.setProperty(XML.STRING_SUBSTITUTES, new String[] {"dummy","language","foo"});
         assertArrayEquals(new String[] {"language"}, (String[]) marshaller.getProperty(XML.STRING_SUBSTITUTES));
         assertXmlEquals(getMetadataXML(CHARACTER_STRING), marshal(marshaller, metadata),
"xmlns:*");

Modified: sis/branches/ISO-19115-3/core/sis-utility/src/test/java/org/apache/sis/test/mock/MetadataMock.java
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-utility/src/test/java/org/apache/sis/test/mock/MetadataMock.java?rev=1819991&r1=1819990&r2=1819991&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-utility/src/test/java/org/apache/sis/test/mock/MetadataMock.java
[UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-utility/src/test/java/org/apache/sis/test/mock/MetadataMock.java
[UTF-8] Wed Jan  3 17:14:43 2018
@@ -32,16 +32,16 @@ import org.apache.sis.xml.Namespaces;
  * A dummy implementation of {@link Metadata} with minimal XML (un)marshalling capability.
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 0.5
+ * @version 1.0
  * @since   0.4
  * @module
  */
-@XmlRootElement(name = "MD_Metadata", namespace = Namespaces.GMD)
+@XmlRootElement(name = "MD_Metadata", namespace = Namespaces.MDB)
 public final strictfp class MetadataMock extends SimpleMetadata {
     /**
      * The language used for documenting metadata.
      */
-    @XmlElement(namespace = Namespaces.GMD)
+    @XmlElement(namespace = Namespaces.MDB)
     @XmlJavaTypeAdapter(LocaleAdapter.class)
     public Locale language;
 

Modified: sis/branches/ISO-19115-3/core/sis-utility/src/test/java/org/apache/sis/util/iso/NameMarshallingTest.java
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-utility/src/test/java/org/apache/sis/util/iso/NameMarshallingTest.java?rev=1819991&r1=1819990&r2=1819991&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-utility/src/test/java/org/apache/sis/util/iso/NameMarshallingTest.java
[UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-utility/src/test/java/org/apache/sis/util/iso/NameMarshallingTest.java
[UTF-8] Wed Jan  3 17:14:43 2018
@@ -25,9 +25,11 @@ import org.opengis.util.LocalName;
 import org.opengis.util.GenericName;
 import org.opengis.util.NameFactory;
 import org.opengis.util.NameSpace;
-import org.apache.sis.internal.system.DefaultFactories;
+import org.apache.sis.xml.XML;
 import org.apache.sis.xml.Namespaces;
 import org.apache.sis.xml.MarshallerPool;
+import org.apache.sis.internal.jaxb.LegacyNamespaces;
+import org.apache.sis.internal.system.DefaultFactories;
 import org.apache.sis.test.mock.IdentifiedObjectMock;
 import org.apache.sis.test.XMLTestCase;
 import org.apache.sis.test.DependsOn;
@@ -42,7 +44,8 @@ import static org.apache.sis.test.Assert
  * Tests the XML marshalling of generic names.
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 0.5
+ * @author  Cullen Rombach (Image Matters)
+ * @version 1.0
  * @since   0.3
  * @module
  */
@@ -64,6 +67,7 @@ public final strictfp class NameMarshall
             pool = new MarshallerPool(JAXBContext.newInstance(IdentifiedObjectMock.class),
null);
         }
         final Marshaller marshaller = pool.acquireMarshaller();
+        marshaller.setProperty(XML.METADATA_VERSION, LegacyNamespaces.ISO_19139);
         final String xml = marshal(marshaller, new IdentifiedObjectMock(null, name));
         pool.recycle(marshaller);
         return xml;
@@ -72,7 +76,7 @@ public final strictfp class NameMarshall
     /**
      * Converse of {@link #marshal(GenericName)}.
      */
-    private GenericName unmarshall(final String xml) throws JAXBException {
+    private GenericName unmarshal(final String xml) throws JAXBException {
         final Unmarshaller unmarshaller = pool.acquireUnmarshaller();
         final Object value = unmarshal(unmarshaller, xml);
         pool.recycle(unmarshaller);
@@ -91,14 +95,14 @@ public final strictfp class NameMarshall
         assertEquals("An ordinary local name", name.toString());
         final String expected =
                 "<gml:IO_IdentifiedObject xmlns:gml=\"" + Namespaces.GML + '"' +
-                                        " xmlns:gco=\"" + Namespaces.GCO + "\">\n" +
+                                        " xmlns:gco=\"" + LegacyNamespaces.GCO + "\">\n"
+
                 "  <gml:alias>\n" +
                 "    <gco:LocalName>An ordinary local name</gco:LocalName>\n"
+
                 "  </gml:alias>\n" +
                 "</gml:IO_IdentifiedObject>\n";
         final String actual = marshal(name);
         assertXmlEquals(expected, actual, "xmlns:*");
-        assertEquals(name, unmarshall(expected));
+        assertEquals(name, unmarshal(expected));
     }
 
     /**
@@ -114,14 +118,14 @@ public final strictfp class NameMarshall
         assertEquals("A name with & and > and <.", name.toString());
         final String expected =
                 "<gml:IO_IdentifiedObject xmlns:gml=\"" + Namespaces.GML + '"' +
-                                        " xmlns:gco=\"" + Namespaces.GCO + "\">\n" +
+                                        " xmlns:gco=\"" + LegacyNamespaces.GCO + "\">\n"
+
                 "  <gml:alias>\n" +
                 "    <gco:LocalName>A name with &amp; and &gt; and &lt;.</gco:LocalName>\n"
+
                 "  </gml:alias>\n" +
                 "</gml:IO_IdentifiedObject>\n";
         final String actual = marshal(name);
         assertXmlEquals(expected, actual, "xmlns:*");
-        assertEquals(name, unmarshall(expected));
+        assertEquals(name, unmarshal(expected));
     }
 
     /**
@@ -138,14 +142,14 @@ public final strictfp class NameMarshall
         assertEquals("A name in a scope", name.toString());
         final String expected =
                 "<gml:IO_IdentifiedObject xmlns:gml=\"" + Namespaces.GML + '"' +
-                                        " xmlns:gco=\"" + Namespaces.GCO + "\">\n" +
+                                        " xmlns:gco=\"" + LegacyNamespaces.GCO + "\">\n"
+
                 "  <gml:alias>\n" +
                 "    <gco:LocalName codeSpace=\"A code space\">A name in a scope</gco:LocalName>\n"
+
                 "  </gml:alias>\n" +
                 "</gml:IO_IdentifiedObject>\n";
         final String actual = marshal(name);
         assertXmlEquals(expected, actual, "xmlns:*");
-        assertEquals(name, unmarshall(expected));
+        assertEquals(name, unmarshal(expected));
     }
 
     /**
@@ -160,7 +164,7 @@ public final strictfp class NameMarshall
         assertEquals("An other local name", name.toString());
         final String expected =
                 "<gml:IO_IdentifiedObject xmlns:gml=\"" + Namespaces.GML + '"' +
-                                        " xmlns:gco=\"" + Namespaces.GCO + "\">\n" +
+                                        " xmlns:gco=\"" + LegacyNamespaces.GCO + "\">\n"
+
                 "  <gml:alias>\n" +
                 "    <gco:TypeName>\n" +
                 "      <gco:aName>\n" +
@@ -171,7 +175,7 @@ public final strictfp class NameMarshall
                 "</gml:IO_IdentifiedObject>\n";
         final String actual = marshal(name);
         assertXmlEquals(expected, actual, "xmlns:*");
-        assertEquals(name, unmarshall(expected));
+        assertEquals(name, unmarshal(expected));
     }
 
     /**
@@ -186,14 +190,14 @@ public final strictfp class NameMarshall
         assertEquals("myScope:myName", name.toString());
         final String expected =
                 "<gml:IO_IdentifiedObject xmlns:gml=\"" + Namespaces.GML + '"' +
-                                        " xmlns:gco=\"" + Namespaces.GCO + "\">\n" +
+                                        " xmlns:gco=\"" + LegacyNamespaces.GCO + "\">\n"
+
                 "  <gml:alias>\n" +
                 "    <gco:ScopedName>myScope:myName</gco:ScopedName>\n" +
                 "  </gml:alias>\n" +
                 "</gml:IO_IdentifiedObject>\n";
         final String actual = marshal(name);
         assertXmlEquals(expected, actual, "xmlns:*");
-        assertEquals(name, unmarshall(expected));
+        assertEquals(name, unmarshal(expected));
     }
 
     /**



Mime
View raw message