Skip to content

Commit ed9447d

Browse files
committed
Add some comments and checks
1 parent bc54270 commit ed9447d

File tree

1 file changed

+29
-23
lines changed

1 file changed

+29
-23
lines changed

src/test/java/org/dstadler/commoncrawl/oldindex/ProcessImplTest.java

+29-23
Original file line numberDiff line numberDiff line change
@@ -15,46 +15,52 @@ public void testOffer() throws Exception {
1515
File file = File.createTempFile("ProcessImplTest", ".tmp");
1616
try {
1717
assertTrue(file.delete());
18-
18+
1919
try (BlockProcessor process = new ProcessImpl(file, false)) {
2020
byte[] block = FileUtils.readFileToByteArray(new File("src/test/data/block1.bin"));
21-
21+
2222
process.offer(block, 0);
23-
}
23+
} // this will flush the queue
2424

2525
// need to do this outside the block to let process.close() join the Thread
26-
assertTrue(file.exists());
27-
assertTrue(file.length() > 0);
28-
29-
final long length = file.length();
26+
assertTrue("Failed for " + file,
27+
file.exists());
28+
assertTrue("Failed for " + file,
29+
file.length() > 0);
30+
31+
final long length = file.length();
3032

3133
// with append=false
3234
try (BlockProcessor process = new ProcessImpl(file, false)) {
3335
byte[] block = FileUtils.readFileToByteArray(new File("src/test/data/block1.bin"));
34-
36+
3537
process.offer(block, 0);
36-
}
37-
38+
} // this will flush the queue
39+
3840
// need to do this outside the block to let process.close() join the Thread
39-
assertTrue(file.exists());
40-
assertTrue(file.length() > 0);
41-
42-
assertEquals("When re-creating the file the length should be the same as before",
43-
length, file.length());
41+
assertTrue("Failed for " + file,
42+
file.exists());
43+
assertTrue("Failed for " + file,
44+
file.length() > 0);
45+
46+
assertEquals("When re-creating the file the length should be the same as before",
47+
length, file.length());
4448

4549
// with append=false
4650
try (BlockProcessor process = new ProcessImpl(file, true)) {
4751
byte[] block = FileUtils.readFileToByteArray(new File("src/test/data/block1.bin"));
48-
52+
4953
process.offer(block, 0);
50-
}
51-
54+
} // this will flush the queue
55+
5256
// need to do this outside the block to let process.close() join the Thread
53-
assertTrue(file.exists());
54-
assertTrue(file.length() > 0);
55-
56-
assertEquals("When appending, the length should be double",
57-
length*2, file.length());
57+
assertTrue("Failed for " + file,
58+
file.exists());
59+
assertTrue("Failed for " + file,
60+
file.length() > 0);
61+
62+
assertEquals("When appending, the length should be double",
63+
length*2, file.length());
5864
} finally {
5965
assertTrue(file.delete());
6066
}

0 commit comments

Comments
 (0)