X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=lttng-ust-java-tests-jul%2Fsrc%2Ftest%2Fjava%2Forg%2Flttng%2Fust%2Fagent%2Futils%2FJulTestUtils.java;h=af90383bd45a9599eebc3d01122ecab1e15c19e7;hb=eca27046b6f32c55dc7ceccb0821431c9be9f3af;hp=400881559400087d7eb1eb956452b19532caeb9e;hpb=88282100495351d3bbdc08743cf6fc6c311163bb;p=lttng-ust-java-tests.git diff --git a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/utils/JulTestUtils.java b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/utils/JulTestUtils.java index 4008815..af90383 100644 --- a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/utils/JulTestUtils.java +++ b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/utils/JulTestUtils.java @@ -18,10 +18,15 @@ package org.lttng.ust.agent.utils; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.io.IOException; import java.util.logging.Level; import java.util.logging.Logger; +import org.lttng.tools.LttngToolsHelper; +import org.lttng.tools.ILttngSession.Domain; import org.lttng.ust.agent.jul.LttngLogHandler; /** @@ -32,20 +37,35 @@ public final class JulTestUtils { private JulTestUtils() { } + /** + * Setup method common to most JUL tests. To be called in a @BeforeClass. + */ + 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)); + + LttngToolsHelper.destroyAllSessions(); + } + + /** + * Teardown method common to most JUL tests. To be called in a @AfterClass. + */ + public static void testClassCleanup() { + LttngToolsHelper.deleteAllTraces(); + } + /** * Check the the JUL native library is available, effectively allowing LTTng * JUL handlers to be used. - * - * @return True if JUL works fine, false if it does not. */ - public static boolean checkForJulLibrary() { + private static void checkForJulLibrary() { try { LttngLogHandler testHandler = new LttngLogHandler(); testHandler.close(); } catch (SecurityException | IOException e) { - return false; + fail(e.getMessage()); } - return true; } /**