/** * Tests unmarshalling of {@code <gcx:FileName>} without {@code src} attribute. * * @throws JAXBException if an error occurred while (un)marshalling the {@code BrowseGraphic}. */ @Test @DependsOnMethod("testFileName") public void testFileNameWithoutSrc() throws JAXBException { final DefaultBrowseGraphic browse = unmarshal(DefaultBrowseGraphic.class, "<mcc:MD_BrowseGraphic xmlns:mcc=\"" + Namespaces.MCC + '"' + " xmlns:gcx=\"" + Namespaces.GCX + "\">\n" + " <mcc:fileName>\n" + " <gcx:FileName>file:/catalog/image.png</gcx:FileName>\n" + " </mcc:fileName>\n" + "</mcc:MD_BrowseGraphic>"); assertEquals(URI.create("file:/catalog/image.png"), browse.getFileName()); }
/** * Implementation of {@link #testWarnings()} using the given {@code <mcc:fileName>} values. */ private void testWarnings(final String first, final String second) throws JAXBException { final Warning listener = new Warning(); final DefaultBrowseGraphic browse = listener.unmarshal( "<mcc:MD_BrowseGraphic xmlns:mcc=\"" + Namespaces.MCC + '"' + " xmlns:gcx=\"" + Namespaces.GCX + '"' + " xmlns:gco=\"" + Namespaces.GCO + "\">\n" + " <mcc:fileName>\n" + " " + first + "\n" + " " + second + "\n" + " </mcc:fileName>\n" + "</mcc:MD_BrowseGraphic>"); assertEquals(URI.create("file:/catalog/image.png"), browse.getFileName()); assertTrue("Expected a warning.", listener.receivedWarning); }
/** * Tests the unmarshaller with the same URI in both {@code <gco:CharacterString>} and {@code <gcx:FileName>}. * Since the URI is the same, the unmarshaller should not produce any warning since there is no ambiguity. * * @throws JAXBException if an error occurred while (un)marshalling the {@code BrowseGraphic}. */ @Test @DependsOnMethod("testStringSubstitution") public void testDuplicatedValues() throws JAXBException { final Warning listener = new Warning(); final DefaultBrowseGraphic browse = listener.unmarshal( "<mcc:MD_BrowseGraphic xmlns:mcc=\"" + Namespaces.MCC + '"' + " xmlns:gcx=\"" + Namespaces.GCX + '"' + " xmlns:gco=\"" + Namespaces.GCO + "\">\n" + " <mcc:fileName>\n" + " <gcx:FileName src=\"file:/catalog/image.png\">image.png</gcx:FileName>\n" + " <gco:CharacterString>file:/catalog/image.png</gco:CharacterString>\n" + " </mcc:fileName>\n" + "</mcc:MD_BrowseGraphic>"); assertEquals(URI.create("file:/catalog/image.png"), browse.getFileName()); assertFalse("Expected no warning.", listener.receivedWarning); }