|
19 | 19 | package org.esa.snap.dataio.znap; |
20 | 20 |
|
21 | 21 | import com.bc.zarr.ZarrConstants; |
| 22 | +import com.google.common.jimfs.Configuration; |
22 | 23 | import com.google.common.jimfs.Jimfs; |
23 | 24 | import org.esa.snap.core.dataio.DecodeQualification; |
24 | 25 | import org.esa.snap.core.util.io.TreeDeleter; |
25 | 26 | import org.junit.After; |
26 | 27 | import org.junit.Before; |
27 | 28 | import org.junit.Test; |
| 29 | +import org.junit.runner.RunWith; |
28 | 30 |
|
| 31 | +import java.io.File; |
29 | 32 | import java.io.IOException; |
30 | 33 | import java.nio.file.FileSystem; |
31 | 34 | import java.nio.file.Files; |
32 | 35 | import java.nio.file.Path; |
| 36 | +import java.nio.file.Paths; |
33 | 37 |
|
34 | 38 | import static org.hamcrest.MatcherAssert.assertThat; |
35 | 39 | import static org.hamcrest.Matchers.equalTo; |
36 | 40 | import static org.hamcrest.Matchers.is; |
| 41 | +import static org.junit.Assume.assumeNotNull; |
37 | 42 |
|
38 | 43 | public class ZnapProductReaderPlugInTest_getDecodeQualification { |
39 | 44 |
|
@@ -95,7 +100,7 @@ public void decodeQualification_INTENDED_perfectMatch_inputStringObject() throws |
95 | 100 |
|
96 | 101 | @Test |
97 | 102 | public void decodeQualification_INTENDED_perfectMatch_inputHasNoParent() throws IOException { |
98 | | - try(FileSystem fileSystem = Jimfs.newFileSystem()) { |
| 103 | + try (FileSystem fileSystem = Jimfs.newFileSystem()) { |
99 | 104 | Path path = fileSystem.getPath("snap_zarr_product_root_dir.znap"); |
100 | 105 |
|
101 | 106 | Path dataDir = path.resolve("a_raster_data_dir"); |
@@ -127,17 +132,30 @@ public void decodeQualification_UNABLE_inputObjectIsNullOrCanNotBeConvertedToPat |
127 | 132 | } |
128 | 133 |
|
129 | 134 | @Test |
130 | | - public void decodeQualification_UNABLE_productRootDoesNotExist() { |
131 | | - // No file or directory as expected |
| 135 | + public void decodeQualification_UNABLE_productRootDoesNotExist() throws IOException { |
| 136 | + try (FileSystem fileSystem = Jimfs.newFileSystem()) { |
| 137 | + Path path = fileSystem.getPath("any_not_supported_file.tar"); |
132 | 138 |
|
133 | | - final DecodeQualification decodeQualification = plugIn.getDecodeQualification(productRoot); |
| 139 | + final DecodeQualification decodeQualification = plugIn.getDecodeQualification(path); |
| 140 | + assertThat(decodeQualification, is(equalTo(DecodeQualification.UNABLE))); |
| 141 | + } |
| 142 | + |
| 143 | + } |
| 144 | + |
| 145 | + @Test() |
| 146 | + public void decodeQualification_UNABLE_AnyFileAtRootLevel() { |
| 147 | + String systemDrive = System.getenv("SystemDrive"); |
| 148 | + assumeNotNull(systemDrive); // only on windows not null |
| 149 | + Path root = Paths.get(systemDrive); |
| 150 | + Path notValid = root.resolve("any_not_supported_file.notznap"); |
134 | 151 |
|
| 152 | + final DecodeQualification decodeQualification = plugIn.getDecodeQualification(notValid); |
135 | 153 | assertThat(decodeQualification, is(equalTo(DecodeQualification.UNABLE))); |
136 | 154 | } |
137 | 155 |
|
138 | 156 | @Test |
139 | 157 | public void decodeQualification_UNABLE_aZGroupFileWhichHasNoParentDir() throws IOException { |
140 | | - try(FileSystem fileSystem = Jimfs.newFileSystem()) { |
| 158 | + try (FileSystem fileSystem = Jimfs.newFileSystem()) { |
141 | 159 | Path path = fileSystem.getPath("any_zarr_group_file_without_parent.zgroup"); |
142 | 160 | final DecodeQualification decodeQualification = plugIn.getDecodeQualification(path); |
143 | 161 |
|
|
0 commit comments