/* * Set up the platform binary download and get it ready to run the tests. * This method is not intended to be called by clients, it will be called * automatically when the clients use a ReconcilerTestSuite. If the executable isn't * found on the file-system after the call, then we fail. */ public void initialize() throws Exception { initialized = false; File file = getPlatformZip(); output = getUniqueFolder(); toRemove.add(output); // for now we will exec to un-tar archives to keep the executable bits if (file.getName().toLowerCase().endsWith(".zip")) { try { FileUtils.unzipFile(file, output); } catch (IOException e) { fail("0.99", e); } } else { untar("1.0", file); } File exe = new File(output, getExeFolder() + "eclipse.exe"); if (!exe.exists()) { exe = new File(output, getExeFolder() + "eclipse"); if (!exe.exists()) fail( "Executable file: " + exe.getAbsolutePath() + "(or .exe) not found after extracting: " + file.getAbsolutePath() + " to: " + output); } initialized = true; }
/* * Untar the given file in the output directory. */ private void untar(String message, File file) { String name = file.getName(); File gzFile = new File(output, name); output.mkdirs(); run(message, new String[] {"cp", file.getAbsolutePath(), gzFile.getAbsolutePath()}); run(message, new String[] {"tar", "-zpxf", gzFile.getAbsolutePath()}); gzFile.delete(); }
/* * Add the given bundle to the given folder (do a copy). * The folder can be one of dropins, plugins or features. * If the file handle points to a directory, then do a deep copy. */ public void add(String message, String target, File file) { if (!(target.startsWith("dropins") || target.startsWith("plugins") || target.startsWith("features"))) fail( "Destination folder for resource copying should be either dropins, plugins or features."); File destinationParent = new File(output, getRootFolder() + target); destinationParent.mkdirs(); copy(message, file, new File(destinationParent, file.getName())); }
/* * 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()); }