@Test
 @SuppressWarnings("rawtypes")
 public void testTemplateProcessorJavaBean() throws Exception {
   String template = "Hello ${name}!";
   String expected = "Hello JBoss Forge!";
   File tempFile = File.createTempFile("template", ".tmp");
   tempFile.deleteOnExit();
   FileResource resource = resourceFactory.create(tempFile).reify(FileResource.class);
   resource.setContents(template);
   TemplateProcessor processor =
       templateProcessorFactory.fromTemplate(new FreemarkerTemplate(resource));
   JavaBean dataModel = new JavaBean();
   dataModel.setName("JBoss Forge");
   String actual = processor.process(dataModel);
   Assert.assertEquals(expected, actual);
 }
Example #2
0
 public static JavaBean newInstance(String s, String pack) throws Exception {
   Builder b = (Builder) JavaBean.parseBeanExtended(s, Builder.class);
   b.setBuilderClassName(b.getClassName() + "Builder");
   b.setPack(pack);
   return b;
 }