Add tests for localized messages
[lttng-ust-java-tests.git] / lttng-ust-java-tests-common / src / main / java / org / lttng / ust / agent / integration / events / EnabledEventsITBase.java
index 5659493991fbd6495973eea17e83969b3a82c68d..c0de521f82168ad58670a2884e3ee5f8776a2c34 100644 (file)
@@ -22,6 +22,7 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
+import java.util.Arrays;
 import java.util.List;
 
 import org.junit.After;
@@ -56,6 +57,11 @@ public abstract class EnabledEventsITBase {
 
     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
      */
@@ -261,4 +267,28 @@ public abstract class EnabledEventsITBase {
         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]\""));
+    }
 }
This page took 0.059217 seconds and 4 git commands to generate.