Skip to content

Commit

Permalink
Add extra asserts to test after step
Browse files Browse the repository at this point in the history
  • Loading branch information
tdrwenski committed Feb 27, 2024
1 parent 34d0d74 commit 8a08af7
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions tds/src/test/java/thredds/server/wms/TestWmsCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public void createTestFiles() throws IOException {
@After
public void clearCache() {
ThreddsWmsServlet.resetCache();
assertThat(ThreddsWmsServlet.getNumberOfEntries()).isEqualTo(0);
assertNoneLockedInNetcdfFileCache();
}

@Test
Expand Down Expand Up @@ -139,12 +141,7 @@ public void shouldNotLockAggregationInNetcdfFileCacheAfterCacheReset() throws IO
assertThat(ThreddsWmsServlet.containsCachedCatalogue(testPath)).isTrue();
ThreddsWmsServlet.resetCache();

// check aggregation is not locked in netcdf file cache
final FileCacheIF cache = NetcdfDatasets.getNetcdfFileCache();
final List<String> entries = cache.showCache();
assertThat(entries.size()).isGreaterThan(0);
final boolean isLocked = entries.stream().filter(e -> e.contains(testPath)).anyMatch(e -> e.startsWith("true"));
assertWithMessage(cache.showCache().toString()).that(isLocked).isFalse();
assertNotLockedInNetcdfFileCache(testPath);
}

@Test
Expand All @@ -154,11 +151,18 @@ public void shouldNotLockFileInCacheAfterExceptionIsThrown() throws ServletExcep
getCapabilities(testPath, HttpServletResponse.SC_BAD_REQUEST);
assertThat(ThreddsWmsServlet.containsCachedCatalogue(testPath)).isFalse();

// check file is not locked in netcdf file cache
assertNotLockedInNetcdfFileCache(filename);
}

private void assertNoneLockedInNetcdfFileCache() {
assertNotLockedInNetcdfFileCache("");
}

private void assertNotLockedInNetcdfFileCache(String path) {
final FileCacheIF cache = NetcdfDatasets.getNetcdfFileCache();
final List<String> entries = cache.showCache();
assertThat(entries.size()).isGreaterThan(0);
final boolean isLocked = entries.stream().filter(e -> e.contains(filename)).anyMatch(e -> e.startsWith("true"));
final boolean isLocked = entries.stream().filter(e -> e.contains(path)).anyMatch(e -> e.startsWith("true"));
assertWithMessage(cache.showCache().toString()).that(isLocked).isFalse();
}

Expand Down

0 comments on commit 8a08af7

Please sign in to comment.