Configuration cfg = new Configuration();
cfg.setObjectWrapper(ObjectWrapper.DEFAULT_WRAPPER);
XTemplate xTemplate = method.getAnnotation(XTemplate.class);
if (xTemplate == null) {
throw new GwtTestException(
"gwt-test-utils expects to find a @XTemplate annotation on method "
+ method.toString());
}
String templateName = method.toGenericString();
if (xTemplate.source().length() > 0) {
InputStream in = method.getDeclaringClass().getResourceAsStream(
xTemplate.source());
if (in == null) {
throw new GwtTestException("Cannot find file @Template source file "
+ xTemplate.source() + " declared for method " + method);
}
BufferedReader br = new BufferedReader(new InputStreamReader(in));
try {
return new Template(templateName, br, cfg);
} catch (IOException e) {
throw new GwtTestException(
"Error while trying to get template for method " + method);
}
} else {
return Template.getPlainTextTemplate(templateName, xTemplate.value(),
cfg);