Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
jenkins
提交
ed2f9cab
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,发现更多精彩内容 >>
提交
ed2f9cab
编写于
7月 23, 2015
作者:
T
tfennelly
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ParametersTest compiling against HtmlUnit 2.17
上级
fc80e221
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
28 addition
and
26 deletion
+28
-26
test/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlFormUtil.java
...java/com/gargoylesoftware/htmlunit/html/HtmlFormUtil.java
+2
-2
test/src/test/java/hudson/model/ParametersTest.java
test/src/test/java/hudson/model/ParametersTest.java
+26
-24
未找到文件。
test/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlFormUtil.java
浏览文件 @
ed2f9cab
...
...
@@ -82,10 +82,10 @@ public class HtmlFormUtil {
return
getSubmitButtons
(
htmlForm
).
get
(
0
);
}
public
static
Html
Button
getButtonByCaption
(
final
HtmlForm
htmlForm
,
final
String
caption
)
throws
ElementNotFoundException
{
public
static
Html
SubmitInput
getButtonByCaption
(
final
HtmlForm
htmlForm
,
final
String
caption
)
throws
ElementNotFoundException
{
for
(
HtmlElement
b
:
htmlForm
.
getHtmlElementsByTagName
(
"button"
))
{
if
(
b
.
getTextContent
().
trim
().
equals
(
caption
))
return
(
Html
Button
)
b
;
return
(
Html
SubmitInput
)
b
;
}
throw
new
ElementNotFoundException
(
"button"
,
"caption"
,
caption
);
}
...
...
test/src/test/java/hudson/model/ParametersTest.java
浏览文件 @
ed2f9cab
...
...
@@ -2,6 +2,8 @@ package hudson.model;
import
static
org
.
junit
.
Assert
.*;
import
com.gargoylesoftware.htmlunit.html.DomNodeUtil
;
import
com.gargoylesoftware.htmlunit.html.HtmlFormUtil
;
import
org.junit.Rule
;
import
org.junit.Test
;
...
...
@@ -42,38 +44,38 @@ public class ParametersTest {
project
.
getBuildersList
().
add
(
builder
);
WebClient
wc
=
j
.
createWebClient
();
wc
.
setThrowExceptionOnFailingStatusCode
(
false
);
wc
.
getOptions
().
setThrowExceptionOnFailingStatusCode
(
false
);
HtmlPage
page
=
wc
.
goTo
(
"job/"
+
project
.
getName
()
+
"/build?delay=0sec"
);
HtmlForm
form
=
page
.
getFormByName
(
"parameters"
);
HtmlElement
element
=
(
HtmlElement
)
form
.
selectSingleNode
(
"//tr[td/div/input/@value='string']"
);
HtmlElement
element
=
(
HtmlElement
)
DomNodeUtil
.
selectSingleNode
(
form
,
"//tr[td/div/input/@value='string']"
);
assertNotNull
(
element
);
assertEquals
(
"string description"
,
((
HtmlElement
)
element
.
getNextSibling
().
getNextSibling
().
selectSingleNode
(
"td[@class='setting-description']"
)).
getTextContent
());
assertEquals
(
"string description"
,
((
HtmlElement
)
DomNodeUtil
.
selectSingleNode
(
element
.
getNextSibling
().
getNextSibling
(),
"td[@class='setting-description']"
)).
getTextContent
());
HtmlTextInput
stringParameterInput
=
(
HtmlTextInput
)
element
.
selectSingleNode
(
".//input[@name='value']"
);
HtmlTextInput
stringParameterInput
=
(
HtmlTextInput
)
DomNodeUtil
.
selectSingleNode
(
element
,
".//input[@name='value']"
);
assertEquals
(
"defaultValue"
,
stringParameterInput
.
getAttribute
(
"value"
));
assertEquals
(
"string"
,
((
HtmlElement
)
element
.
selectSingleNode
(
"td[@class='setting-name']"
)).
getTextContent
());
assertEquals
(
"string"
,
((
HtmlElement
)
DomNodeUtil
.
selectSingleNode
(
element
,
"td[@class='setting-name']"
)).
getTextContent
());
stringParameterInput
.
setAttribute
(
"value"
,
"newValue"
);
element
=
(
HtmlElement
)
form
.
selectSingleNode
(
"//tr[td/div/input/@value='boolean']"
);
element
=
(
HtmlElement
)
DomNodeUtil
.
selectSingleNode
(
form
,
"//tr[td/div/input/@value='boolean']"
);
assertNotNull
(
element
);
assertEquals
(
"boolean description"
,
((
HtmlElement
)
element
.
getNextSibling
().
getNextSibling
().
selectSingleNode
(
"td[@class='setting-description']"
)).
getTextContent
());
Object
o
=
element
.
selectSingleNode
(
".//input[@name='value']"
);
assertEquals
(
"boolean description"
,
((
HtmlElement
)
DomNodeUtil
.
selectSingleNode
(
element
.
getNextSibling
().
getNextSibling
(),
"td[@class='setting-description']"
)).
getTextContent
());
Object
o
=
DomNodeUtil
.
selectSingleNode
(
element
,
".//input[@name='value']"
);
System
.
out
.
println
(
o
);
HtmlCheckBoxInput
booleanParameterInput
=
(
HtmlCheckBoxInput
)
o
;
assertEquals
(
true
,
booleanParameterInput
.
isChecked
());
assertEquals
(
"boolean"
,
((
HtmlElement
)
element
.
selectSingleNode
(
"td[@class='setting-name']"
)).
getTextContent
());
assertEquals
(
"boolean"
,
((
HtmlElement
)
DomNodeUtil
.
selectSingleNode
(
element
,
"td[@class='setting-name']"
)).
getTextContent
());
element
=
(
HtmlElement
)
form
.
selectSingleNode
(
".//tr[td/div/input/@value='choice']"
);
element
=
(
HtmlElement
)
DomNodeUtil
.
selectSingleNode
(
form
,
".//tr[td/div/input/@value='choice']"
);
assertNotNull
(
element
);
assertEquals
(
"choice description"
,
((
HtmlElement
)
element
.
getNextSibling
().
getNextSibling
().
selectSingleNode
(
"td[@class='setting-description']"
)).
getTextContent
());
assertEquals
(
"choice"
,
((
HtmlElement
)
element
.
selectSingleNode
(
"td[@class='setting-name']"
)).
getTextContent
());
assertEquals
(
"choice description"
,
((
HtmlElement
)
DomNodeUtil
.
selectSingleNode
(
element
.
getNextSibling
().
getNextSibling
(),
"td[@class='setting-description']"
)).
getTextContent
());
assertEquals
(
"choice"
,
((
HtmlElement
)
DomNodeUtil
.
selectSingleNode
(
element
,
"td[@class='setting-name']"
)).
getTextContent
());
element
=
(
HtmlElement
)
form
.
selectSingleNode
(
".//tr[td/div/input/@value='run']"
);
element
=
(
HtmlElement
)
DomNodeUtil
.
selectSingleNode
(
form
,
".//tr[td/div/input/@value='run']"
);
assertNotNull
(
element
);
assertEquals
(
"run description"
,
((
HtmlElement
)
element
.
getNextSibling
().
getNextSibling
().
selectSingleNode
(
"td[@class='setting-description']"
)).
getTextContent
());
assertEquals
(
"run"
,
((
HtmlElement
)
element
.
selectSingleNode
(
"td[@class='setting-name']"
)).
getTextContent
());
assertEquals
(
"run description"
,
((
HtmlElement
)
DomNodeUtil
.
selectSingleNode
(
element
.
getNextSibling
().
getNextSibling
(),
"td[@class='setting-description']"
)).
getTextContent
());
assertEquals
(
"run"
,
((
HtmlElement
)
DomNodeUtil
.
selectSingleNode
(
element
,
"td[@class='setting-name']"
)).
getTextContent
());
j
.
submit
(
form
);
Queue
.
Item
q
=
j
.
jenkins
.
getQueue
().
getItem
(
project
);
...
...
@@ -96,15 +98,15 @@ public class ParametersTest {
project
.
getBuildersList
().
add
(
builder
);
WebClient
wc
=
j
.
createWebClient
();
wc
.
setThrowExceptionOnFailingStatusCode
(
false
);
wc
.
getOptions
().
setThrowExceptionOnFailingStatusCode
(
false
);
HtmlPage
page
=
wc
.
goTo
(
"job/"
+
project
.
getName
()
+
"/build?delay=0sec"
);
HtmlForm
form
=
page
.
getFormByName
(
"parameters"
);
HtmlElement
element
=
(
HtmlElement
)
form
.
selectSingleNode
(
".//tr[td/div/input/@value='choice']"
);
HtmlElement
element
=
(
HtmlElement
)
DomNodeUtil
.
selectSingleNode
(
form
,
".//tr[td/div/input/@value='choice']"
);
assertNotNull
(
element
);
assertEquals
(
"choice description"
,
((
HtmlElement
)
element
.
getNextSibling
().
getNextSibling
().
selectSingleNode
(
"td[@class='setting-description']"
)).
getTextContent
());
assertEquals
(
"choice"
,
((
HtmlElement
)
element
.
selectSingleNode
(
"td[@class='setting-name']"
)).
getTextContent
());
HtmlOption
opt
=
(
HtmlOption
)
element
.
selectSingleNode
(
"td/div/select/option[@value='Choice <2>']"
);
assertEquals
(
"choice description"
,
((
HtmlElement
)
DomNodeUtil
.
selectSingleNode
(
element
.
getNextSibling
().
getNextSibling
(),
"td[@class='setting-description']"
)).
getTextContent
());
assertEquals
(
"choice"
,
((
HtmlElement
)
DomNodeUtil
.
selectSingleNode
(
element
,
"td[@class='setting-name']"
)).
getTextContent
());
HtmlOption
opt
=
(
HtmlOption
)
DomNodeUtil
.
selectSingleNode
(
element
,
"td/div/select/option[@value='Choice <2>']"
);
assertNotNull
(
opt
);
assertEquals
(
"Choice <2>"
,
opt
.
asText
());
opt
.
setSelected
(
true
);
...
...
@@ -183,7 +185,7 @@ public class ParametersTest {
project
.
addProperty
(
pdp
);
WebClient
wc
=
j
.
createWebClient
();
wc
.
setThrowExceptionOnFailingStatusCode
(
false
);
wc
.
getOptions
().
setThrowExceptionOnFailingStatusCode
(
false
);
HtmlPage
page
=
wc
.
goTo
(
"job/"
+
project
.
getName
()
+
"/build?delay=0sec"
);
HtmlForm
form
=
page
.
getFormByName
(
"parameters"
);
...
...
@@ -206,12 +208,12 @@ public class ParametersTest {
p
.
addProperty
(
pdb
);
WebClient
wc
=
j
.
createWebClient
();
wc
.
setThrowExceptionOnFailingStatusCode
(
false
);
// Ignore 405
wc
.
getOptions
().
setThrowExceptionOnFailingStatusCode
(
false
);
// Ignore 405
HtmlPage
page
=
wc
.
getPage
(
p
,
"build"
);
// java.lang.IllegalArgumentException: No such parameter definition: <gibberish>.
wc
.
setThrowExceptionOnFailingStatusCode
(
true
);
wc
.
getOptions
().
setThrowExceptionOnFailingStatusCode
(
true
);
final
HtmlForm
form
=
page
.
getFormByName
(
"parameters"
);
form
.
submit
(
form
.
getButtonByCaption
(
"Build"
));
HtmlFormUtil
.
submit
(
form
,
HtmlFormUtil
.
getButtonByCaption
(
form
,
"Build"
));
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录