diff options
author | Thomas Watson | 2014-02-26 16:25:27 +0000 |
---|---|---|
committer | Thomas Watson | 2014-02-26 16:25:27 +0000 |
commit | fb14d0b71f6b4bf654797ee92778c4086af56022 (patch) | |
tree | 05bc472f03cb308874c66452108530a8ba92cccb /bundles/org.eclipse.osgi.tests | |
parent | 5f224660cc2352c99c12a73259d64b34a72772db (diff) | |
download | rt.equinox.framework-fb14d0b71f6b4bf654797ee92778c4086af56022.tar.gz rt.equinox.framework-fb14d0b71f6b4bf654797ee92778c4086af56022.tar.xz rt.equinox.framework-fb14d0b71f6b4bf654797ee92778c4086af56022.zip |
Bug 429158 - When in debug mode log a message with stack trace when Location.getURL is called for a Location that is not set
- Add a testcase
Diffstat (limited to 'bundles/org.eclipse.osgi.tests')
-rw-r--r-- | bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/datalocation/BasicLocationTests.java | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/datalocation/BasicLocationTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/datalocation/BasicLocationTests.java index 8770f1071..008347e46 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/datalocation/BasicLocationTests.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/datalocation/BasicLocationTests.java @@ -10,19 +10,21 @@ *******************************************************************************/ package org.eclipse.osgi.tests.services.datalocation; -import java.io.File; -import java.io.IOException; +import java.io.*; import java.net.URL; import java.util.*; import junit.framework.Test; import junit.framework.TestSuite; import org.eclipse.core.runtime.Platform; import org.eclipse.core.tests.harness.CoreTest; +import org.eclipse.equinox.log.SynchronousLogListener; +import org.eclipse.osgi.internal.framework.EquinoxConfiguration; import org.eclipse.osgi.internal.location.EquinoxLocations; import org.eclipse.osgi.launch.Equinox; import org.eclipse.osgi.service.datalocation.Location; import org.eclipse.osgi.tests.OSGiTestsActivator; import org.osgi.framework.*; +import org.osgi.service.log.*; import org.osgi.util.tracker.ServiceTracker; public class BasicLocationTests extends CoreTest { @@ -446,4 +448,42 @@ public class BasicLocationTests extends CoreTest { equinox.stop(); } } + + public void testDebugLogOnGetURL() throws Exception { + Properties debugOptions = new Properties(); + debugOptions.put("org.eclipse.osgi/debug/location", "true"); + File debugOptionsFile = OSGiTestsActivator.getContext().getDataFile(getName() + ".options"); + debugOptions.store(new FileOutputStream(debugOptionsFile), getName()); + Map<String, String> fwkConfig = new HashMap<String, String>(); + fwkConfig.put(EquinoxLocations.PROP_CONFIG_AREA + EquinoxLocations.READ_ONLY_AREA_SUFFIX, "true"); + fwkConfig.put(EquinoxLocations.PROP_INSTALL_AREA, "file:" + prefix + "/g"); + fwkConfig.put(EquinoxConfiguration.PROP_DEBUG, debugOptionsFile.getAbsolutePath()); + fwkConfig.put("eclipse.consoleLog", "true"); + + Equinox equinox = new Equinox(fwkConfig); + equinox.init(); + try { + final List<LogEntry> logEntries = new ArrayList<LogEntry>(); + LogReaderService logReaderService = getLogReaderService(equinox); + LogListener logListener = new SynchronousLogListener() { + @Override + public void logged(LogEntry entry) { + logEntries.add(entry); + } + }; + logReaderService.addLogListener(logListener); + Map<String, Location> locations = getLocations(equinox); + Location userLocation = locations.get(Location.USER_FILTER); + Location instanceLocation = locations.get(Location.INSTANCE_FILTER); + assertNotNull("User locatoin is not null.", userLocation.getURL()); + assertNotNull("Instance location is not null.", instanceLocation.getURL()); + assertEquals("Wrong number of log entries", 2, logEntries.size()); + } finally { + equinox.stop(); + } + } + + private LogReaderService getLogReaderService(Equinox equinox) { + return equinox.getBundleContext().getService(equinox.getBundleContext().getServiceReference(LogReaderService.class)); + } } |