Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
6f1e97a8
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看板
提交
6f1e97a8
编写于
6月 04, 2013
作者:
A
alanb
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8014855: TEST_BUG: java/nio/file/Files/StreamTest.java fails when sym links not supported
Reviewed-by: alanb Contributed-by: henry.jen@oracle.com
上级
0d2830e5
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
55 addition
and
15 deletion
+55
-15
test/java/nio/file/Files/StreamTest.java
test/java/nio/file/Files/StreamTest.java
+55
-15
未找到文件。
test/java/nio/file/Files/StreamTest.java
浏览文件 @
6f1e97a8
...
...
@@ -476,15 +476,25 @@ public class StreamTest {
}
public
void
testSecurityException
()
throws
IOException
{
Path
triggerFile
=
testFolder
.
resolve
(
Paths
.
get
(
"dir"
,
"SecurityException"
)
);
Files
.
createFile
(
triggerFile
);
Path
sampleFile
=
testFolder
.
resolve
(
Paths
.
get
(
"dir"
,
"sample"
));
Files
.
createFile
(
sampleFile
);
Path
triggerDir
=
testFolder
.
resolve
(
Paths
.
get
(
"dir2"
,
"SecurityException"
)
);
Files
.
createDirectories
(
triggerDir
);
Path
empty
=
testFolder
.
resolve
(
"empty"
);
Path
triggerFile
=
Files
.
createFile
(
empty
.
resolve
(
"SecurityException"
)
);
Path
sampleFile
=
Files
.
createDirectories
(
empty
.
resolve
(
"sample"
));
Path
dir2
=
testFolder
.
resolve
(
"dir2"
);
Path
triggerDir
=
Files
.
createDirectories
(
dir2
.
resolve
(
"SecurityException"
)
);
Files
.
createFile
(
triggerDir
.
resolve
(
"fileInSE"
));
Path
sample
=
testFolder
.
resolve
(
Paths
.
get
(
"dir2"
,
"file"
));
Files
.
createFile
(
sample
);
Path
sample
=
Files
.
createFile
(
dir2
.
resolve
(
"file"
));
Path
triggerLink
=
null
;
Path
linkTriggerDir
=
null
;
Path
linkTriggerFile
=
null
;
if
(
supportsLinks
)
{
Path
dir
=
testFolder
.
resolve
(
"dir"
);
triggerLink
=
Files
.
createSymbolicLink
(
dir
.
resolve
(
"SecurityException"
),
empty
);
linkTriggerDir
=
Files
.
createSymbolicLink
(
dir
.
resolve
(
"lnDirSE"
),
triggerDir
);
linkTriggerFile
=
Files
.
createSymbolicLink
(
dir
.
resolve
(
"lnFileSE"
),
triggerFile
);
}
FaultyFileSystem
.
FaultyFSProvider
fsp
=
FaultyFileSystem
.
FaultyFSProvider
.
getInstance
();
FaultyFileSystem
fs
=
(
FaultyFileSystem
)
fsp
.
newFileSystem
(
testFolder
,
null
);
...
...
@@ -492,10 +502,10 @@ public class StreamTest {
fsp
.
setFaultyMode
(
false
);
Path
fakeRoot
=
fs
.
getRoot
();
// validate setting
try
(
CloseableStream
<
Path
>
s
=
Files
.
list
(
fakeRoot
.
resolve
(
"
dir
"
)))
{
try
(
CloseableStream
<
Path
>
s
=
Files
.
list
(
fakeRoot
.
resolve
(
"
empty
"
)))
{
String
[]
result
=
s
.
map
(
path
->
path
.
getFileName
().
toString
())
.
toArray
(
String
[]::
new
);
assertEqualsNoOrder
(
result
,
new
String
[]
{
"
d1"
,
"f1"
,
"lnDir2"
,
"
SecurityException"
,
"sample"
});
assertEqualsNoOrder
(
result
,
new
String
[]
{
"SecurityException"
,
"sample"
});
}
try
(
CloseableStream
<
Path
>
s
=
Files
.
walk
(
fakeRoot
.
resolve
(
"dir2"
)))
{
...
...
@@ -504,13 +514,21 @@ public class StreamTest {
assertEqualsNoOrder
(
result
,
new
String
[]
{
"dir2"
,
"SecurityException"
,
"fileInSE"
,
"file"
});
}
if
(
supportsLinks
)
{
try
(
CloseableStream
<
Path
>
s
=
Files
.
list
(
fakeRoot
.
resolve
(
"dir"
)))
{
String
[]
result
=
s
.
map
(
path
->
path
.
getFileName
().
toString
())
.
toArray
(
String
[]::
new
);
assertEqualsNoOrder
(
result
,
new
String
[]
{
"d1"
,
"f1"
,
"lnDir2"
,
"SecurityException"
,
"lnDirSE"
,
"lnFileSE"
});
}
}
// execute test
fsp
.
setFaultyMode
(
true
);
// ignore file cause SecurityException
try
(
CloseableStream
<
Path
>
s
=
Files
.
walk
(
fakeRoot
.
resolve
(
"
dir
"
)))
{
try
(
CloseableStream
<
Path
>
s
=
Files
.
walk
(
fakeRoot
.
resolve
(
"
empty
"
)))
{
String
[]
result
=
s
.
map
(
path
->
path
.
getFileName
().
toString
())
.
toArray
(
String
[]::
new
);
assertEqualsNoOrder
(
result
,
new
String
[]
{
"
dir"
,
"d1"
,
"f1"
,
"lnDir2
"
,
"sample"
});
assertEqualsNoOrder
(
result
,
new
String
[]
{
"
empty
"
,
"sample"
});
}
// skip folder cause SecurityException
try
(
CloseableStream
<
Path
>
s
=
Files
.
walk
(
fakeRoot
.
resolve
(
"dir2"
)))
{
...
...
@@ -519,11 +537,29 @@ public class StreamTest {
assertEqualsNoOrder
(
result
,
new
String
[]
{
"dir2"
,
"file"
});
}
if
(
supportsLinks
)
{
// not following links
try
(
CloseableStream
<
Path
>
s
=
Files
.
walk
(
fakeRoot
.
resolve
(
"dir"
)))
{
String
[]
result
=
s
.
map
(
path
->
path
.
getFileName
().
toString
())
.
toArray
(
String
[]::
new
);
assertEqualsNoOrder
(
result
,
new
String
[]
{
"dir"
,
"d1"
,
"f1"
,
"lnDir2"
,
"lnDirSE"
,
"lnFileSE"
});
}
// following links
try
(
CloseableStream
<
Path
>
s
=
Files
.
walk
(
fakeRoot
.
resolve
(
"dir"
),
FileVisitOption
.
FOLLOW_LINKS
))
{
String
[]
result
=
s
.
map
(
path
->
path
.
getFileName
().
toString
())
.
toArray
(
String
[]::
new
);
// ?? Should fileInSE show up?
// With FaultyFS, it does as no exception thrown for link to "SecurityException" with read on "lnXxxSE"
assertEqualsNoOrder
(
result
,
new
String
[]
{
"dir"
,
"d1"
,
"f1"
,
"lnDir2"
,
"file"
,
"lnDirSE"
,
"lnFileSE"
,
"fileInSE"
});
}
}
// list instead of walk
try
(
CloseableStream
<
Path
>
s
=
Files
.
list
(
fakeRoot
.
resolve
(
"
dir
"
)))
{
try
(
CloseableStream
<
Path
>
s
=
Files
.
list
(
fakeRoot
.
resolve
(
"
empty
"
)))
{
String
[]
result
=
s
.
map
(
path
->
path
.
getFileName
().
toString
())
.
toArray
(
String
[]::
new
);
assertEqualsNoOrder
(
result
,
new
String
[]
{
"
d1"
,
"f1"
,
"lnDir2"
,
"
sample"
});
assertEqualsNoOrder
(
result
,
new
String
[]
{
"sample"
});
}
try
(
CloseableStream
<
Path
>
s
=
Files
.
list
(
fakeRoot
.
resolve
(
"dir2"
)))
{
String
[]
result
=
s
.
map
(
path
->
path
.
getFileName
().
toString
())
...
...
@@ -578,6 +614,11 @@ public class StreamTest {
if
(
fs
!=
null
)
{
fs
.
close
();
}
if
(
supportsLinks
)
{
Files
.
delete
(
triggerLink
);
Files
.
delete
(
linkTriggerDir
);
Files
.
delete
(
linkTriggerFile
);
}
Files
.
delete
(
triggerFile
);
Files
.
delete
(
sampleFile
);
Files
.
delete
(
sample
);
...
...
@@ -589,7 +630,6 @@ public class StreamTest {
try
(
CloseableStream
<
String
>
s
=
Files
.
lines
(
testFolder
.
resolve
(
"notExist"
),
Charset
.
forName
(
"UTF-8"
)))
{
s
.
forEach
(
l
->
fail
(
"File is not even exist!"
));
}
catch
(
IOException
ioe
)
{
ioe
.
printStackTrace
(
System
.
err
);
assertTrue
(
ioe
instanceof
NoSuchFileException
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录