提交 68f55859 编写于 作者: J Jesse Glick 提交者: GitHub

Merge pull request #2959 from jglick/lambdas

Using RestartableJenkinsRule.then
......@@ -53,7 +53,7 @@ THE SOFTWARE.
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jenkins-test-harness</artifactId>
<version>2.23</version>
<version>2.24</version>
<scope>test</scope>
<exclusions>
<exclusion>
......
......@@ -40,6 +40,7 @@ import org.apache.commons.io.output.TeeOutputStream;
import org.codehaus.groovy.runtime.Security218;
import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.*;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
......@@ -255,6 +256,7 @@ public class CLIActionTest {
// -ssh mode does not pass client locale or encoding
}
@Ignore("TODO JENKINS-46659 seems to be broken")
@Issue("JENKINS-41745")
@Test
public void interleavedStdio() throws Exception {
......
......@@ -27,10 +27,9 @@ package hudson.model;
import hudson.tasks.Mailer;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.not;
import org.junit.Test;
import static org.junit.Assert.*;
import org.junit.Rule;
import org.junit.runners.model.Statement;
import org.junit.Test;
import org.jvnet.hudson.test.Issue;
import org.jvnet.hudson.test.RestartableJenkinsRule;
......@@ -40,51 +39,39 @@ public class UserRestartTest {
public RestartableJenkinsRule rr = new RestartableJenkinsRule();
@Test public void persistedUsers() throws Exception {
rr.addStep(new Statement() {
@Override
public void evaluate() throws Throwable {
User bob = User.getById("bob", true);
bob.setFullName("Bob");
bob.addProperty(new Mailer.UserProperty("bob@nowhere.net"));
}
rr.then(r -> {
User bob = User.getById("bob", true);
bob.setFullName("Bob");
bob.addProperty(new Mailer.UserProperty("bob@nowhere.net"));
});
rr.addStep(new Statement() {
@Override
public void evaluate() throws Throwable {
User bob = User.getById("bob", false);
assertNotNull(bob);
assertEquals("Bob", bob.getFullName());
Mailer.UserProperty email = bob.getProperty(Mailer.UserProperty.class);
assertNotNull(email);
assertEquals("bob@nowhere.net", email.getAddress());
}
rr.then(r -> {
User bob = User.getById("bob", false);
assertNotNull(bob);
assertEquals("Bob", bob.getFullName());
Mailer.UserProperty email = bob.getProperty(Mailer.UserProperty.class);
assertNotNull(email);
assertEquals("bob@nowhere.net", email.getAddress());
});
}
@Issue("JENKINS-45892")
@Test
public void badSerialization() {
rr.addStep(new Statement() {
@Override
public void evaluate() throws Throwable {
rr.j.jenkins.setSecurityRealm(rr.j.createDummySecurityRealm());
FreeStyleProject p = rr.j.createFreeStyleProject("p");
User u = User.get("pqhacker");
u.setFullName("Pat Q. Hacker");
u.save();
p.addProperty(new BadProperty(u));
String text = p.getConfigFile().asString();
assertThat(text, not(containsString("<fullName>Pat Q. Hacker</fullName>")));
assertThat(text, containsString("<id>pqhacker</id>"));
}
rr.then(r -> {
r.jenkins.setSecurityRealm(r.createDummySecurityRealm());
FreeStyleProject p = r.createFreeStyleProject("p");
User u = User.get("pqhacker");
u.setFullName("Pat Q. Hacker");
u.save();
p.addProperty(new BadProperty(u));
String text = p.getConfigFile().asString();
assertThat(text, not(containsString("<fullName>Pat Q. Hacker</fullName>")));
assertThat(text, containsString("<id>pqhacker</id>"));
});
rr.addStep(new Statement() {
@Override
public void evaluate() throws Throwable {
FreeStyleProject p = rr.j.jenkins.getItemByFullName("p", FreeStyleProject.class);
User u = p.getProperty(BadProperty.class).user; // do not inline: call User.get second
assertEquals(User.get("pqhacker"), u);
}
rr.then(r -> {
FreeStyleProject p = r.jenkins.getItemByFullName("p", FreeStyleProject.class);
User u = p.getProperty(BadProperty.class).user; // do not inline: call User.get second
assertEquals(User.get("pqhacker"), u);
});
}
static class BadProperty extends JobProperty<FreeStyleProject> {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册