未验证 提交 ba44ed59 编写于 作者: J Jesse Glick

AbstractItemTest

上级 26c4ab77
package hudson.model
import org.junit.Rule
import org.junit.Test
import org.jvnet.hudson.test.JenkinsRule
/**
*
*
* @author Kohsuke Kawaguchi
*/
class AbstractItemTest {
@Rule
public JenkinsRule j = new JenkinsRule()
/**
* Tests the reload functionality
*/
@Test
void reload() {
def jenkins = j.jenkins;
def p = jenkins.createProject(FreeStyleProject.class,"foo");
p.description = "Hello World";
def b = j.assertBuildStatusSuccess(p.scheduleBuild2(0))
b.description = "This is my build"
// update on disk representation
def f = p.configFile.file
f.text = f.text.replaceAll("Hello World","Good Evening");
// reload away
p.doReload()
assert p.description == "Good Evening";
def b2 = p.getBuildByNumber(1)
assert !b.is(b2); // should be different object
assert b.description == b2.description // but should have the same properties
}
}
package hudson.model;
import java.io.File;
import jenkins.model.Jenkins;
import org.apache.commons.io.FileUtils;
import static org.junit.Assert.*;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.JenkinsRule;
public class AbstractItemTest {
@Rule
public JenkinsRule j = new JenkinsRule();
/**
* Tests the reload functionality
*/
@Test
public void reload() throws Exception {
Jenkins jenkins = j.jenkins;
FreeStyleProject p = jenkins.createProject(FreeStyleProject.class, "foo");
p.setDescription("Hello World");
FreeStyleBuild b = j.assertBuildStatusSuccess(p.scheduleBuild2(0));
b.setDescription("This is my build");
// update on disk representation
File f = p.getConfigFile().getFile();
FileUtils.writeStringToFile(f, FileUtils.readFileToString(f).replaceAll("Hello World", "Good Evening"));
// reload away
p.doReload();
assertEquals("Good Evening", p.getDescription());
FreeStyleBuild b2 = p.getBuildByNumber(1);
assertNotEquals(b, b2); // should be different object
assertEquals(b.getDescription(), b2.getDescription()); // but should have the same properties
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册