Example usage for org.eclipse.jdt.core.tests.util Util unzip

List of usage examples for org.eclipse.jdt.core.tests.util Util unzip

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.tests.util Util unzip.

Prototype

public static void unzip(String zipPath, String destDirPath) throws IOException 

Source Link

Document

Unzip the contents of the given zip in the given directory (create it if it doesn't exist)

Usage

From source file:dacapo.eclipse.EclipseTests.java

License:Open Source License

private static void unzipWorkspace(IWorkspace workspace, final IWorkspaceRoot workspaceRoot)
        throws IOException, CoreException {
    String fullSourceZipPath = getPluginDirectoryPath() + File.separator + "full-source-R3_0.zip";
    final String targetWorkspacePath = workspaceRoot.getLocation().toFile().getCanonicalPath();

    if (DEBUG)/* w w w  .  j  a v  a2 s . c o m*/
        System.out.print("Unzipping " + fullSourceZipPath + "...");
    Util.unzip(fullSourceZipPath, targetWorkspacePath);
    if (DEBUG)
        System.out.println("done!");

    createWorkspaceProjects(workspace, workspaceRoot);

}

From source file:org.eclipse.pde.api.tools.builder.tests.performance.PerformanceTest.java

License:Open Source License

/**
 * Creates the API baseline for this test.
 * //from   w  w w.  j a va2 s.  c o m
 * @throws Exception
 */
protected void createBaseline() throws Exception {
    String zipPath = getBaselineLocation();
    if (zipPath != null) {
        IApiBaselineManager manager = ApiPlugin.getDefault().getApiBaselineManager();
        IPath path = new Path(zipPath);
        String id = path.lastSegment();
        IApiBaseline perfline = manager.getApiBaseline(id);
        if (perfline == null) {
            // create the API baseline
            IPath baselineLocation = ApiTestsPlugin.getDefault().getStateLocation().append(id);
            long start = System.currentTimeMillis();
            System.out.println("Unzipping baseline: " + zipPath); //$NON-NLS-1$
            System.out.print("   in " + baselineLocation.toOSString() + "..."); //$NON-NLS-1$ //$NON-NLS-2$
            Util.unzip(zipPath, baselineLocation.toOSString());
            System.out.println(" done in " + (System.currentTimeMillis() - start) + "ms."); //$NON-NLS-1$ //$NON-NLS-2$

            perfline = ApiModelFactory.newApiBaseline(id);
            File[] files = baselineLocation.toFile().listFiles();
            IApiComponent[] components = new IApiComponent[files.length];
            for (int i = 0; i < files.length; i++) {
                IPath location = baselineLocation.append(files[i].getName());
                components[i] = ApiModelFactory.newApiComponent(perfline, location.toOSString());
            }
            perfline.addApiComponents(components);
            manager.addApiBaseline(perfline);
            System.out.println("Setting default baseline to be: " + perfline.getName()); //$NON-NLS-1$
            manager.setDefaultApiBaseline(perfline.getName());
        }
        IApiBaseline baseline = manager.getDefaultApiBaseline();
        if (baseline != perfline) {
            manager.setDefaultApiBaseline(perfline.getName());
        }
    }
}

From source file:org.eclipse.pde.api.tools.builder.tests.performance.PerformanceTest.java

License:Open Source License

/**
 * Creates the workspace by importing projects from the source zip. This is
 * the initial state of the workspace./* w  ww  . j  av  a2 s. c  om*/
 * 
 * @throws Exception
 */
protected void createInitialWorkspace() throws Exception {
    // Get workspace info
    IWorkspace workspace = ResourcesPlugin.getWorkspace();

    // Modify resources workspace preferences to avoid disturbing tests
    // while running them
    IEclipsePreferences resourcesPreferences = InstanceScope.INSTANCE.getNode(ResourcesPlugin.PI_RESOURCES);
    resourcesPreferences.put(ResourcesPlugin.PREF_AUTO_REFRESH, "false"); //$NON-NLS-1$

    // do not show the dialog if a build fails...will lock the workspace
    IEclipsePreferences antuiprefs = InstanceScope.INSTANCE.getNode("org.eclipse.ant.ui"); //$NON-NLS-1$
    antuiprefs.put("errorDialog", "false"); //$NON-NLS-1$ //$NON-NLS-2$

    workspace.getDescription().setSnapshotInterval(Long.MAX_VALUE);
    workspace.getDescription().setAutoBuilding(false);

    // Get projects directories
    long start = System.currentTimeMillis();
    String fullSourceZipPath = getWorkspaceLocation();
    IPath path = new Path(fullSourceZipPath);
    String dirName = path.lastSegment();
    String fileExtension = path.getFileExtension();
    dirName = dirName.substring(0, dirName.length() - fileExtension.length());
    IPath location = ApiTestsPlugin.getDefault().getStateLocation().append(dirName);
    File dir = location.toFile();
    if (dir.exists()) {
        deleteDir(dir);
    }
    dir.mkdirs();
    String targetWorkspacePath = location.toOSString();
    System.out.println("Unzipping " + fullSourceZipPath); //$NON-NLS-1$
    System.out.print("   in " + targetWorkspacePath + "..."); //$NON-NLS-1$ //$NON-NLS-2$
    Util.unzip(fullSourceZipPath, targetWorkspacePath);
    System.out.println(" done in " + (System.currentTimeMillis() - start) + "ms."); //$NON-NLS-1$ //$NON-NLS-2$

    start = System.currentTimeMillis();
    System.out.println("Importing projects... "); //$NON-NLS-1$
    File root = dir;
    File[] projects = root.listFiles();
    for (int i = 0; i < projects.length; i++) {
        System.out.println("\t" + projects[i].getName()); //$NON-NLS-1$
        createExistingProject(projects[i], true, false);
    }
    System.out.println(" done in " + (System.currentTimeMillis() - start) + "ms."); //$NON-NLS-1$ //$NON-NLS-2$
}