|
Lines 20-26
Link Here
|
| 20 |
import org.eclipse.mylyn.hudson.tests.support.HudsonFixture; |
20 |
import org.eclipse.mylyn.hudson.tests.support.HudsonFixture; |
| 21 |
import org.eclipse.mylyn.internal.hudson.core.client.HudsonException; |
21 |
import org.eclipse.mylyn.internal.hudson.core.client.HudsonException; |
| 22 |
import org.eclipse.mylyn.internal.hudson.core.client.RestfulHudsonClient; |
22 |
import org.eclipse.mylyn.internal.hudson.core.client.RestfulHudsonClient; |
|
|
23 |
import org.eclipse.mylyn.internal.hudson.model.HudsonModelBallColor; |
| 23 |
import org.eclipse.mylyn.internal.hudson.model.HudsonModelJob; |
24 |
import org.eclipse.mylyn.internal.hudson.model.HudsonModelJob; |
|
|
25 |
import org.eclipse.mylyn.tests.util.TestUtil; |
| 26 |
import org.eclipse.mylyn.tests.util.TestUtil.Credentials; |
| 27 |
import org.eclipse.mylyn.tests.util.TestUtil.PrivilegeLevel; |
| 24 |
|
28 |
|
| 25 |
/** |
29 |
/** |
| 26 |
* Test cases for {@link RestfulHudsonClient}. |
30 |
* Test cases for {@link RestfulHudsonClient}. |
|
Lines 60-69
Link Here
|
| 60 |
} |
64 |
} |
| 61 |
} |
65 |
} |
| 62 |
|
66 |
|
| 63 |
public void testGetPlans() throws Exception { |
67 |
public void testGetJobs() throws Exception { |
| 64 |
client = fixture.connect(); |
68 |
client = fixture.connect(); |
| 65 |
List<HudsonModelJob> plans = client.getJobs(null); |
69 |
List<HudsonModelJob> jobs = client.getJobs(null); |
| 66 |
assertEquals(plans.get(0).getName(), "failing"); |
70 |
assertEquals(jobs.get(0).getName(), "failing"); |
|
|
71 |
} |
| 72 |
|
| 73 |
public void testRunBuild() throws Exception { |
| 74 |
Credentials credentials = TestUtil.readCredentials(PrivilegeLevel.USER); |
| 75 |
|
| 76 |
client = fixture.connect(HudsonFixture.HUDSON_TEST_URL, credentials.username, credentials.password); |
| 77 |
|
| 78 |
// failing build |
| 79 |
client.runBuild(getJob("failing"), ProgressUtil.convert(null)); |
| 80 |
assertEquals(getJob("failing").getColor(), HudsonModelBallColor.RED_ANIME); |
| 81 |
Thread.sleep(1000); |
| 82 |
assertEquals(getJob("succeeding").getColor(), HudsonModelBallColor.RED); |
| 83 |
|
| 84 |
// succeeding build |
| 85 |
client.runBuild(getJob("succeeding"), ProgressUtil.convert(null)); |
| 86 |
assertEquals(getJob("succeeding").getColor(), HudsonModelBallColor.BLUE_ANIME); |
| 87 |
Thread.sleep(1000); |
| 88 |
assertEquals(getJob("succeeding").getColor(), HudsonModelBallColor.BLUE); |
| 89 |
} |
| 90 |
|
| 91 |
private HudsonModelJob getJob(String name) throws HudsonException { |
| 92 |
for (HudsonModelJob job : client.getJobs(null)) { |
| 93 |
if (job.getName().equals(name)) { |
| 94 |
return job; |
| 95 |
} |
| 96 |
} |
| 97 |
return null; |
| 67 |
} |
98 |
} |
| 68 |
|
99 |
|
| 69 |
} |
100 |
} |