提交 a9a0f262 编写于 作者: K kohsuke

I can't put stapler annotations on Groovy, as they fail to produce annotations...

I can't put stapler annotations on Groovy, as they fail to produce annotations on the stub files, so the APT processor doesn't see the annotations in time. So instead I'm falling back to Java code.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@24514 71c3de6d-444a-0410-be80-ed276b4c234a
上级 5bb3c2b0
......@@ -32,6 +32,7 @@ THE SOFTWARE.
<modelVersion>4.0.0</modelVersion>
<groupId>org.jvnet.hudson.main</groupId>
<artifactId>hudson-test-harness</artifactId>
<packaging>stapler-jar</packaging>
<name>Test harness for Hudson and plugins</name>
<description>
Unit test harness (src/main) and Unit tests for Hudson core (src/test)
......@@ -73,6 +74,7 @@ THE SOFTWARE.
<plugin>
<groupId>org.kohsuke.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.0-rc-5-patch-2</version>
<executions>
<execution>
<id>preset-packager</id>
......@@ -101,6 +103,12 @@ THE SOFTWARE.
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.kohsuke.stapler</groupId>
<artifactId>maven-stapler-plugin</artifactId>
<version>1.14</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
......
package lib.form
package lib.form;
import com.gargoylesoftware.htmlunit.html.HtmlForm
import com.gargoylesoftware.htmlunit.html.HtmlPage
import hudson.model.BallColor
import org.jvnet.hudson.test.HudsonTestCase
import hudson.util.FormValidation
import org.kohsuke.stapler.StaplerRequest
import net.sf.json.JSONObject
import org.kohsuke.stapler.DataBoundConstructor
import com.gargoylesoftware.htmlunit.html.HtmlForm;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import hudson.model.BallColor;
import hudson.util.FormValidation;
import net.sf.json.JSONObject;
import org.jvnet.hudson.test.HudsonTestCase;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.StaplerRequest;
import java.util.EnumSet;
/**
*
* @author Kohsuke Kawaguchi
*/
public class EnumSetTest extends HudsonTestCase {
EnumSet<BallColor> f;
EnumSetTest() {
public EnumSetTest() {
f = EnumSet.of(BallColor.BLUE, BallColor.RED);
}
@DataBoundConstructor
EnumSetTest(EnumSet<BallColor> colors) {
public EnumSetTest(EnumSet<BallColor> colors) {
f = colors;
}
@SuppressWarnings
public void test1() {
public void test1() throws Exception {
HtmlPage p = createWebClient().goTo("self/test1");
HtmlForm f = p.getFormByName("config");
submit(f);
interactiveBreak();
}
FormValidation doSubmitTest1(StaplerRequest req) {
public FormValidation doSubmitTest1(StaplerRequest req) throws Exception {
JSONObject f = req.getSubmittedForm();
println f;
EnumSetTest r = req.bindJSON(EnumSetTest,f);
println r.f;
System.out.println(f);
EnumSetTest r = req.bindJSON(EnumSetTest.class,f);
System.out.println(r.f);
return FormValidation.ok();
}
}
\ No newline at end of file
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册