@Test public void testWrite() throws Exception { if ((format == SupportedFormat.NETCDF4) && !isClibraryPresent) { return; } File datasetFile = new File(getClass().getResource(datasetResource).toURI()); File expectedResultFile = new File(getClass().getResource(expectedResultResource).toURI()); String extension; switch (format) { case CSV_FILE: extension = "csv"; break; case XML_FILE: case WATERML2: extension = "xml"; break; case NETCDF3: extension = "nc"; break; case NETCDF4: extension = "nc4"; break; default: throw new AssertionError("Unknown format: " + format); } String basename = FilenameUtils.getBaseName(expectedResultResource); File actualResultFile = File.createTempFile(basename + "_", "." + extension); try { try (FeatureDatasetPoint fdPoint = openPointDataset(wantedType, datasetFile); OutputStream outFileStream = new BufferedOutputStream(new FileOutputStream(actualResultFile))) { DsgSubsetWriter subsetWriterFile = DsgSubsetWriterFactory.newInstance(fdPoint, subsetParams, ncssDiskCache, outFileStream, format); subsetWriterFile.write(); } if (format == SupportedFormat.NETCDF3 || format == SupportedFormat.NETCDF4) { Assert.assertTrue(compareNetCDF(expectedResultFile, actualResultFile)); } else { Assert.assertTrue(compareText(expectedResultFile, actualResultFile)); } if (!actualResultFile.delete()) { logger.warn("Failed to delete " + actualResultFile); } } catch (AssertionError e) { String message = String.format("Files differed:\n\texpected: %s\n\tactual: %s", expectedResultFile, actualResultFile); throw new AssertionError(message, e); } }
abstract public void write() throws Exception;
DsgSubsetWriter { abstract public void write() throws Exception; }
DsgSubsetWriter { abstract public void write() throws Exception; DsgSubsetWriter(FeatureDatasetPoint fdPoint, SubsetParams ncssParams); }
DsgSubsetWriter { abstract public void write() throws Exception; DsgSubsetWriter(FeatureDatasetPoint fdPoint, SubsetParams ncssParams); abstract HttpHeaders getHttpHeaders(String datasetPath, boolean isStream); abstract void write(); void respond(HttpServletResponse res, FeatureDataset ft, String requestPathInfo, SubsetParams queryParams,
      SupportedFormat format); static List<VariableSimpleIF> getWantedVariables(FeatureDatasetPoint fdPoint, SubsetParams ncssParams); static CalendarDateRange getWantedDateRange(SubsetParams ncssParams); }
DsgSubsetWriter { abstract public void write() throws Exception; DsgSubsetWriter(FeatureDatasetPoint fdPoint, SubsetParams ncssParams); abstract HttpHeaders getHttpHeaders(String datasetPath, boolean isStream); abstract void write(); void respond(HttpServletResponse res, FeatureDataset ft, String requestPathInfo, SubsetParams queryParams,
      SupportedFormat format); static List<VariableSimpleIF> getWantedVariables(FeatureDatasetPoint fdPoint, SubsetParams ncssParams); static CalendarDateRange getWantedDateRange(SubsetParams ncssParams);  }