From: Alexandre Montplaisir Date: Thu, 4 Feb 2016 21:26:06 +0000 (-0500) Subject: Add test to to enable events then destroying the session X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=c5796c3e1ef6fd9b05a5f6096923905154fd17ad;p=lttng-ust-java-tests.git 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 --- 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. */