[143879] deletaeAllProjects now in runnable
diff --git a/tests/org.eclipse.wst.common.tests/commontests/org/eclipse/wst/common/tests/ProjectUtility.java b/tests/org.eclipse.wst.common.tests/commontests/org/eclipse/wst/common/tests/ProjectUtility.java
index dc4c90a..4015f04 100644
--- a/tests/org.eclipse.wst.common.tests/commontests/org/eclipse/wst/common/tests/ProjectUtility.java
+++ b/tests/org.eclipse.wst.common.tests/commontests/org/eclipse/wst/common/tests/ProjectUtility.java
@@ -13,8 +13,11 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin;
@@ -82,52 +85,72 @@
public static void deleteAllProjects() throws Exception {
//closing projects and tread work in here is a hack because of a BeanInfo bug holding
//onto jars loaded in another VM
- IProject[] projects = getAllProjects();
+
// for (int i = 0; i < projects.length; i++) {
// if (projects[i].exists()) {
// projects[i].close(null); // This should signal the extra VM to kill itself
// }
// }
// Thread.yield(); // give the VM a chance to die
- for (int i = 0; i < projects.length; i++) {
- IProject project = projects[i];
- boolean success = false;
- Exception lastException = null;
- //Don't make 2^12 is about 4 seconds which is the max we will wait for the VM to die
- for (int j = 0; j < 13 && !success; j++) {
- try {
- if (project.exists()) {
- project.delete(true, true, null);
- ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, null);
- }
- success = true;
- } catch (Exception e) {
- lastException = e;
- if (project.exists()) {
- try{
- project.close(null);
- project.open(null);
- } catch(Exception e2){
- }
- }
- Thread.sleep((int) Math.pow(2, j)); // if the VM isn't dead, try sleeping
- }
- }
- if (!success && lastException != null) {
- Logger.getLogger().log("Problem while deleting: " + lastException.getMessage());
- //Assert.fail("Caught Exception=" + lastException.getMessage() + " when deleting project=" + project.getName());
- }
- }
+ IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
+
+ public void run(IProgressMonitor monitor) {
+ IProject[] projects = getAllProjects();
+ for (int i = 0; i < projects.length; i++) {
+ IProject project = projects[i];
+ boolean success = false;
+ Exception lastException = null;
+ // Don't make 2^12 is about 4 seconds which is the max we
+ // will wait for the VM to die
+ for (int j = 0; j < 13 && !success; j++) {
+ try {
+ if (project.exists()) {
+ project.delete(true, true, null);
+ ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, null);
+ }
+ success = true;
+ } catch (Exception e) {
+ lastException = e;
+ if (project.exists()) {
+ try {
+ project.close(null);
+ project.open(null);
+ } catch (Exception e2) {
+ }
+ }
+ try {
+ Thread.sleep((int) Math.pow(2, j));
+ } catch (InterruptedException e1) {
+ } // if the VM
+ // isn't dead,
+ // try sleeping
+ }
+ }
+ if (!success && lastException != null) {
+ Logger.getLogger().log("Problem while deleting: " + lastException.getMessage());
+ // Assert.fail("Caught Exception=" +
+ // lastException.getMessage() + " when deleting
+ // project=" + project.getName());
+ }
+ }
+ }
+ };
+ try {
+ ResourcesPlugin.getWorkspace().run(runnable, null);
+ } catch (CoreException ce) {
+ }
verifyNoProjects();
}
/**
- * Return the absolute path Strings to the files based on the fileSuffix and path within the plugin.
- *
- * @param path
- * @param fileSuffix
- * the file ending with the "." if required (the suffix will be used as is)
- * @return
- */
+ * Return the absolute path Strings to the files based on the fileSuffix and
+ * path within the plugin.
+ *
+ * @param path
+ * @param fileSuffix
+ * the file ending with the "." if required (the suffix will be
+ * used as is)
+ * @return
+ */
public static List getSpecificFilesInDirectory(Plugin plugin, String path, final String fileSuffix) {
URL entry = null;
entry = plugin.getBundle().getEntry(path);