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.*;
...
@@ -33,13 +33,14 @@ import static org.junit.Assert.*;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.List
;
import
edu.umd.cs.findbugs.annotations.NonNull
;
import
org.junit.Assert
;
import
org.junit.Assert
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.jvnet.hudson.test.Issue
;
import
org.jvnet.hudson.test.Issue
;
public
class
ActionableTest
{
public
class
ActionableTest
{
private
Actionable
thing
=
new
ActionableImpl
();
private
final
Actionable
thing
=
new
ActionableImpl
();
@SuppressWarnings
(
"deprecation"
)
@SuppressWarnings
(
"deprecation"
)
@Test
@Test
...
@@ -67,6 +68,7 @@ public class ActionableTest {
...
@@ -67,6 +68,7 @@ public class ActionableTest {
}
}
@Override
@Override
@NonNull
public
List
<
Action
>
getActions
()
{
public
List
<
Action
>
getActions
()
{
return
specialActions
;
return
specialActions
;
}
}
...
@@ -75,7 +77,7 @@ public class ActionableTest {
...
@@ -75,7 +77,7 @@ public class ActionableTest {
@SuppressWarnings
(
"deprecation"
)
@SuppressWarnings
(
"deprecation"
)
@Issue
(
"JENKINS-39555"
)
@Issue
(
"JENKINS-39555"
)
@Test
@Test
public
void
testExtensionOverrides
()
throws
Exception
{
public
void
testExtensionOverrides
()
{
ActionableOverride
myOverridden
=
new
ActionableOverride
();
ActionableOverride
myOverridden
=
new
ActionableOverride
();
InvisibleAction
invis
=
new
InvisibleAction
()
{
InvisibleAction
invis
=
new
InvisibleAction
()
{
};
};
...
@@ -144,11 +146,11 @@ public class ActionableTest {
...
@@ -144,11 +146,11 @@ public class ActionableTest {
thing
.
addAction
(
a2
);
thing
.
addAction
(
a2
);
assertEquals
(
Arrays
.
asList
(
a1
,
a2
),
thing
.
getActions
());
assertEquals
(
Arrays
.
asList
(
a1
,
a2
),
thing
.
getActions
());
assertThat
(
thing
.
removeAction
(
a1
),
is
(
true
));
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
));
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
));
assertThat
(
thing
.
removeAction
(
null
),
is
(
false
));
assertEquals
(
Arrays
.
as
List
(
a2
),
thing
.
getActions
());
assertEquals
(
Collections
.
singleton
List
(
a2
),
thing
.
getActions
());
}
}
@SuppressWarnings
(
"deprecation"
)
@SuppressWarnings
(
"deprecation"
)
...
@@ -160,9 +162,9 @@ public class ActionableTest {
...
@@ -160,9 +162,9 @@ public class ActionableTest {
thing
.
addAction
(
a2
);
thing
.
addAction
(
a2
);
assertEquals
(
Arrays
.
asList
(
a1
,
a2
),
thing
.
getActions
());
assertEquals
(
Arrays
.
asList
(
a1
,
a2
),
thing
.
getActions
());
assertThat
(
thing
.
removeActions
(
CauseAction
.
class
),
is
(
true
));
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
));
assertThat
(
thing
.
removeActions
(
CauseAction
.
class
),
is
(
false
));
assertEquals
(
Arrays
.
as
List
(
a2
),
thing
.
getActions
());
assertEquals
(
Collections
.
singleton
List
(
a2
),
thing
.
getActions
());
}
}
@SuppressWarnings
(
"deprecation"
)
@SuppressWarnings
(
"deprecation"
)
...
...
core/src/test/java/hudson/model/EnvironmentContributingActionTest.java
浏览文件 @
ed80d244
package
hudson.model
;
package
hudson.model
;
import
edu.umd.cs.findbugs.annotations.NonNull
;
import
hudson.EnvVars
;
import
hudson.EnvVars
;
import
org.junit.Test
;
import
org.junit.Test
;
...
@@ -15,7 +16,7 @@ public class EnvironmentContributingActionTest {
...
@@ -15,7 +16,7 @@ public class EnvironmentContributingActionTest {
private
boolean
wasCalled
=
false
;
private
boolean
wasCalled
=
false
;
@Override
@Override
public
void
buildEnvironment
(
Run
<?,
?>
run
,
EnvVars
env
)
{
public
void
buildEnvironment
(
@NonNull
Run
<?,
?>
run
,
@NonNull
EnvVars
env
)
{
wasCalled
=
true
;
wasCalled
=
true
;
}
}
...
@@ -49,7 +50,7 @@ public class EnvironmentContributingActionTest {
...
@@ -49,7 +50,7 @@ public class EnvironmentContributingActionTest {
}
}
@Override
@Override
public
void
buildEnvironment
(
Run
<?,
?>
run
,
EnvVars
env
)
{
public
void
buildEnvironment
(
@NonNull
Run
<?,
?>
run
,
@NonNull
EnvVars
env
)
{
wasCalledRun
=
true
;
wasCalledRun
=
true
;
}
}
...
@@ -65,9 +66,8 @@ public class EnvironmentContributingActionTest {
...
@@ -65,9 +66,8 @@ public class EnvironmentContributingActionTest {
private
final
EnvVars
envVars
=
mock
(
EnvVars
.
class
);
private
final
EnvVars
envVars
=
mock
(
EnvVars
.
class
);
@Test
@Test
public
void
testOverrideRunMethodAndCallNewMethod
()
throws
Exception
{
public
void
testOverrideRunMethodAndCallNewMethod
()
{
Run
run
=
mock
(
Run
.
class
);
Run
<?,?>
run
=
mock
(
Run
.
class
);
Node
node
=
mock
(
Node
.
class
);
OverrideRun
overrideRun
=
new
OverrideRun
();
OverrideRun
overrideRun
=
new
OverrideRun
();
overrideRun
.
buildEnvironment
(
run
,
envVars
);
overrideRun
.
buildEnvironment
(
run
,
envVars
);
...
@@ -77,12 +77,11 @@ public class EnvironmentContributingActionTest {
...
@@ -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.
* If only non-deprecated method was overridden it would be executed even if someone would call deprecated method.
* @throws Exception if happens.
*/
*/
@Test
@Test
@SuppressWarnings
(
"deprecation"
)
@SuppressWarnings
(
"deprecation"
)
public
void
testOverrideRunMethodAndCallDeprecatedMethod
()
throws
Exception
{
public
void
testOverrideRunMethodAndCallDeprecatedMethod
()
{
AbstractBuild
abstractBuild
=
mock
(
AbstractBuild
.
class
);
AbstractBuild
<?,?>
abstractBuild
=
mock
(
AbstractBuild
.
class
);
when
(
abstractBuild
.
getBuiltOn
()).
thenReturn
(
mock
(
Node
.
class
));
when
(
abstractBuild
.
getBuiltOn
()).
thenReturn
(
mock
(
Node
.
class
));
OverrideRun
overrideRun
=
new
OverrideRun
();
OverrideRun
overrideRun
=
new
OverrideRun
();
...
@@ -93,11 +92,10 @@ public class EnvironmentContributingActionTest {
...
@@ -93,11 +92,10 @@ public class EnvironmentContributingActionTest {
/**
/**
* {@link AbstractBuild} should work as before.
* {@link AbstractBuild} should work as before.
* @throws Exception if happens.
*/
*/
@Test
@Test
public
void
testOverrideAbstractBuildAndCallNewMethodWithAbstractBuild
()
throws
Exception
{
public
void
testOverrideAbstractBuildAndCallNewMethodWithAbstractBuild
()
{
AbstractBuild
abstractBuild
=
mock
(
AbstractBuild
.
class
);
AbstractBuild
<?,?>
abstractBuild
=
mock
(
AbstractBuild
.
class
);
OverrideAbstractBuild
action
=
new
OverrideAbstractBuild
();
OverrideAbstractBuild
action
=
new
OverrideAbstractBuild
();
action
.
buildEnvironment
(
abstractBuild
,
envVars
);
action
.
buildEnvironment
(
abstractBuild
,
envVars
);
...
@@ -107,11 +105,10 @@ public class EnvironmentContributingActionTest {
...
@@ -107,11 +105,10 @@ public class EnvironmentContributingActionTest {
/**
/**
* {@link Run} should not execute method that was overridden for {@link AbstractBuild}.
* {@link Run} should not execute method that was overridden for {@link AbstractBuild}.
* @throws Exception if happens.
*/
*/
@Test
@Test
public
void
testOverrideAbstractBuildAndCallNewMethodWithRun
()
throws
Exception
{
public
void
testOverrideAbstractBuildAndCallNewMethodWithRun
()
{
Run
run
=
mock
(
Run
.
class
);
Run
<?,?>
run
=
mock
(
Run
.
class
);
OverrideAbstractBuild
action
=
new
OverrideAbstractBuild
();
OverrideAbstractBuild
action
=
new
OverrideAbstractBuild
();
action
.
buildEnvironment
(
run
,
envVars
);
action
.
buildEnvironment
(
run
,
envVars
);
...
@@ -121,11 +118,10 @@ public class EnvironmentContributingActionTest {
...
@@ -121,11 +118,10 @@ public class EnvironmentContributingActionTest {
/**
/**
* If someone wants to use overridden deprecated method, it would still work.
* If someone wants to use overridden deprecated method, it would still work.
* @throws Exception if happens.
*/
*/
@Test
@Test
public
void
testOverrideAbstractBuildAndCallDeprecatedMethod
()
throws
Exception
{
public
void
testOverrideAbstractBuildAndCallDeprecatedMethod
()
{
AbstractBuild
abstractBuild
=
mock
(
AbstractBuild
.
class
);
AbstractBuild
<?,?>
abstractBuild
=
mock
(
AbstractBuild
.
class
);
OverrideAbstractBuild
overrideRun
=
new
OverrideAbstractBuild
();
OverrideAbstractBuild
overrideRun
=
new
OverrideAbstractBuild
();
overrideRun
.
buildEnvVars
(
abstractBuild
,
envVars
);
overrideRun
.
buildEnvVars
(
abstractBuild
,
envVars
);
...
@@ -134,8 +130,8 @@ public class EnvironmentContributingActionTest {
...
@@ -134,8 +130,8 @@ public class EnvironmentContributingActionTest {
}
}
@Test
@Test
public
void
testOverrideBothAndCallNewMethod
()
throws
Exception
{
public
void
testOverrideBothAndCallNewMethod
()
{
Run
run
=
mock
(
Run
.
class
);
Run
<?,?>
run
=
mock
(
Run
.
class
);
OverrideBoth
overrideRun
=
new
OverrideBoth
();
OverrideBoth
overrideRun
=
new
OverrideBoth
();
overrideRun
.
buildEnvironment
(
run
,
envVars
);
overrideRun
.
buildEnvironment
(
run
,
envVars
);
...
@@ -144,8 +140,8 @@ public class EnvironmentContributingActionTest {
...
@@ -144,8 +140,8 @@ public class EnvironmentContributingActionTest {
}
}
@Test
@Test
public
void
testOverrideBothAndCallDeprecatedMethod
()
throws
Exception
{
public
void
testOverrideBothAndCallDeprecatedMethod
()
{
AbstractBuild
abstractBuild
=
mock
(
AbstractBuild
.
class
);
AbstractBuild
<?,?>
abstractBuild
=
mock
(
AbstractBuild
.
class
);
OverrideBoth
overrideRun
=
new
OverrideBoth
();
OverrideBoth
overrideRun
=
new
OverrideBoth
();
overrideRun
.
buildEnvVars
(
abstractBuild
,
envVars
);
overrideRun
.
buildEnvVars
(
abstractBuild
,
envVars
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录