Commit | Line | Data |
---|---|---|
eca1a136 MJ |
1 | /* |
2 | * Copyright (C) 2022, EfficiOS Inc. | |
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 | ||
22 | import org.apache.logging.log4j.core.Logger; | |
23 | import org.junit.After; | |
24 | import org.junit.AfterClass; | |
25 | import org.junit.BeforeClass; | |
26 | import org.lttng.tools.ILttngSession.Domain; | |
27 | import org.lttng.ust.agent.ILttngHandler; | |
28 | import org.lttng.ust.agent.utils.Log4j2TestContext; | |
29 | import org.lttng.ust.agent.utils.Log4j2TestUtils; | |
30 | ||
31 | /** | |
32 | * Implementation of {@link AppContextOrderingITBase} for the log4j API. | |
33 | */ | |
34 | public class Log4j2AppContextOrderingIT extends AppContextOrderingITBase { | |
35 | ||
36 | private Log4j2TestContext testContext; | |
37 | private Logger logger; | |
38 | ||
39 | /** | |
40 | * Class setup | |
41 | */ | |
42 | @BeforeClass | |
43 | public static void log4j2ClassSetup() { | |
44 | Log4j2TestUtils.testClassSetup(); | |
45 | } | |
46 | ||
47 | /** | |
48 | * Class cleanup | |
49 | */ | |
50 | @AfterClass | |
51 | public static void log4j2ClassCleanup() { | |
52 | Log4j2TestUtils.testClassCleanup(); | |
53 | } | |
54 | ||
55 | /** | |
56 | * Test teardown | |
57 | */ | |
58 | @After | |
59 | public void log4j2Teardown() { | |
60 | logger = null; | |
61 | logHandler = null; | |
62 | ||
63 | testContext.afterTest(); | |
64 | } | |
65 | ||
66 | @Override | |
67 | protected Domain getDomain() { | |
68 | return Domain.LOG4J; | |
69 | } | |
70 | ||
71 | @Override | |
72 | protected void registerAgent() { | |
73 | testContext = new Log4j2TestContext("log4j2.Log4j2AppContextOrderingIT.xml"); | |
74 | ||
75 | testContext.beforeTest(); | |
76 | ||
77 | logger = testContext.getLoggerContext().getLogger(EVENT_NAME); | |
78 | ||
79 | logHandler = (ILttngHandler) logger.getAppenders().get("Lttng"); | |
80 | } | |
81 | ||
82 | @Override | |
83 | protected void sendEventsToLoggers() { | |
84 | Log4j2TestUtils.send10Events(logger); | |
85 | } | |
86 | } |