Commit | Line | Data |
---|---|---|
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 | ||
e41ec02a AM |
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; | |
24b260d9 | 32 | import org.lttng.ust.agent.integration.MultiSessionTestBase; |
e41ec02a AM |
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; | |
24b260d9 | 36 | import org.lttng.ust.agent.utils.MiscTestUtils; |
e41ec02a | 37 | |
24b260d9 | 38 | public class JulMultiSessionTest extends MultiSessionTestBase { |
e41ec02a AM |
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 */ | |
24b260d9 AM |
50 | assumeTrue(MiscTestUtils.checkForJulLibrary()); |
51 | assumeTrue(MiscTestUtils.checkForLttngTools(Domain.JUL)); | |
e41ec02a AM |
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 | handlerD = new LttngLogHandler(); | |
77 | ||
78 | loggerA.addHandler((Handler) handlerA); | |
79 | loggerB.addHandler((Handler) handlerB); | |
80 | loggerC.addHandler((Handler) handlerC); | |
81 | loggerD.addHandler((Handler) handlerD); | |
82 | } | |
83 | ||
84 | @After | |
85 | public void julTeardown() { | |
86 | loggerA.removeHandler((Handler) handlerA); | |
87 | loggerB.removeHandler((Handler) handlerB); | |
88 | loggerC.removeHandler((Handler) handlerC); | |
89 | loggerD.removeHandler((Handler) handlerD); | |
90 | ||
91 | loggerA = null; | |
92 | loggerB = null; | |
93 | loggerC = null; | |
94 | loggerD = null; | |
95 | } | |
96 | ||
97 | @Override | |
98 | protected Domain getDomain() { | |
99 | return DOMAIN; | |
100 | } | |
101 | ||
102 | @Override | |
103 | protected void sendEventsToLoggers() { | |
104 | JulTestUtils.send10EventsTo(loggerA); | |
105 | JulTestUtils.send10EventsTo(loggerB); | |
106 | JulTestUtils.send10EventsTo(loggerC); | |
107 | JulTestUtils.send10EventsTo(loggerD); | |
108 | } | |
109 | } |