880c21776af996a64e1f5bb8336f28f1e070077e
[lttng-ust-java-tests.git] / src / test / java / org / lttng / ust / agent / integration / jul / JulEnabledEventsTest.java
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.jul;
20
21 import static org.junit.Assume.assumeTrue;
22
23 import java.io.IOException;
24 import java.util.logging.Handler;
25 import java.util.logging.Level;
26 import java.util.logging.Logger;
27
28 import org.junit.After;
29 import org.junit.AfterClass;
30 import org.junit.Before;
31 import org.junit.BeforeClass;
32 import org.lttng.ust.agent.integration.EnabledEventsTestBase;
33 import org.lttng.ust.agent.jul.LttngLogHandler;
34 import org.lttng.ust.agent.utils.LttngSession;
35 import org.lttng.ust.agent.utils.LttngSession.Domain;
36 import org.lttng.ust.agent.utils.MiscTestUtils;
37
38 public class JulEnabledEventsTest extends EnabledEventsTestBase {
39
40 private static final Domain DOMAIN = Domain.JUL;
41
42 private Logger loggerA;
43 private Logger loggerB;
44 private Logger loggerC;
45 private Logger loggerD;
46
47 @BeforeClass
48 public static void julClassSetup() {
49 /* Skip tests if we can't find the JNI library or lttng-tools */
50 assumeTrue(MiscTestUtils.checkForJulLibrary());
51 assumeTrue(MiscTestUtils.checkForLttngTools(Domain.JUL));
52
53 LttngSession.destroyAllSessions();
54 }
55
56 @AfterClass
57 public static void julClassCleanup() {
58 LttngSession.deleteAllTracee();
59 }
60
61 @Before
62 public void julSetup() throws SecurityException, IOException {
63 loggerA = Logger.getLogger(EVENT_NAME_A);
64 loggerB = Logger.getLogger(EVENT_NAME_B);
65 loggerC = Logger.getLogger(EVENT_NAME_C);
66 loggerD = Logger.getLogger(EVENT_NAME_D);
67
68 loggerA.setLevel(Level.ALL);
69 loggerB.setLevel(Level.ALL);
70 loggerC.setLevel(Level.ALL);
71 loggerD.setLevel(Level.ALL);
72
73 handlerA = new LttngLogHandler();
74 handlerB = new LttngLogHandler();
75 handlerC = new LttngLogHandler();
76
77 loggerA.addHandler((Handler) handlerA);
78 loggerB.addHandler((Handler) handlerB);
79 loggerC.addHandler((Handler) handlerC);
80 }
81
82 @After
83 public void julTeardown() {
84 loggerA.removeHandler((Handler) handlerA);
85 loggerB.removeHandler((Handler) handlerB);
86 loggerC.removeHandler((Handler) handlerC);
87
88 loggerA = null;
89 loggerB = null;
90 loggerC = null;
91 loggerD = null;
92 }
93
94 @Override
95 protected Domain getDomain() {
96 return DOMAIN;
97 }
98
99 @Override
100 protected void sendEventsToLoggers() {
101 JulTestUtils.send10EventsTo(loggerA);
102 JulTestUtils.send10EventsTo(loggerB);
103 JulTestUtils.send10EventsTo(loggerC);
104 JulTestUtils.send10EventsTo(loggerD);
105 }
106 }
This page took 0.031064 seconds and 3 git commands to generate.