}
@SuppressWarnings("unchecked")
public void testConnection() throws Exception {
TestProjectProvider projectProvider;
IProject project;
projectProvider = new TestProjectProvider(JMXTestPlugin.PLUGIN_ID,
"projects" + Path.SEPARATOR + "JMX_EXAMPLE",
null, true);
project = projectProvider.getProject();
project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
ILaunchConfigurationWorkingCopy wc = createLaunch();
ILaunch launch = wc.launch("run", new NullProgressMonitor());
Thread.sleep(10000);
try {
IConnectionProvider defProvider =
ExtensionManager.getProvider(DefaultConnectionProvider.PROVIDER_ID);
HashMap map = new HashMap();
map.put(DefaultConnectionProvider.ID, "Test Connection");
map.put(DefaultConnectionProvider.URL, "service:jmx:rmi:///jndi/rmi://localhost:9999" +
"/jmxrmi");
map.put(DefaultConnectionProvider.USERNAME, "");
map.put(DefaultConnectionProvider.PASSWORD, "");
IConnectionWrapper wrapper = defProvider.createConnection(map);
assertTrue("Connection was null", wrapper != null);
wrapper.connect();
Root root = wrapper.getRoot();
assertTrue("Root was not null", root == null);
wrapper.loadRoot();
root = wrapper.getRoot();
assertTrue("Root was null", root != null);
Node[] children = root.getChildren();
assertTrue("children were null", children != null);
assertEquals("Example had the wrong number of domains", 5, children.length);
} finally {
projectProvider.dispose();
launch.terminate();
}
}