Skip to content

Commit

Permalink
[JENKINS-33162] Tried to expose blocking in test case.
Browse files Browse the repository at this point in the history
  • Loading branch information
uhafner committed Feb 27, 2016
1 parent f3b8c7c commit 500a376
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 0 deletions.
@@ -0,0 +1,18 @@
package org.jenkinsci.test.acceptance.plugins.parameterized_trigger;

import org.jenkinsci.test.acceptance.po.Control;
import org.jenkinsci.test.acceptance.po.PageAreaImpl;

/**
* Configuration section of a trigger/call build step.
*
* @author Ullrich Hafner
*/
public class BuildTriggerConfig extends PageAreaImpl {
public final Control projects = control("projects");
public final Control block = control("block");

public BuildTriggerConfig(TriggerCallBuildStep parent, String relativePath) {
super(parent, relativePath);
}
}
@@ -0,0 +1,43 @@
package org.jenkinsci.test.acceptance.plugins.parameterized_trigger;

import java.util.List;

import org.jenkinsci.test.acceptance.po.AbstractStep;
import org.jenkinsci.test.acceptance.po.BuildStep;
import org.jenkinsci.test.acceptance.po.Describable;
import org.jenkinsci.test.acceptance.po.Job;
import org.openqa.selenium.WebElement;

/**
* Trigger/call build step of the parameterized trigger plug-in. Starts downstream projects.
*
* @author Ullrich Hafner
*/
@Describable("Trigger/call builds on other projects")
public class TriggerCallBuildStep extends AbstractStep implements BuildStep {
public TriggerCallBuildStep(Job parent, String path) {
super(parent, path);
}

public BuildTriggerConfig getBuildTriggerConfig(int index) {
WebElement e = self().findElements(by.name("configs")).get(index);
return wrap(e);
}

/**
* Adds a new trigger setting.
*
* Note that newly added trigger has one entry in there by default.
*/
public BuildTriggerConfig addTriggerConfig() {
find(by.button("Add trigger...")).click();

List<WebElement> all = self().findElements(by.name("configs"));
return wrap(all.get(all.size() - 1));
}

private BuildTriggerConfig wrap(WebElement e) {
return new BuildTriggerConfig(this,
e.getAttribute("path").substring(getPath().length() + 1));
}
}
23 changes: 23 additions & 0 deletions src/test/java/plugins/CheckStylePluginTest.java
Expand Up @@ -13,6 +13,8 @@
import org.jenkinsci.test.acceptance.plugins.checkstyle.CheckStylePortlet;
import org.jenkinsci.test.acceptance.plugins.dashboard_view.DashboardView;
import org.jenkinsci.test.acceptance.plugins.maven.MavenModuleSet;
import org.jenkinsci.test.acceptance.plugins.parameterized_trigger.BuildTriggerConfig;
import org.jenkinsci.test.acceptance.plugins.parameterized_trigger.TriggerCallBuildStep;
import org.jenkinsci.test.acceptance.po.Build;
import org.jenkinsci.test.acceptance.po.Build.Result;
import org.jenkinsci.test.acceptance.po.FreeStyleJob;
Expand Down Expand Up @@ -71,6 +73,27 @@ protected int getNumberOfWarnings() {
return TOTAL_NUMBER_OF_WARNINGS;
}

@Test @WithPlugins("parameterized-trigger") @Issue("JENKINS-33162")
public void should_return_from_triggered_subjob() {
FreeStyleJob checkstyleJob = createFreeStyleJob(new AnalysisConfigurator<CheckStyleFreestyleSettings>() {
@Override
public void configure(CheckStyleFreestyleSettings settings) {
settings.pattern.set(PATTERN_WITH_776_WARNINGS);
}
});

FreeStyleJob trigger = jenkins.jobs.create();
trigger.configure();
TriggerCallBuildStep step = trigger.addBuildStep(TriggerCallBuildStep.class);
BuildTriggerConfig config = step.getBuildTriggerConfig(0);
config.projects.set(checkstyleJob.name);
config.block.click();
trigger.save();

trigger.startBuild().shouldSucceed();
Build downstream = checkstyleJob.build(1);
downstream.shouldSucceed();
}
/**
* Checks that the plug-in sends a mail after a build has been failed. The content of the mail contains several
* tokens that should be expanded in the mail with the correct values.
Expand Down

0 comments on commit 500a376

Please sign in to comment.