Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
LinuxSuRen
jenkins
提交
fe70d191
J
jenkins
项目概览
LinuxSuRen
/
jenkins
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
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,发现更多精彩内容 >>
提交
fe70d191
编写于
6月 17, 2013
作者:
J
Jesse Glick
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
JUnit 4.
上级
1e7b82ae
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
41 addition
and
38 deletion
+41
-38
test/src/test/java/hudson/model/ViewTest.java
test/src/test/java/hudson/model/ViewTest.java
+41
-38
未找到文件。
test/src/test/java/hudson/model/ViewTest.java
浏览文件 @
fe70d191
...
...
@@ -31,52 +31,55 @@ import com.gargoylesoftware.htmlunit.html.HtmlForm;
import
com.gargoylesoftware.htmlunit.html.HtmlPage
;
import
com.gargoylesoftware.htmlunit.html.HtmlRadioButtonInput
;
import
org.jvnet.hudson.test.Email
;
import
org.jvnet.hudson.test.HudsonTestCase
;
import
org.w3c.dom.Text
;
import
static
hudson
.
model
.
Messages
.
Hudson_ViewName
;
import
static
junit
.
framework
.
TestCase
.
assertEquals
;
import
static
junit
.
framework
.
TestCase
.
assertNotNull
;
import
static
junit
.
framework
.
TestCase
.
fail
;
import
static
org
.
junit
.
Assert
.*;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.jvnet.hudson.test.JenkinsRule
;
import
org.jvnet.hudson.test.JenkinsRule.WebClient
;
/**
* @author Kohsuke Kawaguchi
*/
public
class
ViewTest
extends
HudsonTestCase
{
public
class
ViewTest
{
@Rule
public
JenkinsRule
j
=
new
JenkinsRule
();
@Bug
(
7100
)
public
void
testX
HudsonHeader
()
throws
Exception
{
assertNotNull
(
new
WebClient
().
goTo
(
"/
"
).
getWebResponse
().
getResponseHeaderValue
(
"X-Hudson"
));
@Test
public
void
x
HudsonHeader
()
throws
Exception
{
assertNotNull
(
j
.
createWebClient
().
goTo
(
"
"
).
getWebResponse
().
getResponseHeaderValue
(
"X-Hudson"
));
}
/**
* Creating two views with the same name.
*/
@Email
(
"http://d.hatena.ne.jp/ssogabe/20090101/1230744150"
)
public
void
testC
onflictingName
()
throws
Exception
{
assertNull
(
jenkins
.
getView
(
"foo"
));
@Test
public
void
c
onflictingName
()
throws
Exception
{
assertNull
(
j
.
j
enkins
.
getView
(
"foo"
));
HtmlForm
form
=
new
WebClient
().
goTo
(
"newView"
).
getFormByName
(
"createItem"
);
HtmlForm
form
=
j
.
create
WebClient
().
goTo
(
"newView"
).
getFormByName
(
"createItem"
);
form
.
getInputByName
(
"name"
).
setValueAttribute
(
"foo"
);
form
.
getRadioButtonsByName
(
"mode"
).
get
(
0
).
setChecked
(
true
);
submit
(
form
);
assertNotNull
(
jenkins
.
getView
(
"foo"
));
j
.
submit
(
form
);
assertNotNull
(
j
.
j
enkins
.
getView
(
"foo"
));
// do it again and verify an error
try
{
submit
(
form
);
j
.
submit
(
form
);
fail
(
"shouldn't be allowed to create two views of the same name."
);
}
catch
(
FailingHttpStatusCodeException
e
)
{
assertEquals
(
400
,
e
.
getStatusCode
());
}
}
public
void
testP
rivateView
()
throws
Exception
{
createFreeStyleProject
(
"project1"
);
@Test
public
void
p
rivateView
()
throws
Exception
{
j
.
createFreeStyleProject
(
"project1"
);
User
user
=
User
.
get
(
"me"
,
true
);
// create user
WebClient
wc
=
new
WebClient
();
HtmlPage
userPage
=
wc
.
goTo
(
"
/
user/me"
);
WebClient
wc
=
j
.
create
WebClient
();
HtmlPage
userPage
=
wc
.
goTo
(
"user/me"
);
HtmlAnchor
privateViewsLink
=
userPage
.
getFirstAnchorByText
(
"My Views"
);
assertNotNull
(
"My Views link not available"
,
privateViewsLink
);
...
...
@@ -85,48 +88,48 @@ public class ViewTest extends HudsonTestCase {
Text
viewLabel
=
(
Text
)
privateViewsPage
.
getFirstByXPath
(
"//table[@id='viewList']//td[@class='active']/text()"
);
assertTrue
(
"'All' view should be selected"
,
viewLabel
.
getTextContent
().
contains
(
Hudson_ViewName
()));
View
listView
=
new
ListView
(
"listView"
,
jenkins
);
jenkins
.
addView
(
listView
);
View
listView
=
new
ListView
(
"listView"
,
j
.
j
enkins
);
j
.
j
enkins
.
addView
(
listView
);
HtmlPage
newViewPage
=
wc
.
goTo
(
"
/
user/me/my-views/newView"
);
HtmlPage
newViewPage
=
wc
.
goTo
(
"user/me/my-views/newView"
);
HtmlForm
form
=
newViewPage
.
getFormByName
(
"createItem"
);
form
.
getInputByName
(
"name"
).
setValueAttribute
(
"proxy-view"
);
((
HtmlRadioButtonInput
)
form
.
getInputByValue
(
"hudson.model.ProxyView"
)).
setChecked
(
true
);
HtmlPage
proxyViewConfigurePage
=
submit
(
form
);
HtmlPage
proxyViewConfigurePage
=
j
.
submit
(
form
);
View
proxyView
=
user
.
getProperty
(
MyViewsProperty
.
class
).
getView
(
"proxy-view"
);
assertNotNull
(
proxyView
);
form
=
proxyViewConfigurePage
.
getFormByName
(
"viewConfig"
);
form
.
getSelectByName
(
"proxiedViewName"
).
setSelectedAttribute
(
"listView"
,
true
);
submit
(
form
);
j
.
submit
(
form
);
assertTrue
(
proxyView
instanceof
ProxyView
);
assertEquals
(((
ProxyView
)
proxyView
).
getProxiedViewName
(),
"listView"
);
assertEquals
(((
ProxyView
)
proxyView
).
getProxiedView
(),
listView
);
}
public
void
testD
eleteView
()
throws
Exception
{
WebClient
wc
=
new
WebClient
();
@Test
public
void
d
eleteView
()
throws
Exception
{
WebClient
wc
=
j
.
create
WebClient
();
ListView
v
=
new
ListView
(
"list"
,
jenkins
);
jenkins
.
addView
(
v
);
ListView
v
=
new
ListView
(
"list"
,
j
.
j
enkins
);
j
.
j
enkins
.
addView
(
v
);
HtmlPage
delete
=
wc
.
getPage
(
v
,
"delete"
);
submit
(
delete
.
getFormByName
(
"delete"
));
assertNull
(
jenkins
.
getView
(
"list"
));
j
.
submit
(
delete
.
getFormByName
(
"delete"
));
assertNull
(
j
.
j
enkins
.
getView
(
"list"
));
User
user
=
User
.
get
(
"user"
,
true
);
MyViewsProperty
p
=
user
.
getProperty
(
MyViewsProperty
.
class
);
v
=
new
ListView
(
"list"
,
p
);
p
.
addView
(
v
);
delete
=
wc
.
getPage
(
v
,
"delete"
);
submit
(
delete
.
getFormByName
(
"delete"
));
j
.
submit
(
delete
.
getFormByName
(
"delete"
));
assertNull
(
p
.
getView
(
"list"
));
}
@Bug
(
9367
)
public
void
testP
ersistence
()
throws
Exception
{
ListView
view
=
new
ListView
(
"foo"
,
jenkins
);
jenkins
.
addView
(
view
);
@Test
public
void
p
ersistence
()
throws
Exception
{
ListView
view
=
new
ListView
(
"foo"
,
j
.
j
enkins
);
j
.
j
enkins
.
addView
(
view
);
ListView
v
=
(
ListView
)
Jenkins
.
XSTREAM
.
fromXML
(
Jenkins
.
XSTREAM
.
toXML
(
view
));
System
.
out
.
println
(
v
.
getProperties
());
...
...
@@ -134,21 +137,21 @@ public class ViewTest extends HudsonTestCase {
}
@Bug
(
9367
)
public
void
testA
llImagesCanBeLoaded
()
throws
Exception
{
@Test
public
void
a
llImagesCanBeLoaded
()
throws
Exception
{
User
.
get
(
"user"
,
true
);
WebClient
webClient
=
new
WebClient
();
WebClient
webClient
=
j
.
create
WebClient
();
webClient
.
setJavaScriptEnabled
(
false
);
assertAllImageLoadSuccessfully
(
webClient
.
goTo
(
"asynchPeople"
));
j
.
assertAllImageLoadSuccessfully
(
webClient
.
goTo
(
"asynchPeople"
));
}
@Bug
(
16608
)
public
void
testNotAllo
edName
()
throws
Exception
{
HtmlForm
form
=
new
WebClient
().
goTo
(
"newView"
).
getFormByName
(
"createItem"
);
@Test
public
void
notAllow
edName
()
throws
Exception
{
HtmlForm
form
=
j
.
create
WebClient
().
goTo
(
"newView"
).
getFormByName
(
"createItem"
);
form
.
getInputByName
(
"name"
).
setValueAttribute
(
".."
);
form
.
getRadioButtonsByName
(
"mode"
).
get
(
0
).
setChecked
(
true
);
try
{
submit
(
form
);
j
.
submit
(
form
);
fail
(
"\"..\" should not be allowed."
);
}
catch
(
FailingHttpStatusCodeException
e
)
{
assertEquals
(
400
,
e
.
getStatusCode
());
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录