1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package edu.samplu.common;
17
18 import java.io.File;
19 import java.util.Properties;
20
21 import org.junit.Test;
22
23 import freemarker.cache.ClassTemplateLoader;
24 import freemarker.template.Configuration;
25
26
27
28
29
30 public class NeustarJSTemplate extends FreemarkerSTBase {
31
32
33
34
35
36
37 @Override
38 public String getTestUrl() {
39 return null;
40 }
41
42
43 private String PROPS_LOCATION = System.getProperty("neustarJS.props.location", null);
44 private String DEFAULT_PROPS_LOCATION = "NeustarJSTemplate/neustarJS.properties";
45
46
47 private static final String DIR_TMPL = "/NeustarJSTemplate/";
48 private static final String TMPL_CONTENT = "CreateNewTmpl.ftl";
49
50 private void buildFileList(Properties props) throws Exception {
51 Integer pageCount= Integer.parseInt(props.getProperty("pageCount"));
52
53 for(int count=1; count<= pageCount;count++ ){
54 try {
55 String subTitle= props.getProperty("page"+count);
56 props.setProperty("pageId",""+ props.get("page")+count);
57
58
59 props.setProperty("viewId",""+ props.get("view"));
60 File f1= new File("Temp" + File.separatorChar + "Env11 Kitchen Sink "+subTitle +" KRAD WebDriver.txt");
61 writeTemplateToFile(f1, cfg.getTemplate(TMPL_CONTENT), props);
62
63
64 props.setProperty("viewId",""+ props.get("view")+"_KNS");
65 File f2= new File("Temp" + File.separatorChar + "Env11 Kitchen Sink "+subTitle +" KNS WebDriver.txt");
66 writeTemplateToFile(f2, cfg.getTemplate(TMPL_CONTENT), props);
67
68 } catch( Exception e) {
69 throw new Exception("Unable to generate files for upload", e);
70 }
71 }
72 }
73
74
75
76
77
78
79 @Override
80 protected String getTemplateDir() {
81 return DIR_TMPL;
82 }
83
84 @Test
85 public void testNeustarTemplating() throws Exception {
86
87 Properties props = loadProperties(PROPS_LOCATION, DEFAULT_PROPS_LOCATION);
88 systemPropertiesOverride(props, "NeustarJS");
89
90 buildFileList(props);
91
92 }
93 }