Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
jenkins
提交
ed80d244
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,发现更多精彩内容 >>
未验证
提交
ed80d244
编写于
4月 24, 2020
作者:
R
Raihaan Shouhell
提交者:
GitHub
4月 24, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4666 from StefanSpieker/test_cleanup
minor test refactoring
上级
31a6b302
34202aaf
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
26 addition
and
28 deletion
+26
-28
core/src/test/java/hudson/model/ActionableTest.java
core/src/test/java/hudson/model/ActionableTest.java
+9
-7
core/src/test/java/hudson/model/EnvironmentContributingActionTest.java
.../java/hudson/model/EnvironmentContributingActionTest.java
+17
-21
未找到文件。
core/src/test/java/hudson/model/ActionableTest.java
浏览文件 @
ed80d244
...
...
@@ -33,13 +33,14 @@ import static org.junit.Assert.*;
import
java.util.Collections
;
import
java.util.List
;
import
edu.umd.cs.findbugs.annotations.NonNull
;
import
org.junit.Assert
;
import
org.junit.Test
;
import
org.jvnet.hudson.test.Issue
;
public
class
ActionableTest
{
private
Actionable
thing
=
new
ActionableImpl
();
private
final
Actionable
thing
=
new
ActionableImpl
();
@SuppressWarnings
(
"deprecation"
)
@Test
...
...
@@ -67,6 +68,7 @@ public class ActionableTest {
}
@Override
@NonNull
public
List
<
Action
>
getActions
()
{
return
specialActions
;
}
...
...
@@ -75,7 +77,7 @@ public class ActionableTest {
@SuppressWarnings
(
"deprecation"
)
@Issue
(
"JENKINS-39555"
)
@Test
public
void
testExtensionOverrides
()
throws
Exception
{
public
void
testExtensionOverrides
()
{
ActionableOverride
myOverridden
=
new
ActionableOverride
();
InvisibleAction
invis
=
new
InvisibleAction
()
{
};
...
...
@@ -144,11 +146,11 @@ public class ActionableTest {
thing
.
addAction
(
a2
);
assertEquals
(
Arrays
.
asList
(
a1
,
a2
),
thing
.
getActions
());
assertThat
(
thing
.
removeAction
(
a1
),
is
(
true
));
assertEquals
(
Arrays
.
as
List
(
a2
),
thing
.
getActions
());
assertEquals
(
Collections
.
singleton
List
(
a2
),
thing
.
getActions
());
assertThat
(
thing
.
removeAction
(
a1
),
is
(
false
));
assertEquals
(
Arrays
.
as
List
(
a2
),
thing
.
getActions
());
assertEquals
(
Collections
.
singleton
List
(
a2
),
thing
.
getActions
());
assertThat
(
thing
.
removeAction
(
null
),
is
(
false
));
assertEquals
(
Arrays
.
as
List
(
a2
),
thing
.
getActions
());
assertEquals
(
Collections
.
singleton
List
(
a2
),
thing
.
getActions
());
}
@SuppressWarnings
(
"deprecation"
)
...
...
@@ -160,9 +162,9 @@ public class ActionableTest {
thing
.
addAction
(
a2
);
assertEquals
(
Arrays
.
asList
(
a1
,
a2
),
thing
.
getActions
());
assertThat
(
thing
.
removeActions
(
CauseAction
.
class
),
is
(
true
));
assertEquals
(
Arrays
.
as
List
(
a2
),
thing
.
getActions
());
assertEquals
(
Collections
.
singleton
List
(
a2
),
thing
.
getActions
());
assertThat
(
thing
.
removeActions
(
CauseAction
.
class
),
is
(
false
));
assertEquals
(
Arrays
.
as
List
(
a2
),
thing
.
getActions
());
assertEquals
(
Collections
.
singleton
List
(
a2
),
thing
.
getActions
());
}
@SuppressWarnings
(
"deprecation"
)
...
...
core/src/test/java/hudson/model/EnvironmentContributingActionTest.java
浏览文件 @
ed80d244
package
hudson.model
;
import
edu.umd.cs.findbugs.annotations.NonNull
;
import
hudson.EnvVars
;
import
org.junit.Test
;
...
...
@@ -15,7 +16,7 @@ public class EnvironmentContributingActionTest {
private
boolean
wasCalled
=
false
;
@Override
public
void
buildEnvironment
(
Run
<?,
?>
run
,
EnvVars
env
)
{
public
void
buildEnvironment
(
@NonNull
Run
<?,
?>
run
,
@NonNull
EnvVars
env
)
{
wasCalled
=
true
;
}
...
...
@@ -49,7 +50,7 @@ public class EnvironmentContributingActionTest {
}
@Override
public
void
buildEnvironment
(
Run
<?,
?>
run
,
EnvVars
env
)
{
public
void
buildEnvironment
(
@NonNull
Run
<?,
?>
run
,
@NonNull
EnvVars
env
)
{
wasCalledRun
=
true
;
}
...
...
@@ -65,9 +66,8 @@ public class EnvironmentContributingActionTest {
private
final
EnvVars
envVars
=
mock
(
EnvVars
.
class
);
@Test
public
void
testOverrideRunMethodAndCallNewMethod
()
throws
Exception
{
Run
run
=
mock
(
Run
.
class
);
Node
node
=
mock
(
Node
.
class
);
public
void
testOverrideRunMethodAndCallNewMethod
()
{
Run
<?,?>
run
=
mock
(
Run
.
class
);
OverrideRun
overrideRun
=
new
OverrideRun
();
overrideRun
.
buildEnvironment
(
run
,
envVars
);
...
...
@@ -77,12 +77,11 @@ public class EnvironmentContributingActionTest {
/**
* If only non-deprecated method was overridden it would be executed even if someone would call deprecated method.
* @throws Exception if happens.
*/
@Test
@SuppressWarnings
(
"deprecation"
)
public
void
testOverrideRunMethodAndCallDeprecatedMethod
()
throws
Exception
{
AbstractBuild
abstractBuild
=
mock
(
AbstractBuild
.
class
);
public
void
testOverrideRunMethodAndCallDeprecatedMethod
()
{
AbstractBuild
<?,?>
abstractBuild
=
mock
(
AbstractBuild
.
class
);
when
(
abstractBuild
.
getBuiltOn
()).
thenReturn
(
mock
(
Node
.
class
));
OverrideRun
overrideRun
=
new
OverrideRun
();
...
...
@@ -93,11 +92,10 @@ public class EnvironmentContributingActionTest {
/**
* {@link AbstractBuild} should work as before.
* @throws Exception if happens.
*/
@Test
public
void
testOverrideAbstractBuildAndCallNewMethodWithAbstractBuild
()
throws
Exception
{
AbstractBuild
abstractBuild
=
mock
(
AbstractBuild
.
class
);
public
void
testOverrideAbstractBuildAndCallNewMethodWithAbstractBuild
()
{
AbstractBuild
<?,?>
abstractBuild
=
mock
(
AbstractBuild
.
class
);
OverrideAbstractBuild
action
=
new
OverrideAbstractBuild
();
action
.
buildEnvironment
(
abstractBuild
,
envVars
);
...
...
@@ -107,11 +105,10 @@ public class EnvironmentContributingActionTest {
/**
* {@link Run} should not execute method that was overridden for {@link AbstractBuild}.
* @throws Exception if happens.
*/
@Test
public
void
testOverrideAbstractBuildAndCallNewMethodWithRun
()
throws
Exception
{
Run
run
=
mock
(
Run
.
class
);
public
void
testOverrideAbstractBuildAndCallNewMethodWithRun
()
{
Run
<?,?>
run
=
mock
(
Run
.
class
);
OverrideAbstractBuild
action
=
new
OverrideAbstractBuild
();
action
.
buildEnvironment
(
run
,
envVars
);
...
...
@@ -121,11 +118,10 @@ public class EnvironmentContributingActionTest {
/**
* If someone wants to use overridden deprecated method, it would still work.
* @throws Exception if happens.
*/
@Test
public
void
testOverrideAbstractBuildAndCallDeprecatedMethod
()
throws
Exception
{
AbstractBuild
abstractBuild
=
mock
(
AbstractBuild
.
class
);
public
void
testOverrideAbstractBuildAndCallDeprecatedMethod
()
{
AbstractBuild
<?,?>
abstractBuild
=
mock
(
AbstractBuild
.
class
);
OverrideAbstractBuild
overrideRun
=
new
OverrideAbstractBuild
();
overrideRun
.
buildEnvVars
(
abstractBuild
,
envVars
);
...
...
@@ -134,8 +130,8 @@ public class EnvironmentContributingActionTest {
}
@Test
public
void
testOverrideBothAndCallNewMethod
()
throws
Exception
{
Run
run
=
mock
(
Run
.
class
);
public
void
testOverrideBothAndCallNewMethod
()
{
Run
<?,?>
run
=
mock
(
Run
.
class
);
OverrideBoth
overrideRun
=
new
OverrideBoth
();
overrideRun
.
buildEnvironment
(
run
,
envVars
);
...
...
@@ -144,8 +140,8 @@ public class EnvironmentContributingActionTest {
}
@Test
public
void
testOverrideBothAndCallDeprecatedMethod
()
throws
Exception
{
AbstractBuild
abstractBuild
=
mock
(
AbstractBuild
.
class
);
public
void
testOverrideBothAndCallDeprecatedMethod
()
{
AbstractBuild
<?,?>
abstractBuild
=
mock
(
AbstractBuild
.
class
);
OverrideBoth
overrideRun
=
new
OverrideBoth
();
overrideRun
.
buildEnvVars
(
abstractBuild
,
envVars
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录