Add tests for "lttng list" when using the legacy agent
[lttng-ust-java-tests.git] / lttng-ust-java-tests-jul / src / test / java / org / lttng / ust / agent / integration / events / JulLegacyApiIT.java
index 88ed2abaea1da7129c2ccb74b8cb6a45d8dcc102..674ca7985b9bff499d821b563a53c7f169fc4af7 100644 (file)
@@ -24,6 +24,8 @@ import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 import java.lang.reflect.Field;
+import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -36,11 +38,9 @@ import org.junit.Test;
 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;
 
 /**
@@ -56,6 +56,7 @@ public class JulLegacyApiIT {
     private static final String EVENT_NAME_B = "EventB";
 
     private ILttngSession session;
+    private LTTngAgent agent;
 
     private Logger loggerA;
     private Logger loggerB;
@@ -65,11 +66,7 @@ public class JulLegacyApiIT {
      */
     @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();
     }
 
     /**
@@ -77,7 +74,7 @@ public class JulLegacyApiIT {
      */
     @AfterClass
     public static void julClassCleanup() {
-        LttngToolsHelper.deleteAllTraces();
+        JulTestUtils.testClassCleanup();
     }
 
     /**
@@ -86,7 +83,7 @@ public class JulLegacyApiIT {
     @Before
     public void setup() {
         loggerA = Logger.getLogger(EVENT_NAME_A);
-        LTTngAgent.getLTTngAgent();
+        agent = LTTngAgent.getLTTngAgent();
         loggerB = Logger.getLogger(EVENT_NAME_B);
 
         loggerA.setLevel(Level.ALL);
@@ -102,7 +99,7 @@ public class JulLegacyApiIT {
     public void tearDown() {
         session.close();
 
-        LTTngAgent.dispose();
+        agent.dispose();
 
         loggerA = null;
         loggerB = null;
@@ -170,6 +167,20 @@ public class JulLegacyApiIT {
         assertEquals(10, handler.getEventCount());
     }
 
+    /**
+     * Test that the "lttng list" commands lists the expected events.
+     */
+    @Test
+    public void testListEvents() {
+        List<String> enabledEvents = session.listEvents();
+        List<String> expectedEvents = Arrays.asList(EVENT_NAME_A, EVENT_NAME_B);
+
+        Collections.sort(enabledEvents);
+        Collections.sort(expectedEvents);
+
+        assertEquals(expectedEvents, enabledEvents);
+    }
+
     /**
      * Get the singleton JUL Handler currently managed by the LTTngAgent. It is
      * not public, so we need reflection to access it.
This page took 0.023637 seconds and 4 git commands to generate.