Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test cleanup #489

Merged
merged 4 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions tds-test-utils/src/main/java/thredds/test/util/TdsTestDir.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,11 @@ public abstract class TdsUnitTestCommon {
static final Set<NetcdfDataset.Enhance> ENHANCEMENT = EnumSet.of(NetcdfDataset.Enhance.CoordSystems);

protected static String threddsroot = null;
protected static String threddsServer = null;

static {
// Compute the root path
threddsroot = locateThreddsRoot();
assert threddsroot != null : "Cannot locate /thredds parent dir";
threddsServer = TdsTestDir.remoteTestServer;
if (DEBUG)
System.err.println("TdsUnitTestCommon: threddsServer=" + threddsServer);
}

//////////////////////////////////////////////////
Expand Down
6 changes: 3 additions & 3 deletions tds/src/integrationTests/java/opendap/test/TestGrid1.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import thredds.test.util.TdsUnitTestCommon;
import thredds.test.util.TestOnLocalServer;
import ucar.nc2.NetcdfFiles;
import ucar.nc2.dataset.NetcdfDataset;
import ucar.nc2.dataset.NetcdfDatasets;
import ucar.unidata.util.test.TestDir;

import java.lang.invoke.MethodHandles;

Expand All @@ -36,7 +36,7 @@

public class TestGrid1 extends TdsUnitTestCommon {
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
static final protected String URLPATH = "/thredds/dodsC/scanLocal/testgrid1.nc";
static final protected String URLPATH = "dodsC/scanLocal/testgrid1.nc";

public TestGrid1() {
setTitle("Simple DAP Grid");
Expand All @@ -46,7 +46,7 @@ public TestGrid1() {
@Test
public void testGrid1() throws Exception {
System.out.println("TestGrid1:");
String url = "dods://" + TestDir.remoteTestServer + URLPATH;
String url = "dods://" + TestOnLocalServer.server + URLPATH;
boolean pass = true;
NetcdfDataset ncfile = null;

Expand Down
5 changes: 2 additions & 3 deletions tds/src/integrationTests/java/opendap/test/TestGrid2.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import ucar.nc2.dataset.NetcdfDataset;
import ucar.nc2.dataset.NetcdfDatasets;
import ucar.nc2.write.Ncdump;
import ucar.unidata.util.test.TestDir;

import java.io.IOException;
import java.io.StringWriter;
Expand All @@ -38,7 +37,7 @@
public class TestGrid2 extends TdsUnitTestCommon {
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());

static final protected String URLPATH = "/thredds/dodsC/scanLocal/testgrid2.nc";
static final protected String URLPATH = "dodsC/scanLocal/testgrid2.nc";

public TestGrid2() {
setTitle("DAP Grid with repeated dimension");
Expand All @@ -48,7 +47,7 @@ public TestGrid2() {
@Test
public void testGrid2() throws Exception {
System.out.println("TestGrid2:");
String url = "dods://" + TestDir.remoteTestServer + URLPATH;
String url = "dods://" + TestOnLocalServer.server + URLPATH;
boolean pass = true;
try (NetcdfDataset ncfile = NetcdfDatasets.openDataset(url)) {
System.out.println("url: " + url);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@
import ucar.nc2.NetcdfFile;
import ucar.nc2.Variable;
import ucar.nc2.dataset.NetcdfDatasets;
import ucar.unidata.util.test.TestDir;

public class TestNcmlWithOpendap {
private static final double[] expectedValues = new double[] {Double.NaN, 1, 2, 3};

@Test
public void shouldUseNcmlToModifyDatasetScanValues() throws IOException {
final String path = "/thredds/dodsC/EnhancedDatasetScan/testgrid1.nc";
final String url = "dods://" + TestDir.remoteTestServer + path;
final String path = "dodsC/EnhancedDatasetScan/testgrid1.nc";
final String url = "dods://" + TestOnLocalServer.server + path;
try (NetcdfFile ncFile = NetcdfDatasets.openDataset(url)) {
final Variable var = ncFile.findVariable("enhancedVar");
assertThat((Object) var).isNotNull();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.junit.runners.Parameterized;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import thredds.test.util.TdsTestDir;
import thredds.test.util.TestOnLocalServer;
import ucar.nc2.Attribute;
import ucar.nc2.NetcdfFile;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import thredds.client.catalog.Dataset;
import thredds.client.catalog.ServiceType;
import thredds.client.catalog.tools.DataFactory;
import thredds.test.util.TestOnLocalServer;
import ucar.ma2.Array;
import ucar.ma2.Index;
import ucar.nc2.Attribute;
Expand All @@ -20,7 +21,6 @@
import ucar.nc2.dataset.NetcdfDataset;
import ucar.nc2.dataset.NetcdfDatasets;
import ucar.unidata.util.test.Assert2;
import ucar.unidata.util.test.TestDir;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.util.Formatter;
Expand All @@ -29,7 +29,7 @@
public class TestHTTP {
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());

String url = "http://" + TestDir.remoteTestServer + "/thredds/fileServer/scanLocal/mydata1.nc";
String url = "http://" + TestOnLocalServer.server + "fileServer/scanLocal/mydata1.nc";

@Test
public void testOpenNetcdfFile() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.junit.runners.Parameterized;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import thredds.test.util.TdsTestDir;
import thredds.test.util.TestOnLocalServer;
import thredds.util.ContentType;
import ucar.httpservices.HTTPFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.junit.rules.TemporaryFolder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import thredds.test.util.TdsTestDir;
import thredds.test.util.TestOnLocalServer;
import thredds.util.ContentType;
import ucar.nc2.Attribute;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.junit.rules.TemporaryFolder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import thredds.test.util.TdsTestDir;
import thredds.test.util.TestOnLocalServer;
import thredds.util.ContentType;
import ucar.nc2.NetcdfFile;
Expand Down
19 changes: 9 additions & 10 deletions tds/src/integrationTests/java/ucar/nc2/dt/fmrc/TestUgridFmrc.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import thredds.test.util.TdsTestDir;
import thredds.test.util.TestOnLocalServer;
import ucar.ma2.Array;
import ucar.ma2.DataType;
import ucar.ma2.InvalidRangeException;
Expand Down Expand Up @@ -49,8 +49,8 @@ public static void openIndividualFiles() {
@Test
@Category(NeedsCdmUnitTest.class)
public void test2DFmrc() throws IOException, InvalidRangeException {
final String urlPath2d = "/thredds/cdmremote/testUsfWsfUgridFmrc/USF_WSF_nc_fmrc.ncd";
final String tdsLocation = "cdmremote:http://" + TdsTestDir.remoteTestServer + urlPath2d;
final String urlPath2d = "cdmremote/testUsfWsfUgridFmrc/USF_WSF_nc_fmrc.ncd";
final String tdsLocation = "cdmremote:http://" + TestOnLocalServer.server + urlPath2d;
String testVariableName = "salinity";
String singleRuntimeSection = ":,2,10:10000:100";
try (NetcdfFile fmrc2d = NetcdfDatasets.openFile(tdsLocation, null)) {
Expand Down Expand Up @@ -80,8 +80,8 @@ public void test2DFmrc() throws IOException, InvalidRangeException {
@Category(NeedsCdmUnitTest.class)
public void testCFOFmrc() throws IOException, InvalidRangeException {
// 8 hour offset into a collection of runs that output hourly
final String urlPathCfo = "/thredds/cdmremote/testUsfWsfUgridFmrc/offset/USF_WSF_nc_Offset_8.0hr";
final String tdsLocation = "cdmremote:http://" + TdsTestDir.remoteTestServer + urlPathCfo;
final String urlPathCfo = "cdmremote/testUsfWsfUgridFmrc/offset/USF_WSF_nc_Offset_8.0hr";
final String tdsLocation = "cdmremote:http://" + TestOnLocalServer.server + urlPathCfo;
String testVariableName = "salinity";
String singleSpatialSection = "2,10:10000:100";
// index 8 => forecast hour 8 since index 0 is forecast hour 0
Expand Down Expand Up @@ -113,9 +113,8 @@ public void testCFOFmrc() throws IOException, InvalidRangeException {
@Category(NeedsCdmUnitTest.class)
public void testCFTFmrc() throws IOException, InvalidRangeException {
// 8 hour offset into a collection of runs that output hourly
final String urlPathCft =
"/thredds/cdmremote/testUsfWsfUgridFmrc/forecast/USF_WSF_nc_ConstantForecast_2019-01-28T03:00:00Z";
final String tdsLocation = "cdmremote:http://" + TdsTestDir.remoteTestServer + urlPathCft;
final String urlPathCft = "cdmremote/testUsfWsfUgridFmrc/forecast/USF_WSF_nc_ConstantForecast_2019-01-28T03:00:00Z";
final String tdsLocation = "cdmremote:http://" + TestOnLocalServer.server + urlPathCft;
String testVariableName = "salinity";
String singleSpatialSection = "2,10:10000:100";
// Forecast time 2019-01-28T03:00:00Z should be the 4th time index into the second granule of the collection
Expand All @@ -141,8 +140,8 @@ public void testCFTFmrc() throws IOException, InvalidRangeException {
@Category(NeedsCdmUnitTest.class)
public void testFMRFmrc() throws IOException, InvalidRangeException {
// the 2019-01-28T00:00:00Z Forecast Model Run should be the same as the second granule that makes up collection.
final String urlPathCft = "/thredds/cdmremote/testUsfWsfUgridFmrc/runs/USF_WSF_nc_RUN_2019-01-28T00:00:00Z";
final String tdsLocation = "cdmremote:http://" + TdsTestDir.remoteTestServer + urlPathCft;
final String urlPathCft = "cdmremote/testUsfWsfUgridFmrc/runs/USF_WSF_nc_RUN_2019-01-28T00:00:00Z";
final String tdsLocation = "cdmremote:http://" + TestOnLocalServer.server + urlPathCft;
String testVariableName = "salinity";
String testSection = ":,2,10:10000:100";
try (NetcdfFile fmrcCfo = NetcdfDatasets.openFile(tdsLocation, null)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import thredds.test.util.TdsUnitTestCommon;
import thredds.test.util.TestOnLocalServer;
import ucar.httpservices.*;
import ucar.unidata.util.test.TestDir;

import java.io.*;
import java.lang.invoke.MethodHandles;
Expand Down Expand Up @@ -58,7 +58,7 @@ public class TestFormBuilder extends TdsUnitTestCommon {

// This needs to be a real site in order to get
// the request info
static final String NULLURL = "http://" + TestDir.remoteTestServer;
static final String NULLURL = "http://" + TestOnLocalServer.server;

//////////////////////////////////////////////////
// Static Fields
Expand Down
12 changes: 6 additions & 6 deletions tds/src/integrationTests/java/ucar/nc2/util/net/TestMisc.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import thredds.test.util.TdsUnitTestCommon;
import thredds.test.util.TestOnLocalServer;
import ucar.httpservices.HTTPException;
import ucar.httpservices.HTTPFactory;
import ucar.httpservices.HTTPMethod;
import ucar.httpservices.HTTPSession;
import ucar.nc2.dataset.DatasetUrl;
import ucar.nc2.util.EscapeStrings;
import ucar.unidata.util.test.TestDir;

import java.lang.invoke.MethodHandles;
import java.util.List;
Expand Down Expand Up @@ -47,7 +47,7 @@ public TestMisc() {
setTitle("HTTP Session tests");
}

static protected final String server = "http://" + TestDir.remoteTestServer;
static protected final String server = "http://" + TestOnLocalServer.server;

static final String[] esinputs = {server + "/dts/test.01", server + "///xx/", server + "/<>^/`/",};
static final String[] esoutputs = {server + "/dts/test.01", server + "///xx/", server + "/%3c%3e%5e/%60/",};
Expand All @@ -72,7 +72,7 @@ public void testEscapeStrings() throws Exception {
public void testUTF8Stream() throws Exception {
pass = true;

String catalogName = "http://" + TestDir.remoteTestServer + "/thredds/catalog.xml";
String catalogName = "http://" + TestOnLocalServer.server + "catalog.xml";

try (HTTPMethod m = HTTPFactory.Get(catalogName)) {
int statusCode = m.execute();
Expand Down Expand Up @@ -109,7 +109,7 @@ public void testGetProtocols() {
String tag = "TestMisc.testGetProtocols";
Assert.assertTrue(tag, protocheck("http://server/thredds/dodsC/", "http:"));
Assert.assertTrue(tag,
protocheck("dods://" + TestDir.remoteTestServer + "/thredds/dodsC/grib/NCEP/NAM/CONUS_12km/best", "dods:"));
protocheck("dods://" + TestOnLocalServer.server + "dodsC/grib/NCEP/NAM/CONUS_12km/best", "dods:"));
Assert.assertTrue(tag, protocheck("dap4://ucar.edu:8080/x/y/z", "dap4:"));
Assert.assertTrue(tag, protocheck("dap4:https://ucar.edu:8080/x/y/z", "dap4:https:"));
Assert.assertTrue(tag, protocheck("file:///x/y/z", "file:"));
Expand All @@ -128,7 +128,7 @@ public void testGetProtocols() {

@Test
public void testByteRange() {
String file = "http://" + TestDir.remoteTestServer + "/thredds/fileServer/scanLocal/testData.nc";
String file = "http://" + TestOnLocalServer.server + "fileServer/scanLocal/testData.nc";
try {
try (HTTPMethod m = HTTPFactory.Get(file)) {
m.setRange(0, 9);
Expand All @@ -147,7 +147,7 @@ public void testByteRange() {
* This test uses a single HTTPSession.
*/

static String CLOSEFILE = "http://" + TestDir.remoteTestServer + "/thredds/fileServer/scanLocal/testData.nc";
static String CLOSEFILE = "http://" + TestOnLocalServer.server + "fileServer/scanLocal/testData.nc";
// "http://rdavm.ucar.edu:8443/thredds/admin/collection/trigger?trigger=never&collection=ds083.2_Grib1";

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import thredds.test.util.TdsUnitTestCommon;
import thredds.test.util.TestOnLocalServer;
import ucar.httpservices.HTTPFactory;
import ucar.httpservices.HTTPMethod;
import ucar.httpservices.HTTPSession;
import ucar.unidata.util.test.TestDir;
import ucar.unidata.util.test.category.NotPullRequest;

import java.io.IOException;
Expand Down Expand Up @@ -148,7 +148,7 @@ public TestTomcatAuth() {
setTitle("Authorization tests");
// HTTPSession.debugHeaders(true);
HTTPSession.TESTING = true;
this.server = TestDir.remoteTestServer;
this.server = TestOnLocalServer.server;
defineTestCases();
}

Expand Down Expand Up @@ -214,8 +214,8 @@ public String inline() throws Exception {
protected List<AuthDataBasic> basictests = new ArrayList<>();

protected void defineTestCases() {
basictests.add(new AuthDataBasic("http://" + this.server + "/thredds/dodsC/containerauth/testData2.nc.dds", "tds",
"secret666"));
basictests
.add(new AuthDataBasic("http://" + this.server + "dodsC/containerauth/testData2.nc.dds", "tds", "secret666"));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;
import thredds.test.util.TdsTestDir;
import thredds.mock.params.GridPathParams;
import thredds.mock.web.MockTdsContextLoader;
import ucar.nc2.NetcdfFile;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;
import thredds.test.util.TdsTestDir;
import thredds.junit4.SpringJUnit4ParameterizedClassRunner;
import thredds.mock.web.MockTdsContextLoader;
import ucar.nc2.NetcdfFile;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;
import thredds.test.util.TdsTestDir;
import thredds.junit4.SpringJUnit4ParameterizedClassRunner;
import thredds.junit4.SpringJUnit4ParameterizedClassRunner.Parameters;
import thredds.mock.params.GridDataParameters;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;
import thredds.test.util.TdsTestDir;
import thredds.junit4.SpringJUnit4ParameterizedClassRunner;
import thredds.junit4.SpringJUnit4ParameterizedClassRunner.Parameters;
import thredds.mock.params.GridPathParams;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;
import thredds.test.util.TdsTestDir;
import thredds.junit4.SpringJUnit4ParameterizedClassRunner;
import thredds.junit4.SpringJUnit4ParameterizedClassRunner.Parameters;
import thredds.mock.params.GridDataParameters;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;
import thredds.test.util.TdsTestDir;
import thredds.junit4.SpringJUnit4ParameterizedClassRunner.Parameters;
import thredds.mock.params.GridDataParameters;
import thredds.mock.params.GridPathParams;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import thredds.test.util.TdsTestDir;
import thredds.test.util.TdsUnitTestCommon;
import ucar.nc2.NetcdfFile;
import ucar.nc2.dataset.NetcdfDataset;
Expand Down
Loading