Пример #1
0
  private Template setupTemplate(
      ResourceLoader loader,
      RuntimeInstance runtimeServices,
      String templateName,
      InputStream templateContents) {
    try {
      Template template = new Template();
      template.setRuntimeServices(runtimeServices);
      template.setResourceLoader(loader);
      template.setName(templateName);

      when(loader.getResourceStream(templateName)).thenReturn(templateContents);
      doReturn(template).when(runtimeServices).getTemplate(templateName);
      doReturn(template)
          .when(runtimeServices)
          .getTemplate(eq(templateName), Matchers.<String>any());

      return template;
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
 @Override
 public void commonInit(RuntimeServices rs, ExtendedProperties configuration) {
   super.commonInit(rs, configuration);
   this.templateEngine = (ITemplateEngine) rs.getProperty(VELOCITY_TEMPLATE_ENGINE_KEY);
 }