bc8e631dcce4ba48a3b9adcae28dce328154f741
[lttng-ust-java-tests.git] /
1 /*
2 * Copyright (C) 2016, EfficiOS Inc., Alexandre Montplaisir <alexmonthy@efficios.com>
3 *
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.
8 *
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.
13 *
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.
17 */
18
19 package org.lttng.ust.agent.integration.context;
20
21 import static org.junit.Assume.assumeTrue;
22
23 import java.io.IOException;
24
25 import org.apache.log4j.Appender;
26 import org.apache.log4j.Level;
27 import org.apache.log4j.Logger;
28 import org.junit.After;
29 import org.junit.AfterClass;
30 import org.junit.Before;
31 import org.junit.BeforeClass;
32 import org.lttng.tools.ILttngSession.Domain;
33 import org.lttng.tools.LttngToolsHelper;
34 import org.lttng.ust.agent.log4j.LttngLogAppender;
35 import org.lttng.ust.agent.utils.Log4jTestUtils;
36 import org.lttng.ust.agent.utils.LttngUtils;
37
38 /**
39 * Enabled app contexts test for the LTTng-UST JUL log handler.
40 */
41 public class Log4jAppContextIT extends AppContextITBase {
42
43 private static final Domain DOMAIN = Domain.LOG4J;
44
45 private Logger logger;
46
47 /**
48 * Class setup
49 */
50 @BeforeClass
51 public static void julClassSetup() {
52 /* Skip tests if we can't find the log4j library or lttng-tools */
53 assumeTrue(Log4jTestUtils.checkForLog4jLibrary());
54 assumeTrue(LttngUtils.checkForLttngTools(Domain.LOG4J));
55
56 LttngToolsHelper.destroyAllSessions();
57 }
58
59 /**
60 * Class cleanup
61 */
62 @AfterClass
63 public static void julClassCleanup() {
64 LttngToolsHelper.deleteAllTraces();
65 }
66
67 /**
68 * Test setup
69 *
70 * @throws SecurityException
71 * @throws IOException
72 */
73 @Before
74 public void julSetup() throws SecurityException, IOException {
75 logger = Logger.getLogger(EVENT_NAME);
76 logger.setLevel(Level.ALL);
77
78 logHandler = new LttngLogAppender();
79 logger.addAppender((Appender) logHandler);
80 }
81
82 /**
83 * Test teardown
84 */
85 @After
86 public void julTeardown() {
87 logger.removeAppender((Appender) logHandler);
88 logger = null;
89 }
90
91 @Override
92 protected Domain getDomain() {
93 return DOMAIN;
94 }
95
96 @Override
97 protected void sendEventsToLoggers() {
98 Log4jTestUtils.send10Events(logger);
99 }
100 }
This page took 0.033288 seconds and 3 git commands to generate.