Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
jenkins
提交
3aa812fe
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,发现更多精彩内容 >>
提交
3aa812fe
编写于
1月 29, 2014
作者:
O
Oliver Gondža
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactor CLI tests
上级
de132fb3
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
51 addition
and
57 deletion
+51
-57
test/src/test/java/hudson/cli/CopyJobCommandTest.java
test/src/test/java/hudson/cli/CopyJobCommandTest.java
+3
-9
test/src/test/java/hudson/cli/CreateNodeCommandTest.java
test/src/test/java/hudson/cli/CreateNodeCommandTest.java
+12
-13
test/src/test/java/hudson/cli/CreateViewCommandTest.java
test/src/test/java/hudson/cli/CreateViewCommandTest.java
+3
-6
test/src/test/java/hudson/cli/DeleteViewCommandTest.java
test/src/test/java/hudson/cli/DeleteViewCommandTest.java
+2
-3
test/src/test/java/hudson/cli/GetNodeCommandTest.java
test/src/test/java/hudson/cli/GetNodeCommandTest.java
+10
-6
test/src/test/java/hudson/cli/HelpCommandTest.java
test/src/test/java/hudson/cli/HelpCommandTest.java
+5
-5
test/src/test/java/hudson/cli/SetBuildDisplayNameCommandTest.java
.../test/java/hudson/cli/SetBuildDisplayNameCommandTest.java
+6
-6
test/src/test/java/hudson/cli/UpdateNodeCommandTest.java
test/src/test/java/hudson/cli/UpdateNodeCommandTest.java
+8
-7
test/src/test/java/hudson/cli/UpdateViewCommandTest.java
test/src/test/java/hudson/cli/UpdateViewCommandTest.java
+2
-2
未找到文件。
test/src/test/java/hudson/cli/CopyJobCommandTest.java
浏览文件 @
3aa812fe
...
...
@@ -35,9 +35,7 @@ import org.jvnet.hudson.test.MockFolder;
import
static
org
.
hamcrest
.
MatcherAssert
.
assertThat
;
import
static
hudson
.
cli
.
CLICommandInvoker
.
Matcher
.
hasNoStandardOutput
;
import
static
hudson
.
cli
.
CLICommandInvoker
.
Matcher
.
hasNoErrorOutput
;
import
static
hudson
.
cli
.
CLICommandInvoker
.
Matcher
.
succeeded
;
import
static
hudson
.
cli
.
CLICommandInvoker
.
Matcher
.
succeededSilently
;
@SuppressWarnings
(
"DM_DEFAULT_ENCODING"
)
public
class
CopyJobCommandTest
{
...
...
@@ -56,9 +54,7 @@ public class CopyJobCommandTest {
CLICommandInvoker
.
Result
result
=
command
.
invokeWithArgs
(
"dir1/p1"
,
"dir2/p2"
);
assertThat
(
result
,
succeeded
());
assertThat
(
result
,
hasNoStandardOutput
());
assertThat
(
result
,
hasNoErrorOutput
());
assertThat
(
result
,
succeededSilently
());
assertNotNull
(
j
.
jenkins
.
getItemByFullName
(
"dir2/p2"
));
// TODO test copying from/to root, or into nonexistent folder
...
...
@@ -72,9 +68,7 @@ public class CopyJobCommandTest {
CLICommandInvoker
.
Result
result
=
command
.
invokeWithArgs
(
p1
.
getName
(),
copiedProjectName
);
assertThat
(
result
,
succeeded
());
assertThat
(
result
,
hasNoStandardOutput
());
assertThat
(
result
,
hasNoErrorOutput
());
assertThat
(
result
,
succeededSilently
());
FreeStyleProject
p2
=
(
FreeStyleProject
)
j
.
jenkins
.
getItem
(
copiedProjectName
);
...
...
test/src/test/java/hudson/cli/CreateNodeCommandTest.java
浏览文件 @
3aa812fe
...
...
@@ -28,7 +28,9 @@ import static org.hamcrest.MatcherAssert.assertThat;
import
static
org
.
hamcrest
.
Matchers
.
containsString
;
import
static
org
.
hamcrest
.
Matchers
.
equalTo
;
import
static
org
.
hamcrest
.
Matchers
.
nullValue
;
import
static
org
.
hamcrest
.
text
.
IsEmptyString
.
isEmptyString
;
import
static
hudson
.
cli
.
CLICommandInvoker
.
Matcher
.
failedWith
;
import
static
hudson
.
cli
.
CLICommandInvoker
.
Matcher
.
hasNoStandardOutput
;
import
static
hudson
.
cli
.
CLICommandInvoker
.
Matcher
.
succeededSilently
;
import
hudson.model.Computer
;
import
hudson.model.Node
;
import
hudson.model.Slave
;
...
...
@@ -59,8 +61,8 @@ public class CreateNodeCommandTest {
;
assertThat
(
result
.
stderr
(),
containsString
(
"user is missing the Slave/Create permission"
));
assertThat
(
"No output expected"
,
result
.
stdout
(),
isEmptyString
());
assertThat
(
"Command is expected to fail"
,
result
.
returnCode
(),
equalTo
(-
1
));
assertThat
(
result
,
hasNoStandardOutput
());
assertThat
(
result
,
failedWith
(-
1
));
}
@Test
public
void
createNode
()
throws
Exception
{
...
...
@@ -71,8 +73,7 @@ public class CreateNodeCommandTest {
.
invoke
()
;
assertThat
(
"No error output expected"
,
result
.
stderr
(),
isEmptyString
());
assertThat
(
"Command is expected to succeed"
,
result
.
returnCode
(),
equalTo
(
0
));
assertThat
(
result
,
succeededSilently
());
final
Slave
updatedSlave
=
(
Slave
)
j
.
jenkins
.
getNode
(
"SlaveFromXML"
);
assertThat
(
updatedSlave
.
getNodeName
(),
equalTo
(
"SlaveFromXML"
));
...
...
@@ -88,8 +89,7 @@ public class CreateNodeCommandTest {
.
invokeWithArgs
(
"CustomSlaveName"
)
;
assertThat
(
"No error output expected"
,
result
.
stderr
(),
isEmptyString
());
assertThat
(
"Command is expected to succeed"
,
result
.
returnCode
(),
equalTo
(
0
));
assertThat
(
result
,
succeededSilently
());
assertThat
(
"A slave with original name should not exist"
,
j
.
jenkins
.
getNode
(
"SlaveFromXml"
),
nullValue
());
...
...
@@ -109,8 +109,7 @@ public class CreateNodeCommandTest {
.
invokeWithArgs
(
"CustomSlaveName"
)
;
assertThat
(
"No error output expected"
,
result
.
stderr
(),
isEmptyString
());
assertThat
(
"Command is expected to succeed"
,
result
.
returnCode
(),
equalTo
(
0
));
assertThat
(
result
,
succeededSilently
());
assertThat
(
"A slave with original name should be left untouched"
,
j
.
jenkins
.
getNode
(
"SlaveFromXml"
),
equalTo
(
originalSlave
));
...
...
@@ -131,8 +130,8 @@ public class CreateNodeCommandTest {
;
assertThat
(
result
.
stderr
(),
containsString
(
"Node 'SlaveFromXML' already exists"
));
assertThat
(
"No output expected"
,
result
.
stdout
(),
isEmptyString
());
assertThat
(
"Command is expected to fail"
,
result
.
returnCode
(),
equalTo
(-
1
));
assertThat
(
result
,
hasNoStandardOutput
());
assertThat
(
result
,
failedWith
(-
1
));
}
@Test
public
void
createNodeShouldFailIfNodeAlreadyExistWhenNameSpecifiedExplicitly
()
throws
Exception
{
...
...
@@ -146,7 +145,7 @@ public class CreateNodeCommandTest {
;
assertThat
(
result
.
stderr
(),
containsString
(
"Node 'ExistingSlave' already exists"
));
assertThat
(
"No output expected"
,
result
.
stdout
(),
isEmptyString
());
assertThat
(
"Command is expected to fail"
,
result
.
returnCode
(),
equalTo
(-
1
));
assertThat
(
result
,
hasNoStandardOutput
());
assertThat
(
result
,
failedWith
(-
1
));
}
}
test/src/test/java/hudson/cli/CreateViewCommandTest.java
浏览文件 @
3aa812fe
...
...
@@ -28,6 +28,7 @@ import static hudson.cli.CLICommandInvoker.Matcher.failedWith;
import
static
hudson
.
cli
.
CLICommandInvoker
.
Matcher
.
hasNoStandardOutput
;
import
static
hudson
.
cli
.
CLICommandInvoker
.
Matcher
.
hasNoErrorOutput
;
import
static
hudson
.
cli
.
CLICommandInvoker
.
Matcher
.
succeeded
;
import
static
hudson
.
cli
.
CLICommandInvoker
.
Matcher
.
succeededSilently
;
import
static
org
.
hamcrest
.
MatcherAssert
.
assertThat
;
import
static
org
.
hamcrest
.
Matchers
.
containsString
;
import
static
org
.
hamcrest
.
Matchers
.
equalTo
;
...
...
@@ -76,9 +77,7 @@ public class CreateViewCommandTest {
.
invoke
()
;
assertThat
(
result
,
succeeded
());
assertThat
(
result
,
hasNoErrorOutput
());
assertThat
(
result
,
hasNoStandardOutput
());
assertThat
(
result
,
succeededSilently
());
final
View
updatedView
=
j
.
jenkins
.
getView
(
"ViewFromXML"
);
assertThat
(
updatedView
.
getViewName
(),
equalTo
(
"ViewFromXML"
));
...
...
@@ -94,9 +93,7 @@ public class CreateViewCommandTest {
.
invokeWithArgs
(
"CustomViewName"
)
;
assertThat
(
result
,
succeeded
());
assertThat
(
result
,
hasNoErrorOutput
());
assertThat
(
result
,
hasNoStandardOutput
());
assertThat
(
result
,
succeededSilently
());
assertThat
(
"A view with original name should not exist"
,
j
.
jenkins
.
getView
(
"ViewFromXML"
),
nullValue
());
...
...
test/src/test/java/hudson/cli/DeleteViewCommandTest.java
浏览文件 @
3aa812fe
...
...
@@ -31,6 +31,7 @@ import static org.hamcrest.Matchers.nullValue;
import
static
hudson
.
cli
.
CLICommandInvoker
.
Matcher
.
hasNoStandardOutput
;
import
static
hudson
.
cli
.
CLICommandInvoker
.
Matcher
.
hasNoErrorOutput
;
import
static
hudson
.
cli
.
CLICommandInvoker
.
Matcher
.
succeeded
;
import
static
hudson
.
cli
.
CLICommandInvoker
.
Matcher
.
succeededSilently
;
import
static
hudson
.
cli
.
CLICommandInvoker
.
Matcher
.
failedWith
;
import
java.io.IOException
;
...
...
@@ -78,9 +79,7 @@ public class DeleteViewCommandTest {
.
invokeWithArgs
(
"aView"
)
;
assertThat
(
result
,
succeeded
());
assertThat
(
result
,
hasNoStandardOutput
());
assertThat
(
result
,
hasNoErrorOutput
());
assertThat
(
result
,
succeededSilently
());
assertThat
(
j
.
jenkins
.
getView
(
"aView"
),
nullValue
());
}
...
...
test/src/test/java/hudson/cli/GetNodeCommandTest.java
浏览文件 @
3aa812fe
...
...
@@ -24,6 +24,10 @@
package
hudson.cli
;
import
static
hudson
.
cli
.
CLICommandInvoker
.
Matcher
.
failedWith
;
import
static
hudson
.
cli
.
CLICommandInvoker
.
Matcher
.
hasNoStandardOutput
;
import
static
hudson
.
cli
.
CLICommandInvoker
.
Matcher
.
hasNoErrorOutput
;
import
static
hudson
.
cli
.
CLICommandInvoker
.
Matcher
.
succeeded
;
import
static
org
.
hamcrest
.
MatcherAssert
.
assertThat
;
import
static
org
.
hamcrest
.
Matchers
.
containsString
;
import
static
org
.
hamcrest
.
Matchers
.
equalTo
;
...
...
@@ -58,8 +62,8 @@ public class GetNodeCommandTest {
;
assertThat
(
result
.
stderr
(),
containsString
(
"user is missing the Slave/ExtendedRead permission"
));
assertThat
(
"No output expected"
,
result
.
stdout
(),
isEmptyString
(
));
assertThat
(
"Command is expected to fail"
,
result
.
returnCode
(),
equalTo
(-
1
));
assertThat
(
result
,
failedWith
(-
1
));
assertThat
(
result
,
hasNoStandardOutput
(
));
}
@Test
public
void
getNodeShouldYieldConfigXml
()
throws
Exception
{
...
...
@@ -73,8 +77,8 @@ public class GetNodeCommandTest {
assertThat
(
result
.
stdout
(),
startsWith
(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
));
assertThat
(
result
.
stdout
(),
containsString
(
"<name>MySlave</name>"
));
assertThat
(
"No error output expected"
,
result
.
stderr
(),
isEmptyString
());
assertThat
(
"Command is expected to succeed"
,
result
.
returnCode
(),
equalTo
(
0
));
assertThat
(
result
,
hasNoErrorOutput
());
assertThat
(
result
,
succeeded
(
));
}
@Test
public
void
getNodeShouldFailIfNodeDoesNotExist
()
throws
Exception
{
...
...
@@ -85,7 +89,7 @@ public class GetNodeCommandTest {
;
assertThat
(
result
.
stderr
(),
containsString
(
"No such node 'MySlave'"
));
assertThat
(
"No output expected"
,
result
.
stdout
(),
isEmptyString
(
));
assertThat
(
"Command is expected to fail"
,
result
.
returnCode
(),
equalTo
(-
1
));
assertThat
(
result
,
failedWith
(-
1
));
assertThat
(
result
,
hasNoStandardOutput
(
));
}
}
test/src/test/java/hudson/cli/HelpCommandTest.java
浏览文件 @
3aa812fe
...
...
@@ -24,9 +24,9 @@
package
hudson.cli
;
import
static
hudson
.
cli
.
CLICommandInvoker
.
Matcher
.*;
import
static
org
.
junit
.
Assert
.*;
import
static
org
.
hamcrest
.
CoreMatchers
.*;
import
static
org
.
hamcrest
.
text
.
IsEmptyString
.
isEmptyString
;
import
static
org
.
hamcrest
.
text
.
StringContainsInOrder
.
stringContainsInOrder
;
import
java.io.PrintStream
;
...
...
@@ -58,15 +58,15 @@ public class HelpCommandTest {
assertContainsOverviewOfMethodCommand
(
generalHelp
);
Result
result
=
command
.
invokeWithArgs
(
ClassCommand
.
NAME
);
assertThat
(
result
.
returnCode
(),
equalTo
(
0
));
assertThat
(
result
.
stdout
(),
isEmptyString
());
assertThat
(
result
,
succeeded
(
));
assertThat
(
result
,
hasNoStandardOutput
());
assertContainsUsageOfClassCommand
(
result
.
stderr
());
result
=
command
.
invokeWithArgs
(
"offline-node"
);
assertThat
(
result
.
returnCode
(),
equalTo
(
0
));
assertThat
(
result
.
stdout
(),
isEmptyString
());
assertThat
(
result
,
succeeded
(
));
assertThat
(
result
,
hasNoStandardOutput
());
assertContainsUsageOfMethodCommand
(
result
.
stderr
());
}
...
...
test/src/test/java/hudson/cli/SetBuildDisplayNameCommandTest.java
浏览文件 @
3aa812fe
...
...
@@ -24,10 +24,12 @@
package
hudson.cli
;
import
static
hudson
.
cli
.
CLICommandInvoker
.
Matcher
.
failedWith
;
import
static
hudson
.
cli
.
CLICommandInvoker
.
Matcher
.
hasNoStandardOutput
;
import
static
hudson
.
cli
.
CLICommandInvoker
.
Matcher
.
succeededSilently
;
import
static
org
.
hamcrest
.
MatcherAssert
.
assertThat
;
import
static
org
.
hamcrest
.
Matchers
.
containsString
;
import
static
org
.
hamcrest
.
Matchers
.
equalTo
;
import
static
org
.
hamcrest
.
text
.
IsEmptyString
.
isEmptyString
;
import
hudson.model.FreeStyleBuild
;
import
hudson.model.FreeStyleProject
;
...
...
@@ -56,8 +58,8 @@ public class SetBuildDisplayNameCommandTest {
;
assertThat
(
result
.
stderr
(),
containsString
(
"Build #42 does not exist"
));
assertThat
(
"No output expected"
,
result
.
stdout
(),
isEmptyString
());
assertThat
(
"Command is expected to fail"
,
result
.
returnCode
(),
equalTo
(-
1
));
assertThat
(
result
,
hasNoStandardOutput
());
assertThat
(
result
,
failedWith
(-
1
));
}
@Test
public
void
setDescriptionSuccesfully
()
throws
Exception
{
...
...
@@ -69,9 +71,7 @@ public class SetBuildDisplayNameCommandTest {
.
invokeWithArgs
(
"project"
,
"1"
,
"DisplayName"
)
;
assertThat
(
"No output expected"
,
result
.
stdout
(),
isEmptyString
());
assertThat
(
"No error output expected"
,
result
.
stderr
(),
isEmptyString
());
assertThat
(
"Command is expected to succeed"
,
result
.
returnCode
(),
equalTo
(
0
));
assertThat
(
result
,
succeededSilently
());
assertThat
(
build
.
getDisplayName
(),
equalTo
(
"DisplayName"
));
}
}
test/src/test/java/hudson/cli/UpdateNodeCommandTest.java
浏览文件 @
3aa812fe
...
...
@@ -28,7 +28,9 @@ import static org.hamcrest.MatcherAssert.assertThat;
import
static
org
.
hamcrest
.
Matchers
.
containsString
;
import
static
org
.
hamcrest
.
Matchers
.
equalTo
;
import
static
org
.
hamcrest
.
Matchers
.
nullValue
;
import
static
org
.
hamcrest
.
text
.
IsEmptyString
.
isEmptyString
;
import
static
hudson
.
cli
.
CLICommandInvoker
.
Matcher
.
failedWith
;
import
static
hudson
.
cli
.
CLICommandInvoker
.
Matcher
.
hasNoStandardOutput
;
import
static
hudson
.
cli
.
CLICommandInvoker
.
Matcher
.
succeededSilently
;
import
hudson.model.Computer
;
import
hudson.model.Node
;
import
jenkins.model.Jenkins
;
...
...
@@ -59,8 +61,8 @@ public class UpdateNodeCommandTest {
;
assertThat
(
result
.
stderr
(),
containsString
(
"user is missing the Slave/Configure permission"
));
assertThat
(
"No output expected"
,
result
.
stdout
(),
isEmptyString
(
));
assertThat
(
"Command is expected to fail"
,
result
.
returnCode
(),
equalTo
(-
1
));
assertThat
(
result
,
failedWith
(-
1
));
assertThat
(
result
,
hasNoStandardOutput
(
));
}
@Test
public
void
updateNodeShouldModifyNodeConfiguration
()
throws
Exception
{
...
...
@@ -73,8 +75,7 @@ public class UpdateNodeCommandTest {
.
invokeWithArgs
(
"MySlave"
)
;
assertThat
(
"No error output expected"
,
result
.
stderr
(),
isEmptyString
());
assertThat
(
"Command is expected to succeed"
,
result
.
returnCode
(),
equalTo
(
0
));
assertThat
(
result
,
succeededSilently
());
assertThat
(
"A slave with old name should not exist"
,
j
.
jenkins
.
getNode
(
"MySlave"
),
nullValue
());
...
...
@@ -92,7 +93,7 @@ public class UpdateNodeCommandTest {
;
assertThat
(
result
.
stderr
(),
containsString
(
"No such node 'MySlave'"
));
assertThat
(
"No output expected"
,
result
.
stdout
(),
isEmptyString
(
));
assertThat
(
"Command is expected to fail"
,
result
.
returnCode
(),
equalTo
(-
1
));
assertThat
(
result
,
failedWith
(-
1
));
assertThat
(
result
,
hasNoStandardOutput
(
));
}
}
test/src/test/java/hudson/cli/UpdateViewCommandTest.java
浏览文件 @
3aa812fe
...
...
@@ -28,6 +28,7 @@ import static hudson.cli.CLICommandInvoker.Matcher.failedWith;
import
static
hudson
.
cli
.
CLICommandInvoker
.
Matcher
.
hasNoStandardOutput
;
import
static
hudson
.
cli
.
CLICommandInvoker
.
Matcher
.
hasNoErrorOutput
;
import
static
hudson
.
cli
.
CLICommandInvoker
.
Matcher
.
succeeded
;
import
static
hudson
.
cli
.
CLICommandInvoker
.
Matcher
.
succeededSilently
;
import
static
org
.
hamcrest
.
MatcherAssert
.
assertThat
;
import
static
org
.
hamcrest
.
Matchers
.
containsString
;
import
static
org
.
hamcrest
.
Matchers
.
equalTo
;
...
...
@@ -77,8 +78,7 @@ public class UpdateViewCommandTest {
.
invokeWithArgs
(
"aView"
)
;
assertThat
(
result
,
succeeded
());
assertThat
(
result
,
hasNoErrorOutput
());
assertThat
(
result
,
succeededSilently
());
assertThat
(
"Update should not modify view name"
,
j
.
jenkins
.
getView
(
"ViewFromXML"
),
nullValue
());
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录