use of org.opengis.metadata.citation.Citation in project sis by apache.
the class MetadataWriterTest method read.
/**
* Reads known entries in the database.
* Expected entry is:
*
* {@preformat text
* Citation
* ├─Title………………………………………………………… EPSG Geodetic Parameter Dataset
* ├─Identifier
* │ └─Code………………………………………………… EPSG
* ├─Cited responsible party
* │ ├─Party
* │ │ ├─Name……………………………………… International Association of Oil & Gas Producers
* │ │ └─Contact info
* │ │ └─Online resource
* │ │ ├─Linkage………… http://www.epsg.org
* │ │ └─Function……… Information
* │ └─Role………………………………………………… Principal investigator
* └─Presentation form………………………… Table digital
* }
*
* @throws MetadataStoreException if an error occurred while reading the database.
*/
private void read() throws MetadataStoreException {
final Citation c = source.lookup(Citation.class, "EPSG");
assertEquals("EPSG Geodetic Parameter Dataset", c.getTitle().toString());
assertEquals(PresentationForm.TABLE_DIGITAL, TestUtilities.getSingleton(c.getPresentationForms()));
/*
* Ask for dependencies that are known to exist.
*/
final ResponsibleParty responsible = TestUtilities.getSingleton(c.getCitedResponsibleParties());
assertEquals(Role.PRINCIPAL_INVESTIGATOR, responsible.getRole());
assertEquals("International Association of Oil & Gas Producers", responsible.getOrganisationName().toString());
OnlineResource resource = responsible.getContactInfo().getOnlineResource();
assertEquals("http://www.epsg.org", resource.getLinkage().toString());
assertEquals(OnLineFunction.INFORMATION, resource.getFunction());
/*
* Ask columns that are known to not exist.
*/
assertNull(c.getEditionDate());
assertTrue(c.getDates().isEmpty());
assertEquals(0, c.getAlternateTitles().size());
/*
* Test the cache.
*/
assertSame(c, source.lookup(Citation.class, "EPSG"));
assertNotSame(c, source.lookup(Citation.class, "SIS"));
/*
* Should return the identifier with no search. Actually the real test is the call to "proxy",
* since there is no way to ensure that the call to "search" tooks the short path (except by
* looking at the debugger). But if "proxy" succeed, then "search" should be okay.
*/
assertEquals("EPSG", source.proxy(c));
assertEquals("EPSG", source.search(c));
}
use of org.opengis.metadata.citation.Citation in project sis by apache.
the class FreeTextMarshallingTest method testLegacy.
/**
* Tests parsing of a free text in the legacy (pre-Geotk 3.17) format.
* We continue to support this format for compatibility reason, but
* also because it is more compact and closer to what we would expect
* inside a {@code <textGroup>} node.
*
* @throws JAXBException if the XML in this test can not be parsed by JAXB.
*/
@Test
public void testLegacy() throws JAXBException {
final String legacy = "<cit:CI_Citation xmlns:lan=\"" + Namespaces.LAN + '"' + " xmlns:cit=\"" + Namespaces.CIT + '"' + " xmlns:gco=\"" + Namespaces.GCO + '"' + " xmlns:xsi=\"" + Namespaces.XSI + "\">\n" + " <cit:title xsi:type=\"lan:PT_FreeText_PropertyType\">\n" + " <gco:CharacterString>OpenSource Project</gco:CharacterString>\n" + " <lan:PT_FreeText>\n" + " <lan:textGroup>\n" + " <lan:LocalisedCharacterString locale=\"#locale-eng\">OpenSource Project</lan:LocalisedCharacterString>\n" + " <lan:LocalisedCharacterString locale=\"#locale-ita\">Progetto OpenSource</lan:LocalisedCharacterString>\n" + " <lan:LocalisedCharacterString locale=\"#locale-fra\">Projet OpenSource</lan:LocalisedCharacterString>\n" + " </lan:textGroup>\n" + " </lan:PT_FreeText>\n" + " </cit:title>\n" + "</cit:CI_Citation>\n";
final Citation citation = unmarshal(Citation.class, legacy);
assertEquals(getExpectedI18N(), citation.getTitle());
}
use of org.opengis.metadata.citation.Citation in project sis by apache.
the class FreeTextMarshallingTest method testStandard.
/**
* Tests parsing of a free text in an ISO 19139-compliant way.
* The free text is wrapped inside a citation for marshalling
* purpose, but only the free text is actually tested.
*
* @throws JAXBException if the XML in this test can not be parsed by JAXB.
*/
@Test
public void testStandard() throws JAXBException {
final String expected = "<cit:CI_Citation xmlns:lan=\"" + Namespaces.LAN + '"' + " xmlns:cit=\"" + Namespaces.CIT + '"' + " xmlns:gco=\"" + Namespaces.GCO + '"' + " xmlns:xsi=\"" + Namespaces.XSI + "\">\n" + " <cit:title xsi:type=\"lan:PT_FreeText_PropertyType\">\n" + " <gco:CharacterString>OpenSource Project</gco:CharacterString>\n" + " <lan:PT_FreeText>\n" + " <lan:textGroup>\n" + " <lan:LocalisedCharacterString locale=\"#locale-eng\">OpenSource Project</lan:LocalisedCharacterString>\n" + " </lan:textGroup>\n" + " <lan:textGroup>\n" + " <lan:LocalisedCharacterString locale=\"#locale-ita\">Progetto OpenSource</lan:LocalisedCharacterString>\n" + " </lan:textGroup>\n" + " <lan:textGroup>\n" + " <lan:LocalisedCharacterString locale=\"#locale-fra\">Projet OpenSource</lan:LocalisedCharacterString>\n" + " </lan:textGroup>\n" + " </lan:PT_FreeText>\n" + " </cit:title>\n" + "</cit:CI_Citation>\n";
final Citation citation = unmarshal(Citation.class, expected);
assertEquals(getExpectedI18N(), citation.getTitle());
final String actual = marshal(citation);
assertXmlEquals(expected, actual, "xmlns:*");
}
use of org.opengis.metadata.citation.Citation in project sis by apache.
the class NilReasonMarshallingTest method testURI.
/**
* Tests a case where the nil reason is specified by a URI.
*
* @throws JAXBException if an error occurred during (un)marshalling.
*/
@Test
@DependsOnMethod("testMissing")
public void testURI() throws JAXBException {
final String expected = "<cit:CI_Citation xmlns:cit=\"" + Namespaces.CIT + '"' + " xmlns:gco=\"" + Namespaces.GCO + "\">\n" + " <cit:title>\n" + " <gco:CharacterString>A title</gco:CharacterString>\n" + " </cit:title>\n" + " <cit:series gco:nilReason=\"http://www.myreason.org\"/>\n" + "</cit:CI_Citation>";
final Citation citation = unmarshal(Citation.class, expected);
assertTitleEquals("citation", "A title", citation);
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 = marshal(citation);
assertXmlEquals(expected, actual, "xmlns:*");
assertEquals(citation, unmarshal(Citation.class, actual));
}
use of org.opengis.metadata.citation.Citation in project sis by apache.
the class NilReasonMarshallingTest method testOther.
/**
* Tests a case where the nil reason is specified by an other reason.
*
* @throws JAXBException if an error occurred during (un)marshalling.
*/
@Test
@DependsOnMethod("testMissing")
public void testOther() throws JAXBException {
final String expected = "<cit:CI_Citation xmlns:cit=\"" + Namespaces.CIT + '"' + " xmlns:gco=\"" + Namespaces.GCO + "\">\n" + " <cit:title>\n" + " <gco:CharacterString>A title</gco:CharacterString>\n" + " </cit:title>\n" + " <cit:series gco:nilReason=\"other:myReason\"/>\n" + "</cit:CI_Citation>";
final Citation citation = unmarshal(Citation.class, expected);
assertTitleEquals("citation", "A title", citation);
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 = marshal(citation);
assertXmlEquals(expected, actual, "xmlns:*");
assertEquals(citation, unmarshal(Citation.class, actual));
}
Aggregations