Skip to content
Permalink
Browse files
Merge pull request #210 from Vlatombe/JENKINS-38928
[JENKINS-38928] Add a test doing apply then save in a job
  • Loading branch information
Vlatombe committed Nov 4, 2016
2 parents fdd33e1 + 057ae2f commit 5f4c2b81cea283b5397b0b3bc40120609a0921a1
20 pom.xml
@@ -743,6 +743,26 @@
</plugins>
</build>
</profile>
<profile>
<id>FORM_ELEMENT_PATH_VERSION</id>
<activation>
<property>
<name>FORM_ELEMENT_PATH_VERSION</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<environmentVariables>
<FORM_ELEMENT_PATH_VERSION>${FORM_ELEMENT_PATH_VERSION}</FORM_ELEMENT_PATH_VERSION>
</environmentVariables>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<!-- TODO could be laboriously repeated for $TYPE, etc. (seems Maven provides no generic way to do this) -->

<profile>
@@ -251,7 +251,9 @@ public Jenkins createJenkins(Injector injector, JenkinsController controller) {
@Named("form-element-path.hpi") @Provides
public File getFormElementsPathFile(RepositorySystem repositorySystem, RepositorySystemSession repositorySystemSession) {
ArtifactResolverUtil resolverUtil = new ArtifactResolverUtil(repositorySystem, repositorySystemSession);
ArtifactResult resolvedArtifact = resolverUtil.resolve(new DefaultArtifact("org.jenkins-ci.plugins", "form-element-path", "hpi", "1.7"));
String version = System.getenv("FORM_ELEMENT_PATH_VERSION");
version = version == null ? "1.8" : version;
ArtifactResult resolvedArtifact = resolverUtil.resolve(new DefaultArtifact("org.jenkins-ci.plugins", "form-element-path", "hpi", version));
return resolvedArtifact.getArtifact().getFile();
}

@@ -23,11 +23,14 @@
*/
package org.jenkinsci.test.acceptance.po;

import com.google.common.base.Predicate;
import com.google.inject.Injector;
import groovy.lang.Closure;
import org.openqa.selenium.WebDriver;

import java.net.URL;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
@@ -95,4 +98,9 @@ public void save() {
clickButton("Save");
assertThat(driver, not(hasContent("This page expects a form submission")));
}

public void apply() {
clickButton("Apply");
waitFor(driver, hasContent("Saved"), 5);
}
}
@@ -0,0 +1,32 @@
package core;

import org.jenkinsci.test.acceptance.junit.AbstractJUnitTest;
import org.jenkinsci.test.acceptance.po.FreeStyleJob;
import org.jenkinsci.test.acceptance.po.ShellBuildStep;
import org.junit.Test;
import org.jvnet.hudson.test.Issue;

import static org.jenkinsci.test.acceptance.Matchers.pageObjectExists;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;

public class FreestyleJobTest extends AbstractJUnitTest {

@Test
@Issue("JENKINS-38928")
public void apply_then_save() {
FreeStyleJob j = jenkins.jobs.create(FreeStyleJob.class, "simple-job");
assertThat(j, pageObjectExists());

j.configure();
ShellBuildStep shell = j.addBuildStep(ShellBuildStep.class);
shell.command("echo 1");

j.apply();
j.save();

j.visit("config.xml");

assertTrue("job config.xml should contain the step \"echo 1\"",driver.getPageSource().contains("echo 1"));
}
}

0 comments on commit 5f4c2b8

Please sign in to comment.