X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=lttng-ust-java-tests-common%2Fsrc%2Ftest%2Fjava%2Forg%2Flttng%2Fust%2Fagent%2Fintegration%2Fclient%2FTcpClientIT.java;h=6313a6fd34134d1be05fe67023b8132acb6ab8cf;hb=HEAD;hp=8f3750ba782dda78de9284b39febc879531cd907;hpb=88282100495351d3bbdc08743cf6fc6c311163bb;p=lttng-ust-java-tests.git 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 8f3750b..6313a6f 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 @@ -18,21 +18,21 @@ package org.lttng.ust.agent.integration.client; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; import org.lttng.tools.ILttngSession; import org.lttng.tools.LttngToolsHelper; import org.lttng.ust.agent.ILttngAgent; @@ -42,7 +42,7 @@ import org.lttng.ust.agent.session.LogLevelSelector; import org.lttng.ust.agent.session.LogLevelSelector.LogLevelType; import org.lttng.ust.agent.utils.EventRuleFactory; import org.lttng.ust.agent.utils.ILogLevelStrings; -import org.lttng.ust.agent.utils.TestPrintRunner; +import org.lttng.ust.agent.utils.TestPrintExtension; /** * Tests for the TCP client only, without using an agent. @@ -53,7 +53,7 @@ import org.lttng.ust.agent.utils.TestPrintRunner; * * @author Alexandre Montplaisir */ -@RunWith(TestPrintRunner.class) +@ExtendWith(TestPrintExtension.class) public class TcpClientIT { // ------------------------------------------------------------------------ @@ -77,6 +77,8 @@ public class TcpClientIT { private static LttngTcpSessiondClient client; private static Thread clientThread; + private static EventRuleFactory eventRuleFactory = new EventRuleFactory(SESSION_DOMAIN); + private ILttngSession session; // ------------------------------------------------------------------------ @@ -86,7 +88,7 @@ public class TcpClientIT { /** * Class setup */ - @BeforeClass + @BeforeAll public static void setupClass() { LttngToolsHelper.destroyAllSessions(); @@ -113,13 +115,13 @@ public class TcpClientIT { clientThread = new Thread(client); clientThread.start(); - assertTrue("Timed out waiting for a sessiond", client.waitForConnection(5)); + assertTrue(client.waitForConnection(5), "Timed out waiting for a sessiond"); } /** * Class teardown */ - @AfterClass + @AfterAll public static void teardownClass() { if (client != null) { client.close(); @@ -135,7 +137,7 @@ public class TcpClientIT { /** * Test setup */ - @Before + @BeforeEach public void setup() { session = ILttngSession.createSession(null, SESSION_DOMAIN); clientListener.clearAllCommands(); @@ -144,7 +146,7 @@ public class TcpClientIT { /** * Test teardown */ - @After + @AfterEach public void teardown() { session.close(); } @@ -179,7 +181,7 @@ public class TcpClientIT { session.enableEvent(EVENT_NAME_A, null, false, null); List expectedCommands = Collections.singletonList( - EventRuleFactory.createRule(EVENT_NAME_A)); + eventRuleFactory.createRule(EVENT_NAME_A)); List actualCommands = clientListener.getEnabledEventCommands(); assertEquals(expectedCommands, actualCommands); @@ -193,7 +195,7 @@ public class TcpClientIT { session.enableAllEvents(); List expectedCommands = Collections.singletonList( - EventRuleFactory.createRuleAllEvents()); + eventRuleFactory.createRuleAllEvents()); List actualCommands = clientListener.getEnabledEventCommands(); assertEquals(expectedCommands, actualCommands); @@ -208,7 +210,7 @@ public class TcpClientIT { session.disableEvents(EVENT_NAME_A); List expectedEnableCommands = Collections.singletonList( - EventRuleFactory.createRule(EVENT_NAME_A)); + eventRuleFactory.createRule(EVENT_NAME_A)); List expectedDisableCommands = Collections.singletonList(EVENT_NAME_A); assertEquals(expectedEnableCommands, clientListener.getEnabledEventCommands()); @@ -226,9 +228,9 @@ public class TcpClientIT { session.disableAllEvents(); List expectedEnableCommands = Arrays.asList( - EventRuleFactory.createRule(EVENT_NAME_A), - EventRuleFactory.createRule(EVENT_NAME_B), - EventRuleFactory.createRule(EVENT_NAME_C)); + eventRuleFactory.createRule(EVENT_NAME_A), + eventRuleFactory.createRule(EVENT_NAME_B), + eventRuleFactory.createRule(EVENT_NAME_C)); /* * A "disable-event -a" will send one command for each enabled event. * The order may be different though. @@ -248,7 +250,7 @@ public class TcpClientIT { session.enableAllEvents(); session.disableAllEvents(); - List expectedEnableCommands = Arrays.asList(EventRuleFactory.createRuleAllEvents()); + List expectedEnableCommands = Arrays.asList(eventRuleFactory.createRuleAllEvents()); List expectedDisableCommands = Arrays.asList(EventRuleFactory.EVENT_NAME_ALL); assertEquals(expectedEnableCommands, clientListener.getEnabledEventCommands()); @@ -267,7 +269,7 @@ public class TcpClientIT { 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 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()); @@ -284,7 +286,7 @@ public class TcpClientIT { session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), false, null); List expectedCommands = Collections.singletonList( - EventRuleFactory.createRule(EVENT_NAME_A, lls)); + eventRuleFactory.createRule(EVENT_NAME_A, lls)); List actualCommands = clientListener.getEnabledEventCommands(); assertEquals(expectedCommands, actualCommands); @@ -300,7 +302,7 @@ public class TcpClientIT { session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), true, null); List expectedCommands = Collections.singletonList( - EventRuleFactory.createRule(EVENT_NAME_A, lls)); + eventRuleFactory.createRule(EVENT_NAME_A, lls)); List actualCommands = clientListener.getEnabledEventCommands(); assertEquals(expectedCommands, actualCommands); @@ -318,8 +320,8 @@ public class TcpClientIT { session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), true, null); List expectedCommands = Arrays.asList( - EventRuleFactory.createRule(EVENT_NAME_A, lls1), - EventRuleFactory.createRule(EVENT_NAME_A, lls2) + eventRuleFactory.createRule(EVENT_NAME_A, lls1), + eventRuleFactory.createRule(EVENT_NAME_A, lls2) ); List actualCommands = clientListener.getEnabledEventCommands(); @@ -338,8 +340,8 @@ public class TcpClientIT { session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), false, null); List expectedCommands = Arrays.asList( - EventRuleFactory.createRule(EVENT_NAME_A, lls1), - EventRuleFactory.createRule(EVENT_NAME_A, lls2) + eventRuleFactory.createRule(EVENT_NAME_A, lls1), + eventRuleFactory.createRule(EVENT_NAME_A, lls2) ); List actualCommands = clientListener.getEnabledEventCommands(); @@ -361,8 +363,8 @@ public class TcpClientIT { session2.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), true, null); List expectedCommands = Arrays.asList( - EventRuleFactory.createRule(EVENT_NAME_A, lls1), - EventRuleFactory.createRule(EVENT_NAME_A, lls2)); + eventRuleFactory.createRule(EVENT_NAME_A, lls1), + eventRuleFactory.createRule(EVENT_NAME_A, lls2)); List actualCommands = clientListener.getEnabledEventCommands(); assertEquals(expectedCommands, actualCommands); @@ -382,9 +384,9 @@ public class TcpClientIT { session.enableEvent(EVENT_NAME_A, null, false, filter2); List expectedCommands = Arrays.asList( - EventRuleFactory.createRule(EVENT_NAME_A), - EventRuleFactory.createRule(EVENT_NAME_A, EventRuleFactory.LOG_LEVEL_UNSPECIFIED, filter1), - EventRuleFactory.createRule(EVENT_NAME_A, EventRuleFactory.LOG_LEVEL_UNSPECIFIED, filter2)); + eventRuleFactory.createRule(EVENT_NAME_A), + eventRuleFactory.createRule(EVENT_NAME_A, eventRuleFactory.LOG_LEVEL_UNSPECIFIED, filter1), + eventRuleFactory.createRule(EVENT_NAME_A, eventRuleFactory.LOG_LEVEL_UNSPECIFIED, filter2)); List actualCommands = clientListener.getEnabledEventCommands(); assertEquals(expectedCommands, actualCommands); @@ -405,10 +407,10 @@ public class TcpClientIT { session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), false, filter); List expectedCommands = Arrays.asList( - EventRuleFactory.createRule(EVENT_NAME_A), - EventRuleFactory.createRule(EVENT_NAME_A, lls), - EventRuleFactory.createRule(EVENT_NAME_A, EventRuleFactory.LOG_LEVEL_UNSPECIFIED, filter), - EventRuleFactory.createRule(EVENT_NAME_A, lls, filter)); + eventRuleFactory.createRule(EVENT_NAME_A), + eventRuleFactory.createRule(EVENT_NAME_A, lls), + eventRuleFactory.createRule(EVENT_NAME_A, eventRuleFactory.LOG_LEVEL_UNSPECIFIED, filter), + eventRuleFactory.createRule(EVENT_NAME_A, lls, filter)); List actualCommands = clientListener.getEnabledEventCommands(); assertEquals(expectedCommands, actualCommands);