import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import java.util.Arrays;
import java.util.List;
import org.junit.After;
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
*/
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]\""));
+ }
}
import org.junit.BeforeClass;
import org.lttng.tools.ILttngSession.Domain;
import org.lttng.tools.LttngToolsHelper;
-import org.lttng.ust.agent.integration.events.EnabledEventsITBase;
import org.lttng.ust.agent.jul.LttngLogHandler;
import org.lttng.ust.agent.utils.JulTestUtils;
import org.lttng.ust.agent.utils.LttngUtils;
JulTestUtils.send10EventsTo(loggerC);
JulTestUtils.send10EventsTo(loggerD);
}
+
+ @Override
+ protected void sendLocalizedEvent(String rawString, Object[] params) {
+ loggerA.log(Level.SEVERE, rawString, params);
+ }
}
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
+import org.junit.Test;
import org.lttng.tools.ILttngSession.Domain;
import org.lttng.tools.LttngToolsHelper;
-import org.lttng.ust.agent.integration.events.EnabledEventsITBase;
import org.lttng.ust.agent.log4j.LttngLogAppender;
import org.lttng.ust.agent.utils.Log4jTestUtils;
import org.lttng.ust.agent.utils.LttngUtils;
Log4jTestUtils.send10Events(loggerC);
Log4jTestUtils.send10Events(loggerD);
}
+
+ @Override
+ protected void sendLocalizedEvent(String rawString, Object[] params) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ @Test
+ public void testLocalizedMessage() {
+ /* Does not apply to log4j 1.2.x */
+ }
}