diff options
author | Thomas Watson | 2018-04-09 15:00:18 +0000 |
---|---|---|
committer | Thomas Watson | 2018-04-09 15:00:18 +0000 |
commit | 55b58a7acb2d6b448c56e9e74694c84d0ea4aa0a (patch) | |
tree | c7e691f2f027e618428a6c7bb197b2042cb40b54 /bundles/org.eclipse.osgi.tests | |
parent | d40e89ffa170de5e7337bc91c7fcad66fac14d43 (diff) | |
download | rt.equinox.framework-I20180502-2000.tar.gz rt.equinox.framework-I20180502-2000.tar.xz rt.equinox.framework-I20180502-2000.zip |
Bug 533386 - [framework] "Events.Service" log events do not contain aI20180503-2000I20180503-0740I20180502-2000I20180502-0100I20180501-2000I20180430-2000I20180430-0715I20180429-2000I20180428-2020I20180428-1500I20180427-2000I20180426-2000I20180426-0500I20180425-2000I20180425-1705I20180425-1650I20180425-1455I20180425-0910I20180425-0725I20180425-0505I20180425-0250I20180424-2000I20180423-2000I20180423-0655I20180423-0640I20180422-2000I20180421-1500I20180420-2000I20180419-2000I20180418-2000I20180417-2000I20180416-2000I20180416-0305I20180415-2000I20180414-1500I20180413-2000I20180412-2000I20180411-2000I20180411-0735I20180411-0530I20180410-2000I20180409-2000
service reference
Change-Id: Ieacda0ecbb60502002dbd0ca2cb64ad0db6b81bf
Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
Diffstat (limited to 'bundles/org.eclipse.osgi.tests')
-rw-r--r-- | bundles/org.eclipse.osgi.tests/src/org/eclipse/equinox/log/test/LogServiceTest.java | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/equinox/log/test/LogServiceTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/equinox/log/test/LogServiceTest.java index 5c16a48d7..12d87736b 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/equinox/log/test/LogServiceTest.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/equinox/log/test/LogServiceTest.java @@ -8,15 +8,24 @@ *******************************************************************************/ package org.eclipse.equinox.log.test; +import java.util.Collections; import java.util.HashMap; +import java.util.Hashtable; import java.util.Map; import junit.framework.TestCase; import org.eclipse.osgi.tests.OSGiTestsActivator; +import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceReference; -import org.osgi.service.log.*; +import org.osgi.framework.ServiceRegistration; +import org.osgi.service.log.LogEntry; +import org.osgi.service.log.LogLevel; +import org.osgi.service.log.LogReaderService; +import org.osgi.service.log.LogService; +import org.osgi.service.log.Logger; import org.osgi.service.log.admin.LoggerAdmin; import org.osgi.service.log.admin.LoggerContext; +@SuppressWarnings("deprecation") public class LogServiceTest extends TestCase { private LogService log; @@ -267,4 +276,41 @@ public class LogServiceTest extends TestCase { assertTrue(entry.getException().getMessage().equals(t.getMessage())); assertTrue(entry.getServiceReference() == logReference); } + + public void testServiceEventLog() throws InterruptedException { + BundleContext context = OSGiTestsActivator.getContext(); + ServiceRegistration<Object> reg = context.registerService(Object.class, new Object(), null); + ServiceReference<Object> ref = reg.getReference(); + listener.waitForLogEntry(); + + listener.waitForLogEntry(); + LogEntry entry = listener.getEntryX(); + assertEquals("Wrong logger name.", "Events.Service", entry.getLoggerName()); + assertEquals("Wrong event log level.", LogLevel.INFO, entry.getLogLevel()); + assertEquals("Wrong bundle.", context.getBundle(), entry.getBundle()); + assertNull("Wrong exception.", entry.getException()); + assertEquals("Wrong service reference.", ref, entry.getServiceReference()); + assertEquals("Wrong message.", "ServiceEvent REGISTERED", entry.getMessage()); + + reg.setProperties(new Hashtable(Collections.singletonMap("key1", "value1"))); + + listener.waitForLogEntry(); + entry = listener.getEntryX(); + assertEquals("Wrong logger name.", "Events.Service", entry.getLoggerName()); + assertEquals("Wrong event log level.", LogLevel.DEBUG, entry.getLogLevel()); + assertEquals("Wrong bundle.", context.getBundle(), entry.getBundle()); + assertNull("Wrong exception.", entry.getException()); + assertEquals("Wrong service reference.", ref, entry.getServiceReference()); + assertEquals("Wrong message.", "ServiceEvent MODIFIED", entry.getMessage()); + + reg.unregister(); + listener.waitForLogEntry(); + entry = listener.getEntryX(); + assertEquals("Wrong logger name.", "Events.Service", entry.getLoggerName()); + assertEquals("Wrong event log level.", LogLevel.INFO, entry.getLogLevel()); + assertEquals("Wrong bundle.", context.getBundle(), entry.getBundle()); + assertNull("Wrong exception.", entry.getException()); + assertEquals("Wrong service reference.", ref, entry.getServiceReference()); + assertEquals("Wrong message.", "ServiceEvent UNREGISTERING", entry.getMessage()); + } } |