X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=lttng-ust-java-tests-log4j%2Fsrc%2Ftest%2Fjava%2Forg%2Flttng%2Fust%2Fagent%2Futils%2FLog4jTestUtils.java;h=a258e923111ad03a23eb9f7c60039adf625bb08f;hb=eca27046b6f32c55dc7ceccb0821431c9be9f3af;hp=b356dbe21f295a74e9393665aedd81f5c9c81d18;hpb=88282100495351d3bbdc08743cf6fc6c311163bb;p=lttng-ust-java-tests.git diff --git a/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/utils/Log4jTestUtils.java b/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/utils/Log4jTestUtils.java index b356dbe..a258e92 100644 --- a/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/utils/Log4jTestUtils.java +++ b/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/utils/Log4jTestUtils.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 org.apache.log4j.Level; import org.apache.log4j.Logger; +import org.lttng.tools.LttngToolsHelper; +import org.lttng.tools.ILttngSession.Domain; import org.lttng.ust.agent.log4j.LttngLogAppender; /** @@ -32,21 +37,35 @@ public final class Log4jTestUtils { private Log4jTestUtils() { } + /** + * Setup method common to most log4j tests. To be called in a @BeforeClass. + */ + 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)); + + LttngToolsHelper.destroyAllSessions(); + } + + /** + * Teardown method common to most log4j tests. To be called in a @AfterClass. + */ + public static void testClassCleanup() { + LttngToolsHelper.deleteAllTraces(); + } + /** * Check the the Log4j native library is available, effectively allowing * LTTng Log4j appenders to be used. - * - * @return True if Log4j works fine, false if it does not. */ - public static boolean checkForLog4jLibrary() { + private static void checkForLog4jLibrary() { try { LttngLogAppender testAppender = new LttngLogAppender(); testAppender.close(); } catch (SecurityException | IOException e) { - e.printStackTrace(); - return false; + fail(e.getMessage()); } - return true; } /**