I am attempting to make gmx a Groovy oriented but Java usable API, so for the most part, each logical test case has a Java and a Groovy version. Here's an example of a Groovy test:
public void testRemoteClosureForMBeanCountAndDomains() throws Exception {In a nutshell, this test:
def port = 18900;
def gmx = null;
def jvmProcess = null;
try {
jvmProcess = JVMLauncher.newJVMLauncher().timeout(120000).basicPortJmx(port).start();
gmx = Gmx.remote(jmxUrl(port));
def remoteDomains = gmx.exec({ return it.getDomains();});
def domains = gmx.getDomains();
Assert.assertArrayEquals("Domain array", domains, remoteDomains);
def remoteMBeanCount = gmx.exec({ return it.getMBeanCount();});
def mbeanCount = gmx.getMBeanCount();
Assert.assertEquals("MBean Count", mbeanCount, remoteMBeanCount);
} finally {
if(gmx!=null) try { gmx.close(); } catch (Exception e) {}
if(jvmProcess!=null) try { jvmProcess.destroy(); } catch (Exception e) {}
}
}
- Starts a new JVM with the JMX management agent enabled.
- Retrieves the MBeanServer's MBean domains using a remote JMX call and then using a remoted closure. Verifies they're equal.
- Retrieves the MBeanServer's MBean count using a remote JMX call and then using a remoted closure. Verifies they're equal.
The latest snapshot is available here:
Of course, these tests raised a bunch of issues which I am in arrears entering into Github. If you encounter any issues, please leave me some feedback.
//Nicholas
No comments:
Post a Comment