diff --git a/net.sourceforge.pmd.eclipse.plugin.test/src/main/java/net/sourceforge/pmd/eclipse/EclipseUtils.java b/net.sourceforge.pmd.eclipse.plugin.test/src/main/java/net/sourceforge/pmd/eclipse/EclipseUtils.java index cfd144580..63753d629 100644 --- a/net.sourceforge.pmd.eclipse.plugin.test/src/main/java/net/sourceforge/pmd/eclipse/EclipseUtils.java +++ b/net.sourceforge.pmd.eclipse.plugin.test/src/main/java/net/sourceforge/pmd/eclipse/EclipseUtils.java @@ -39,6 +39,7 @@ import net.sourceforge.pmd.eclipse.runtime.PMDRuntimeConstants; import net.sourceforge.pmd.eclipse.runtime.builder.PMDNature; +import net.sourceforge.pmd.eclipse.runtime.cmd.ReviewCodeCmd; import net.sourceforge.pmd.lang.rule.Rule; import net.sourceforge.pmd.properties.PropertyDescriptor; @@ -365,17 +366,18 @@ public static void createFolders(IProject testProject, String fullpath) throws C public static void waitForPMDJobs() throws InterruptedException { long start = System.currentTimeMillis(); - while (hasPMDJob(Job.getJobManager().find(null))) { + String jobName = new ReviewCodeCmd().getName(); + while (hasPMDJob(Job.getJobManager().find(null), jobName)) { Thread.sleep(500); - if (System.currentTimeMillis() - start > TimeUnit.SECONDS.toMillis(30)) { - Assert.fail("Timeout while waiting for Jobs to finish"); + if (System.currentTimeMillis() - start > TimeUnit.MINUTES.toMillis(1)) { + Assert.fail("Timeout while waiting for Job " + jobName + " to finish"); } } } - private static boolean hasPMDJob(Job[] jobs) { + private static boolean hasPMDJob(Job[] jobs, String jobName) { for (Job job : jobs) { - if (job.getClass().getName().startsWith("net.sourceforge.pmd.eclipse.runtime.cmd.JobCommandProcessor")) { + if (job.getName().equals(jobName)) { return true; } } diff --git a/net.sourceforge.pmd.eclipse.plugin.test/src/main/java/net/sourceforge/pmd/eclipse/ui/dialogs/ViolationDetailsDialogTest.java b/net.sourceforge.pmd.eclipse.plugin.test/src/main/java/net/sourceforge/pmd/eclipse/ui/dialogs/ViolationDetailsDialogTest.java index 3293dbedd..9a01464c3 100644 --- a/net.sourceforge.pmd.eclipse.plugin.test/src/main/java/net/sourceforge/pmd/eclipse/ui/dialogs/ViolationDetailsDialogTest.java +++ b/net.sourceforge.pmd.eclipse.plugin.test/src/main/java/net/sourceforge/pmd/eclipse/ui/dialogs/ViolationDetailsDialogTest.java @@ -16,7 +16,6 @@ import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.swt.widgets.Display; import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView; -import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException; import org.eclipse.swtbot.swt.finder.waits.DefaultCondition; import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; import org.eclipse.swtbot.swt.finder.widgets.SWTBotTableItem; @@ -85,24 +84,6 @@ public void openDialogViaProblemView() throws Exception { SWTBotView problemsView = bot.viewByPartName("Problems"); String markerText = "UnnecessaryModifier: Unnecessary modifier 'public' on method 'run': the method is declared in an interface type"; - - problemsView.bot().waitUntil(new DefaultCondition() { - @Override - public boolean test() throws Exception { - try { - SWTBotTreeItem item = bot.tree().getTreeItem("Warnings (4 items)").expand(); - item.getNode(markerText); - } catch (WidgetNotFoundException e) { - return false; - } - return true; - } - - @Override - public String getFailureMessage() { - return "Marker not found"; - } - }); SWTBotTreeItem item = problemsView.bot().tree().getTreeItem("Warnings (4 items)").expand(); SWTBotTreeItem markerItem = item.getNode(markerText).select(); markerItem.contextMenu("Show details...").click(); @@ -114,7 +95,7 @@ public String getFailureMessage() { public void openDialogViaViolationOutlineView() throws Exception { buildAndWaitForViolations(); openPMDPerspective(); - + SWTBotTree projectTree = bot.viewByPartName("Package Explorer").bot().tree(); SWTBotTreeItem item = projectTree.getTreeItem("ViolationDetailsDialogTest").expand(); item = item.getNode("src").expand(); @@ -139,8 +120,9 @@ private void assertDialog() { assertEquals("Unnecessary modifier 'public' on method 'run': the method is declared in an interface type", message); } - private void buildAndWaitForViolations() throws CoreException { + private void buildAndWaitForViolations() throws CoreException, InterruptedException { testProject.build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor()); + EclipseUtils.waitForPMDJobs(); bot.waitUntil(new DefaultCondition() { @Override