add traceMethods method

This commit is contained in:
Doug MacEachern 2007-07-26 07:14:18 +00:00
parent 103440f8c0
commit 9cb4fdb0e5
1 changed files with 14 additions and 1 deletions

View File

@ -22,7 +22,7 @@ import java.io.PrintStream;
import java.io.IOException; import java.io.IOException;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.lang.reflect.Method;
import java.util.Properties; import java.util.Properties;
import junit.framework.TestCase; import junit.framework.TestCase;
@ -156,4 +156,17 @@ public abstract class SigarTestCase extends TestCase {
traceln(msg + "=" + actual + "/" + expected); traceln(msg + "=" + actual + "/" + expected);
assertEquals(msg, expected, actual); assertEquals(msg, expected, actual);
} }
public void traceMethods(Object obj) throws Exception {
Class cls = obj.getClass();
Method[] methods = cls.getDeclaredMethods();
traceln("");
for (int i=0; i<methods.length; i++) {
String name = methods[i].getName();
if (!name.startsWith("get")) {
continue;
}
traceln(name + "=" + methods[i].invoke(obj, new Object[0]));
}
}
} }