From bda25414d38806ccd992e072acd30221654faa38 Mon Sep 17 00:00:00 2001 From: Alexandre Montplaisir Date: Wed, 1 Jun 2016 21:49:29 -0400 Subject: [PATCH] Add tests for "lttng list" when using the legacy agent Highlights a bug in current master. Signed-off-by: Alexandre Montplaisir --- .../agent/integration/events/JulLegacyApiIT.java | 16 ++++++++++++++++ .../integration/events/Log4jLegacyApiIT.java | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulLegacyApiIT.java b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulLegacyApiIT.java index e8bcb9d..674ca79 100644 --- a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulLegacyApiIT.java +++ b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulLegacyApiIT.java @@ -24,6 +24,8 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import java.lang.reflect.Field; +import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; @@ -165,6 +167,20 @@ public class JulLegacyApiIT { assertEquals(10, handler.getEventCount()); } + /** + * Test that the "lttng list" commands lists the expected events. + */ + @Test + public void testListEvents() { + List enabledEvents = session.listEvents(); + List expectedEvents = Arrays.asList(EVENT_NAME_A, EVENT_NAME_B); + + Collections.sort(enabledEvents); + Collections.sort(expectedEvents); + + assertEquals(expectedEvents, enabledEvents); + } + /** * Get the singleton JUL Handler currently managed by the LTTngAgent. It is * not public, so we need reflection to access it. diff --git a/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/events/Log4jLegacyApiIT.java b/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/events/Log4jLegacyApiIT.java index 56a3d23..50e824e 100644 --- a/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/events/Log4jLegacyApiIT.java +++ b/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/events/Log4jLegacyApiIT.java @@ -24,6 +24,8 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import java.lang.reflect.Field; +import java.util.Arrays; +import java.util.Collections; import java.util.List; import org.apache.log4j.Level; @@ -166,6 +168,20 @@ public class Log4jLegacyApiIT { assertEquals(10, handler.getEventCount()); } + /** + * Test that the "lttng list" commands lists the expected events. + */ + @Test + public void testListEvents() { + List enabledEvents = session.listEvents(); + List expectedEvents = Arrays.asList(EVENT_NAME_A, EVENT_NAME_B); + + Collections.sort(enabledEvents); + Collections.sort(expectedEvents); + + assertEquals(expectedEvents, enabledEvents); + } + /** * Get the singleton Log4j Handler currently managed by the LTTngAgent. It * is not public, so we need reflection to access it. -- 2.39.5