package org.lttng.ust.agent.integration.context;
-import static org.junit.Assert.assertTrue;
-
import java.io.IOException;
import java.util.logging.Handler;
import java.util.logging.Level;
import org.junit.Before;
import org.junit.BeforeClass;
import org.lttng.tools.ILttngSession.Domain;
-import org.lttng.tools.LttngToolsHelper;
import org.lttng.ust.agent.jul.LttngLogHandler;
import org.lttng.ust.agent.utils.JulTestUtils;
-import org.lttng.ust.agent.utils.LttngUtils;
/**
* Enabled app contexts test for the LTTng-UST JUL log handler.
*/
@BeforeClass
public static void julClassSetup() {
- /* Make sure we can find the JNI library and lttng-tools */
- assertTrue(JulTestUtils.checkForJulLibrary());
- assertTrue(LttngUtils.checkForLttngTools(Domain.JUL));
-
- LttngToolsHelper.destroyAllSessions();
+ JulTestUtils.testClassSetup();
}
/**
*/
@AfterClass
public static void julClassCleanup() {
- LttngToolsHelper.deleteAllTraces();
+ JulTestUtils.testClassCleanup();
}
/**
package org.lttng.ust.agent.integration.context;
-import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.IOException;
import java.util.logging.Logger;
import org.junit.After;
+import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.lttng.tools.ILttngSession.Domain;
-import org.lttng.tools.LttngToolsHelper;
import org.lttng.ust.agent.jul.LttngLogHandler;
import org.lttng.ust.agent.utils.JulTestUtils;
-import org.lttng.ust.agent.utils.LttngUtils;
/**
* Implementation of {@link AppContextOrderingITBase} for the JUL API.
*/
@BeforeClass
public static void julClassSetup() {
- /* Make sure we can find the JNI library and lttng-tools */
- assertTrue(JulTestUtils.checkForJulLibrary());
- assertTrue(LttngUtils.checkForLttngTools(Domain.JUL));
+ JulTestUtils.testClassSetup();
+ }
- LttngToolsHelper.destroyAllSessions();
+ /**
+ * Class cleanup
+ */
+ @AfterClass
+ public static void julClassCleanup() {
+ JulTestUtils.testClassCleanup();
}
/**
package org.lttng.ust.agent.integration.events;
-import static org.junit.Assert.assertTrue;
-
import java.io.IOException;
import java.util.logging.Handler;
import java.util.logging.Level;
import org.junit.Before;
import org.junit.BeforeClass;
import org.lttng.tools.ILttngSession.Domain;
-import org.lttng.tools.LttngToolsHelper;
import org.lttng.ust.agent.jul.LttngLogHandler;
import org.lttng.ust.agent.utils.JulTestUtils;
-import org.lttng.ust.agent.utils.LttngUtils;
/**
* Enabled events test for the LTTng-UST JUL log handler.
*/
@BeforeClass
public static void julClassSetup() {
- /* Make sure we can find the JNI library and lttng-tools */
- assertTrue(JulTestUtils.checkForJulLibrary());
- assertTrue(LttngUtils.checkForLttngTools(Domain.JUL));
-
- LttngToolsHelper.destroyAllSessions();
+ JulTestUtils.testClassSetup();
}
/**
*/
@AfterClass
public static void julClassCleanup() {
- LttngToolsHelper.deleteAllTraces();
+ JulTestUtils.testClassCleanup();
}
/**
import org.junit.runner.RunWith;
import org.lttng.tools.ILttngSession;
import org.lttng.tools.ILttngSession.Domain;
-import org.lttng.tools.LttngToolsHelper;
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.LttngUtils;
import org.lttng.ust.agent.utils.TestPrintRunner;
/**
*/
@BeforeClass
public static void julClassSetup() {
- /* Make sure we can find the JNI library and lttng-tools */
- assertTrue(JulTestUtils.checkForJulLibrary());
- assertTrue(LttngUtils.checkForLttngTools(Domain.JUL));
-
- LttngToolsHelper.destroyAllSessions();
+ JulTestUtils.testClassSetup();
}
/**
*/
@AfterClass
public static void julClassCleanup() {
- LttngToolsHelper.deleteAllTraces();
+ JulTestUtils.testClassCleanup();
}
/**
package org.lttng.ust.agent.integration.events;
-import static org.junit.Assert.assertTrue;
-
import java.io.IOException;
import java.util.logging.Handler;
import java.util.logging.Logger;
import org.junit.After;
+import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
-import org.lttng.tools.ILttngSession.Domain;
import org.lttng.tools.ILttngSession;
-import org.lttng.tools.LttngToolsHelper;
-import org.lttng.ust.agent.integration.events.ListEventsITBase;
import org.lttng.ust.agent.jul.LttngLogHandler;
import org.lttng.ust.agent.utils.JulTestUtils;
-import org.lttng.ust.agent.utils.LttngUtils;
/**
* Test suite for the list events command for the JUL domain
private Handler[] handlers;
/**
- * Test class setup
+ * Class setup
*/
@BeforeClass
- public static void testClassSetup() {
- /* Make sure we can find the JNI library and lttng-tools */
- assertTrue(JulTestUtils.checkForJulLibrary());
- assertTrue(LttngUtils.checkForLttngTools(Domain.JUL));
+ public static void julClassSetup() {
+ JulTestUtils.testClassSetup();
+ }
- LttngToolsHelper.destroyAllSessions();
+ /**
+ * Class cleanup
+ */
+ @AfterClass
+ public static void julClassCleanup() {
+ JulTestUtils.testClassCleanup();
}
/**
package org.lttng.ust.agent.integration.events;
-import static org.junit.Assert.assertTrue;
-
import java.io.IOException;
import java.util.logging.Handler;
import java.util.logging.Level;
import org.junit.Before;
import org.junit.BeforeClass;
import org.lttng.tools.ILttngSession.Domain;
-import org.lttng.tools.LttngToolsHelper;
-import org.lttng.ust.agent.integration.events.MultiSessionITBase;
import org.lttng.ust.agent.jul.LttngLogHandler;
import org.lttng.ust.agent.utils.JulTestUtils;
-import org.lttng.ust.agent.utils.LttngUtils;
/**
* JUL tests for multiple concurrent tracing sessions
*/
@BeforeClass
public static void julClassSetup() {
- /* Make sure we can find the JNI library and lttng-tools */
- assertTrue(JulTestUtils.checkForJulLibrary());
- assertTrue(LttngUtils.checkForLttngTools(Domain.JUL));
-
- LttngToolsHelper.destroyAllSessions();
+ JulTestUtils.testClassSetup();
}
/**
*/
@AfterClass
public static void julClassCleanup() {
- LttngToolsHelper.deleteAllTraces();
+ JulTestUtils.testClassCleanup();
}
/**
package org.lttng.ust.agent.integration.filter;
-import static org.junit.Assert.assertTrue;
-
import java.io.IOException;
+import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.lttng.tools.ILttngSession;
-import org.lttng.tools.LttngToolsHelper;
import org.lttng.ust.agent.ILttngHandler;
import org.lttng.ust.agent.jul.LttngLogHandler;
import org.lttng.ust.agent.utils.ILogLevelStrings;
import org.lttng.ust.agent.utils.JulTestUtils;
-import org.lttng.ust.agent.utils.LttngUtils;
/**
* Filter notifications tests using the JUL logging API.
*/
@BeforeClass
public static void julClassSetup() {
- /* Make sure we can find the JNI library and lttng-tools */
- assertTrue(JulTestUtils.checkForJulLibrary());
- assertTrue(LttngUtils.checkForLttngTools(ILttngSession.Domain.JUL));
- LttngToolsHelper.destroyAllSessions();
+ JulTestUtils.testClassSetup();
+ }
+
+ /**
+ * Class cleanup
+ */
+ @AfterClass
+ public static void julClassCleanup() {
+ JulTestUtils.testClassCleanup();
}
@Override
package org.lttng.ust.agent.integration.filter;
-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.junit.AfterClass;
import org.junit.BeforeClass;
import org.lttng.tools.ILttngSession.Domain;
-import org.lttng.tools.LttngToolsHelper;
import org.lttng.ust.agent.jul.LttngLogHandler;
import org.lttng.ust.agent.utils.JulTestUtils;
-import org.lttng.ust.agent.utils.LttngUtils;
/**
* Implementation of {@link FilterListenerOrderingITBase} for the JUL API.
*/
@BeforeClass
public static void julClassSetup() {
- /* Make sure we can find the JNI library and lttng-tools */
- assertTrue(JulTestUtils.checkForJulLibrary());
- assertTrue(LttngUtils.checkForLttngTools(Domain.JUL));
+ JulTestUtils.testClassSetup();
+ }
- LttngToolsHelper.destroyAllSessions();
+ /**
+ * Class cleanup
+ */
+ @AfterClass
+ public static void julClassCleanup() {
+ JulTestUtils.testClassCleanup();
}
@Override
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;
/**
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;
}
/**
package org.lttng.ust.agent.integration.context;
-import static org.junit.Assert.assertTrue;
-
import java.io.IOException;
import org.apache.log4j.Appender;
import org.junit.Before;
import org.junit.BeforeClass;
import org.lttng.tools.ILttngSession.Domain;
-import org.lttng.tools.LttngToolsHelper;
import org.lttng.ust.agent.log4j.LttngLogAppender;
import org.lttng.ust.agent.utils.Log4jTestUtils;
-import org.lttng.ust.agent.utils.LttngUtils;
/**
* Enabled app contexts test for the LTTng-UST JUL log handler.
* Class setup
*/
@BeforeClass
- public static void julClassSetup() {
- /* Make sure we can find the JNI library and lttng-tools */
- assertTrue(Log4jTestUtils.checkForLog4jLibrary());
- assertTrue(LttngUtils.checkForLttngTools(Domain.LOG4J));
-
- LttngToolsHelper.destroyAllSessions();
+ public static void log4jClassSetup() {
+ Log4jTestUtils.testClassSetup();
}
/**
* Class cleanup
*/
@AfterClass
- public static void julClassCleanup() {
- LttngToolsHelper.deleteAllTraces();
+ public static void log4jClassCleanup() {
+ Log4jTestUtils.testClassCleanup();
}
/**
package org.lttng.ust.agent.integration.context;
-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.junit.After;
+import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.lttng.tools.ILttngSession.Domain;
-import org.lttng.tools.LttngToolsHelper;
import org.lttng.ust.agent.log4j.LttngLogAppender;
import org.lttng.ust.agent.utils.Log4jTestUtils;
-import org.lttng.ust.agent.utils.LttngUtils;
/**
* Implementation of {@link AppContextOrderingITBase} for the log4j API.
*/
@BeforeClass
public static void log4jClassSetup() {
- /* Make sure we can find the JNI library and lttng-tools */
- assertTrue(Log4jTestUtils.checkForLog4jLibrary());
- assertTrue(LttngUtils.checkForLttngTools(Domain.LOG4J));
+ Log4jTestUtils.testClassSetup();
+ }
- LttngToolsHelper.destroyAllSessions();
+ /**
+ * Class cleanup
+ */
+ @AfterClass
+ public static void log4jClassCleanup() {
+ Log4jTestUtils.testClassCleanup();
}
/**
package org.lttng.ust.agent.integration.events;
-import static org.junit.Assert.assertTrue;
-
import java.io.IOException;
import org.apache.log4j.Appender;
import org.junit.BeforeClass;
import org.junit.Test;
import org.lttng.tools.ILttngSession.Domain;
-import org.lttng.tools.LttngToolsHelper;
import org.lttng.ust.agent.log4j.LttngLogAppender;
import org.lttng.ust.agent.utils.Log4jTestUtils;
-import org.lttng.ust.agent.utils.LttngUtils;
/**
* Enabled events test for the LTTng-UST Log4j log handler.
*/
@BeforeClass
public static void log4jClassSetup() {
- /* Make sure we can find the JNI library and lttng-tools */
- assertTrue(Log4jTestUtils.checkForLog4jLibrary());
- assertTrue(LttngUtils.checkForLttngTools(Domain.LOG4J));
-
- LttngToolsHelper.destroyAllSessions();
+ Log4jTestUtils.testClassSetup();
}
/**
- * Class teardown
+ * Class cleanup
*/
@AfterClass
public static void log4jClassCleanup() {
- LttngToolsHelper.deleteAllTraces();
+ Log4jTestUtils.testClassCleanup();
}
/**
import org.junit.runner.RunWith;
import org.lttng.tools.ILttngSession;
import org.lttng.tools.ILttngSession.Domain;
-import org.lttng.tools.LttngToolsHelper;
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.LttngUtils;
import org.lttng.ust.agent.utils.TestPrintRunner;
/**
* Class setup
*/
@BeforeClass
- public static void classSetup() {
- /* Make sure we can find the JNI library and lttng-tools */
- assertTrue(Log4jTestUtils.checkForLog4jLibrary());
- assertTrue(LttngUtils.checkForLttngTools(Domain.LOG4J));
-
- LttngToolsHelper.destroyAllSessions();
+ public static void log4jClassSetup() {
+ Log4jTestUtils.testClassSetup();
}
/**
* Class cleanup
*/
@AfterClass
- public static void classCleanup() {
- LttngToolsHelper.deleteAllTraces();
+ public static void log4jClassCleanup() {
+ Log4jTestUtils.testClassCleanup();
}
/**
package org.lttng.ust.agent.integration.events;
-import static org.junit.Assert.assertTrue;
-
import java.io.IOException;
import org.apache.log4j.Appender;
import org.apache.log4j.Logger;
import org.junit.After;
+import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
-import org.lttng.tools.ILttngSession.Domain;
import org.lttng.tools.ILttngSession;
-import org.lttng.tools.LttngToolsHelper;
-import org.lttng.ust.agent.integration.events.ListEventsITBase;
import org.lttng.ust.agent.log4j.LttngLogAppender;
import org.lttng.ust.agent.utils.Log4jTestUtils;
-import org.lttng.ust.agent.utils.LttngUtils;
/**
* Test suite for the list events command for the log4j domain
private Appender[] appenders;
/**
- * Test class setup
+ * Class setup
*/
@BeforeClass
- public static void testClassSetup() {
- /* Make sure we can find the JNI library and lttng-tools */
- assertTrue(Log4jTestUtils.checkForLog4jLibrary());
- assertTrue(LttngUtils.checkForLttngTools(Domain.LOG4J));
+ public static void log4jClassSetup() {
+ Log4jTestUtils.testClassSetup();
+ }
- LttngToolsHelper.destroyAllSessions();
+ /**
+ * Class cleanup
+ */
+ @AfterClass
+ public static void log4jClassCleanup() {
+ Log4jTestUtils.testClassCleanup();
}
/**
package org.lttng.ust.agent.integration.events;
-import static org.junit.Assert.assertTrue;
-
import java.io.IOException;
import org.apache.log4j.Appender;
import org.junit.Before;
import org.junit.BeforeClass;
import org.lttng.tools.ILttngSession.Domain;
-import org.lttng.tools.LttngToolsHelper;
-import org.lttng.ust.agent.integration.events.MultiSessionITBase;
import org.lttng.ust.agent.log4j.LttngLogAppender;
import org.lttng.ust.agent.utils.Log4jTestUtils;
-import org.lttng.ust.agent.utils.LttngUtils;
/**
* Log4j tests for multiple concurrent tracing sessions
*/
@BeforeClass
public static void log4jClassSetup() {
- /* Make sure we can find the JNI library and lttng-tools */
- assertTrue(Log4jTestUtils.checkForLog4jLibrary());
- assertTrue(LttngUtils.checkForLttngTools(Domain.LOG4J));
-
- LttngToolsHelper.destroyAllSessions();
+ Log4jTestUtils.testClassSetup();
}
/**
- * Class teardown
+ * Class cleanup
*/
@AfterClass
public static void log4jClassCleanup() {
- LttngToolsHelper.deleteAllTraces();
+ Log4jTestUtils.testClassCleanup();
}
/**
package org.lttng.ust.agent.integration.filter;
-import static org.junit.Assert.assertTrue;
-
import java.io.IOException;
+import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.lttng.tools.ILttngSession;
-import org.lttng.tools.LttngToolsHelper;
import org.lttng.ust.agent.ILttngHandler;
import org.lttng.ust.agent.log4j.LttngLogAppender;
import org.lttng.ust.agent.utils.ILogLevelStrings;
import org.lttng.ust.agent.utils.Log4jTestUtils;
-import org.lttng.ust.agent.utils.LttngUtils;
/**
* Filter notifications tests using the log4j logging API.
*/
@BeforeClass
public static void log4jClassSetup() {
- /* Make sure we can find the JNI library and lttng-tools */
- assertTrue(Log4jTestUtils.checkForLog4jLibrary());
- assertTrue(LttngUtils.checkForLttngTools(ILttngSession.Domain.LOG4J));
- LttngToolsHelper.destroyAllSessions();
+ Log4jTestUtils.testClassSetup();
+ }
+
+ /**
+ * Class cleanup
+ */
+ @AfterClass
+ public static void log4jClassCleanup() {
+ Log4jTestUtils.testClassCleanup();
}
@Override
package org.lttng.ust.agent.integration.filter;
-import static org.junit.Assert.assertTrue;
import static org.junit.Assert.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.lttng.tools.ILttngSession.Domain;
-import org.lttng.tools.LttngToolsHelper;
import org.lttng.ust.agent.log4j.LttngLogAppender;
import org.lttng.ust.agent.utils.Log4jTestUtils;
-import org.lttng.ust.agent.utils.LttngUtils;
/**
* Implementation of {@link FilterListenerOrderingITBase} for the log4j API.
* Class setup
*/
@BeforeClass
- public static void julClassSetup() {
- /* Make sure we can find the JNI library and lttng-tools */
- assertTrue(Log4jTestUtils.checkForLog4jLibrary());
- assertTrue(LttngUtils.checkForLttngTools(Domain.LOG4J));
+ public static void log4jClassSetup() {
+ Log4jTestUtils.testClassSetup();
+ }
- LttngToolsHelper.destroyAllSessions();
+ /**
+ * Class cleanup
+ */
+ @AfterClass
+ public static void log4jClassCleanup() {
+ Log4jTestUtils.testClassCleanup();
}
@Override
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;
/**
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;
}
/**