Add 'log4j2' domain tests to the Log4j 2.x agent
[lttng-ust-java-tests.git] / lttng-ust-java-tests-jul / src / test / java / org / lttng / ust / agent / integration / events / JulMultiSessionIT.java
CommitLineData
2b408e85
AM
1/*
2 * Copyright (C) 2015, 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
4821eac9 19package org.lttng.ust.agent.integration.events;
e41ec02a 20
e41ec02a
AM
21import java.io.IOException;
22import java.util.logging.Handler;
23import java.util.logging.Level;
24import java.util.logging.Logger;
25
7a4f0255
MJ
26import org.junit.jupiter.api.AfterAll;
27import org.junit.jupiter.api.AfterEach;
28import org.junit.jupiter.api.BeforeAll;
29import org.junit.jupiter.api.BeforeEach;
9db2c69a 30import org.junit.jupiter.api.Tag;
45d1768c 31import org.lttng.tools.ILttngSession.Domain;
e41ec02a 32import org.lttng.ust.agent.jul.LttngLogHandler;
4821eac9 33import org.lttng.ust.agent.utils.JulTestUtils;
e41ec02a 34
8a0613fa
AM
35/**
36 * JUL tests for multiple concurrent tracing sessions
37 */
9db2c69a
MJ
38@Tag("agent:jul")
39@Tag("domain:jul")
7b82be36 40public class JulMultiSessionIT extends MultiSessionITBase {
e41ec02a
AM
41
42 private static final Domain DOMAIN = Domain.JUL;
43
44 private Logger loggerA;
45 private Logger loggerB;
46 private Logger loggerC;
47 private Logger loggerD;
48
8a0613fa
AM
49 /**
50 * Class setup
51 */
7a4f0255 52 @BeforeAll
e41ec02a 53 public static void julClassSetup() {
eca27046 54 JulTestUtils.testClassSetup();
e41ec02a
AM
55 }
56
8a0613fa
AM
57 /**
58 * Class cleanup
59 */
7a4f0255 60 @AfterAll
e41ec02a 61 public static void julClassCleanup() {
eca27046 62 JulTestUtils.testClassCleanup();
e41ec02a
AM
63 }
64
8a0613fa
AM
65 /**
66 * Test setup
67 *
68 * @throws SecurityException
69 * @throws IOException
70 */
7a4f0255 71 @BeforeEach
e41ec02a
AM
72 public void julSetup() throws SecurityException, IOException {
73 loggerA = Logger.getLogger(EVENT_NAME_A);
74 loggerB = Logger.getLogger(EVENT_NAME_B);
75 loggerC = Logger.getLogger(EVENT_NAME_C);
76 loggerD = Logger.getLogger(EVENT_NAME_D);
77
78 loggerA.setLevel(Level.ALL);
79 loggerB.setLevel(Level.ALL);
80 loggerC.setLevel(Level.ALL);
81 loggerD.setLevel(Level.ALL);
82
83 handlerA = new LttngLogHandler();
84 handlerB = new LttngLogHandler();
85 handlerC = new LttngLogHandler();
86 handlerD = new LttngLogHandler();
87
88 loggerA.addHandler((Handler) handlerA);
89 loggerB.addHandler((Handler) handlerB);
90 loggerC.addHandler((Handler) handlerC);
91 loggerD.addHandler((Handler) handlerD);
92 }
93
8a0613fa
AM
94 /**
95 * Test teardown
96 */
7a4f0255 97 @AfterEach
e41ec02a
AM
98 public void julTeardown() {
99 loggerA.removeHandler((Handler) handlerA);
100 loggerB.removeHandler((Handler) handlerB);
101 loggerC.removeHandler((Handler) handlerC);
102 loggerD.removeHandler((Handler) handlerD);
103
104 loggerA = null;
105 loggerB = null;
106 loggerC = null;
107 loggerD = null;
108 }
109
110 @Override
111 protected Domain getDomain() {
112 return DOMAIN;
113 }
114
eca1a136
MJ
115 @Override
116 protected boolean closeHandlers()
117 {
118 return true;
119 }
120
e41ec02a
AM
121 @Override
122 protected void sendEventsToLoggers() {
123 JulTestUtils.send10EventsTo(loggerA);
124 JulTestUtils.send10EventsTo(loggerB);
125 JulTestUtils.send10EventsTo(loggerC);
126 JulTestUtils.send10EventsTo(loggerD);
127 }
128}
This page took 0.028273 seconds and 4 git commands to generate.