From fc836c135e2bba4fa66239ef42e8b542298cdbd9 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Tue, 16 Jul 2013 12:29:08 -0700 Subject: [PATCH] [FIXED JENKINS-18771] ... with a test case. The fix is in Stapler. --- changelog.html | 3 + core/pom.xml | 2 +- test/pom.xml | 29 +++++++-- .../groovy/hudson/RelativePathTest.groovy | 65 +++++++++++++++++++ .../RelativePathTest/Model/config.groovy | 5 ++ .../hudson/RelativePathTest/index.groovy | 18 +++++ 6 files changed, 114 insertions(+), 8 deletions(-) create mode 100644 test/src/test/groovy/hudson/RelativePathTest.groovy create mode 100644 test/src/test/resources/hudson/RelativePathTest/Model/config.groovy create mode 100644 test/src/test/resources/hudson/RelativePathTest/index.groovy diff --git a/changelog.html b/changelog.html index ed5d4ae9b9..eb56a756e1 100644 --- a/changelog.html +++ b/changelog.html @@ -58,6 +58,9 @@ Upcoming changes
  • Provided maven settings.xml in maven builder is lost. (issue 15976) +
  • + Fixed a regression that broke some plugins' form validation + (issue 18776) diff --git a/core/pom.xml b/core/pom.xml index f7aa5a8e27..95e1af1fcc 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -42,7 +42,7 @@ THE SOFTWARE. true - 1.213 + 1.214 2.5.6.SEC03 diff --git a/test/pom.xml b/test/pom.xml index da1db18af8..8742f77299 100644 --- a/test/pom.xml +++ b/test/pom.xml @@ -193,6 +193,28 @@ THE SOFTWARE. true + + org.codehaus.gmaven + gmaven-plugin + + + + test-in-groovy + + + generateTestStubs + testCompile + + + + + + ant + ant + 1.6.5 + + + org.kohsuke.gmaven gmaven-plugin @@ -208,13 +230,6 @@ THE SOFTWARE. ${pom.basedir}/src/main/preset-data/package.groovy - - test-in-groovy - - - testCompile - - diff --git a/test/src/test/groovy/hudson/RelativePathTest.groovy b/test/src/test/groovy/hudson/RelativePathTest.groovy new file mode 100644 index 0000000000..b135bc906c --- /dev/null +++ b/test/src/test/groovy/hudson/RelativePathTest.groovy @@ -0,0 +1,65 @@ +package hudson + +import hudson.model.AbstractDescribableImpl +import hudson.model.Describable +import hudson.model.Descriptor +import hudson.util.ListBoxModel +import org.jvnet.hudson.test.Bug +import org.jvnet.hudson.test.HudsonTestCase +import org.jvnet.hudson.test.TestExtension +import org.kohsuke.stapler.QueryParameter + +/** + * Regression test for JENKINS-18776 + * + * @author Kohsuke Kawaguchi + */ +class RelativePathTest extends HudsonTestCase implements Describable { + @Bug(18776) + void testRelativePath() { + // I was having trouble causing annotation processing on test stubs + jenkins.getDescriptorOrDie(RelativePathTest.class) + jenkins.getDescriptorOrDie(Model.class) + + createWebClient().goTo("/self/"); + assert jenkins.getDescriptorOrDie(Model.class).touched + } + + String getName() { + return "Alice"; + } + + Model getModel() { + return new Model(); + } + + DescriptorImpl getDescriptor() { + return jenkins.getDescriptorOrDie(getClass()); + } + + @TestExtension + static class DescriptorImpl extends Descriptor { + @Override + String getDisplayName() { + return ""; + } + } + + static class Model extends AbstractDescribableImpl { + @TestExtension + static class DescriptorImpl extends Descriptor { + boolean touched; + + @Override + String getDisplayName() { + return "test"; + } + + ListBoxModel doFillAbcItems(@RelativePath("..") @QueryParameter String name) { + assert name=="Alice"; + touched = true; + return new ListBoxModel().add("foo").add("bar") + } + } + } +} diff --git a/test/src/test/resources/hudson/RelativePathTest/Model/config.groovy b/test/src/test/resources/hudson/RelativePathTest/Model/config.groovy new file mode 100644 index 0000000000..cd17d550a2 --- /dev/null +++ b/test/src/test/resources/hudson/RelativePathTest/Model/config.groovy @@ -0,0 +1,5 @@ +def f= namespace(lib.FormTagLib) + +f.entry(field:"abc") { + f.select() +} \ No newline at end of file diff --git a/test/src/test/resources/hudson/RelativePathTest/index.groovy b/test/src/test/resources/hudson/RelativePathTest/index.groovy new file mode 100644 index 0000000000..4ee16e1b71 --- /dev/null +++ b/test/src/test/resources/hudson/RelativePathTest/index.groovy @@ -0,0 +1,18 @@ +package hudson.RelativePathTest + +def l = namespace(lib.LayoutTagLib) +def j = namespace("jelly:core") +def f= namespace(lib.FormTagLib) + +l.layout { + l.main_panel { + set("instance",my) + set("descriptor",my.descriptor) + f.form() { + f.entry(field:"name") { + f.textbox() + } + f.property(field:"model") + } + } +} -- GitLab