/** * 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); } }