public class MethodDatabaseUtilTest {
@Test
public void testLoad() throws IOException {
MethodDatabase db = new MethodDatabase(Thread.currentThread().getContextClassLoader());
MethodDatabaseUtil.load(db, "nginx/clojure/wave/test-coroutine-method-db.txt");
ClassEntry ce = db.getClasses().get("java/lang/Thread");
assertEquals(MethodDatabase.SUSPEND_BLOCKING, ce.check("sleep", "(J)V"));
assertEquals(MethodDatabase.SUSPEND_BLOCKING, ce.check("sleep", "(JI)V"));
assertEquals(MethodDatabase.SUSPEND_BLOCKING, ce.check("join", "()V"));
ce = db.getClasses().get("java/lang/Object");
assertEquals(MethodDatabase.SUSPEND_BLOCKING, ce.check("wait", "(J)V"));
assertEquals(MethodDatabase.SUSPEND_BLOCKING, ce.check("wait", "()V"));
assertEquals(MethodDatabase.SUSPEND_BLOCKING, ce.check("wait", "(JI)V"));
assertNull(ce.check("test-unknown-method", "()V"));
ce = db.getClasses().get("clojure/lang/IFn");
assertEquals(MethodDatabase.SUSPEND_FAMILY, ce.check("invoke", "()Ljava/lang/Object;"));
ClassEntry mce = MethodDatabaseUtil.buildClassEntryFamily(db, Type.getInternalName(MyAF.class));
assertEquals(MethodDatabase.SUSPEND_FAMILY, db.checkMethodSuspendType(Type.getInternalName(MyAF.class), "invoke()Ljava/lang/Object;", true));
}