sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1497581 - in /sis/branches/JDK7/core: sis-metadata/src/test/java/org/apache/sis/test/suite/ sis-metadata/src/test/java/org/apache/sis/xml/ sis-utility/src/test/java/org/apache/sis/test/mock/
Date Thu, 27 Jun 2013 22:10:26 GMT
Author: desruisseaux
Date: Thu Jun 27 22:10:26 2013
New Revision: 1497581

URL: http://svn.apache.org/r1497581
Log:
More tests.

Added:
    sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/xml/
    sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/xml/NilReasonMarshallingTest.java
  (with props)
Modified:
    sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
    sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/mock/DataIdentificationMock.java
    sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/mock/IdentifiedObjectMock.java

Modified: sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java?rev=1497581&r1=1497580&r2=1497581&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
[UTF-8] Thu Jun 27 22:10:26 2013
@@ -56,6 +56,7 @@ import org.junit.BeforeClass;
     org.apache.sis.metadata.iso.AllMetadataTest.class,
 
     // XML marshalling.
+    org.apache.sis.xml.NilReasonMarshallingTest.class,
     org.apache.sis.internal.jaxb.code.CodeListMarshallingTest.class,
     org.apache.sis.internal.jaxb.gmd.LanguageMarshallingTest.class,
     org.apache.sis.internal.jaxb.gml.TimePeriodTest.class

Added: sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/xml/NilReasonMarshallingTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/xml/NilReasonMarshallingTest.java?rev=1497581&view=auto
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/xml/NilReasonMarshallingTest.java
(added)
+++ sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/xml/NilReasonMarshallingTest.java
[UTF-8] Thu Jun 27 22:10:26 2013
@@ -0,0 +1,144 @@
+/*
+ * 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.xml;
+
+import javax.xml.bind.JAXBException;
+import org.opengis.metadata.citation.Series;
+import org.opengis.metadata.citation.Citation;
+import org.apache.sis.test.XMLTestCase;
+import org.junit.Test;
+
+import static org.apache.sis.test.Assert.*;
+
+
+/**
+ * Tests the XML marshalling of object having {@code nilReason} attribute.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.3 (derived from geotk-3.18)
+ * @version 0.3
+ * @module
+ *
+ * @see <a href="http://jira.geotoolkit.org/browse/GEOTK-149">GEOTK-149</a>
+ */
+public final strictfp class NilReasonMarshallingTest extends XMLTestCase {
+    /**
+     * Tests a simple case for a missing data.
+     *
+     * @throws JAXBException Should never happen.
+     */
+    @Test
+    public void testMissing() throws JAXBException {
+        final String expected =
+            "<gmd:CI_Citation xmlns:gmd=\"" + Namespaces.GMD + '"' +
+                            " xmlns:gco=\"" + Namespaces.GCO + '"' +
+                            " xmlns:xlink=\"" + Namespaces.XLINK + "\">\n" +
+            "  <gmd:title>\n" +
+            "    <gco:CharacterString>A title</gco:CharacterString>\n" +
+            "  </gmd:title>\n" +
+            "  <gmd:series gco:nilReason=\"missing\"/>\n" +
+            "</gmd:CI_Citation>";
+
+        final Citation citation = (Citation) XML.unmarshal(expected);
+        assertEquals("title", "A title", citation.getTitle().toString());
+
+        final Series series = citation.getSeries();
+        assertInstanceOf("Should have instantiated a proxy.", NilObject.class, series);
+
+        final NilReason reason = ((NilObject) series).getNilReason();
+        assertSame("nilReason", NilReason.MISSING, reason);
+        assertNull("NilReason.explanation", reason.getOtherExplanation());
+        assertNull("NilReason.URI",         reason.getURI());
+
+        assertEquals("Series[missing]", series.toString());
+        assertNull("All attributes are expected to be null.", series.getName());
+
+        final String actual = XML.marshal(citation);
+        assertXmlEquals(expected, actual, "xmlns:*");
+        assertEquals(citation, XML.unmarshal(actual));
+    }
+
+    /**
+     * Tests a case where the nil reason is specified by an other reason.
+     *
+     * @throws JAXBException Should never happen.
+     */
+    @Test
+    public void testOther() throws JAXBException {
+        final String expected =
+            "<gmd:CI_Citation xmlns:gmd=\"" + Namespaces.GMD + '"' +
+                            " xmlns:gco=\"" + Namespaces.GCO + '"' +
+                            " xmlns:xlink=\"" + Namespaces.XLINK + "\">\n" +
+            "  <gmd:title>\n" +
+            "    <gco:CharacterString>A title</gco:CharacterString>\n" +
+            "  </gmd:title>\n" +
+            "  <gmd:series gco:nilReason=\"other:myReason\"/>\n" +
+            "</gmd:CI_Citation>";
+
+        final Citation citation = (Citation) XML.unmarshal(expected);
+        assertEquals("title", "A title", citation.getTitle().toString());
+
+        final Series series = citation.getSeries();
+        assertInstanceOf("Should have instantiated a proxy.", NilObject.class, series);
+
+        final NilReason reason = ((NilObject) series).getNilReason();
+        assertEquals("NilReason.explanation", "myReason", reason.getOtherExplanation());
+        assertNull("NilReason.URI", reason.getURI());
+
+        assertEquals("Series[other:myReason]", series.toString());
+        assertNull("All attributes are expected to be null.", series.getName());
+
+        final String actual = XML.marshal(citation);
+        assertXmlEquals(expected, actual, "xmlns:*");
+        assertEquals(citation, XML.unmarshal(actual));
+    }
+
+    /**
+     * Tests a case where the nil reason is specified by a URI.
+     *
+     * @throws JAXBException Should never happen.
+     */
+    @Test
+    public void testURI() throws JAXBException {
+        final String expected =
+            "<gmd:CI_Citation xmlns:gmd=\"" + Namespaces.GMD + '"' +
+                            " xmlns:gco=\"" + Namespaces.GCO + '"' +
+                            " xmlns:xlink=\"" + Namespaces.XLINK + "\">\n" +
+            "  <gmd:title>\n" +
+            "    <gco:CharacterString>A title</gco:CharacterString>\n" +
+            "  </gmd:title>\n" +
+            "  <gmd:series gco:nilReason=\"http://www.myreason.org\"/>\n" +
+            "</gmd:CI_Citation>";
+
+        final Citation citation = (Citation) XML.unmarshal(expected);
+        assertEquals("title", "A title", citation.getTitle().toString());
+
+        final Series series = citation.getSeries();
+        assertInstanceOf("Should have instantiated a proxy.", NilObject.class, series);
+
+        final NilReason reason = ((NilObject) series).getNilReason();
+        assertNull("NilReason.explanation", reason.getOtherExplanation());
+        assertEquals("NilReason.URI", "http://www.myreason.org", String.valueOf(reason.getURI()));
+
+        assertEquals("Series[http://www.myreason.org]", series.toString());
+        assertNull("All attributes are expected to be null.", series.getName());
+
+        final String actual = XML.marshal(citation);
+        assertXmlEquals(expected, actual, "xmlns:*");
+        assertEquals(citation, XML.unmarshal(actual));
+    }
+}

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

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

Modified: sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/mock/DataIdentificationMock.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/mock/DataIdentificationMock.java?rev=1497581&r1=1497580&r2=1497581&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/mock/DataIdentificationMock.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/mock/DataIdentificationMock.java
[UTF-8] Thu Jun 27 22:10:26 2013
@@ -19,7 +19,6 @@ package org.apache.sis.test.mock;
 import java.util.Locale;
 import java.util.Collection;
 import java.util.Collections;
-import javax.xml.bind.annotation.XmlType;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
@@ -52,7 +51,6 @@ import org.apache.sis.internal.jaxb.gmd.
  * @version 0.3
  * @module
  */
-@XmlType(name = "MD_DataIdentification_Type")
 @XmlRootElement(name = "MD_DataIdentification", namespace = Namespaces.GMD)
 public final strictfp class DataIdentificationMock implements DataIdentification {
     /**

Modified: sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/mock/IdentifiedObjectMock.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/mock/IdentifiedObjectMock.java?rev=1497581&r1=1497580&r2=1497581&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/mock/IdentifiedObjectMock.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/mock/IdentifiedObjectMock.java
[UTF-8] Thu Jun 27 22:10:26 2013
@@ -23,7 +23,6 @@ import org.opengis.util.GenericName;
 import org.opengis.util.InternationalString;
 import org.opengis.referencing.IdentifiedObject;
 import org.opengis.referencing.ReferenceIdentifier;
-import javax.xml.bind.annotation.XmlType;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
@@ -38,7 +37,6 @@ import org.apache.sis.internal.jaxb.gco.
  * @version 0.3
  * @module
  */
-@XmlType(name = "IdentifiedObjectType")
 @XmlRootElement(name = "IO_IdentifiedObject")
 public final strictfp class IdentifiedObjectMock implements IdentifiedObject {
     /**



Mime
View raw message