@@ -15,46 +15,52 @@ public void testOffer() throws Exception {
15
15
File file = File .createTempFile ("ProcessImplTest" , ".tmp" );
16
16
try {
17
17
assertTrue (file .delete ());
18
-
18
+
19
19
try (BlockProcessor process = new ProcessImpl (file , false )) {
20
20
byte [] block = FileUtils .readFileToByteArray (new File ("src/test/data/block1.bin" ));
21
-
21
+
22
22
process .offer (block , 0 );
23
- }
23
+ } // this will flush the queue
24
24
25
25
// 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 ();
30
32
31
33
// with append=false
32
34
try (BlockProcessor process = new ProcessImpl (file , false )) {
33
35
byte [] block = FileUtils .readFileToByteArray (new File ("src/test/data/block1.bin" ));
34
-
36
+
35
37
process .offer (block , 0 );
36
- }
37
-
38
+ } // this will flush the queue
39
+
38
40
// 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 ());
44
48
45
49
// with append=false
46
50
try (BlockProcessor process = new ProcessImpl (file , true )) {
47
51
byte [] block = FileUtils .readFileToByteArray (new File ("src/test/data/block1.bin" ));
48
-
52
+
49
53
process .offer (block , 0 );
50
- }
51
-
54
+ } // this will flush the queue
55
+
52
56
// 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 ());
58
64
} finally {
59
65
assertTrue (file .delete ());
60
66
}
0 commit comments