From dc7a984463a07a39fbe08036ab265282fd472671 Mon Sep 17 00:00:00 2001 From: Tara Drwenski Date: Thu, 21 Dec 2023 11:33:04 -0700 Subject: [PATCH] Add tests for opening a ncml dataset on S3 --- .../java/thredds/tds/TestS3Ncml.java | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 tds/src/integrationTests/java/thredds/tds/TestS3Ncml.java diff --git a/tds/src/integrationTests/java/thredds/tds/TestS3Ncml.java b/tds/src/integrationTests/java/thredds/tds/TestS3Ncml.java new file mode 100644 index 0000000000..85855ed1a4 --- /dev/null +++ b/tds/src/integrationTests/java/thredds/tds/TestS3Ncml.java @@ -0,0 +1,53 @@ +package thredds.tds; + +import static com.google.common.truth.Truth.assertThat; + +import java.nio.charset.StandardCharsets; +import javax.servlet.http.HttpServletResponse; +import org.junit.Test; +import thredds.test.util.TestOnLocalServer; + +public class TestS3Ncml { + final private static String S3_NCML_PATH = "dodsC/s3-dataset-scan/ncml/"; + + @Test + public void shouldOpenNcmlOnS3() { + final String endpoint = TestOnLocalServer.withHttpPath(S3_NCML_PATH + "testStandalone.ncml.ascii?time"); + final byte[] content = TestOnLocalServer.getContent(endpoint, HttpServletResponse.SC_OK); + final String stringContent = new String(content, StandardCharsets.UTF_8); + + assertThat(stringContent).contains("time[2]"); + assertThat(stringContent).contains("6, 18"); + } + + @Test + public void shouldOpenNcmlWithOtherExtensionOnS3() { + final String endpoint = TestOnLocalServer.withHttpPath(S3_NCML_PATH + "testStandaloneNcml.otherExt.ascii?time"); + final byte[] content = TestOnLocalServer.getContent(endpoint, HttpServletResponse.SC_OK); + final String stringContent = new String(content, StandardCharsets.UTF_8); + + assertThat(stringContent).contains("time[2]"); + assertThat(stringContent).contains("6, 18"); + } + + @Test + public void shouldOpenAggregationWithRelativePathsOnS3() { + final String endpoint = TestOnLocalServer.withHttpPath(S3_NCML_PATH + "nc/namExtract/test_agg.ncml.ascii?time"); + final byte[] content = TestOnLocalServer.getContent(endpoint, HttpServletResponse.SC_OK); + final String stringContent = new String(content, StandardCharsets.UTF_8); + + assertThat(stringContent).contains("time[8]"); + assertThat(stringContent).contains("3.0, 6.0, 9.0, 12.0, 15.0, 18.0, 21.0, 24.0"); + } + + @Test + public void shouldOpenAggregationWithAbsolutePathsOnS3() { + final String endpoint = + TestOnLocalServer.withHttpPath(S3_NCML_PATH + "nc/namExtract/test_agg_absolute_paths.ncml.ascii?time"); + final byte[] content = TestOnLocalServer.getContent(endpoint, HttpServletResponse.SC_OK); + final String stringContent = new String(content, StandardCharsets.UTF_8); + + assertThat(stringContent).contains("time[8]"); + assertThat(stringContent).contains("3.0, 6.0, 9.0, 12.0, 15.0, 18.0, 21.0, 24.0"); + } +}