package org.lttng.ust.agent.integration.events;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import java.util.Arrays;
import java.util.List;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.lttng.tools.ILttngSession;
import org.lttng.tools.ILttngSession.Domain;
import org.lttng.ust.agent.ILttngHandler;
-import org.lttng.ust.agent.utils.TestPrintRunner;
+import org.lttng.ust.agent.utils.TestPrintExtension;
/**
* Base abstract class to implement all sorts of integration tests verifying the
* presence of enabled events in resulting traces.
*/
-@RunWith(TestPrintRunner.class)
+@ExtendWith(TestPrintExtension.class)
public abstract class EnabledEventsITBase {
protected static final String EVENT_NAME_A = "EventA";
protected static final String EVENT_NAME_B = "EventAB";
protected static final String EVENT_NAME_C = "EventABC";
- protected static final String EVENT_NAME_D = "EventABCD";
+ protected static final String EVENT_NAME_D = "EventABCDÉ";
private ILttngSession session;
protected abstract Domain getDomain();
+ protected abstract boolean closeHandlers();
+
protected abstract void sendEventsToLoggers();
+ /**
+ * Send one event using a localized API to logger/handler A.
+ */
+ protected abstract void sendLocalizedEvent(String rawString, Object[] params);
+
/**
* Base test setup
*/
- @Before
+ @BeforeEach
public void testSetup() {
session = ILttngSession.createSession(null, getDomain());
}
/**
* Base test teardown
*/
- @After
+ @AfterEach
public void testTeardown() {
session.close();
- handlerA.close();
- handlerB.close();
- handlerC.close();
+ if (closeHandlers()) {
+ handlerA.close();
+ handlerB.close();
+ handlerC.close();
+ }
handlerA = null;
handlerB = null;
assertEquals(10, handlerB.getEventCount());
assertEquals(10, handlerC.getEventCount());
}
+
+ /**
+ * Test sending a localized message.
+ */
+ @Test
+ public void testLocalizedMessage() {
+ Integer value1 = Integer.valueOf(10);
+ List<Integer> value2 = Arrays.asList(Integer.valueOf(1000), Integer.valueOf(1001), Integer.valueOf(1002));
+
+ assertTrue(session.enableAllEvents());
+ assertTrue(session.start());
+
+ sendLocalizedEvent("Message with a localized value: {0} and some others: {1}",
+ new Object[] { value1, value2 });
+
+ assertTrue(session.stop());
+ assertEquals(1, handlerA.getEventCount());
+
+ List<String> output = session.view();
+
+ assertNotNull(output);
+ assertEquals(1, output.size());
+ assertTrue(output.get(0).contains("msg = \"Message with a localized value: 10 and some others: [1000, 1001, 1002]\""));
+ }
}