2 * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir <alexmonthy@efficios.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 package org
.lttng
.ust
.agent
.integration
.events
;
21 import java
.io
.IOException
;
23 import org
.apache
.log4j
.Appender
;
24 import org
.apache
.log4j
.Level
;
25 import org
.apache
.log4j
.Logger
;
26 import org
.junit
.After
;
27 import org
.junit
.AfterClass
;
28 import org
.junit
.Before
;
29 import org
.junit
.BeforeClass
;
30 import org
.lttng
.tools
.ILttngSession
.Domain
;
31 import org
.lttng
.ust
.agent
.log4j
.LttngLogAppender
;
32 import org
.lttng
.ust
.agent
.utils
.Log4jTestUtils
;
35 * Log4j tests for multiple concurrent tracing sessions
37 public class Log4jMultiSessionIT
extends MultiSessionITBase
{
39 private static final Domain DOMAIN
= Domain
.LOG4J
;
41 private Logger loggerA
;
42 private Logger loggerB
;
43 private Logger loggerC
;
44 private Logger loggerD
;
50 public static void log4jClassSetup() {
51 Log4jTestUtils
.testClassSetup();
58 public static void log4jClassCleanup() {
59 Log4jTestUtils
.testClassCleanup();
65 * @throws SecurityException
69 public void log4jSetup() throws SecurityException
, IOException
{
70 // TODO Wipe all existing LTTng sessions?
72 loggerA
= Logger
.getLogger(EVENT_NAME_A
);
73 loggerB
= Logger
.getLogger(EVENT_NAME_B
);
74 loggerC
= Logger
.getLogger(EVENT_NAME_C
);
75 loggerD
= Logger
.getLogger(EVENT_NAME_D
);
77 loggerA
.setLevel(Level
.ALL
);
78 loggerB
.setLevel(Level
.ALL
);
79 loggerC
.setLevel(Level
.ALL
);
80 loggerD
.setLevel(Level
.ALL
);
82 handlerA
= new LttngLogAppender();
83 handlerB
= new LttngLogAppender();
84 handlerC
= new LttngLogAppender();
85 handlerD
= new LttngLogAppender();
87 loggerA
.addAppender((Appender
) handlerA
);
88 loggerB
.addAppender((Appender
) handlerB
);
89 loggerC
.addAppender((Appender
) handlerC
);
90 loggerD
.addAppender((Appender
) handlerD
);
97 public void log4jTeardown() {
98 loggerA
.removeAppender((Appender
) handlerA
);
99 loggerB
.removeAppender((Appender
) handlerB
);
100 loggerC
.removeAppender((Appender
) handlerC
);
101 loggerD
.removeAppender((Appender
) handlerD
);
110 protected Domain
getDomain() {
115 protected boolean closeHandlers()
121 protected void sendEventsToLoggers() {
122 Log4jTestUtils
.send10Events(loggerA
);
123 Log4jTestUtils
.send10Events(loggerB
);
124 Log4jTestUtils
.send10Events(loggerC
);
125 Log4jTestUtils
.send10Events(loggerD
);
This page took 0.032433 seconds and 4 git commands to generate.