@@ -87,19 +87,23 @@ public void terminateExecutorService() {
87
87
public void testStart_DoNotDetectCrashWhenNoInputPipeProvided () throws Exception {
88
88
when (processPipes .getProcessInStream ()).thenReturn (Optional .empty ());
89
89
try (AbstractNativeProcess process = new TestNativeProcess ()) {
90
- process .start (executorService );
91
- } finally {
92
- mockNativeProcessLoggingStreamEnds .countDown ();
93
- // Not detecting a crash is confirmed in terminateExecutorService()
90
+ try {
91
+ process .start (executorService );
92
+ } finally {
93
+ mockNativeProcessLoggingStreamEnds .countDown ();
94
+ // Not detecting a crash is confirmed in terminateExecutorService()
95
+ }
94
96
}
95
97
}
96
98
97
99
public void testStart_DoNotDetectCrashWhenProcessIsBeingClosed () throws Exception {
98
100
try (AbstractNativeProcess process = new TestNativeProcess ()) {
99
- process .start (executorService );
100
- } finally {
101
- mockNativeProcessLoggingStreamEnds .countDown ();
102
- // Not detecting a crash is confirmed in terminateExecutorService()
101
+ try {
102
+ process .start (executorService );
103
+ } finally {
104
+ mockNativeProcessLoggingStreamEnds .countDown ();
105
+ // Not detecting a crash is confirmed in terminateExecutorService()
106
+ }
103
107
}
104
108
}
105
109
@@ -142,65 +146,74 @@ public void testCrashReporting() throws Exception {
142
146
143
147
public void testWriteRecord () throws Exception {
144
148
try (AbstractNativeProcess process = new TestNativeProcess ()) {
145
- process . start ( executorService );
146
- process . writeRecord ( new String [] { "a" , "b" , "c" } );
147
- process .flushStream ( );
148
-
149
- verify (inputStream ).write (any (), anyInt (), anyInt ());
150
-
151
- } finally {
152
- mockNativeProcessLoggingStreamEnds . countDown ();
149
+ try {
150
+ process . start ( executorService );
151
+ process .writeRecord ( new String []{ "a" , "b" , "c" } );
152
+ process . flushStream ();
153
+ verify (inputStream ).write (any (), anyInt (), anyInt ());
154
+ } finally {
155
+ mockNativeProcessLoggingStreamEnds . countDown ();
156
+ }
153
157
}
154
158
}
155
159
156
160
public void testWriteRecord_FailWhenNoInputPipeProvided () throws Exception {
157
161
when (processPipes .getProcessInStream ()).thenReturn (Optional .empty ());
158
162
try (AbstractNativeProcess process = new TestNativeProcess ()) {
159
- process .start (executorService );
160
- expectThrows (NullPointerException .class , () -> process .writeRecord (new String [] {"a" , "b" , "c" }));
161
- } finally {
162
- mockNativeProcessLoggingStreamEnds .countDown ();
163
+ try {
164
+ process .start (executorService );
165
+ expectThrows (NullPointerException .class , () -> process .writeRecord (new String []{"a" , "b" , "c" }));
166
+ } finally {
167
+ mockNativeProcessLoggingStreamEnds .countDown ();
168
+ }
163
169
}
164
170
}
165
171
166
172
public void testFlush () throws Exception {
167
173
try (AbstractNativeProcess process = new TestNativeProcess ()) {
168
- process .start (executorService );
169
- process .flushStream ();
170
-
171
- verify (inputStream ).flush ();
172
- } finally {
173
- mockNativeProcessLoggingStreamEnds .countDown ();
174
+ try {
175
+ process .start (executorService );
176
+ process .flushStream ();
177
+ verify (inputStream ).flush ();
178
+ } finally {
179
+ mockNativeProcessLoggingStreamEnds .countDown ();
180
+ }
174
181
}
175
182
}
176
183
177
184
public void testFlush_FailWhenNoInputPipeProvided () throws Exception {
178
185
when (processPipes .getProcessInStream ()).thenReturn (Optional .empty ());
179
186
try (AbstractNativeProcess process = new TestNativeProcess ()) {
180
- process .start (executorService );
181
- expectThrows (NullPointerException .class , process ::flushStream );
182
- } finally {
183
- mockNativeProcessLoggingStreamEnds .countDown ();
187
+ try {
188
+ process .start (executorService );
189
+ expectThrows (NullPointerException .class , process ::flushStream );
190
+ } finally {
191
+ mockNativeProcessLoggingStreamEnds .countDown ();
192
+ }
184
193
}
185
194
}
186
195
187
196
public void testIsReady () throws Exception {
188
197
try (AbstractNativeProcess process = new TestNativeProcess ()) {
189
- process .start (executorService );
190
- assertThat (process .isReady (), is (false ));
191
- process .setReady ();
192
- assertThat (process .isReady (), is (true ));
193
- } finally {
194
- mockNativeProcessLoggingStreamEnds .countDown ();
198
+ try {
199
+ process .start (executorService );
200
+ assertThat (process .isReady (), is (false ));
201
+ process .setReady ();
202
+ assertThat (process .isReady (), is (true ));
203
+ } finally {
204
+ mockNativeProcessLoggingStreamEnds .countDown ();
205
+ }
195
206
}
196
207
}
197
208
198
209
public void testConsumeAndCloseOutputStream_GivenNoOutputStream () throws Exception {
199
210
when (processPipes .getProcessOutStream ()).thenReturn (Optional .empty ());
200
211
try (AbstractNativeProcess process = new TestNativeProcess ()) {
201
- process .consumeAndCloseOutputStream ();
202
- } finally {
203
- mockNativeProcessLoggingStreamEnds .countDown ();
212
+ try {
213
+ process .consumeAndCloseOutputStream ();
214
+ } finally {
215
+ mockNativeProcessLoggingStreamEnds .countDown ();
216
+ }
204
217
}
205
218
}
206
219
0 commit comments