Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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 In order to define a reader test at least two files must be provided in the resource directory of the reader module. They must be placed in the same package as the implemented reader plugin. The files must follow this naming convention:

...

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

The files must be located in

...

    \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 68320841) and apath to the test data and an optional description (see class org.esa.snap.dataio.TestProduct).

Code Block
languagepy
{
  "testProducts": [   
    {
      "id": "LC81960222013195LGN00",
      "relativePath": "sensors_platforms/LANDSAT/LANDSAT_8_OLI_TIRS/geotiff/LC81960222013195LGN00/LC81960222013195LGN00_MTL.txt",
      "description": "Landsat 8 OLI_TIRS GeoTIFF Test product, PROCESSING_SOFTWARE_VERSION: LPGS_2.2.2"
    },
    {
      "id": "LT51970222006231KIS02",
      "relativePath": "sensors_platforms/LANDSAT/LANDSAT_5_TM/legacy/LT51970222006231KIS02.tar.gz",
      "description": "Landsat 5 legacy Test product, PROCESSING_SOFTWARE: LPGS_11.0.0"
    },
    {
      "id": "L71191027_02720070313",
      "relativePath": "sensors_platforms/LANDSAT/LANDSAT_7_ETM/legacy/L71191027_02720070313/L71191027_02720070313_MTL.txt",
      "description": "Landsat 7 legacy Test product, Product type: Landsat7_ETM+_L1T, PROCESSING_SOFTWARE: LPGS_10.1.0"
    }
  ]
}


Within the product-id file the expected content of each the product is defined (see class org.esa.snap.dataio.ExpectedContent).

...

The file L71191027_02720070313.json shows the example content. How such a file can be created is explained further down, in the section 'Create the Expected Content'.


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.

1. Execute Tests within the Reader 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 reader implementation must be added to the dependency list of the snap-reader-tests module. This is the approach used for the toolboxes, like s2tbx and s1tbx. 

Note
titleAttention

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.

After committing the JSON files the reader tests are automatically executed on the build server.

2. Execute Tests within the SNAP Reader Test Project.

For the second approach, the dependency on the snap-reader-test project has to be added to the list of the reader dependencies.

This approach can be used by external reader acceptance tests (like SMOS-Box, SeaDAS), , like in ProbaVBox or SeaDAS. Here you need to implement a test class extending 'org.esa.snap.dataio.ProductReaderAcceptanceTest', leaving its implementation empty. Just This is only to have something in the projected which can be started start.

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

...

Code Block
languagexml
   
<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.

Instead of using the compiled plugin within a SNAP installation, also the cluster which is build can be used within the IDE. The path to the cluster must be set '–cluster' parameter. See also How to run and debug SNAP from an IDE

Code Block
languagebash
--clusters
"C:\Users\Marco\Projects\senbox\s1tbx\s1tbx-kit\target\netbeans_clusters\s1tbx;C:\Users\Marco\Projects\senbox\s2tbx\s2tbx-kit\target\netbeans_clusters\s2tbx;C:\Users\Marco\Projects\senbox\s3tbx\s3tbx-kit\target\netbeans_clusters\s3tbx;C:\Users\Marco\Projects\senbox\snap-reader-tests\target\nbm\netbeans\extra"