Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
6a4b66a9
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
6a4b66a9
编写于
9月 14, 2016
作者:
I
igerasim
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8142926: OutputAnalyzer's shouldXXX() calls return this
Reviewed-by: alanb, robm
上级
1ea25df6
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
28 addition
and
15 deletion
+28
-15
test/lib/testlibrary/jdk/testlibrary/OutputAnalyzer.java
test/lib/testlibrary/jdk/testlibrary/OutputAnalyzer.java
+28
-15
未找到文件。
test/lib/testlibrary/jdk/testlibrary/OutputAnalyzer.java
浏览文件 @
6a4b66a9
...
...
@@ -90,13 +90,14 @@ public final class OutputAnalyzer {
* @throws RuntimeException
* If the string was not found
*/
public
void
shouldContain
(
String
expectedString
)
{
public
OutputAnalyzer
shouldContain
(
String
expectedString
)
{
if
(!
stdout
.
contains
(
expectedString
)
&&
!
stderr
.
contains
(
expectedString
))
{
reportDiagnosticSummary
();
throw
new
RuntimeException
(
"'"
+
expectedString
+
"' missing from stdout/stderr \n"
);
}
return
this
;
}
/**
...
...
@@ -107,12 +108,13 @@ public final class OutputAnalyzer {
* @throws RuntimeException
* If the string was not found
*/
public
void
stdoutShouldContain
(
String
expectedString
)
{
public
OutputAnalyzer
stdoutShouldContain
(
String
expectedString
)
{
if
(!
stdout
.
contains
(
expectedString
))
{
reportDiagnosticSummary
();
throw
new
RuntimeException
(
"'"
+
expectedString
+
"' missing from stdout \n"
);
}
return
this
;
}
/**
...
...
@@ -123,24 +125,25 @@ public final class OutputAnalyzer {
* @throws RuntimeException
* If the string was not found
*/
public
void
stderrShouldContain
(
String
expectedString
)
{
public
OutputAnalyzer
stderrShouldContain
(
String
expectedString
)
{
if
(!
stderr
.
contains
(
expectedString
))
{
reportDiagnosticSummary
();
throw
new
RuntimeException
(
"'"
+
expectedString
+
"' missing from stderr \n"
);
}
return
this
;
}
/**
* Verify that the stdout and stderr contents of output buffer does not
* contain the string
*
* @param
e
xpectedString
* @param
notE
xpectedString
* String that the buffer should not contain
* @throws RuntimeException
* If the string was found
*/
public
void
shouldNotContain
(
String
notExpectedString
)
{
public
OutputAnalyzer
shouldNotContain
(
String
notExpectedString
)
{
if
(
stdout
.
contains
(
notExpectedString
))
{
reportDiagnosticSummary
();
throw
new
RuntimeException
(
"'"
+
notExpectedString
...
...
@@ -151,23 +154,25 @@ public final class OutputAnalyzer {
throw
new
RuntimeException
(
"'"
+
notExpectedString
+
"' found in stderr \n"
);
}
return
this
;
}
/**
* Verify that the stdout contents of output buffer does not contain the
* string
*
* @param
e
xpectedString
* @param
notE
xpectedString
* String that the buffer should not contain
* @throws RuntimeException
* If the string was found
*/
public
void
stdoutShouldNotContain
(
String
notExpectedString
)
{
public
OutputAnalyzer
stdoutShouldNotContain
(
String
notExpectedString
)
{
if
(
stdout
.
contains
(
notExpectedString
))
{
reportDiagnosticSummary
();
throw
new
RuntimeException
(
"'"
+
notExpectedString
+
"' found in stdout \n"
);
}
return
this
;
}
/**
...
...
@@ -195,7 +200,7 @@ public final class OutputAnalyzer {
* @throws RuntimeException
* If the pattern was not found
*/
public
void
shouldMatch
(
String
pattern
)
{
public
OutputAnalyzer
shouldMatch
(
String
pattern
)
{
Matcher
stdoutMatcher
=
Pattern
.
compile
(
pattern
,
Pattern
.
MULTILINE
)
.
matcher
(
stdout
);
Matcher
stderrMatcher
=
Pattern
.
compile
(
pattern
,
Pattern
.
MULTILINE
)
...
...
@@ -205,6 +210,7 @@ public final class OutputAnalyzer {
throw
new
RuntimeException
(
"'"
+
pattern
+
"' missing from stdout/stderr \n"
);
}
return
this
;
}
/**
...
...
@@ -214,7 +220,7 @@ public final class OutputAnalyzer {
* @throws RuntimeException
* If the pattern was not found
*/
public
void
stdoutShouldMatch
(
String
pattern
)
{
public
OutputAnalyzer
stdoutShouldMatch
(
String
pattern
)
{
Matcher
matcher
=
Pattern
.
compile
(
pattern
,
Pattern
.
MULTILINE
).
matcher
(
stdout
);
if
(!
matcher
.
find
())
{
...
...
@@ -222,6 +228,7 @@ public final class OutputAnalyzer {
throw
new
RuntimeException
(
"'"
+
pattern
+
"' missing from stdout \n"
);
}
return
this
;
}
/**
...
...
@@ -231,7 +238,7 @@ public final class OutputAnalyzer {
* @throws RuntimeException
* If the pattern was not found
*/
public
void
stderrShouldMatch
(
String
pattern
)
{
public
OutputAnalyzer
stderrShouldMatch
(
String
pattern
)
{
Matcher
matcher
=
Pattern
.
compile
(
pattern
,
Pattern
.
MULTILINE
).
matcher
(
stderr
);
if
(!
matcher
.
find
())
{
...
...
@@ -239,6 +246,7 @@ public final class OutputAnalyzer {
throw
new
RuntimeException
(
"'"
+
pattern
+
"' missing from stderr \n"
);
}
return
this
;
}
/**
...
...
@@ -249,7 +257,7 @@ public final class OutputAnalyzer {
* @throws RuntimeException
* If the pattern was found
*/
public
void
shouldNotMatch
(
String
pattern
)
{
public
OutputAnalyzer
shouldNotMatch
(
String
pattern
)
{
Matcher
matcher
=
Pattern
.
compile
(
pattern
,
Pattern
.
MULTILINE
).
matcher
(
stdout
);
if
(
matcher
.
find
())
{
...
...
@@ -263,6 +271,7 @@ public final class OutputAnalyzer {
throw
new
RuntimeException
(
"'"
+
pattern
+
"' found in stderr: '"
+
matcher
.
group
()
+
"' \n"
);
}
return
this
;
}
/**
...
...
@@ -273,13 +282,14 @@ public final class OutputAnalyzer {
* @throws RuntimeException
* If the pattern was found
*/
public
void
stdoutShouldNotMatch
(
String
pattern
)
{
public
OutputAnalyzer
stdoutShouldNotMatch
(
String
pattern
)
{
Matcher
matcher
=
Pattern
.
compile
(
pattern
,
Pattern
.
MULTILINE
).
matcher
(
stdout
);
if
(
matcher
.
find
())
{
reportDiagnosticSummary
();
throw
new
RuntimeException
(
"'"
+
pattern
+
"' found in stdout \n"
);
}
return
this
;
}
/**
...
...
@@ -290,13 +300,14 @@ public final class OutputAnalyzer {
* @throws RuntimeException
* If the pattern was found
*/
public
void
stderrShouldNotMatch
(
String
pattern
)
{
public
OutputAnalyzer
stderrShouldNotMatch
(
String
pattern
)
{
Matcher
matcher
=
Pattern
.
compile
(
pattern
,
Pattern
.
MULTILINE
).
matcher
(
stderr
);
if
(
matcher
.
find
())
{
reportDiagnosticSummary
();
throw
new
RuntimeException
(
"'"
+
pattern
+
"' found in stderr \n"
);
}
return
this
;
}
/**
...
...
@@ -344,12 +355,13 @@ public final class OutputAnalyzer {
* If the exit value from the process did not match the expected
* value
*/
public
void
shouldHaveExitValue
(
int
expectedExitValue
)
{
public
OutputAnalyzer
shouldHaveExitValue
(
int
expectedExitValue
)
{
if
(
getExitValue
()
!=
expectedExitValue
)
{
reportDiagnosticSummary
();
throw
new
RuntimeException
(
"Expected to get exit value of ["
+
expectedExitValue
+
"]\n"
);
}
return
this
;
}
/**
...
...
@@ -357,11 +369,12 @@ public final class OutputAnalyzer {
* - standard input produced by the process under test - standard output -
* exit code Note: the command line is printed by the ProcessTools
*/
private
void
reportDiagnosticSummary
()
{
private
OutputAnalyzer
reportDiagnosticSummary
()
{
String
msg
=
" stdout: ["
+
stdout
+
"];\n"
+
" stderr: ["
+
stderr
+
"]\n"
+
" exitValue = "
+
getExitValue
()
+
"\n"
;
System
.
err
.
println
(
msg
);
return
this
;
}
/**
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录