Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
8cbc207f
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看板
提交
8cbc207f
编写于
11月 12, 2013
作者:
E
egahlin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8027209: javax/management/monitor/ThreadPoolAccTest.java fails intermittently
Reviewed-by: sla, jbachorik
上级
9cbf0f9c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
32 addition
and
59 deletion
+32
-59
test/javax/management/monitor/ThreadPoolAccTest.java
test/javax/management/monitor/ThreadPoolAccTest.java
+32
-59
未找到文件。
test/javax/management/monitor/ThreadPoolAccTest.java
浏览文件 @
8cbc207f
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005,
2013
Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -33,8 +33,8 @@
*/
import
java.security.AccessController
;
import
java.security.Principal
;
import
java.security.PrivilegedAction
;
import
java.util.Date
;
import
java.util.Set
;
import
javax.management.MBeanServer
;
import
javax.management.MBeanServerFactory
;
...
...
@@ -49,8 +49,8 @@ import javax.security.auth.Subject;
public
class
ThreadPoolAccTest
{
// MBean class
public
class
ObservedObject
implements
ObservedObjectMBean
{
public
String
principal
;
public
static
class
ObservedObject
implements
ObservedObjectMBean
{
public
volatile
String
principal
;
public
Integer
getInteger
()
{
setPrincipal
();
return
0
;
...
...
@@ -65,8 +65,8 @@ public class ThreadPoolAccTest {
}
private
void
setPrincipal
()
{
Subject
subject
=
Subject
.
getSubject
(
AccessController
.
getContext
());
Set
principals
=
subject
.
getPrincipals
(
JMXPrincipal
.
class
);
principal
=
((
Principal
)
principals
.
iterator
().
next
()
).
getName
();
Set
<
JMXPrincipal
>
principals
=
subject
.
getPrincipals
(
JMXPrincipal
.
class
);
principal
=
principals
.
iterator
().
next
(
).
getName
();
}
}
...
...
@@ -77,10 +77,7 @@ public class ThreadPoolAccTest {
public
String
getString
();
}
/**
* Run test
*/
public
int
runTest
()
throws
Exception
{
public
static
void
main
(
String
args
[])
throws
Exception
{
ObjectName
[]
mbeanNames
=
new
ObjectName
[
6
];
ObservedObject
[]
monitored
=
new
ObservedObject
[
6
];
...
...
@@ -93,8 +90,6 @@ public class ThreadPoolAccTest {
echo
(
">>> CREATE MBeanServer"
);
MBeanServer
server
=
MBeanServerFactory
.
newMBeanServer
();
String
domain
=
server
.
getDefaultDomain
();
for
(
int
i
=
0
;
i
<
6
;
i
++)
{
mbeanNames
[
i
]
=
new
ObjectName
(
":type=ObservedObject,instance="
+
i
);
...
...
@@ -132,8 +127,8 @@ public class ThreadPoolAccTest {
Subject
subject
=
new
Subject
();
echo
(
">>> RUN Principal = "
+
principals
[
i
/
3
]);
subject
.
getPrincipals
().
add
(
new
JMXPrincipal
(
principals
[
i
/
3
]));
PrivilegedAction
action
=
new
PrivilegedAction
()
{
public
Object
run
()
{
PrivilegedAction
<
Void
>
action
=
new
PrivilegedAction
<
Void
>
()
{
public
Void
run
()
{
m
.
start
();
return
null
;
}
...
...
@@ -141,61 +136,39 @@ public class ThreadPoolAccTest {
Subject
.
doAs
(
subject
,
action
);
}
// Wait for all tasks to be submitted
//
try
{
Thread
.
sleep
(
2000
);
}
catch
(
InterruptedException
e
)
{
echo
(
"I fell asleep but someone woke me up"
);
return
1
;
}
while
(!
testPrincipals
(
monitored
,
monitorNames
,
monitor
,
principals
));
// Check if task principal is correct
//
for
(
int
i
=
0
;
i
<
6
;
i
++)
{
echo
(
">>> Monitor = "
+
monitorNames
[
i
]);
echo
(
">>> ObservedObject = "
+
monitor
[
i
].
getObservedObject
());
echo
(
">>> ObservedAttribute = "
+
monitor
[
i
].
getObservedAttribute
());
echo
(
">>> Principal = "
+
monitored
[
i
].
principal
);
if
(
monitored
[
i
].
principal
.
equals
(
principals
[
i
/
3
]))
{
echo
(
"\tOK: Got Expected Principal"
);
}
else
{
echo
(
"\tKO: Got Unexpected Principal"
);
return
1
;
}
}
}
finally
{
for
(
int
i
=
0
;
i
<
6
;
i
++)
if
(
monitor
[
i
]
!=
null
)
monitor
[
i
].
stop
();
}
}
return
0
;
private
static
boolean
testPrincipals
(
ObservedObject
[]
monitored
,
ObjectName
[]
monitorNames
,
Monitor
[]
monitor
,
String
[]
principals
)
throws
Exception
{
for
(
int
i
=
0
;
i
<
6
;
i
++)
{
String
principal
=
monitored
[
i
].
principal
;
String
expected
=
principals
[
i
/
3
];
if
(
principal
==
null
)
{
echo
(
"Task not submitted "
+
new
Date
()
+
". RETRY"
);
return
false
;
}
echo
(
">>> Monitor = "
+
monitorNames
[
i
]);
echo
(
">>> ObservedObject = "
+
monitor
[
i
].
getObservedObject
());
echo
(
">>> ObservedAttribute = "
+
monitor
[
i
].
getObservedAttribute
());
echo
(
">>> Principal = "
+
principal
);
if
(
expected
.
equals
(
principal
))
{
echo
(
"\tOK: Got Expected principal"
);
}
else
{
throw
new
Exception
(
"Unexpected principal. Got: "
+
principal
+
" Expected: "
+
expected
);
}
}
return
true
;
}
/*
* Print message
*/
private
static
void
echo
(
String
message
)
{
System
.
out
.
println
(
message
);
}
/*
* Standalone entry point.
*
* Run the test and report to stdout.
*/
public
static
void
main
(
String
args
[])
throws
Exception
{
ThreadPoolAccTest
test
=
new
ThreadPoolAccTest
();
int
error
=
test
.
runTest
();
if
(
error
>
0
)
{
echo
(
">>> Unhappy Bye, Bye!"
);
throw
new
IllegalStateException
(
"Test FAILED: Monitor task ran on wrong security context!"
);
}
else
{
echo
(
">>> Happy Bye, Bye!"
);
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录