Skip to content

Commit

Permalink
Improve before/after steps of test that checks cache
Browse files Browse the repository at this point in the history
  • Loading branch information
Tara Drwenski committed Apr 19, 2024
1 parent 4905e37 commit 0f1f8a9
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tds/src/test/java/thredds/server/wms/TestWmsCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ public void createTestFiles() throws IOException {
Files.copy(TEST_FILE, TEMP_FILE, StandardCopyOption.REPLACE_EXISTING);
}

@Before
public void clearNetcdfFileCache() {
final FileCacheIF cache = NetcdfDatasets.getNetcdfFileCache();
cache.clearCache(true);
assertNoneLockedInNetcdfFileCache();
}

@After
public void clearCache() {
ThreddsWmsServlet.resetCache();
Expand Down Expand Up @@ -174,7 +181,10 @@ public void shouldNotLockFileInCacheAfterExceptionIsThrown() throws ServletExcep
}

private void assertNoneLockedInNetcdfFileCache() {
assertNotLockedInNetcdfFileCache("");
final FileCacheIF cache = NetcdfDatasets.getNetcdfFileCache();
final List<String> entries = cache.showCache();
final boolean isLocked = entries.stream().anyMatch(e -> e.startsWith("true"));
assertWithMessage(cache.showCache().toString()).that(isLocked).isFalse();
}

private void assertNotLockedInNetcdfFileCache(String path) {
Expand Down

0 comments on commit 0f1f8a9

Please sign in to comment.