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