use of freemarker.ext.beans.BeansWrapper in project zm-mailbox by Zimbra.
the class SoapApiChangeLog method writeChangelog.
private void writeChangelog() throws IOException, TemplateException {
File templateDirFile = new File(templateDir, CHANGELOG_TEMPLATE_SUBDIR);
Configuration config = new Configuration();
config.setDirectoryForTemplateLoading(templateDirFile);
config.setObjectWrapper(new BeansWrapper());
fmTemplate = config.getTemplate(TEMPLATE_FILE);
File of = new File(outputDir, OUTPUT_FILE);
FileWriter out = new FileWriter(of);
try {
fmTemplate.process(changelogDataModel, out);
} finally {
try {
out.close();
} catch (Exception e) {
// worst case scenario...clean-up quietly
}
}
}
use of freemarker.ext.beans.BeansWrapper in project ninja by ninjaframework.
the class TemplateEngineFreemarkerI18nMethodTest method testThatConstraintViolationWorksWithDefault.
@Test
public void testThatConstraintViolationWorksWithDefault() throws Exception {
Optional<Result> resultOptional = Optional.of(result);
Mockito.when(messages.get(IsInteger.KEY, context, resultOptional)).thenReturn(Optional.empty());
ConstraintViolation violation = new ConstraintViolation(IsInteger.KEY, "theField", IsInteger.MESSAGE);
List args = new ArrayList();
args.add(new StringModel(violation, new BeansWrapper()));
TemplateModel returnValue = templateEngineFreemarkerI18nMethod.exec(args);
assertThat(((SimpleScalar) returnValue).getAsString(), CoreMatchers.equalTo("theField must be an integer"));
Mockito.verify(mockAppender, Mockito.never()).doAppend(Matchers.anyObject());
}
use of freemarker.ext.beans.BeansWrapper in project ninja by ninjaframework.
the class TemplateEngineFreemarkerI18nMethodTest method testThatConstraintViolationWorks.
@Test
public void testThatConstraintViolationWorks() throws Exception {
Optional<Result> resultOptional = Optional.of(result);
Mockito.when(messages.get(IsInteger.KEY, context, resultOptional)).thenReturn(Optional.of("This simulates the translated message!"));
ConstraintViolation violation = new ConstraintViolation(IsInteger.KEY, "theField", IsInteger.MESSAGE);
List args = new ArrayList();
args.add(new StringModel(violation, new BeansWrapper()));
TemplateModel returnValue = templateEngineFreemarkerI18nMethod.exec(args);
assertThat(((SimpleScalar) returnValue).getAsString(), CoreMatchers.equalTo("This simulates the translated message!"));
Mockito.verify(mockAppender, Mockito.never()).doAppend(Matchers.anyObject());
}
use of freemarker.ext.beans.BeansWrapper in project head by mifos.
the class DateFormatterTest method getFormatterArgs.
private List<Object> getFormatterArgs(Object date, Locale locale) throws TemplateModelException {
BeansWrapper wrapper = BeansWrapper.getDefaultInstance();
List<Object> args = new ArrayList<Object>();
args.add(wrapper.wrap(date));
args.add(wrapper.wrap("MMMM"));
args.add(wrapper.wrap(locale));
return args;
}
Aggregations