From 06945a8e31fab05c562a3922d6a4aa3a7730796a Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Sat, 18 Oct 2008 23:37:21 +0000 Subject: [PATCH] test SigarProcessMBean --- .../java/src/org/hyperic/sigar/cmd/Mx.java | 3 +++ .../src/org/hyperic/sigar/test/TestMx.java | 24 +++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/bindings/java/src/org/hyperic/sigar/cmd/Mx.java b/bindings/java/src/org/hyperic/sigar/cmd/Mx.java index 1bc2a3d9..78e0dafb 100644 --- a/bindings/java/src/org/hyperic/sigar/cmd/Mx.java +++ b/bindings/java/src/org/hyperic/sigar/cmd/Mx.java @@ -28,6 +28,7 @@ import javax.management.MBeanServerFactory; import javax.management.ObjectName; import org.hyperic.sigar.SigarException; +import org.hyperic.sigar.jmx.SigarProcess; import org.hyperic.sigar.jmx.SigarRegistry; public class Mx extends SigarCommandBase { @@ -70,6 +71,8 @@ public class Mx extends SigarCommandBase { SigarRegistry registry = new SigarRegistry(); try { server.registerMBean(registry, null); + SigarProcess proc = new SigarProcess(); + server.registerMBean(proc, new ObjectName(proc.getObjectName())); isRegistered = true; } catch (Exception e) { throw new SigarException(e.getMessage()); diff --git a/bindings/java/src/org/hyperic/sigar/test/TestMx.java b/bindings/java/src/org/hyperic/sigar/test/TestMx.java index 4340dbbc..7efa83f5 100644 --- a/bindings/java/src/org/hyperic/sigar/test/TestMx.java +++ b/bindings/java/src/org/hyperic/sigar/test/TestMx.java @@ -28,6 +28,7 @@ import javax.management.ObjectName; import org.hyperic.sigar.SigarException; import org.hyperic.sigar.cmd.Mx; +import org.hyperic.sigar.jmx.SigarProcess; import org.hyperic.sigar.jmx.SigarRegistry; public class TestMx extends SigarTestCase { @@ -45,6 +46,19 @@ public class TestMx extends SigarTestCase { } } + private void _testProcess(MBeanServer server) throws Exception { + long[] pids = getSigar().getProcList(); + for (int i=0; i