Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
d09fa405
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看板
提交
d09fa405
编写于
12月 20, 2012
作者:
A
alanb
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8001048: JSR-160: Allow IIOP transport to be optional
Reviewed-by: dsamersoff, dfuchs, mchung
上级
397d95ab
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
211 addition
and
187 deletion
+211
-187
src/share/classes/com/sun/jmx/remote/internal/IIOPHelper.java
...share/classes/com/sun/jmx/remote/internal/IIOPHelper.java
+19
-18
src/share/classes/javax/management/remote/JMXConnectorFactory.java
.../classes/javax/management/remote/JMXConnectorFactory.java
+4
-2
src/share/classes/javax/management/remote/JMXConnectorServerFactory.java
...es/javax/management/remote/JMXConnectorServerFactory.java
+4
-2
src/share/classes/javax/management/remote/rmi/RMIConnector.java
...are/classes/javax/management/remote/rmi/RMIConnector.java
+11
-0
src/share/classes/javax/management/remote/rmi/RMIConnectorServer.java
...asses/javax/management/remote/rmi/RMIConnectorServer.java
+2
-1
src/share/classes/javax/management/remote/rmi/package.html
src/share/classes/javax/management/remote/rmi/package.html
+2
-2
test/javax/management/remote/mandatory/connection/AddressableTest.java
...nagement/remote/mandatory/connection/AddressableTest.java
+26
-9
test/javax/management/remote/mandatory/connection/CloseableTest.java
...management/remote/mandatory/connection/CloseableTest.java
+27
-11
test/javax/management/remote/mandatory/connection/ConnectionListenerNullTest.java
...mote/mandatory/connection/ConnectionListenerNullTest.java
+18
-22
test/javax/management/remote/mandatory/connection/IIOPURLTest.java
...x/management/remote/mandatory/connection/IIOPURLTest.java
+13
-6
test/javax/management/remote/mandatory/connection/IdleTimeoutTest.java
...nagement/remote/mandatory/connection/IdleTimeoutTest.java
+17
-11
test/javax/management/remote/mandatory/connection/MultiThreadDeadLockTest.java
.../remote/mandatory/connection/MultiThreadDeadLockTest.java
+0
-1
test/javax/management/remote/mandatory/connectorServer/SetMBeanServerForwarder.java
...te/mandatory/connectorServer/SetMBeanServerForwarder.java
+17
-21
test/javax/management/remote/mandatory/loading/MissingClassTest.java
...management/remote/mandatory/loading/MissingClassTest.java
+23
-21
test/javax/management/remote/mandatory/provider/ProviderTest.java
...ax/management/remote/mandatory/provider/ProviderTest.java
+27
-59
test/javax/management/remote/mandatory/serverError/JMXServerErrorTest.java
...ment/remote/mandatory/serverError/JMXServerErrorTest.java
+1
-1
未找到文件。
src/share/classes/com/sun/jmx/remote/internal/IIOPHelper.java
浏览文件 @
d09fa405
...
...
@@ -26,13 +26,8 @@
package
com.sun.jmx.remote.internal
;
import
java.util.Properties
;
import
java.io.IOException
;
import
java.rmi.Remote
;
import
java.rmi.RemoteException
;
import
java.rmi.NoSuchObjectException
;
import
java.util.Properties
;
import
java.rmi.Remote
;
import
java.rmi.RemoteException
;
import
java.rmi.NoSuchObjectException
;
import
java.security.AccessController
;
...
...
@@ -115,9 +110,10 @@ public final class IIOPHelper {
* Connects the Stub to the given ORB.
*/
public
static
void
connect
(
Object
stub
,
Object
orb
)
throws
Remote
Exception
throws
IO
Exception
{
ensureAvailable
();
if
(
proxy
==
null
)
throw
new
IOException
(
"Connection to ORB failed, RMI/IIOP not available"
);
proxy
.
connect
(
stub
,
orb
);
}
...
...
@@ -125,15 +121,17 @@ public final class IIOPHelper {
* Returns true if the given object is an ORB.
*/
public
static
boolean
isOrb
(
Object
obj
)
{
ensureAvailable
();
return
proxy
.
isOrb
(
obj
);
return
(
proxy
==
null
)
?
false
:
proxy
.
isOrb
(
obj
);
}
/**
* Creates, and returns, a new ORB instance.
*/
public
static
Object
createOrb
(
String
[]
args
,
Properties
props
)
{
ensureAvailable
();
public
static
Object
createOrb
(
String
[]
args
,
Properties
props
)
throws
IOException
{
if
(
proxy
==
null
)
throw
new
IOException
(
"ORB initialization failed, RMI/IIOP not available"
);
return
proxy
.
createOrb
(
args
,
props
);
}
...
...
@@ -166,24 +164,27 @@ public final class IIOPHelper {
/**
* Makes a server object ready to receive remote calls
*/
public
static
void
exportObject
(
Remote
obj
)
throws
RemoteException
{
ensureAvailable
();
public
static
void
exportObject
(
Remote
obj
)
throws
IOException
{
if
(
proxy
==
null
)
throw
new
IOException
(
"RMI object cannot be exported, RMI/IIOP not available"
);
proxy
.
exportObject
(
obj
);
}
/**
* Deregisters a server object from the runtime.
*/
public
static
void
unexportObject
(
Remote
obj
)
throws
NoSuchObjectException
{
ensureAvailable
();
public
static
void
unexportObject
(
Remote
obj
)
throws
IOException
{
if
(
proxy
==
null
)
throw
new
NoSuchObjectException
(
"Object not exported"
);
proxy
.
unexportObject
(
obj
);
}
/**
* Returns a stub for the given server object.
*/
public
static
Remote
toStub
(
Remote
obj
)
throws
NoSuchObjectException
{
ensureAvailable
();
public
static
Remote
toStub
(
Remote
obj
)
throws
IOException
{
if
(
proxy
==
null
)
throw
new
NoSuchObjectException
(
"Object not exported"
);
return
proxy
.
toStub
(
obj
);
}
}
src/share/classes/javax/management/remote/JMXConnectorFactory.java
浏览文件 @
d09fa405
...
...
@@ -137,8 +137,10 @@ import com.sun.jmx.remote.util.EnvHelp;
* JAR conventions for service providers</a>, where the service
* interface is <code>JMXConnectorProvider</code>.</p>
*
* <p>Every implementation must support the RMI connector protocols,
* specified with the string <code>rmi</code> or
* <p>Every implementation must support the RMI connector protocol with
* the default RMI transport, specified with string <code>rmi</code>.
* An implementation may optionally support the RMI connector protocol
* with the RMI/IIOP transport, specified with the string
* <code>iiop</code>.</p>
*
* <p>Once a provider is found, the result of the
...
...
src/share/classes/javax/management/remote/JMXConnectorServerFactory.java
浏览文件 @
d09fa405
...
...
@@ -129,8 +129,10 @@ import javax.management.MBeanServer;
* JAR conventions for service providers</a>, where the service
* interface is <code>JMXConnectorServerProvider</code>.</p>
*
* <p>Every implementation must support the RMI connector protocols,
* specified with the string <code>rmi</code> or
* <p>Every implementation must support the RMI connector protocol with
* the default RMI transport, specified with string <code>rmi</code>.
* An implementation may optionally support the RMI connector protocol
* with the RMI/IIOP transport, specified with the string
* <code>iiop</code>.</p>
*
* <p>Once a provider is found, the result of the
...
...
src/share/classes/javax/management/remote/rmi/RMIConnector.java
浏览文件 @
d09fa405
...
...
@@ -238,10 +238,21 @@ public class RMIConnector implements JMXConnector, Serializable, JMXAddressable
//--------------------------------------------------------------------
// implements JMXConnector interface
//--------------------------------------------------------------------
/**
* @throws IOException if the connection could not be made because of a
* communication problem, or in the case of the {@code iiop} protocol,
* that RMI/IIOP is not supported
*/
public
void
connect
()
throws
IOException
{
connect
(
null
);
}
/**
* @throws IOException if the connection could not be made because of a
* communication problem, or in the case of the {@code iiop} protocol,
* that RMI/IIOP is not supported
*/
public
synchronized
void
connect
(
Map
<
String
,?>
environment
)
throws
IOException
{
final
boolean
tracing
=
logger
.
traceOn
();
...
...
src/share/classes/javax/management/remote/rmi/RMIConnectorServer.java
浏览文件 @
d09fa405
...
...
@@ -337,7 +337,8 @@ public class RMIConnectorServer extends JMXConnectorServer {
* @exception IllegalStateException if the connector server has
* not been attached to an MBean server.
* @exception IOException if the connector server cannot be
* started.
* started, or in the case of the {@code iiop} protocol, that
* RMI/IIOP is not supported.
*/
public
synchronized
void
start
()
throws
IOException
{
final
boolean
tracing
=
logger
.
traceOn
();
...
...
src/share/classes/javax/management/remote/rmi/package.html
浏览文件 @
d09fa405
...
...
@@ -36,8 +36,8 @@ questions.
that different implementations of the RMI connector can
interoperate.
</p>
<p>
The RMI connector supports
both the JRMP and the IIOP transports
for RMI
.
</p>
<p>
The RMI connector supports
the JRMP transport for RMI, and
optionally the IIOP transport
.
</p>
<p>
Like most connectors in the JMX Remote API, an RMI connector
usually has an address, which
...
...
test/javax/management/remote/mandatory/connection/AddressableTest.java
浏览文件 @
d09fa405
...
...
@@ -45,19 +45,36 @@ public class AddressableTest {
private
static
final
MBeanServer
mbs
=
MBeanServerFactory
.
createMBeanServer
();
private
static
boolean
isProtocolSupported
(
String
protocol
)
{
if
(
protocol
.
equals
(
"rmi"
))
return
true
;
if
(
protocol
.
equals
(
"iiop"
))
{
try
{
Class
.
forName
(
"javax.management.remote.rmi._RMIConnectionImpl_Tie"
);
return
true
;
}
catch
(
ClassNotFoundException
x
)
{
}
}
return
false
;
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
System
.
out
.
println
(
">>> test the new interface Addressable."
);
boolean
ok
=
true
;
for
(
int
i
=
0
;
i
<
protocols
.
length
;
i
++)
{
try
{
test
(
protocols
[
i
],
prefixes
[
i
]);
System
.
out
.
println
(
">>> Test successed for "
+
protocols
[
i
]);
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
">>> Test failed for "
+
protocols
[
i
]);
e
.
printStackTrace
(
System
.
out
);
ok
=
false
;
String
protocol
=
protocols
[
i
];
if
(
isProtocolSupported
(
protocol
))
{
try
{
test
(
protocol
,
prefixes
[
i
]);
System
.
out
.
println
(
">>> Test successed for "
+
protocols
[
i
]);
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
">>> Test failed for "
+
protocols
[
i
]);
e
.
printStackTrace
(
System
.
out
);
ok
=
false
;
}
}
else
{
System
.
out
.
format
(
">>> Test skipped for %s, protocol not supported%n"
,
protocol
);
}
}
...
...
@@ -65,7 +82,7 @@ public class AddressableTest {
System
.
out
.
println
(
">>> All Test passed."
);
}
else
{
System
.
out
.
println
(
">>> Some TESTs FAILED"
);
System
.
exit
(
1
);
throw
new
RuntimeException
(
"See log for details"
);
}
}
...
...
test/javax/management/remote/mandatory/connection/CloseableTest.java
浏览文件 @
d09fa405
...
...
@@ -42,7 +42,6 @@ import javax.management.remote.rmi.RMIConnector;
import
javax.management.remote.rmi.RMIIIOPServerImpl
;
import
javax.management.remote.rmi.RMIJRMPServerImpl
;
import
javax.management.remote.rmi.RMIServerImpl
;
import
org.omg.stub.javax.management.remote.rmi._RMIConnection_Stub
;
public
class
CloseableTest
{
private
static
final
Class
closeArray
[]
=
{
...
...
@@ -51,26 +50,43 @@ public class CloseableTest {
RMIConnection
.
class
,
RMIConnectionImpl
.
class
,
RMIConnectionImpl_Stub
.
class
,
_RMIConnection_Stub
.
class
,
RMIServerImpl
.
class
,
RMIIIOPServerImpl
.
class
,
RMIJRMPServerImpl
.
class
};
static
int
error
;
static
void
test
(
Class
<?>
c
)
{
System
.
out
.
println
(
"\nTest "
+
c
);
if
(
Closeable
.
class
.
isAssignableFrom
(
c
))
{
System
.
out
.
println
(
"Test passed!"
);
}
else
{
error
++;
System
.
out
.
println
(
"Test failed!"
);
}
}
static
void
test
(
String
cn
)
{
try
{
test
(
Class
.
forName
(
cn
));
}
catch
(
ClassNotFoundException
ignore
)
{
System
.
out
.
println
(
"\n"
+
cn
+
" not tested."
);
}
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
System
.
out
.
println
(
"Test that all the JMX Remote API classes that "
+
"define\nthe method \"void close() throws "
+
"IOException;\" extend\nor implement the "
+
"java.io.Closeable interface."
);
int
error
=
0
;
for
(
Class
c
:
closeArray
)
{
System
.
out
.
println
(
"\nTest "
+
c
);
if
(
Closeable
.
class
.
isAssignableFrom
(
c
))
{
System
.
out
.
println
(
"Test passed!"
);
}
else
{
error
++;
System
.
out
.
println
(
"Test failed!"
);
}
for
(
Class
<?>
c
:
closeArray
)
{
test
(
c
);
}
// Stub classes not present if RMI-IIOP not supported
test
(
"org.omg.stub.javax.management.remote.rmi._RMIConnection_Stub"
);
if
(
error
>
0
)
{
final
String
msg
=
"\nTest FAILED! Got "
+
error
+
" error(s)"
;
System
.
out
.
println
(
msg
);
...
...
test/javax/management/remote/mandatory/connection/ConnectionListenerNullTest.java
浏览文件 @
d09fa405
...
...
@@ -39,33 +39,22 @@ import javax.management.NotificationListener;
import
java.util.Map
;
public
class
ConnectionListenerNullTest
{
static
final
boolean
optionalFlag
;
static
{
Class
genericClass
=
null
;
static
boolean
isPresent
(
String
cn
)
{
try
{
genericClass
=
Class
.
forName
(
"javax.management.remote.generic.GenericConnector"
)
;
Class
.
forName
(
cn
);
return
true
;
}
catch
(
ClassNotFoundException
x
)
{
// NO optional package
return
false
;
}
optionalFlag
=
(
genericClass
!=
null
);
}
final
static
String
[]
mandatoryList
=
{
"service:jmx:rmi://"
,
"service:jmx:iiop://"
};
final
static
String
[]
optionalList
=
{
"service:jmx:jmxmp://"
};
public
static
int
test
(
String
[]
urls
)
{
public
static
int
test
(
String
...
urls
)
{
int
errCount
=
0
;
for
(
int
i
=
0
;
i
<
urls
.
length
;
i
++)
{
try
{
final
JMXServiceURL
url
=
new
JMXServiceURL
(
urls
[
i
]);
final
JMXConnector
c
=
JMXConnectorFactory
.
newJMXConnector
(
url
,(
Map
)
null
);
JMXConnectorFactory
.
newJMXConnector
(
url
,(
Map
<
String
,
String
>
)
null
);
final
NotificationListener
nl
=
null
;
final
NotificationFilter
nf
=
null
;
final
Object
h
=
null
;
...
...
@@ -121,12 +110,19 @@ public class ConnectionListenerNullTest {
public
static
void
main
(
String
args
[])
{
int
errCount
=
0
;
errCount
+=
test
(
mandatoryList
);
if
(
optionalFlag
)
errCount
+=
test
(
optionalList
);
// mandatory
errCount
+=
test
(
"service:jmx:rmi://"
);
// optional
if
(
isPresent
(
"javax.management.remote.rmi._RMIConnectionImpl_Tie"
))
errCount
+=
test
(
"service:jmx:iiop://"
);
if
(
isPresent
(
"javax.management.remote.generic.GenericConnector"
))
errCount
+=
test
(
"service:jmx:jmxmp://"
);
if
(
errCount
>
0
)
{
System
.
err
.
println
(
"ConnectionListenerNullTest failed: "
+
errCount
+
" error(s) reported."
);
System
.
exit
(
1
);
throw
new
RuntimeException
(
"ConnectionListenerNullTest failed: "
+
errCount
+
" error(s) reported."
);
}
System
.
out
.
println
(
"ConnectionListenerNullTest passed."
);
}
...
...
test/javax/management/remote/mandatory/connection/IIOPURLTest.java
浏览文件 @
d09fa405
...
...
@@ -49,17 +49,24 @@ public class IIOPURLTest {
public
static
void
main
(
String
[]
args
)
throws
Exception
{
JMXServiceURL
inputAddr
=
new
JMXServiceURL
(
"service:jmx:iiop://"
);
JMXConnectorServer
s
=
JMXConnectorServerFactory
.
newJMXConnectorServer
(
inputAddr
,
null
,
null
);
JMXConnectorServer
s
;
try
{
s
=
JMXConnectorServerFactory
.
newJMXConnectorServer
(
inputAddr
,
null
,
null
);
}
catch
(
java
.
net
.
MalformedURLException
x
)
{
try
{
Class
.
forName
(
"javax.management.remote.rmi._RMIConnectionImpl_Tie"
);
throw
new
RuntimeException
(
"MalformedURLException thrown but iiop appears to be supported"
);
}
catch
(
ClassNotFoundException
expected
)
{
}
System
.
out
.
println
(
"IIOP protocol not supported, test skipped"
);
return
;
}
MBeanServer
mbs
=
MBeanServerFactory
.
createMBeanServer
();
mbs
.
registerMBean
(
s
,
new
ObjectName
(
"a:b=c"
));
s
.
start
();
JMXServiceURL
outputAddr
=
s
.
getAddress
();
if
(!
outputAddr
.
getURLPath
().
startsWith
(
"/ior/IOR:"
))
{
System
.
out
.
println
(
"URL path should start with \"/ior/IOR:\": "
+
outputAddr
);
System
.
exit
(
1
);
throw
new
RuntimeException
(
"URL path should start with \"/ior/IOR:\": "
+
outputAddr
);
}
System
.
out
.
println
(
"IIOP URL path looks OK: "
+
outputAddr
);
JMXConnector
c
=
JMXConnectorFactory
.
connect
(
outputAddr
);
...
...
test/javax/management/remote/mandatory/connection/IdleTimeoutTest.java
浏览文件 @
d09fa405
...
...
@@ -52,21 +52,27 @@ import javax.management.remote.JMXServiceURL;
import
com.sun.jmx.remote.util.EnvHelp
;
public
class
IdleTimeoutTest
{
static
boolean
isPresent
(
String
cn
)
{
try
{
Class
.
forName
(
cn
);
return
true
;
}
catch
(
ClassNotFoundException
x
)
{
return
false
;
}
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
boolean
ok
=
true
;
List
protos
;
if
(
args
.
length
>
0
)
protos
=
Arrays
.
asList
(
args
);
else
{
protos
=
new
ArrayList
(
Arrays
.
asList
(
new
String
[]
{
"rmi"
,
"iiop"
}));
try
{
Class
.
forName
(
"javax.management.remote.jmxmp."
+
"JMXMPConnectorServer"
);
protos
=
new
ArrayList
(
Arrays
.
asList
(
new
String
[]
{
"rmi"
}));
if
(
isPresent
(
"javax.management.remote.rmi._RMIConnectionImpl_Tie"
))
protos
.
add
(
"iiop"
);
if
(
isPresent
(
"javax.management.remote.jmxmp.JMXMPConnectorServer"
))
protos
.
add
(
"jmxmp"
);
}
catch
(
ClassNotFoundException
e
)
{
// OK: Optional JMXMP support is not present
}
}
for
(
Iterator
it
=
protos
.
iterator
();
it
.
hasNext
();
)
{
String
proto
=
(
String
)
it
.
next
();
...
...
@@ -81,13 +87,13 @@ public class IdleTimeoutTest {
}
}
if
(!
ok
)
{
System
.
out
.
println
(
"SOME TESTS FAILED"
);
System
.
exit
(
1
);
throw
new
RuntimeException
(
"Some tests failed - see log for details"
);
}
}
private
static
long
getIdleTimeout
(
MBeanServer
mbs
,
JMXServiceURL
url
)
throws
Exception
{
throws
Exception
{
JMXConnectorServer
server
=
JMXConnectorServerFactory
.
newJMXConnectorServer
(
url
,
null
,
mbs
);
server
.
start
();
...
...
test/javax/management/remote/mandatory/connection/MultiThreadDeadLockTest.java
浏览文件 @
d09fa405
...
...
@@ -253,4 +253,3 @@ public class MultiThreadDeadLockTest {
System
.
out
.
println
(
"===Leave the method: "
+
m
);
}
}
test/javax/management/remote/mandatory/connectorServer/SetMBeanServerForwarder.java
浏览文件 @
d09fa405
...
...
@@ -40,27 +40,16 @@ import com.sun.jmx.remote.security.MBeanServerAccessController;
public
class
SetMBeanServerForwarder
{
static
final
boolean
optionalFlag
;
static
{
Class
genericClass
=
null
;
static
boolean
isPresent
(
String
cn
)
{
try
{
genericClass
=
Class
.
forName
(
"javax.management.remote.generic.GenericConnector"
)
;
Class
.
forName
(
cn
);
return
true
;
}
catch
(
ClassNotFoundException
x
)
{
// NO optional package
return
false
;
}
optionalFlag
=
(
genericClass
!=
null
);
}
final
static
String
[]
mandatoryList
=
{
"service:jmx:rmi://"
,
"service:jmx:iiop://"
};
final
static
String
[]
optionalList
=
{
"service:jmx:jmxmp://"
};
public
static
int
test
(
String
[]
urls
)
{
public
static
int
test
(
String
...
urls
)
{
int
errorCount
=
0
;
for
(
int
i
=
0
;
i
<
urls
.
length
;
i
++)
{
try
{
...
...
@@ -241,12 +230,19 @@ public class SetMBeanServerForwarder {
public
static
void
main
(
String
args
[])
{
int
errCount
=
0
;
errCount
+=
test
(
mandatoryList
);
if
(
optionalFlag
)
errCount
+=
test
(
optionalList
);
// mandatory
errCount
+=
test
(
"service:jmx:rmi://"
);
// optional
if
(
isPresent
(
"javax.management.remote.rmi._RMIConnectionImpl_Tie"
))
errCount
+=
test
(
"service:jmx:iiop://"
);
if
(
isPresent
(
"javax.management.remote.generic.GenericConnector"
))
errCount
+=
test
(
"service:jmx:jmxmp://"
);
if
(
errCount
>
0
)
{
System
.
err
.
println
(
"SetMBeanServerForwarder failed: "
+
errCount
+
" error(s) reported."
);
System
.
exit
(
1
);
throw
new
RuntimeException
(
"SetMBeanServerForwarder failed: "
+
errCount
+
" error(s) reported."
);
}
System
.
out
.
println
(
"SetMBeanServerForwarder passed."
);
}
...
...
test/javax/management/remote/mandatory/loading/MissingClassTest.java
浏览文件 @
d09fa405
...
...
@@ -70,7 +70,6 @@ import javax.management.remote.JMXConnectorServer;
import
javax.management.remote.JMXConnectorServerFactory
;
import
javax.management.remote.JMXServiceURL
;
import
javax.management.remote.rmi.RMIConnectorServer
;
import
org.omg.CORBA.MARSHAL
;
public
class
MissingClassTest
{
private
static
final
int
NNOTIFS
=
50
;
...
...
@@ -84,6 +83,15 @@ public class MissingClassTest {
private
static
final
Object
unserializableObject
=
Thread
.
currentThread
();
private
static
boolean
isInstance
(
Object
o
,
String
cn
)
{
try
{
Class
<?>
c
=
Class
.
forName
(
cn
);
return
c
.
isInstance
(
o
);
}
catch
(
ClassNotFoundException
x
)
{
return
false
;
}
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
System
.
out
.
println
(
"Test that the client or server end of a "
+
"connection does not fail if sent an object "
+
...
...
@@ -118,8 +126,7 @@ public class MissingClassTest {
if
(
ok
)
System
.
out
.
println
(
"Test passed"
);
else
{
System
.
out
.
println
(
"TEST FAILED"
);
System
.
exit
(
1
);
throw
new
RuntimeException
(
"TEST FAILED"
);
}
}
...
...
@@ -133,7 +140,7 @@ public class MissingClassTest {
JMXConnectorServer
cs
;
JMXServiceURL
url
=
new
JMXServiceURL
(
proto
,
null
,
0
);
Map
serverMap
=
new
HashMap
();
Map
<
String
,
Object
>
serverMap
=
new
HashMap
<>
();
serverMap
.
put
(
JMXConnectorServerFactory
.
DEFAULT_CLASS_LOADER
,
serverLoader
);
...
...
@@ -151,7 +158,7 @@ public class MissingClassTest {
}
cs
.
start
();
JMXServiceURL
addr
=
cs
.
getAddress
();
Map
clientMap
=
new
HashMap
();
Map
<
String
,
Object
>
clientMap
=
new
HashMap
<>
();
clientMap
.
put
(
JMXConnectorFactory
.
DEFAULT_CLASS_LOADER
,
clientLoader
);
...
...
@@ -174,7 +181,7 @@ public class MissingClassTest {
ok
=
false
;
}
catch
(
IOException
e
)
{
Throwable
cause
=
e
.
getCause
();
if
(
cause
instanceof
MARSHAL
)
// see CR 4935098
if
(
isInstance
(
cause
,
"org.omg.CORBA.MARSHAL"
)
)
// see CR 4935098
cause
=
cause
.
getCause
();
if
(
cause
instanceof
ClassNotFoundException
)
{
System
.
out
.
println
(
"Success: got an IOException wrapping "
+
...
...
@@ -188,7 +195,7 @@ public class MissingClassTest {
}
System
.
out
.
println
(
"Doing queryNames to ensure connection alive"
);
Set
names
=
mbsc
.
queryNames
(
null
,
null
);
Set
<
ObjectName
>
names
=
mbsc
.
queryNames
(
null
,
null
);
System
.
out
.
println
(
"queryNames returned "
+
names
);
System
.
out
.
println
(
"Provoke exception of unknown class"
);
...
...
@@ -198,7 +205,7 @@ public class MissingClassTest {
ok
=
false
;
}
catch
(
IOException
e
)
{
Throwable
wrapped
=
e
.
getCause
();
if
(
wrapped
instanceof
MARSHAL
)
// see CR 4935098
if
(
isInstance
(
wrapped
,
"org.omg.CORBA.MARSHAL"
)
)
// see CR 4935098
wrapped
=
wrapped
.
getCause
();
if
(
wrapped
instanceof
ClassNotFoundException
)
{
System
.
out
.
println
(
"Success: got an IOException wrapping "
+
...
...
@@ -251,7 +258,7 @@ public class MissingClassTest {
ok
=
false
;
}
catch
(
IOException
e
)
{
Throwable
cause
=
e
.
getCause
();
if
(
cause
instanceof
MARSHAL
)
// see CR 4935098
if
(
isInstance
(
cause
,
"org.omg.CORBA.MARSHAL"
)
)
// see CR 4935098
cause
=
cause
.
getCause
();
if
(
cause
instanceof
ClassNotFoundException
)
{
System
.
out
.
println
(
"Success: got an IOException "
+
...
...
@@ -584,15 +591,13 @@ public class MissingClassTest {
try
{
new
ObjectOutputStream
(
new
ByteArrayOutputStream
())
.
writeObject
(
tricky
);
System
.
out
.
println
(
"TEST INCORRECT: tricky notif is "
+
"serializable"
);
System
.
exit
(
1
);
throw
new
RuntimeException
(
"TEST INCORRECT: tricky notif is "
+
"serializable"
);
}
catch
(
NotSerializableException
e
)
{
// OK: tricky notif is not serializable
}
catch
(
IOException
e
)
{
System
.
out
.
println
(
"TEST INCORRECT: tricky notif "
+
"serialization check failed"
);
System
.
exit
(
1
);
throw
new
RuntimeException
(
"TEST INCORRECT: tricky notif "
+
"serialization check failed"
);
}
/* Now shuffle an imaginary deck of cards where K, U, T, and
...
...
@@ -629,12 +634,11 @@ public class MissingClassTest {
}
if
(
knownCount
!=
0
||
unknownCount
!=
0
||
trickyCount
!=
0
||
boringCount
!=
0
)
{
System
.
out
.
printl
n
(
"TEST INCORRECT: Shuffle failed: "
+
throw
new
RuntimeExceptio
n
(
"TEST INCORRECT: Shuffle failed: "
+
"known="
+
knownCount
+
" unknown="
+
unknownCount
+
" tricky="
+
trickyCount
+
" boring="
+
boringCount
+
" deal="
+
notifList
);
System
.
exit
(
1
);
}
String
notifs
=
notifList
.
toString
();
System
.
out
.
println
(
"Shuffle: "
+
notifs
);
...
...
@@ -646,10 +650,8 @@ public class MissingClassTest {
case
't'
:
n
=
tricky
;
break
;
case
'b'
:
n
=
boring
;
break
;
default
:
System
.
out
.
println
(
"TEST INCORRECT: Bad shuffle char: "
+
notifs
.
charAt
(
i
));
System
.
exit
(
1
);
throw
new
Error
();
throw
new
RuntimeException
(
"TEST INCORRECT: Bad shuffle char: "
+
notifs
.
charAt
(
i
));
}
sendNotification
(
n
);
}
...
...
test/javax/management/remote/mandatory/provider/ProviderTest.java
浏览文件 @
d09fa405
...
...
@@ -49,13 +49,13 @@ import javax.management.MBeanServer;
import
provider.JMXConnectorProviderImpl
;
import
provider.JMXConnectorServerProviderImpl
;
public
class
ProviderTest
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
System
.
out
.
println
(
"Starting ProviderTest"
);
MBeanServer
mbs
=
MBeanServerFactory
.
newMBeanServer
();
//First do the test with a protocol handled by Service providers
JMXServiceURL
url
=
new
JMXServiceURL
(
"service:jmx:rmi://"
);
// First do the test with a protocol handled by Service providers
JMXServiceURL
url
=
new
JMXServiceURL
(
"service:jmx:rmi://"
);
dotest
(
url
,
mbs
);
boolean
clientCalled
=
provider
.
JMXConnectorProviderImpl
.
called
();
...
...
@@ -66,16 +66,22 @@ public class ProviderTest {
System
.
out
.
println
(
"Client provider not called"
);
if
(!
serverCalled
)
System
.
out
.
println
(
"Server provider not called"
);
System
.
out
.
println
(
"Test Failed"
);
System
.
exit
(
1
);
throw
new
RuntimeException
(
"Test failed - see log for details"
);
}
//The Service Provider doesn't handle IIOP. Default providers MUST
//be called.
url
=
new
JMXServiceURL
(
"service:jmx:iiop://"
);
dotest
(
url
,
mbs
);
// The Service Provider doesn't handle IIOP. Default providers MUST
// be called, which may or may not support IIOP.
url
=
new
JMXServiceURL
(
"service:jmx:iiop://"
);
try
{
dotest
(
url
,
mbs
);
}
catch
(
MalformedURLException
e
)
{
try
{
Class
.
forName
(
"javax.management.remote.rmi._RMIConnectionImpl_Tie"
);
e
.
printStackTrace
(
System
.
out
);
throw
new
RuntimeException
(
"MalformedURLException throw but IIOP appears to be supported"
);
}
catch
(
ClassNotFoundException
expected
)
{
}
System
.
out
.
println
(
"MalformedURLException thrown, IIOP transport not supported"
);
}
// Unsupported protocol.
JMXConnectorServer
server
=
null
;
...
...
@@ -87,31 +93,19 @@ public class ProviderTest {
JMXConnectorServerFactory
.
newJMXConnectorServer
(
url
,
null
,
mbs
);
System
.
out
.
println
(
"Exception not thrown."
);
System
.
exit
(
1
);
}
catch
(
MalformedURLException
e
)
{
throw
new
RuntimeException
(
"Exception not thrown."
);
}
catch
(
MalformedURLException
e
)
{
System
.
out
.
println
(
"Expected MalformedURLException thrown."
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
System
.
out
.
println
(
"Exception thrown : "
+
e
);
System
.
exit
(
1
);
}
try
{
client
=
JMXConnectorFactory
.
newJMXConnector
(
url
,
null
);
System
.
out
.
println
(
"Exception not thrown."
);
System
.
exit
(
1
);
}
catch
(
MalformedURLException
e
)
{
throw
new
RuntimeException
(
"Exception not thrown."
);
}
catch
(
MalformedURLException
e
)
{
System
.
out
.
println
(
"Expected MalformedURLException thrown."
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
System
.
out
.
println
(
"Exception thrown : "
+
e
);
System
.
exit
(
1
);
}
//JMXConnectorProviderException
url
=
...
...
@@ -121,60 +115,34 @@ public class ProviderTest {
JMXConnectorServerFactory
.
newJMXConnectorServer
(
url
,
null
,
mbs
);
System
.
out
.
println
(
"Exception not thrown."
);
System
.
exit
(
1
);
}
catch
(
JMXProviderException
e
)
{
throw
new
RuntimeException
(
"Exception not thrown."
);
}
catch
(
JMXProviderException
e
)
{
System
.
out
.
println
(
"Expected JMXProviderException thrown."
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
System
.
out
.
println
(
"Exception thrown : "
+
e
);
System
.
exit
(
1
);
}
try
{
client
=
JMXConnectorFactory
.
newJMXConnector
(
url
,
null
);
System
.
out
.
println
(
"Exception not thrown."
);
System
.
exit
(
1
);
throw
new
RuntimeException
(
"Exception not thrown."
);
}
catch
(
JMXProviderException
e
)
{
System
.
out
.
println
(
"Expected JMXProviderException thrown."
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
System
.
out
.
println
(
"Exception thrown : "
+
e
);
System
.
exit
(
1
);
}
System
.
out
.
println
(
"Test OK"
);
return
;
}
private
static
void
dotest
(
JMXServiceURL
url
,
MBeanServer
mbs
)
throws
Exception
{
JMXConnectorServer
server
=
null
;
JMXConnector
client
=
null
;
try
{
server
=
JMXConnectorServerFactory
.
newJMXConnectorServer
(
url
,
null
,
mbs
);
}
catch
(
IllegalArgumentException
e
)
{
e
.
printStackTrace
();
System
.
exit
(
1
);
}
server
=
JMXConnectorServerFactory
.
newJMXConnectorServer
(
url
,
null
,
mbs
);
server
.
start
();
JMXServiceURL
outputAddr
=
server
.
getAddress
();
System
.
out
.
println
(
"Server started ["
+
outputAddr
+
"]"
);
try
{
client
=
JMXConnectorFactory
.
newJMXConnector
(
outputAddr
,
null
);
}
catch
(
IllegalArgumentException
e
)
{
e
.
printStackTrace
();
System
.
exit
(
1
);
}
client
=
JMXConnectorFactory
.
newJMXConnector
(
outputAddr
,
null
);
client
.
connect
();
System
.
out
.
println
(
"Client connected"
);
...
...
test/javax/management/remote/mandatory/serverError/JMXServerErrorTest.java
浏览文件 @
d09fa405
...
...
@@ -120,7 +120,7 @@ public class JMXServerErrorTest {
try
{
cs
=
JMXConnectorServerFactory
.
newJMXConnectorServer
(
jurl
,
null
,
kbs
);
}
catch
(
MalformedURLException
m
)
{
if
(
"jmxmp"
.
equals
(
jurl
.
getProtocol
()))
{
if
(
"jmxmp"
.
equals
(
jurl
.
getProtocol
())
||
"iiop"
.
equals
(
jurl
.
getProtocol
())
)
{
// OK, we may not have this in the classpath...
System
.
out
.
println
(
"WARNING: Skipping protocol: "
+
jurl
);
return
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录