use of org.opengis.metadata.Metadata in project sis by apache.
the class LanguageCodeTest method testUnmarshalLanguageCode.
/**
* Tests the unmarshalling using the {@code <gmd:LanguageCode>} construct. XML fragment:
*
* {@preformat xml
* <gmd:MD_Metadata>
* <gmd:language>
* <gmd:LanguageCode codeList="(snip)/gmxCodelists.xml#LanguageCode" codeListValue="jpn">Japanese</gmd:LanguageCode>
* </gmd:language>
* </gmd:MD_Metadata>
* }
*
* @throws JAXBException if an error occurs while unmarshalling the language.
*
* @see #testMarshalLanguageCode()
*/
@Test
public void testUnmarshalLanguageCode() throws JAXBException {
final Unmarshaller unmarshaller = pool.acquireUnmarshaller();
final String xml = getMetadataXML(LANGUAGE_CODE);
final Metadata metadata = (Metadata) unmarshal(unmarshaller, xml);
assertEquals(Locale.JAPANESE, metadata.getLanguage());
}
use of org.opengis.metadata.Metadata in project sis by apache.
the class LanguageCodeTest method testLanguageCodeWithoutAttributes.
/**
* Tests the unmarshalling using the {@code <gmd:LanguageCode>} construct without attributes.
* The adapter is expected to parse the element value. XML fragment:
*
* {@preformat xml
* <gmd:MD_Metadata>
* <gmd:language>
* <gmd:LanguageCode>jpn</gmd:LanguageCode>
* </gmd:language>
* </gmd:MD_Metadata>
* }
*
* @throws JAXBException if an error occurs while unmarshalling the language.
*/
@Test
@DependsOnMethod("testMarshalLanguageCode")
public void testLanguageCodeWithoutAttributes() throws JAXBException {
final Unmarshaller unmarshaller = pool.acquireUnmarshaller();
final String xml = getMetadataXML(LANGUAGE_CODE_WITHOUT_ATTRIBUTE);
final Metadata metadata = (Metadata) unmarshal(unmarshaller, xml);
assertEquals(Locale.JAPANESE, metadata.getLanguage());
pool.recycle(unmarshaller);
}
use of org.opengis.metadata.Metadata in project sis by apache.
the class StoreTest method testFromReader.
/**
* Tests {@link Store#getMetadata()} reading from a {@link java.io.Reader}.
*
* @throws DataStoreException if an error occurred while reading the metadata.
*/
@Test
public void testFromReader() throws DataStoreException {
final Metadata metadata;
try (Store store = new Store(null, new StorageConnector(new StringReader(WKT)))) {
metadata = store.getMetadata();
assertSame("Expected cached value.", metadata, store.getMetadata());
}
validate((GeographicCRS) TestUtilities.getSingleton(metadata.getReferenceSystemInfo()));
}
use of org.opengis.metadata.Metadata in project sis by apache.
the class MetadataReaderTest method testEmbedded.
/**
* Reads the metadata using the netCDF decoder embedded with SIS,
* and compares its string representation with the expected one.
*
* @throws IOException if an I/O error occurred while opening the file.
* @throws DataStoreException if a logical error occurred.
*/
@Test
public void testEmbedded() throws IOException, DataStoreException {
final Metadata metadata;
try (Decoder input = ChannelDecoderTest.createChannelDecoder(NCEP)) {
metadata = new MetadataReader(input).read();
}
compareToExpected(metadata);
}
use of org.opengis.metadata.Metadata in project sis by apache.
the class MetadataCommand method run.
/**
* Prints metadata or CRS information.
*
* @return 0 on success, or an exit code if the command failed for a reason other than an uncaught Java exception.
*/
@Override
public int run() throws Exception {
/*
* Read metadata from the data storage only after we verified that the arguments are valid.
* The input can be a file given on the command line, or the standard input stream.
*/
Object metadata = readMetadataOrCRS();
if (hasUnexpectedFileCount) {
return Command.INVALID_ARGUMENT_EXIT_CODE;
}
if (metadata != null) {
if (!(metadata instanceof Metadata)) {
final DefaultMetadata md = new DefaultMetadata();
md.setReferenceSystemInfo(Collections.singleton((ReferenceSystem) metadata));
metadata = md;
}
format(metadata);
}
return 0;
}
Aggregations