Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 13 Next »

Introduction

The SNAP product reader test is located in the snap-reader tests project.

The tests are defined in the JUnit class org.esa.snap.dataio.ProductReaderAcceptanceTest.

This test class contains 5 different test methods:

testOneIntendedReader - checks if there is only one reader which is intended for a product. Multiple intended readers can cause problems.
testPluginDecodeQualifications - checks if returned decode qualification is as expected and the detection of the qualification doesn't take too long.
testProductIO_readProduct - simply opens the product, without reading raster data.
testProductReadTimes - testing how long reading of data takes and logs the results.

testReadIntendedProductContent - this is the most important test. It ensures that the project structure is as expected, the data is correctly read and the geo-information is as required.


Executing the Reader Tests

Configuration

To run the reader tests, simply execute the JUnit test class ProductReaderAcceptanceTest either in your IDE or with maven.

Java VM system properties are used to configure the execution.

This property enables the acceptance test runner. If not set or set to false, all reader acceptance tests are skipped and a message is printed to the console window. Only unit-level tests are executed in this case.-Dsnap.reader.tests.execute=true

-Dsnap.reader.tests.data.dir=<Path_To_Data>

This property defines the root directory for the test dataset. All test-product definitions are referenced relative to this root directory. If the property is not set or does not denote a valid directory, the test setup fails. The data is at different locations on the server and the local system. But from this specified base folder, the directory structure must be the same.

-Dsnap.reader.tests.failOnMissingData=false

By default, the reader tests fail if test data is missing. This property can be set to false to avoid this. It is helpful for developers if they don't have the complete test data set on their developer machine.

-Dsnap.reader.tests.failOnMultipleIntendedReaders=false

By default, the reader tests fail if there is more then one reader intended for one file. This property can be set to false to avoid this.

-Dsnap.reader.tests.log.file=<Path_To_LogFile>

Specifies the path to the log file which will be written. If not specified, no log file will be created.

-Dsnap.reader.tests.class.name=<ProductReaderPlugIn_ClassName>

If the ProductReaderPlugIn class name is given, the tests for this reader plugin are executed only. It is also possible to indicate the package of the reader plugins: for example, if <ProductReaderPlugIn_ClassName> is "org.esa.s3tbx.dataio.landsat", the tests for all the landsat reader plugins will be executed.


Creating a New Reader Test

A number of files must be provided in the resource directory of the reader module. They must be placed in the same package as the implemented plugin. The files must follow this naming convention:

    <READER_PLUGIN_NAME>-data.json
    <PRODUCT-ID>.json

where <PRODUCT-ID> must match the product identifier that is defined within the *-data.json file.

Example for Landsat:

Plugin is

    org.esa.snap.dataio.landsat.geotiff.LandsatGeotiffReaderPlugin.

The files must be located in

    \src\main\resources\org\esa\snap\dataio\landsat\geotiff\LandsatGeotiffReaderPlugin-data.json
    \src\main\resources\org\esa\snap\dataio\landsat\geotiff\L71191027_02720070313.json


Within the data file the test products are defined. Each definition consists of an id, a relative Path (see How to run and create a Reader Test) and a

description (see class org.esa.snap.dataio.TestProduct). Within the product-id file the expected content of each product

is defined (see class org.esa.snap.dataio.ExpectedContent).


Defining the dependencies

There are two different approaches for executing the reader tests: execute them when building the reader or execute them with the snap-reader-test project.

In the first case, the dependency to the snap-reader-test project has to be added to the list of the reader dependencies.

With the other approach, the dependency to the reader must be added to the dependency list of the snap-reader-tests module.

Attention

Remember to install the reader module to your local maven repository after you have made changes. The dependencies used by the snap-reader-tests link to the installed jars. If not installed the old code will be used for the new test.


For external reader acceptance tests (like SMOS-Box, SeaDAS), you need to implement a test class extending 'org.esa.snap.dataio.ProductReaderAcceptanceTest', leaving its implementation empty. Just to have something which can be started start.

In the dependency list of the external module the 'test-jar' type of the snap-reader-tests dependency must be added.

    <dependency>
        <groupId>org.esa.snap</groupId>
        <artifactId>snap-reader-tests</artifactId>
        <version>${snap.version}</version>
    </dependency>
    <dependency>
        <groupId>org.esa.snap</groupId>
        <artifactId>snap-reader-tests</artifactId>
        <type>test-jar</type>
        <scope>test</scope>
        <version>${snap.version}</version>
    </dependency>

Create the expected content

It is possible to add the snap-reader-tests as a new plugin in SNAP. Once installed, an option in the menu will be available in order to generate the expected content:

It will generate the expected content by selecting randomly some pixel values for every band, metadata fields... If some pins have been selected in the product, then the pixel values will be collected in these points.

  • No labels