|
10 | 10 | import org.jdom2.xpath.XPathFactory;
|
11 | 11 | import org.junit.Test;
|
12 | 12 | import org.junit.experimental.categories.Category;
|
| 13 | +import org.junit.runner.RunWith; |
| 14 | +import org.junit.runners.Parameterized; |
13 | 15 | import thredds.test.util.TestOnLocalServer;
|
14 | 16 | import thredds.util.xml.XmlUtil;
|
15 | 17 | import ucar.unidata.util.test.category.NeedsCdmUnitTest;
|
16 | 18 |
|
17 | 19 | import java.io.IOException;
|
18 | 20 | import java.nio.charset.StandardCharsets;
|
| 21 | +import java.util.Arrays; |
19 | 22 | import java.util.List;
|
20 | 23 |
|
21 | 24 | import static com.google.common.truth.Truth.assertThat;
|
22 | 25 |
|
23 | 26 | @Category(NeedsCdmUnitTest.class)
|
| 27 | +@RunWith(Parameterized.class) |
24 | 28 | public class TestRadarServerQuery {
|
25 | 29 | private static final Namespace NS =
|
26 | 30 | Namespace.getNamespace("ns", "http://www.unidata.ucar.edu/namespaces/thredds/InvCatalog/v1.0");
|
27 |
| - private static final String L2_URL = "/radarServer/nexrad/level2/IDD"; |
28 |
| - private static final String L3_URL = "/radarServer/nexrad/level3/IDD"; |
| 31 | + |
| 32 | + private final String l2Url; |
| 33 | + private final String l3Url; |
| 34 | + |
| 35 | + @Parameterized.Parameters(name = "{0}") |
| 36 | + public static List<String> getTestParameters() { |
| 37 | + return Arrays.asList("", "s3/"); |
| 38 | + } |
| 39 | + |
| 40 | + public TestRadarServerQuery(String datasetPathPrefix) { |
| 41 | + l2Url = "/radarServer/" + datasetPathPrefix + "nexrad/level2/IDD"; |
| 42 | + l3Url = "/radarServer/" + datasetPathPrefix + "nexrad/level3/IDD"; |
| 43 | + } |
29 | 44 |
|
30 | 45 | @Test
|
31 | 46 | public void shouldReturnAllDatasetsForStation() throws IOException, JDOMException {
|
32 |
| - String endpoint = L2_URL + "?stn=KDGX&temporal=all"; |
| 47 | + String endpoint = l2Url + "?stn=KDGX&temporal=all"; |
33 | 48 | verifyNumberOfDatasets(endpoint, 3);
|
34 | 49 | }
|
35 | 50 |
|
36 | 51 | @Test
|
37 | 52 | public void shouldReturnZeroDatasetsForNonOverlappingTimeRange() throws IOException, JDOMException {
|
38 |
| - String endpoint = L2_URL + "?stn=KDGX&time_start=2000-01-01T12:00:00&time_end=2001-01-01T12:00:00"; |
| 53 | + String endpoint = l2Url + "?stn=KDGX&time_start=2000-01-01T12:00:00&time_end=2001-01-01T12:00:00"; |
39 | 54 | verifyNumberOfDatasets(endpoint, 0);
|
40 | 55 | }
|
41 | 56 |
|
42 | 57 | @Test
|
43 | 58 | public void shouldReturnOneDatasetForOverlappingTimeRange() throws IOException, JDOMException {
|
44 |
| - String endpoint = L2_URL + "?stn=KDGX&time_start=2014-06-02T23:52:00&time_end=2014-06-02T23:53:00"; |
| 59 | + String endpoint = l2Url + "?stn=KDGX&time_start=2014-06-02T23:52:00&time_end=2014-06-02T23:53:00"; |
45 | 60 | verifyNumberOfDatasets(endpoint, 1);
|
46 | 61 | }
|
47 | 62 |
|
48 | 63 | @Test
|
49 | 64 | public void shouldReturnOneDatasetForOverlappingTimeDuration() throws IOException, JDOMException {
|
50 |
| - String endpoint = L2_URL + "?stn=KDGX&time_start=2014-06-02T23:52:00&time_duration=PT1M"; |
| 65 | + String endpoint = l2Url + "?stn=KDGX&time_start=2014-06-02T23:52:00&time_duration=PT1M"; |
51 | 66 | verifyNumberOfDatasets(endpoint, 1);
|
52 | 67 | }
|
53 | 68 |
|
54 | 69 | @Test
|
55 | 70 | public void shouldReturnOneDatasetForTime() throws IOException, JDOMException {
|
56 |
| - String endpoint = L2_URL + "?stn=KDGX&time=2014-06-02T23:52:00"; |
| 71 | + String endpoint = l2Url + "?stn=KDGX&time=2014-06-02T23:52:00"; |
57 | 72 | verifyNumberOfDatasets(endpoint, 1);
|
58 | 73 | }
|
59 | 74 |
|
60 | 75 | @Test
|
61 | 76 | public void shouldReturnZeroDatasetsForNonExistentStation() throws IOException, JDOMException {
|
62 |
| - String endpoint = L2_URL + "?stn=ABCD&temporal=all"; |
| 77 | + String endpoint = l2Url + "?stn=ABCD&temporal=all"; |
63 | 78 | verifyNumberOfDatasets(endpoint, 0);
|
64 | 79 | }
|
65 | 80 |
|
66 | 81 | @Test
|
67 | 82 | public void shouldReturnErrorForNonOverlappingBox() throws IOException, JDOMException {
|
68 |
| - String endpoint = L2_URL + "?north=10&south=0&west=-100&east=-80&temporal=all"; |
| 83 | + String endpoint = l2Url + "?north=10&south=0&west=-100&east=-80&temporal=all"; |
69 | 84 | byte[] result = TestOnLocalServer.getContent(TestOnLocalServer.withHttpPath(endpoint), HttpServletResponse.SC_OK,
|
70 | 85 | "text/plain;charset=iso-8859-1");
|
71 | 86 | assertThat(new String(result, StandardCharsets.UTF_8)).isEqualTo("No stations found for specified coordinates.");
|
72 | 87 | }
|
73 | 88 |
|
74 | 89 | @Test
|
75 | 90 | public void shouldReturnAllDatasetsForOverlappingBox() throws IOException, JDOMException {
|
76 |
| - String endpoint = L2_URL + "?north=50&south=30&west=-100&east=-80&temporal=all"; |
| 91 | + String endpoint = l2Url + "?north=50&south=30&west=-100&east=-80&temporal=all"; |
77 | 92 | verifyNumberOfDatasets(endpoint, 3);
|
78 | 93 | }
|
79 | 94 |
|
80 | 95 | @Test
|
81 | 96 | public void shouldReturnAllDatasetsForLonLat() throws IOException, JDOMException {
|
82 |
| - String endpoint = L2_URL + "?latitude=30&longitude=-90&temporal=all"; |
| 97 | + String endpoint = l2Url + "?latitude=30&longitude=-90&temporal=all"; |
83 | 98 | verifyNumberOfDatasets(endpoint, 3);
|
84 | 99 | }
|
85 | 100 |
|
86 | 101 | @Test
|
87 | 102 | public void shouldReturnAllLevel3Datasets() throws IOException, JDOMException {
|
88 |
| - String endpoint = L3_URL + "?temporal=all&var=N0R&stn=UDX"; |
| 103 | + String endpoint = l3Url + "?temporal=all&var=N0R&stn=UDX"; |
89 | 104 | verifyNumberOfDatasets(endpoint, 329);
|
90 | 105 | }
|
91 | 106 |
|
92 | 107 | @Test
|
93 | 108 | public void shouldReturnErrorWithoutVar() throws IOException, JDOMException {
|
94 |
| - String endpoint = L3_URL + "?temporal=all&stn=UDX"; |
| 109 | + String endpoint = l3Url + "?temporal=all&stn=UDX"; |
95 | 110 | byte[] result = TestOnLocalServer.getContent(TestOnLocalServer.withHttpPath(endpoint), HttpServletResponse.SC_OK,
|
96 | 111 | "text/plain;charset=iso-8859-1");
|
97 | 112 | assertThat(new String(result, StandardCharsets.UTF_8)).isEqualTo("One or more variables required.");
|
|
0 commit comments