use of org.osgi.service.log.LogReaderService in project rt.equinox.framework by eclipse.
the class SystemBundleTests method testOverrideEquinoxConfigAreaProp.
public void testOverrideEquinoxConfigAreaProp() {
// $NON-NLS-1$
File config = OSGiTestsActivator.getContext().getDataFile(getName());
Map configuration = new HashMap();
configuration.put(Constants.FRAMEWORK_STORAGE, config.getAbsolutePath());
configuration.put(EquinoxLocations.PROP_CONFIG_AREA, config.getAbsolutePath() + "-override");
configuration.put(EquinoxConfiguration.PROP_LOG_HISTORY_MAX, "10");
Equinox equinox = null;
try {
equinox = new Equinox(configuration);
equinox.init();
BundleContext bc = equinox.getBundleContext();
LogReaderService logReader = bc.getService(bc.getServiceReference(LogReaderService.class));
Enumeration<LogEntry> logs = logReader.getLog();
assertTrue("No logs found.", logs.hasMoreElements());
LogEntry entry = logs.nextElement();
assertEquals("Wrong log level.", LogLevel.WARN, entry.getLogLevel());
assertTrue("Wrong message found: " + entry.getMessage(), entry.getMessage().contains(EquinoxLocations.PROP_CONFIG_AREA));
} catch (BundleException e) {
fail("Failed init", e);
} finally {
try {
if (equinox != null) {
equinox.stop();
equinox.waitForStop(1000);
}
} catch (BundleException e) {
fail("Failed to stop framework.", e);
} catch (InterruptedException e) {
fail("Failed to stop framework.", e);
}
}
}
Aggregations