1e0022771dada46ee460d4d0de18d35ab2ef1c1e
[lttng-ust.git] / tests / java-jul / JULTest.java
1 /*
2 * Copyright (C) 2013 - David Goulet <dgoulet@efficios.com>
3 *
4 * This library is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License, version 2.1 only,
6 * as published by the Free Software Foundation.
7 *
8 * This library is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
11 * for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this library; if not, write to the Free Software Foundation,
15 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17
18 import java.io.IOException;
19 import java.util.concurrent.Semaphore;
20 import java.util.logging.LogManager;
21
22 import org.lttng.ust.jul.*;
23
24 public class JULTest {
25 private final static int NUM_TESTS = 5;
26 private static int testCount = 1;
27
28 /* Singleton agent object. */
29 private static LTTngAgent agent;
30 private static LTTngLogHandler handler;
31 private static LTTngTCPSessiondClient client;
32
33 private static Semaphore sem;
34
35 private static void ok(String desc) {
36 System.out.println("ok " + testCount + " - " + desc);
37 testCount++;
38 }
39
40 public static void go() throws IOException {
41 handler = new LTTngLogHandler(LogManager.getLogManager());
42 assert handler.logManager == LogManager.getLogManager();
43 ok("Log handler logManager is valid");
44
45 client = new LTTngTCPSessiondClient("127.0.0.1", sem);
46 assert client != null;
47 ok("TCP client is valid");
48 client.destroy();
49 ok("TCP client destroyed");
50
51 agent = LTTngAgent.getLTTngAgent();
52 assert agent != null;
53 ok("LTTngAgent is valid");
54 agent.dispose();
55 ok("LTTngAgent disposed");
56 }
57
58 public static void main(String args[]) throws Exception {
59 System.out.println("1.." + NUM_TESTS);
60 go();
61 }
62 }
This page took 0.029826 seconds and 3 git commands to generate.