// Only one class miss gathered with two occurrences
// Only one class miss gathered
assertEquals(1,eventsGathered.size());
// 2 log entries
assertEquals("Two missing class should be printed out in the log",2,logging.getRecords().stream().filter(r->r.getMessage().contains(NON_EXISTING_CLASS)||
// The stack trace of these CNFE are different but we only look at class names when printing on logs, so
// just one log entry
assertEquals("Single missing class should be printed out in the log",1,logging.getRecords().stream().filter(r->r.getMessage().contains(NON_EXISTING_CLASS)).count());
}
/**
...
...
@@ -120,7 +132,7 @@ public class MissingClassTelemetryFasterTest {
for(inti=0;i<2;i++){
try{
//Exceptions thrown at the same line, with the same stack trace become occurrences of just one event
cl.loadClass("sun.java.MyNonExistentJavaClass");
cl.loadClass(NON_EXISTING_CLASS);
}catch(ClassNotFoundExceptionignored){
}
}
...
...
@@ -132,6 +144,9 @@ public class MissingClassTelemetryFasterTest {
// Only one class miss gathered with two occurrences
// The class name and also the stack trace of these CNFEs are the same, so 1 log event
assertEquals("Just one missing class should be printed out in the log",1,logging.getRecords().stream().filter(r->r.getMessage().contains(NON_EXISTING_CLASS)).count());
}
/**
...
...
@@ -152,31 +167,42 @@ public class MissingClassTelemetryFasterTest {
// No events gathered
assertEquals(0,eventsGathered.size());
// No log
assertEquals("No log if the class is not a java one",0,logging.getRecords().stream().filter(r->r.getMessage().contains(NON_EXISTING_CLASS)).count());
}
/**
* Only a max number of events is gathered. In this test, just one wit two occurrences
* Only a max number of events is gathered. In this test, just one with two occurrences
*/
@Test
publicvoidmaxEventsLimitedSameStackTrace(){
Assume.assumeTrue("The telemetry should be enabled",MissingClassTelemetry.enabled());