Author: dgolovin
Date: 2008-09-23 19:36:58 -0400 (Tue, 23 Sep 2008)
New Revision: 10439
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/XJob.java
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/project/facet/AbstractSeamFacetTest.java
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/view/SeamComponentsViewTest.java
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/AbstractSeamNewOperationTest.java
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/OpenSeamComponentDialogTest.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/TestUtil.java
Log:
XJob migrated to WorkspaceJob, auto build disabled before deleting projects
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/XJob.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/XJob.java 2008-09-23
21:00:19 UTC (rev 10438)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/XJob.java 2008-09-23
23:36:58 UTC (rev 10439)
@@ -13,6 +13,8 @@
import java.util.*;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.resources.WorkspaceJob;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -24,7 +26,7 @@
import org.jboss.tools.common.model.plugin.ModelPlugin;
import org.osgi.framework.Bundle;
-public class XJob extends Job {
+public class XJob extends WorkspaceJob {
public static Object FAMILY_XJOB = new Object();
public interface XRunnable extends Runnable {
@@ -103,27 +105,6 @@
public boolean belongsTo(Object family) {
return family == FAMILY_XJOB;
}
-
- protected IStatus run(IProgressMonitor monitor) {
- while(true) {
- XRunnable r = null;
- synchronized (this) {
- if(list.size() == 0) break;
- r = list.remove(0);
- }
- monitor.subTask(r.getId());
- int state = 0;
- Bundle b = Platform.getBundle("org.jboss.tools.common.model");
- state = b==null ? -1 : b.getState();
- if(state == Bundle.ACTIVE) {
- r.run();
- }
- synchronized (this) {
- ids.remove(r.getId());
- }
- }
- return Status.OK_STATUS;
- }
void addRunnableInternal(XRunnable runnable) {
synchronized (this) {
@@ -147,4 +128,27 @@
}
}
+ @Override
+ public IStatus runInWorkspace(IProgressMonitor monitor)
+ throws CoreException {
+ while(true) {
+ XRunnable r = null;
+ synchronized (this) {
+ if(list.size() == 0) break;
+ r = list.remove(0);
+ }
+ monitor.subTask(r.getId());
+ int state = 0;
+ Bundle b = Platform.getBundle("org.jboss.tools.common.model");
+ state = b==null ? -1 : b.getState();
+ if(state == Bundle.ACTIVE) {
+ r.run();
+ }
+ synchronized (this) {
+ ids.remove(r.getId());
+ }
+ }
+ return Status.OK_STATUS;
+ }
+
}
Modified:
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/project/facet/AbstractSeamFacetTest.java
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/project/facet/AbstractSeamFacetTest.java 2008-09-23
21:00:19 UTC (rev 10438)
+++
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/project/facet/AbstractSeamFacetTest.java 2008-09-23
23:36:58 UTC (rev 10439)
@@ -11,8 +11,11 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceDescription;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
import org.eclipse.wst.common.project.facet.core.IFacetedProject;
import org.eclipse.wst.common.project.facet.core.IProjectFacet;
@@ -24,7 +27,6 @@
import org.jboss.tools.seam.core.project.facet.SeamVersion;
import org.jboss.tools.seam.internal.core.project.facet.ISeamFacetDataModelProperties;
import
org.jboss.tools.seam.internal.core.project.facet.SeamFacetInstallDataModelProvider;
-import org.jboss.tools.seam.internal.core.project.facet.SeamFacetPreInstallDelegate;
import org.jboss.tools.test.util.xpl.EditorTestHelper;
/**
@@ -52,6 +54,8 @@
protected static final IProjectFacetVersion javaFacesVersion;
private static final IProjectFacet seamFacet;
+
+ private static final long MAX_IDLE = 30*60*1000L;
static {
seamFacet = ProjectFacetsManager.getProjectFacet("jst.seam");
@@ -94,28 +98,45 @@
throws Exception
{
+
// Wait until all jobs is finished to avoid delete project problems
- EditorTestHelper.joinBackgroundActivities();
- EditorTestHelper.runEventQueue(3000);
+
+ ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, null);
+ waitForIdle();
+ boolean oldAutoBuilding = true;
Exception last = null;
- for (IResource r : this.resourcesToCleanup) {
- try {
- System.out.println("Deleting " + r);
- r.delete(true, null);
- } catch(Exception e) {
- System.out.println("Error deleting " + r);
- e.printStackTrace();
- last = e;
+ try {
+ oldAutoBuilding = setAutoBuilding(false);
+ for (IResource r : this.resourcesToCleanup) {
+ try {
+ System.out.println("Deleting " + r);
+ r.delete(true, null);
+ } catch(Exception e) {
+ System.out.println("Error deleting " + r);
+ e.printStackTrace();
+ last = e;
+ }
}
- }
- for (Runnable runnable : this.tearDownOperations) {
- runnable.run();
+ for (Runnable runnable : this.tearDownOperations) {
+ runnable.run();
+ }
+ } finally {
+ setAutoBuilding(oldAutoBuilding);
}
if(last!=null) throw last;
}
+ public static void waitForIdle() {
+ long start = System.currentTimeMillis();
+ while (!EditorTestHelper.allJobsQuiet()) {
+ delay(500);
+ if ( (System.currentTimeMillis()-start) > MAX_IDLE )
+ throw new RuntimeException("A long running task detected"); //$NON-NLS-1$
+ }
+ }
+
protected final void addResourceToCleanup(final IResource resource) {
this.resourcesToCleanup.add(resource);
}
@@ -242,4 +263,36 @@
}
+ protected boolean setAutoBuilding(boolean state) throws CoreException {
+ boolean oldAutoBuilding;
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ IWorkspaceDescription description = workspace.getDescription();
+ oldAutoBuilding = description.isAutoBuilding();
+ if (state != oldAutoBuilding) {
+ description.setAutoBuilding(state);
+ workspace.setDescription(description);
+ }
+ return oldAutoBuilding;
+ }
+
+ public static void delay(long waitTimeMillis) {
+ Display display = Display.getCurrent();
+ if (display != null) {
+ long endTimeMillis = System.currentTimeMillis() + waitTimeMillis;
+ while (System.currentTimeMillis() < endTimeMillis) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.update();
+ }
+ // Otherwise, perform a simple sleep.
+ else {
+ try {
+ Thread.sleep(waitTimeMillis);
+ } catch (InterruptedException e) {
+ // Ignored.
+ }
+ }
+ }
+
}
\ No newline at end of file
Modified:
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/view/SeamComponentsViewTest.java
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/view/SeamComponentsViewTest.java 2008-09-23
21:00:19 UTC (rev 10438)
+++
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/view/SeamComponentsViewTest.java 2008-09-23
23:36:58 UTC (rev 10439)
@@ -18,9 +18,11 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
@@ -56,10 +58,11 @@
project =
(IProject)ResourcesPlugin.getWorkspace().getRoot().findMember("TestComponentView");
assertNotNull("",project);
-
- componentsFile = project.getFile("WebContent/WEB-INF/components.xml");
+ this.project.refreshLocal(IResource.DEPTH_INFINITE, null);
+ componentsFile = project.getFile(new
Path("WebContent/WEB-INF/components.xml"));
assertTrue("Cannot find components.xml in test project", componentsFile !=
null && componentsFile.exists());
+ this.project.build(IncrementalProjectBuilder.FULL_BUILD, null);
EditorTestHelper.joinBackgroundActivities();
}
Modified:
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/AbstractSeamNewOperationTest.java
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/AbstractSeamNewOperationTest.java 2008-09-23
21:00:19 UTC (rev 10438)
+++
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/AbstractSeamNewOperationTest.java 2008-09-23
23:36:58 UTC (rev 10439)
@@ -195,8 +195,8 @@
* Test Seam Action for
http://jira.jboss.com/jira/browse/JBIDE-2004
*/
public void testNewSeamActionOperation() {
- try { EditorTestHelper.joinBackgroundActivities(); }
- catch (Exception e) { JUnitUtils.fail(e.getMessage(), e); }
+// try { EditorTestHelper.joinBackgroundActivities(); }
+// catch (Exception e) { JUnitUtils.fail(e.getMessage(), e); }
assertProjectsAreCreated();
@@ -208,11 +208,11 @@
registry.fillDataDefaults(SEAM_ACTION_COMPONENT_NAME, getProject().getName());
performOperation(CREATE_SEAM_ACTION, registry);
- try {
- EditorTestHelper.joinBackgroundActivities();
- } catch (Exception e) {
- JUnitUtils.fail(e.getMessage(), e);
- }
+// try {
+// EditorTestHelper.joinBackgroundActivities();
+// } catch (Exception e) {
+// JUnitUtils.fail(e.getMessage(), e);
+// }
assertNewActionFilesAreCreatedSuccessfully(registry);
}
@@ -221,11 +221,11 @@
* Test Seam Form for
http://jira.jboss.com/jira/browse/JBIDE-2004
*/
public void testNewSeamFormOperation() {
- try {
- EditorTestHelper.joinBackgroundActivities();
- } catch (Exception e) {
- JUnitUtils.fail(e.getMessage(), e);
- }
+// try {
+// EditorTestHelper.joinBackgroundActivities();
+// } catch (Exception e) {
+// JUnitUtils.fail(e.getMessage(), e);
+// }
assertProjectsAreCreated();
setUpSeamProjects();
@@ -234,11 +234,11 @@
registry.createData();
registry.fillDataDefaults(SEAM_FORM_COMPONENT_NAME, getProject().getName());
performOperation(CREATE_SEAM_FORM, registry);
- try {
- EditorTestHelper.joinBackgroundActivities();
- } catch (Exception e) {
- JUnitUtils.fail(e.getMessage(), e);
- }
+// try {
+// EditorTestHelper.joinBackgroundActivities();
+// } catch (Exception e) {
+// JUnitUtils.fail(e.getMessage(), e);
+// }
assertNewFormFilesAreCreatedSuccessfully(registry);
}
@@ -246,11 +246,11 @@
* Test Seam Action for
http://jira.jboss.com/jira/browse/JBIDE-2004
*/
public void testNewSeamConversationOperation() {
- try {
- EditorTestHelper.joinBackgroundActivities();
- } catch (Exception e) {
- JUnitUtils.fail(e.getMessage(), e);
- }
+// try {
+// EditorTestHelper.joinBackgroundActivities();
+// } catch (Exception e) {
+// JUnitUtils.fail(e.getMessage(), e);
+// }
assertProjectsAreCreated();
setUpSeamProjects();
@@ -259,11 +259,11 @@
registry.createData();
registry.fillDataDefaults(SEAM_CONVERSATION_COMPONENT_NAME, getProject().getName());
performOperation(CREATE_SEAM_CONVERSATION, registry);
- try {
- EditorTestHelper.joinBackgroundActivities();
- } catch (Exception e) {
- JUnitUtils.fail(e.getMessage(), e);
- }
+// try {
+// EditorTestHelper.joinBackgroundActivities();
+// } catch (Exception e) {
+// JUnitUtils.fail(e.getMessage(), e);
+// }
assertNewConversationFilesAreCreatedSuccessfully(registry);
}
@@ -272,11 +272,11 @@
* Test Seam Action for
http://jira.jboss.com/jira/browse/JBIDE-2004
*/
public void testNewSeamEntityOperation() {
- try {
- EditorTestHelper.joinBackgroundActivities();
- } catch (Exception e) {
- JUnitUtils.fail(e.getMessage(), e);
- }
+// try {
+// EditorTestHelper.joinBackgroundActivities();
+// } catch (Exception e) {
+// JUnitUtils.fail(e.getMessage(), e);
+// }
assertProjectsAreCreated();
@@ -292,11 +292,11 @@
registry.createData();
registry.fillDataDefaults(SEAM_ENTITY_COMPONENT_NAME, getProject().getName());
performOperation(CREATE_SEAM_ENTITY, registry);
- try {
- EditorTestHelper.joinBackgroundActivities();
- } catch (Exception e) {
- JUnitUtils.fail(e.getMessage(), e);
- }
+// try {
+// EditorTestHelper.joinBackgroundActivities();
+// } catch (Exception e) {
+// JUnitUtils.fail(e.getMessage(), e);
+// }
assertNewEntityFilesAreCreatedSuccessfully(registry);
}
Modified:
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/OpenSeamComponentDialogTest.java
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/OpenSeamComponentDialogTest.java 2008-09-23
21:00:19 UTC (rev 10438)
+++
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/OpenSeamComponentDialogTest.java 2008-09-23
23:36:58 UTC (rev 10439)
@@ -13,6 +13,9 @@
import junit.framework.TestCase;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceDescription;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -32,7 +35,7 @@
@Override
protected void setUp() throws Exception {
super.setUp();
-
+
project =
(IProject)ResourcesPlugin.getWorkspace().getRoot().findMember("TestComponentView");
if(project == null) {
ProjectImportTestSetup setup = new ProjectImportTestSetup(
@@ -41,6 +44,7 @@
"projects/TestComponentView",
"TestComponentView");
project = setup.importProject();
+ this.project.refreshLocal(IResource.DEPTH_INFINITE, null);
}
this.project = project.getProject();
this.project.build(IncrementalProjectBuilder.FULL_BUILD, null);
@@ -71,7 +75,6 @@
//JBIDE-1879
public void testFindShortHand() {
-
find("o*jbpm", "org.jboss.seam.core.jbpm", true);
find("jbpm", "org.jboss.seam.core.jbpm", false);
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/TestUtil.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/TestUtil.java 2008-09-23
21:00:19 UTC (rev 10438)
+++
trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/TestUtil.java 2008-09-23
23:36:58 UTC (rev 10439)
@@ -103,7 +103,7 @@
.getActiveWorkbenchWindow().getShell());
// run import
- importOp.run(new NullProgressMonitor());
+ importOp.run(null);
} catch (InvocationTargetException ite) {
VPETestPlugin.getDefault().logError(ite.getCause());