2 * Copyright (C) 2016, 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
;
22 import java
.util
.logging
.Handler
;
23 import java
.util
.logging
.LogManager
;
24 import java
.util
.logging
.Logger
;
26 import org
.junit
.jupiter
.api
.AfterAll
;
27 import org
.junit
.jupiter
.api
.AfterEach
;
28 import org
.junit
.jupiter
.api
.BeforeAll
;
29 import org
.junit
.jupiter
.api
.BeforeEach
;
30 import org
.junit
.jupiter
.api
.Tag
;
31 import org
.lttng
.tools
.ILttngSession
.Domain
;
32 import org
.lttng
.ust
.agent
.jul
.LttngLogHandler
;
33 import org
.lttng
.ust
.agent
.utils
.JulTestUtils
;
36 * Implementation of {@link LoggerHierachyListITBase} for JUL log handlers.
38 * @author Alexandre Montplaisir
42 public class JulLoggerHierarchyListIT
extends LoggerHierachyListITBase
{
44 private Logger parentLogger
;
45 private Logger childLogger
;
47 private Handler parentHandler
;
48 private Handler childHandler
;
50 // ------------------------------------------------------------------------
52 // ------------------------------------------------------------------------
58 public static void julClassSetup() {
59 JulTestUtils
.testClassSetup();
66 public static void julClassCleanup() {
67 JulTestUtils
.testClassCleanup();
73 @SuppressWarnings("static-method")
77 * Kind of hackish, but it's the only way to ensure that loggers are
78 * really removed in-between tests, since LogManager does not provide a
79 * way to forcibly remove a logger, and it doesn't seem like it will any
80 * time soon, see http://bugs.java.com/view_bug.do?bug_id=4811930
82 LogManager
.getLogManager().reset();
90 public void cleanup() {
91 if (parentLogger
!= null) {
92 if (parentHandler
!= null) {
93 parentLogger
.removeHandler(parentHandler
);
94 parentHandler
.close();
100 if (childLogger
!= null) {
101 if (childHandler
!= null) {
102 childLogger
.removeHandler(childHandler
);
103 childHandler
.close();
109 LogManager
.getLogManager().reset();
113 // ------------------------------------------------------------------------
115 // ------------------------------------------------------------------------
118 protected Domain
getDomain() {
123 protected void activateLoggers(boolean parentLoggerActive
,
124 boolean parentLoggerHasHandler
,
125 boolean childLoggerActive
,
126 boolean childLoggerHasHandler
) throws IOException
{
127 if (parentLoggerActive
) {
128 parentLogger
= Logger
.getLogger(PARENT_LOGGER
);
129 if (parentLoggerHasHandler
) {
130 parentHandler
= new LttngLogHandler();
131 parentLogger
.addHandler(parentHandler
);
135 if (childLoggerActive
) {
136 childLogger
= Logger
.getLogger(CHILD_LOGGER
);
137 if (childLoggerHasHandler
) {
138 childHandler
= new LttngLogHandler();
139 childLogger
.addHandler(childHandler
);
This page took 0.036761 seconds and 4 git commands to generate.