.map(e -> e.trim())
.filter(e -> e.startsWith("- "))
.map(e -> e.substring(2))
+ .filter(e -> !e.startsWith("org.junit"))
.collect(Collectors.toList());
}
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);
</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>
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";
/**
* Base test setup
*/
- @Before
+ @BeforeEach
public void testSetup() {
try {
cim = ContextInfoManager.getInstance();
/**
* Base test teardown
*/
- @After
+ @AfterEach
public void testTeardown() {
session.close();
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:
* 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";
/**
* Base test setup
*/
- @Before
+ @BeforeEach
public void testSetup() {
try {
cim = ContextInfoManager.getInstance();
/**
* Base test cleanup
*/
- @After
+ @AfterEach
public void testCleanup() {
session.close();
assertTrue(cim.unregisterContextInfoRetriever(RETRIEVER_NAME));
/**
* Base class cleanup
*/
- @AfterClass
+ @AfterAll
public static void julClassCleanup() {
LttngToolsHelper.deleteAllTraces();
}
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";
/**
* Base test setup
*/
- @Before
+ @BeforeEach
public void testSetup() {
session = ILttngSession.createSession(null, getDomain());
}
/**
* Base test teardown
*/
- @After
+ @AfterEach
public void testTeardown() {
session.close();
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";
/**
* Common test setup
*/
- @Before
+ @BeforeEach
public void testSetup() {
session = ILttngSession.createSession(null, getDomain());
}
/**
* Common test teardown
*/
- @After
+ @AfterEach
public void testTeardown() {
session.close();
}
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
*
* @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;
// ------------------------------------------------------------------------
* 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
* 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() {
/**
* Common test setup
*/
- @Before
+ @BeforeEach
public void testSetup() {
session = ILttngSession.createSession(null, getDomain());
}
/**
* Common test teardown
*/
- @After
+ @AfterEach
public void testTeardown() {
session.close();
}
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
/**
* 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<>();
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";
/**
* Base test setup
*/
- @Before
+ @BeforeEach
public void testSetup() {
session1 = ILttngSession.createSession(null, getDomain());
session2 = ILttngSession.createSession(null, getDomain());
/**
* Base test teardown
*/
- @After
+ @AfterEach
public void testTeardown() {
session1.close();
session2.close();
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;
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;
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";
* @throws SecurityException
* @throws IOException
*/
- @Before
+ @BeforeEach
public void setup() throws SecurityException, IOException {
handler = getLogHandler();
listener = new TestFilterListener();
/**
* Test teardown
*/
- @After
+ @AfterEach
public void teardown() {
session.close();
FilterChangeNotifier.getInstance().unregisterListener(listener);
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
* possibilities.
* </p>
*/
+@ExtendWith(TestPrintExtension.class)
@SuppressWarnings("javadoc")
public abstract class FilterListenerOrderingITBase {
/**
* Base class cleanup
*/
- @After
+ @AfterEach
public void baseTeardown() {
/*
* Deregister the listener (should always be done after all the other
--- /dev/null
+/*
+ * 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
+++ /dev/null
-/*
- * 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();
- }
- }
-
-}
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;
/**
* Test setup
*/
- @Before
+ @BeforeEach
public void testSetup() {
try {
mgr = ContextInfoManager.getInstance();
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;
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.
*
* @author Alexandre Montplaisir
*/
-@RunWith(TestPrintRunner.class)
+@ExtendWith(TestPrintExtension.class)
public class TcpClientIT {
// ------------------------------------------------------------------------
/**
* Class setup
*/
- @BeforeClass
+ @BeforeAll
public static void setupClass() {
LttngToolsHelper.destroyAllSessions();
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();
/**
* Test setup
*/
- @Before
+ @BeforeEach
public void setup() {
session = ILttngSession.createSession(null, SESSION_DOMAIN);
clientListener.clearAllCommands();
/**
* Test teardown
*/
- @After
+ @AfterEach
public void teardown() {
session.close();
}
<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>
<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>
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 {
// ------------------------------------------------------------------------
/**
* Base test setup
*/
- @Before
+ @BeforeEach
public void setup() {
/* Set up the logger */
logger = Logger.getLogger("Test logger");
/**
* Base test teardown
*/
- @After
+ @AfterEach
public void teardown() {
if (handler != null) {
logger.removeHandler(handler);
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;
/**
/**
* Test setup
*/
- @Before
+ @BeforeEach
public void testSetup() {
handler = new DummyHandler();
}
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;
/**
* @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);
* @throws IOException
* If we could not delete the test file
*/
- @After
+ @AfterEach
public void testTeardown() throws IOException {
Files.deleteIfExists(outputFile);
}
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;
/**
* Override the super class's setup() to avoid creating a Logger.
*/
@Override
- @Before
+ @BeforeEach
public void setup() {
logger = null;
handler = null;
* Override the super class's teardown()
*/
@Override
- @After
+ @AfterEach
public void teardown() {
}
}
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;
*
* @throws IOException
*/
- @Before
+ @BeforeEach
public void testSetup() throws IOException {
handler = new LttngLogHandler();
/**
* Test cleanup
*/
- @After
+ @AfterEach
public void testTeardown() {
assertTrue(session.stop());
session.close();
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;
*
* @throws IOException
*/
- @Before
+ @BeforeEach
public void testSetup() throws IOException {
handler = new LttngLogHandler();
/**
* Test cleanup
*/
- @After
+ @AfterEach
public void testTeardown() {
assertTrue(session.stop());
session.close();
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;
/**
* Test setup
*/
- @Before
+ @BeforeEach
public void testSetup() {
agent = LTTngAgent.getLTTngAgent();
/**
* Test cleanup
*/
- @After
+ @AfterEach
public void testTeardown() {
assertTrue(session.stop());
session.close();
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;
/**
* Test setup
*/
- @Before
+ @BeforeEach
public void testSetup() {
agent = LTTngAgent.getLTTngAgent();
/**
* Test cleanup
*/
- @After
+ @AfterEach
public void testTeardown() {
assertTrue(session.stop());
session.close();
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;
/**
* Class setup
*/
- @BeforeClass
+ @BeforeAll
public static void julClassSetup() {
JulTestUtils.testClassSetup();
}
/**
* Class cleanup
*/
- @AfterClass
+ @AfterAll
public static void julClassCleanup() {
JulTestUtils.testClassCleanup();
}
* @throws SecurityException
* @throws IOException
*/
- @Before
+ @BeforeEach
public void julSetup() throws SecurityException, IOException {
logger = Logger.getLogger(EVENT_NAME);
logger.setLevel(Level.ALL);
/**
* Test teardown
*/
- @After
+ @AfterEach
public void julTeardown() {
logger.removeHandler((Handler) logHandler);
logger = null;
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;
/**
* Class setup
*/
- @BeforeClass
+ @BeforeAll
public static void julClassSetup() {
JulTestUtils.testClassSetup();
}
/**
* Class cleanup
*/
- @AfterClass
+ @AfterAll
public static void julClassCleanup() {
JulTestUtils.testClassCleanup();
}
/**
* Test teardown
*/
- @After
+ @AfterEach
public void julTeardown() {
logger.removeHandler((Handler) logHandler);
logger = null;
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;
/**
* Class setup
*/
- @BeforeClass
+ @BeforeAll
public static void julClassSetup() {
JulTestUtils.testClassSetup();
}
/**
* Class cleanup
*/
- @AfterClass
+ @AfterAll
public static void julClassCleanup() {
JulTestUtils.testClassCleanup();
}
* @throws SecurityException
* @throws IOException
*/
- @Before
+ @BeforeEach
public void julSetup() throws SecurityException, IOException {
loggerA = Logger.getLogger(EVENT_NAME_A);
loggerB = Logger.getLogger(EVENT_NAME_B);
/**
* Test teardown
*/
- @After
+ @AfterEach
public void julTeardown() {
loggerA.removeHandler((Handler) handlerA);
loggerB.removeHandler((Handler) handlerB);
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;
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 {
/**
* Class setup
*/
- @BeforeClass
+ @BeforeAll
public static void julClassSetup() {
JulTestUtils.testClassSetup();
}
/**
* Class cleanup
*/
- @AfterClass
+ @AfterAll
public static void julClassCleanup() {
JulTestUtils.testClassCleanup();
}
/**
* Test setup
*/
- @Before
+ @BeforeEach
public void setup() {
/* Clear the JUL logger configuration */
LogManager.getLogManager().reset();
/**
* Test cleanup
*/
- @After
+ @AfterEach
public void tearDown() {
session.close();
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.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;
* @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
// ------------------------------------------------------------------------
/**
* Class setup
*/
- @BeforeClass
+ @BeforeAll
public static void julClassSetup() {
JulTestUtils.testClassSetup();
}
/**
* Class cleanup
*/
- @AfterClass
+ @AfterAll
public static void julClassCleanup() {
JulTestUtils.testClassCleanup();
}
* Test setup
*/
@SuppressWarnings("static-method")
- @Before
+ @BeforeEach
public void setup() {
LogManager.getLogManager().reset();
System.gc();
/**
* Test cleanup
*/
- @After
+ @AfterEach
public void cleanup() {
agent.dispose();
}
@Override
- protected void activateLoggers() throws IOException {
+ protected void activateLoggers(boolean parentLoggerActive,
+ boolean parentLoggerHasHandler,
+ boolean childLoggerActive,
+ boolean childLoggerHasHandler) throws IOException {
agent = LTTngAgent.getLTTngAgent();
/*
* 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<>();
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;
/**
* Class setup
*/
- @BeforeClass
+ @BeforeAll
public static void julClassSetup() {
JulTestUtils.testClassSetup();
}
/**
* Class cleanup
*/
- @AfterClass
+ @AfterAll
public static void julClassCleanup() {
JulTestUtils.testClassCleanup();
}
* @throws SecurityException
* @throws IOException
*/
- @Before
+ @BeforeEach
public void julSetup() throws SecurityException, IOException {
/* Clear the JUL logger configuration */
LogManager.getLogManager().reset();
/**
* Test teardown. Detach and close all log handlers.
*/
- @After
+ @AfterEach
public void julTeardown() {
for (Logger logger : loggers) {
for (Handler handler : handlers) {
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;
*
* @author Alexandre Montplaisir
*/
-@RunWith(Parameterized.class)
public class JulLoggerHierarchyListIT extends LoggerHierachyListITBase {
private Logger parentLogger;
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
// ------------------------------------------------------------------------
/**
* Class setup
*/
- @BeforeClass
+ @BeforeAll
public static void julClassSetup() {
JulTestUtils.testClassSetup();
}
/**
* Class cleanup
*/
- @AfterClass
+ @AfterAll
public static void julClassCleanup() {
JulTestUtils.testClassCleanup();
}
* Test setup
*/
@SuppressWarnings("static-method")
- @Before
+ @BeforeEach
public void setup() {
/*
* Kind of hackish, but it's the only way to ensure that loggers are
/**
* Test cleanup
*/
- @After
+ @AfterEach
public void cleanup() {
if (parentLogger != null) {
if (parentHandler != null) {
}
@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) {
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;
/**
* Class setup
*/
- @BeforeClass
+ @BeforeAll
public static void julClassSetup() {
JulTestUtils.testClassSetup();
}
/**
* Class cleanup
*/
- @AfterClass
+ @AfterAll
public static void julClassCleanup() {
JulTestUtils.testClassCleanup();
}
* @throws SecurityException
* @throws IOException
*/
- @Before
+ @BeforeEach
public void julSetup() throws SecurityException, IOException {
loggerA = Logger.getLogger(EVENT_NAME_A);
loggerB = Logger.getLogger(EVENT_NAME_B);
/**
* Test teardown
*/
- @After
+ @AfterEach
public void julTeardown() {
loggerA.removeHandler((Handler) handlerA);
loggerB.removeHandler((Handler) handlerB);
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;
/**
* Class setup
*/
- @BeforeClass
+ @BeforeAll
public static void julClassSetup() {
JulTestUtils.testClassSetup();
}
/**
* Class cleanup
*/
- @AfterClass
+ @AfterAll
public static void julClassCleanup() {
JulTestUtils.testClassCleanup();
}
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;
/**
* Class setup
*/
- @BeforeClass
+ @BeforeAll
public static void julClassSetup() {
JulTestUtils.testClassSetup();
}
/**
* Class cleanup
*/
- @AfterClass
+ @AfterAll
public static void julClassCleanup() {
JulTestUtils.testClassCleanup();
}
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;
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();
}
<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>
<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>
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;
/**
* Class setup
*/
- @BeforeClass
+ @BeforeAll
public static void log4jClassSetup() {
Log4jTestUtils.testClassSetup();
}
/**
* Class cleanup
*/
- @AfterClass
+ @AfterAll
public static void log4jClassCleanup() {
Log4jTestUtils.testClassCleanup();
}
* @throws SecurityException
* @throws IOException
*/
- @Before
+ @BeforeEach
public void julSetup() throws SecurityException, IOException {
logger = Logger.getLogger(EVENT_NAME);
logger.setLevel(Level.ALL);
/**
* Test teardown
*/
- @After
+ @AfterEach
public void julTeardown() {
logger.removeAppender((Appender) logHandler);
logger = null;
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;
/**
* Class setup
*/
- @BeforeClass
+ @BeforeAll
public static void log4jClassSetup() {
Log4jTestUtils.testClassSetup();
}
/**
* Class cleanup
*/
- @AfterClass
+ @AfterAll
public static void log4jClassCleanup() {
Log4jTestUtils.testClassCleanup();
}
/**
* Test teardown
*/
- @After
+ @AfterEach
public void log4jTeardown() {
logger.removeAppender((Appender) logHandler);
logger = null;
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;
/**
* Class setup
*/
- @BeforeClass
+ @BeforeAll
public static void log4jClassSetup() {
Log4jTestUtils.testClassSetup();
}
/**
* Class cleanup
*/
- @AfterClass
+ @AfterAll
public static void log4jClassCleanup() {
Log4jTestUtils.testClassCleanup();
}
* @throws SecurityException
* @throws IOException
*/
- @Before
+ @BeforeEach
public void log4jSetup() throws SecurityException, IOException {
loggerA = Logger.getLogger(EVENT_NAME_A);
loggerB = Logger.getLogger(EVENT_NAME_B);
/**
* Test teardown
*/
- @After
+ @AfterEach
public void log4jTeardown() {
loggerA.removeAppender((Appender) handlerA);
loggerB.removeAppender((Appender) handlerB);
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;
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 {
/**
* Class setup
*/
- @BeforeClass
+ @BeforeAll
public static void log4jClassSetup() {
Log4jTestUtils.testClassSetup();
}
/**
* Class cleanup
*/
- @AfterClass
+ @AfterAll
public static void log4jClassCleanup() {
Log4jTestUtils.testClassCleanup();
}
/**
* Test setup
*/
- @Before
+ @BeforeEach
public void setup() {
loggerA = Logger.getLogger(EVENT_NAME_A);
agent = LTTngAgent.getLTTngAgent();
/**
* Test cleanup
*/
- @After
+ @AfterEach
public void tearDown() {
session.close();
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;
/**
* Class setup
*/
- @BeforeClass
+ @BeforeAll
public static void log4jClassSetup() {
Log4jTestUtils.testClassSetup();
}
/**
* Class cleanup
*/
- @AfterClass
+ @AfterAll
public static void log4jClassCleanup() {
Log4jTestUtils.testClassCleanup();
}
* @throws SecurityException
* @throws IOException
*/
- @Before
+ @BeforeEach
public void log4jSetup() throws SecurityException, IOException {
/* Try clearing the log4j logger configuration */
LogManager.resetConfiguration();
/**
* Test teardown. Detach and close all log handlers.
*/
- @After
+ @AfterEach
public void log4jTeardown() {
for (Logger logger : loggers) {
for (Appender appender : appenders) {
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;
/**
* Class setup
*/
- @BeforeClass
+ @BeforeAll
public static void log4jClassSetup() {
Log4jTestUtils.testClassSetup();
}
/**
* Class cleanup
*/
- @AfterClass
+ @AfterAll
public static void log4jClassCleanup() {
Log4jTestUtils.testClassCleanup();
}
* @throws SecurityException
* @throws IOException
*/
- @Before
+ @BeforeEach
public void log4jSetup() throws SecurityException, IOException {
// TODO Wipe all existing LTTng sessions?
/**
* Test teardown
*/
- @After
+ @AfterEach
public void log4jTeardown() {
loggerA.removeAppender((Appender) handlerA);
loggerB.removeAppender((Appender) handlerB);
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;
/**
* Class setup
*/
- @BeforeClass
+ @BeforeAll
public static void log4jClassSetup() {
Log4jTestUtils.testClassSetup();
}
/**
* Class cleanup
*/
- @AfterClass
+ @AfterAll
public static void log4jClassCleanup() {
Log4jTestUtils.testClassCleanup();
}
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;
/**
* Class setup
*/
- @BeforeClass
+ @BeforeAll
public static void log4jClassSetup() {
Log4jTestUtils.testClassSetup();
}
/**
* Class cleanup
*/
- @AfterClass
+ @AfterAll
public static void log4jClassCleanup() {
Log4jTestUtils.testClassCleanup();
}
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;
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();
}
<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>
<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>
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;
/**
* Class setup
*/
- @BeforeClass
+ @BeforeAll
public static void log4j2ClassSetup() {
Log4j2TestUtils.testClassSetup();
}
/**
* Class cleanup
*/
- @AfterClass
+ @AfterAll
public static void log4j2ClassCleanup() {
Log4j2TestUtils.testClassCleanup();
}
* @throws SecurityException
* @throws IOException
*/
- @Before
+ @SuppressWarnings("resource")
+ @BeforeEach
public void log4j2Setup() throws SecurityException, IOException {
testContext = new Log4j2TestContext("log4j2.Log4j2AppContextIT.xml");
/**
* Test teardown
*/
- @After
+ @AfterEach
public void log4j2Teardown() {
testContext.afterTest();
logger = null;
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;
/**
* Class setup
*/
- @BeforeClass
+ @BeforeAll
public static void log4j2ClassSetup() {
Log4j2TestUtils.testClassSetup();
}
/**
* Class cleanup
*/
- @AfterClass
+ @AfterAll
public static void log4j2ClassCleanup() {
Log4j2TestUtils.testClassCleanup();
}
/**
* Test teardown
*/
- @After
+ @AfterEach
public void log4j2Teardown() {
logger = null;
logHandler = null;
return Domain.LOG4J;
}
+ @SuppressWarnings("resource")
@Override
protected void registerAgent() {
testContext = new Log4j2TestContext("log4j2.Log4j2AppContextOrderingIT.xml");
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;
/**
* Class setup
*/
- @BeforeClass
+ @BeforeAll
public static void log4j2ClassSetup() {
Log4j2TestUtils.testClassSetup();
}
/**
* Class cleanup
*/
- @AfterClass
+ @AfterAll
public static void log4j2ClassCleanup() {
Log4j2TestUtils.testClassCleanup();
}
* @throws IOException
*/
@SuppressWarnings("resource")
- @Before
+ @BeforeEach
public void log4j2Setup() throws SecurityException, IOException {
testContext = new Log4j2TestContext("log4j2.Log4j2EnabledEventsIT.xml");
/**
* Test teardown
*/
- @After
+ @AfterEach
public void log4j2Teardown() {
loggerA = null;
loggerB = null;
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();
}
/**
* 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();
/**
* Close the current session after each test.
*/
- @After
+ @AfterEach
public void testTeardown() {
session.close();
testContext.afterTest();
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;
/**
* Class setup
*/
- @BeforeClass
+ @BeforeAll
public static void log4j2ClassSetup() {
Log4j2TestUtils.testClassSetup();
}
/**
* Class cleanup
*/
- @AfterClass
+ @AfterAll
public static void log4j2ClassCleanup() {
Log4j2TestUtils.testClassCleanup();
}
* @throws SecurityException
* @throws IOException
*/
- @Before
+ @SuppressWarnings("resource")
+ @BeforeEach
public void log4j2Setup() throws SecurityException, IOException {
testContext = new Log4j2TestContext("log4j2.Log4j2MultiSessionIT.xml");
/**
* Test teardown
*/
- @After
+ @AfterEach
public void log4j2Teardown() {
loggerA = null;
loggerB = null;
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;
/**
* Class setup
*/
- @BeforeClass
+ @BeforeAll
public static void log4j2ClassSetup() {
Log4j2TestUtils.testClassSetup();
}
/**
* Class cleanup
*/
- @AfterClass
+ @AfterAll
public static void log4j2ClassCleanup() {
Log4j2TestUtils.testClassCleanup();
}
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;
/**
* Class setup
*/
- @BeforeClass
+ @BeforeAll
public static void log4j2ClassSetup() {
Log4j2TestUtils.testClassSetup();
}
/**
* Class cleanup
*/
- @AfterClass
+ @AfterAll
public static void log4j2ClassCleanup() {
Log4j2TestUtils.testClassCleanup();
}
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);
}
}
+ /**
+ * @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();
}
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;
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();
}
</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 -->