Fix latest tests
[lttng-ust-java-tests.git] / lttng-ust-java-tests-common / src / test / java / org / lttng / ust / agent / integration / client / TcpClientDebugListener.java
index 703e0e3ba3e2f54a645e567019b29d33e571a706..abc9d423b031b3a4ed415d74d5362be3e2b26c43 100644 (file)
@@ -36,6 +36,9 @@ public class TcpClientDebugListener implements ILttngTcpClientListener {
     private final List<EventRule> enabledEventCommands = Collections.synchronizedList(new ArrayList<>());
     private final List<String> disabledEventCommands = Collections.synchronizedList(new ArrayList<>());
 
+    private final List<String> enabledAppContextCommands = Collections.synchronizedList(new ArrayList<>());
+    private final List<String> disabledAppContextCommands = Collections.synchronizedList(new ArrayList<>());
+
     @Override
     public boolean eventEnabled(EventRule rule) {
         enabledEventCommands.add(rule);
@@ -48,6 +51,18 @@ public class TcpClientDebugListener implements ILttngTcpClientListener {
         return true;
     }
 
+    @Override
+    public boolean appContextEnabled(String contextRetrieverName, String contextName) {
+        enabledAppContextCommands.add(contextRetrieverName + ':' + contextName);
+        return true;
+    }
+
+    @Override
+    public boolean appContextDisabled(String contextRetrieverName, String contextName) {
+        disabledAppContextCommands.add(contextRetrieverName + ':' + contextName);
+        return true;
+    }
+
     /**
      * Not yet implemented
      */
@@ -77,12 +92,39 @@ public class TcpClientDebugListener implements ILttngTcpClientListener {
         }
     }
 
+    /**
+     * @return The "add-context" commands that were received since instantiation
+     *         or the last {@link #clearAllCommands}.
+     */
+    public List<String> getEnabledAppContextCommands() {
+        synchronized (enabledAppContextCommands) {
+            return new ArrayList<>(enabledAppContextCommands);
+        }
+    }
+
+    /**
+     * Return the number of "context disabled" commands received.
+     *
+     * There is no equivalent command in the lttng CLI, but the sessiond will
+     * send such messages through the agent socket when a session is destroyed
+     * and had contexts enabled.
+     *
+     * @return The number of "context disabled" commands received.
+     */
+    public List<String> getDisabledAppContextCommands() {
+        synchronized (disabledAppContextCommands) {
+            return new ArrayList<>(disabledAppContextCommands);
+        }
+    }
+
     /**
      * Clear all tracked data.
      */
     public void clearAllCommands() {
         enabledEventCommands.clear();
         disabledEventCommands.clear();
+        enabledAppContextCommands.clear();
+        disabledAppContextCommands.clear();
     }
 
 }
This page took 0.030108 seconds and 4 git commands to generate.