@Test public void testProcessTemplate() throws Exception { Credentials credentials = new Credentials("dummy", "dummy"); Cluster.Instance instance = new Cluster.Instance(credentials, Sets.newHashSet("foo"), "127.0.0.1", "127.0.0.1", "id-0", null); ClusterSpec clusterSpec = ClusterSpec.withTemporaryKeys(new PropertiesConfiguration("whirr-core-test.properties")); Cluster cluster = new Cluster(Sets.newHashSet(instance)); VelocityEngine ve = TemplateUtils.newVelocityEngine(); String result = TemplateUtils.processTemplate(ve, "template-test.txt.vm", clusterSpec, cluster); Assert.assertEquals("instance ip: 127.0.0.1", result); }
public static String processTemplate(VelocityEngine engine, String templateName, ClusterSpec clusterSpec, Cluster cluster) { VelocityContext context = new VelocityContext(); context.put("clusterSpec", clusterSpec); context.put("cluster", cluster); context.put("RolePredicates", RolePredicates.class); Template template = engine.getTemplate(templateName); StringWriter writer = new StringWriter(); template.merge(context, writer); return writer.toString(); }
TemplateUtils { public static String processTemplate(VelocityEngine engine, String templateName, ClusterSpec clusterSpec, Cluster cluster) { VelocityContext context = new VelocityContext(); context.put("clusterSpec", clusterSpec); context.put("cluster", cluster); context.put("RolePredicates", RolePredicates.class); Template template = engine.getTemplate(templateName); StringWriter writer = new StringWriter(); template.merge(context, writer); return writer.toString(); } }
TemplateUtils { public static String processTemplate(VelocityEngine engine, String templateName, ClusterSpec clusterSpec, Cluster cluster) { VelocityContext context = new VelocityContext(); context.put("clusterSpec", clusterSpec); context.put("cluster", cluster); context.put("RolePredicates", RolePredicates.class); Template template = engine.getTemplate(templateName); StringWriter writer = new StringWriter(); template.merge(context, writer); return writer.toString(); }  }
TemplateUtils { public static String processTemplate(VelocityEngine engine, String templateName, ClusterSpec clusterSpec, Cluster cluster) { VelocityContext context = new VelocityContext(); context.put("clusterSpec", clusterSpec); context.put("cluster", cluster); context.put("RolePredicates", RolePredicates.class); Template template = engine.getTemplate(templateName); StringWriter writer = new StringWriter(); template.merge(context, writer); return writer.toString(); }  static Statement createFileFromTemplate(String path, VelocityEngine engine, String templateName, ClusterSpec clusterSpec, Cluster cluster); static String processTemplate(VelocityEngine engine, String templateName, ClusterSpec clusterSpec, Cluster cluster); static VelocityEngine newVelocityEngine(); static VelocityEngine newVelocityEngine(Properties properties); }
TemplateUtils { public static String processTemplate(VelocityEngine engine, String templateName, ClusterSpec clusterSpec, Cluster cluster) { VelocityContext context = new VelocityContext(); context.put("clusterSpec", clusterSpec); context.put("cluster", cluster); context.put("RolePredicates", RolePredicates.class); Template template = engine.getTemplate(templateName); StringWriter writer = new StringWriter(); template.merge(context, writer); return writer.toString(); }  static Statement createFileFromTemplate(String path, VelocityEngine engine, String templateName, ClusterSpec clusterSpec, Cluster cluster); static String processTemplate(VelocityEngine engine, String templateName, ClusterSpec clusterSpec, Cluster cluster); static VelocityEngine newVelocityEngine(); static VelocityEngine newVelocityEngine(Properties properties);  }