Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a test case in an attempt to isolate the root cause of the problem, but this one works as expected. Hmm.
- Loading branch information
Showing
2 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package lib.form | ||
|
||
import hudson.model.AbstractProject | ||
import hudson.tasks.BuildStepDescriptor | ||
import hudson.tasks.Builder | ||
import hudson.util.FormValidation | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.jvnet.hudson.test.Bug | ||
import org.jvnet.hudson.test.JenkinsRule | ||
import org.jvnet.hudson.test.TestExtension | ||
import org.kohsuke.stapler.DataBoundConstructor | ||
import org.kohsuke.stapler.QueryParameter | ||
|
||
import javax.inject.Inject | ||
|
||
/** | ||
* | ||
* | ||
* @author Kohsuke Kawaguchi | ||
*/ | ||
class TextAreaTest { | ||
@Rule | ||
public JenkinsRule j = new JenkinsRule(); | ||
|
||
@Inject | ||
TestBuilder.DescriptorImpl d; | ||
|
||
@Test @Bug(19457) | ||
public void validation() { | ||
j.jenkins.injector.injectMembers(this) | ||
def p = j.createFreeStyleProject() | ||
p.buildersList.add(new TestBuilder()) | ||
j.configRoundtrip(p) | ||
assert d.text1=="This is text1" | ||
assert d.text2=="Received This is text1" | ||
} | ||
|
||
public static class TestBuilder extends Builder { | ||
@DataBoundConstructor | ||
TestBuilder() { | ||
} | ||
|
||
public String getText1() { return "This is text1" } | ||
public String getText2() { return "This is text2" } | ||
|
||
@TestExtension | ||
public static class DescriptorImpl extends BuildStepDescriptor<Builder> { | ||
def text1,text2; | ||
|
||
@Override | ||
boolean isApplicable(Class<? extends AbstractProject> jobType) { | ||
return true; | ||
} | ||
|
||
FormValidation doCheckText1(@QueryParameter String value) { | ||
this.text1 = value; | ||
return FormValidation.ok(); | ||
} | ||
|
||
FormValidation doCheckText2(@QueryParameter String text1) { | ||
this.text2 = "Received "+text1; | ||
return FormValidation.ok(); | ||
} | ||
|
||
@Override | ||
String getDisplayName() { | ||
return this.class.name; | ||
} | ||
} | ||
|
||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
test/src/test/resources/lib/form/TextAreaTest/TestBuilder/config.jelly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!-- no config --> | ||
<?jelly escape-by-default='true'?> | ||
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form"> | ||
<f:entry field="text1" title="${%Text1}"> | ||
<f:textarea/> | ||
</f:entry> | ||
<f:entry field="text2" title="${%Text1}"> | ||
<f:textarea/> | ||
</f:entry> | ||
</j:jelly> |