MBeanServer mbs = MBeanServerFactory.createMBeanServer();
// Instantiate an MLet
//
System.out.println("Create the MLet");
MLet mlet = new MLet();
// Register the MLet MBean with the MBeanServer
//
System.out.println("Register the MLet MBean");
ObjectName mletObjectName = new ObjectName("Test:type=MLet");
mbs.registerMBean(mlet, mletObjectName);
// Call getMBeansFromURL
//
System.out.println("Call mlet.getMBeansFromURL(<url>)");
String testSrc = System.getProperty("test.src");
System.out.println("test.src = " + testSrc);
String urlCodebase;
if (testSrc.startsWith("/")) {
urlCodebase =
"file:" + testSrc.replace(File.separatorChar, '/') + "/";
} else {
urlCodebase =
"file:/" + testSrc.replace(File.separatorChar, '/') + "/";
}
String mletFile = urlCodebase + args[0];
System.out.println("MLet File = " + mletFile);
try {
mlet.getMBeansFromURL(mletFile);
System.out.println(
"TEST FAILED: Expected ServiceNotFoundException not thrown");
error = true;
} catch (ServiceNotFoundException e) {
if (e.getCause() == null) {