Skip to content

Commit

Permalink
Merge pull request #539 from tdrwenski/s3-radar-server
Browse files Browse the repository at this point in the history
S3 radar server
  • Loading branch information
dopplershift authored Oct 2, 2024
2 parents 58a0229 + 27ac865 commit 1662945
Show file tree
Hide file tree
Showing 6 changed files with 287 additions and 146 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,15 @@ public static java.util.Collection<Object[]> getTestParameters() {
// {"/radar/radarCollections.xml"},
{"/radarServer/nexrad/level2/IDD/dataset.xml"}, {"/radarServer/nexrad/level2/IDD/stations.xml"},
{"/radarServer/nexrad/level2/IDD?stn=KDGX&time_start=2014-06-05T12:47:17&time_end=2014-06-05T16:07:17"},
{"/radarServer/nexrad/level3/IDD/stations.xml"}, {"/radarServer/terminal/level3/IDD/stations.xml"},});
{"/radarServer/nexrad/level3/IDD/stations.xml"}, {"/radarServer/terminal/level3/IDD/stations.xml"},


// s3 tests
{"/radarServer/s3/nexrad/level2/IDD/dataset.xml"}, {"/radarServer/s3/nexrad/level2/IDD/stations.xml"},
{"/radarServer/s3/nexrad/level2/IDD?stn=KDGX&time_start=2014-06-05T12:47:17&time_end=2014-06-05T16:07:17"},
{"/radarServer/s3/nexrad/level3/IDD/stations.xml"},

});
}

private static final String expectedContentType = "application/xml";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,88 +10,103 @@
import org.jdom2.xpath.XPathFactory;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import thredds.test.util.TestOnLocalServer;
import thredds.util.xml.XmlUtil;
import ucar.unidata.util.test.category.NeedsCdmUnitTest;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.List;

import static com.google.common.truth.Truth.assertThat;

@Category(NeedsCdmUnitTest.class)
@RunWith(Parameterized.class)
public class TestRadarServerQuery {
private static final Namespace NS =
Namespace.getNamespace("ns", "http://www.unidata.ucar.edu/namespaces/thredds/InvCatalog/v1.0");
private static final String L2_URL = "/radarServer/nexrad/level2/IDD";
private static final String L3_URL = "/radarServer/nexrad/level3/IDD";

private final String l2Url;
private final String l3Url;

@Parameterized.Parameters(name = "{0}")
public static List<String> getTestParameters() {
return Arrays.asList("", "s3/");
}

public TestRadarServerQuery(String datasetPathPrefix) {
l2Url = "/radarServer/" + datasetPathPrefix + "nexrad/level2/IDD";
l3Url = "/radarServer/" + datasetPathPrefix + "nexrad/level3/IDD";
}

@Test
public void shouldReturnAllDatasetsForStation() throws IOException, JDOMException {
String endpoint = L2_URL + "?stn=KDGX&temporal=all";
String endpoint = l2Url + "?stn=KDGX&temporal=all";
verifyNumberOfDatasets(endpoint, 3);
}

@Test
public void shouldReturnZeroDatasetsForNonOverlappingTimeRange() throws IOException, JDOMException {
String endpoint = L2_URL + "?stn=KDGX&time_start=2000-01-01T12:00:00&time_end=2001-01-01T12:00:00";
String endpoint = l2Url + "?stn=KDGX&time_start=2000-01-01T12:00:00&time_end=2001-01-01T12:00:00";
verifyNumberOfDatasets(endpoint, 0);
}

@Test
public void shouldReturnOneDatasetForOverlappingTimeRange() throws IOException, JDOMException {
String endpoint = L2_URL + "?stn=KDGX&time_start=2014-06-02T23:52:00&time_end=2014-06-02T23:53:00";
String endpoint = l2Url + "?stn=KDGX&time_start=2014-06-02T23:52:00&time_end=2014-06-02T23:53:00";
verifyNumberOfDatasets(endpoint, 1);
}

@Test
public void shouldReturnOneDatasetForOverlappingTimeDuration() throws IOException, JDOMException {
String endpoint = L2_URL + "?stn=KDGX&time_start=2014-06-02T23:52:00&time_duration=PT1M";
String endpoint = l2Url + "?stn=KDGX&time_start=2014-06-02T23:52:00&time_duration=PT1M";
verifyNumberOfDatasets(endpoint, 1);
}

@Test
public void shouldReturnOneDatasetForTime() throws IOException, JDOMException {
String endpoint = L2_URL + "?stn=KDGX&time=2014-06-02T23:52:00";
String endpoint = l2Url + "?stn=KDGX&time=2014-06-02T23:52:00";
verifyNumberOfDatasets(endpoint, 1);
}

@Test
public void shouldReturnZeroDatasetsForNonExistentStation() throws IOException, JDOMException {
String endpoint = L2_URL + "?stn=ABCD&temporal=all";
String endpoint = l2Url + "?stn=ABCD&temporal=all";
verifyNumberOfDatasets(endpoint, 0);
}

@Test
public void shouldReturnErrorForNonOverlappingBox() throws IOException, JDOMException {
String endpoint = L2_URL + "?north=10&south=0&west=-100&east=-80&temporal=all";
String endpoint = l2Url + "?north=10&south=0&west=-100&east=-80&temporal=all";
byte[] result = TestOnLocalServer.getContent(TestOnLocalServer.withHttpPath(endpoint), HttpServletResponse.SC_OK,
"text/plain;charset=iso-8859-1");
assertThat(new String(result, StandardCharsets.UTF_8)).isEqualTo("No stations found for specified coordinates.");
}

@Test
public void shouldReturnAllDatasetsForOverlappingBox() throws IOException, JDOMException {
String endpoint = L2_URL + "?north=50&south=30&west=-100&east=-80&temporal=all";
String endpoint = l2Url + "?north=50&south=30&west=-100&east=-80&temporal=all";
verifyNumberOfDatasets(endpoint, 3);
}

@Test
public void shouldReturnAllDatasetsForLonLat() throws IOException, JDOMException {
String endpoint = L2_URL + "?latitude=30&longitude=-90&temporal=all";
String endpoint = l2Url + "?latitude=30&longitude=-90&temporal=all";
verifyNumberOfDatasets(endpoint, 3);
}

@Test
public void shouldReturnAllLevel3Datasets() throws IOException, JDOMException {
String endpoint = L3_URL + "?temporal=all&var=N0R&stn=UDX";
String endpoint = l3Url + "?temporal=all&var=N0R&stn=UDX";
verifyNumberOfDatasets(endpoint, 329);
}

@Test
public void shouldReturnErrorWithoutVar() throws IOException, JDOMException {
String endpoint = L3_URL + "?temporal=all&stn=UDX";
String endpoint = l3Url + "?temporal=all&stn=UDX";
byte[] result = TestOnLocalServer.getContent(TestOnLocalServer.withHttpPath(endpoint), HttpServletResponse.SC_OK,
"text/plain;charset=iso-8859-1");
assertThat(new String(result, StandardCharsets.UTF_8)).isEqualTo("One or more variables required.");
Expand Down
Loading

0 comments on commit 1662945

Please sign in to comment.