diff options
author | gjoranv <gv@verizonmedia.com> | 2022-05-10 14:01:18 +0200 |
---|---|---|
committer | gjoranv <gjoranv@gmail.com> | 2022-05-10 22:28:45 +0200 |
commit | d8f393420f0e3fffa981d52dc9d969a22c1dfdc0 (patch) | |
tree | 56e6c4f846e66ee7e94da27f445e4bb9f845d5fe /jdisc_core_test | |
parent | 20bb0b703f97226f7866565478a6df34f9769467 (diff) |
Test vespa log instead of osgi log reader.
Diffstat (limited to 'jdisc_core_test')
-rw-r--r-- | jdisc_core_test/integration_test/src/test/java/com/yahoo/jdisc/core/OsgiLogServiceIntegrationTest.java | 63 |
1 files changed, 0 insertions, 63 deletions
diff --git a/jdisc_core_test/integration_test/src/test/java/com/yahoo/jdisc/core/OsgiLogServiceIntegrationTest.java b/jdisc_core_test/integration_test/src/test/java/com/yahoo/jdisc/core/OsgiLogServiceIntegrationTest.java deleted file mode 100644 index 6a36a13b976..00000000000 --- a/jdisc_core_test/integration_test/src/test/java/com/yahoo/jdisc/core/OsgiLogServiceIntegrationTest.java +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.jdisc.core; - -import com.yahoo.jdisc.test.TestDriver; -import org.junit.Test; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; -import org.osgi.service.log.LogEntry; -import org.osgi.service.log.LogReaderService; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - - -/** - * @author Simon Thoresen Hult - * @author bjorncs - */ -public class OsgiLogServiceIntegrationTest { - - @Test - @SuppressWarnings("unchecked") - public void requireThatAllSupportedLogFrameworksAreConfigured() throws Exception { - // need to explicitly set log level of root logger since integration suite now provides a logger config file, - // which disables that setLevel() call of the OsgiLogManager. - Logger.getLogger("").setLevel(Level.INFO); - - long now = System.currentTimeMillis(); - TestDriver driver = TestDriver.newApplicationBundleInstance("app-h-log.jar", false); - BundleContext ctx = driver.osgiFramework().bundleContext(); - ServiceReference<?> ref = ctx.getServiceReference(LogReaderService.class.getName()); - LogReaderService reader = (LogReaderService)ctx.getService(ref); - ArrayList<LogEntry> logEntries = Collections.list(reader.getLog()); - assertTrue(logEntries.size() >= 4); - - assertLogContainsEntry("[jdk14] hello world", logEntries, now); - assertLogContainsEntry("[slf4j] hello world", logEntries, now); - assertLogContainsEntry("[log4j] hello world", logEntries, now); - assertLogContainsEntry("[jcl] hello world", logEntries, now); - - assertTrue(driver.close()); - } - - private static void assertLogContainsEntry(String expectedMessage, List<LogEntry> logEntries, long expectedTimeGE) - { - LogEntry entry = logEntries.stream().filter(e -> e.getMessage().equals(expectedMessage)).findFirst() - .orElseThrow(() -> new AssertionError("Could not find log entry with messsage: " + expectedMessage)); - - assertNull(entry.getBundle()); - assertNotNull(entry.getServiceReference()); - assertEquals(OsgiLogHandler.toServiceLevel(Level.INFO), entry.getLevel()); - assertNull(entry.getException()); - assertTrue(expectedTimeGE <= entry.getTime()); - } -} |