Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
LinuxSuRen
jenkins
提交
5531c112
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,发现更多精彩内容 >>
提交
5531c112
编写于
5月 06, 2013
作者:
J
Jesse Glick
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
JUnit 4.
上级
61e4f6f5
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
29 addition
and
23 deletion
+29
-23
test/src/test/groovy/hudson/cli/BuildCommandTest.groovy
test/src/test/groovy/hudson/cli/BuildCommandTest.groovy
+29
-23
未找到文件。
test/src/test/groovy/hudson/cli/BuildCommandTest.groovy
浏览文件 @
5531c112
...
...
@@ -23,7 +23,10 @@
*/
package
hudson.cli
import
org.jvnet.hudson.test.HudsonTestCase
import
org.jvnet.hudson.test.JenkinsRule
import
org.junit.Rule
import
org.junit.Test
import
static
org
.
junit
.
Assert
.*
import
hudson.tasks.Shell
import
hudson.util.OneShotEvent
import
org.jvnet.hudson.test.TestBuilder
...
...
@@ -40,12 +43,15 @@ import org.apache.commons.io.output.TeeOutputStream
*
* @author Kohsuke Kawaguchi
*/
public
class
BuildCommandTest
extends
HudsonTestCase
{
public
class
BuildCommandTest
{
@Rule
public
JenkinsRule
j
=
new
JenkinsRule
();
/**
* Just schedules a build and return.
*/
void
testA
sync
()
{
def
p
=
createFreeStyleProject
();
@Test
void
a
sync
()
{
def
p
=
j
.
createFreeStyleProject
();
def
started
=
new
OneShotEvent
();
def
completed
=
new
OneShotEvent
();
p
.
buildersList
.
add
([
perform:
{
AbstractBuild
build
,
Launcher
launcher
,
BuildListener
listener
->
...
...
@@ -55,7 +61,7 @@ public class BuildCommandTest extends HudsonTestCase {
}]
as
TestBuilder
);
// this should be asynchronous
def
cli
=
new
CLI
(
getURL
()
)
def
cli
=
new
CLI
(
j
.
URL
)
try
{
assertEquals
(
0
,
cli
.
execute
([
"build"
,
p
.
name
]))
started
.
block
()
...
...
@@ -70,11 +76,11 @@ public class BuildCommandTest extends HudsonTestCase {
/**
* Tests synchronous execution.
*/
void
testS
ync
()
{
def
p
=
createFreeStyleProject
();
@Test
void
s
ync
()
{
def
p
=
j
.
createFreeStyleProject
();
p
.
buildersList
.
add
(
new
Shell
(
"sleep 3"
));
def
cli
=
new
CLI
(
getURL
()
)
def
cli
=
new
CLI
(
j
.
URL
)
try
{
cli
.
execute
([
"build"
,
"-s"
,
p
.
name
])
assertFalse
(
p
.
getBuildByNumber
(
1
).
isBuilding
())
...
...
@@ -87,11 +93,11 @@ public class BuildCommandTest extends HudsonTestCase {
/**
* Tests synchronous execution with retried verbose output
*/
void
testS
yncWOutputStreaming
()
{
def
p
=
createFreeStyleProject
();
@Test
void
s
yncWOutputStreaming
()
{
def
p
=
j
.
createFreeStyleProject
();
p
.
buildersList
.
add
(
new
Shell
(
"sleep 3"
));
def
cli
=
new
CLI
(
getURL
()
)
def
cli
=
new
CLI
(
j
.
URL
)
try
{
cli
.
execute
([
"build"
,
"-s"
,
"-v"
,
"-r"
,
"5"
,
p
.
name
])
assertFalse
(
p
.
getBuildByNumber
(
1
).
isBuilding
())
...
...
@@ -100,28 +106,28 @@ public class BuildCommandTest extends HudsonTestCase {
}
}
void
testP
arameters
()
{
def
p
=
createFreeStyleProject
();
@Test
void
p
arameters
()
{
def
p
=
j
.
createFreeStyleProject
();
p
.
addProperty
(
new
ParametersDefinitionProperty
([
new
StringParameterDefinition
(
"key"
,
null
)]));
def
cli
=
new
CLI
(
getURL
()
)
def
cli
=
new
CLI
(
j
.
URL
)
try
{
cli
.
execute
([
"build"
,
"-s"
,
"-p"
,
"key=foobar"
,
p
.
name
])
def
b
=
assertBuildStatusSuccess
(
p
.
getBuildByNumber
(
1
))
def
b
=
j
.
assertBuildStatusSuccess
(
p
.
getBuildByNumber
(
1
))
assertEquals
(
"foobar"
,
b
.
getAction
(
ParametersAction
.
class
).
getParameter
(
"key"
).
value
)
}
finally
{
cli
.
close
();
}
}
void
testD
efaultParameters
()
{
def
p
=
createFreeStyleProject
();
@Test
void
d
efaultParameters
()
{
def
p
=
j
.
createFreeStyleProject
();
p
.
addProperty
(
new
ParametersDefinitionProperty
([
new
StringParameterDefinition
(
"key"
,
"default"
),
new
StringParameterDefinition
(
"key2"
,
"default2"
)
]));
def
cli
=
new
CLI
(
getURL
()
)
def
cli
=
new
CLI
(
j
.
URL
)
try
{
cli
.
execute
([
"build"
,
"-s"
,
"-p"
,
"key=foobar"
,
p
.
name
])
def
b
=
assertBuildStatusSuccess
(
p
.
getBuildByNumber
(
1
))
def
b
=
j
.
assertBuildStatusSuccess
(
p
.
getBuildByNumber
(
1
))
assertEquals
(
"foobar"
,
b
.
getAction
(
ParametersAction
.
class
).
getParameter
(
"key"
).
value
)
assertEquals
(
"default2"
,
b
.
getAction
(
ParametersAction
.
class
).
getParameter
(
"key2"
).
value
)
}
finally
{
...
...
@@ -129,13 +135,13 @@ public class BuildCommandTest extends HudsonTestCase {
}
}
void
testC
onsoleOutput
()
{
def
p
=
createFreeStyleProject
()
def
cli
=
new
CLI
(
getURL
()
)
@Test
void
c
onsoleOutput
()
{
def
p
=
j
.
createFreeStyleProject
()
def
cli
=
new
CLI
(
j
.
URL
)
try
{
def
o
=
new
ByteArrayOutputStream
()
cli
.
execute
([
"build"
,
"-s"
,
"-v"
,
p
.
name
],
System
.
in
,
new
TeeOutputStream
(
System
.
out
,
o
),
System
.
err
)
assertBuildStatusSuccess
(
p
.
getBuildByNumber
(
1
))
j
.
assertBuildStatusSuccess
(
p
.
getBuildByNumber
(
1
))
assertTrue
(
o
.
toString
(),
o
.
toString
().
contains
(
"Started by command line by anonymous"
))
assertTrue
(
o
.
toString
().
contains
(
"Finished: SUCCESS"
))
}
finally
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录