2 * Copyright (C) 2022, EfficiOS Inc.
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
.context
;
22 import org
.apache
.logging
.log4j
.core
.Logger
;
23 import org
.junit
.jupiter
.api
.AfterAll
;
24 import org
.junit
.jupiter
.api
.AfterEach
;
25 import org
.junit
.jupiter
.api
.BeforeAll
;
26 import org
.junit
.jupiter
.api
.TestInstance
;
27 import org
.junit
.jupiter
.api
.TestInstance
.Lifecycle
;
28 import org
.lttng
.ust
.agent
.ILttngHandler
;
29 import org
.lttng
.ust
.agent
.utils
.Log4j2TestContext
;
30 import org
.lttng
.ust
.agent
.utils
.Log4j2TestUtils
;
33 * Implementation of {@link AppContextOrderingITBase} for the log4j API.
35 @TestInstance(Lifecycle
.PER_CLASS
)
36 public abstract class Log4j2AppContextOrderingITBase
extends AppContextOrderingITBase
{
38 private Log4j2TestContext testContext
;
39 private Logger logger
;
45 public void log4j2ClassSetup() {
46 Log4j2TestUtils
.testClassSetup(getDomain());
53 public static void log4j2ClassCleanup() {
54 Log4j2TestUtils
.testClassCleanup();
61 public void log4j2Teardown() {
65 testContext
.afterTest();
68 @SuppressWarnings("resource")
70 protected void registerAgent() {
71 testContext
= new Log4j2TestContext("log4j2." + this.getClass().getSimpleName() + ".xml");
73 testContext
.beforeTest();
75 logger
= testContext
.getLoggerContext().getLogger(EVENT_NAME
);
77 logHandler
= (ILttngHandler
) logger
.getAppenders().get("Lttng");
81 protected void sendEventsToLoggers() {
82 Log4j2TestUtils
.send10Events(logger
);