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