13
13
import javax .management .MBeanServer ;
14
14
import javax .management .ObjectName ;
15
15
16
+ import java .io .File ;
16
17
import java .lang .management .ManagementFactory ;
17
18
import java .util .Arrays ;
18
19
import java .util .HashMap ;
@@ -401,12 +402,12 @@ public void testServiceCheckCounter() throws Exception {
401
402
402
403
// Let's check that the counter is null
403
404
assertEquals (0 , repo .getServiceCheckCount ("jmx" ));
404
-
405
+
405
406
// Let's put a service check in the pipeline (we cannot call doIteration()
406
- // here unfortunately because it would call reportStatus which will flush
407
- // the count to the jmx_status.yaml file and reset the counter.
407
+ // here unfortunately because it would call reportStatus which will flush
408
+ // the count to the jmx_status.yaml file and reset the counter.
408
409
repo .sendServiceCheck ("jmx" , Status .STATUS_OK , "This is a test" , "jmx_test_instance" , null );
409
-
410
+
410
411
// Let's check that the counter has been updated
411
412
assertEquals (1 , repo .getServiceCheckCount ("jmx" ));
412
413
@@ -430,6 +431,21 @@ public void testPrefixFormatter() throws Exception {
430
431
assertEquals (data [i ][1 ], Reporter .formatServiceCheckPrefix (data [i ][0 ]));
431
432
}
432
433
434
+ @ Test
435
+ public void testExitWatcher () throws Exception {
436
+ // Test the ExitWatcher logic
437
+
438
+ // Create a temp file
439
+ File temp = File .createTempFile ("exit-jmxfetch-file-name" , ".tmp" );
440
+ temp .deleteOnExit ();
441
+
442
+ ExitWatcher exitWatcher = new ExitWatcher (temp .getAbsolutePath ());
443
+ assertTrue (exitWatcher .shouldExit ());
444
+
445
+ temp .delete ();
446
+ assertFalse (exitWatcher .shouldExit ());
447
+ }
448
+
433
449
@ Test
434
450
public void testApp () throws Exception {
435
451
// We expose a few metrics through JMX
0 commit comments