You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2018/05/21 14:51:06 UTC
svn commit: r1831975 [2/2] - in /sis/trunk: ./
application/sis-console/src/main/java/org/apache/sis/console/
application/sis-console/src/test/java/org/apache/sis/console/
core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/
core/sis-metadata/s...
Modified: sis/trunk/storage/sis-netcdf/src/test/java/org/apache/sis/internal/netcdf/VariableTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-netcdf/src/test/java/org/apache/sis/internal/netcdf/VariableTest.java?rev=1831975&r1=1831974&r2=1831975&view=diff
==============================================================================
--- sis/trunk/storage/sis-netcdf/src/test/java/org/apache/sis/internal/netcdf/VariableTest.java [UTF-8] (original)
+++ sis/trunk/storage/sis-netcdf/src/test/java/org/apache/sis/internal/netcdf/VariableTest.java [UTF-8] Mon May 21 14:51:05 2018
@@ -18,7 +18,9 @@ package org.apache.sis.internal.netcdf;
import java.io.IOException;
import org.apache.sis.math.Vector;
+import org.apache.sis.util.Workaround;
import org.apache.sis.storage.DataStoreException;
+import org.apache.sis.internal.netcdf.ucar.DecoderWrapper;
import org.apache.sis.test.DependsOn;
import org.junit.Test;
@@ -29,10 +31,10 @@ import static org.opengis.test.Assert.*;
* Tests the {@link Variable} implementation. The default implementation tests
* {@code org.apache.sis.internal.netcdf.ucar.VariableWrapper} since the UCAR
* library is our reference implementation. However subclasses can override the
- * {@link #createDecoder(String)} method in order to test a different implementation.
+ * {@link #createDecoder(TestData)} method in order to test a different implementation.
*
* @author Martin Desruisseaux (Geomatys)
- * @version 0.8
+ * @version 1.0
* @since 0.3
* @module
*/
@@ -45,7 +47,41 @@ public strictfp class VariableTest exten
private static final int NUM_BASIC_PROPERTY_COLUMNS = 6;
/**
- * Tests the basic properties of all variables found in the {@link #NCEP} file.
+ * Whether the {@code "runtime"} variable in {@link TestData#NETCDF_4D_PROJECTED} is considered an axis or not.
+ * The UCAR library considers it as an axis because it has an {@code "_CoordinateAxisType"} attribute.
+ * Apache SIS does not consider it as an axis because that variable does not match any dimension and is not used
+ * in any other variable.
+ */
+ protected boolean isRuntimeAnAxis;
+
+ /**
+ * Creates a new test.
+ */
+ public VariableTest() {
+ isRuntimeAnAxis = true;
+ }
+
+ /**
+ * Gets the variable from the given decoder, reordering them if the decoder is a wrapper for UCAR library.
+ * We perform this reordering because UCAR library does not always return the variables in the order they
+ * are declared. In the case of the {@link TestData#NETCDF_4D_PROJECTED} file, the CIP variable is expected
+ * last but UCAR library put it second.
+ */
+ @Workaround(library = "UCAR", version = "4.6.11")
+ private Variable[] getVariablesCIP(final Decoder decoder) {
+ Variable[] variables = decoder.getVariables();
+ if (decoder instanceof DecoderWrapper) {
+ variables = variables.clone();
+ final Variable cip = variables[1];
+ final int last = variables.length - 1;
+ System.arraycopy(variables, 2, variables, 1, last - 1);
+ variables[last] = cip;
+ }
+ return variables;
+ }
+
+ /**
+ * Tests the basic properties of all variables found in the {@link TestData#NETCDF_4D_PROJECTED} file.
* The tested methods are:
*
* <ul>
@@ -63,34 +99,15 @@ public strictfp class VariableTest exten
@Test
public void testBasicProperties() throws IOException, DataStoreException {
assertBasicPropertiesEqual(new Object[] {
- // __name______________description_________________________________datatype_______dim__axis?__raster?
- "reftime", "reference time", DataType.DOUBLE, 1, false, false,
- "datetime", "reference date and time", DataType.CHAR, 2, false, false,
- "forecasttime", "forecast date and time", DataType.CHAR, 2, false, false,
- "model_id", "generating process ID number", DataType.INT, 1, false, false,
- "nav_model", "navigation model name", DataType.CHAR, 2, false, false,
- "grid_type_code", "GRIB-1 GDS data representation type", DataType.INT, 1, false, false,
- "grid_type", "GRIB-1 grid type", DataType.CHAR, 2, false, false,
- "grid_name", "grid name", DataType.CHAR, 2, false, false,
- "grid_center", "GRIB-1 originating center ID", DataType.INT, 1, false, false,
- "grid_number", "GRIB-1 catalogued grid numbers", DataType.INT, 2, false, false,
- "i_dim", "longitude dimension name", DataType.CHAR, 2, false, false,
- "j_dim", "latitude dimension name", DataType.CHAR, 2, false, false,
- "Ni", "number of points along a latitude circle", DataType.INT, 1, false, false,
- "Nj", "number of points along a longitude circle", DataType.INT, 1, false, false,
- "La1", "latitude of first grid point", DataType.FLOAT, 1, false, false,
- "Lo1", "longitude of first grid point", DataType.FLOAT, 1, false, false,
- "La2", "latitude of last grid point", DataType.FLOAT, 1, false, false,
- "Lo2", "longitude of last grid point", DataType.FLOAT, 1, false, false,
- "Di", "longitudinal direction increment", DataType.FLOAT, 1, false, false,
- "Dj", "latitudinal direction increment", DataType.FLOAT, 1, false, false,
- "ResCompFlag", "resolution and component flags", DataType.BYTE, 1, false, false,
- "SST", "Sea temperature", DataType.FLOAT, 3, false, true,
- "valtime", "valid time", DataType.DOUBLE, 1, true, false,
- "valtime_offset", "hours from reference time", DataType.DOUBLE, 1, true, false,
- "lat", "latitude", DataType.FLOAT, 1, true, false,
- "lon", "longitude", DataType.FLOAT, 1, true, false
- }, selectDataset(NCEP).getVariables());
+ // __name______________description_____________________datatype_______dim__axis?__raster?
+ "grid_mapping_0", null, DataType.INT, 0, false, false,
+ "x0", "projection_x_coordinate", DataType.FLOAT, 1, true, false,
+ "y0", "projection_y_coordinate", DataType.FLOAT, 1, true, false,
+ "z0", "Flight levels in 100s of feet", DataType.FLOAT, 1, true, false,
+ "time", "Data time", DataType.DOUBLE, 1, true, false,
+ "runtime", "Data generation time", DataType.DOUBLE, 1, isRuntimeAnAxis, false,
+ "CIP", "Current Icing Product", DataType.FLOAT, 4, false, true
+ }, getVariablesCIP(selectDataset(TestData.NETCDF_4D_PROJECTED)));
}
/**
@@ -119,23 +136,44 @@ public strictfp class VariableTest exten
}
/**
- * Tests {@link Variable#getGridDimensionNames()} and {@link Variable#getGridEnvelope()}.
- * Current implementation tests on the {@code "SST"} variable.
+ * Tests {@link Variable#getGridDimensionNames()} and {@link Variable#getGridEnvelope()}
+ * on a simple two-dimensional dataset.
*
* @throws IOException if an I/O error occurred while opening the file.
* @throws DataStoreException if a logical error occurred.
*/
@Test
- public void testGridDimensions() throws IOException, DataStoreException {
- final Variable variable = selectDataset(NCEP).getVariables()[21];
+ public void testGridRange2D() throws IOException, DataStoreException {
+ final Variable variable = selectDataset(TestData.NETCDF_2D_GEOGRAPHIC).getVariables()[0];
assertEquals("SST", variable.getName());
assertArrayEquals("getGridDimensionNames()", new String[] {
- "record", "lat", "lon"
+ "lat", "lon"
}, variable.getGridDimensionNames());
assertArrayEquals("getGridEnvelope()", new int[] {
- 1, 73, 73
+ 73, 73
+ }, variable.getGridEnvelope());
+ }
+
+ /**
+ * Tests {@link Variable#getGridDimensionNames()} and {@link Variable#getGridEnvelope()}
+ * on a compound four-dimensional dataset.
+ *
+ * @throws IOException if an I/O error occurred while opening the file.
+ * @throws DataStoreException if a logical error occurred.
+ */
+ @Test
+ public void testGridRange4D() throws IOException, DataStoreException {
+ final Variable variable = getVariablesCIP(selectDataset(TestData.NETCDF_4D_PROJECTED))[6];
+ assertEquals("CIP", variable.getName());
+
+ assertArrayEquals("getGridDimensionNames()", new String[] {
+ "time", "z0", "y0", "x0"
+ }, variable.getGridDimensionNames());
+
+ assertArrayEquals("getGridEnvelope()", new int[] {
+ 1, 4, 19, 38
}, variable.getGridEnvelope());
}
@@ -147,18 +185,18 @@ public strictfp class VariableTest exten
*/
@Test
public void testGetAttributes() throws IOException, DataStoreException {
- final Variable[] variables = selectDataset(NCEP).getVariables();
- Variable variable = variables[9];
- assertEquals("grid_number", variable.getName());
- assertArrayEquals("grid_number:_FillValue", new Number[] { -9999 }, variable.getAttributeValues("_FillValue", true));
- assertArrayEquals("grid_number:_FillValue", new String[] {"-9999"}, variable.getAttributeValues("_FillValue", false));
-
- variable = variables[21];
- assertEquals("SST", variable.getName());
- assertArrayEquals("SST:_FillValue", new Number[] { -9999f }, variable.getAttributeValues("_FillValue", true));
- assertArrayEquals("SST:_FillValue", new String[] {"-9999.0"}, variable.getAttributeValues("_FillValue", false));
- assertArrayEquals("SST:units", new String[] {"degK"}, variable.getAttributeValues("units", false));
- assertArrayEquals("SST:units", new Number[] { }, variable.getAttributeValues("units", true));
+ final Variable[] variables = getVariablesCIP(selectDataset(TestData.NETCDF_4D_PROJECTED));
+ Variable variable = variables[6];
+ assertEquals("CIP", variable.getName());
+ assertArrayEquals("CIP:_FillValue", new Number[] { -1f }, variable.getAttributeValues("_FillValue", true));
+ assertArrayEquals("CIP:_FillValue", new String[] {"-1.0"}, variable.getAttributeValues("_FillValue", false));
+ assertArrayEquals("CIP:units", new String[] { "%"}, variable.getAttributeValues("units", false));
+ assertArrayEquals("CIP:units", new Number[] { }, variable.getAttributeValues("units", true));
+
+ variable = variables[0];
+ assertEquals("grid_mapping_0", variable.getName());
+ assertArrayEquals("standard_parallel", new Number[] { 25.f, 25.05f}, variable.getAttributeValues("standard_parallel", true));
+ assertArrayEquals("standard_parallel", new String[] {"25.0", "25.05"}, variable.getAttributeValues("standard_parallel", false));
}
/**
@@ -169,7 +207,7 @@ public strictfp class VariableTest exten
*/
@Test
public void testRead1D() throws IOException, DataStoreException {
- final Variable variable = selectDataset(NCEP).getVariables()[25];
+ final Variable variable = selectDataset(TestData.NETCDF_2D_GEOGRAPHIC).getVariables()[2];
assertEquals("lon", variable.getName());
final Vector data = variable.read();
assertEquals("lon", Float.class, data.getElementType());
Modified: sis/trunk/storage/sis-netcdf/src/test/java/org/apache/sis/internal/netcdf/impl/ChannelDecoderTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-netcdf/src/test/java/org/apache/sis/internal/netcdf/impl/ChannelDecoderTest.java?rev=1831975&r1=1831974&r2=1831975&view=diff
==============================================================================
--- sis/trunk/storage/sis-netcdf/src/test/java/org/apache/sis/internal/netcdf/impl/ChannelDecoderTest.java [UTF-8] (original)
+++ sis/trunk/storage/sis-netcdf/src/test/java/org/apache/sis/internal/netcdf/impl/ChannelDecoderTest.java [UTF-8] Mon May 21 14:51:05 2018
@@ -20,7 +20,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.channels.Channels;
-import org.apache.sis.internal.netcdf.IOTestCase;
+import org.apache.sis.internal.netcdf.TestData;
import org.apache.sis.internal.netcdf.Decoder;
import org.apache.sis.internal.netcdf.DecoderTest;
import org.apache.sis.internal.storage.io.ChannelDataInput;
@@ -28,8 +28,6 @@ import org.apache.sis.storage.DataStoreE
import org.apache.sis.setup.GeometryLibrary;
import org.apache.sis.test.DependsOn;
-import static org.junit.Assume.*;
-
/**
* Tests the {@link ChannelDecoder} implementation. This test shall be executed only if the
@@ -37,54 +35,42 @@ import static org.junit.Assume.*;
* passed.
*
* @author Martin Desruisseaux (Geomatys)
- * @version 0.3
+ * @version 1.0
* @since 0.3
* @module
*/
@DependsOn(DecoderTest.class)
public final strictfp class ChannelDecoderTest extends DecoderTest {
/**
- * Creates a new decoder for dataset of the given name.
+ * Creates a new decoder for the specified dataset.
*
- * @return the decoder for the given name.
+ * @return the decoder for the specified dataset.
* @throws IOException if an I/O error occurred while opening the file.
* @throws DataStoreException if a logical error occurred.
*/
@Override
- protected Decoder createDecoder(final String name) throws IOException, DataStoreException {
- return createChannelDecoder(name);
+ protected Decoder createDecoder(final TestData file) throws IOException, DataStoreException {
+ return createChannelDecoder(file);
}
/**
- * Creates a new {@link ChannelDecoder} instance for dataset of the given name.
- * The {@code name} parameter can be one of the following values:
+ * Creates a new {@link ChannelDecoder} instance for the specified dataset.
+ * The {@code file} parameter can be one of the following values:
*
* <ul>
- * <li>{@link #NCEP} for a netCDF binary file.</li>
- * <li>{@link #CIP} for a netCDF binary file.</li>
+ * <li>{@link TestData#NETCDF_2D_GEOGRAPHIC} — uses a geographic CRS for global data over the world.</li>
+ * <li>{@link TestData#NETCDF_4D_PROJECTED} — uses a projected CRS with elevation and time.</li>
* </ul>
*
- * @param name the file name as one of the above-cited constants.
- * @return the decoder for the given name.
+ * @param file the file as one of the above-cited constants.
+ * @return the decoder for the specified dataset.
* @throws IOException if an I/O error occurred while opening the file.
* @throws DataStoreException if a logical error occurred.
*/
- public static Decoder createChannelDecoder(final String name) throws IOException, DataStoreException {
- final InputStream in = IOTestCase.class.getResourceAsStream(name);
- assumeNotNull(name, in);
- final ChannelDataInput input = new ChannelDataInput(name,
+ public static Decoder createChannelDecoder(final TestData file) throws IOException, DataStoreException {
+ final InputStream in = file.open();
+ final ChannelDataInput input = new ChannelDataInput(file.name(),
Channels.newChannel(in), ByteBuffer.allocate(4096), false);
return new ChannelDecoder(input, null, GeometryLibrary.JAVA2D, LISTENERS);
}
-
- /**
- * Unconditionally returns {@code false} since {@link ChannelDecoder}
- * supports only the classic and 64 bits netCDF formats.
- *
- * @return {@code false}.
- */
- @Override
- protected boolean isSupplementalFormatSupported(final String format) {
- return false;
- }
}
Modified: sis/trunk/storage/sis-netcdf/src/test/java/org/apache/sis/internal/netcdf/impl/GridGeometryInfoTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-netcdf/src/test/java/org/apache/sis/internal/netcdf/impl/GridGeometryInfoTest.java?rev=1831975&r1=1831974&r2=1831975&view=diff
==============================================================================
--- sis/trunk/storage/sis-netcdf/src/test/java/org/apache/sis/internal/netcdf/impl/GridGeometryInfoTest.java [UTF-8] (original)
+++ sis/trunk/storage/sis-netcdf/src/test/java/org/apache/sis/internal/netcdf/impl/GridGeometryInfoTest.java [UTF-8] Mon May 21 14:51:05 2018
@@ -20,6 +20,7 @@ import java.io.IOException;
import org.apache.sis.internal.netcdf.Decoder;
import org.apache.sis.internal.netcdf.GridGeometry;
import org.apache.sis.internal.netcdf.GridGeometryTest;
+import org.apache.sis.internal.netcdf.TestData;
import org.apache.sis.storage.DataStoreException;
import org.apache.sis.util.ArraysExt;
import org.apache.sis.test.DependsOn;
@@ -31,33 +32,22 @@ import org.apache.sis.test.DependsOn;
* passed.
*
* @author Martin Desruisseaux (Geomatys)
- * @version 0.3
+ * @version 1.0
* @since 0.3
* @module
*/
@DependsOn({VariableInfoTest.class, GridGeometryTest.class})
public final strictfp class GridGeometryInfoTest extends GridGeometryTest {
/**
- * Creates a new decoder for dataset of the given name.
+ * Creates a new decoder for the specified dataset.
*
- * @return the decoder for the given name.
+ * @return the decoder for the specified dataset.
* @throws IOException if an I/O error occurred while opening the file.
* @throws DataStoreException if a logical error occurred.
*/
@Override
- protected Decoder createDecoder(final String name) throws IOException, DataStoreException {
- return ChannelDecoderTest.createChannelDecoder(name);
- }
-
- /**
- * Unconditionally returns {@code false} since {@link ChannelDecoder}
- * supports only the classic and 64 bits netCDF formats.
- *
- * @return {@code false}.
- */
- @Override
- protected boolean isSupplementalFormatSupported(final String format) {
- return false;
+ protected Decoder createDecoder(final TestData file) throws IOException, DataStoreException {
+ return ChannelDecoderTest.createChannelDecoder(file);
}
/**
Modified: sis/trunk/storage/sis-netcdf/src/test/java/org/apache/sis/internal/netcdf/impl/VariableInfoTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-netcdf/src/test/java/org/apache/sis/internal/netcdf/impl/VariableInfoTest.java?rev=1831975&r1=1831974&r2=1831975&view=diff
==============================================================================
--- sis/trunk/storage/sis-netcdf/src/test/java/org/apache/sis/internal/netcdf/impl/VariableInfoTest.java [UTF-8] (original)
+++ sis/trunk/storage/sis-netcdf/src/test/java/org/apache/sis/internal/netcdf/impl/VariableInfoTest.java [UTF-8] Mon May 21 14:51:05 2018
@@ -19,6 +19,7 @@ package org.apache.sis.internal.netcdf.i
import java.io.IOException;
import org.apache.sis.internal.netcdf.Decoder;
import org.apache.sis.internal.netcdf.VariableTest;
+import org.apache.sis.internal.netcdf.TestData;
import org.apache.sis.storage.DataStoreException;
import org.apache.sis.test.DependsOn;
import org.junit.Test;
@@ -32,33 +33,29 @@ import static org.junit.Assert.*;
* passed.
*
* @author Martin Desruisseaux (Geomatys)
- * @version 0.8
+ * @version 1.0
* @since 0.3
* @module
*/
@DependsOn({ChannelDecoderTest.class, VariableTest.class})
public final strictfp class VariableInfoTest extends VariableTest {
/**
- * Creates a new decoder for dataset of the given name.
- *
- * @return the decoder for the given dataset.
- * @throws IOException if an I/O error occurred while opening the file.
- * @throws DataStoreException if a logical error occurred.
+ * Creates a new test.
*/
- @Override
- protected Decoder createDecoder(final String name) throws IOException, DataStoreException {
- return ChannelDecoderTest.createChannelDecoder(name);
+ public VariableInfoTest() {
+ isRuntimeAnAxis = false;
}
/**
- * Unconditionally returns {@code false} since {@link ChannelDecoder}
- * supports only the classic and 64 bits netCDF formats.
+ * Creates a new decoder for the specified dataset.
*
- * @return {@code false}.
+ * @return the decoder for the specified dataset.
+ * @throws IOException if an I/O error occurred while opening the file.
+ * @throws DataStoreException if a logical error occurred.
*/
@Override
- protected boolean isSupplementalFormatSupported(final String format) {
- return false;
+ protected Decoder createDecoder(final TestData file) throws IOException, DataStoreException {
+ return ChannelDecoderTest.createChannelDecoder(file);
}
/**
Modified: sis/trunk/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/MetadataReaderTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/MetadataReaderTest.java?rev=1831975&r1=1831974&r2=1831975&view=diff
==============================================================================
--- sis/trunk/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/MetadataReaderTest.java [UTF-8] (original)
+++ sis/trunk/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/MetadataReaderTest.java [UTF-8] Mon May 21 14:51:05 2018
@@ -17,21 +17,26 @@
package org.apache.sis.storage.netcdf;
import java.io.IOException;
-import ucar.nc2.dataset.NetcdfDataset;
import org.opengis.metadata.Metadata;
+import org.opengis.metadata.citation.Role;
+import org.opengis.metadata.citation.DateType;
+import org.opengis.metadata.identification.KeywordType;
+import org.opengis.metadata.content.TransferFunctionType;
+import org.opengis.metadata.spatial.SpatialRepresentationType;
+import org.opengis.metadata.spatial.DimensionNameType;
+import org.opengis.metadata.spatial.CellGeometry;
+import org.opengis.metadata.maintenance.ScopeCode;
+import org.apache.sis.internal.netcdf.TestData;
import org.apache.sis.internal.netcdf.TestCase;
import org.apache.sis.internal.netcdf.Decoder;
-import org.apache.sis.internal.netcdf.IOTestCase;
-import org.apache.sis.internal.netcdf.ucar.DecoderWrapper;
import org.apache.sis.internal.netcdf.impl.ChannelDecoderTest;
-import org.apache.sis.metadata.iso.DefaultMetadata;
import org.apache.sis.storage.DataStoreException;
-import org.apache.sis.setup.GeometryLibrary;
+import org.apache.sis.test.ContentVerifier;
import org.apache.sis.test.DependsOn;
import org.junit.Test;
import static org.apache.sis.test.Assert.*;
-import static org.apache.sis.test.TestUtilities.formatNameAndValue;
+import static org.apache.sis.test.TestUtilities.date;
/**
@@ -47,7 +52,7 @@ import static org.apache.sis.test.TestUt
ChannelDecoderTest.class,
org.apache.sis.internal.netcdf.impl.VariableInfoTest.class
})
-public final strictfp class MetadataReaderTest extends IOTestCase {
+public final strictfp class MetadataReaderTest extends TestCase {
/**
* Tests {@link MetadataReader#split(String)}.
*/
@@ -67,7 +72,7 @@ public final strictfp class MetadataRead
@Test
public void testEmbedded() throws IOException, DataStoreException {
final Metadata metadata;
- try (Decoder input = ChannelDecoderTest.createChannelDecoder(NCEP)) {
+ try (Decoder input = ChannelDecoderTest.createChannelDecoder(TestData.NETCDF_2D_GEOGRAPHIC)) {
metadata = new MetadataReader(input).read();
}
compareToExpected(metadata);
@@ -83,7 +88,7 @@ public final strictfp class MetadataRead
@Test
public void testUCAR() throws IOException, DataStoreException {
final Metadata metadata;
- try (Decoder input = new DecoderWrapper(new NetcdfDataset(open(NCEP)), GeometryLibrary.JAVA2D, TestCase.LISTENERS)) {
+ try (Decoder input = createDecoder(TestData.NETCDF_2D_GEOGRAPHIC)) {
metadata = new MetadataReader(input).read();
}
compareToExpected(metadata);
@@ -91,88 +96,60 @@ public final strictfp class MetadataRead
/**
* Compares the string representation of the given metadata object with the expected one.
- * The given metadata shall have been created from the {@link #NCEP} dataset.
+ * The given metadata shall have been created from the {@link TestData#NETCDF_2D_GEOGRAPHIC} dataset.
*/
static void compareToExpected(final Metadata actual) {
- final String text = formatNameAndValue(DefaultMetadata.castOrCopy(actual).asTreeTable());
- assertMultilinesEquals(
- "Metadata\n" +
- " ├─Metadata identifier……………………………………………………………… NCEP/SST/Global_5x2p5deg/SST_Global_5x2p5deg_20050922_0000.nc\n" +
- " │ └─Authority……………………………………………………………………………… edu.ucar.unidata\n" +
- " ├─Contact\n" +
- " │ ├─Role…………………………………………………………………………………………… Point of contact\n" +
- " │ └─Individual…………………………………………………………………………… NOAA/NWS/NCEP\n" + // TODO: actually we can not distinguish individual from organization.
- " ├─Metadata standard (1 of 2)…………………………………………… Geographic Information — Metadata Part 1: Fundamentals\n" +
- " │ ├─Edition…………………………………………………………………………………… ISO 19115-1:2014(E)\n" +
- " │ ├─Identifier…………………………………………………………………………… 19115-1\n" +
- " │ │ ├─Code space………………………………………………………………… ISO\n" +
- " │ │ └─Version………………………………………………………………………… 2014(E)\n" +
- " │ ├─Cited responsible party\n" +
- " │ │ ├─Role………………………………………………………………………………… Principal investigator\n" +
- " │ │ └─Organisation…………………………………………………………… International Organization for Standardization\n" +
- " │ └─Presentation form………………………………………………………… Document digital\n" +
- " ├─Metadata standard (2 of 2)…………………………………………… Geographic Information — Metadata Part 2: Extensions for imagery and gridded data\n" +
- " │ ├─Edition…………………………………………………………………………………… ISO 19115-2:2009(E)\n" +
- " │ ├─Identifier…………………………………………………………………………… 19115-2\n" +
- " │ │ ├─Code space………………………………………………………………… ISO\n" +
- " │ │ └─Version………………………………………………………………………… 2009(E)\n" +
- " │ ├─Cited responsible party\n" +
- " │ │ ├─Role………………………………………………………………………………… Principal investigator\n" +
- " │ │ └─Organisation…………………………………………………………… International Organization for Standardization\n" +
- " │ └─Presentation form………………………………………………………… Document digital\n" +
- " ├─Spatial representation info\n" +
- " │ ├─Number of dimensions………………………………………………… 3\n" +
- " │ ├─Axis dimension properties (1 of 3)…………… Column\n" +
- " │ │ └─Dimension size……………………………………………………… 73\n" +
- " │ ├─Axis dimension properties (2 of 3)…………… Row\n" +
- " │ │ └─Dimension size……………………………………………………… 73\n" +
- " │ ├─Axis dimension properties (3 of 3)…………… Time\n" +
- " │ │ └─Dimension size……………………………………………………… 1\n" +
- " │ ├─Cell geometry…………………………………………………………………… Area\n" +
- " │ └─Transformation parameter availability…… false\n" +
- " ├─Identification info\n" +
- " │ ├─Citation………………………………………………………………………………… Sea Surface Temperature Analysis Model\n" +
- " │ │ ├─Date………………………………………………………………………………… 2005-09-22 00:00:00\n" +
- " │ │ │ └─Date type………………………………………………………… Creation\n" +
- " │ │ ├─Identifier………………………………………………………………… NCEP/SST/Global_5x2p5deg/SST_Global_5x2p5deg_20050922_0000.nc\n" +
- " │ │ │ └─Authority………………………………………………………… edu.ucar.unidata\n" +
- " │ │ └─Cited responsible party\n" +
- " │ │ ├─Role……………………………………………………………………… Originator\n" +
- " │ │ └─Individual……………………………………………………… NOAA/NWS/NCEP\n" + // TODO: actually we can not distinguish individual from organization.
- " │ ├─Abstract………………………………………………………………………………… NCEP SST Global 5.0 x 2.5 degree model data\n" +
- " │ ├─Point of contact\n" +
- " │ │ ├─Role………………………………………………………………………………… Point of contact\n" +
- " │ │ └─Individual………………………………………………………………… NOAA/NWS/NCEP\n" +
- " │ ├─Spatial representation type……………………………… Grid\n" +
- " │ ├─Extent\n" +
- " │ │ ├─Geographic element\n" +
- " │ │ │ ├─West bound longitude…………………………… 180°W\n" +
- " │ │ │ ├─East bound longitude…………………………… 180°E\n" +
- " │ │ │ ├─South bound latitude…………………………… 90°S\n" +
- " │ │ │ ├─North bound latitude…………………………… 90°N\n" +
- " │ │ │ └─Extent type code……………………………………… true\n" +
- " │ │ └─Vertical element\n" +
- " │ │ ├─Minimum value……………………………………………… 0.0\n" +
- " │ │ └─Maximum value……………………………………………… 0.0\n" +
- " │ ├─Descriptive keywords\n" +
- " │ │ ├─Keyword………………………………………………………………………… EARTH SCIENCE > Oceans > Ocean Temperature > Sea Surface Temperature\n" +
- " │ │ ├─Type………………………………………………………………………………… Theme\n" +
- " │ │ └─Thesaurus name……………………………………………………… GCMD Science Keywords\n" +
- " │ └─Resource constraints\n" +
- " │ └─Use limitation……………………………………………………… Freely available\n" +
- " ├─Content info\n" +
- " │ └─Attribute group\n" +
- " │ └─Attribute…………………………………………………………………… SST\n" +
- " │ ├─Description…………………………………………………… Sea temperature\n" +
- " │ ├─Name……………………………………………………………………… sea_water_temperature\n" +
- " │ └─Units…………………………………………………………………… K\n" +
- " ├─Data quality info\n" +
- " │ ├─Scope\n" +
- " │ │ └─Level……………………………………………………………………………… Dataset\n" +
- " │ └─Lineage\n" +
- " │ └─Statement…………………………………………………………………… 2003-04-07 12:12:50 - created by gribtocdl" +
- " 2005-09-26T21:50:00 - edavis - add attributes for dataset discovery\n" +
- " └─Metadata scope\n" +
- " └─Resource scope………………………………………………………………… Dataset\n", text);
+ final ContentVerifier verifier = new ContentVerifier();
+ verifier.addPropertyToIgnore(Metadata.class, "metadataStandard");
+ verifier.addMetadataToVerify(actual);
+ verifier.assertMetadataEquals(
+ "dateInfo[0].date", date("2018-05-15 13:01:00"),
+ "dateInfo[0].dateType", DateType.REVISION,
+ "metadataScope[0].resourceScope", ScopeCode.DATASET,
+ "identificationInfo[0].abstract", "Global, two-dimensional model data",
+ "identificationInfo[0].purpose", "GeoAPI conformance tests",
+ "identificationInfo[0].supplementalInformation", "For testing purpose only.",
+ "identificationInfo[0].citation.title", "Test data from Sea Surface Temperature Analysis Model",
+ "identificationInfo[0].descriptiveKeywords[0].keyword[0]", "EARTH SCIENCE > Oceans > Ocean Temperature > Sea Surface Temperature",
+ "identificationInfo[0].descriptiveKeywords[0].thesaurusName.title", "GCMD Science Keywords",
+ "identificationInfo[0].descriptiveKeywords[0].type", KeywordType.THEME,
+ "identificationInfo[0].pointOfContact[0].role", Role.POINT_OF_CONTACT,
+ "identificationInfo[0].pointOfContact[0].party[0].name", "NOAA/NWS/NCEP",
+ "identificationInfo[0].citation.citedResponsibleParty[0].role", Role.ORIGINATOR,
+ "identificationInfo[0].citation.citedResponsibleParty[0].party[0].name", "NOAA/NWS/NCEP",
+ "identificationInfo[0].citation.date[0].date", date("2005-09-22 00:00:00"),
+ "identificationInfo[0].citation.date[1].date", date("2018-05-15 13:00:00"),
+ "identificationInfo[0].citation.date[0].dateType", DateType.CREATION,
+ "identificationInfo[0].citation.date[1].dateType", DateType.REVISION,
+ "identificationInfo[0].citation.identifier[0].code", "NCEP/SST/Global_5x2p5deg/SST_Global_5x2p5deg_20050922_0000.nc",
+ "identificationInfo[0].citation.identifier[0].authority.title", "edu.ucar.unidata",
+ "identificationInfo[0].resourceConstraints[0].useLimitation[0]", "Freely available",
+ "identificationInfo[0].extent[0].geographicElement[0].extentTypeCode", Boolean.TRUE,
+ "identificationInfo[0].extent[0].geographicElement[0].westBoundLongitude", -180.0,
+ "identificationInfo[0].extent[0].geographicElement[0].eastBoundLongitude", 180.0,
+ "identificationInfo[0].extent[0].geographicElement[0].southBoundLatitude", -90.0,
+ "identificationInfo[0].extent[0].geographicElement[0].northBoundLatitude", 90.0,
+ "identificationInfo[0].extent[0].verticalElement[0].maximumValue", 0.0,
+ "identificationInfo[0].extent[0].verticalElement[0].minimumValue", 0.0,
+ "identificationInfo[0].spatialRepresentationType[0]", SpatialRepresentationType.GRID,
+ "spatialRepresentationInfo[0].cellGeometry", CellGeometry.AREA,
+ "spatialRepresentationInfo[0].numberOfDimensions", 2,
+ "spatialRepresentationInfo[0].axisDimensionProperties[0].dimensionName", DimensionNameType.COLUMN,
+ "spatialRepresentationInfo[0].axisDimensionProperties[1].dimensionName", DimensionNameType.ROW,
+ "spatialRepresentationInfo[0].axisDimensionProperties[0].dimensionSize", 73,
+ "spatialRepresentationInfo[0].axisDimensionProperties[1].dimensionSize", 73,
+ "spatialRepresentationInfo[0].transformationParameterAvailability", false,
+
+ // Variable descriptions (only one in this test).
+ "contentInfo[0].attributeGroup[0].attribute[0].sequenceIdentifier", "SST",
+ "contentInfo[0].attributeGroup[0].attribute[0].description", "Sea temperature",
+ "contentInfo[0].attributeGroup[0].attribute[0].name[0].code", "sea_water_temperature",
+ "contentInfo[0].attributeGroup[0].attribute[0].transferFunctionType", TransferFunctionType.LINEAR,
+ "contentInfo[0].attributeGroup[0].attribute[0].scaleFactor", 0.0011,
+ "contentInfo[0].attributeGroup[0].attribute[0].offset", -1.85,
+ "contentInfo[0].attributeGroup[0].attribute[0].units", "°C",
+
+ "dataQualityInfo[0].lineage.statement", "Decimated and modified by GeoAPI for inclusion in conformance test suite.",
+ "dataQualityInfo[0].scope.level", ScopeCode.DATASET);
}
}
Modified: sis/trunk/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/NetcdfStoreProviderTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/NetcdfStoreProviderTest.java?rev=1831975&r1=1831974&r2=1831975&view=diff
==============================================================================
--- sis/trunk/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/NetcdfStoreProviderTest.java [UTF-8] (original)
+++ sis/trunk/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/NetcdfStoreProviderTest.java [UTF-8] Mon May 21 14:51:05 2018
@@ -18,7 +18,6 @@ package org.apache.sis.storage.netcdf;
import java.io.IOException;
import ucar.nc2.NetcdfFile;
-import org.apache.sis.internal.netcdf.IOTestCase;
import org.apache.sis.internal.netcdf.TestCase;
import org.apache.sis.internal.netcdf.Decoder;
import org.apache.sis.internal.netcdf.ucar.DecoderWrapper;
@@ -29,6 +28,7 @@ import org.apache.sis.storage.StorageCon
import org.apache.sis.storage.DataStoreException;
import org.apache.sis.util.Version;
import org.apache.sis.test.DependsOn;
+import org.apache.sis.internal.netcdf.TestData;
import org.junit.Test;
import static org.opengis.test.Assert.*;
@@ -38,14 +38,14 @@ import static org.opengis.test.Assert.*;
* Tests {@link NetcdfStoreProvider}.
*
* @author Martin Desruisseaux (Geomatys)
- * @version 0.4
+ * @version 1.0
* @since 0.3
* @module
*/
@DependsOn({
ChannelDecoderTest.class
})
-public final strictfp class NetcdfStoreProviderTest extends IOTestCase {
+public final strictfp class NetcdfStoreProviderTest extends TestCase {
/**
* Tests {@link NetcdfStoreProvider#probeContent(StorageConnector)} for an input stream which shall
* be recognized as a classic netCDF file.
@@ -54,7 +54,7 @@ public final strictfp class NetcdfStoreP
*/
@Test
public void testProbeContentFromStream() throws DataStoreException {
- final StorageConnector c = new StorageConnector(IOTestCase.getResourceAsStream(NCEP));
+ final StorageConnector c = new StorageConnector(TestData.NETCDF_2D_GEOGRAPHIC.location());
final NetcdfStoreProvider provider = new NetcdfStoreProvider();
final ProbeResult probe = provider.probeContent(c);
assertTrue ("isSupported", probe.isSupported());
@@ -71,7 +71,7 @@ public final strictfp class NetcdfStoreP
*/
@Test
public void testProbeContentFromUCAR() throws IOException, DataStoreException {
- try (NetcdfFile file = open(NCEP)) {
+ try (NetcdfFile file = createUCAR(TestData.NETCDF_2D_GEOGRAPHIC)) {
final StorageConnector c = new StorageConnector(file);
final NetcdfStoreProvider provider = new NetcdfStoreProvider();
final ProbeResult probe = provider.probeContent(c);
@@ -90,9 +90,9 @@ public final strictfp class NetcdfStoreP
*/
@Test
public void testDecoderFromStream() throws IOException, DataStoreException {
- final StorageConnector c = new StorageConnector(IOTestCase.getResourceAsStream(NCEP));
- try (Decoder decoder = NetcdfStoreProvider.decoder(TestCase.LISTENERS, c)) {
- assertInstanceOf(NCEP, ChannelDecoder.class, decoder);
+ final StorageConnector c = new StorageConnector(TestData.NETCDF_2D_GEOGRAPHIC.open());
+ try (Decoder decoder = NetcdfStoreProvider.decoder(LISTENERS, c)) {
+ assertInstanceOf("decoder", ChannelDecoder.class, decoder);
}
}
@@ -105,9 +105,9 @@ public final strictfp class NetcdfStoreP
*/
@Test
public void testDecoderFromUCAR() throws IOException, DataStoreException {
- final StorageConnector c = new StorageConnector(open(NCEP));
- try (Decoder decoder = NetcdfStoreProvider.decoder(TestCase.LISTENERS, c)) {
- assertInstanceOf(NCEP, DecoderWrapper.class, decoder);
+ final StorageConnector c = new StorageConnector(createUCAR(TestData.NETCDF_2D_GEOGRAPHIC));
+ try (Decoder decoder = NetcdfStoreProvider.decoder(LISTENERS, c)) {
+ assertInstanceOf("decoder", DecoderWrapper.class, decoder);
}
}
}
Modified: sis/trunk/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/NetcdfStoreTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/NetcdfStoreTest.java?rev=1831975&r1=1831974&r2=1831975&view=diff
==============================================================================
--- sis/trunk/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/NetcdfStoreTest.java [UTF-8] (original)
+++ sis/trunk/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/NetcdfStoreTest.java [UTF-8] Mon May 21 14:51:05 2018
@@ -17,10 +17,12 @@
package org.apache.sis.storage.netcdf;
import org.opengis.metadata.Metadata;
-import org.apache.sis.internal.netcdf.IOTestCase;
import org.apache.sis.storage.StorageConnector;
import org.apache.sis.storage.DataStoreException;
+import org.apache.sis.test.TestCase;
import org.apache.sis.test.DependsOn;
+import org.apache.sis.util.Version;
+import org.apache.sis.internal.netcdf.TestData;
import org.junit.Test;
import static org.opengis.test.Assert.*;
@@ -30,7 +32,7 @@ import static org.opengis.test.Assert.*;
* Tests {@link NetcdfStore}.
*
* @author Martin Desruisseaux (Geomatys)
- * @version 0.8
+ * @version 1.0
* @since 0.3
* @module
*/
@@ -38,15 +40,15 @@ import static org.opengis.test.Assert.*;
MetadataReaderTest.class,
NetcdfStoreProviderTest.class
})
-public final strictfp class NetcdfStoreTest extends IOTestCase {
+public final strictfp class NetcdfStoreTest extends TestCase {
/**
* Returns a new netCDF store to test.
*
* @param dataset the name of the datastore to load.
* @throws DataStoreException if an error occurred while reading the netCDF file.
*/
- private static NetcdfStore create(final String dataset) throws DataStoreException {
- return new NetcdfStore(null, new StorageConnector(IOTestCase.getResource(dataset)));
+ private static NetcdfStore create(final TestData dataset) throws DataStoreException {
+ return new NetcdfStore(null, new StorageConnector(dataset.location()));
}
/**
@@ -57,10 +59,25 @@ public final strictfp class NetcdfStoreT
@Test
public void testGetMetadata() throws DataStoreException {
final Metadata metadata;
- try (NetcdfStore store = create(NCEP)) {
+ try (NetcdfStore store = create(TestData.NETCDF_2D_GEOGRAPHIC)) {
metadata = store.getMetadata();
assertSame("Should be cached.", metadata, store.getMetadata());
}
MetadataReaderTest.compareToExpected(metadata);
}
+
+ /**
+ * Tests {@link NetcdfStore#getConventionVersion()}.
+ *
+ * @throws DataStoreException if an error occurred while reading the netCDF file.
+ */
+ @Test
+ public void testGetConventionVersion() throws DataStoreException {
+ final Version version;
+ try (NetcdfStore store = create(TestData.NETCDF_2D_GEOGRAPHIC)) {
+ version = store.getConventionVersion();
+ }
+ assertEquals("major", 1, version.getMajor());
+ assertEquals("minor", 4, version.getMinor());
+ }
}
Modified: sis/trunk/storage/sis-netcdf/src/test/java/org/apache/sis/test/suite/NetcdfTestSuite.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-netcdf/src/test/java/org/apache/sis/test/suite/NetcdfTestSuite.java?rev=1831975&r1=1831974&r2=1831975&view=diff
==============================================================================
--- sis/trunk/storage/sis-netcdf/src/test/java/org/apache/sis/test/suite/NetcdfTestSuite.java [UTF-8] (original)
+++ sis/trunk/storage/sis-netcdf/src/test/java/org/apache/sis/test/suite/NetcdfTestSuite.java [UTF-8] Mon May 21 14:51:05 2018
@@ -16,9 +16,7 @@
*/
package org.apache.sis.test.suite;
-import org.apache.sis.internal.netcdf.IOTestCase;
import org.apache.sis.test.TestSuite;
-import org.apache.sis.test.TestCase;
import org.junit.runners.Suite;
import org.junit.BeforeClass;
@@ -27,7 +25,7 @@ import org.junit.BeforeClass;
* All tests from the {@code sis-netcdf} module, in approximative dependency order.
*
* @author Martin Desruisseaux (Geomatys)
- * @version 0.8
+ * @version 1.0
* @since 0.3
* @module
*/
@@ -51,9 +49,6 @@ public final strictfp class NetcdfTestSu
@BeforeClass
public static void verifyTestList() {
assertNoMissingTest(NetcdfTestSuite.class);
- verifyTestList(NetcdfTestSuite.class, new Class<?>[] {
- TestCase.class,
- IOTestCase.class
- });
+ verifyTestList(NetcdfTestSuite.class);
}
}