/** * Verifies that marshalling the given metadata produces the expected XML document, * then verifies that unmarshalling that document gives back the original metadata object. * If {@link #legacy} is {@code true}, then this method will use ISO 19139:2007 schema. */ private void roundtrip(final RepresentativeFraction browse, String expected) throws JAXBException { final String actual; final Version version; if (legacy) { expected = toLegacyXML(expected); version = VERSION_2007; } else { version = VERSION_2014; } actual = marshal(browse, version); assertXmlEquals(expected, actual, "xmlns:*"); assertEquals(browse, unmarshal(RepresentativeFraction.class, actual)); }
/** * Tests XML marshalling using ISO 19139:2007 schema. * This XML fragment contains an identifier. * * @throws JAXBException if an error occurred during marshalling. */ @Test @DependsOnMethod("testMarshalling") public void testMarshallingLegacy() throws JAXBException { legacy = true; testMarshalling(); }
/** * Tests XML marshalling using ISO 19115-3 schema. * This XML fragment contains an identifier. * * @throws JAXBException if an error occurred during marshalling. */ @Test public void testMarshalling() throws JAXBException { final DefaultRepresentativeFraction fraction = new DefaultRepresentativeFraction(8); fraction.getIdentifierMap().putSpecialized(IdentifierSpace.ID, "scale"); roundtrip(fraction, "<mri:MD_RepresentativeFraction xmlns:mri=\"" + Namespaces.MRI + '"' + " xmlns:gco=\"" + Namespaces.GCO + '"' + " id=\"scale\">\n" + " <mri:denominator>\n" + " <gco:Integer>8</gco:Integer>\n" + " </mri:denominator>\n" + "</mri:MD_RepresentativeFraction>"); }