}
/** @since 1.1 */
public void testToString() throws Exception
{
ClassFab cf = newClassFab("FredRunnable", BaseLocatable.class);
cf.addInterface(Runnable.class);
cf.addInterface(Serializable.class);
cf.addField("_map", Map.class);
cf.addConstructor(new Class[]
{ Map.class, Runnable.class }, new Class[]
{ IllegalArgumentException.class, DataFormatException.class }, "{ _map = $1; }");
MethodSignature sig = new MethodSignature(Map.class, "doTheNasty", new Class[]
{ int.class, String.class }, new Class[]
{ InstantiationException.class, IllegalAccessException.class });
MethodFab mf = cf.addMethod(
Modifier.PUBLIC + Modifier.FINAL + Modifier.SYNCHRONIZED,
sig,
"{ return _map; }");
mf.addCatch(NullPointerException.class, "return null;");
mf.extend("_map.clear();", true);
String toString = cf.toString();
contains(
toString,
"public class FredRunnable extends org.apache.hivemind.impl.BaseLocatable\n"
+ " implements java.lang.Runnable, java.io.Serializable");