import static org.junit.Assert.fail;
import java.lang.reflect.Field;
+import java.util.Arrays;
import java.util.List;
import org.apache.log4j.Level;
assertEquals(10, handler.getEventCount());
}
+ /**
+ * Test that the "lttng list" commands lists the expected events.
+ */
+ @Test
+ public void testListEvents() {
+ List<String> enabledEvents = session.listEvents();
+ List<String> expectedEvents = Arrays.asList(EVENT_NAME_A, EVENT_NAME_B);
+
+ /*
+ * It doesn't seem possible to forcibly remove Loggers with log4j 1.2.
+ * This, coupled with the way the legacy agent works, makes it so
+ * loggers defined in other tests will always "leak" into this one when
+ * running the whole test suite.
+ *
+ * For this test, simply check that the expected names are present, and
+ * let pass the case where other loggers may the present too.
+ */
+ expectedEvents.forEach(event -> assertTrue(enabledEvents.contains(event)));
+ }
+
/**
* Get the singleton Log4j Handler currently managed by the LTTngAgent. It
* is not public, so we need reflection to access it.