Add liblttng-ust-jul for JUL support
[lttng-ust.git] / tests / java-jul / JULTest.java
diff --git a/tests/java-jul/JULTest.java b/tests/java-jul/JULTest.java
new file mode 100644 (file)
index 0000000..0a2e854
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2013 - David Goulet <dgoulet@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License, version 2.1 only,
+ * as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+import java.io.IOException;
+import java.util.concurrent.Semaphore;
+import java.util.logging.LogManager;
+
+import org.lttng.ust.jul.*;
+
+public class JULTest {
+       private final static int NUM_TESTS = 5;
+       private static int testCount = 1;
+
+       /* Singleton agent object. */
+       private static LTTngAgent agent;
+       private static LTTngLogHandler handler;
+       private static LTTngTCPSessiondClient client;
+
+       private static Semaphore sem;
+
+       private static void ok(String desc) {
+               System.out.println("ok " + testCount + " - " + desc);
+               testCount++;
+       }
+
+       public static void go() throws IOException {
+               handler = new LTTngLogHandler(LogManager.getLogManager());
+               assert handler.logManager == LogManager.getLogManager();
+               ok("Log handler logManager is valid");
+
+               client = new LTTngTCPSessiondClient("127.0.0.1", 5345, sem);
+               assert client != null;
+               ok("TCP client is valid");
+               client.destroy();
+               ok("TCP client destroyed");
+
+               agent = LTTngAgent.getLTTngAgent();
+               assert agent != null;
+               ok("LTTngAgent is valid");
+               agent.dispose();
+               ok("LTTngAgent disposed");
+       }
+
+       public static void main(String args[]) throws Exception {
+               System.out.println("1.." + NUM_TESTS);
+               go();
+       }
+}
This page took 0.023974 seconds and 4 git commands to generate.