< prev index next >

application/tests/org.openjdk.jmc.rjmx.test/src/test/java/org/openjdk/jmc/rjmx/test/PackageExampleTest.java

Print this page

        

*** 72,87 **** * * @throws ConnectionException */ @Test public void testPackageExampleVerbatim() throws Exception { ! IConnectionDescriptor descriptor = new ConnectionDescriptorBuilder().hostName("localhost").port(0).build(); //$NON-NLS-1$ IServerHandle serverHandle = IServerHandle.create(descriptor); ! IConnectionHandle handle = serverHandle.connect("Usage description"); //$NON-NLS-1$ try { ISubscriptionService service = handle.getServiceOrThrow(ISubscriptionService.class); ! MRI attribute = new MRI(Type.ATTRIBUTE, "java.lang:type=Threading", "ThreadCount"); //$NON-NLS-1$ //$NON-NLS-2$ service.addMRIValueListener(attribute, new IMRIValueListener() { @Override public void valueChanged(MRIValueEvent event) { System.out.println(event.getValue()); } --- 72,87 ---- * * @throws ConnectionException */ @Test public void testPackageExampleVerbatim() throws Exception { ! IConnectionDescriptor descriptor = new ConnectionDescriptorBuilder().hostName("localhost").port(0).build(); IServerHandle serverHandle = IServerHandle.create(descriptor); ! IConnectionHandle handle = serverHandle.connect("Usage description"); try { ISubscriptionService service = handle.getServiceOrThrow(ISubscriptionService.class); ! MRI attribute = new MRI(Type.ATTRIBUTE, "java.lang:type=Threading", "ThreadCount"); service.addMRIValueListener(attribute, new IMRIValueListener() { @Override public void valueChanged(MRIValueEvent event) { System.out.println(event.getValue()); }
*** 96,111 **** } @Test public void testPackageExampleFunctionality() throws Exception { ConnectionDescriptorBuilder builder = new ConnectionDescriptorBuilder(); ! IConnectionDescriptor descriptor = builder.hostName("localhost").port(0).build(); //$NON-NLS-1$ ! IConnectionHandle handle = IServerHandle.create(descriptor).connect("Usage description"); //$NON-NLS-1$ try { ISubscriptionService service = handle.getServiceOrThrow(ISubscriptionService.class); gotEvent = false; ! MRI attribute = new MRI(Type.ATTRIBUTE, "java.lang:type=Threading", "ThreadCount"); //$NON-NLS-1$ //$NON-NLS-2$ service.addMRIValueListener(attribute, new IMRIValueListener() { @Override public void valueChanged(MRIValueEvent event) { synchronized (PackageExampleTest.this) { gotEvent = true; --- 96,111 ---- } @Test public void testPackageExampleFunctionality() throws Exception { ConnectionDescriptorBuilder builder = new ConnectionDescriptorBuilder(); ! IConnectionDescriptor descriptor = builder.hostName("localhost").port(0).build(); ! IConnectionHandle handle = IServerHandle.create(descriptor).connect("Usage description"); try { ISubscriptionService service = handle.getServiceOrThrow(ISubscriptionService.class); gotEvent = false; ! MRI attribute = new MRI(Type.ATTRIBUTE, "java.lang:type=Threading", "ThreadCount"); service.addMRIValueListener(attribute, new IMRIValueListener() { @Override public void valueChanged(MRIValueEvent event) { synchronized (PackageExampleTest.this) { gotEvent = true;
*** 119,139 **** this.wait(4000); } } finally { IOToolkit.closeSilently(handle); } ! assertTrue("Never got any event!", gotEvent); //$NON-NLS-1$ } @Test public void testUseServerModel() throws Exception { IServerModel model = RJMXPlugin.getDefault().getService(IServerModel.class); for (IServer server : model.elements()) { IServerDescriptor descriptor = server.getServerHandle().getServerDescriptor(); if (descriptor.getJvmInfo() != null && Integer.valueOf(Environment.getThisPID()).equals(descriptor.getJvmInfo().getPid())) { ! IConnectionHandle handle = server.getServerHandle().connect("Usage description"); //$NON-NLS-1$ try { handle.getServiceOrThrow(IMBeanHelperService.class).getMBeanNames().size(); return; } finally { IOToolkit.closeSilently(handle); --- 119,139 ---- this.wait(4000); } } finally { IOToolkit.closeSilently(handle); } ! assertTrue("Never got any event!", gotEvent); } @Test public void testUseServerModel() throws Exception { IServerModel model = RJMXPlugin.getDefault().getService(IServerModel.class); for (IServer server : model.elements()) { IServerDescriptor descriptor = server.getServerHandle().getServerDescriptor(); if (descriptor.getJvmInfo() != null && Integer.valueOf(Environment.getThisPID()).equals(descriptor.getJvmInfo().getPid())) { ! IConnectionHandle handle = server.getServerHandle().connect("Usage description"); try { handle.getServiceOrThrow(IMBeanHelperService.class).getMBeanNames().size(); return; } finally { IOToolkit.closeSilently(handle);
< prev index next >