Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
FIY695
jenkins
提交
2b0bd977
J
jenkins
项目概览
FIY695
/
jenkins
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
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,发现更多精彩内容 >>
提交
2b0bd977
编写于
5月 30, 2013
作者:
J
Jesse Glick
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
JUnit 4.
上级
24334dc1
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
29 addition
and
24 deletion
+29
-24
test/src/test/java/hudson/model/JobTest.java
test/src/test/java/hudson/model/JobTest.java
+29
-24
test/src/test/resources/hudson/model/JobTest/configDotXmlPermission.zip
...resources/hudson/model/JobTest/configDotXmlPermission.zip
+0
-0
test/src/test/resources/hudson/model/JobTest/getArtifactsUpTo.zip
.../test/resources/hudson/model/JobTest/getArtifactsUpTo.zip
+0
-0
test/src/test/resources/hudson/model/JobTest/readPermission.zip
...rc/test/resources/hudson/model/JobTest/readPermission.zip
+0
-0
未找到文件。
test/src/test/java/hudson/model/JobTest.java
浏览文件 @
2b0bd977
...
...
@@ -35,26 +35,31 @@ import java.util.concurrent.CountDownLatch;
import
jenkins.model.ProjectNamingStrategy
;
import
static
org
.
junit
.
Assert
.*;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.jvnet.hudson.test.Bug
;
import
org.jvnet.hudson.test.
HudsonTestCas
e
;
import
org.jvnet.hudson.test.
JenkinsRul
e
;
import
org.jvnet.hudson.test.recipes.LocalData
;
/**
* @author Kohsuke Kawaguchi
*/
public
class
JobTest
extends
HudsonTestCase
{
public
class
JobTest
{
@Rule
public
JenkinsRule
j
=
new
JenkinsRule
();
@SuppressWarnings
(
"unchecked"
)
public
void
testJ
obPropertySummaryIsShownInMainPage
()
throws
Exception
{
AbstractProject
project
=
createFreeStyleProject
();
@Test
public
void
j
obPropertySummaryIsShownInMainPage
()
throws
Exception
{
AbstractProject
project
=
j
.
createFreeStyleProject
();
project
.
addProperty
(
new
JobPropertyImpl
(
"NeedleInPage"
));
HtmlPage
page
=
new
WebClient
().
getPage
(
project
);
HtmlPage
page
=
j
.
create
WebClient
().
getPage
(
project
);
WebAssert
.
assertTextPresent
(
page
,
"NeedleInPage"
);
}
public
void
testB
uildNumberSynchronization
()
throws
Exception
{
AbstractProject
project
=
createFreeStyleProject
();
@Test
public
void
b
uildNumberSynchronization
()
throws
Exception
{
AbstractProject
project
=
j
.
createFreeStyleProject
();
CountDownLatch
startLatch
=
new
CountDownLatch
(
1
);
CountDownLatch
stopLatch
=
new
CountDownLatch
(
2
);
BuildNumberSyncTester
test1
=
new
BuildNumberSyncTester
(
project
,
startLatch
,
stopLatch
,
true
);
...
...
@@ -167,8 +172,8 @@ public class JobTest extends HudsonTestCase {
}
@LocalData
public
void
testR
eadPermission
()
throws
Exception
{
WebClient
wc
=
new
WebClient
();
@Test
public
void
r
eadPermission
()
throws
Exception
{
JenkinsRule
.
WebClient
wc
=
j
.
create
WebClient
();
wc
.
assertFails
(
"job/testJob/"
,
HttpURLConnection
.
HTTP_NOT_FOUND
);
wc
.
assertFails
(
"jobCaseInsensitive/testJob/"
,
HttpURLConnection
.
HTTP_NOT_FOUND
);
wc
.
login
(
"joe"
);
// Has Item.READ permission
...
...
@@ -178,9 +183,9 @@ public class JobTest extends HudsonTestCase {
}
@LocalData
public
void
testC
onfigDotXmlPermission
()
throws
Exception
{
jenkins
.
setCrumbIssuer
(
null
);
WebClient
wc
=
new
WebClient
();
@Test
public
void
c
onfigDotXmlPermission
()
throws
Exception
{
j
.
j
enkins
.
setCrumbIssuer
(
null
);
JenkinsRule
.
WebClient
wc
=
j
.
create
WebClient
();
boolean
saveEnabled
=
Item
.
EXTENDED_READ
.
getEnabled
();
Item
.
EXTENDED_READ
.
setEnabled
(
true
);
try
{
...
...
@@ -196,7 +201,7 @@ public class JobTest extends HudsonTestCase {
}
}
private
static
void
tryConfigDotXml
(
WebClient
wc
,
int
status
,
String
msg
)
throws
Exception
{
private
static
void
tryConfigDotXml
(
JenkinsRule
.
WebClient
wc
,
int
status
,
String
msg
)
throws
Exception
{
// Verify we can GET the config.xml:
wc
.
goTo
(
"job/testJob/config.xml"
,
"application/xml"
);
// This page is a simple form to POST to /job/testJob/config.xml
...
...
@@ -212,10 +217,10 @@ public class JobTest extends HudsonTestCase {
}
@LocalData
@Bug
(
6371
)
public
void
testG
etArtifactsUpTo
()
throws
Exception
{
@Test
public
void
g
etArtifactsUpTo
()
throws
Exception
{
// There was a bug where intermediate directories were counted,
// so too few artifacts were returned.
Run
r
=
jenkins
.
getItemByFullName
(
"testJob"
,
Job
.
class
).
getLastCompletedBuild
();
Run
r
=
j
.
j
enkins
.
getItemByFullName
(
"testJob"
,
Job
.
class
).
getLastCompletedBuild
();
assertEquals
(
3
,
r
.
getArtifacts
().
size
());
assertEquals
(
3
,
r
.
getArtifactsUpTo
(
3
).
size
());
assertEquals
(
2
,
r
.
getArtifactsUpTo
(
2
).
size
());
...
...
@@ -223,29 +228,29 @@ public class JobTest extends HudsonTestCase {
}
@Bug
(
10182
)
public
void
testE
mptyDescriptionReturnsEmptyPage
()
throws
Exception
{
@Test
public
void
e
mptyDescriptionReturnsEmptyPage
()
throws
Exception
{
// A NPE was thrown if a job had a null (empty) description.
WebClient
wc
=
createWebClient
();
FreeStyleProject
project
=
createFreeStyleProject
(
"project"
);
JenkinsRule
.
WebClient
wc
=
j
.
createWebClient
();
FreeStyleProject
project
=
j
.
createFreeStyleProject
(
"project"
);
project
.
setDescription
(
"description"
);
assertEquals
(
"description"
,
((
TextPage
)
wc
.
goTo
(
"job/project/description"
,
"text/plain"
)).
getContent
());
project
.
setDescription
(
null
);
assertEquals
(
""
,
((
TextPage
)
wc
.
goTo
(
"job/project/description"
,
"text/plain"
)).
getContent
());
}
public
void
testP
rojectNamingStrategy
()
throws
Exception
{
jenkins
.
setProjectNamingStrategy
(
new
ProjectNamingStrategy
.
PatternProjectNamingStrategy
(
"DUMMY.*"
,
false
));
final
FreeStyleProject
p
=
createFreeStyleProject
(
"DUMMY_project"
);
@Test
public
void
p
rojectNamingStrategy
()
throws
Exception
{
j
.
j
enkins
.
setProjectNamingStrategy
(
new
ProjectNamingStrategy
.
PatternProjectNamingStrategy
(
"DUMMY.*"
,
false
));
final
FreeStyleProject
p
=
j
.
createFreeStyleProject
(
"DUMMY_project"
);
assertNotNull
(
"no project created"
,
p
);
try
{
createFreeStyleProject
(
"project"
);
j
.
createFreeStyleProject
(
"project"
);
fail
(
"should not get here, the project name is not allowed, therefore the creation must fail!"
);
}
catch
(
Failure
e
)
{
// OK, expected
}
finally
{
// set it back to the default naming strategy, otherwise all other tests would fail to create jobs!
jenkins
.
setProjectNamingStrategy
(
ProjectNamingStrategy
.
DEFAULT_NAMING_STRATEGY
);
j
.
j
enkins
.
setProjectNamingStrategy
(
ProjectNamingStrategy
.
DEFAULT_NAMING_STRATEGY
);
}
createFreeStyleProject
(
"project"
);
j
.
createFreeStyleProject
(
"project"
);
}
}
test/src/test/resources/hudson/model/JobTest/
testC
onfigDotXmlPermission.zip
→
test/src/test/resources/hudson/model/JobTest/
c
onfigDotXmlPermission.zip
浏览文件 @
2b0bd977
此差异由.gitattributes 抑制。
test/src/test/resources/hudson/model/JobTest/
testG
etArtifactsUpTo.zip
→
test/src/test/resources/hudson/model/JobTest/
g
etArtifactsUpTo.zip
浏览文件 @
2b0bd977
此差异由.gitattributes 抑制。
test/src/test/resources/hudson/model/JobTest/
testR
eadPermission.zip
→
test/src/test/resources/hudson/model/JobTest/
r
eadPermission.zip
浏览文件 @
2b0bd977
此差异由.gitattributes 抑制。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录