Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
6b169fd5
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看板
提交
6b169fd5
编写于
7月 14, 2014
作者:
A
asaha
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
799a7405
0128a3c2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
42 addition
and
80 deletion
+42
-80
.hgtags
.hgtags
+1
-0
test/sun/tools/native2ascii/NativeErrors.java
test/sun/tools/native2ascii/NativeErrors.java
+41
-80
未找到文件。
.hgtags
浏览文件 @
6b169fd5
...
@@ -307,6 +307,7 @@ d723d05cd17afd5c4dd4293bcba83fef44a3c0bb jdk8u20-b16
...
@@ -307,6 +307,7 @@ d723d05cd17afd5c4dd4293bcba83fef44a3c0bb jdk8u20-b16
38548d32c91cfa57b1d31eec0a5e79c936e86f11 jdk8u20-b19
38548d32c91cfa57b1d31eec0a5e79c936e86f11 jdk8u20-b19
5c0406ee9e820140b5322db006baed199c165b4f jdk8u20-b20
5c0406ee9e820140b5322db006baed199c165b4f jdk8u20-b20
693025bbc45d683676fa78bb76201b665e0d8f2d jdk8u20-b21
693025bbc45d683676fa78bb76201b665e0d8f2d jdk8u20-b21
0c2393744b29175de5204140d4dfbf12ca3d364f jdk8u20-b22
abca9f6f1a10e9f91b2538bbe7870f54f550d986 jdk8u25-b00
abca9f6f1a10e9f91b2538bbe7870f54f550d986 jdk8u25-b00
7d0627679c9fdeaaaa9fe15c7cc11af0763621ec jdk8u25-b01
7d0627679c9fdeaaaa9fe15c7cc11af0763621ec jdk8u25-b01
b0277ec994b751ebb761814675352506cd56bcd6 jdk8u25-b02
b0277ec994b751ebb761814675352506cd56bcd6 jdk8u25-b02
...
...
test/sun/tools/native2ascii/NativeErrors.java
浏览文件 @
6b169fd5
/*
/*
* Copyright (c) 1998,
1999
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998,
2014
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -25,12 +25,18 @@
...
@@ -25,12 +25,18 @@
* @test
* @test
* @bug 4136352
* @bug 4136352
* @summary Test Native2ASCII error messages
* @summary Test Native2ASCII error messages
*
* @library /lib/testlibrary
* @build jdk.testlibrary.* NativeErrors
* @run main NativeErrors
*/
*/
import
java.io.*
;
import
sun.tools.native2ascii.*
;
import
java.io.File
;
import
java.util.*
;
import
java.util.ResourceBundle
;
import
java.util.MissingResourceException
;
import
jdk.testlibrary.OutputAnalyzer
;
import
jdk.testlibrary.JDKToolLauncher
;
import
jdk.testlibrary.ProcessTools
;
public
class
NativeErrors
{
public
class
NativeErrors
{
...
@@ -45,30 +51,18 @@ public class NativeErrors {
...
@@ -45,30 +51,18 @@ public class NativeErrors {
}
}
}
}
public
static
void
main
(
String
args
[])
throws
Exception
{
public
static
void
main
(
String
args
[])
throws
Throwable
{
String
[]
command
;
// Execute command in another vm. Verify stdout for expected err msg.
Process
p
=
null
;
BufferedReader
in
=
null
;
// Construct a command that runs the test in other vm
// Test with no input file given.
// Exec another vm to run test in
checkResult
(
executeCmd
(
"-encoding"
),
"err.bad.arg"
);
// Read the result to determine if test failed
command
=
getComString
(
"-encoding"
);
p
=
Runtime
.
getRuntime
().
exec
(
command
);
in
=
new
BufferedReader
(
new
InputStreamReader
(
p
.
getInputStream
()));
checkResult
(
in
,
"err.bad.arg"
);
File
f0
=
new
File
(
System
.
getProperty
(
"test.src"
,
"."
),
"test123"
);
File
f0
=
new
File
(
System
.
getProperty
(
"test.src"
,
"."
),
"test123"
);
String
path0
=
f0
.
getPath
();
String
path0
=
f0
.
getPath
();
if
(
f0
.
exists
()
)
{
if
(
f0
.
exists
()
)
{
throw
new
Error
(
"Input file should not exist: "
+
path0
);
throw
new
Error
(
"Input file should not exist: "
+
path0
);
}
}
checkResult
(
executeCmd
(
path0
),
"err.cannot.read"
);
command
=
getComString
(
path0
);
p
=
Runtime
.
getRuntime
().
exec
(
command
);
in
=
new
BufferedReader
(
new
InputStreamReader
(
p
.
getInputStream
()));
checkResult
(
in
,
"err.cannot.read"
);
File
f1
=
new
File
(
System
.
getProperty
(
"test.src"
,
"."
),
"test1"
);
File
f1
=
new
File
(
System
.
getProperty
(
"test.src"
,
"."
),
"test1"
);
File
f2
=
File
.
createTempFile
(
"test2"
,
".tmp"
);
File
f2
=
File
.
createTempFile
(
"test2"
,
".tmp"
);
...
@@ -81,71 +75,38 @@ public class NativeErrors {
...
@@ -81,71 +75,38 @@ public class NativeErrors {
throw
new
Error
(
"Output file cannot be made read only: "
+
path2
);
throw
new
Error
(
"Output file cannot be made read only: "
+
path2
);
}
}
f2
.
deleteOnExit
();
f2
.
deleteOnExit
();
checkResult
(
executeCmd
(
path1
,
path2
),
"err.cannot.write"
);
command
=
getComString
(
path1
,
path2
);
p
=
Runtime
.
getRuntime
().
exec
(
command
);
in
=
new
BufferedReader
(
new
InputStreamReader
(
p
.
getInputStream
()));
checkResult
(
in
,
"err.cannot.write"
);
}
}
private
static
String
executeCmd
(
String
...
toolArgs
)
throws
Throwable
{
private
static
void
checkResult
(
BufferedReader
in
,
String
errorExpected
)
JDKToolLauncher
cmd
=
JDKToolLauncher
.
createUsingTestJDK
(
"native2ascii"
);
throws
Exception
{
for
(
String
s
:
toolArgs
)
{
String
errorReceived
;
cmd
.
addToolArg
(
s
);
errorReceived
=
in
.
readLine
();
assert
errorReceived
!=
null
:
"First readline cannot be null"
;
errorExpected
=
rsrc
.
getString
(
errorExpected
);
assert
errorExpected
!=
null
:
"Expected message cannot be null"
;
StringBuffer
error
=
new
StringBuffer
(
errorExpected
);
int
start
=
errorExpected
.
indexOf
(
"{0}"
);
if
(
start
>=
0
)
{
error
.
delete
(
start
,
start
+
3
);
errorExpected
=
error
.
toString
();
}
}
//System.out.println("received: " + errorReceived);
OutputAnalyzer
output
=
ProcessTools
.
executeProcess
(
cmd
.
getCommand
());
//System.out.println("expected: " + errorExpected);
if
(
output
==
null
||
output
.
getStdout
()
==
null
)
{
if
(!
errorReceived
.
endsWith
(
errorExpected
))
throw
new
Exception
(
"Output was null. Process did not finish correctly."
);
throw
new
RuntimeException
(
"Native2ascii bad arg error broken."
);
}
}
if
(
output
.
getExitValue
()
==
0
)
{
throw
new
Exception
(
"Process exit code was 0, but error was expected."
);
private
static
String
[]
getComString
(
String
arg2
)
{
}
String
[]
coms
=
new
String
[
2
];
return
output
.
getStdout
();
coms
[
0
]
=
getPathString
();
coms
[
1
]
=
arg2
;
return
coms
;
}
private
static
String
[]
getComString
(
String
arg2
,
String
arg3
)
{
String
[]
coms
=
new
String
[
3
];
coms
[
0
]
=
getPathString
();
coms
[
1
]
=
arg2
;
coms
[
2
]
=
arg3
;
return
coms
;
}
}
/*
private
static
void
checkResult
(
* Search for path to native2ascii
String
errorReceived
,
String
errorKey
)
throws
Exception
{
*/
String
errorExpected
=
rsrc
.
getString
(
errorKey
);
private
static
String
getPathString
()
{
if
(
errorExpected
==
null
)
{
String
path
=
System
.
getProperty
(
"java.home"
)
+
File
.
separator
+
throw
new
Exception
(
"No error message for key: "
+
errorKey
);
"bin"
+
File
.
separator
+
"native2ascii"
;
if
(
File
.
separatorChar
==
'\\'
)
{
path
=
path
+
".exe"
;
}
}
File
f
=
new
File
(
path
);
// Remove template tag from error message.
if
(!
f
.
exists
())
{
errorExpected
=
errorExpected
.
replaceAll
(
"\\{0\\}"
,
""
);
System
.
out
.
println
(
"Cannot find native2ascii at "
+
path
);
path
=
System
.
getProperty
(
"java.home"
)
+
File
.
separator
+
".."
+
System
.
out
.
println
(
"received: "
+
errorReceived
);
File
.
separator
+
"bin"
+
File
.
separator
+
"native2ascii"
;
System
.
out
.
println
(
"expected: "
+
errorExpected
);
if
(
File
.
separatorChar
==
'\\'
)
{
if
(
errorReceived
.
indexOf
(
errorExpected
)
<
0
)
{
path
=
path
+
".exe"
;
throw
new
RuntimeException
(
"Native2ascii bad arg error broken."
);
}
f
=
new
File
(
path
);
if
(!
f
.
exists
())
throw
new
RuntimeException
(
"Cannot find native2ascii at "
+
path
);
System
.
out
.
println
(
"Using native2ascii at "
+
path
);
}
}
return
path
;
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录