[jbosstools-commits] JBoss Tools SVN: r42720 - trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Wed Jul 25 15:57:33 EDT 2012
Author: vpakan at redhat.com
Date: 2012-07-25 15:57:33 -0400 (Wed, 25 Jul 2012)
New Revision: 42720
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTUtilExt.java
Log:
Added methods waiting also for sleeping jobs.
Modified: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTUtilExt.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTUtilExt.java 2012-07-25 19:20:53 UTC (rev 42719)
+++ trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTUtilExt.java 2012-07-25 19:57:33 UTC (rev 42720)
@@ -202,32 +202,50 @@
/**
* Wait for named running jobs with defined TIMEOUT
+ * @param jobNames
*/
public void waitForJobs(String... jobNames) {
- waitForJobs(TIMEOUT, jobNames);
+ waitForJobs(false,TIMEOUT, jobNames);
}
+ /**
+ * Wait for named running jobs with defined TIMEOUT
+ *
+ * @param timeout
+ * @param jobNames
+ */
+ public void waitForJobs(long timeout ,String... jobNames) {
+ waitForJobs(false,timeout, jobNames);
+ }
+
/**
* Wait for all running jobs not named in JobList.ignoredJobs
*
* @param timeOut
*/
public void waitForNonIgnoredJobs(long timeOut) {
- waitForAllExcept(timeOut, JobLists.ignoredJobs);
+ waitForAllExcept(false,timeOut, JobLists.ignoredJobs);
}
-
+ /**
+ * Wait for all running jobs not named in JobList.ignoredJobs
+ *
+ * @param timeOut
+ */
+ public void waitForNonIgnoredJobs(boolean includeSleepingJobs,long timeOut) {
+ waitForAllExcept(includeSleepingJobs,timeOut, JobLists.ignoredJobs);
+ }
/**
* Wait for all running jobs not named in JobList.ignoredJobs
*/
public void waitForNonIgnoredJobs() {
- waitForAllExcept(TIMEOUT, JobLists.ignoredJobs);
+ waitForAllExcept(false, TIMEOUT, JobLists.ignoredJobs);
}
/**
* Wait for all running jobs
*/
public void waitForAll(long timeOut) {
- waitForAllExcept(timeOut, new String[0]);
+ waitForAll(false , timeOut);
}
/**
@@ -236,16 +254,50 @@
* @param timeOut
*/
public void waitForAll() {
- waitForAllExcept(TIMEOUT, new String[0]);
+ waitForAll(false, TIMEOUT);
}
-
+ /**
+ * Wait for all running jobs
+ *
+ * @param includeSleepingJobs
+ */
+ public void waitForAll(boolean includeSleepingJobs) {
+ waitForAll(includeSleepingJobs,TIMEOUT);
+ }
+ /**
+ * Wait for all running jobs
+ *
+ * @param includeSleepingJobs
+ * @param timeout
+ */
+ public void waitForAll(boolean includeSleepingJobs , long timeout) {
+ waitForAllExcept(includeSleepingJobs,timeout, new String[0]);
+ }
+ /**
+ * Wait for all running jobs except named jobs
+ *
+ * @param timeOut
+ * @param jobNames
+ */
+ public void waitForAllExcept(long timeOut, String... jobNames) {
+ waitForAllExcept(false, timeOut,jobNames);
+ }
+ /**
+ * Wait for all running jobs except named jobs
+ *
+ * @param jobNames
+ */
+ public void waitForAllExcept(String... jobNames) {
+ waitForAllExcept(false, TIMEOUT,jobNames);
+ }
/**
* Wait for all running jobs except named jobs
*
+ * @param includeSleepingJobs
* @param timeOut
* @param jobNames
*/
- public void waitForAllExcept(long timeOut, String... jobNames) {
+ public void waitForAllExcept(boolean includeSleepingJobs , long timeOut, String... jobNames) {
// Find all jobs
Job[] jobs = Job.getJobManager().find(null);
@@ -267,16 +319,17 @@
names[i] = listNames.get(i);
}
- waitForJobs(timeOut, names);
+ waitForJobs(includeSleepingJobs,timeOut, names);
}
/**
* Waits for selected job
*
+ * @param includeSleepingJobs
* @param timeOut
* @param jobNames
*/
- public void waitForJobs(long timeOut, String... jobNames) {
+ public void waitForJobs(boolean includeSleepingJobs,long timeOut, String... jobNames) {
// DEBUG
printRunningJobs();
@@ -298,6 +351,10 @@
log.info("Blocking job " + jobName + " found");
blockingJobs.add(jobName);
}
+ else if (includeSleepingJobs && isJobSleeping(jobName)) {
+ log.info("Blocking sleeping job " + jobName + " found");
+ blockingJobs.add(jobName);
+ }
}
// Wait until all blocking jobs aren't finished or timeout
@@ -340,6 +397,24 @@
return false;
}
+ /**
+ * Search for jobname in JobManager job list
+ *
+ * @param jobName
+ * name of the job
+ * @return true if job with corresponding name found, else false
+ */
+ private boolean isJobSleeping(String jobName) {
+ Job[] jobs = Job.getJobManager().find(null);
+ for (Job job : jobs) {
+ if ((jobName.equalsIgnoreCase(job.getName()))
+ && (job.getState() == JobState.SLEEPING)){
+ return true;
+ }
+ }
+ return false;
+ }
+
public void printRunningJobs() {
Job[] jobs = Job.getJobManager().find(null);
for (Job job : jobs) {
More information about the jbosstools-commits
mailing list