sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1497277 - /sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/util/iso/NameMarshallingTest.java
Date Thu, 27 Jun 2013 10:01:34 GMT
Author: desruisseaux
Date: Thu Jun 27 10:01:33 2013
New Revision: 1497277

URL: http://svn.apache.org/r1497277
Log:
Test GenericName unmarshalling.

Modified:
    sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/util/iso/NameMarshallingTest.java

Modified: sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/util/iso/NameMarshallingTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/util/iso/NameMarshallingTest.java?rev=1497277&r1=1497276&r2=1497277&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/util/iso/NameMarshallingTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/util/iso/NameMarshallingTest.java
[UTF-8] Thu Jun 27 10:01:33 2013
@@ -16,8 +16,10 @@
  */
 package org.apache.sis.util.iso;
 
+import java.io.StringReader;
 import java.io.StringWriter;
 import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBException;
 import org.opengis.util.TypeName;
@@ -29,6 +31,7 @@ import org.apache.sis.xml.MarshallerPool
 import org.apache.sis.test.mock.IdentifiedObjectMock;
 import org.apache.sis.test.XMLTestCase;
 import org.apache.sis.test.DependsOn;
+import org.apache.sis.test.DependsOnMethod;
 import org.junit.AfterClass;
 import org.junit.Test;
 
@@ -66,6 +69,17 @@ public final strictfp class NameMarshall
     }
 
     /**
+     * Converse of {@link #marshall(GenericName)}.
+     */
+    private static GenericName unmarshall(final String xml) throws JAXBException {
+        final Unmarshaller unmarshaller = pool.acquireUnmarshaller();
+        final StringReader in = new StringReader(xml);
+        final Object value = unmarshaller.unmarshal(in);
+        pool.recycle(unmarshaller);
+        return ((IdentifiedObjectMock) value).alias;
+    }
+
+    /**
      * Tests XML of a {@link LocalName}.
      *
      * @throws JAXBException Should not happen.
@@ -83,6 +97,7 @@ public final strictfp class NameMarshall
                 "</gml:IO_IdentifiedObject>\n";
         final String actual = marshall(name);
         assertXmlEquals(expected, actual, "xmlns:*", "xsi:schemaLocation");
+        assertEquals(name, unmarshall(actual));
     }
 
     /**
@@ -91,6 +106,7 @@ public final strictfp class NameMarshall
      * @throws JAXBException Should not happen.
      */
     @Test
+    @DependsOnMethod("testLocalName")
     public void testLocalNameWithAmp() throws JAXBException {
         final NameFactory factory = DefaultFactories.NAMES;
         final LocalName name = factory.createLocalName(null, "A name with & and >
and <.");
@@ -103,6 +119,7 @@ public final strictfp class NameMarshall
                 "</gml:IO_IdentifiedObject>\n";
         final String actual = marshall(name);
         assertXmlEquals(expected, actual, "xmlns:*", "xsi:schemaLocation");
+        assertEquals(name, unmarshall(actual));
     }
 
     /**
@@ -127,6 +144,7 @@ public final strictfp class NameMarshall
                 "</gml:IO_IdentifiedObject>\n";
         final String actual = marshall(name);
         assertXmlEquals(expected, actual, "xmlns:*", "xsi:schemaLocation");
+        assertEquals(name, unmarshall(actual));
     }
 
     /**
@@ -147,6 +165,7 @@ public final strictfp class NameMarshall
                 "</gml:IO_IdentifiedObject>\n";
         final String actual = marshall(name);
         assertXmlEquals(expected, actual, "xmlns:*", "xsi:schemaLocation");
+        assertEquals(name, unmarshall(actual));
     }
 
     /**



Mime
View raw message