File D:\maven-qcr-plugin-testsunitaires\qcr4java\jenkins-master\target\site\qc\test\src\test\java\hudson\model\queue\QueueTaskDispatcherTest.java.html

1 package hudson.model.queue;
2
3 import hudson.model.FreeStyleProject;
4 import hudson.model.Queue.Item;
5
6 import org.jvnet.hudson.test.HudsonTestCase;
7 import org.jvnet.hudson.test.TestExtension;
8
9 public class QueueTaskDispatcherTest extends HudsonTestCase {
10
11 @SuppressWarnings("deprecation")
12 public void testCanRunBlockageIsDisplayed() throws Exception {
13 FreeStyleProject project = createFreeStyleProject();
14 jenkins.getQueue().schedule(project);
15
16 Item item = jenkins.getQueue().getItem(project);
17 for (int i = 0; i < 4 * 60 && !item.isBlocked(); i++) {
18 Thread.sleep(250);
19 item = jenkins.getQueue().getItem(project);
20 }
21 assertTrue("Not blocked after 60 seconds", item.isBlocked());
22 assertEquals("Expected CauseOfBlockage to be returned", "blocked by canRun", item.getWhy());
23 }
24
25 @TestExtension
26 public static class MyQueueTaskDispatcher extends QueueTaskDispatcher {
27 @Override
28 public CauseOfBlockage canRun(Item item) {
29 return new CauseOfBlockage() {
30 @Override
31 public String getShortDescription() {
32 return "blocked by canRun";
33 }
34 };
35 }
36 }
37 }
38