/** * Returns the dev.properties as a property store. * * @return properties */ protected static Properties getDevProperties() { if (fgIsDev) { if (fgDevProperties == null) { fgDevProperties = new Properties(); if (fgDevPropertiesURL != null) { try { URL url = new URL(fgDevPropertiesURL); String path = url.getFile(); if (path != null && path.length() > 0) { File file = new File(path); if (file.exists()) { BufferedInputStream stream = null; try { stream = new BufferedInputStream(new FileInputStream(file)); fgDevProperties.load(stream); } catch (FileNotFoundException e) { PDECore.log(e); } catch (IOException e) { PDECore.log(e); } finally { if (stream != null) stream.close(); } } } } catch (MalformedURLException e) { PDECore.log(e); } catch (IOException e) { PDECore.log(e); } } } return fgDevProperties; } return null; }
/** * Tests reading a 3.0.2 install with a mix of classic and OSGi plug-ins. * * @throws Exception */ public void testClassicPlugins() throws Exception { // extract the 3.0.2 skeleton IPath location = extractClassicPlugins(); // the new way ITargetDefinition definition = getNewTarget(); ITargetLocation container = getTargetService().newDirectoryLocation(location.toOSString()); definition.setTargetLocations(new ITargetLocation[] {container}); Set urls = getAllBundleURLs(definition); assertTrue("Must be bundles", urls.size() > 0); Preferences store = PDECore.getDefault().getPluginPreferences(); boolean restore = store.getBoolean(ICoreConstants.TARGET_PLATFORM_REALIZATION); try { store.setValue(ICoreConstants.TARGET_PLATFORM_REALIZATION, false); // the old way URL[] pluginPaths = PluginPathFinder.getPluginPaths(location.toOSString()); for (int i = 0; i < pluginPaths.length; i++) { URL url = pluginPaths[i]; if (!urls.contains(url)) { System.err.println(url.toString()); } } assertEquals("Wrong number of bundles", pluginPaths.length, urls.size()); } finally { store.setValue(ICoreConstants.TARGET_PLATFORM_REALIZATION, restore); } }
/** * Tests that a bundle directory container is equivalent to scanning locations when it uses a * variable to specify its location. * * @throws Exception */ public void testVariableDirectoryBundleContainer() throws Exception { // the new way ITargetDefinition definition = getNewTarget(); ITargetLocation container = getTargetService().newDirectoryLocation("${eclipse_home}/plugins"); definition.setTargetLocations(new ITargetLocation[] {container}); Set urls = getAllBundleURLs(definition); Preferences store = PDECore.getDefault().getPluginPreferences(); boolean restore = store.getBoolean(ICoreConstants.TARGET_PLATFORM_REALIZATION); try { store.setValue(ICoreConstants.TARGET_PLATFORM_REALIZATION, false); // the old way URL[] pluginPaths = PluginPathFinder.getPluginPaths(TargetPlatform.getDefaultLocation()); assertEquals("Should have same number of bundles", pluginPaths.length, urls.size()); for (int i = 0; i < pluginPaths.length; i++) { URL url = pluginPaths[i]; assertTrue("Missing plug-in " + url.toString(), urls.contains(url)); } } finally { store.setValue(ICoreConstants.TARGET_PLATFORM_REALIZATION, restore); } }