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.AdminMenuLegacyITBase;
19 import edu.samplu.common.ITUtil;
20 import org.junit.Rule;
21 import org.junit.Test;
22 import org.junit.rules.TemporaryFolder;
23 import org.openqa.selenium.By;
24
25 import java.io.File;
26 import java.io.FileWriter;
27
28
29
30
31
32
33 public class XMLIngesterLegacyIT extends AdminMenuLegacyITBase {
34
35 private File loadUsersFile;
36
37 @Rule
38 public TemporaryFolder folder= new TemporaryFolder();
39
40 @Override
41 protected String getLinkLocator() {
42 return "XML Ingester";
43 }
44
45 @Override
46 public String getUserName() {
47 return "admin";
48 }
49
50 @Override
51 public void setUp() throws Exception {
52 super.setUp();
53
54 generateLoadUsersFile(10, ITUtil.DTS);
55 }
56
57
58
59
60
61
62
63
64 private void generateLoadUsersFile(int numberOfUsers, String prefix) throws Exception {
65 loadUsersFile = folder.newFile("loadtest-users.xml");
66 java.util.Date date= new java.util.Date();
67
68 FileWriter writer = new FileWriter(loadUsersFile);
69 writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
70 writer.write("<data xmlns=\"ns:workflow\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"ns:workflow resource:WorkflowData\">\n");
71 writer.write("\t<users xmlns=\"ns:workflow/User\" xsi:schemaLocation=\"ns:workflow/User resource:User\">\n");
72 for(int i = 0; i < numberOfUsers; i++) {
73 StringBuffer stringBuffer = new StringBuffer();
74 stringBuffer.append("\t\t<user><principalId>lt" + prefix + i + "</principalId>");
75 stringBuffer.append("<emplId>lt" + prefix + i + "emplid</emplId>");
76 stringBuffer.append("<principalName>loadtester" + prefix + i + "</principalName>");
77 stringBuffer.append("<givenName>Tester</givenName>");
78 stringBuffer.append("<lastName>McLoady" + prefix + i + "</lastName>");
79 stringBuffer.append("<emailAddress>loadtester" + prefix + i + "@kuali.org</emailAddress>");
80 stringBuffer.append("</user>\n");
81 writer.write(stringBuffer.toString());
82 }
83 writer.write("\t</users>\n</data>\n");
84 writer.close();
85 }
86
87 @Test
88 public void testXMLIngesterUpload() throws Exception {
89 gotoMenuLinkLocator();
90 String path = loadUsersFile.getAbsolutePath().toString();
91 driver.findElement(By.name("file[0]")).sendKeys(path);
92 waitAndClickByXpath("//*[@id='imageField']");
93 assertTextPresent("Ingested xml doc");
94 passed();
95 }
96
97 }