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

1 package hudson.maven;
2
3 import org.jvnet.hudson.test.ExtractResourceSCM;
4 import org.jvnet.hudson.test.HudsonTestCase;
5
6 /**
7 * Tests that Maven jobs are triggered, when snapshot dependencies of them were build.
8 *
9 * @author Andrew Bayer
10 */
11 public class MavenSnapshotTriggerTest extends HudsonTestCase {
12 /**
13 * Verifies dependency build ordering of SNAPSHOT dependency.
14 * Note - has to build the projects once each first in order to get dependency info.
15 */
16 public void testSnapshotDependencyBuildTrigger() throws Exception {
17
18 configureDefaultMaven();
19 MavenModuleSet projA = createMavenProject("snap-dep-test-up");
20 projA.setGoals("clean install");
21 projA.setScm(new ExtractResourceSCM(getClass().getResource("maven-dep-test-A.zip")));
22 MavenModuleSet projB = createMavenProject("snap-dep-test-down");
23 projB.setGoals("clean install");
24 projB.setIgnoreUpstremChanges(false);
25 projB.setQuietPeriod(0);
26 projB.setScm(new ExtractResourceSCM(getClass().getResource("maven-dep-test-B.zip")));
27
28 buildAndAssertSuccess(projA);
29 buildAndAssertSuccess(projB);
30
31 projA.setScm(new ExtractResourceSCM(getClass().getResource("maven-dep-test-A-changed.zip")));
32 buildAndAssertSuccess(projA);
33
34 // at this point runB2 should be in the queue, so wait until that completes.
35 waitUntilNoActivityUpTo(90*1000);
36 assertEquals("Expected most recent build of second project to be #2", 2, projB.getLastBuild().getNumber());
37 }
38
39 /**
40 * Verifies dependency build ordering of multiple SNAPSHOT dependencies.
41 * Note - has to build the projects once each first in order to get dependency info.
42 * B depends on A, C depends on A and B. Build order should be A->B->C.
43 */
44 public void testMixedTransitiveSnapshotTrigger() throws Exception {
45 configureDefaultMaven();
46
47 MavenModuleSet projA = createMavenProject("snap-dep-test-up");
48 projA.setGoals("clean install");
49 projA.setScm(new ExtractResourceSCM(getClass().getResource("maven-dep-test-A.zip")));
50
51 MavenModuleSet projB = createMavenProject("snap-dep-test-mid");
52 projB.setGoals("clean install");
53 projB.setIgnoreUpstremChanges(false);
54 projB.setQuietPeriod(0);
55 projB.setScm(new ExtractResourceSCM(getClass().getResource("maven-dep-test-B.zip")));
56
57 MavenModuleSet projC = createMavenProject("snap-dep-test-down");
58 projC.setGoals("clean install");
59 projC.setIgnoreUpstremChanges(false);
60 projC.setQuietPeriod(0);
61 projC.setScm(new ExtractResourceSCM(getClass().getResource("maven-dep-test-C.zip")));
62
63 buildAndAssertSuccess(projA);
64 buildAndAssertSuccess(projB);
65 buildAndAssertSuccess(projC);
66
67 projA.setScm(new ExtractResourceSCM(getClass().getResource("maven-dep-test-A-changed.zip")));
68
69 buildAndAssertSuccess(projA);
70
71 waitUntilNoActivityUpTo(90*1000); // wait until dependency build trickles down
72 assertEquals("Expected most recent build of second project to be #2", 2, projB.getLastBuild().getNumber());
73 assertEquals("Expected most recent build of third project to be #2", 2, projC.getLastBuild().getNumber());
74 }
75 }
76