use of org.opengis.metadata.identification.BrowseGraphic in project sis by apache.
the class DefaultBrowseGraphicTest method testStringSubstitution.
/**
* Tests XML marshalling of filename substituted by {@code <gco:CharacterString>}
* inside {@code <mcc:MD_BrowseGraphic>}.
*
* @throws JAXBException if an error occurred while (un)marshalling the {@code BrowseGraphic}.
*/
@Test
@DependsOnMethod("testFileNameAndType")
public void testStringSubstitution() throws JAXBException {
final DefaultBrowseGraphic browse = new DefaultBrowseGraphic(URI.create("file:/catalog/image.png"));
browse.setFileType("image/tiff");
final MarshallerPool pool = getMarshallerPool();
final Marshaller marshaller = pool.acquireMarshaller();
marshaller.setProperty(XML.STRING_SUBSTITUTES, new String[] { "filename", "mimetype" });
final String xml = marshal(marshaller, browse);
pool.recycle(marshaller);
assertXmlEquals("<mcc:MD_BrowseGraphic xmlns:mcc=\"" + Namespaces.MCC + '"' + " xmlns:gco=\"" + Namespaces.GCO + "\">\n" + " <mcc:fileName>\n" + " <gco:CharacterString>file:/catalog/image.png</gco:CharacterString>\n" + " </mcc:fileName>\n" + " <mcc:fileType>\n" + " <gco:CharacterString>image/tiff</gco:CharacterString>\n" + " </mcc:fileType>\n" + "</mcc:MD_BrowseGraphic>", xml, "xmlns:*");
/*
* Unmarshal the element back to a Java object and compare to the original.
*/
assertEquals(browse, unmarshal(BrowseGraphic.class, xml));
}
use of org.opengis.metadata.identification.BrowseGraphic in project sis by apache.
the class DefaultBrowseGraphicTest method roundtrip.
/**
* 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 BrowseGraphic 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(BrowseGraphic.class, actual));
}
Aggregations