/** * Reads a target definition file from the tests/targets/target-files location with the given * name. Note that ".target" will be appended. * * @param name * @return target definition * @throws Exception */ protected ITargetDefinition readOldTarget(String name) throws Exception { URL url = MacroPlugin.getBundleContext() .getBundle() .getEntry("/tests/targets/target-files/" + name + ".target"); File file = new File(FileLocator.toFileURL(url).getFile()); ITargetDefinition target = getNewTarget(); FileInputStream stream = new FileInputStream(file); TargetDefinitionPersistenceHelper.initFromXML(target, stream); stream.close(); return target; }
/* * Copy the bundle with the given id to the specified location. (location * is parent directory) */ public void copyBundle(String bundlename, File source, File destination) throws IOException { if (destination == null) destination = output; destination = new File(destination, "eclipse/plugins"); if (source == null) { Bundle bundle = TestActivator.getBundle(bundlename); if (bundle == null) { throw new IOException("Could not find: " + bundlename); } String location = bundle.getLocation(); if (location.startsWith("reference:")) location = location.substring("reference:".length()); source = new File(FileLocator.toFileURL(new URL(location)).getFile()); } destination = new File(destination, source.getName()); if (destination.exists()) return; FileUtils.copy(source, destination, new File(""), false); // if the target of the copy doesn't exist, then signal an error assertTrue("Unable to copy " + source + " to " + destination, destination.exists()); }
/** Creates the specified image descriptor and registers it */ private void createImageDescriptor(String id, ImageRegistry reg) { URL url = FileLocator.find(getBundle(), new Path(ProvUIImages.ICON_PATH + id), null); ImageDescriptor desc = ImageDescriptor.createFromURL(url); reg.put(id, desc); }