Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
jenkins
提交
55d1f1fe
J
jenkins
项目概览
xxadev
/
jenkins
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jenkins
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
55d1f1fe
编写于
3月 31, 2011
作者:
K
Kohsuke Kawaguchi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added test cases
上级
3417dc04
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
71 addition
and
9 deletion
+71
-9
test/src/test/java/hudson/model/JobPropertyTest.java
test/src/test/java/hudson/model/JobPropertyTest.java
+66
-9
test/src/test/resources/hudson/model/JobPropertyTest/JobPropertyWithConfigImpl/config.jelly
...el/JobPropertyTest/JobPropertyWithConfigImpl/config.jelly
+5
-0
未找到文件。
test/src/test/java/hudson/model/JobPropertyTest.java
浏览文件 @
55d1f1fe
/*
* The MIT License
*
* Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, Erik Ramfelt
* Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, Erik Ramfelt
, CloudBees, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
...
...
@@ -27,13 +27,20 @@ import com.gargoylesoftware.htmlunit.WebAssert;
import
com.gargoylesoftware.htmlunit.html.HtmlPage
;
import
hudson.matrix.MatrixProject
;
import
hudson.maven.MavenModuleSet
;
import
hudson.model.Descriptor.FormException
;
import
net.sf.json.JSONObject
;
import
org.jvnet.hudson.test.Bug
;
import
org.jvnet.hudson.test.HudsonTestCase
;
import
org.jvnet.hudson.test.TestExtension
;
import
org.kohsuke.stapler.DataBoundConstructor
;
import
org.kohsuke.stapler.StaplerRequest
;
public
class
JobPropertyTest
extends
HudsonTestCase
{
/**
* Asserts that rfe#2398 is fixed.
*/
@Bug
(
2398
)
public
void
testJobPropertySummaryIsShownInMavenModuleSetIndexPage
()
throws
Exception
{
assertJobPropertySummaryIsShownInIndexPage
(
MavenModuleSet
.
DESCRIPTOR
);
}
...
...
@@ -54,7 +61,6 @@ public class JobPropertyTest extends HudsonTestCase {
}
public
static
class
JobPropertyImpl
extends
JobProperty
<
Job
<?,?>>
{
public
static
DescriptorImpl
DESCRIPTOR
=
new
DescriptorImpl
();
private
final
String
propertyString
;
public
JobPropertyImpl
(
String
propertyString
)
{
this
.
propertyString
=
propertyString
;
...
...
@@ -64,13 +70,8 @@ public class JobPropertyTest extends HudsonTestCase {
return
propertyString
;
}
@Override
public
JobPropertyDescriptor
getDescriptor
()
{
return
DESCRIPTOR
;
}
@SuppressWarnings
(
"unchecked"
)
private
static
class
DescriptorImpl
extends
JobPropertyDescriptor
{
@TestExtension
public
static
class
DescriptorImpl
extends
JobPropertyDescriptor
{
@Override
public
boolean
isApplicable
(
Class
<?
extends
Job
>
jobType
)
{
return
false
;
...
...
@@ -82,4 +83,60 @@ public class JobPropertyTest extends HudsonTestCase {
}
}
}
/**
* Make sure that the UI rendering works as designed.
*/
public
void
testConfigRoundtrip
()
throws
Exception
{
FreeStyleProject
p
=
createFreeStyleProject
();
JobPropertyWithConfigImpl
before
=
new
JobPropertyWithConfigImpl
(
"Duke"
);
p
.
addProperty
(
before
);
configRoundtrip
(
p
);
JobPropertyWithConfigImpl
after
=
p
.
getProperty
(
JobPropertyWithConfigImpl
.
class
);
assertNotSame
(
after
,
before
);
assertEqualDataBoundBeans
(
before
,
after
);
}
public
static
class
JobPropertyWithConfigImpl
extends
JobProperty
<
Job
<?,?>>
{
public
String
name
;
@DataBoundConstructor
public
JobPropertyWithConfigImpl
(
String
name
)
{
this
.
name
=
name
;
}
@TestExtension
(
"testConfigRoundtrip"
)
public
static
class
DescriptorImpl
extends
JobPropertyDescriptor
{
@Override
public
String
getDisplayName
()
{
return
null
;
}
}
}
public
void
testInvisibleProperty
()
throws
Exception
{
FreeStyleProject
p
=
createFreeStyleProject
();
InvisibleImpl
before
=
new
InvisibleImpl
();
p
.
addProperty
(
before
);
configRoundtrip
(
p
);
InvisibleImpl
after
=
p
.
getProperty
(
InvisibleImpl
.
class
);
assertSame
(
after
,
before
);
}
public
static
class
InvisibleImpl
extends
JobProperty
<
Job
<?,?>>
{
public
String
name
;
InvisibleImpl
()
{}
@Override
public
JobProperty
<?>
reconfigure
(
StaplerRequest
req
,
JSONObject
form
)
throws
FormException
{
return
this
;
}
@TestExtension
(
"testInvisibleProperty"
)
public
static
class
DescriptorImpl
extends
JobPropertyDescriptor
{
@Override
public
String
getDisplayName
()
{
return
null
;
}
}
}
}
test/src/test/resources/hudson/model/JobPropertyTest/JobPropertyWithConfigImpl/config.jelly
0 → 100644
浏览文件 @
55d1f1fe
<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="name" title="${%Name}">
<f:textbox/>
</f:entry>
</j:jelly>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录