Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[FIXED JENKINS-18771]
... with a test case. The fix is in Stapler.
  • Loading branch information
kohsuke committed Jul 16, 2013
1 parent 5a3d877 commit fc836c1
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 8 deletions.
3 changes: 3 additions & 0 deletions changelog.html
Expand Up @@ -58,6 +58,9 @@
<li class=bug>
Provided maven settings.xml in maven builder is lost.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-15976">issue 15976</a>)
<li class=bug>
Fixed a regression that broke some plugins' form validation
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-18776">issue 18776</a>)
</ul>
</div><!--=TRUNK-END=-->

Expand Down
2 changes: 1 addition & 1 deletion core/pom.xml
Expand Up @@ -42,7 +42,7 @@ THE SOFTWARE.

<properties>
<staplerFork>true</staplerFork>
<stapler.version>1.213</stapler.version>
<stapler.version>1.214</stapler.version>
<spring.version>2.5.6.SEC03</spring.version>
</properties>

Expand Down
29 changes: 22 additions & 7 deletions test/pom.xml
Expand Up @@ -193,6 +193,28 @@ THE SOFTWARE.
<redirectTestOutputToFile>true</redirectTestOutputToFile>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<!-- version specified in grandparent pom -->
<executions>
<execution>
<id>test-in-groovy</id>
<!-- compile and process annotations in Groovy test code -->
<goals>
<goal>generateTestStubs</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>ant</groupId>
<artifactId>ant</artifactId>
<version>1.6.5</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.kohsuke.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
Expand All @@ -208,13 +230,6 @@ THE SOFTWARE.
<source>${pom.basedir}/src/main/preset-data/package.groovy</source>
</configuration>
</execution>
<execution>
<id>test-in-groovy</id>
<!-- allow tests written in Groovy -->
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
Expand Down
65 changes: 65 additions & 0 deletions 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<RelativePathTest> {

This comment has been minimized.

This comment has been minimized.

Copy link
@kohsuke

kohsuke Jul 17, 2013

Author Member

Yes, still chasing down what turns out to be a pretty deep rabbit hole.

@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<RelativePathTest> {
@Override
String getDisplayName() {
return "";
}
}

static class Model extends AbstractDescribableImpl<Model> {
@TestExtension
static class DescriptorImpl extends Descriptor<Model> {
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")
}
}
}
}
@@ -0,0 +1,5 @@
def f= namespace(lib.FormTagLib)

f.entry(field:"abc") {
f.select()
}
18 changes: 18 additions & 0 deletions 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")
}
}
}

1 comment on commit fc836c1

@oleg-nenashev
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems that you have specified wrong JIRA issue.

https://issues.jenkins-ci.org/browse/JENKINS-18771 is related to the "custom-tools" plugin

Please sign in to comment.