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.Ignore;
21 import org.junit.Rule;
22 import org.junit.Test;
23 import org.junit.rules.TemporaryFolder;
24 import org.openqa.selenium.By;
25
26 import java.io.File;
27 import java.io.FileWriter;
28 import java.util.ArrayList;
29 import java.util.List;
30
31
32
33
34
35
36 public class XMLIngesterLegacyIT extends AdminMenuLegacyITBase {
37
38
39 private List<File> fileUploadList;
40 private int userCnt = Integer.valueOf(System.getProperty("test.xmlingester.user.cnt", "10"));
41 private String userPrefix = System.getProperty("test.xmlingester.user.prefix", ITUtil.DTS);
42
43 private String groupId = System.getProperty("test.xmlingester.grp.id", "2203");
44 private String groupNamespace = System.getProperty("test.xmlingester.grp.namespace","KUALI");
45 private String groupName = System.getProperty("test.xmlingester.grp.name", "eDoc.Example1.IUPUI.Workgroup");
46 private String groupDesc = System.getProperty("test.xmlingester.grp.desc", "Edoclite Documentation workgroup");
47
48 @Rule
49 public TemporaryFolder folder= new TemporaryFolder();
50
51 @Ignore
52 @Override
53 public void testCreateNewCancel() throws Exception {}
54
55 @Ignore
56 @Override
57 public void testEditCancel() throws Exception {}
58
59
60 @Override
61 protected String getLinkLocator() {
62 return "XML Ingester";
63 }
64
65 @Override
66 public String getUserName() {
67 return "admin";
68 }
69
70 @Override
71 public void setUp() throws Exception {
72 super.setUp();
73
74 buildFileUploadList();
75
76 }
77
78 private void buildFileUploadList() throws Exception {
79 fileUploadList = new ArrayList<File>();
80 fileUploadList.add(generateLoadUsersFile(userCnt, userPrefix));
81 fileUploadList.add(generateLoadGroupFile(userCnt, userPrefix));
82 }
83
84
85
86
87
88
89
90
91 private File generateLoadUsersFile(int numberOfUsers, String prefix) throws Exception {
92 File loadUsersFile = folder.newFile("loadtest-users.xml");
93
94 java.util.Date date= new java.util.Date();
95
96 FileWriter writer = new FileWriter(loadUsersFile);
97 writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
98 writer.write("<data xmlns=\"ns:workflow\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"ns:workflow resource:WorkflowData\">\n");
99 writer.write("\t<users xmlns=\"ns:workflow/User\" xsi:schemaLocation=\"ns:workflow/User resource:User\">\n");
100 for(int i = 0; i < numberOfUsers; i++) {
101 StringBuffer stringBuffer = new StringBuffer();
102 stringBuffer.append("\t\t<user><principalId>lt" + prefix + i + "</principalId>");
103 stringBuffer.append("<emplId>lt" + prefix + i + "emplid</emplId>");
104 stringBuffer.append("<principalName>loadtester" + prefix + i + "</principalName>");
105 stringBuffer.append("<givenName>Tester</givenName>");
106 stringBuffer.append("<lastName>McLoady" + prefix + i + "</lastName>");
107 stringBuffer.append("<emailAddress>loadtester" + prefix + i + "@kuali.org</emailAddress>");
108 stringBuffer.append("</user>\n");
109 writer.write(stringBuffer.toString());
110 }
111 writer.write("\t</users>\n</data>\n");
112 writer.close();
113 return loadUsersFile;
114 }
115
116
117
118
119
120
121
122
123
124
125 private File generateLoadGroupFile(int numberOfUsers, String prefix) throws Exception {
126 File loadGroupFile = folder.newFile("loadtest-group.xml");
127
128 FileWriter writer = new FileWriter(loadGroupFile);
129 writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
130 writer.write("<data xmlns=\"ns:workflow\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"ns:workflow resource:WorkflowData\">\n");
131 writer.write("\t<groups xmlns=\"ns:workflow/Group\" xsi:schemaLocation=\"ns:workflow/Group resource:Group\">\n");
132 writer.write("\t\t<group><id>" + groupId + "</id><namespace>" + groupNamespace + "</namespace><description>" + groupDesc + "</description>");
133 writer.write("<name>" + groupName + "</name>");
134 writer.write("<members>");
135 writer.write("<principalName>admin</principalName>");
136 writer.write("<principalName>notsys</principalName>");
137 for(int i = 0; i < numberOfUsers; i++) {
138 StringBuffer stringBuffer = new StringBuffer();
139 stringBuffer.append("<principalName>loadtester" + prefix + i + "</principalName>");
140 writer.write(stringBuffer.toString());
141 }
142 writer.write("\t\t</members>\n\t</group>\n</groups>\n</data>\n");
143 writer.close();
144 return loadGroupFile;
145 }
146
147
148
149
150
151
152 @Test
153 public void testXMLIngesterSuccessfulFileUpload() throws Exception {
154 gotoMenuLinkLocator();
155 int cnt = 0;
156 for(File file : fileUploadList) {
157 String path = file.getAbsolutePath().toString();
158 driver.findElement(By.name("file[" + cnt + "]")).sendKeys(path);
159 cnt++;
160 }
161 waitAndClickByXpath("//*[@id='imageField']");
162
163
164 for(File file: fileUploadList) {
165 assertTextPresent("Ingested xml doc: " + file.getName());
166 }
167 passed();
168 }
169
170 }