]> git.lttng.org Git - lttng-ust-java-tests.git/commitdiff
Add generic context test
authorAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Thu, 28 Jan 2016 21:16:52 +0000 (16:16 -0500)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Thu, 4 Feb 2016 19:30:02 +0000 (14:30 -0500)
We can test context retriever registration/unregistration
independently of the logging APIs.

Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
lttng-ust-java-tests-common/src/test/java/org/lttng/ust/agent/context/ContextRegistrationIT.java [new file with mode: 0644]

diff --git a/lttng-ust-java-tests-common/src/test/java/org/lttng/ust/agent/context/ContextRegistrationIT.java b/lttng-ust-java-tests-common/src/test/java/org/lttng/ust/agent/context/ContextRegistrationIT.java
new file mode 100644 (file)
index 0000000..4b8fc2c
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2016, EfficiOS Inc., Alexandre Montplaisir <alexmonthy@efficios.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+package org.lttng.ust.agent.context;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.lttng.ust.agent.utils.TestPrintRunner;
+
+/**
+ * Generic tests related to the context retrieval mechanisms.
+ *
+ * @author Alexandre Montplaisir
+ */
+@RunWith(TestPrintRunner.class)
+public class ContextRegistrationIT {
+
+    private ContextInfoManager mgr;
+
+    /**
+     * Test setup
+     */
+    @Before
+    public void testSetup() {
+        try {
+            mgr = ContextInfoManager.getInstance();
+        } catch (SecurityException | IOException e) {
+            fail();
+        }
+    }
+
+    /**
+     * Test registration and unregistration of a basic retriever.
+     */
+    @Test
+    public void testRegistration() {
+        final String retrieverName = "test-retriever";
+        final IContextInfoRetriever emptyRetriever = (key -> null);
+
+        mgr.registerContextInfoRetriever(retrieverName, emptyRetriever);
+
+        IContextInfoRetriever retriever2 = mgr.getContextInfoRetriever(retrieverName);
+        assertEquals(emptyRetriever, retriever2);
+
+        mgr.unregisterContextInfoRetriever(retrieverName);
+    }
+}
This page took 0.026555 seconds and 4 git commands to generate.