server.stop();
}
}
public void testFoldableCauseAction() throws Exception {
final OneShotEvent buildStarted = new OneShotEvent();
final OneShotEvent buildShouldComplete = new OneShotEvent();
setQuietPeriod(0);
FreeStyleProject project = createFreeStyleProject();
// Make build sleep a while so it blocks new builds
project.getBuildersList().add(new TestBuilder() {
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
buildStarted.signal();
buildShouldComplete.block();
return true;
}
});
// Start one build to block others
assertTrue(project.scheduleBuild(new UserIdCause()));
buildStarted.block(); // wait for the build to really start
// Schedule a new build, and trigger it many ways while it sits in queue
Future<FreeStyleBuild> fb = project.scheduleBuild2(0, new UserIdCause());
assertNotNull(fb);
assertFalse(project.scheduleBuild(new SCMTriggerCause("")));
assertFalse(project.scheduleBuild(new UserIdCause()));
assertFalse(project.scheduleBuild(new TimerTriggerCause()));
assertFalse(project.scheduleBuild(new RemoteCause("1.2.3.4", "test")));
assertFalse(project.scheduleBuild(new RemoteCause("4.3.2.1", "test")));
assertFalse(project.scheduleBuild(new SCMTriggerCause("")));
assertFalse(project.scheduleBuild(new RemoteCause("1.2.3.4", "test")));
assertFalse(project.scheduleBuild(new RemoteCause("1.2.3.4", "foo")));
assertFalse(project.scheduleBuild(new SCMTriggerCause("")));
assertFalse(project.scheduleBuild(new TimerTriggerCause()));
// Wait for 2nd build to finish
buildShouldComplete.signal();
FreeStyleBuild build = fb.get();
// Make sure proper folding happened.
CauseAction ca = build.getAction(CauseAction.class);
assertNotNull(ca);