Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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
kohsuke committed Sep 5, 2013
1 parent b94cab3 commit ac274f1
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 0 deletions.
73 changes: 73 additions & 0 deletions test/src/test/groovy/lib/form/TextAreaTest.groovy
@@ -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;
}
}

}
}
@@ -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>

0 comments on commit ac274f1

Please sign in to comment.