Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
roginluo
Jenkins
提交
dbe24a85
J
Jenkins
项目概览
roginluo
/
Jenkins
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
Jenkins
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
dbe24a85
编写于
4月 04, 2017
作者:
J
Jesse Glick
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Using CLICommandInvoker in cases where we did not actually need to be testing Remoting-based CLI.
上级
94d5f96d
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
23 addition
and
42 deletion
+23
-42
test/src/test/java/hudson/cli/CLIActionTest.java
test/src/test/java/hudson/cli/CLIActionTest.java
+1
-1
test/src/test/java/hudson/model/ComputerSetTest.java
test/src/test/java/hudson/model/ComputerSetTest.java
+8
-15
test/src/test/java/hudson/model/listeners/ItemListenerTest.java
...rc/test/java/hudson/model/listeners/ItemListenerTest.java
+9
-20
test/src/test/java/hudson/security/CliAuthenticationTest.java
.../src/test/java/hudson/security/CliAuthenticationTest.java
+2
-4
test/src/test/java/jenkins/security/Security218BlackBoxTest.java
...c/test/java/jenkins/security/Security218BlackBoxTest.java
+1
-1
test/src/test/java/jenkins/security/Security218CliTest.java
test/src/test/java/jenkins/security/Security218CliTest.java
+2
-1
未找到文件。
test/src/test/java/hudson/cli/CLIActionTest.java
浏览文件 @
dbe24a85
...
...
@@ -87,7 +87,7 @@ public class CLIActionTest {
}
@SuppressWarnings
({
"unchecked"
,
"rawtypes"
})
// intentionally passing an unreifiable argument here
@SuppressWarnings
({
"unchecked"
,
"rawtypes"
,
"deprecation"
})
// intentionally passing an unreifiable argument here; Remoting-based constructor intentional
@Test
public
void
security218_take2
()
throws
Exception
{
pool
=
Executors
.
newCachedThreadPool
();
...
...
test/src/test/java/hudson/model/ComputerSetTest.java
浏览文件 @
dbe24a85
...
...
@@ -23,18 +23,13 @@
*/
package
hudson.model
;
import
static
org
.
hamcrest
.
MatcherAssert
.
assertThat
;
import
static
org
.
hamcrest
.
Matchers
.
contains
;
import
static
org
.
hamcrest
.
Matchers
.
containsInAnyOrder
;
import
static
org
.
hamcrest
.
Matchers
.
empty
;
import
static
org
.
hamcrest
.
Matchers
.
is
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
hudson.cli.CLI
;
import
com.gargoylesoftware.htmlunit.html.HtmlForm
;
import
hudson.cli.CLICommandInvoker
;
import
hudson.slaves.DumbSlave
;
import
static
org
.
hamcrest
.
Matchers
.*;
import
static
org
.
junit
.
Assert
.*;
import
org.junit.Rule
;
import
org.junit.Test
;
import
com.gargoylesoftware.htmlunit.html.HtmlForm
;
import
org.jvnet.hudson.test.Issue
;
import
org.jvnet.hudson.test.JenkinsRule
;
import
org.jvnet.hudson.test.JenkinsRule.WebClient
;
...
...
@@ -69,14 +64,12 @@ public class ComputerSetTest {
public
void
nodeOfflineCli
()
throws
Exception
{
DumbSlave
s
=
j
.
createSlave
();
try
(
CLI
cli
=
new
CLI
(
j
.
getURL
()))
{
assertTrue
(
cli
.
execute
(
"wait-node-offline"
,
"xxx"
)!=
0
);
assertTrue
(
cli
.
execute
(
"wait-node-online"
,
s
.
getNodeName
())==
0
);
assertThat
(
new
CLICommandInvoker
(
j
,
"wait-node-offline"
).
invokeWithArgs
(
"xxx"
),
CLICommandInvoker
.
Matcher
.
failedWith
(
/* IllegalArgumentException from NodeOptionHandler */
3
));
assertThat
(
new
CLICommandInvoker
(
j
,
"wait-node-online"
).
invokeWithArgs
(
s
.
getNodeName
()),
CLICommandInvoker
.
Matcher
.
succeededSilently
());
s
.
toComputer
().
disconnect
(
).
get
();
s
.
toComputer
().
disconnect
(
null
).
get
();
assertTrue
(
cli
.
execute
(
"wait-node-offline"
,
s
.
getNodeName
())==
0
);
}
assertThat
(
new
CLICommandInvoker
(
j
,
"wait-node-offline"
).
invokeWithArgs
(
s
.
getNodeName
()),
CLICommandInvoker
.
Matcher
.
succeededSilently
());
}
@Test
...
...
test/src/test/java/hudson/model/listeners/ItemListenerTest.java
浏览文件 @
dbe24a85
...
...
@@ -23,21 +23,15 @@
*/
package
hudson.model.listeners
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
hudson.cli.CLI
;
import
hudson.cli.CLICommandInvoker
;
import
hudson.model.Item
;
import
java.io.ByteArrayInputStream
;
import
static
org
.
junit
.
Assert
.*;
import
org.junit.Before
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.jvnet.hudson.test.JenkinsRule
;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.PrintStream
;
import
java.util.Arrays
;
/**
* Tests for ItemListener events.
* @author Alan.Harder@sun.com
...
...
@@ -64,16 +58,11 @@ public class ItemListenerTest {
@Test
public
void
onCreatedViaCLI
()
throws
Exception
{
ByteArrayOutputStream
buf
=
new
ByteArrayOutputStream
();
PrintStream
out
=
new
PrintStream
(
buf
);
try
(
CLI
cli
=
new
CLI
(
j
.
getURL
()))
{
cli
.
execute
(
Arrays
.
asList
(
"create-job"
,
"testJob"
),
new
ByteArrayInputStream
((
"<project><actions/><builders/><publishers/>"
+
"<buildWrappers/></project>"
).
getBytes
()),
out
,
out
);
out
.
flush
();
assertNotNull
(
"job should be created: "
+
buf
,
j
.
jenkins
.
getItem
(
"testJob"
));
assertEquals
(
"onCreated event should be triggered: "
+
buf
,
"C"
,
events
.
toString
());
}
CLICommandInvoker
.
Result
result
=
new
CLICommandInvoker
(
j
,
"create-job"
).
withStdin
(
new
ByteArrayInputStream
((
"<project><actions/><builders/><publishers/><buildWrappers/></project>"
).
getBytes
())).
invokeWithArgs
(
"testJob"
);
assertThat
(
result
,
CLICommandInvoker
.
Matcher
.
succeeded
());
assertNotNull
(
"job should be created: "
+
result
,
j
.
jenkins
.
getItem
(
"testJob"
));
assertEquals
(
"onCreated event should be triggered: "
+
result
,
"C"
,
events
.
toString
());
}
}
test/src/test/java/hudson/security/CliAuthenticationTest.java
浏览文件 @
dbe24a85
...
...
@@ -7,9 +7,6 @@ import static org.junit.Assert.assertTrue;
import
hudson.cli.CLI
;
import
hudson.cli.CLICommand
;
import
hudson.cli.ClientAuthenticationCache
;
import
hudson.cli.LoginCommand
;
import
hudson.cli.LogoutCommand
;
import
jenkins.model.Jenkins
;
import
org.acegisecurity.Authentication
;
import
org.apache.commons.io.input.NullInputStream
;
...
...
@@ -25,6 +22,7 @@ import java.util.Arrays;
/**
* @author Kohsuke Kawaguchi
*/
@SuppressWarnings
(
"deprecation"
)
// Remoting-based CLI usages intentional
public
class
CliAuthenticationTest
{
@Rule
...
...
@@ -88,7 +86,7 @@ public class CliAuthenticationTest {
}
@Test
@For
({
LoginCommand
.
class
,
LogoutCommand
.
class
,
ClientAuthenticationCache
.
class
})
@For
({
hudson
.
cli
.
LoginCommand
.
class
,
hudson
.
cli
.
LogoutCommand
.
class
,
hudson
.
cli
.
ClientAuthenticationCache
.
class
})
public
void
login
()
throws
Exception
{
j
.
jenkins
.
setSecurityRealm
(
j
.
createDummySecurityRealm
());
...
...
test/src/test/java/jenkins/security/Security218BlackBoxTest.java
浏览文件 @
dbe24a85
...
...
@@ -85,7 +85,7 @@ public class Security218BlackBoxTest {
@Rule
public
JenkinsRule
r
=
new
JenkinsRule
();
@SuppressWarnings
(
"deprecation"
)
// really mean to use getPage(String)
@SuppressWarnings
(
"deprecation"
)
// really mean to use getPage(String)
, and Remoting-based CLI
@PresetData
(
PresetData
.
DataSet
.
ANONYMOUS_READONLY
)
// TODO userContent inaccessible without authentication otherwise
@Test
public
void
probe
()
throws
Exception
{
...
...
test/src/test/java/jenkins/security/Security218CliTest.java
浏览文件 @
dbe24a85
...
...
@@ -41,6 +41,7 @@ import org.jvnet.hudson.test.TestExtension;
import
org.jvnet.hudson.test.recipes.PresetData
;
import
org.kohsuke.args4j.Argument
;
@SuppressWarnings
(
"deprecation"
)
// Remoting-based CLI usages intentional
public
class
Security218CliTest
{
@Rule
...
...
@@ -197,8 +198,8 @@ public class Security218CliTest {
@Argument
(
metaVar
=
"command"
,
usage
=
"Command to be launched by the payload"
,
required
=
true
,
index
=
1
)
public
String
command
;
@Override
protected
int
run
()
throws
Exception
{
Payload
payloadItem
=
Payload
.
valueOf
(
this
.
payload
);
PayloadCaller
callable
=
new
PayloadCaller
(
payloadItem
,
command
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录