Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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
Expand Down
Loading