Skip to content

Commit ae8987c

Browse files
Vladimir Kotalahornace
authored andcommitted
fix style
1 parent c11b56f commit ae8987c

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

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

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,12 @@ private static class RemoveIndexChangeListener implements IndexChangedListener {
268268
final Queue<String> filesToAdd = new ConcurrentLinkedQueue<>();
269269
final Queue<String> removedFiles = new ConcurrentLinkedQueue<>();
270270

271+
private final String path;
272+
273+
RemoveIndexChangeListener(String path) {
274+
this.path = path;
275+
}
276+
271277
@Override
272278
public void fileAdd(String path, String analyzer) {
273279
filesToAdd.add(path);
@@ -290,11 +296,12 @@ public void fileRemoved(String path) {
290296
// The test for the file existence needs to be performed here
291297
// since the call to {@code removeFile()} will be eventually
292298
// followed by {@code addFile()} that will create the file again.
293-
if (path.equals("/mercurial/bar.txt")) {
299+
if (path.equals(this.path)) {
294300
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
295301
File f = new File(env.getDataRootPath(),
296302
TandemPath.join("historycache" + path, ".gz"));
297-
Assert.assertTrue("history cache file should be preserved", f.exists());
303+
Assert.assertTrue(String.format("history cache file %s should be preserved", f),
304+
f.exists());
298305
}
299306
removedFiles.add(path);
300307
}
@@ -326,22 +333,20 @@ public void testRemoveFileOnFileChange() throws Exception {
326333
Project project = new Project("mercurial", "/mercurial");
327334
IndexDatabase idb = new IndexDatabase(project);
328335
assertNotNull(idb);
329-
RemoveIndexChangeListener listener = new RemoveIndexChangeListener();
336+
RemoveIndexChangeListener listener = new RemoveIndexChangeListener("/mercurial/bar.txt");
330337
idb.addIndexChangedListener(listener);
331338
idb.update();
332339
Assert.assertEquals(5, listener.filesToAdd.size());
333340
listener.reset();
334341

335342
// Change a file so that it gets picked up by the indexer.
336-
Thread.sleep(1100);
343+
// Thread.sleep(1100);
337344
File bar = new File(testrepo.getSourceRoot() + File.separator + "mercurial",
338345
"bar.txt");
339346
Assert.assertTrue(bar.exists());
340-
FileWriter fw = new FileWriter(bar, true);
341-
BufferedWriter bw = new BufferedWriter(fw);
342-
bw.write("foo\n");
343-
bw.close();
344-
fw.close();
347+
try (BufferedWriter bw = new BufferedWriter(new FileWriter(bar, true))) {
348+
bw.write("foo\n");
349+
}
345350

346351
// reindex
347352
idb.update();

0 commit comments

Comments
 (0)