1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package edu.samplu.admin.test;
17
18 import edu.samplu.common.Failable;
19 import edu.samplu.common.FreemarkerSTBase;
20 import edu.samplu.common.ITUtil;
21 import org.openqa.selenium.By;
22
23 import java.io.File;
24 import java.io.IOException;
25 import java.util.ArrayList;
26 import java.util.List;
27 import java.util.Properties;
28
29
30
31
32
33
34
35 public abstract class XMLIngesterAbstractSmokeTestBase extends FreemarkerSTBase {
36
37
38
39
40 public static final String BOOKMARK_URL = ITUtil.PORTAL + "?channelTitle=XML%20Ingester&channelUrl="
41 + ITUtil.getBaseUrlString() + "/kew/../core/Ingester.do";
42
43
44 private String PROPS_LOCATION = System.getProperty("xmlingester.props.location", null);
45 private static final String DEFAULT_PROPS_LOCATION = "XML/xmlingester.properties";
46
47
48 private static final String DIR_TMPL = "/XML/";
49 private static final String TMPL_USER_CONTENT = "SimpleUserContent.ftl";
50 private static final String TMPL_GROUP_CONTENT = "SimpleGroupContent.ftl";
51
52
53
54
55
56
57
58 protected abstract File newTempFile(String name) throws IOException;
59
60
61
62
63
64
65 @Override
66 protected String getTemplateDir() {
67 return DIR_TMPL;
68 }
69
70
71
72
73
74
75 @Override
76 public String getTestUrl() {
77 return ITUtil.PORTAL;
78 }
79
80
81
82
83
84
85 @Override
86 public String getUserName() {
87 return "admin";
88 }
89
90
91
92
93 protected void navigate(Failable failable) throws Exception {
94 selectTopFrame();
95 waitAndClickAdministration(failable);
96 waitForTitleToEqualKualiPortalIndex();
97 waitAndClickXMLIngester(failable);
98 selectFrameIframePortlet();
99 checkForIncidentReport("XML Ingester", failable, "");
100 }
101
102
103
104
105
106
107
108 protected void testIngestionNav(Failable failable) throws Exception {
109 navigate(failable);
110 testIngestion(failable);
111 passed();
112 }
113
114 protected void testIngestionBookmark(Failable failable) throws Exception {
115 testIngestion(failable);
116 passed();
117 }
118
119
120
121
122
123
124
125
126 protected void testIngestion(Failable failable) throws Exception {
127 selectFrameIframePortlet();
128 List<File> fileUploadList = buildFileUploadList();
129 int cnt = 0;
130
131 for(File file : fileUploadList) {
132 String path = file.getAbsolutePath().toString();
133 if (isKrad()){
134 driver.findElement(By.name("files[" + cnt + "]")).sendKeys(path);
135 } else {
136 driver.findElement(By.name("file[" + cnt + "]")).sendKeys(path);
137 }
138 cnt++;
139 }
140
141
142 if (isKrad()){
143 waitAndClickByXpath("//button");
144 } else {
145 waitAndClickByXpath("//*[@id='imageField']");
146 }
147
148
149 Thread.sleep(1000);
150 for(File file: fileUploadList) {
151 assertTextPresent("Ingested xml doc: " + file.getName());
152 }
153 }
154
155 protected List<File> buildFileUploadList() throws Exception {
156 List<File> fileUploadList = new ArrayList<File>();
157 try {
158
159 Properties props = loadProperties(PROPS_LOCATION, DEFAULT_PROPS_LOCATION);
160 if(props.get("userIncludeDTSinPrefix") != null
161 && "true".equalsIgnoreCase((String) props.get("userIncludeDTSinPrefix"))) {
162 props.setProperty("userPrefix", "" + props.get("userPrefix") + ITUtil.DTS);
163 }
164 systemPropertiesOverride(props, "XMLIngester");
165
166
167 fileUploadList.add(
168 writeTemplateToFile(newTempFile("loadtest-users.xml"), cfg.getTemplate(TMPL_USER_CONTENT), props));
169 fileUploadList.add(
170 writeTemplateToFile(newTempFile("loadtest-group.xml"), cfg.getTemplate(TMPL_GROUP_CONTENT), props));
171 } catch( Exception e) {
172 throw new Exception("Unable to generate files for upload", e);
173 }
174
175 return fileUploadList;
176 }
177 }