use of org.apache.sis.storage.StorageConnector in project sis by apache.
the class NetcdfStoreProviderTest method testProbeContentFromStream.
/**
* Tests {@link NetcdfStoreProvider#probeContent(StorageConnector)} for an input stream which shall
* be recognized as a classic netCDF file.
*
* @throws DataStoreException if a logical error occurred.
*/
@Test
public void testProbeContentFromStream() throws DataStoreException {
final StorageConnector c = new StorageConnector(IOTestCase.getResourceAsStream(NCEP));
final NetcdfStoreProvider provider = new NetcdfStoreProvider();
final ProbeResult probe = provider.probeContent(c);
assertTrue("isSupported", probe.isSupported());
assertEquals("getMimeType", NetcdfStoreProvider.MIME_TYPE, probe.getMimeType());
assertEquals("getVersion", new Version("1"), probe.getVersion());
c.closeAllExcept(null);
}
use of org.apache.sis.storage.StorageConnector in project sis by apache.
the class NetcdfStoreProviderTest method testProbeContentFromUCAR.
/**
* Tests {@link NetcdfStoreProvider#probeContent(StorageConnector)} for a UCAR {@link NetcdfFile} object.
*
* @throws IOException if an error occurred while opening the netCDF file.
* @throws DataStoreException if a logical error occurred.
*/
@Test
public void testProbeContentFromUCAR() throws IOException, DataStoreException {
try (NetcdfFile file = open(NCEP)) {
final StorageConnector c = new StorageConnector(file);
final NetcdfStoreProvider provider = new NetcdfStoreProvider();
final ProbeResult probe = provider.probeContent(c);
assertTrue("isSupported", probe.isSupported());
assertEquals("getMimeType", NetcdfStoreProvider.MIME_TYPE, probe.getMimeType());
assertNull("getVersion", probe.getVersion());
}
}
use of org.apache.sis.storage.StorageConnector in project sis by apache.
the class StoreTest method testFromInputStream.
/**
* Tests {@link StoreProvider#probeContent(StorageConnector)} followed by {@link Store#getMetadata()}
* reading from an {@link java.io.InputStream}. This method tests indirectly {@link StorageConnector}
* capability to reset the {@code InputStream} to its original position after {@code probeContent(…)}.
*
* @throws DataStoreException if en error occurred while reading the WKT.
*/
@Test
public void testFromInputStream() throws DataStoreException {
final Metadata metadata;
final StoreProvider p = new StoreProvider();
final StorageConnector c = new StorageConnector(new ByteArrayInputStream(StoreTest.WKT.getBytes(StandardCharsets.US_ASCII)));
assertTrue("isSupported", p.probeContent(c).isSupported());
try (Store store = new Store(null, c)) {
metadata = store.getMetadata();
assertSame("Expected cached value.", metadata, store.getMetadata());
}
validate((GeographicCRS) TestUtilities.getSingleton(metadata.getReferenceSystemInfo()));
}
use of org.apache.sis.storage.StorageConnector in project sis by apache.
the class StoreProviderTest method testProbeContentFromReader.
/**
* Tests {@link StoreProvider#probeContent(StorageConnector)} method from a {@link java.io.Reader} object.
*
* @throws DataStoreException if en error occurred while reading the XML.
*/
@Test
public void testProbeContentFromReader() throws DataStoreException {
final StoreProvider p = new StoreProvider();
final StorageConnector c = new StorageConnector(new StringReader(StoreTest.XML));
final ProbeResult r = p.probeContent(c);
c.closeAllExcept(null);
assertTrue("isSupported", r.isSupported());
assertEquals("mimeType", "application/vnd.iso.19139+xml", r.getMimeType());
}
use of org.apache.sis.storage.StorageConnector in project sis by apache.
the class StoreTest method testMetadata.
/**
* Tests {@link Store#getMetadata()}.
*
* @throws DataStoreException if en error occurred while reading the XML.
*/
@Test
public void testMetadata() throws DataStoreException {
final Metadata metadata;
try (Store store = new Store(null, new StorageConnector(new StringReader(XML)))) {
metadata = store.getMetadata();
assertSame("Expected cached value.", metadata, store.getMetadata());
}
final ResponsibleParty resp = getSingleton(metadata.getContacts());
final Contact contact = resp.getContactInfo();
final OnlineResource resource = contact.getOnlineResource();
assertEquals(Locale.ENGLISH, metadata.getLanguage());
if (!REGRESSION)
assertEquals(CharacterSet.UTF_8, metadata.getCharacterSet());
assertEquals(Role.PRINCIPAL_INVESTIGATOR, resp.getRole());
assertEquals("Apache SIS", String.valueOf(resp.getOrganisationName()));
assertEquals("http://sis.apache.org", String.valueOf(resource.getLinkage()));
assertEquals(OnLineFunction.INFORMATION, resource.getFunction());
}
Aggregations