Put common setup code in the utils classes
[lttng-ust-java-tests.git] / lttng-ust-java-tests-jul / src / test / java / org / lttng / ust / agent / integration / events / JulEnabledEventsIT.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
4821eac9 19package org.lttng.ust.agent.integration.events;
da8308fe 20
da8308fe 21import java.io.IOException;
c5524c71 22import java.util.logging.Handler;
da8308fe
AM
23import java.util.logging.Level;
24import java.util.logging.Logger;
25
26import org.junit.After;
9368bd5e 27import org.junit.AfterClass;
da8308fe
AM
28import org.junit.Before;
29import org.junit.BeforeClass;
45d1768c 30import org.lttng.tools.ILttngSession.Domain;
da8308fe 31import org.lttng.ust.agent.jul.LttngLogHandler;
4821eac9 32import org.lttng.ust.agent.utils.JulTestUtils;
da8308fe 33
8a0613fa
AM
34/**
35 * Enabled events test for the LTTng-UST JUL log handler.
36 */
7b82be36 37public class JulEnabledEventsIT extends EnabledEventsITBase {
da8308fe
AM
38
39 private static final Domain DOMAIN = Domain.JUL;
40
da8308fe
AM
41 private Logger loggerA;
42 private Logger loggerB;
43 private Logger loggerC;
44 private Logger loggerD;
45
8a0613fa
AM
46 /**
47 * Class setup
48 */
da8308fe 49 @BeforeClass
c5524c71 50 public static void julClassSetup() {
eca27046 51 JulTestUtils.testClassSetup();
9368bd5e
AM
52 }
53
8a0613fa
AM
54 /**
55 * Class cleanup
56 */
9368bd5e 57 @AfterClass
c5524c71 58 public static void julClassCleanup() {
eca27046 59 JulTestUtils.testClassCleanup();
da8308fe
AM
60 }
61
8a0613fa
AM
62 /**
63 * Test setup
64 *
65 * @throws SecurityException
66 * @throws IOException
67 */
da8308fe 68 @Before
c5524c71 69 public void julSetup() throws SecurityException, IOException {
da8308fe
AM
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
c5524c71
AM
84 loggerA.addHandler((Handler) handlerA);
85 loggerB.addHandler((Handler) handlerB);
86 loggerC.addHandler((Handler) handlerC);
da8308fe
AM
87 }
88
8a0613fa
AM
89 /**
90 * Test teardown
91 */
da8308fe 92 @After
c5524c71
AM
93 public void julTeardown() {
94 loggerA.removeHandler((Handler) handlerA);
95 loggerB.removeHandler((Handler) handlerB);
96 loggerC.removeHandler((Handler) handlerC);
da8308fe
AM
97
98 loggerA = null;
99 loggerB = null;
100 loggerC = null;
101 loggerD = null;
da8308fe
AM
102 }
103
c5524c71
AM
104 @Override
105 protected Domain getDomain() {
106 return DOMAIN;
9368bd5e
AM
107 }
108
c5524c71
AM
109 @Override
110 protected void sendEventsToLoggers() {
8576633f
AM
111 JulTestUtils.send10EventsTo(loggerA);
112 JulTestUtils.send10EventsTo(loggerB);
113 JulTestUtils.send10EventsTo(loggerC);
114 JulTestUtils.send10EventsTo(loggerD);
da8308fe 115 }
3fa81377
AM
116
117 @Override
118 protected void sendLocalizedEvent(String rawString, Object[] params) {
119 loggerA.log(Level.SEVERE, rawString, params);
120 }
da8308fe 121}
This page took 0.033042 seconds and 4 git commands to generate.