Skip to content

Commit 33ff895

Browse files
committed
try to avoid cache implementation specifics in tests
1 parent 2ca3b5f commit 33ff895

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

opengrok-indexer/src/test/java/org/opengrok/indexer/index/IndexDatabaseTest.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -210,21 +210,27 @@ void testGetDefinitions() throws Exception {
210210
*/
211211
private void checkDataExistence(String fileName, boolean shouldExist) {
212212
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
213+
HistoryGuru historyGuru = HistoryGuru.getInstance();
213214

214215
for (String dirName : new String[] {"historycache", "annotationcache", IndexDatabase.XREF_DIR}) {
215216
File dataDir = new File(env.getDataRootFile(), dirName);
217+
File file = new File(env.getServerName(), fileName);
216218
String cacheFile;
217219
if (dirName.equals("annotationcache")) {
218-
cacheFile = fileName;
220+
if (shouldExist) {
221+
assertTrue(historyGuru.hasAnnotationCacheForFile(file));
222+
} else {
223+
assertFalse(historyGuru.hasAnnotationCacheForFile(file));
224+
}
219225
} else {
220226
cacheFile = TandemPath.join(fileName, ".gz");
221-
}
222-
File dataFile = new File(dataDir, cacheFile);
227+
File dataFile = new File(dataDir, cacheFile);
223228

224-
if (shouldExist) {
225-
assertTrue(dataFile.exists(), "file " + fileName + " not found in " + dirName);
226-
} else {
227-
assertFalse(dataFile.exists(), "file " + fileName + " found in " + dirName);
229+
if (shouldExist) {
230+
assertTrue(dataFile.exists(), "file " + fileName + " not found in " + dirName);
231+
} else {
232+
assertFalse(dataFile.exists(), "file " + fileName + " found in " + dirName);
233+
}
228234
}
229235
}
230236
}

0 commit comments

Comments
 (0)