From c5796c3e1ef6fd9b05a5f6096923905154fd17ad Mon Sep 17 00:00:00 2001 From: Alexandre Montplaisir Date: Thu, 4 Feb 2016 16:26:06 -0500 Subject: [PATCH] Add test to to enable events then destroying the session Upon session destroy, the sessiond should send the corresponding agent messages to disable the events that were present in the session. Signed-off-by: Alexandre Montplaisir --- .../agent/integration/client/TcpClientIT.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lttng-ust-java-tests-common/src/test/java/org/lttng/ust/agent/integration/client/TcpClientIT.java b/lttng-ust-java-tests-common/src/test/java/org/lttng/ust/agent/integration/client/TcpClientIT.java index 2794dfa..16c7d01 100644 --- a/lttng-ust-java-tests-common/src/test/java/org/lttng/ust/agent/integration/client/TcpClientIT.java +++ b/lttng-ust-java-tests-common/src/test/java/org/lttng/ust/agent/integration/client/TcpClientIT.java @@ -234,6 +234,25 @@ public class TcpClientIT { assertTrue(containSameElements(expectedDisableCommands, clientListener.getDisabledEventCommands())); } + /** + * Test enabling then destroying the session (should send corresponding + * disable event messages). + */ + @SuppressWarnings("static-method") + @Test + public void testEnableEventThenDestroy() { + try (ILttngSession session2 = ILttngSession.createSession(null, SESSION_DOMAIN);) { + session2.enableEvent(EVENT_NAME_A, null, false, null); + session2.enableEvent(EVENT_NAME_B, null, false, null); + } // close(), aka destroy the session, sending "disable event" messages + + List expectedEnabledCommands = Arrays.asList(EventRuleFactory.createRule(EVENT_NAME_A), EventRuleFactory.createRule(EVENT_NAME_B)); + List expectedDisabledCommands = Arrays.asList(EVENT_NAME_A, EVENT_NAME_B); + + assertEquals(expectedEnabledCommands, clientListener.getEnabledEventCommands()); + assertEquals(expectedDisabledCommands, clientListener.getDisabledEventCommands()); + } + /** * Test specifying an event with a --loglevel option. */ -- 2.34.1