use of com.googlecode.gwt.test.patchers.InitMethod in project gwt-test-utils by gwt-test-utils.
the class AutomaticPatcher method initClass.
public void initClass(CtClass c) throws Exception {
if (initMethod == null) {
return;
}
Class<?> clazz = GwtReflectionUtils.getClass(initMethod.getDeclaringClass().getName());
Method compiledMethod = clazz.getDeclaredMethod(initMethod.getName(), CtClass.class);
// TODO : this should not be mandatory since AutomaticPatcher set every
// initMethod to public when loaded by GwtClassLoader
GwtReflectionUtils.makeAccessible(compiledMethod);
try {
compiledMethod.invoke(null, c);
} catch (InvocationTargetException e) {
if (Exception.class.isInstance(e)) {
throw (Exception) e.getCause();
} else {
throw e;
}
}
}
use of com.googlecode.gwt.test.patchers.InitMethod in project gwt-test-utils by gwt-test-utils.
the class AbstractRemoteServiceServletPatcher method addMockedGetServletConfigMethod.
@InitMethod
static void addMockedGetServletConfigMethod(CtClass c) throws CannotCompileException {
StringBuilder sb = new StringBuilder();
sb.append("public javax.servlet.ServletConfig getServletConfig() { return ");
sb.append(AbstractRemoteServiceServletPatcher.class.getName()).append(".ensureServletMockProvider(this, \"getServletConfig()\").getMockedConfig(this); }");
CtMethod m = CtMethod.make(sb.toString(), c);
c.addMethod(m);
}
use of com.googlecode.gwt.test.patchers.InitMethod in project gwt-test-utils by gwt-test-utils.
the class ValueBoxBasePatcher method initClass.
@InitMethod
static void initClass(CtClass c) throws CannotCompileException {
CtConstructor cons = JavassistUtils.findConstructor(c, Element.class, Renderer.class, Parser.class);
cons.insertAfter("setText(\"\");");
}
use of com.googlecode.gwt.test.patchers.InitMethod in project gwt-test-utils by gwt-test-utils.
the class GwtPatcher method init.
@InitMethod
static void init(CtClass ctClass) throws CannotCompileException {
CtConstructor staticInitializer = ctClass.makeClassInitializer();
staticInitializer.insertAfter("setBridge(" + GwtTestGWTBridge.class.getName() + ".get());");
}
use of com.googlecode.gwt.test.patchers.InitMethod in project gwt-test-utils by gwt-test-utils.
the class ListWrapperPatcher method initClass.
@InitMethod
static void initClass(CtClass c) throws CannotCompileException, NotFoundException {
CtMethod flushMethod = c.getDeclaredMethod("flush");
flushMethod.insertAfter(BrowserSimulatorImpl.class.getName() + ".get().fireLoopEnd();");
}
Aggregations