test bogus queries too

This commit is contained in:
Doug MacEachern 2004-06-22 02:27:51 +00:00
parent 18c8735ce3
commit fc5bf90b3c
1 changed files with 29 additions and 2 deletions

View File

@ -1,6 +1,7 @@
package net.hyperic.sigar.test; package net.hyperic.sigar.test;
import net.hyperic.sigar.Sigar; import net.hyperic.sigar.Sigar;
import net.hyperic.sigar.SigarException;
import net.hyperic.sigar.SigarLoader; import net.hyperic.sigar.SigarLoader;
import net.hyperic.sigar.SigarProxy; import net.hyperic.sigar.SigarProxy;
import net.hyperic.sigar.SigarProxyCache; import net.hyperic.sigar.SigarProxyCache;
@ -28,6 +29,14 @@ public class TestInvoker extends SigarTestCase {
{ "sigar:Type=CpuPercList,Arg=0", "Idle" }, { "sigar:Type=CpuPercList,Arg=0", "Idle" },
}; };
private static final String[][] BROKEN_QUERIES = {
{ "sigar:Type=BREAK", "Free" },
{ "sigar:Type=Mem", "BREAK" },
{ "sigar:Type=ProcTime,Arg=BREAK", "Stime" },
{ "sigar:Type=CpuPercList,Arg=1000", "Idle" },
{ "sigar:Type=CpuPercList,Arg=BREAK", "Idle" },
};
public TestInvoker(String name) { public TestInvoker(String name) {
super(name); super(name);
} }
@ -56,8 +65,26 @@ public class TestInvoker extends SigarTestCase {
*/ */
continue; continue;
} }
try {
Object o = invoker.invoke(query[1]); Object o = invoker.invoke(query[1]);
traceln(query[0] + ":" + query[1] + "=" + o); traceln(query[0] + ":" + query[1] + "=" + o);
assertTrue(true);
} catch (SigarException e) {
assertTrue(false);
}
}
for (int i=0; i<BROKEN_QUERIES.length; i++) {
String[] query = BROKEN_QUERIES[i];
SigarInvokerJMX invoker =
SigarInvokerJMX.getInstance(proxy, query[0]);
try {
Object o = invoker.invoke(query[1]);
assertTrue(false);
} catch (SigarException e) {
traceln(query[0] + ":" + query[1] + "=" + e.getMessage());
assertTrue(true);
}
} }
} }
} }