Migrate to Junit 5 Jupiter
authorMichael Jeanson <mjeanson@efficios.com>
Mon, 24 Jan 2022 19:08:49 +0000 (19:08 +0000)
committerMichael Jeanson <mjeanson@efficios.com>
Mon, 31 Jan 2022 20:57:12 +0000 (20:57 +0000)
This is mostly boilerplate stuff to move from Junit 4 to 5. The only
exceptions are the TestPrintRunner which was converted to an extension
and the parametrized tests that required more involved changes.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
59 files changed:
lttng-tools-java/src/main/java/org/lttng/tools/LttngCommandLineSession.java
lttng-tools-java/src/main/java/org/lttng/tools/utils/ShellUtils.java
lttng-ust-java-tests-common/pom.xml
lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/integration/context/AppContextITBase.java
lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/integration/context/AppContextOrderingITBase.java
lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/integration/events/EnabledEventsITBase.java
lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/integration/events/ListEventsITBase.java
lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/integration/events/LoggerHierachyListITBase.java
lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/integration/events/MultiSessionITBase.java
lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/integration/filter/FilterListenerITBase.java
lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/integration/filter/FilterListenerOrderingITBase.java
lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/utils/TestPrintExtension.java [new file with mode: 0644]
lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/utils/TestPrintRunner.java [deleted file]
lttng-ust-java-tests-common/src/test/java/org/lttng/ust/agent/context/ContextRegistrationIT.java
lttng-ust-java-tests-common/src/test/java/org/lttng/ust/agent/integration/client/TcpClientIT.java
lttng-ust-java-tests-jul/.classpath
lttng-ust-java-tests-jul/pom.xml
lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/JulHandlerBenchmarkBase.java
lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/builtin/DummyHandlerBenchmark.java
lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/builtin/FileHandlerBenchmark.java
lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/builtin/NoLoggerBenchmark.java
lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/LttngJulHandlerTracingDisabledBenchmark.java
lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/LttngJulHandlerTracingEnabledBenchmark.java
lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/old/OldLttngJulHandlerTracingDisabledBenchmark.java
lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/old/OldLttngJulHandlerTracingEnabledBenchmark.java
lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/context/JulAppContextIT.java
lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/context/JulAppContextOrderingIT.java
lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulEnabledEventsIT.java
lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulLegacyApiIT.java
lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulLegacyApiLoggerHierarchyListIT.java
lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulListEventsIT.java
lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulLoggerHierarchyListIT.java
lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulMultiSessionIT.java
lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/filter/JulFilterListenerIT.java
lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/filter/JulFilterListenerOrderingIT.java
lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/utils/JulTestUtils.java
lttng-ust-java-tests-log4j/.classpath
lttng-ust-java-tests-log4j/pom.xml
lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/context/Log4jAppContextIT.java
lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/context/Log4jAppContextOrderingIT.java
lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/events/Log4jEnabledEventsIT.java
lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/events/Log4jLegacyApiIT.java
lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/events/Log4jListEventsIT.java
lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/events/Log4jMultiSessionIT.java
lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/filter/Log4jFilterListenerIT.java
lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/filter/Log4jFilterListenerOrderingIT.java
lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/utils/Log4jTestUtils.java
lttng-ust-java-tests-log4j2/.classpath
lttng-ust-java-tests-log4j2/pom.xml
lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/context/Log4j2AppContextIT.java
lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/context/Log4j2AppContextOrderingIT.java
lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/events/Log4j2EnabledEventsIT.java
lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/events/Log4j2ListEventsIT.java
lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/events/Log4j2MultiSessionIT.java
lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/filter/Log4j2FilterListenerIT.java
lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/filter/Log4j2FilterListenerOrderingIT.java
lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/utils/Log4j2TestContext.java
lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/utils/Log4j2TestUtils.java
pom.xml

index 3f8793be9313bf0b0924c2bd2bd1290e27e516ee..d2867dde3744375e6b4c507bb5f6cc2bb48a1f86 100644 (file)
@@ -143,6 +143,7 @@ class LttngCommandLineSession implements ILttngSession {
                 .map(e -> e.trim())
                 .filter(e -> e.startsWith("- "))
                 .map(e -> e.substring(2))
+                .filter(e -> !e.startsWith("org.junit"))
                 .collect(Collectors.toList());
     }
 
index 112d5d416f16c072c57dea597200aaf583e6a22c..5c451961e63e4eb19f969ac869c560c2cb821eb1 100644 (file)
@@ -69,7 +69,7 @@ public final class ShellUtils {
             Process p = builder.start();
             int ret = p.waitFor();
 
-            System.out.println(String.format("(returned from command: %d)", ret));
+            System.out.println(String.format("(returned from command: %d)", Integer.valueOf(ret)));
 
             return (ret == 0);
 
index c72cd5ca20d6287efb1d9090d030b5e27a218ce1..55edc494c711fad446c674690781f8746e4c7d81 100644 (file)
@@ -45,8 +45,8 @@
     </dependency>
 
     <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter</artifactId>
       <!-- Special case here, we ship abstract test classes in the jar, so we
            need the JUnit dependency all the time. -->
       <scope>compile</scope>
index f7b32936ad2b2cb4fab6db6d581d58850ae289ef..acf19bdb79fec6c7fcef41c92433bc3e0c8922d5 100644 (file)
 
 package org.lttng.ust.agent.integration.context;
 
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 import java.io.IOException;
 import java.util.List;
 
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.lttng.tools.ILttngSession;
 import org.lttng.tools.ILttngSession.Domain;
 import org.lttng.ust.agent.ILttngHandler;
 import org.lttng.ust.agent.context.ContextInfoManager;
-import org.lttng.ust.agent.utils.TestPrintRunner;
+import org.lttng.ust.agent.utils.TestPrintExtension;
 
 /**
  * Base abstract class to implement all sorts of integration tests verifying the
  * presence of enabled application contexts in resulting traces.
  */
-@RunWith(TestPrintRunner.class)
+@ExtendWith(TestPrintExtension.class)
 public abstract class AppContextITBase {
 
     protected static final String EVENT_NAME = "EventName";
@@ -65,7 +65,7 @@ public abstract class AppContextITBase {
     /**
      * Base test setup
      */
-    @Before
+    @BeforeEach
     public void testSetup() {
         try {
             cim = ContextInfoManager.getInstance();
@@ -79,7 +79,7 @@ public abstract class AppContextITBase {
     /**
      * Base test teardown
      */
-    @After
+    @AfterEach
     public void testTeardown() {
         session.close();
 
index d567c18b986c13e0db5c78f9f0b51ee3875a748f..2ced54606d1449de23999c7354d97947f3fbd63c 100644 (file)
 
 package org.lttng.ust.agent.integration.context;
 
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 import java.io.IOException;
 import java.util.List;
 
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.lttng.tools.ILttngSession;
 import org.lttng.tools.LttngToolsHelper;
 import org.lttng.tools.ILttngSession.Domain;
 import org.lttng.ust.agent.ILttngHandler;
 import org.lttng.ust.agent.context.ContextInfoManager;
 import org.lttng.ust.agent.context.IContextInfoRetriever;
-import org.lttng.ust.agent.utils.TestPrintRunner;
+import org.lttng.ust.agent.utils.TestPrintExtension;
 
 /**
  * To obtain application contexts in a trace, three steps are required:
@@ -51,7 +51,7 @@ import org.lttng.ust.agent.utils.TestPrintRunner;
  * These three steps however can occur in any order ; this means there are 6
  * possible cases. The goal of this class is to test all these cases.
  */
-@RunWith(TestPrintRunner.class)
+@ExtendWith(TestPrintExtension.class)
 public abstract class AppContextOrderingITBase {
 
     protected static final String EVENT_NAME = "EventName";
@@ -72,7 +72,7 @@ public abstract class AppContextOrderingITBase {
     /**
      * Base test setup
      */
-    @Before
+    @BeforeEach
     public void testSetup() {
         try {
             cim = ContextInfoManager.getInstance();
@@ -86,7 +86,7 @@ public abstract class AppContextOrderingITBase {
     /**
      * Base test cleanup
      */
-    @After
+    @AfterEach
     public void testCleanup() {
         session.close();
         assertTrue(cim.unregisterContextInfoRetriever(RETRIEVER_NAME));
@@ -95,7 +95,7 @@ public abstract class AppContextOrderingITBase {
     /**
      * Base class cleanup
      */
-    @AfterClass
+    @AfterAll
     public static void julClassCleanup() {
         LttngToolsHelper.deleteAllTraces();
     }
index 7a7ce36183712f394749f95dcf3638106b779e96..25ebc9e7b3fbe436c0223eff88b2dbe755310970 100644 (file)
 
 package org.lttng.ust.agent.integration.events;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.util.Arrays;
 import java.util.List;
 
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.lttng.tools.ILttngSession;
 import org.lttng.tools.ILttngSession.Domain;
 import org.lttng.ust.agent.ILttngHandler;
-import org.lttng.ust.agent.utils.TestPrintRunner;
+import org.lttng.ust.agent.utils.TestPrintExtension;
 
 /**
  * Base abstract class to implement all sorts of integration tests verifying the
  * presence of enabled events in resulting traces.
  */
-@RunWith(TestPrintRunner.class)
+@ExtendWith(TestPrintExtension.class)
 public abstract class EnabledEventsITBase {
 
     protected static final String EVENT_NAME_A = "EventA";
@@ -67,7 +67,7 @@ public abstract class EnabledEventsITBase {
     /**
      * Base test setup
      */
-    @Before
+    @BeforeEach
     public void testSetup() {
         session = ILttngSession.createSession(null, getDomain());
     }
@@ -75,7 +75,7 @@ public abstract class EnabledEventsITBase {
     /**
      * Base test teardown
      */
-    @After
+    @AfterEach
     public void testTeardown() {
         session.close();
 
index a2fa932a858f6f68a3f04fb4b71212263395ed2a..5551db8f21f9faee4b583c5b2af02983025a3518 100644 (file)
 
 package org.lttng.ust.agent.integration.events;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.lttng.tools.ILttngSession;
+import org.lttng.ust.agent.utils.TestPrintExtension;
 
 /**
  * Base class for the list events command tests
  */
+@ExtendWith(TestPrintExtension.class)
 public abstract class ListEventsITBase {
 
     protected static final String LOGGER_NAME_1 = "org.lttng.somecomponent";
@@ -44,7 +47,7 @@ public abstract class ListEventsITBase {
     /**
      * Common test setup
      */
-    @Before
+    @BeforeEach
     public void testSetup() {
         session = ILttngSession.createSession(null, getDomain());
     }
@@ -52,7 +55,7 @@ public abstract class ListEventsITBase {
     /**
      * Common test teardown
      */
-    @After
+    @AfterEach
     public void testTeardown() {
         session.close();
     }
index 5e1af16e9854342225aef68261a3a4c27c52fb71..dae031a94071f46b57ff6d8a702f3e2cb74b1296 100644 (file)
 
 package org.lttng.ust.agent.integration.events;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runners.Parameterized.Parameters;
+import java.util.stream.Stream;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
 import org.lttng.tools.ILttngSession;
+import org.lttng.ust.agent.utils.TestPrintExtension;
 
 /**
  * Base class testing the "lttng list" command when using loggers organized as a
@@ -43,16 +46,12 @@ import org.lttng.tools.ILttngSession;
  *
  * @author Alexandre Montplaisir
  */
+@ExtendWith(TestPrintExtension.class)
 public abstract class LoggerHierachyListITBase {
 
     protected static final String PARENT_LOGGER = "org.lttng";
     protected static final String CHILD_LOGGER = "org.lttng.mycomponent";
 
-    protected final boolean parentLoggerActive;
-    protected final boolean parentLoggerHasHandler;
-    protected final boolean childLoggerActive;
-    protected final boolean childLoggerHasHandler;
-
     private ILttngSession session;
 
     // ------------------------------------------------------------------------
@@ -66,41 +65,6 @@ public abstract class LoggerHierachyListITBase {
      * except "parentActive" is necessarily true when "hasHandler" is true for a
      * given logger.
      *
-     * @return The test parameters
-     */
-    @Parameters(name = "{index}: parentActive={0}, parentHasHandler={1}, childActive={2}, childHasHandler={3}")
-    public static Iterable<Object[]> testCases() {
-        /*
-         * Kept the whole array for clarity, but some cases are commented out:
-         * it is impossible to attach an handler if the logger itself is not
-         * defined!
-         */
-        return Arrays.asList(new Object[][] {
-                { Boolean.TRUE, Boolean.TRUE, Boolean.TRUE, Boolean.TRUE },
-                { Boolean.TRUE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE },
-//                { Boolean.TRUE, Boolean.TRUE, Boolean.FALSE, Boolean.TRUE },
-                { Boolean.TRUE, Boolean.TRUE, Boolean.FALSE, Boolean.FALSE },
-
-                { Boolean.TRUE, Boolean.FALSE, Boolean.TRUE, Boolean.TRUE },
-                { Boolean.TRUE, Boolean.FALSE, Boolean.TRUE, Boolean.FALSE },
-//                { Boolean.TRUE, Boolean.FALSE, Boolean.FALSE, Boolean.TRUE },
-                { Boolean.TRUE, Boolean.FALSE, Boolean.FALSE, Boolean.FALSE },
-
-//                { Boolean.FALSE, Boolean.TRUE, Boolean.TRUE, Boolean.TRUE },
-//                { Boolean.FALSE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE },
-//                { Boolean.FALSE, Boolean.TRUE, Boolean.FALSE, Boolean.TRUE },
-//                { Boolean.FALSE, Boolean.TRUE, Boolean.FALSE, Boolean.FALSE },
-
-                { Boolean.FALSE, Boolean.FALSE, Boolean.TRUE, Boolean.TRUE },
-                { Boolean.FALSE, Boolean.FALSE, Boolean.TRUE, Boolean.FALSE },
-//                { Boolean.FALSE, Boolean.FALSE, Boolean.FALSE, Boolean.TRUE },
-                { Boolean.FALSE, Boolean.FALSE, Boolean.FALSE, Boolean.FALSE },
-        });
-    }
-
-    /**
-     * Test constructor
-     *
      * @param parentLoggerActive
      *            Parent logger has been instantiated
      * @param parentLoggerHasHandler
@@ -109,15 +73,37 @@ public abstract class LoggerHierachyListITBase {
      *            Child logger has been instantiated
      * @param childLoggerHasHandler
      *            Child logger has a LTTng handler attached to it
+     *
+     * @return The test parameters
      */
-    public LoggerHierachyListITBase(boolean parentLoggerActive,
-            boolean parentLoggerHasHandler,
-            boolean childLoggerActive,
-            boolean childLoggerHasHandler) {
-        this.parentLoggerActive = parentLoggerActive;
-        this.parentLoggerHasHandler = parentLoggerHasHandler;
-        this.childLoggerActive = childLoggerActive;
-        this.childLoggerHasHandler = childLoggerHasHandler;
+    protected static Stream<Arguments> provideArguments() {
+
+        /*
+         * Kept the whole array for clarity, but some cases are commented out:
+         * it is impossible to attach an handler if the logger itself is not
+         * defined!
+         */
+        return Stream.of(
+                Arguments.of( Boolean.TRUE, Boolean.TRUE, Boolean.TRUE, Boolean.TRUE ),
+                Arguments.of( Boolean.TRUE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE ),
+//              Arguments.of( Boolean.TRUE, Boolean.TRUE, Boolean.FALSE, Boolean.TRUE ),
+                Arguments.of( Boolean.TRUE, Boolean.TRUE, Boolean.FALSE, Boolean.FALSE ),
+
+                Arguments.of( Boolean.TRUE, Boolean.FALSE, Boolean.TRUE, Boolean.TRUE ),
+                Arguments.of( Boolean.TRUE, Boolean.FALSE, Boolean.TRUE, Boolean.FALSE ),
+//              Arguments.of( Boolean.TRUE, Boolean.FALSE, Boolean.FALSE, Boolean.TRUE ),
+                Arguments.of( Boolean.TRUE, Boolean.FALSE, Boolean.FALSE, Boolean.FALSE ),
+
+//              Arguments.of( Boolean.FALSE, Boolean.TRUE, Boolean.TRUE, Boolean.TRUE ),
+//              Arguments.of( Boolean.FALSE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE ),
+//              Arguments.of( Boolean.FALSE, Boolean.TRUE, Boolean.FALSE, Boolean.TRUE ),
+//              Arguments.of( Boolean.FALSE, Boolean.TRUE, Boolean.FALSE, Boolean.FALSE ),
+
+                Arguments.of( Boolean.FALSE, Boolean.FALSE, Boolean.TRUE, Boolean.TRUE ),
+                Arguments.of( Boolean.FALSE, Boolean.FALSE, Boolean.TRUE, Boolean.FALSE ),
+//              Arguments.of( Boolean.FALSE, Boolean.FALSE, Boolean.FALSE, Boolean.TRUE ),
+                Arguments.of( Boolean.FALSE, Boolean.FALSE, Boolean.FALSE, Boolean.FALSE )
+        );
     }
 
     protected ILttngSession getSession() {
@@ -131,7 +117,7 @@ public abstract class LoggerHierachyListITBase {
     /**
      * Common test setup
      */
-    @Before
+    @BeforeEach
     public void testSetup() {
         session = ILttngSession.createSession(null, getDomain());
     }
@@ -139,7 +125,7 @@ public abstract class LoggerHierachyListITBase {
     /**
      * Common test teardown
      */
-    @After
+    @AfterEach
     public void testTeardown() {
         session.close();
     }
@@ -150,7 +136,10 @@ public abstract class LoggerHierachyListITBase {
 
     protected abstract ILttngSession.Domain getDomain();
 
-    protected abstract void activateLoggers() throws IOException;
+    protected abstract void activateLoggers(boolean parentLoggerActive,
+            boolean parentLoggerHasHandler,
+            boolean childLoggerActive,
+            boolean childLoggerHasHandler) throws IOException;
 
     // ------------------------------------------------------------------------
     // Common tests
@@ -159,12 +148,29 @@ public abstract class LoggerHierachyListITBase {
     /**
      * Test the output of the "lttng list" command.
      *
+     * @param parentLoggerActive
+     *            Parent logger has been instantiated
+     * @param parentLoggerHasHandler
+     *            Parent logger has a LTTng handler attached to it
+     * @param childLoggerActive
+     *            Child logger has been instantiated
+     * @param childLoggerHasHandler
+     *            Child logger has a LTTng handler attached to it
+     *
      * @throws IOException
      *             Fails the test
      */
-    @Test
-    public void testList() throws IOException {
-        activateLoggers();
+    @ParameterizedTest
+    @MethodSource("provideArguments")
+    public void testList(boolean parentLoggerActive,
+            boolean parentLoggerHasHandler,
+            boolean childLoggerActive,
+            boolean childLoggerHasHandler) throws IOException {
+
+        activateLoggers(parentLoggerActive,
+                parentLoggerHasHandler,
+                childLoggerActive,
+                childLoggerHasHandler);
 
         List<String> enabledEvents = session.listEvents();
         List<String> expectedEvents = new ArrayList<>();
index bc75961da6f995337041aeb30c24790512bd8a6d..930b5f987c3d071f0866dca5737ffc328717b647 100644 (file)
 
 package org.lttng.ust.agent.integration.events;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.util.List;
 
-import org.junit.After;
-import org.junit.Before;
-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.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
 import org.lttng.tools.ILttngSession;
 import org.lttng.tools.ILttngSession.Domain;
 import org.lttng.ust.agent.ILttngHandler;
-import org.lttng.ust.agent.utils.TestPrintRunner;
+import org.lttng.ust.agent.utils.TestPrintExtension;
 
 /**
  * Base abstract class for tests with multiple concurrent tracing sessions
  */
-@RunWith(TestPrintRunner.class)
+@ExtendWith(TestPrintExtension.class)
 public abstract class MultiSessionITBase {
 
     protected static final String EVENT_NAME_A = "EventA";
@@ -63,7 +63,7 @@ public abstract class MultiSessionITBase {
     /**
      * Base test setup
      */
-    @Before
+    @BeforeEach
     public void testSetup() {
         session1 = ILttngSession.createSession(null, getDomain());
         session2 = ILttngSession.createSession(null, getDomain());
@@ -73,7 +73,7 @@ public abstract class MultiSessionITBase {
     /**
      * Base test teardown
      */
-    @After
+    @AfterEach
     public void testTeardown() {
         session1.close();
         session2.close();
index dddcaeea74f98efd03c48c33ef667798d17676f5..7712b46cd9f5509c98f8471e7f1500982f09a487 100644 (file)
@@ -18,7 +18,7 @@
 
 package org.lttng.ust.agent.integration.filter;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.io.IOException;
 import java.util.Collections;
@@ -27,10 +27,10 @@ import java.util.Set;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
-import org.junit.After;
-import org.junit.Before;
-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.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
 import org.lttng.tools.ILttngSession;
 import org.lttng.ust.agent.ILttngHandler;
 import org.lttng.ust.agent.filter.FilterChangeNotifier;
@@ -40,14 +40,14 @@ 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;
 
 /**
  * Base test class for {@link IFilterChangeListener} tests.
  *
  * @author Alexandre Montplaisir
  */
-@RunWith(TestPrintRunner.class)
+@ExtendWith(TestPrintExtension.class)
 public abstract class FilterListenerITBase {
 
     private static final String EVENT_NAME_A = "eventA";
@@ -68,7 +68,7 @@ public abstract class FilterListenerITBase {
      * @throws SecurityException
      * @throws IOException
      */
-    @Before
+    @BeforeEach
     public void setup() throws SecurityException, IOException {
         handler = getLogHandler();
         listener = new TestFilterListener();
@@ -81,7 +81,7 @@ public abstract class FilterListenerITBase {
     /**
      * Test teardown
      */
-    @After
+    @AfterEach
     public void teardown() {
         session.close();
         FilterChangeNotifier.getInstance().unregisterListener(listener);
index c226d455f59a220807b93b3a26a9bf9340ca2cd7..4e344e05d3c891bb3b3871e7badab359ae0fad43 100644 (file)
 
 package org.lttng.ust.agent.integration.filter;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.util.Collections;
 import java.util.Set;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
-import org.junit.After;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.jupiter.api.AfterEach;
 import org.lttng.tools.ILttngSession;
 import org.lttng.ust.agent.filter.FilterChangeNotifier;
 import org.lttng.ust.agent.integration.filter.FilterListenerITBase.TestFilterListener;
 import org.lttng.ust.agent.session.EventRule;
 import org.lttng.ust.agent.utils.EventRuleFactory;
+import org.lttng.ust.agent.utils.TestPrintExtension;
 
 /**
  * For the filter change notifications to work, several setup steps are
@@ -65,6 +67,7 @@ import org.lttng.ust.agent.utils.EventRuleFactory;
  * possibilities.
  * </p>
  */
+@ExtendWith(TestPrintExtension.class)
 @SuppressWarnings("javadoc")
 public abstract class FilterListenerOrderingITBase {
 
@@ -77,7 +80,7 @@ public abstract class FilterListenerOrderingITBase {
     /**
      * Base class cleanup
      */
-    @After
+    @AfterEach
     public void baseTeardown() {
         /*
          * Deregister the listener (should always be done after all the other
diff --git a/lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/utils/TestPrintExtension.java b/lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/utils/TestPrintExtension.java
new file mode 100644 (file)
index 0000000..772d1ed
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2022, EfficiOS Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+package org.lttng.ust.agent.utils;
+
+import java.util.Optional;
+
+import org.junit.jupiter.api.extension.AfterTestExecutionCallback;
+import org.junit.jupiter.api.extension.BeforeTestExecutionCallback;
+import org.junit.jupiter.api.extension.ExtensionContext;
+import org.junit.jupiter.api.extension.ExtensionContext.Namespace;
+import org.junit.jupiter.api.extension.ExtensionContext.Store;
+import org.junit.jupiter.api.extension.TestWatcher;
+
+/**
+ * Test extension that will print the name of the test being run to stdout.
+ */
+public class TestPrintExtension implements BeforeTestExecutionCallback, AfterTestExecutionCallback, TestWatcher {
+
+    private static final String START_TIME = "start time";
+
+
+    @Override
+    public void beforeTestExecution(ExtensionContext context) throws Exception {
+        System.out.println("\nStarted " + context.getDisplayName() + "\n");
+        getStore(context).put(START_TIME, Long.valueOf(System.currentTimeMillis()));
+    }
+
+    @Override
+    public void afterTestExecution(ExtensionContext context) throws Exception {
+        long startTime = getStore(context).remove(START_TIME, long.class).longValue();
+        long duration = System.currentTimeMillis() - startTime;
+
+        System.out.println("\nEnded " + context.getDisplayName() + " in " + duration + " ms\n");
+    }
+
+    @Override
+    public void testDisabled(ExtensionContext context, Optional<String> reason) {
+        System.out.println("\nSKIPPING TEST: " + context.getDisplayName() + "\n");
+    }
+
+    private Store getStore(ExtensionContext context) {
+        return context.getStore(Namespace.create(getClass(), context.getRequiredTestMethod()));
+    }
+}
\ No newline at end of file
diff --git a/lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/utils/TestPrintRunner.java b/lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/utils/TestPrintRunner.java
deleted file mode 100644 (file)
index 1285984..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir <alexmonthy@efficios.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-package org.lttng.ust.agent.utils;
-
-import org.junit.runner.Description;
-import org.junit.runner.notification.Failure;
-import org.junit.runner.notification.RunListener;
-import org.junit.runner.notification.RunNotifier;
-import org.junit.runners.BlockJUnit4ClassRunner;
-import org.junit.runners.model.InitializationError;
-
-/**
- * Test runner that will print the name of the test being run to stdout.
- *
- * Thanks to http://stackoverflow.com/a/27070843/4227853 for the tips.
- *
- * @author Alexandre Montplaisir
- */
-public class TestPrintRunner extends BlockJUnit4ClassRunner {
-
-    /**
-     * Constructor
-     *
-     * @param klass
-     * @throws InitializationError
-     */
-    public TestPrintRunner(Class<?> klass) throws InitializationError {
-        super(klass);
-    }
-
-    @Override
-    public void run(RunNotifier notifier) {
-        RunListener listener = new TestPrintListener();
-
-        notifier.addListener(listener);
-        super.run(notifier);
-        notifier.removeListener(listener);
-    }
-
-    /**
-     * Listener that will print the class and test name to stdout.
-     */
-    public static class TestPrintListener extends RunListener {
-
-        @Override
-        public void testStarted(Description description) {
-            System.out.println("Running " + getTestName(description));
-        }
-
-        @Override
-        public void testAssumptionFailure(Failure failure) {
-            System.out.println("SKIPPING TEST: " + getTestName(failure.getDescription()));
-            System.out.println(failure.getMessage());
-        }
-
-        /**
-         * Get the className#methodName from a Description.
-         */
-        private static String getTestName(Description description) {
-            return description.getClassName() + '#' + description.getMethodName();
-        }
-    }
-
-}
index 10327b07657cf1d6634e8319c0933d7f92e6f399..6174d9449f780551b65d71fc45db9ede5449d6f9 100644 (file)
 
 package org.lttng.ust.agent.context;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-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.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 import java.io.IOException;
 
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.lttng.ust.agent.utils.TestPrintRunner;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.lttng.ust.agent.utils.TestPrintExtension;
 
 /**
  * Generic tests related to the context retrieval mechanisms.
  *
  * @author Alexandre Montplaisir
  */
-@RunWith(TestPrintRunner.class)
+@ExtendWith(TestPrintExtension.class)
 public class ContextRegistrationIT {
 
     private ContextInfoManager mgr;
@@ -44,7 +44,7 @@ public class ContextRegistrationIT {
     /**
      * Test setup
      */
-    @Before
+    @BeforeEach
     public void testSetup() {
         try {
             mgr = ContextInfoManager.getInstance();
index 8f3750ba782dda78de9284b39febc879531cd907..0c0af7d68c9aa89ad5f3351440af8256e0992222 100644 (file)
 
 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 {
 
     // ------------------------------------------------------------------------
@@ -86,7 +86,7 @@ public class TcpClientIT {
     /**
      * Class setup
      */
-    @BeforeClass
+    @BeforeAll
     public static void setupClass() {
         LttngToolsHelper.destroyAllSessions();
 
@@ -113,13 +113,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 +135,7 @@ public class TcpClientIT {
     /**
      * Test setup
      */
-    @Before
+    @BeforeEach
     public void setup() {
         session = ILttngSession.createSession(null, SESSION_DOMAIN);
         clientListener.clearAllCommands();
@@ -144,7 +144,7 @@ public class TcpClientIT {
     /**
      * Test teardown
      */
-    @After
+    @AfterEach
     public void teardown() {
         session.close();
     }
index 2d5eac0c6758f383a3e2f4b62ee1d587396d0f5a..3b348b78f092a975932be0a97de375183841ac47 100644 (file)
@@ -24,6 +24,6 @@
                        <attribute name="maven.pomderived" value="true"/>
                </attributes>
        </classpathentry>
-       <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
+       <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
        <classpathentry kind="output" path="target/classes"/>
 </classpath>
index b33a1a78b839fa6be1b09715a7cf4745f7e32b67..3a2354046021692da19adf487fae90d5dd3c60fe 100644 (file)
@@ -51,8 +51,9 @@
       <artifactId>lttng-ust-java-tests-common</artifactId>
     </dependency>
     <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter</artifactId>
+      <scope>test</scope>
     </dependency>
   </dependencies>
 
index 201ff838d6b32974d4b0e94c81a451bf6ff12021..45324a2afaede658fea55560f1b799e3d3ed7dfe 100644 (file)
@@ -24,14 +24,17 @@ import java.util.logging.Handler;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.lttng.ust.agent.utils.TestPrintExtension;
 
 /**
  * Base abstract class for JUL benchmarks. Sub-classes can setup parameters to
  * test different types of log handlers.
  */
+@ExtendWith(TestPrintExtension.class)
 public abstract class JulHandlerBenchmarkBase {
 
     // ------------------------------------------------------------------------
@@ -61,7 +64,7 @@ public abstract class JulHandlerBenchmarkBase {
     /**
      * Base test setup
      */
-    @Before
+    @BeforeEach
     public void setup() {
         /* Set up the logger */
         logger = Logger.getLogger("Test logger");
@@ -74,7 +77,7 @@ public abstract class JulHandlerBenchmarkBase {
     /**
      * Base test teardown
      */
-    @After
+    @AfterEach
     public void teardown() {
         if (handler != null) {
             logger.removeHandler(handler);
index 44a5290bcab6cfb9e7d3042837c2762b486f4506..c3b89535c3bbddf7f8a2cb0ba74726b0162778aa 100644 (file)
@@ -21,7 +21,7 @@ package org.lttng.ust.agent.benchmarks.jul.handler.builtin;
 import java.util.logging.Handler;
 import java.util.logging.LogRecord;
 
-import org.junit.Before;
+import org.junit.jupiter.api.BeforeEach;
 import org.lttng.ust.agent.benchmarks.jul.handler.JulHandlerBenchmarkBase;
 
 /**
@@ -33,7 +33,7 @@ public class DummyHandlerBenchmark extends JulHandlerBenchmarkBase {
        /**
         * Test setup
         */
-       @Before
+       @BeforeEach
        public void testSetup() {
                handler = new DummyHandler();
        }
index af4ab7ceb52dc589c13366e273e136aa961b0f66..5437754b8a4447553b3b42af4bf1b57ddeec8bfa 100644 (file)
@@ -24,8 +24,8 @@ import java.nio.file.Path;
 import java.util.logging.FileHandler;
 import java.util.logging.SimpleFormatter;
 
-import org.junit.After;
-import org.junit.Before;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
 import org.lttng.ust.agent.benchmarks.jul.handler.JulHandlerBenchmarkBase;
 
 /**
@@ -43,7 +43,7 @@ public class FileHandlerBenchmark extends JulHandlerBenchmarkBase {
         * @throws IOException
         *             If there is problem setting up the handler
         */
-       @Before
+       @BeforeEach
        public void testSetup() throws SecurityException, IOException {
                outputFile = Files.createTempFile(this.getClass().getSimpleName(), null);
 
@@ -57,7 +57,7 @@ public class FileHandlerBenchmark extends JulHandlerBenchmarkBase {
         * @throws IOException
         *             If we could not delete the test file
         */
-       @After
+       @AfterEach
        public void testTeardown() throws IOException {
                Files.deleteIfExists(outputFile);
        }
index ffa57262696b92b619843aa88fcd9714ee38ecea..fc1661885129e48542c2f655f0ee4c31f8c42573 100644 (file)
@@ -18,8 +18,8 @@
 
 package org.lttng.ust.agent.benchmarks.jul.handler.builtin;
 
-import org.junit.After;
-import org.junit.Before;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
 import org.lttng.ust.agent.benchmarks.jul.handler.JulHandlerBenchmarkBase;
 
 /**
@@ -32,7 +32,7 @@ public class NoLoggerBenchmark extends JulHandlerBenchmarkBase {
      * Override the super class's setup() to avoid creating a Logger.
      */
     @Override
-    @Before
+    @BeforeEach
     public void setup() {
         logger = null;
         handler = null;
@@ -42,7 +42,7 @@ public class NoLoggerBenchmark extends JulHandlerBenchmarkBase {
      * Override the super class's teardown()
      */
     @Override
-    @After
+    @AfterEach
     public void teardown() {
     }
 }
index d0e514c703ecc16612437fb38d403bc2f00184e7..df7eca3266610360b854c0c394195811d6ffb59e 100644 (file)
 
 package org.lttng.ust.agent.benchmarks.jul.handler.lttng;
 
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.io.IOException;
 
-import org.junit.After;
-import org.junit.Before;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
 import org.lttng.tools.ILttngSession;
 import org.lttng.tools.ILttngSession.Domain;
 import org.lttng.ust.agent.benchmarks.jul.handler.JulHandlerBenchmarkBase;
@@ -42,7 +42,7 @@ public class LttngJulHandlerTracingDisabledBenchmark extends JulHandlerBenchmark
      *
      * @throws IOException
      */
-    @Before
+    @BeforeEach
     public void testSetup() throws IOException {
         handler = new LttngLogHandler();
 
@@ -54,7 +54,7 @@ public class LttngJulHandlerTracingDisabledBenchmark extends JulHandlerBenchmark
     /**
      * Test cleanup
      */
-    @After
+    @AfterEach
     public void testTeardown() {
         assertTrue(session.stop());
         session.close();
index c594de437b02903f69a5f359c8747d481c155489..bdddedad0e5ea8b0f68bea351517b2feb8ed4590 100644 (file)
 
 package org.lttng.ust.agent.benchmarks.jul.handler.lttng;
 
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.io.IOException;
 
-import org.junit.After;
-import org.junit.Before;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
 import org.lttng.tools.ILttngSession;
 import org.lttng.tools.ILttngSession.Domain;
 import org.lttng.ust.agent.benchmarks.jul.handler.JulHandlerBenchmarkBase;
@@ -41,7 +41,7 @@ public class LttngJulHandlerTracingEnabledBenchmark extends JulHandlerBenchmarkB
      *
      * @throws IOException
      */
-    @Before
+    @BeforeEach
     public void testSetup() throws IOException {
         handler = new LttngLogHandler();
 
@@ -53,7 +53,7 @@ public class LttngJulHandlerTracingEnabledBenchmark extends JulHandlerBenchmarkB
     /**
      * Test cleanup
      */
-    @After
+    @AfterEach
     public void testTeardown() {
         assertTrue(session.stop());
         session.close();
index 49a7c83aa8cb0d38e09429a15e0d4d401f10ab1b..17c67e039734922d208779bd845a229a03c32008 100644 (file)
 
 package org.lttng.ust.agent.benchmarks.jul.handler.lttng.old;
 
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
-import org.junit.After;
-import org.junit.Before;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
 import org.lttng.tools.ILttngSession;
 import org.lttng.tools.ILttngSession.Domain;
 import org.lttng.ust.agent.LTTngAgent;
@@ -40,7 +40,7 @@ public class OldLttngJulHandlerTracingDisabledBenchmark extends JulHandlerBenchm
     /**
      * Test setup
      */
-    @Before
+    @BeforeEach
     public void testSetup() {
         agent = LTTngAgent.getLTTngAgent();
 
@@ -52,7 +52,7 @@ public class OldLttngJulHandlerTracingDisabledBenchmark extends JulHandlerBenchm
     /**
      * Test cleanup
      */
-    @After
+    @AfterEach
     public void testTeardown() {
         assertTrue(session.stop());
         session.close();
index e18efdcdf6ba29864d8d41258942efcf1167445c..a9985c4f3ef36d440879b6cb6401736ab4b8779e 100644 (file)
 
 package org.lttng.ust.agent.benchmarks.jul.handler.lttng.old;
 
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 import java.lang.reflect.Field;
 
-import org.junit.After;
-import org.junit.Before;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
 import org.lttng.tools.ILttngSession;
 import org.lttng.tools.ILttngSession.Domain;
 import org.lttng.ust.agent.LTTngAgent;
@@ -46,7 +46,7 @@ public class OldLttngJulHandlerTracingEnabledBenchmark extends JulHandlerBenchma
     /**
      * Test setup
      */
-    @Before
+    @BeforeEach
     public void testSetup() {
         agent = LTTngAgent.getLTTngAgent();
 
@@ -78,7 +78,7 @@ public class OldLttngJulHandlerTracingEnabledBenchmark extends JulHandlerBenchma
     /**
      * Test cleanup
      */
-    @After
+    @AfterEach
     public void testTeardown() {
         assertTrue(session.stop());
         session.close();
index 56e8d56abb480b1678d37bfd7f48bdd551f4a346..b5735f2b99610703c522334697c1f01fd04b50ef 100644 (file)
@@ -23,10 +23,10 @@ import java.util.logging.Handler;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
+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.Domain;
 import org.lttng.ust.agent.jul.LttngLogHandler;
 import org.lttng.ust.agent.utils.JulTestUtils;
@@ -43,7 +43,7 @@ public class JulAppContextIT extends AppContextITBase {
     /**
      * Class setup
      */
-    @BeforeClass
+    @BeforeAll
     public static void julClassSetup() {
         JulTestUtils.testClassSetup();
     }
@@ -51,7 +51,7 @@ public class JulAppContextIT extends AppContextITBase {
     /**
      * Class cleanup
      */
-    @AfterClass
+    @AfterAll
     public static void julClassCleanup() {
         JulTestUtils.testClassCleanup();
     }
@@ -62,7 +62,7 @@ public class JulAppContextIT extends AppContextITBase {
      * @throws SecurityException
      * @throws IOException
      */
-    @Before
+    @BeforeEach
     public void julSetup() throws SecurityException, IOException {
         logger = Logger.getLogger(EVENT_NAME);
         logger.setLevel(Level.ALL);
@@ -74,7 +74,7 @@ public class JulAppContextIT extends AppContextITBase {
     /**
      * Test teardown
      */
-    @After
+    @AfterEach
     public void julTeardown() {
         logger.removeHandler((Handler) logHandler);
         logger = null;
index 530efab60f79eb0dd6d6126fecb9035ee5a2df20..1b488a4d5d81a82af8f904469e0e2749c06e262a 100644 (file)
 
 package org.lttng.ust.agent.integration.context;
 
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.fail;
 
 import java.io.IOException;
 import java.util.logging.Handler;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
 import org.lttng.tools.ILttngSession.Domain;
 import org.lttng.ust.agent.jul.LttngLogHandler;
 import org.lttng.ust.agent.utils.JulTestUtils;
@@ -42,7 +42,7 @@ public class JulAppContextOrderingIT extends AppContextOrderingITBase {
     /**
      * Class setup
      */
-    @BeforeClass
+    @BeforeAll
     public static void julClassSetup() {
         JulTestUtils.testClassSetup();
     }
@@ -50,7 +50,7 @@ public class JulAppContextOrderingIT extends AppContextOrderingITBase {
     /**
      * Class cleanup
      */
-    @AfterClass
+    @AfterAll
     public static void julClassCleanup() {
         JulTestUtils.testClassCleanup();
     }
@@ -58,7 +58,7 @@ public class JulAppContextOrderingIT extends AppContextOrderingITBase {
     /**
      * Test teardown
      */
-    @After
+    @AfterEach
     public void julTeardown() {
         logger.removeHandler((Handler) logHandler);
         logger = null;
index 0cfe8607629e7fbad0cb8de1611bcc91410e8b72..02c1c74574644d0f879a5737c16c53ee3114652a 100644 (file)
@@ -23,10 +23,10 @@ import java.util.logging.Handler;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
+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.Domain;
 import org.lttng.ust.agent.jul.LttngLogHandler;
 import org.lttng.ust.agent.utils.JulTestUtils;
@@ -46,7 +46,7 @@ public class JulEnabledEventsIT extends EnabledEventsITBase {
     /**
      * Class setup
      */
-    @BeforeClass
+    @BeforeAll
     public static void julClassSetup() {
         JulTestUtils.testClassSetup();
     }
@@ -54,7 +54,7 @@ public class JulEnabledEventsIT extends EnabledEventsITBase {
     /**
      * Class cleanup
      */
-    @AfterClass
+    @AfterAll
     public static void julClassCleanup() {
         JulTestUtils.testClassCleanup();
     }
@@ -65,7 +65,7 @@ public class JulEnabledEventsIT extends EnabledEventsITBase {
      * @throws SecurityException
      * @throws IOException
      */
-    @Before
+    @BeforeEach
     public void julSetup() throws SecurityException, IOException {
         loggerA = Logger.getLogger(EVENT_NAME_A);
         loggerB = Logger.getLogger(EVENT_NAME_B);
@@ -89,7 +89,7 @@ public class JulEnabledEventsIT extends EnabledEventsITBase {
     /**
      * Test teardown
      */
-    @After
+    @AfterEach
     public void julTeardown() {
         loggerA.removeHandler((Handler) handlerA);
         loggerB.removeHandler((Handler) handlerB);
index 97ba4b694049299795b686e4aecde7b66c7d83d0..7b993f3489a96344d84f40f71ada596c6e158481 100644 (file)
 
 package org.lttng.ust.agent.integration.events;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-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.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 import java.lang.reflect.Field;
 import java.util.Arrays;
@@ -31,23 +31,23 @@ import java.util.logging.Level;
 import java.util.logging.LogManager;
 import java.util.logging.Logger;
 
-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.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.lttng.tools.ILttngSession;
 import org.lttng.tools.ILttngSession.Domain;
 import org.lttng.ust.agent.ILttngHandler;
 import org.lttng.ust.agent.LTTngAgent;
 import org.lttng.ust.agent.utils.JulTestUtils;
-import org.lttng.ust.agent.utils.TestPrintRunner;
+import org.lttng.ust.agent.utils.TestPrintExtension;
 
 /**
  * Enabled events test for the LTTng-UST JUL log handler, using the legacy API.
  */
-@RunWith(TestPrintRunner.class)
+@ExtendWith(TestPrintExtension.class)
 @SuppressWarnings("deprecation")
 public class JulLegacyApiIT {
 
@@ -65,7 +65,7 @@ public class JulLegacyApiIT {
     /**
      * Class setup
      */
-    @BeforeClass
+    @BeforeAll
     public static void julClassSetup() {
         JulTestUtils.testClassSetup();
     }
@@ -73,7 +73,7 @@ public class JulLegacyApiIT {
     /**
      * Class cleanup
      */
-    @AfterClass
+    @AfterAll
     public static void julClassCleanup() {
         JulTestUtils.testClassCleanup();
     }
@@ -81,7 +81,7 @@ public class JulLegacyApiIT {
     /**
      * Test setup
      */
-    @Before
+    @BeforeEach
     public void setup() {
         /* Clear the JUL logger configuration */
         LogManager.getLogManager().reset();
@@ -100,7 +100,7 @@ public class JulLegacyApiIT {
     /**
      * Test cleanup
      */
-    @After
+    @AfterEach
     public void tearDown() {
         session.close();
 
index a9ecf8c403b812bbeab59a11546794a9fa961e72..ed8a08d178e7d708d8fc22bcd79fd311fd4ffb82 100644 (file)
@@ -18,7 +18,7 @@
 
 package org.lttng.ust.agent.integration.events;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.io.IOException;
 import java.util.ArrayList;
@@ -27,13 +27,12 @@ import java.util.List;
 import java.util.logging.LogManager;
 import java.util.logging.Logger;
 
-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.runners.Parameterized;
+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.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
 import org.lttng.tools.ILttngSession.Domain;
 import org.lttng.ust.agent.LTTngAgent;
 import org.lttng.ust.agent.utils.JulTestUtils;
@@ -45,36 +44,13 @@ import org.lttng.ust.agent.utils.JulTestUtils;
  * @author Alexandre Montplaisir
  */
 @SuppressWarnings("deprecation")
-@RunWith(Parameterized.class)
+//@RunWith(Parameterized.class)
 public class JulLegacyApiLoggerHierarchyListIT extends LoggerHierachyListITBase {
 
     private LTTngAgent agent;
     private Logger parentLogger;
     private Logger childLogger;
 
-    /**
-     * Test constructor
-     *
-     * @param parentLoggerActive
-     *            Parent logger has been instantiated
-     * @param parentLoggerHasHandler
-     *            Parent logger has a LTTng handler attached to it
-     * @param childLoggerActive
-     *            Child logger has been instantiated
-     * @param childLoggerHasHandler
-     *            Child logger has a LTTng handler attached to it
-     */
-    public JulLegacyApiLoggerHierarchyListIT(boolean parentLoggerActive,
-            boolean parentLoggerHasHandler,
-            boolean childLoggerActive,
-            boolean childLoggerHasHandler) {
-        /* Set by parameters defined in the base class */
-        super(parentLoggerActive,
-                parentLoggerHasHandler,
-                childLoggerActive,
-                childLoggerHasHandler);
-    }
-
     // ------------------------------------------------------------------------
     // Maintenance
     // ------------------------------------------------------------------------
@@ -82,7 +58,7 @@ public class JulLegacyApiLoggerHierarchyListIT extends LoggerHierachyListITBase
     /**
      * Class setup
      */
-    @BeforeClass
+    @BeforeAll
     public static void julClassSetup() {
         JulTestUtils.testClassSetup();
     }
@@ -90,7 +66,7 @@ public class JulLegacyApiLoggerHierarchyListIT extends LoggerHierachyListITBase
     /**
      * Class cleanup
      */
-    @AfterClass
+    @AfterAll
     public static void julClassCleanup() {
         JulTestUtils.testClassCleanup();
     }
@@ -99,7 +75,7 @@ public class JulLegacyApiLoggerHierarchyListIT extends LoggerHierachyListITBase
      * Test setup
      */
     @SuppressWarnings("static-method")
-    @Before
+    @BeforeEach
     public void setup() {
         LogManager.getLogManager().reset();
         System.gc();
@@ -108,7 +84,7 @@ public class JulLegacyApiLoggerHierarchyListIT extends LoggerHierachyListITBase
     /**
      * Test cleanup
      */
-    @After
+    @AfterEach
     public void cleanup() {
         agent.dispose();
 
@@ -134,7 +110,10 @@ public class JulLegacyApiLoggerHierarchyListIT extends LoggerHierachyListITBase
     }
 
     @Override
-    protected void activateLoggers() throws IOException {
+    protected void activateLoggers(boolean parentLoggerActive,
+            boolean parentLoggerHasHandler,
+            boolean childLoggerActive,
+            boolean childLoggerHasHandler) throws IOException {
         agent = LTTngAgent.getLTTngAgent();
 
         /*
@@ -161,10 +140,19 @@ public class JulLegacyApiLoggerHierarchyListIT extends LoggerHierachyListITBase
      * the logger exists, it will be visible in "lttng list" because the single
      * log handler is attached to the root logger.
      */
+    @SuppressWarnings("resource")
     @Override
-    @Test
-    public void testList() throws IOException {
-        activateLoggers();
+    @ParameterizedTest
+    @MethodSource("provideArguments")
+    public void testList(boolean parentLoggerActive,
+            boolean parentLoggerHasHandler,
+            boolean childLoggerActive,
+            boolean childLoggerHasHandler) throws IOException {
+
+        activateLoggers(parentLoggerActive,
+                parentLoggerHasHandler,
+                childLoggerActive,
+                childLoggerHasHandler);
 
         List<String> enabledEvents = getSession().listEvents();
         List<String> expectedEvents = new ArrayList<>();
index dbd5c334e5bfd15aa14633116b56b941213f5b5a..f3e2b1f988e7af24098b7b7af8f0fbafe042a33b 100644 (file)
@@ -23,10 +23,10 @@ import java.util.logging.Handler;
 import java.util.logging.LogManager;
 import java.util.logging.Logger;
 
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
+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.ust.agent.jul.LttngLogHandler;
 import org.lttng.ust.agent.utils.JulTestUtils;
@@ -42,7 +42,7 @@ public class JulListEventsIT extends ListEventsITBase {
     /**
      * Class setup
      */
-    @BeforeClass
+    @BeforeAll
     public static void julClassSetup() {
         JulTestUtils.testClassSetup();
     }
@@ -50,7 +50,7 @@ public class JulListEventsIT extends ListEventsITBase {
     /**
      * Class cleanup
      */
-    @AfterClass
+    @AfterAll
     public static void julClassCleanup() {
         JulTestUtils.testClassCleanup();
     }
@@ -61,7 +61,7 @@ public class JulListEventsIT extends ListEventsITBase {
      * @throws SecurityException
      * @throws IOException
      */
-    @Before
+    @BeforeEach
     public void julSetup() throws SecurityException, IOException {
         /* Clear the JUL logger configuration */
         LogManager.getLogManager().reset();
@@ -82,7 +82,7 @@ public class JulListEventsIT extends ListEventsITBase {
     /**
      * Test teardown. Detach and close all log handlers.
      */
-    @After
+    @AfterEach
     public void julTeardown() {
         for (Logger logger : loggers) {
             for (Handler handler : handlers) {
index 531309aa613f35b385ba1358ad0fe7870b0845f1..0d588bf9e2a84f61cc9da30af615d5ed0e4a0ad6 100644 (file)
@@ -23,12 +23,10 @@ import java.util.logging.Handler;
 import java.util.logging.LogManager;
 import java.util.logging.Logger;
 
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+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.Domain;
 import org.lttng.ust.agent.jul.LttngLogHandler;
 import org.lttng.ust.agent.utils.JulTestUtils;
@@ -38,7 +36,6 @@ import org.lttng.ust.agent.utils.JulTestUtils;
  *
  * @author Alexandre Montplaisir
  */
-@RunWith(Parameterized.class)
 public class JulLoggerHierarchyListIT extends LoggerHierachyListITBase {
 
     private Logger parentLogger;
@@ -47,29 +44,6 @@ public class JulLoggerHierarchyListIT extends LoggerHierachyListITBase {
     private Handler parentHandler;
     private Handler childHandler;
 
-    /**
-     * Test constructor
-     *
-     * @param parentLoggerActive
-     *            Parent logger has been instantiated
-     * @param parentLoggerHasHandler
-     *            Parent logger has a LTTng handler attached to it
-     * @param childLoggerActive
-     *            Child logger has been instantiated
-     * @param childLoggerHasHandler
-     *            Child logger has a LTTng handler attached to it
-     */
-    public JulLoggerHierarchyListIT(boolean parentLoggerActive,
-            boolean parentLoggerHasHandler,
-            boolean childLoggerActive,
-            boolean childLoggerHasHandler) {
-        /* Set by parameters defined in the base class */
-        super(parentLoggerActive,
-                parentLoggerHasHandler,
-                childLoggerActive,
-                childLoggerHasHandler);
-    }
-
     // ------------------------------------------------------------------------
     // Maintenance
     // ------------------------------------------------------------------------
@@ -77,7 +51,7 @@ public class JulLoggerHierarchyListIT extends LoggerHierachyListITBase {
     /**
      * Class setup
      */
-    @BeforeClass
+    @BeforeAll
     public static void julClassSetup() {
         JulTestUtils.testClassSetup();
     }
@@ -85,7 +59,7 @@ public class JulLoggerHierarchyListIT extends LoggerHierachyListITBase {
     /**
      * Class cleanup
      */
-    @AfterClass
+    @AfterAll
     public static void julClassCleanup() {
         JulTestUtils.testClassCleanup();
     }
@@ -94,7 +68,7 @@ public class JulLoggerHierarchyListIT extends LoggerHierachyListITBase {
      * Test setup
      */
     @SuppressWarnings("static-method")
-    @Before
+    @BeforeEach
     public void setup() {
         /*
          * Kind of hackish, but it's the only way to ensure that loggers are
@@ -109,7 +83,7 @@ public class JulLoggerHierarchyListIT extends LoggerHierachyListITBase {
     /**
      * Test cleanup
      */
-    @After
+    @AfterEach
     public void cleanup() {
         if (parentLogger != null) {
             if (parentHandler != null) {
@@ -143,7 +117,10 @@ public class JulLoggerHierarchyListIT extends LoggerHierachyListITBase {
     }
 
     @Override
-    protected void activateLoggers() throws IOException {
+    protected void activateLoggers(boolean parentLoggerActive,
+            boolean parentLoggerHasHandler,
+            boolean childLoggerActive,
+            boolean childLoggerHasHandler) throws IOException {
         if (parentLoggerActive) {
             parentLogger = Logger.getLogger(PARENT_LOGGER);
             if (parentLoggerHasHandler) {
index 5ab9bf0cf0f95a4acf72d7ffede1d32c1182c951..633f8f09ca0be8d9b759d8c9f1db24083d198100 100644 (file)
@@ -23,10 +23,10 @@ import java.util.logging.Handler;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
+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.Domain;
 import org.lttng.ust.agent.jul.LttngLogHandler;
 import org.lttng.ust.agent.utils.JulTestUtils;
@@ -46,7 +46,7 @@ public class JulMultiSessionIT extends MultiSessionITBase {
     /**
      * Class setup
      */
-    @BeforeClass
+    @BeforeAll
     public static void julClassSetup() {
         JulTestUtils.testClassSetup();
     }
@@ -54,7 +54,7 @@ public class JulMultiSessionIT extends MultiSessionITBase {
     /**
      * Class cleanup
      */
-    @AfterClass
+    @AfterAll
     public static void julClassCleanup() {
         JulTestUtils.testClassCleanup();
     }
@@ -65,7 +65,7 @@ public class JulMultiSessionIT extends MultiSessionITBase {
      * @throws SecurityException
      * @throws IOException
      */
-    @Before
+    @BeforeEach
     public void julSetup() throws SecurityException, IOException {
         loggerA = Logger.getLogger(EVENT_NAME_A);
         loggerB = Logger.getLogger(EVENT_NAME_B);
@@ -91,7 +91,7 @@ public class JulMultiSessionIT extends MultiSessionITBase {
     /**
      * Test teardown
      */
-    @After
+    @AfterEach
     public void julTeardown() {
         loggerA.removeHandler((Handler) handlerA);
         loggerB.removeHandler((Handler) handlerB);
index ace61de1930f1d8fbc37fb72c5eb8dfa208dc5d3..04f04ec48c45666a215117f818c6166712239d73 100644 (file)
@@ -20,8 +20,8 @@ package org.lttng.ust.agent.integration.filter;
 
 import java.io.IOException;
 
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
 import org.lttng.tools.ILttngSession;
 import org.lttng.ust.agent.ILttngHandler;
 import org.lttng.ust.agent.jul.LttngLogHandler;
@@ -38,7 +38,7 @@ public class JulFilterListenerIT extends FilterListenerITBase {
     /**
      * Class setup
      */
-    @BeforeClass
+    @BeforeAll
     public static void julClassSetup() {
         JulTestUtils.testClassSetup();
     }
@@ -46,7 +46,7 @@ public class JulFilterListenerIT extends FilterListenerITBase {
     /**
      * Class cleanup
      */
-    @AfterClass
+    @AfterAll
     public static void julClassCleanup() {
         JulTestUtils.testClassCleanup();
     }
index e1145c9e6d2230d0a0b8bd99a7919b9e5d3a017d..5964c97fb5f73bf35e1036ed1aa5f459437fa099 100644 (file)
 
 package org.lttng.ust.agent.integration.filter;
 
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.fail;
 
 import java.io.IOException;
 import java.util.logging.Handler;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
 import org.lttng.tools.ILttngSession.Domain;
 import org.lttng.ust.agent.jul.LttngLogHandler;
 import org.lttng.ust.agent.utils.JulTestUtils;
@@ -42,7 +42,7 @@ public class JulFilterListenerOrderingIT extends FilterListenerOrderingITBase {
     /**
      * Class setup
      */
-    @BeforeClass
+    @BeforeAll
     public static void julClassSetup() {
         JulTestUtils.testClassSetup();
     }
@@ -50,7 +50,7 @@ public class JulFilterListenerOrderingIT extends FilterListenerOrderingITBase {
     /**
      * Class cleanup
      */
-    @AfterClass
+    @AfterAll
     public static void julClassCleanup() {
         JulTestUtils.testClassCleanup();
     }
index af90383bd45a9599eebc3d01122ecab1e15c19e7..ed54927ea513c9cfa760ef9fd98562971341514e 100644 (file)
@@ -18,8 +18,8 @@
 
 package org.lttng.ust.agent.utils;
 
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 import java.io.IOException;
 import java.util.logging.Level;
@@ -43,7 +43,7 @@ public final class JulTestUtils {
     public static void testClassSetup() {
         /* Make sure we can find the JNI library and lttng-tools */
         checkForJulLibrary();
-        assertTrue("lttng-tools is not working properly.", LttngUtils.checkForLttngTools(Domain.JUL));
+        assertTrue(LttngUtils.checkForLttngTools(Domain.JUL), "lttng-tools is not working properly.");
 
         LttngToolsHelper.destroyAllSessions();
     }
index 3d72c56f2fe1f2e58e558ebc10dd5d3021e3bb70..73e8bfaa850393f8b51d24be6604df3ec32fe114 100644 (file)
@@ -24,6 +24,6 @@
                        <attribute name="maven.pomderived" value="true"/>
                </attributes>
        </classpathentry>
-       <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
+       <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
        <classpathentry kind="output" path="target/classes"/>
 </classpath>
index 016befad8fd7b6dbb340c2125dfe6036395facbc..81c31b8e71e7df47060d63343567825fcb38e557 100644 (file)
@@ -55,8 +55,9 @@
       <artifactId>log4j</artifactId>
     </dependency>
     <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter</artifactId>
+      <scope>test</scope>
     </dependency>
   </dependencies>
 
index 162d13e429d5ff67b173e58c5bdfa293a3da33b9..c7670eaaf5f5b4f49407e311e1f4b6352cabac21 100644 (file)
@@ -23,10 +23,10 @@ import java.io.IOException;
 import org.apache.log4j.Appender;
 import org.apache.log4j.Level;
 import org.apache.log4j.Logger;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
+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.Domain;
 import org.lttng.ust.agent.log4j.LttngLogAppender;
 import org.lttng.ust.agent.utils.Log4jTestUtils;
@@ -43,7 +43,7 @@ public class Log4jAppContextIT extends AppContextITBase {
     /**
      * Class setup
      */
-    @BeforeClass
+    @BeforeAll
     public static void log4jClassSetup() {
         Log4jTestUtils.testClassSetup();
     }
@@ -51,7 +51,7 @@ public class Log4jAppContextIT extends AppContextITBase {
     /**
      * Class cleanup
      */
-    @AfterClass
+    @AfterAll
     public static void log4jClassCleanup() {
         Log4jTestUtils.testClassCleanup();
     }
@@ -62,7 +62,7 @@ public class Log4jAppContextIT extends AppContextITBase {
      * @throws SecurityException
      * @throws IOException
      */
-    @Before
+    @BeforeEach
     public void julSetup() throws SecurityException, IOException {
         logger = Logger.getLogger(EVENT_NAME);
         logger.setLevel(Level.ALL);
@@ -74,7 +74,7 @@ public class Log4jAppContextIT extends AppContextITBase {
     /**
      * Test teardown
      */
-    @After
+    @AfterEach
     public void julTeardown() {
         logger.removeAppender((Appender) logHandler);
         logger = null;
index 44a93a829893613b68d99b368cacb82b7d300b3e..02e0ceaa85b605e9eb5deaf3e39a5ebe523afd95 100644 (file)
 
 package org.lttng.ust.agent.integration.context;
 
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.fail;
 
 import java.io.IOException;
 
 import org.apache.log4j.Appender;
 import org.apache.log4j.Level;
 import org.apache.log4j.Logger;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
 import org.lttng.tools.ILttngSession.Domain;
 import org.lttng.ust.agent.log4j.LttngLogAppender;
 import org.lttng.ust.agent.utils.Log4jTestUtils;
@@ -42,7 +42,7 @@ public class Log4jAppContextOrderingIT extends AppContextOrderingITBase {
     /**
      * Class setup
      */
-    @BeforeClass
+    @BeforeAll
     public static void log4jClassSetup() {
         Log4jTestUtils.testClassSetup();
     }
@@ -50,7 +50,7 @@ public class Log4jAppContextOrderingIT extends AppContextOrderingITBase {
     /**
      * Class cleanup
      */
-    @AfterClass
+    @AfterAll
     public static void log4jClassCleanup() {
         Log4jTestUtils.testClassCleanup();
     }
@@ -58,7 +58,7 @@ public class Log4jAppContextOrderingIT extends AppContextOrderingITBase {
     /**
      * Test teardown
      */
-    @After
+    @AfterEach
     public void log4jTeardown() {
         logger.removeAppender((Appender) logHandler);
         logger = null;
index 34bfdf7257249944e3cd3179ddc16b42474e7b2e..579d43c2a0865e935359900f2d6747896d445d40 100644 (file)
@@ -23,11 +23,11 @@ import java.io.IOException;
 import org.apache.log4j.Appender;
 import org.apache.log4j.Level;
 import org.apache.log4j.Logger;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+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.junit.jupiter.api.Test;
 import org.lttng.tools.ILttngSession.Domain;
 import org.lttng.ust.agent.log4j.LttngLogAppender;
 import org.lttng.ust.agent.utils.Log4jTestUtils;
@@ -47,7 +47,7 @@ public class Log4jEnabledEventsIT extends EnabledEventsITBase {
     /**
      * Class setup
      */
-    @BeforeClass
+    @BeforeAll
     public static void log4jClassSetup() {
         Log4jTestUtils.testClassSetup();
     }
@@ -55,7 +55,7 @@ public class Log4jEnabledEventsIT extends EnabledEventsITBase {
     /**
      * Class cleanup
      */
-    @AfterClass
+    @AfterAll
     public static void log4jClassCleanup() {
         Log4jTestUtils.testClassCleanup();
     }
@@ -66,7 +66,7 @@ public class Log4jEnabledEventsIT extends EnabledEventsITBase {
      * @throws SecurityException
      * @throws IOException
      */
-    @Before
+    @BeforeEach
     public void log4jSetup() throws SecurityException, IOException {
         loggerA = Logger.getLogger(EVENT_NAME_A);
         loggerB = Logger.getLogger(EVENT_NAME_B);
@@ -90,7 +90,7 @@ public class Log4jEnabledEventsIT extends EnabledEventsITBase {
     /**
      * Test teardown
      */
-    @After
+    @AfterEach
     public void log4jTeardown() {
         loggerA.removeAppender((Appender) handlerA);
         loggerB.removeAppender((Appender) handlerB);
index 2630101d94ce94b52becef5f4e68c6d6b28908f8..a82857cd3e17b3e3dd7095fec3e9524e85dc2cee 100644 (file)
 
 package org.lttng.ust.agent.integration.events;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-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.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 import java.lang.reflect.Field;
 import java.util.Arrays;
@@ -29,24 +29,24 @@ import java.util.List;
 
 import org.apache.log4j.Level;
 import org.apache.log4j.Logger;
-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.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.lttng.tools.ILttngSession;
 import org.lttng.tools.ILttngSession.Domain;
 import org.lttng.ust.agent.ILttngHandler;
 import org.lttng.ust.agent.LTTngAgent;
 import org.lttng.ust.agent.utils.Log4jTestUtils;
-import org.lttng.ust.agent.utils.TestPrintRunner;
+import org.lttng.ust.agent.utils.TestPrintExtension;
 
 /**
  * Enabled events test for the LTTng-UST Log4j log handler, using the legacy
  * API.
  */
-@RunWith(TestPrintRunner.class)
+@ExtendWith(TestPrintExtension.class)
 @SuppressWarnings("deprecation")
 public class Log4jLegacyApiIT {
 
@@ -64,7 +64,7 @@ public class Log4jLegacyApiIT {
     /**
      * Class setup
      */
-    @BeforeClass
+    @BeforeAll
     public static void log4jClassSetup() {
         Log4jTestUtils.testClassSetup();
     }
@@ -72,7 +72,7 @@ public class Log4jLegacyApiIT {
     /**
      * Class cleanup
      */
-    @AfterClass
+    @AfterAll
     public static void log4jClassCleanup() {
         Log4jTestUtils.testClassCleanup();
     }
@@ -80,7 +80,7 @@ public class Log4jLegacyApiIT {
     /**
      * Test setup
      */
-    @Before
+    @BeforeEach
     public void setup() {
         loggerA = Logger.getLogger(EVENT_NAME_A);
         agent = LTTngAgent.getLTTngAgent();
@@ -95,7 +95,7 @@ public class Log4jLegacyApiIT {
     /**
      * Test cleanup
      */
-    @After
+    @AfterEach
     public void tearDown() {
         session.close();
 
index 7c1effa054f09fd67daf547e8b24c5193c3ed436..241e47c843765fc00f4ae5187a600717e0382826 100644 (file)
@@ -23,10 +23,10 @@ import java.io.IOException;
 import org.apache.log4j.Appender;
 import org.apache.log4j.LogManager;
 import org.apache.log4j.Logger;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
+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.ust.agent.log4j.LttngLogAppender;
 import org.lttng.ust.agent.utils.Log4jTestUtils;
@@ -42,7 +42,7 @@ public class Log4jListEventsIT extends ListEventsITBase {
     /**
      * Class setup
      */
-    @BeforeClass
+    @BeforeAll
     public static void log4jClassSetup() {
         Log4jTestUtils.testClassSetup();
     }
@@ -50,7 +50,7 @@ public class Log4jListEventsIT extends ListEventsITBase {
     /**
      * Class cleanup
      */
-    @AfterClass
+    @AfterAll
     public static void log4jClassCleanup() {
         Log4jTestUtils.testClassCleanup();
     }
@@ -61,7 +61,7 @@ public class Log4jListEventsIT extends ListEventsITBase {
      * @throws SecurityException
      * @throws IOException
      */
-    @Before
+    @BeforeEach
     public void log4jSetup() throws SecurityException, IOException {
         /* Try clearing the log4j logger configuration */
         LogManager.resetConfiguration();
@@ -82,7 +82,7 @@ public class Log4jListEventsIT extends ListEventsITBase {
     /**
      * Test teardown. Detach and close all log handlers.
      */
-    @After
+    @AfterEach
     public void log4jTeardown() {
         for (Logger logger : loggers) {
             for (Appender appender : appenders) {
index dc654b0df696010334a85ac306d608b9e98621b6..5040506737cc6e6299580395615acc3e0d11141d 100644 (file)
@@ -23,10 +23,10 @@ import java.io.IOException;
 import org.apache.log4j.Appender;
 import org.apache.log4j.Level;
 import org.apache.log4j.Logger;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
+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.Domain;
 import org.lttng.ust.agent.log4j.LttngLogAppender;
 import org.lttng.ust.agent.utils.Log4jTestUtils;
@@ -46,7 +46,7 @@ public class Log4jMultiSessionIT extends MultiSessionITBase {
     /**
      * Class setup
      */
-    @BeforeClass
+    @BeforeAll
     public static void log4jClassSetup() {
         Log4jTestUtils.testClassSetup();
     }
@@ -54,7 +54,7 @@ public class Log4jMultiSessionIT extends MultiSessionITBase {
     /**
      * Class cleanup
      */
-    @AfterClass
+    @AfterAll
     public static void log4jClassCleanup() {
         Log4jTestUtils.testClassCleanup();
     }
@@ -65,7 +65,7 @@ public class Log4jMultiSessionIT extends MultiSessionITBase {
         * @throws SecurityException
         * @throws IOException
         */
-    @Before
+    @BeforeEach
     public void log4jSetup() throws SecurityException, IOException {
         // TODO Wipe all existing LTTng sessions?
 
@@ -93,7 +93,7 @@ public class Log4jMultiSessionIT extends MultiSessionITBase {
     /**
      * Test teardown
      */
-    @After
+    @AfterEach
     public void log4jTeardown() {
         loggerA.removeAppender((Appender) handlerA);
         loggerB.removeAppender((Appender) handlerB);
index abe591d30f90497a44d47828012cbbaa50e5f6f4..cc55f406cb0ce5b9df2cf0c595f2d3a55f12f4c1 100644 (file)
@@ -20,8 +20,8 @@ package org.lttng.ust.agent.integration.filter;
 
 import java.io.IOException;
 
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
 import org.lttng.tools.ILttngSession;
 import org.lttng.ust.agent.ILttngHandler;
 import org.lttng.ust.agent.log4j.LttngLogAppender;
@@ -38,7 +38,7 @@ public class Log4jFilterListenerIT extends FilterListenerITBase {
     /**
      * Class setup
      */
-    @BeforeClass
+    @BeforeAll
     public static void log4jClassSetup() {
         Log4jTestUtils.testClassSetup();
     }
@@ -46,7 +46,7 @@ public class Log4jFilterListenerIT extends FilterListenerITBase {
     /**
      * Class cleanup
      */
-    @AfterClass
+    @AfterAll
     public static void log4jClassCleanup() {
         Log4jTestUtils.testClassCleanup();
     }
index 5c700dbe92dcfb80cf974c2846e254758468a53e..5b3d1d4ca875e28cbb0ba0f211474bfd3a3ccc11 100644 (file)
 
 package org.lttng.ust.agent.integration.filter;
 
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.fail;
 
 import java.io.IOException;
 
 import org.apache.log4j.Appender;
 import org.apache.log4j.Level;
 import org.apache.log4j.Logger;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
 import org.lttng.tools.ILttngSession.Domain;
 import org.lttng.ust.agent.log4j.LttngLogAppender;
 import org.lttng.ust.agent.utils.Log4jTestUtils;
@@ -42,7 +42,7 @@ public class Log4jFilterListenerOrderingIT extends FilterListenerOrderingITBase
     /**
      * Class setup
      */
-    @BeforeClass
+    @BeforeAll
     public static void log4jClassSetup() {
         Log4jTestUtils.testClassSetup();
     }
@@ -50,7 +50,7 @@ public class Log4jFilterListenerOrderingIT extends FilterListenerOrderingITBase
     /**
      * Class cleanup
      */
-    @AfterClass
+    @AfterAll
     public static void log4jClassCleanup() {
         Log4jTestUtils.testClassCleanup();
     }
index a258e923111ad03a23eb9f7c60039adf625bb08f..fe8f0f2aae4ed784e3e665d1a83875d69a19415b 100644 (file)
@@ -18,8 +18,8 @@
 
 package org.lttng.ust.agent.utils;
 
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 import java.io.IOException;
 
@@ -43,7 +43,7 @@ public final class Log4jTestUtils {
     public static void testClassSetup() {
         /* Make sure we can find the JNI library and lttng-tools */
         checkForLog4jLibrary();
-        assertTrue("lttng-tools is not working properly.", LttngUtils.checkForLttngTools(Domain.LOG4J));
+        assertTrue(LttngUtils.checkForLttngTools(Domain.LOG4J), "lttng-tools is not working properly.");
 
         LttngToolsHelper.destroyAllSessions();
     }
index e6f72a77cbb5edb2160c2d2c0cfe1c3266de3c30..8f6300abf843f95f1f847d572e08612a7f86b8d2 100644 (file)
@@ -24,6 +24,6 @@
                        <attribute name="maven.pomderived" value="true"/>
                </attributes>
        </classpathentry>
-       <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
+       <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
        <classpathentry kind="output" path="target/classes"/>
 </classpath>
index 422ba8c7e17fe398044f8bb7e9d05899a6000b9d..1eb7d27c4ad2513e0117889fb0a2c03ca3431393 100644 (file)
@@ -59,8 +59,9 @@
       <artifactId>log4j-core</artifactId>
     </dependency>
     <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter</artifactId>
+      <scope>test</scope>
     </dependency>
   </dependencies>
 
index f285b8956d0272e758bed6f7d3e82c3c65b357c7..7a00b4b2fe91eec78cb596f6076ec3164bc40d55 100644 (file)
@@ -21,11 +21,10 @@ package org.lttng.ust.agent.integration.context;
 import java.io.IOException;
 
 import org.apache.logging.log4j.core.Logger;
-
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
+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.Domain;
 import org.lttng.ust.agent.ILttngHandler;
 import org.lttng.ust.agent.utils.Log4j2TestContext;
@@ -44,7 +43,7 @@ public class Log4j2AppContextIT extends AppContextITBase {
     /**
      * Class setup
      */
-    @BeforeClass
+    @BeforeAll
     public static void log4j2ClassSetup() {
         Log4j2TestUtils.testClassSetup();
     }
@@ -52,7 +51,7 @@ public class Log4j2AppContextIT extends AppContextITBase {
     /**
      * Class cleanup
      */
-    @AfterClass
+    @AfterAll
     public static void log4j2ClassCleanup() {
         Log4j2TestUtils.testClassCleanup();
     }
@@ -63,7 +62,8 @@ public class Log4j2AppContextIT extends AppContextITBase {
      * @throws SecurityException
      * @throws IOException
      */
-    @Before
+    @SuppressWarnings("resource")
+    @BeforeEach
     public void log4j2Setup() throws SecurityException, IOException {
         testContext = new Log4j2TestContext("log4j2.Log4j2AppContextIT.xml");
 
@@ -77,7 +77,7 @@ public class Log4j2AppContextIT extends AppContextITBase {
     /**
      * Test teardown
      */
-    @After
+    @AfterEach
     public void log4j2Teardown() {
         testContext.afterTest();
         logger = null;
index 9189f82a2fb4f3203a6424b04329c851ec6076dc..a015f13ec05990b2ec1120b4c1e1047f7ad9fa5c 100644 (file)
@@ -20,9 +20,9 @@ package org.lttng.ust.agent.integration.context;
 
 
 import org.apache.logging.log4j.core.Logger;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
 import org.lttng.tools.ILttngSession.Domain;
 import org.lttng.ust.agent.ILttngHandler;
 import org.lttng.ust.agent.utils.Log4j2TestContext;
@@ -39,7 +39,7 @@ public class Log4j2AppContextOrderingIT extends AppContextOrderingITBase {
     /**
      * Class setup
      */
-    @BeforeClass
+    @BeforeAll
     public static void log4j2ClassSetup() {
         Log4j2TestUtils.testClassSetup();
     }
@@ -47,7 +47,7 @@ public class Log4j2AppContextOrderingIT extends AppContextOrderingITBase {
     /**
      * Class cleanup
      */
-    @AfterClass
+    @AfterAll
     public static void log4j2ClassCleanup() {
         Log4j2TestUtils.testClassCleanup();
     }
@@ -55,7 +55,7 @@ public class Log4j2AppContextOrderingIT extends AppContextOrderingITBase {
     /**
      * Test teardown
      */
-    @After
+    @AfterEach
     public void log4j2Teardown() {
         logger = null;
         logHandler = null;
@@ -68,6 +68,7 @@ public class Log4j2AppContextOrderingIT extends AppContextOrderingITBase {
         return Domain.LOG4J;
     }
 
+    @SuppressWarnings("resource")
     @Override
     protected void registerAgent() {
         testContext = new Log4j2TestContext("log4j2.Log4j2AppContextOrderingIT.xml");
index bd5ad3e8781a386dcb858c3b9fed22266eab075b..1bbf4e46365c5bce69c4f09319c0ac788f4f2164 100644 (file)
 package org.lttng.ust.agent.integration.events;
 
 import java.io.IOException;
-import java.util.Map;
 
-import org.apache.logging.log4j.core.Appender;
 import org.apache.logging.log4j.core.Logger;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+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.junit.jupiter.api.Test;
 import org.lttng.tools.ILttngSession.Domain;
 import org.lttng.ust.agent.ILttngHandler;
-import org.lttng.ust.agent.log4j2.LttngLogAppender;
 import org.lttng.ust.agent.utils.Log4j2TestContext;
 import org.lttng.ust.agent.utils.Log4j2TestUtils;
 
@@ -55,7 +52,7 @@ public class Log4j2EnabledEventsIT extends EnabledEventsITBase {
     /**
      * Class setup
      */
-    @BeforeClass
+    @BeforeAll
     public static void log4j2ClassSetup() {
         Log4j2TestUtils.testClassSetup();
     }
@@ -63,7 +60,7 @@ public class Log4j2EnabledEventsIT extends EnabledEventsITBase {
     /**
      * Class cleanup
      */
-    @AfterClass
+    @AfterAll
     public static void log4j2ClassCleanup() {
         Log4j2TestUtils.testClassCleanup();
     }
@@ -75,7 +72,7 @@ public class Log4j2EnabledEventsIT extends EnabledEventsITBase {
      * @throws IOException
      */
     @SuppressWarnings("resource")
-    @Before
+    @BeforeEach
     public void log4j2Setup() throws SecurityException, IOException {
 
         testContext = new Log4j2TestContext("log4j2.Log4j2EnabledEventsIT.xml");
@@ -95,7 +92,7 @@ public class Log4j2EnabledEventsIT extends EnabledEventsITBase {
     /**
      * Test teardown
      */
-    @After
+    @AfterEach
     public void log4j2Teardown() {
         loggerA = null;
         loggerB = null;
index 92eedec4941504f945da4003e19c3bf88055a7b0..04676b62b28eb99cec5876376c04388c23821775 100644 (file)
 
 package org.lttng.ust.agent.integration.events;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 
 import org.apache.logging.log4j.Logger;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestName;
+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.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.lttng.tools.ILttngSession;
 import org.lttng.ust.agent.utils.Log4j2TestContext;
 import org.lttng.ust.agent.utils.Log4j2TestUtils;
+import org.lttng.ust.agent.utils.TestPrintExtension;
 
 /**
  * Test suite for the list events command for the log4j domain
  */
+@ExtendWith(TestPrintExtension.class)
 public class Log4j2ListEventsIT {
 
     protected static final String LOGGER_NAME_1 = "org.lttng.somecomponent";
     protected static final String LOGGER_NAME_2 = "org.lttng.mycomponent";
     protected static final String LOGGER_NAME_3 = "org.lttng.myothercomponent-àéç";
 
+    @SuppressWarnings("unused")
     private Logger logger1;
+    @SuppressWarnings("unused")
     private Logger logger2;
+    @SuppressWarnings("unused")
     private Logger logger3;
 
     private ILttngSession session;
     private Log4j2TestContext testContext;
 
-    @Rule
-    public TestName testName = new TestName();
-
     /**
      * Class setup
      */
-    @BeforeClass
+    @BeforeAll
     public static void log4j2ClassSetup() {
         Log4j2TestUtils.testClassSetup();
     }
@@ -67,19 +69,21 @@ public class Log4j2ListEventsIT {
     /**
      * Class cleanup
      */
-    @AfterClass
+    @AfterAll
     public static void log4j2ClassCleanup() {
         Log4j2TestUtils.testClassCleanup();
     }
 
     /**
      * Create a new session before each test.
+     * @param testInfo current test information
      */
-    @Before
-    public void testSetup() {
+    @SuppressWarnings("resource")
+    @BeforeEach
+    public void testSetup(TestInfo testInfo) {
         session = ILttngSession.createSession("Log4j2ListEventsIT", ILttngSession.Domain.LOG4J);
 
-        testContext = new Log4j2TestContext("log4j2." + testName.getMethodName() + ".xml");
+        testContext = new Log4j2TestContext("log4j2." + testInfo.getDisplayName().replaceAll("[()]", "") + ".xml");
 
         testContext.beforeTest();
 
@@ -91,7 +95,7 @@ public class Log4j2ListEventsIT {
     /**
      * Close the current session after each test.
      */
-    @After
+    @AfterEach
     public void testTeardown() {
         session.close();
         testContext.afterTest();
index e4b29c3d6a4290cbea380342bc3fbf7279f27f03..36eb43539344008cb551cd189ebc75bfc3a9b496 100644 (file)
@@ -21,10 +21,10 @@ package org.lttng.ust.agent.integration.events;
 import java.io.IOException;
 
 import org.apache.logging.log4j.core.Logger;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
+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.Domain;
 import org.lttng.ust.agent.ILttngHandler;
 import org.lttng.ust.agent.utils.Log4j2TestContext;
@@ -52,7 +52,7 @@ public class Log4j2MultiSessionIT extends MultiSessionITBase {
     /**
      * Class setup
      */
-    @BeforeClass
+    @BeforeAll
     public static void log4j2ClassSetup() {
         Log4j2TestUtils.testClassSetup();
     }
@@ -60,7 +60,7 @@ public class Log4j2MultiSessionIT extends MultiSessionITBase {
     /**
      * Class cleanup
      */
-    @AfterClass
+    @AfterAll
     public static void log4j2ClassCleanup() {
         Log4j2TestUtils.testClassCleanup();
     }
@@ -71,7 +71,8 @@ public class Log4j2MultiSessionIT extends MultiSessionITBase {
         * @throws SecurityException
         * @throws IOException
         */
-    @Before
+    @SuppressWarnings("resource")
+    @BeforeEach
     public void log4j2Setup() throws SecurityException, IOException {
 
         testContext = new Log4j2TestContext("log4j2.Log4j2MultiSessionIT.xml");
@@ -92,7 +93,7 @@ public class Log4j2MultiSessionIT extends MultiSessionITBase {
     /**
      * Test teardown
      */
-    @After
+    @AfterEach
     public void log4j2Teardown() {
         loggerA = null;
         loggerB = null;
index 057e8b0ea7ab606b2956c433b1ad036f9248eb31..7e2beb793d6e54a4acb7d26d6991c27cfc25c924 100644 (file)
@@ -20,8 +20,8 @@ package org.lttng.ust.agent.integration.filter;
 
 import java.io.IOException;
 
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
 import org.lttng.tools.ILttngSession;
 import org.lttng.ust.agent.ILttngHandler;
 import org.lttng.ust.agent.log4j2.LttngLogAppender;
@@ -38,7 +38,7 @@ public class Log4j2FilterListenerIT extends FilterListenerITBase {
     /**
      * Class setup
      */
-    @BeforeClass
+    @BeforeAll
     public static void log4j2ClassSetup() {
         Log4j2TestUtils.testClassSetup();
     }
@@ -46,7 +46,7 @@ public class Log4j2FilterListenerIT extends FilterListenerITBase {
     /**
      * Class cleanup
      */
-    @AfterClass
+    @AfterAll
     public static void log4j2ClassCleanup() {
         Log4j2TestUtils.testClassCleanup();
     }
index dae9a6bf046d0fd68ee2d6da24b84606cacfcaa7..03e8f9e12913bf656226a9c1e2963c2cc9b9e54d 100644 (file)
@@ -18,8 +18,8 @@
 
 package org.lttng.ust.agent.integration.filter;
 
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
 import org.lttng.tools.ILttngSession.Domain;
 import org.lttng.ust.agent.utils.Log4j2TestContext;
 import org.lttng.ust.agent.utils.Log4j2TestUtils;
@@ -34,7 +34,7 @@ public class Log4j2FilterListenerOrderingIT extends FilterListenerOrderingITBase
     /**
      * Class setup
      */
-    @BeforeClass
+    @BeforeAll
     public static void log4j2ClassSetup() {
         Log4j2TestUtils.testClassSetup();
     }
@@ -42,7 +42,7 @@ public class Log4j2FilterListenerOrderingIT extends FilterListenerOrderingITBase
     /**
      * Class cleanup
      */
-    @AfterClass
+    @AfterAll
     public static void log4j2ClassCleanup() {
         Log4j2TestUtils.testClassCleanup();
     }
index 96b26833fd34f686ce43c9aaee3928dff981342f..301ff701fa1a154725c856c0a3c55824aa6da148 100644 (file)
@@ -24,12 +24,18 @@ import java.net.URL;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.core.LoggerContext;
 
+/**
+ * Log4j 2.x test context utilities.
+ */
 public class Log4j2TestContext {
 
     private final URI configFileUri;
 
     private LoggerContext loggerContext;
 
+    /**
+     * @param configFile path to the log4j configuration file.
+     */
     public Log4j2TestContext(String configFile) {
 
         URL resource = getClass().getClassLoader().getResource(configFile);
@@ -45,15 +51,24 @@ public class Log4j2TestContext {
         }
     }
 
+    /**
+     * @return the log4j2 logger context.
+     */
     public synchronized LoggerContext getLoggerContext() {
         return loggerContext;
     }
 
+    /**
+     * Initialize the log4j2 context before running a test.
+     */
     public synchronized void beforeTest() {
         loggerContext = (LoggerContext) LogManager.getContext(
                 ClassLoader.getSystemClassLoader(), false, configFileUri);
     }
 
+    /**
+     * Dispose of the log4j2 context after running a test.
+     */
     public synchronized void afterTest() {
         loggerContext.stop();
     }
index 948e120f9fc729a2dea8ca3e1fc862567abca407..33eed8e2b8eaac92c8d81439fdee5b670786cdc5 100644 (file)
@@ -18,8 +18,8 @@
 
 package org.lttng.ust.agent.utils;
 
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 import java.io.IOException;
 
@@ -44,7 +44,7 @@ public final class Log4j2TestUtils {
     public static void testClassSetup() {
         /* Make sure we can find the JNI library and lttng-tools */
         checkForLog4jLibrary();
-        assertTrue("lttng-tools is not working properly.", LttngUtils.checkForLttngTools(Domain.LOG4J));
+        assertTrue(LttngUtils.checkForLttngTools(Domain.LOG4J), "lttng-tools is not working properly.");
 
         LttngToolsHelper.destroyAllSessions();
     }
diff --git a/pom.xml b/pom.xml
index e64a7b1b4937bfdc999cd767ca0d01f9f53b088d..68c634aa01d7324cf69620962a200522f10b9ac0 100644 (file)
--- a/pom.xml
+++ b/pom.xml
       </dependency>
 
       <dependency>
-        <groupId>junit</groupId>
-        <artifactId>junit</artifactId>
-        <version>4.13.2</version>
-        <scope>test</scope>
+        <groupId>org.junit</groupId>
+        <artifactId>junit-bom</artifactId>
+        <version>5.8.2</version>
+        <type>pom</type>
+        <scope>import</scope>
       </dependency>
 
       <!-- System dependencies, should have been installed by UST -->
This page took 0.111649 seconds and 4 git commands to generate.