Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
e1a8df2f
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看板
提交
e1a8df2f
编写于
9月 03, 2008
作者:
E
emcmanus
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6744132: Spurious failures from test/javax/management/MBeanInfo/NotificationInfoTest.java
Reviewed-by: dfuchs
上级
bcaacfd4
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
42 addition
and
60 deletion
+42
-60
test/javax/management/MBeanInfo/NotificationInfoTest.java
test/javax/management/MBeanInfo/NotificationInfoTest.java
+42
-60
未找到文件。
test/javax/management/MBeanInfo/NotificationInfoTest.java
浏览文件 @
e1a8df2f
...
...
@@ -33,14 +33,16 @@
*/
import
java.io.*
;
import
java.lang.management.*
;
import
java.lang.reflect.*
;
import
java.net.*
;
import
java.security.CodeSource
;
import
java.util.*
;
import
java.util.jar.*
;
import
javax.management.*
;
import
javax.management.modelmbean.*
;
import
javax.management.relation.*
;
import
javax.management.remote.*
;
import
javax.management.remote.rmi.*
;
/*
* This test finds all classes in the same code-base as the JMX
...
...
@@ -68,10 +70,10 @@ import javax.management.relation.*;
*/
public
class
NotificationInfoTest
{
// class or object names where the test failed
private
static
final
Set
/*<String>*/
failed
=
new
TreeSet
();
private
static
final
Set
<
String
>
failed
=
new
TreeSet
<
String
>
();
// class or object names where there were no MBeanNotificationInfo entries
private
static
final
Set
/*<String>*/
suspicious
=
new
TreeSet
();
private
static
final
Set
<
String
>
suspicious
=
new
TreeSet
<
String
>
();
public
static
void
main
(
String
[]
args
)
throws
Exception
{
System
.
out
.
println
(
"Checking that all known MBeans that are "
+
...
...
@@ -86,8 +88,20 @@ public class NotificationInfoTest {
.
getCodeSource
();
URL
codeBase
;
if
(
cs
==
null
)
{
codeBase
=
new
URL
(
"file:"
+
System
.
getProperty
(
"java.home"
)
+
"/lib/rt.jar"
);
String
javaHome
=
System
.
getProperty
(
"java.home"
);
String
[]
candidates
=
{
"/lib/rt.jar"
,
"/classes/"
};
codeBase
=
null
;
for
(
String
candidate
:
candidates
)
{
File
file
=
new
File
(
javaHome
+
candidate
);
if
(
file
.
exists
())
{
codeBase
=
file
.
toURI
().
toURL
();
break
;
}
}
if
(
codeBase
==
null
)
{
throw
new
Exception
(
"Could not determine codeBase for java.home="
+
javaHome
);
}
}
else
codeBase
=
cs
.
getLocation
();
...
...
@@ -98,7 +112,7 @@ public class NotificationInfoTest {
System
.
out
.
println
(
"Testing standard MBeans..."
);
for
(
int
i
=
0
;
i
<
classes
.
length
;
i
++)
{
String
name
=
classes
[
i
];
Class
c
;
Class
<?>
c
;
try
{
c
=
Class
.
forName
(
name
);
}
catch
(
Throwable
e
)
{
...
...
@@ -109,18 +123,22 @@ public class NotificationInfoTest {
System
.
out
.
println
(
name
+
": not a NotificationBroadcaster"
);
continue
;
}
if
(
Modifier
.
isAbstract
(
c
.
getModifiers
()))
{
System
.
out
.
println
(
name
+
": abstract class"
);
continue
;
}
NotificationBroadcaster
mbean
;
Constructor
constr
;
Constructor
<?>
constr
;
try
{
constr
=
c
.
getConstructor
(
null
);
constr
=
c
.
getConstructor
();
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
name
+
": no public no-arg constructor: "
+
e
);
continue
;
}
try
{
mbean
=
(
NotificationBroadcaster
)
constr
.
newInstance
(
null
);
mbean
=
(
NotificationBroadcaster
)
constr
.
newInstance
();
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
name
+
": no-arg constructor failed: "
+
e
);
continue
;
...
...
@@ -161,22 +179,9 @@ public class NotificationInfoTest {
}
private
static
void
checkPlatformMBeans
()
throws
Exception
{
Class
managementFactory
;
try
{
managementFactory
=
Class
.
forName
(
"java.lang.management.ManagementFactory"
);
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"...no ManagementFactory, assuming pre-Tiger: "
+
e
);
return
;
}
Method
getPlatformMBeanServer
=
managementFactory
.
getMethod
(
"getPlatformMBeanServer"
,
null
);
MBeanServer
mbs
=
(
MBeanServer
)
getPlatformMBeanServer
.
invoke
(
null
,
null
);
Set
mbeanNames
=
mbs
.
queryNames
(
null
,
null
);
for
(
Iterator
it
=
mbeanNames
.
iterator
();
it
.
hasNext
();
)
{
ObjectName
name
=
(
ObjectName
)
it
.
next
();
MBeanServer
mbs
=
ManagementFactory
.
getPlatformMBeanServer
();
Set
<
ObjectName
>
mbeanNames
=
mbs
.
queryNames
(
null
,
null
);
for
(
ObjectName
name
:
mbeanNames
)
{
if
(!
mbs
.
isInstanceOf
(
name
,
NotificationBroadcaster
.
class
.
getName
()))
{
System
.
out
.
println
(
name
+
": not a NotificationBroadcaster"
);
...
...
@@ -188,31 +193,9 @@ public class NotificationInfoTest {
}
private
static
void
checkRMIConnectorServer
()
throws
Exception
{
Class
rmiConnectorServer
;
try
{
rmiConnectorServer
=
Class
.
forName
(
"javax.management.remote.rmi.RMIConnectorServer"
);
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"No RMIConnectorServer class, skipping: "
+
e
);
return
;
}
Class
jmxServiceURL
=
Class
.
forName
(
"javax.management.remote.JMXServiceURL"
);
Constructor
jmxServiceURLConstructor
=
jmxServiceURL
.
getConstructor
(
new
Class
[]
{
String
.
class
});
Object
url
=
jmxServiceURLConstructor
.
newInstance
(
new
Object
[]
{
"service:jmx:rmi://"
});
Constructor
rmiConnectorServerConstructor
=
rmiConnectorServer
.
getConstructor
(
new
Class
[]
{
jmxServiceURL
,
Map
.
class
});
Object
connector
=
rmiConnectorServerConstructor
.
newInstance
(
new
Object
[]
{
url
,
null
});
check
((
NotificationBroadcaster
)
connector
);
JMXServiceURL
url
=
new
JMXServiceURL
(
"service:jmx:rmi://"
);
RMIConnectorServer
connector
=
new
RMIConnectorServer
(
url
,
null
);
check
(
connector
);
}
private
static
void
check
(
String
what
,
MBeanNotificationInfo
[]
mbnis
)
{
...
...
@@ -250,30 +233,29 @@ public class NotificationInfoTest {
private
static
String
[]
findStandardMBeans
(
URL
codeBase
)
throws
Exception
{
Set
names
;
Set
<
String
>
names
;
if
(
codeBase
.
getProtocol
().
equalsIgnoreCase
(
"file"
)
&&
codeBase
.
toString
().
endsWith
(
"/"
))
names
=
findStandardMBeansFromDir
(
codeBase
);
else
names
=
findStandardMBeansFromJar
(
codeBase
);
Set
standardMBeanNames
=
new
TreeSet
();
for
(
Iterator
it
=
names
.
iterator
();
it
.
hasNext
();
)
{
String
name
=
(
String
)
it
.
next
();
Set
<
String
>
standardMBeanNames
=
new
TreeSet
<
String
>();
for
(
String
name
:
names
)
{
if
(
name
.
endsWith
(
"MBean"
))
{
String
prefix
=
name
.
substring
(
0
,
name
.
length
()
-
5
);
if
(
names
.
contains
(
prefix
))
standardMBeanNames
.
add
(
prefix
);
}
}
return
(
String
[])
standardMBeanNames
.
toArray
(
new
String
[
0
]);
return
standardMBeanNames
.
toArray
(
new
String
[
0
]);
}
private
static
Set
findStandardMBeansFromJar
(
URL
codeBase
)
private
static
Set
<
String
>
findStandardMBeansFromJar
(
URL
codeBase
)
throws
Exception
{
InputStream
is
=
codeBase
.
openStream
();
JarInputStream
jis
=
new
JarInputStream
(
is
);
Set
names
=
new
TreeSet
();
Set
<
String
>
names
=
new
TreeSet
<
String
>
();
JarEntry
entry
;
while
((
entry
=
jis
.
getNextJarEntry
())
!=
null
)
{
String
name
=
entry
.
getName
();
...
...
@@ -286,15 +268,15 @@ public class NotificationInfoTest {
return
names
;
}
private
static
Set
findStandardMBeansFromDir
(
URL
codeBase
)
private
static
Set
<
String
>
findStandardMBeansFromDir
(
URL
codeBase
)
throws
Exception
{
File
dir
=
new
File
(
new
URI
(
codeBase
.
toString
()));
Set
names
=
new
TreeSet
();
Set
<
String
>
names
=
new
TreeSet
<
String
>
();
scanDir
(
dir
,
""
,
names
);
return
names
;
}
private
static
void
scanDir
(
File
dir
,
String
prefix
,
Set
names
)
private
static
void
scanDir
(
File
dir
,
String
prefix
,
Set
<
String
>
names
)
throws
Exception
{
File
[]
files
=
dir
.
listFiles
();
if
(
files
==
null
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录