0cfe8607629e7fbad0cb8de1611bcc91410e8b72
[lttng-ust-java-tests.git] /
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
19 package org.lttng.ust.agent.integration.events;
20
21 import java.io.IOException;
22 import java.util.logging.Handler;
23 import java.util.logging.Level;
24 import java.util.logging.Logger;
25
26 import org.junit.After;
27 import org.junit.AfterClass;
28 import org.junit.Before;
29 import org.junit.BeforeClass;
30 import org.lttng.tools.ILttngSession.Domain;
31 import org.lttng.ust.agent.jul.LttngLogHandler;
32 import org.lttng.ust.agent.utils.JulTestUtils;
33
34 /**
35 * Enabled events test for the LTTng-UST JUL log handler.
36 */
37 public class JulEnabledEventsIT extends EnabledEventsITBase {
38
39 private static final Domain DOMAIN = Domain.JUL;
40
41 private Logger loggerA;
42 private Logger loggerB;
43 private Logger loggerC;
44 private Logger loggerD;
45
46 /**
47 * Class setup
48 */
49 @BeforeClass
50 public static void julClassSetup() {
51 JulTestUtils.testClassSetup();
52 }
53
54 /**
55 * Class cleanup
56 */
57 @AfterClass
58 public static void julClassCleanup() {
59 JulTestUtils.testClassCleanup();
60 }
61
62 /**
63 * Test setup
64 *
65 * @throws SecurityException
66 * @throws IOException
67 */
68 @Before
69 public void julSetup() throws SecurityException, IOException {
70 loggerA = Logger.getLogger(EVENT_NAME_A);
71 loggerB = Logger.getLogger(EVENT_NAME_B);
72 loggerC = Logger.getLogger(EVENT_NAME_C);
73 loggerD = Logger.getLogger(EVENT_NAME_D);
74
75 loggerA.setLevel(Level.ALL);
76 loggerB.setLevel(Level.ALL);
77 loggerC.setLevel(Level.ALL);
78 loggerD.setLevel(Level.ALL);
79
80 handlerA = new LttngLogHandler();
81 handlerB = new LttngLogHandler();
82 handlerC = new LttngLogHandler();
83
84 loggerA.addHandler((Handler) handlerA);
85 loggerB.addHandler((Handler) handlerB);
86 loggerC.addHandler((Handler) handlerC);
87 }
88
89 /**
90 * Test teardown
91 */
92 @After
93 public void julTeardown() {
94 loggerA.removeHandler((Handler) handlerA);
95 loggerB.removeHandler((Handler) handlerB);
96 loggerC.removeHandler((Handler) handlerC);
97
98 loggerA = null;
99 loggerB = null;
100 loggerC = null;
101 loggerD = null;
102 }
103
104 @Override
105 protected Domain getDomain() {
106 return DOMAIN;
107 }
108
109 @Override
110 protected boolean closeHandlers()
111 {
112 return true;
113 }
114
115 @Override
116 protected void sendEventsToLoggers() {
117 JulTestUtils.send10EventsTo(loggerA);
118 JulTestUtils.send10EventsTo(loggerB);
119 JulTestUtils.send10EventsTo(loggerC);
120 JulTestUtils.send10EventsTo(loggerD);
121 }
122
123 @Override
124 protected void sendLocalizedEvent(String rawString, Object[] params) {
125 loggerA.log(Level.SEVERE, rawString, params);
126 }
127 }
This page took 0.033546 seconds and 3 git commands to generate.