< prev index next >
application/tests/org.openjdk.jmc.rjmx.test/src/test/java/org/openjdk/jmc/rjmx/test/BasicCommunicationTest.java
Print this page
*** 58,69 ****
/**
* Basic tests for the new cleaned up RJMX API.
*/
public class BasicCommunicationTest extends ServerHandleTestCase {
final static int DEFAULT_PORT = 0;
! final static String DEFAULT_HOST = "localhost".intern(); //$NON-NLS-1$
! final static String ALTERNATIVE_HOST = "127.1.0.1".intern(); //$NON-NLS-1$
/**
* Attempts creating a {@link JMXConnectionDescriptor} with a bunch of options.
*/
@Test
--- 58,69 ----
/**
* Basic tests for the new cleaned up RJMX API.
*/
public class BasicCommunicationTest extends ServerHandleTestCase {
final static int DEFAULT_PORT = 0;
! final static String DEFAULT_HOST = "localhost".intern();
! final static String ALTERNATIVE_HOST = "127.1.0.1".intern();
/**
* Attempts creating a {@link JMXConnectionDescriptor} with a bunch of options.
*/
@Test
*** 74,111 ****
assertEquals(DEFAULT_PORT, ConnectionToolkit.getPort(url));
}
@Test
public void testIConnectionHandle() throws Exception {
! IConnectionHandle handle = getDefaultServer().connect("Test"); //$NON-NLS-1$
! MRI descriptor = new MRI(Type.ATTRIBUTE, "java.lang:type=Threading", //$NON-NLS-1$
! "ThreadCount"); //$NON-NLS-1$
MBeanServerConnection connection = handle.getServiceOrThrow(MBeanServerConnection.class);
assertBetween(1L, 1000L,
((Number) connection.getAttribute(descriptor.getObjectName(), descriptor.getDataPath())).longValue());
handle.close();
}
@Test
public void testServerHandle() throws Exception {
! IConnectionHandle handle = getDefaultServer().connect("Test"); //$NON-NLS-1$
assertEquals(1, getDefaultServer().getConnectionHandles().length);
assertEquals(handle, getDefaultServer().getConnectionHandles()[0]);
handle.close();
assertEquals(0, getDefaultServer().getConnectionHandles().length);
}
protected void muppTestConnection() throws Exception {
ConnectionDescriptorBuilder builder = new ConnectionDescriptorBuilder();
! IConnectionDescriptor descriptor = builder.hostName("localhost").port(0).build(); //$NON-NLS-1$
! IConnectionHandle handle = IServerHandle.create(descriptor).connect("Test"); //$NON-NLS-1$
ISubscriptionService service = handle.getServiceOrThrow(ISubscriptionService.class);
! MRI attribute = new MRI(Type.ATTRIBUTE, "java.lang:type=Threading", //$NON-NLS-1$
! "ThreadCount"); //$NON-NLS-1$
service.addMRIValueListener(attribute, new IMRIValueListener() {
@Override
public void valueChanged(MRIValueEvent event) {
System.out.println(event.getValue());
}
--- 74,111 ----
assertEquals(DEFAULT_PORT, ConnectionToolkit.getPort(url));
}
@Test
public void testIConnectionHandle() throws Exception {
! IConnectionHandle handle = getDefaultServer().connect("Test");
! MRI descriptor = new MRI(Type.ATTRIBUTE, "java.lang:type=Threading",
! "ThreadCount");
MBeanServerConnection connection = handle.getServiceOrThrow(MBeanServerConnection.class);
assertBetween(1L, 1000L,
((Number) connection.getAttribute(descriptor.getObjectName(), descriptor.getDataPath())).longValue());
handle.close();
}
@Test
public void testServerHandle() throws Exception {
! IConnectionHandle handle = getDefaultServer().connect("Test");
assertEquals(1, getDefaultServer().getConnectionHandles().length);
assertEquals(handle, getDefaultServer().getConnectionHandles()[0]);
handle.close();
assertEquals(0, getDefaultServer().getConnectionHandles().length);
}
protected void muppTestConnection() throws Exception {
ConnectionDescriptorBuilder builder = new ConnectionDescriptorBuilder();
! IConnectionDescriptor descriptor = builder.hostName("localhost").port(0).build();
! IConnectionHandle handle = IServerHandle.create(descriptor).connect("Test");
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());
}
< prev index next >