提交 56220462 编写于 作者: C christ66

Add @DataBoundConstructor to SleepBuilder along with test unit.

上级 dd6eab43
......@@ -29,6 +29,7 @@ import hudson.model.AbstractBuild;
import hudson.model.BuildListener;
import hudson.model.Descriptor;
import hudson.tasks.Builder;
import org.kohsuke.stapler.DataBoundConstructor;
import java.io.IOException;
......@@ -40,6 +41,7 @@ import java.io.IOException;
public class SleepBuilder extends Builder {
public final long time;
@DataBoundConstructor
public SleepBuilder(long time) {
this.time = time;
}
......
......@@ -23,4 +23,8 @@ THE SOFTWARE.
-->
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" />
\ No newline at end of file
<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form">
<f:entry field="time" title="${%Time}">
<f:textbox />
</f:entry>
</j:jelly>
\ No newline at end of file
package org.jvnet.hudson.test
import org.junit.Rule
import org.junit.Test
/**
* @author schristou@cloudbees.com
* Date: 9/17/13
* Time: 11:43 AM
* To change this template use File | Settings | File Templates.
*/
class SleepBuilderTest {
@Rule public JenkinsRule j = new JenkinsRule();
@Test
void testPerform() {
def project = j.createFreeStyleProject();
def builder = new SleepBuilder(30)
project.buildersList.add(builder);
j.configRoundtrip(project);
j.assertEqualDataBoundBeans(project.buildersList.get(SleepBuilder.class), builder);
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册