Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
6f8ea830
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看板
提交
6f8ea830
编写于
9月 19, 2013
作者:
S
sherman
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8023113: tools/jar/ChangeDir.java fails if /tmp/a exists
Summary: updated the test case Reviewed-by: alanb
上级
ef182632
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
33 addition
and
32 deletion
+33
-32
test/tools/jar/ChangeDir.java
test/tools/jar/ChangeDir.java
+33
-32
未找到文件。
test/tools/jar/ChangeDir.java
浏览文件 @
6f8ea830
...
...
@@ -23,13 +23,15 @@
/**
* @test
* @bug 4806786
* @bug 4806786
8023113
* @summary jar -C doesn't ignore multiple // in path
*/
import
java.io.*
;
import
java.nio.file.*
;
import
java.util.*
;
import
java.util.jar.*
;
import
java.util.stream.Stream
;
import
sun.tools.jar.Main
;
public
class
ChangeDir
{
...
...
@@ -37,13 +39,16 @@ public class ChangeDir {
private
final
static
String
fileName
=
"hello.txt"
;
/** Remove dirs & files needed for test. */
private
static
void
cleanup
(
File
dir
)
throws
Throwable
{
if
(
dir
!=
null
&&
dir
.
exists
())
{
for
(
File
ff
:
dir
.
listFiles
())
{
check
(
ff
.
delete
());
private
static
void
cleanup
(
Path
dir
)
{
try
{
if
(
Files
.
isDirectory
(
dir
))
{
try
(
Stream
<
Path
>
s
=
Files
.
list
(
dir
))
{
s
.
forEach
(
p
->
cleanup
(
p
));
}
}
check
(
dir
.
delete
());
check
(
new
File
(
jarName
).
delete
());
Files
.
delete
(
dir
);
}
catch
(
IOException
x
)
{
fail
(
x
.
toString
());
}
}
...
...
@@ -62,19 +67,16 @@ public class ChangeDir {
}
static
void
doTest
(
String
sep
)
throws
Throwable
{
File
testDir
=
null
;
JarFile
jf
=
null
;
Path
topDir
=
Files
.
createTempDirectory
(
"delete"
);
try
{
Files
.
deleteIfExists
(
Paths
.
get
(
jarName
));
// Create a subdirectory "a/b"
File
f
=
File
.
createTempFile
(
"delete"
,
".me"
);
String
dirName
=
f
.
getParent
();
testDir
=
new
File
(
dirName
+
sep
+
"a"
+
sep
+
"b"
);
cleanup
(
testDir
);
check
(
testDir
.
mkdirs
());
Path
testDir
=
Files
.
createDirectories
(
topDir
.
resolve
(
"a"
).
resolve
(
"b"
));
// Create file in that subdirectory
File
testFile
=
new
File
(
testDir
,
fileName
);
check
(
testFile
.
createNewFile
()
);
Path
testFile
=
testDir
.
resolve
(
fileName
);
Files
.
createFile
(
testFile
);
// Create a jar file from that subdirectory, but with a // in the
// path name.
...
...
@@ -82,33 +84,32 @@ public class ChangeDir {
argList
.
add
(
"cf"
);
argList
.
add
(
jarName
);
argList
.
add
(
"-C"
);
argList
.
add
(
dirName
+
sep
+
"a"
+
sep
+
sep
+
"b"
);
// Note double 'sep' is intentional
argList
.
add
(
topDir
.
toString
()
+
sep
+
"a"
+
sep
+
sep
+
"b"
);
// Note double 'sep' is intentional
argList
.
add
(
fileName
);
String
jarArgs
[]
=
new
String
[
argList
.
size
()];
jarArgs
=
argList
.
toArray
(
jarArgs
);
Main
jarTool
=
new
Main
(
System
.
out
,
System
.
err
,
"jar"
);
if
(!
jarTool
.
run
(
jarArgs
))
{
if
(!
jarTool
.
run
(
argList
.
toArray
(
new
String
[
argList
.
size
()])
))
{
fail
(
"Could not create jar file."
);
}
// Check that the entry for hello.txt does *not* have a pathname.
jf
=
new
JarFile
(
jarName
);
for
(
Enumeration
<
JarEntry
>
i
=
jf
.
entries
();
i
.
hasMoreElements
();)
{
JarEntry
je
=
i
.
nextElement
();
String
name
=
je
.
getName
();
if
(
name
.
indexOf
(
fileName
)
!=
-
1
)
{
if
(
name
.
indexOf
(
fileName
)
!=
0
)
{
fail
(
String
.
format
(
"Expected '%s' but got '%s'%n"
,
fileName
,
name
));
try
(
JarFile
jf
=
new
JarFile
(
jarName
))
{
for
(
Enumeration
<
JarEntry
>
i
=
jf
.
entries
();
i
.
hasMoreElements
();)
{
JarEntry
je
=
i
.
nextElement
();
String
name
=
je
.
getName
();
if
(
name
.
indexOf
(
fileName
)
!=
-
1
)
{
if
(
name
.
indexOf
(
fileName
)
!=
0
)
{
fail
(
String
.
format
(
"Expected '%s' but got '%s'%n"
,
fileName
,
name
));
}
else
{
pass
();
}
}
}
}
}
finally
{
if
(
jf
!=
null
)
{
jf
.
close
();
}
cleanup
(
testDir
);
cleanup
(
topDir
);
Files
.
deleteIfExists
(
Paths
.
get
(
jarName
));
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录