4254aafec7ef95b85ff6b8899aa6147afb9ebcff
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
.After
;
27 import org
.junit
.AfterClass
;
28 import org
.junit
.BeforeClass
;
29 import org
.junit
.runner
.RunWith
;
30 import org
.junit
.runners
.Parameterized
;
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
40 @RunWith(Parameterized
.class)
41 public class JulLoggerHierarchyListIT
extends LoggerHierachyListITBase
{
43 private Logger parentLogger
;
44 private Logger childLogger
;
46 private Handler parentHandler
;
47 private Handler childHandler
;
52 * @param parentLoggerActive
53 * Parent logger has been instantiated
54 * @param parentLoggerHasHandler
55 * Parent logger has a LTTng handler attached to it
56 * @param childLoggerActive
57 * Child logger has been instantiated
58 * @param childLoggerHasHandler
59 * Child logger has a LTTng handler attached to it
61 public JulLoggerHierarchyListIT(boolean parentLoggerActive
,
62 boolean parentLoggerHasHandler
,
63 boolean childLoggerActive
,
64 boolean childLoggerHasHandler
) {
65 /* Set by parameters defined in the base class */
66 super(parentLoggerActive
,
67 parentLoggerHasHandler
,
69 childLoggerHasHandler
);
72 // ------------------------------------------------------------------------
74 // ------------------------------------------------------------------------
80 public static void julClassSetup() {
81 JulTestUtils
.testClassSetup();
88 public static void julClassCleanup() {
89 JulTestUtils
.testClassCleanup();
96 public void cleanup() {
97 if (parentLogger
!= null) {
98 if (parentHandler
!= null) {
99 parentLogger
.removeHandler(parentHandler
);
100 parentHandler
.close();
101 parentHandler
= null;
106 if (childLogger
!= null) {
107 if (childHandler
!= null) {
108 childLogger
.removeHandler(childHandler
);
109 childHandler
.close();
116 * Kind of hackish, but it's the only way to ensure that loggers are
117 * really removed in-between tests, since LogManager does not provide a
118 * way to forcibly remove a logger, and it doesn't seem like it will any
119 * time soon, see http://bugs.java.com/view_bug.do?bug_id=4811930
121 LogManager
.getLogManager().reset();
125 // ------------------------------------------------------------------------
127 // ------------------------------------------------------------------------
130 protected Domain
getDomain() {
135 protected void activateLoggers() throws IOException
{
136 if (parentLoggerActive
) {
137 parentLogger
= Logger
.getLogger(PARENT_LOGGER
);
138 if (parentLoggerHasHandler
) {
139 parentHandler
= new LttngLogHandler();
140 parentLogger
.addHandler(parentHandler
);
144 if (childLoggerActive
) {
145 childLogger
= Logger
.getLogger(CHILD_LOGGER
);
146 if (childLoggerHasHandler
) {
147 childHandler
= new LttngLogHandler();
148 childLogger
.addHandler(childHandler
);
This page took 0.032434 seconds and 4 git commands to generate.