Skip to content
Permalink
Browse files
[JENKINS-34716] Verifying doPolling in a test.
  • Loading branch information
jglick committed May 5, 2017
1 parent a8c5b5f commit 7ecd9856e6b5474af804d45d1d8054848a8d6cf3
Showing with 54 additions and 0 deletions.
  1. +28 −0 pom.xml
  2. +26 −0 src/test/java/org/jenkinsci/plugins/workflow/job/WorkflowJobTest.java
28 pom.xml
@@ -66,6 +66,8 @@
<jenkins-test-harness.version>2.19</jenkins-test-harness.version>
<no-test-jar>false</no-test-jar>
<workflow-support-plugin.version>2.2</workflow-support-plugin.version>
<scm-api-plugin.version>2.1.1</scm-api-plugin.version>
<git-plugin.version>3.2.0</git-plugin.version>
</properties>
<dependencies>
<dependency>
@@ -109,5 +111,31 @@
<version>2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>scm-api</artifactId>
<version>${scm-api-plugin.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>scm-api</artifactId>
<version>${scm-api-plugin.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>git</artifactId>
<version>${git-plugin.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>git</artifactId>
<version>${git-plugin.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
</dependencies>
</project>
@@ -5,16 +5,22 @@
import com.gargoylesoftware.htmlunit.html.HtmlCheckBoxInput;
import com.gargoylesoftware.htmlunit.html.HtmlForm;
import hudson.model.Result;
import hudson.plugins.git.GitSCM;
import hudson.security.WhoAmI;
import hudson.triggers.SCMTrigger;
import jenkins.plugins.git.GitSampleRepoRule;
import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
import org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition;
import static org.junit.Assert.*;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.Issue;
import org.jvnet.hudson.test.JenkinsRule;

public class WorkflowJobTest {

@Rule public JenkinsRule j = new JenkinsRule();
@Rule public GitSampleRepoRule sampleRepo = new GitSampleRepoRule();

@Issue("JENKINS-40255")
@Test public void getSCM() throws Exception {
@@ -42,6 +48,26 @@
assertEquals("Expecting zero SCMs",0, p.getSCMs().size());
}

@Issue("JENKINS-34716")
@Test public void polling() throws Exception {
sampleRepo.init();
sampleRepo.write("Jenkinsfile", "echo 'first version'");
sampleRepo.git("add", "Jenkinsfile");
sampleRepo.git("commit", "-m", "init");
WorkflowJob p = j.jenkins.createProject(WorkflowJob.class, "p");
p.addTrigger(new SCMTrigger(""));
p.setDefinition(new CpsScmFlowDefinition(new GitSCM(sampleRepo.toString()), "Jenkinsfile"));
j.assertLogContains("first version", j.buildAndAssertSuccess(p));
sampleRepo.write("Jenkinsfile", "echo 'second version'");
sampleRepo.git("commit", "-a", "-m", "init");
j.jenkins.setQuietPeriod(0);
j.createWebClient().getPage(new WebRequest(j.createWebClient().createCrumbedUrl(p.getUrl() + "polling"), HttpMethod.POST));
j.waitUntilNoActivity();
WorkflowRun b2 = p.getLastBuild();
assertEquals(2, b2.getNumber());
j.assertLogContains("second version", b2);
}

@Test
public void addAction() throws Exception {
WorkflowJob p = j.jenkins.createProject(WorkflowJob.class, "p");

0 comments on commit 7ecd985

Please sign in to comment.