1 |
2263
|
sgarg
|
/**
|
2 |
|
|
* '$RCSfile$'
|
3 |
|
|
* Copyright: 2004 Regents of the University of California and the
|
4 |
|
|
* National Center for Ecological Analysis and Synthesis
|
5 |
|
|
* Purpose: To test the Access Controls in metacat by JUnit
|
6 |
|
|
*
|
7 |
|
|
* '$Author$'
|
8 |
|
|
* '$Date$'
|
9 |
|
|
* '$Revision$'
|
10 |
|
|
*
|
11 |
|
|
* This program is free software; you can redistribute it and/or modify
|
12 |
|
|
* it under the terms of the GNU General Public License as published by
|
13 |
|
|
* the Free Software Foundation; either version 2 of the License, or
|
14 |
|
|
* (at your option) any later version.
|
15 |
|
|
*
|
16 |
|
|
* This program is distributed in the hope that it will be useful,
|
17 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
19 |
|
|
* GNU General Public License for more details.
|
20 |
|
|
*
|
21 |
|
|
* You should have received a copy of the GNU General Public License
|
22 |
|
|
* along with this program; if not, write to the Free Software
|
23 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
24 |
|
|
*/
|
25 |
|
|
|
26 |
|
|
package edu.ucsb.nceas.metacattest;
|
27 |
|
|
|
28 |
|
|
import java.io.Reader;
|
29 |
|
|
import java.io.StringReader;
|
30 |
|
|
import java.util.Calendar;
|
31 |
|
|
import java.util.Date;
|
32 |
|
|
import java.util.GregorianCalendar;
|
33 |
|
|
import java.util.SimpleTimeZone;
|
34 |
|
|
import java.util.TimeZone;
|
35 |
|
|
|
36 |
4145
|
daigle
|
import edu.ucsb.nceas.MCTestCase;
|
37 |
2263
|
sgarg
|
import edu.ucsb.nceas.metacat.client.InsufficientKarmaException;
|
38 |
|
|
import edu.ucsb.nceas.metacat.client.Metacat;
|
39 |
|
|
import edu.ucsb.nceas.metacat.client.MetacatAuthException;
|
40 |
|
|
import edu.ucsb.nceas.metacat.client.MetacatException;
|
41 |
|
|
import edu.ucsb.nceas.metacat.client.MetacatFactory;
|
42 |
|
|
import edu.ucsb.nceas.metacat.client.MetacatInaccessibleException;
|
43 |
4080
|
daigle
|
import edu.ucsb.nceas.metacat.service.PropertyService;
|
44 |
2263
|
sgarg
|
import edu.ucsb.nceas.utilities.IOUtil;
|
45 |
4080
|
daigle
|
import edu.ucsb.nceas.utilities.PropertyNotFoundException;
|
46 |
2263
|
sgarg
|
import junit.framework.Test;
|
47 |
|
|
import junit.framework.TestSuite;
|
48 |
|
|
|
49 |
|
|
/**
|
50 |
|
|
* A JUnit test for testing Access Control for Inline data in Metacat
|
51 |
|
|
*/
|
52 |
4080
|
daigle
|
public class InlineDataAccessTest
|
53 |
4145
|
daigle
|
extends MCTestCase {
|
54 |
4080
|
daigle
|
|
55 |
|
|
private static String metacatUrl;
|
56 |
|
|
private static String username;
|
57 |
|
|
private static String password;
|
58 |
|
|
private static String anotheruser;
|
59 |
|
|
private static String anotherpassword;
|
60 |
|
|
static {
|
61 |
|
|
try {
|
62 |
4231
|
daigle
|
metacatUrl = PropertyService.getProperty("test.metacatUrl");
|
63 |
|
|
username = PropertyService.getProperty("test.mcUser");
|
64 |
|
|
password = PropertyService.getProperty("test.mcPassword");
|
65 |
|
|
anotheruser = PropertyService.getProperty("test.mcAnotherUser");
|
66 |
|
|
anotherpassword = PropertyService.getProperty("test.mcAnotherPassword");
|
67 |
4080
|
daigle
|
} catch (PropertyNotFoundException pnfe) {
|
68 |
|
|
System.err.println("Could not get property in static block: "
|
69 |
|
|
+ pnfe.getMessage());
|
70 |
|
|
}
|
71 |
|
|
}
|
72 |
|
|
|
73 |
2263
|
sgarg
|
private String prefix = "test";
|
74 |
|
|
private String newdocid = null;
|
75 |
|
|
private String testdocument = "";
|
76 |
|
|
|
77 |
|
|
private Metacat m;
|
78 |
|
|
|
79 |
4477
|
daigle
|
private String testEml_200_Header =
|
80 |
2263
|
sgarg
|
"<?xml version=\"1.0\"?><eml:eml" +
|
81 |
4477
|
daigle
|
" xmlns:eml=\"eml://ecoinformatics.org/eml-2.0.0\"" +
|
82 |
|
|
" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
|
83 |
|
|
" packageId=\"eml.1.1\" system=\"knb\"" +
|
84 |
|
|
" xsi:schemaLocation=\"eml://ecoinformatics.org/eml-2.0.0 eml.xsd\"" +
|
85 |
|
|
" scope=\"system\">";
|
86 |
|
|
|
87 |
|
|
private String testEml_201_Header =
|
88 |
|
|
"<?xml version=\"1.0\"?><eml:eml" +
|
89 |
2263
|
sgarg
|
" xmlns:eml=\"eml://ecoinformatics.org/eml-2.0.1\"" +
|
90 |
|
|
" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
|
91 |
|
|
" packageId=\"eml.1.1\" system=\"knb\"" +
|
92 |
|
|
" xsi:schemaLocation=\"eml://ecoinformatics.org/eml-2.0.1 eml.xsd\"" +
|
93 |
|
|
" scope=\"system\">";
|
94 |
4477
|
daigle
|
|
95 |
|
|
private String testEml_210_Header =
|
96 |
|
|
"<?xml version=\"1.0\"?><eml:eml" +
|
97 |
|
|
" xmlns:eml=\"eml://ecoinformatics.org/eml-2.1.0\"" +
|
98 |
|
|
" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
|
99 |
|
|
" packageId=\"eml.1.1\" system=\"knb\"" +
|
100 |
|
|
" xsi:schemaLocation=\"eml://ecoinformatics.org/eml-2.1.0 eml.xsd\"" +
|
101 |
|
|
" scope=\"system\">";
|
102 |
2263
|
sgarg
|
|
103 |
|
|
private String testEmlCreatorBlock =
|
104 |
|
|
"<creator scope=\"document\"> " +
|
105 |
|
|
" <individualName> " +
|
106 |
|
|
" <surName>Smith</surName> " +
|
107 |
|
|
" </individualName> " +
|
108 |
|
|
"</creator> ";
|
109 |
|
|
|
110 |
|
|
private String testEmlContactBlock =
|
111 |
|
|
"<contact scope=\"document\"> " +
|
112 |
|
|
" <individualName> " +
|
113 |
|
|
" <surName>Jackson</surName> " +
|
114 |
|
|
" </individualName> " +
|
115 |
|
|
"</contact> ";
|
116 |
|
|
|
117 |
|
|
private String testEmlInlineBlock1 =
|
118 |
|
|
" <admin> " +
|
119 |
|
|
" <contact> " +
|
120 |
|
|
" <name>Operator</name> " +
|
121 |
|
|
" <institution>PSI</institution> " +
|
122 |
|
|
" </contact> " +
|
123 |
|
|
" </admin> ";
|
124 |
|
|
|
125 |
|
|
private String testEmlInlineBlock2 =
|
126 |
|
|
" <instrument> " +
|
127 |
|
|
" <instName>LCQ</instName> " +
|
128 |
|
|
" <source type=\"ESI\"></source> " +
|
129 |
|
|
" <detector type=\"EM\"></detector> " +
|
130 |
|
|
" </instrument> ";
|
131 |
|
|
|
132 |
2288
|
sgarg
|
|
133 |
2263
|
sgarg
|
/**
|
134 |
|
|
* This function returns an access block based on the params passed
|
135 |
|
|
*/
|
136 |
4509
|
daigle
|
protected String getAccessBlock(String principal, boolean grantAccess,
|
137 |
2263
|
sgarg
|
boolean read, boolean write,
|
138 |
|
|
boolean changePermission, boolean all) {
|
139 |
|
|
String accessBlock = "<access " +
|
140 |
|
|
"authSystem=\"ldap://ldap.ecoinformatics.org:389/dc=ecoinformatics,dc=org\"" +
|
141 |
|
|
" order=\"allowFirst\" scope=\"document\">";
|
142 |
|
|
|
143 |
|
|
if (grantAccess) {
|
144 |
|
|
accessBlock += "<allow>";
|
145 |
|
|
}
|
146 |
|
|
else {
|
147 |
|
|
accessBlock += "<deny>";
|
148 |
|
|
}
|
149 |
|
|
|
150 |
|
|
accessBlock = accessBlock + "<principal>" + principal + "</principal>";
|
151 |
|
|
|
152 |
|
|
if (all) {
|
153 |
|
|
accessBlock += "<permission>all</permission>";
|
154 |
|
|
}
|
155 |
|
|
else {
|
156 |
|
|
if (read) {
|
157 |
|
|
accessBlock += "<permission>read</permission>";
|
158 |
|
|
}
|
159 |
|
|
if (write) {
|
160 |
|
|
accessBlock += "<permission>write</permission>";
|
161 |
|
|
}
|
162 |
|
|
if (changePermission) {
|
163 |
|
|
accessBlock += "<permission>changePermission</permission>";
|
164 |
|
|
}
|
165 |
|
|
}
|
166 |
|
|
|
167 |
|
|
if (grantAccess) {
|
168 |
|
|
accessBlock += "</allow>";
|
169 |
|
|
}
|
170 |
|
|
else {
|
171 |
|
|
accessBlock += "</deny>";
|
172 |
|
|
}
|
173 |
|
|
accessBlock += "</access>";
|
174 |
|
|
|
175 |
|
|
return accessBlock;
|
176 |
|
|
|
177 |
|
|
}
|
178 |
|
|
|
179 |
|
|
/**
|
180 |
4477
|
daigle
|
* This function returns a valid eml 2.0 1 document
|
181 |
|
|
*/
|
182 |
|
|
private String get201TestEmlDoc(String title, String inlineData1, String inlineData2,
|
183 |
|
|
String onlineUrl1, String onlineUrl2, String docAccessBlock,
|
184 |
|
|
String inlineAccessBlock1, String inlineAccessBlock2,
|
185 |
|
|
String onlineAccessBlock1, String onlineAccessBlock2) {
|
186 |
2263
|
sgarg
|
|
187 |
4477
|
daigle
|
String testDocument = testEml_201_Header;
|
188 |
2263
|
sgarg
|
|
189 |
4477
|
daigle
|
testDocument += "<dataset scope=\"document\"><title>" + title + "</title>"
|
190 |
|
|
+ testEmlCreatorBlock;
|
191 |
2263
|
sgarg
|
|
192 |
4477
|
daigle
|
// The inline/online level access block sits at the same level as the
|
193 |
|
|
// inline element.
|
194 |
|
|
if (inlineData1 != null) {
|
195 |
|
|
testDocument += "<distribution scope=\"document\" id=\"inlineEntity1\">"
|
196 |
|
|
+ "<inline>" + inlineData1 + "</inline></distribution>";
|
197 |
|
|
}
|
198 |
|
|
if (inlineData2 != null) {
|
199 |
|
|
testDocument = testDocument
|
200 |
|
|
+ "<distribution scope=\"document\" id=\"inlineEntity2\">"
|
201 |
|
|
+ "<inline>" + inlineData2 + "</inline></distribution>";
|
202 |
|
|
}
|
203 |
|
|
if (onlineUrl1 != null) {
|
204 |
|
|
testDocument = testDocument
|
205 |
|
|
+ "<distribution scope=\"document\" id=\"InlineEntity1\">"
|
206 |
|
|
+ "<Inline><url function=\"download\">" + onlineUrl1
|
207 |
|
|
+ "</url></Inline></distribution>";
|
208 |
|
|
}
|
209 |
|
|
if (onlineUrl2 != null) {
|
210 |
|
|
testDocument = testDocument
|
211 |
|
|
+ "<distribution scope=\"document\" id=\"InlineEntity2\">"
|
212 |
|
|
+ "<Inline><url function=\"download\">" + onlineUrl2
|
213 |
|
|
+ "</url></Inline></distribution>";
|
214 |
|
|
}
|
215 |
|
|
testDocument += testEmlContactBlock;
|
216 |
|
|
|
217 |
|
|
// The document level access block sits inside the dataset element.
|
218 |
|
|
if (docAccessBlock != null) {
|
219 |
|
|
testDocument += docAccessBlock;
|
220 |
|
|
}
|
221 |
2263
|
sgarg
|
|
222 |
4477
|
daigle
|
testDocument += "</dataset>";
|
223 |
2263
|
sgarg
|
|
224 |
4477
|
daigle
|
// The inline access blocks live in additionalMetadata elements at
|
225 |
|
|
// the same level as the dataset.
|
226 |
|
|
if (inlineAccessBlock1 != null) {
|
227 |
|
|
testDocument += "<additionalMetadata>";
|
228 |
|
|
testDocument += "<describes>inlineEntity1</describes>";
|
229 |
|
|
testDocument += inlineAccessBlock1;
|
230 |
|
|
testDocument += "</additionalMetadata>";
|
231 |
|
|
}
|
232 |
2263
|
sgarg
|
|
233 |
4477
|
daigle
|
if (inlineAccessBlock2 != null) {
|
234 |
|
|
testDocument += "<additionalMetadata>";
|
235 |
|
|
testDocument += "<describes>inlineEntity2</describes>";
|
236 |
|
|
testDocument += inlineAccessBlock2;
|
237 |
|
|
testDocument += "</additionalMetadata>";
|
238 |
|
|
}
|
239 |
2263
|
sgarg
|
|
240 |
4477
|
daigle
|
if (onlineAccessBlock1 != null) {
|
241 |
|
|
testDocument += "<additionalMetadata>";
|
242 |
|
|
testDocument += "<describes>InlineEntity1</describes>";
|
243 |
|
|
testDocument += onlineAccessBlock1;
|
244 |
|
|
testDocument += "</additionalMetadata>";
|
245 |
|
|
}
|
246 |
2263
|
sgarg
|
|
247 |
4477
|
daigle
|
if (onlineAccessBlock2 != null) {
|
248 |
|
|
testDocument += "<additionalMetadata>";
|
249 |
|
|
testDocument += "<describes>InlineEntity2</describes>";
|
250 |
|
|
testDocument += onlineAccessBlock2;
|
251 |
|
|
testDocument += "</additionalMetadata>";
|
252 |
|
|
}
|
253 |
2263
|
sgarg
|
|
254 |
4477
|
daigle
|
testDocument += "</eml:eml>";
|
255 |
2263
|
sgarg
|
|
256 |
4477
|
daigle
|
debug("Returning following document" + testDocument);
|
257 |
|
|
return testDocument;
|
258 |
|
|
}
|
259 |
|
|
|
260 |
|
|
/**
|
261 |
|
|
* This function returns a valid eml document
|
262 |
|
|
*/
|
263 |
|
|
private String get210TestEmlDoc(String title, String inlineData1,
|
264 |
|
|
String inlineData2, String onlineUrl1,
|
265 |
|
|
String onlineUrl2, String docAccessBlock,
|
266 |
|
|
String inlineAccessBlock1,
|
267 |
|
|
String inlineAccessBlock2,
|
268 |
|
|
String onlineAccessBlock1,
|
269 |
|
|
String onlineAccessBlock2) {
|
270 |
2263
|
sgarg
|
|
271 |
4477
|
daigle
|
String testDocument = testEml_210_Header;
|
272 |
|
|
|
273 |
|
|
// the document level access block sits at the same level and
|
274 |
|
|
// before the dataset element.
|
275 |
|
|
if (docAccessBlock != null) {
|
276 |
|
|
testDocument += docAccessBlock;
|
277 |
|
|
}
|
278 |
|
|
|
279 |
|
|
testDocument += "<dataset scope=\"document\"><title>" + title + "</title>"
|
280 |
|
|
+ testEmlCreatorBlock + testEmlContactBlock
|
281 |
|
|
+ "<dataTable>"
|
282 |
|
|
+ " <entityName>Test Data</entityName>"
|
283 |
|
|
+ " <physical>"
|
284 |
|
|
+ " <objectName>2.1.0 test physical</objectName>"
|
285 |
|
|
+ " <size unit=\"bytes\">1</size>"
|
286 |
|
|
+ " <characterEncoding>ASCII</characterEncoding>"
|
287 |
|
|
+ " <dataFormat>"
|
288 |
|
|
+ " <textFormat>"
|
289 |
|
|
+ " <numHeaderLines>1</numHeaderLines>"
|
290 |
|
|
+ " <attributeOrientation>column</attributeOrientation>"
|
291 |
|
|
+ " <simpleDelimited>"
|
292 |
|
|
+ " <fieldDelimiter>\t</fieldDelimiter>"
|
293 |
|
|
+ " </simpleDelimited>"
|
294 |
|
|
+ " </textFormat>"
|
295 |
|
|
+ " </dataFormat>";
|
296 |
|
|
|
297 |
|
|
// The inline/online level access block sits at the same level as the
|
298 |
|
|
// inline element.
|
299 |
|
|
if (inlineData1 != null) {
|
300 |
|
|
testDocument += "<distribution><inline>" + inlineData1 + "</inline>";
|
301 |
|
|
if (inlineAccessBlock1 != null) {
|
302 |
|
|
testDocument += inlineAccessBlock1;
|
303 |
|
|
}
|
304 |
|
|
testDocument += "</distribution>";
|
305 |
|
|
}
|
306 |
|
|
if (inlineData2 != null) {
|
307 |
|
|
testDocument += "<distribution><inline>" + inlineData2 + "</inline>";
|
308 |
|
|
if (inlineAccessBlock2 != null) {
|
309 |
|
|
testDocument += inlineAccessBlock2;
|
310 |
|
|
}
|
311 |
|
|
testDocument += "</distribution>";
|
312 |
|
|
}
|
313 |
|
|
if (onlineUrl1 != null) {
|
314 |
|
|
testDocument = testDocument
|
315 |
|
|
+ "<distribution><Inline><url function=\"download\">" + onlineUrl1
|
316 |
|
|
+ "</url></Inline>";
|
317 |
|
|
if (onlineAccessBlock1 != null) {
|
318 |
|
|
testDocument += onlineAccessBlock1;
|
319 |
|
|
}
|
320 |
|
|
testDocument += "</distribution>";
|
321 |
|
|
}
|
322 |
|
|
if (onlineUrl2 != null) {
|
323 |
|
|
testDocument = testDocument
|
324 |
|
|
+ "<distribution><Inline><url function=\"download\">" + onlineUrl2
|
325 |
|
|
+ "</url></Inline>";
|
326 |
|
|
if (onlineAccessBlock2 != null) {
|
327 |
|
|
testDocument += onlineAccessBlock2;
|
328 |
|
|
}
|
329 |
|
|
testDocument += "</distribution>";
|
330 |
|
|
}
|
331 |
|
|
testDocument +=
|
332 |
|
|
" </physical>"
|
333 |
|
|
+ " <attributeList>"
|
334 |
|
|
+ " <attribute>"
|
335 |
|
|
+ " <attributeName>rain</attributeName>"
|
336 |
|
|
+ " <attributeLabel>Surface Rainfall</attributeLabel>"
|
337 |
|
|
+ " <attributeDefinition>The amount of rainfall on the sampling unit."
|
338 |
|
|
+ " </attributeDefinition>"
|
339 |
|
|
+ " <storageType>float</storageType>"
|
340 |
|
|
+ " <storageType typeSystem=\"http://java.sun.com/docs/books/jls/second_edition/html\">double</storageType>"
|
341 |
|
|
+ " <measurementScale>"
|
342 |
|
|
+ " <interval>"
|
343 |
|
|
+ " <unit><standardUnit>millimeter</standardUnit></unit>"
|
344 |
|
|
+ " <precision>0.5</precision>"
|
345 |
|
|
+ " <numericDomain id=\"nd.1\">"
|
346 |
|
|
+ " <numberType>real</numberType>"
|
347 |
|
|
+ " <bounds>"
|
348 |
|
|
+ " <minimum exclusive=\"false\">0</minimum>"
|
349 |
|
|
+ " </bounds>"
|
350 |
|
|
+ " </numericDomain>"
|
351 |
|
|
+ " </interval>"
|
352 |
|
|
+ " </measurementScale>"
|
353 |
|
|
+ " </attribute>"
|
354 |
|
|
+ " </attributeList>"
|
355 |
|
|
+ "</dataTable></dataset></eml:eml>";
|
356 |
|
|
|
357 |
|
|
debug("Returning following document" + testDocument);
|
358 |
|
|
return testDocument;
|
359 |
|
|
}
|
360 |
|
|
|
361 |
2263
|
sgarg
|
/**
|
362 |
4477
|
daigle
|
* Constructor to build the test
|
363 |
|
|
*
|
364 |
|
|
* @param name
|
365 |
|
|
* the name of the test method
|
366 |
|
|
*/
|
367 |
2263
|
sgarg
|
public InlineDataAccessTest(String name) {
|
368 |
|
|
super(name);
|
369 |
|
|
newdocid = generateDocid();
|
370 |
|
|
}
|
371 |
|
|
|
372 |
|
|
/**
|
373 |
|
|
* Establish a testing framework by initializing appropriate objects
|
374 |
|
|
*/
|
375 |
|
|
public void setUp() {
|
376 |
|
|
try {
|
377 |
|
|
System.err.println("Test Metacat: " + metacatUrl);
|
378 |
|
|
m = MetacatFactory.createMetacatConnection(metacatUrl);
|
379 |
|
|
}
|
380 |
|
|
catch (MetacatInaccessibleException mie) {
|
381 |
|
|
System.err.println("Metacat is: " + metacatUrl);
|
382 |
|
|
fail("Metacat connection failed." + mie.getMessage());
|
383 |
|
|
}
|
384 |
|
|
}
|
385 |
|
|
|
386 |
|
|
/**
|
387 |
|
|
* Release any objects after tests are complete
|
388 |
|
|
*/
|
389 |
|
|
public void tearDown() {
|
390 |
|
|
}
|
391 |
|
|
|
392 |
|
|
/**
|
393 |
|
|
* Create a suite of tests to be run together
|
394 |
|
|
*/
|
395 |
|
|
public static Test suite() {
|
396 |
|
|
TestSuite suite = new TestSuite();
|
397 |
|
|
suite.addTest(new InlineDataAccessTest("initialize"));
|
398 |
|
|
|
399 |
4477
|
daigle
|
suite.addTest(new InlineDataAccessTest("inlineData201CasesTest_1"));
|
400 |
|
|
suite.addTest(new InlineDataAccessTest("inlineData210CasesTest_1"));
|
401 |
|
|
suite.addTest(new InlineDataAccessTest("inlineData201CasesTest_2"));
|
402 |
|
|
suite.addTest(new InlineDataAccessTest("inlineData210CasesTest_2"));
|
403 |
|
|
suite.addTest(new InlineDataAccessTest("inlineData201CasesTest_3"));
|
404 |
|
|
suite.addTest(new InlineDataAccessTest("inlineData210CasesTest_3"));
|
405 |
|
|
suite.addTest(new InlineDataAccessTest("inlineData201CasesTest_4"));
|
406 |
|
|
suite.addTest(new InlineDataAccessTest("inlineData210CasesTest_4"));
|
407 |
|
|
suite.addTest(new InlineDataAccessTest("inlineData201CasesTest_5"));
|
408 |
|
|
suite.addTest(new InlineDataAccessTest("inlineData210CasesTest_5"));
|
409 |
|
|
suite.addTest(new InlineDataAccessTest("inlineData201CasesTest_6"));
|
410 |
|
|
suite.addTest(new InlineDataAccessTest("inlineData210CasesTest_6"));
|
411 |
2263
|
sgarg
|
|
412 |
|
|
return suite;
|
413 |
|
|
}
|
414 |
|
|
|
415 |
|
|
|
416 |
|
|
/**
|
417 |
|
|
* Run an initial test that always passes to check that the test
|
418 |
|
|
* harness is working.
|
419 |
|
|
*/
|
420 |
|
|
public void initialize() {
|
421 |
|
|
assertTrue(1 == 1);
|
422 |
|
|
}
|
423 |
|
|
|
424 |
4477
|
daigle
|
/**
|
425 |
|
|
* For EML 2.0.1, checking the following cases:
|
426 |
2263
|
sgarg
|
* when only Inline data is uploaded by a user and
|
427 |
|
|
* -> he tries to read it - success
|
428 |
|
|
* -> he tries to add same docid again - failure
|
429 |
|
|
* -> he tries to update it - success
|
430 |
|
|
* -> he removes it and adds it again - success
|
431 |
|
|
* -> he tries to delete it - success
|
432 |
|
|
* -> he tries to read it after deleteing - failure
|
433 |
|
|
*/
|
434 |
4477
|
daigle
|
public void inlineData201CasesTest_1() {
|
435 |
|
|
debug("\nRunning: inlineData201CasesTest_1()");
|
436 |
|
|
try {
|
437 |
|
|
newdocid = generateDocid();
|
438 |
|
|
m.login(username, password);
|
439 |
2263
|
sgarg
|
|
440 |
4477
|
daigle
|
// insert a document
|
441 |
|
|
testdocument = get201TestEmlDoc("Testing insert", testEmlInlineBlock1,
|
442 |
|
|
null, null, null, null, null, null, null, null);
|
443 |
2263
|
sgarg
|
|
444 |
4477
|
daigle
|
insertDocid(newdocid + ".1", testdocument, SUCCESS, false);
|
445 |
|
|
readDocidWhichEqualsDoc(newdocid, testdocument, SUCCESS, true);
|
446 |
2263
|
sgarg
|
|
447 |
4477
|
daigle
|
// insert same document again
|
448 |
|
|
insertDocid(newdocid + ".1", testdocument, FAILURE, false);
|
449 |
2263
|
sgarg
|
|
450 |
4477
|
daigle
|
// update by changing inline data
|
451 |
|
|
testdocument = get201TestEmlDoc("Testing update inline",
|
452 |
|
|
testEmlInlineBlock2, null, null, null, null, null, null, null, null);
|
453 |
|
|
Thread.sleep(2000);
|
454 |
|
|
updateDocid(newdocid + ".2", testdocument, SUCCESS, false);
|
455 |
|
|
readDocidWhichEqualsDoc(newdocid + ".2", testdocument, SUCCESS, true);
|
456 |
2263
|
sgarg
|
|
457 |
4477
|
daigle
|
// update by removing inline data
|
458 |
|
|
testdocument = get201TestEmlDoc("Testing update inline", null, null,
|
459 |
|
|
null, null, null, null, null, null, null);
|
460 |
|
|
Thread.sleep(2000);
|
461 |
|
|
updateDocid(newdocid + ".3", testdocument, SUCCESS, false);
|
462 |
|
|
readDocidWhichEqualsDoc(newdocid + ".3", testdocument, SUCCESS, true);
|
463 |
2263
|
sgarg
|
|
464 |
4477
|
daigle
|
// update by introducing inline data
|
465 |
|
|
testdocument = get201TestEmlDoc("Testing update inline",
|
466 |
|
|
testEmlInlineBlock1, null, null, null, null, null, null, null, null);
|
467 |
|
|
Thread.sleep(2000);
|
468 |
|
|
updateDocid(newdocid + ".4", testdocument, SUCCESS, false);
|
469 |
|
|
readDocidWhichEqualsDoc(newdocid + ".4", testdocument, SUCCESS, true);
|
470 |
2263
|
sgarg
|
|
471 |
4477
|
daigle
|
// read inline data only
|
472 |
|
|
readInlineDataWhichEqualsDoc(newdocid + ".1.1", testEmlInlineBlock1, SUCCESS,
|
473 |
|
|
false);
|
474 |
2263
|
sgarg
|
|
475 |
4477
|
daigle
|
// delete the inline data
|
476 |
|
|
// sleep needed only in case of inline data - jing said that
|
477 |
|
|
// somehow the thread writing data to xml_index takes too much time
|
478 |
|
|
// when used with inline data. hence if delete is requested too soon
|
479 |
|
|
// database gives an error of xml_index records left with FK to
|
480 |
|
|
// xml_document record which is going to be deleted.
|
481 |
|
|
Thread.sleep(10000);
|
482 |
2288
|
sgarg
|
|
483 |
4477
|
daigle
|
deleteDocid(newdocid + ".4", SUCCESS, false);
|
484 |
|
|
readDocidWhichEqualsDoc(newdocid + ".4", testdocument, FAILURE, false);
|
485 |
|
|
m.logout();
|
486 |
|
|
} catch (MetacatAuthException mae) {
|
487 |
|
|
fail("Authorization failed:\n" + mae.getMessage());
|
488 |
|
|
} catch (MetacatInaccessibleException mie) {
|
489 |
|
|
fail("Metacat Inaccessible:\n" + mie.getMessage());
|
490 |
|
|
} catch (Exception e) {
|
491 |
|
|
fail("General exception:\n" + e.getMessage());
|
492 |
|
|
}
|
493 |
|
|
}
|
494 |
|
|
|
495 |
|
|
/**
|
496 |
|
|
* For EML 2.1.0, checking the following cases: when only Inline data is
|
497 |
|
|
* uploaded by a user and -> he tries to read it - success -> he tries to
|
498 |
|
|
* add same docid again - failure -> he tries to update it - success -> he
|
499 |
|
|
* removes it and adds it again - success -> he tries to delete it - success ->
|
500 |
|
|
* he tries to read it after deleteing - failure
|
501 |
|
|
*/
|
502 |
|
|
public void inlineData210CasesTest_1() {
|
503 |
|
|
debug("\nRunning: inlineData210CasesTest_1()");
|
504 |
|
|
try {
|
505 |
|
|
newdocid = generateDocid();
|
506 |
|
|
m.login(username, password);
|
507 |
2263
|
sgarg
|
|
508 |
4477
|
daigle
|
// insert a document
|
509 |
|
|
testdocument = get210TestEmlDoc("Testing insert", testEmlInlineBlock1,
|
510 |
|
|
null, null, null, null, null, null, null, null);
|
511 |
2263
|
sgarg
|
|
512 |
4477
|
daigle
|
insertDocid(newdocid + ".1", testdocument, SUCCESS, false);
|
513 |
|
|
readDocidWhichEqualsDoc(newdocid, testdocument, SUCCESS, true);
|
514 |
2263
|
sgarg
|
|
515 |
4477
|
daigle
|
// insert same document again
|
516 |
|
|
insertDocid(newdocid + ".1", testdocument, FAILURE, false);
|
517 |
2263
|
sgarg
|
|
518 |
4477
|
daigle
|
// update by changing inline data
|
519 |
|
|
testdocument = get210TestEmlDoc("Testing update inline",
|
520 |
|
|
testEmlInlineBlock2, null, null, null, null, null, null, null, null);
|
521 |
|
|
Thread.sleep(2000);
|
522 |
|
|
updateDocid(newdocid + ".2", testdocument, SUCCESS, false);
|
523 |
|
|
readDocidWhichEqualsDoc(newdocid + ".2", testdocument, SUCCESS, true);
|
524 |
2263
|
sgarg
|
|
525 |
4477
|
daigle
|
// update by removing inline data
|
526 |
|
|
testdocument = get210TestEmlDoc("Testing update inline", null, null,
|
527 |
|
|
null, null, null, null, null, null, null);
|
528 |
|
|
Thread.sleep(2000);
|
529 |
|
|
updateDocid(newdocid + ".3", testdocument, SUCCESS, false);
|
530 |
|
|
readDocidWhichEqualsDoc(newdocid + ".3", testdocument, SUCCESS, true);
|
531 |
2263
|
sgarg
|
|
532 |
4477
|
daigle
|
// update by introducing inline data
|
533 |
|
|
testdocument = get210TestEmlDoc("Testing update inline",
|
534 |
|
|
testEmlInlineBlock1, null, null, null, null, null, null, null, null);
|
535 |
|
|
Thread.sleep(2000);
|
536 |
|
|
updateDocid(newdocid + ".4", testdocument, SUCCESS, false);
|
537 |
|
|
readDocidWhichEqualsDoc(newdocid + ".4", testdocument, SUCCESS, true);
|
538 |
2263
|
sgarg
|
|
539 |
4477
|
daigle
|
// read inline data only
|
540 |
|
|
readInlineDataWhichEqualsDoc(newdocid + ".1.1", testEmlInlineBlock1, SUCCESS,
|
541 |
|
|
false);
|
542 |
2263
|
sgarg
|
|
543 |
4477
|
daigle
|
// delete the inline data
|
544 |
|
|
// sleep needed only in case of inline data - jing said that
|
545 |
|
|
// somehow the thread writing data to xml_index takes too much time
|
546 |
|
|
// when used with inline data. hence if delete is requested too soon
|
547 |
|
|
// database gives an error of xml_index records left with FK to
|
548 |
|
|
// xml_document record which is going to be deleted.
|
549 |
|
|
Thread.sleep(10000);
|
550 |
2263
|
sgarg
|
|
551 |
4477
|
daigle
|
deleteDocid(newdocid + ".4", SUCCESS, false);
|
552 |
|
|
readDocidWhichEqualsDoc(newdocid + ".4", testdocument, FAILURE, false);
|
553 |
|
|
m.logout();
|
554 |
|
|
} catch (MetacatAuthException mae) {
|
555 |
|
|
fail("Authorization failed:\n" + mae.getMessage());
|
556 |
|
|
} catch (MetacatInaccessibleException mie) {
|
557 |
|
|
fail("Metacat Inaccessible:\n" + mie.getMessage());
|
558 |
|
|
} catch (Exception e) {
|
559 |
|
|
fail("General exception:\n" + e.getMessage());
|
560 |
|
|
}
|
561 |
|
|
}
|
562 |
2263
|
sgarg
|
|
563 |
4477
|
daigle
|
/***************************************************************************
|
564 |
|
|
* For EML 2.0.1, checking the following cases: when only inline data is
|
565 |
|
|
* uploaded by a user and another user -> tries to read it - failure ->
|
566 |
|
|
* tries to read inline data only - failure -> tries to update - failure ->
|
567 |
|
|
* tries to delete it - failure
|
568 |
|
|
*/
|
569 |
|
|
public void inlineData201CasesTest_2() {
|
570 |
|
|
debug("\nRunning: inlineData201CasesTest_2()");
|
571 |
|
|
try {
|
572 |
|
|
newdocid = generateDocid();
|
573 |
|
|
m.login(username, password);
|
574 |
2263
|
sgarg
|
|
575 |
4477
|
daigle
|
// insert a document
|
576 |
|
|
testdocument = get201TestEmlDoc("Testing insert", testEmlInlineBlock1,
|
577 |
|
|
null, null, null, null, null, null, null, null);
|
578 |
2263
|
sgarg
|
|
579 |
4477
|
daigle
|
insertDocid(newdocid + ".1", testdocument, SUCCESS, false);
|
580 |
|
|
readDocidWhichEqualsDoc(newdocid, testdocument, SUCCESS, true);
|
581 |
2263
|
sgarg
|
|
582 |
4477
|
daigle
|
// login as another user
|
583 |
|
|
m.logout();
|
584 |
|
|
m.login(anotheruser, anotherpassword);
|
585 |
2263
|
sgarg
|
|
586 |
4477
|
daigle
|
// try to read document or data only
|
587 |
|
|
readDocidWhichEqualsDoc(newdocid, testdocument, FAILURE, true);
|
588 |
|
|
readInlineDataWhichEqualsDoc(newdocid + ".1.1", testEmlInlineBlock1, FAILURE,
|
589 |
|
|
true);
|
590 |
2263
|
sgarg
|
|
591 |
4477
|
daigle
|
// try to update the document
|
592 |
|
|
testdocument = get201TestEmlDoc("Testing insert", testEmlInlineBlock1,
|
593 |
|
|
null, null, null, null, null, null, null, null);
|
594 |
|
|
Thread.sleep(2000);
|
595 |
|
|
updateDocid(newdocid + ".2", testdocument, FAILURE, true);
|
596 |
2263
|
sgarg
|
|
597 |
4477
|
daigle
|
// try to delete the document
|
598 |
|
|
deleteDocid(newdocid + ".1", FAILURE, true);
|
599 |
|
|
m.logout();
|
600 |
2263
|
sgarg
|
|
601 |
4477
|
daigle
|
// delete the document
|
602 |
|
|
m.login(username, password);
|
603 |
|
|
deleteDocid(newdocid + ".1", SUCCESS, false);
|
604 |
|
|
m.logout();
|
605 |
2263
|
sgarg
|
|
606 |
4477
|
daigle
|
} catch (MetacatAuthException mae) {
|
607 |
|
|
fail("Authorization failed:\n" + mae.getMessage());
|
608 |
|
|
} catch (MetacatInaccessibleException mie) {
|
609 |
|
|
fail("Metacat Inaccessible:\n" + mie.getMessage());
|
610 |
|
|
} catch (Exception e) {
|
611 |
|
|
fail("General exception:\n" + e.getMessage());
|
612 |
|
|
}
|
613 |
|
|
}
|
614 |
|
|
|
615 |
|
|
/***************************************************************************
|
616 |
|
|
* For EML 2.1.0, checking the following cases: when only inline data is
|
617 |
|
|
* uploaded by a user and another user -> tries to read it - failure ->
|
618 |
|
|
* tries to read inline data only - failure -> tries to update - failure ->
|
619 |
|
|
* tries to delete it - failure
|
620 |
|
|
*/
|
621 |
|
|
public void inlineData210CasesTest_2() {
|
622 |
|
|
debug("\nRunning: inlineData210CasesTest_2()");
|
623 |
|
|
try {
|
624 |
|
|
newdocid = generateDocid();
|
625 |
|
|
m.login(username, password);
|
626 |
2263
|
sgarg
|
|
627 |
4477
|
daigle
|
// insert a document
|
628 |
|
|
testdocument = get210TestEmlDoc("Testing insert", testEmlInlineBlock1,
|
629 |
|
|
null, null, null, null, null, null, null, null);
|
630 |
2263
|
sgarg
|
|
631 |
4477
|
daigle
|
insertDocid(newdocid + ".1", testdocument, SUCCESS, false);
|
632 |
|
|
readDocidWhichEqualsDoc(newdocid, testdocument, SUCCESS, true);
|
633 |
2263
|
sgarg
|
|
634 |
4477
|
daigle
|
// login as another user
|
635 |
|
|
m.logout();
|
636 |
|
|
m.login(anotheruser, anotherpassword);
|
637 |
2263
|
sgarg
|
|
638 |
4477
|
daigle
|
// try to read document or data only
|
639 |
|
|
readDocidWhichEqualsDoc(newdocid, testdocument, FAILURE, true);
|
640 |
|
|
readInlineDataWhichEqualsDoc(newdocid + ".1.1", testEmlInlineBlock1, FAILURE,
|
641 |
|
|
true);
|
642 |
2263
|
sgarg
|
|
643 |
4477
|
daigle
|
// try to update the document
|
644 |
|
|
testdocument = get210TestEmlDoc("Testing insert", testEmlInlineBlock1,
|
645 |
|
|
null, null, null, null, null, null, null, null);
|
646 |
|
|
Thread.sleep(2000);
|
647 |
|
|
updateDocid(newdocid + ".2", testdocument, FAILURE, true);
|
648 |
2263
|
sgarg
|
|
649 |
4477
|
daigle
|
// try to delete the document
|
650 |
|
|
deleteDocid(newdocid + ".1", FAILURE, true);
|
651 |
|
|
m.logout();
|
652 |
2263
|
sgarg
|
|
653 |
4477
|
daigle
|
// delete the document
|
654 |
|
|
m.login(username, password);
|
655 |
|
|
deleteDocid(newdocid + ".1", SUCCESS, false);
|
656 |
|
|
m.logout();
|
657 |
2263
|
sgarg
|
|
658 |
4477
|
daigle
|
} catch (MetacatAuthException mae) {
|
659 |
|
|
fail("Authorization failed:\n" + mae.getMessage());
|
660 |
|
|
} catch (MetacatInaccessibleException mie) {
|
661 |
|
|
fail("Metacat Inaccessible:\n" + mie.getMessage());
|
662 |
|
|
} catch (Exception e) {
|
663 |
|
|
fail("General exception:\n" + e.getMessage());
|
664 |
|
|
}
|
665 |
|
|
}
|
666 |
2263
|
sgarg
|
|
667 |
4477
|
daigle
|
/***************************************************************************
|
668 |
|
|
* For EML 2.0.1, checking the following cases:
|
669 |
|
|
* when only inline data is uploaded by a user with the following different
|
670 |
|
|
* access controls in another document 1.read 2.write 3.change permission
|
671 |
|
|
* 4.all And another user tries to do the following: -> tries to read it ->
|
672 |
|
|
* tries to update it -> tries to set permissions on it -> tries to delete it
|
673 |
|
|
*/
|
674 |
|
|
public void inlineData201CasesTest_3() {
|
675 |
|
|
debug("\nRunning: inlineData201CasesTest_3()");
|
676 |
|
|
try {
|
677 |
2263
|
sgarg
|
|
678 |
4477
|
daigle
|
// ///////Case 1./////////////////////
|
679 |
|
|
// insert an inline document - read only
|
680 |
|
|
m.login(username, password);
|
681 |
|
|
newdocid = generateDocid();
|
682 |
2263
|
sgarg
|
|
683 |
4477
|
daigle
|
// insert a document which gives read access to the inline document
|
684 |
|
|
testdocument = get201TestEmlDoc("InlineDataAccessTest: Doing insert",
|
685 |
|
|
testEmlInlineBlock1, null, null, null, getAccessBlock(anotheruser,
|
686 |
|
|
true, true, false, false, false), null, null, null, null);
|
687 |
|
|
|
688 |
|
|
insertDocid(newdocid + ".1", testdocument, SUCCESS, false);
|
689 |
|
|
m.logout();
|
690 |
2263
|
sgarg
|
|
691 |
4477
|
daigle
|
// login as another user
|
692 |
|
|
m.login(anotheruser, anotherpassword);
|
693 |
2263
|
sgarg
|
|
694 |
4477
|
daigle
|
// try to read the document and the inline data
|
695 |
|
|
readDocid(newdocid + ".1", SUCCESS, false);
|
696 |
|
|
readInlineDataWhichEqualsDoc(newdocid + ".1.1", testEmlInlineBlock1, SUCCESS,
|
697 |
|
|
false);
|
698 |
2263
|
sgarg
|
|
699 |
4477
|
daigle
|
// try to update the inline data
|
700 |
|
|
testdocument = get201TestEmlDoc("InlineDataAccessTest: Doing update",
|
701 |
|
|
testEmlInlineBlock2, null, null, null, getAccessBlock(anotheruser,
|
702 |
|
|
true, true, false, false, false), null, null, null, null);
|
703 |
|
|
Thread.sleep(2000);
|
704 |
|
|
updateDocid(newdocid + ".2", testdocument, FAILURE, true);
|
705 |
2263
|
sgarg
|
|
706 |
4477
|
daigle
|
// try to set the permissions for the inline data
|
707 |
|
|
testdocument = get201TestEmlDoc("InlineDataAccessTest: Doing insert",
|
708 |
|
|
testEmlInlineBlock1, null, null, null, getAccessBlock(anotheruser,
|
709 |
|
|
true, false, false, false, true), null, null, null, null);
|
710 |
|
|
Thread.sleep(2000);
|
711 |
|
|
updateDocid(newdocid + ".2", testdocument, FAILURE, true);
|
712 |
2263
|
sgarg
|
|
713 |
4477
|
daigle
|
// try to delete the document
|
714 |
|
|
deleteDocid(newdocid + ".1", FAILURE, true);
|
715 |
|
|
m.logout();
|
716 |
2263
|
sgarg
|
|
717 |
4477
|
daigle
|
// delete the document
|
718 |
|
|
m.login(username, password);
|
719 |
|
|
deleteDocid(newdocid + ".1", SUCCESS, false);
|
720 |
|
|
m.logout();
|
721 |
2263
|
sgarg
|
|
722 |
4477
|
daigle
|
// ///////Case 2./////////////////////
|
723 |
|
|
// insert an inline document - write only
|
724 |
|
|
m.login(username, password);
|
725 |
|
|
newdocid = generateDocid();
|
726 |
2263
|
sgarg
|
|
727 |
4477
|
daigle
|
// insert a document which gives read access to the inline document
|
728 |
|
|
testdocument = get201TestEmlDoc("InlineDataAccessTest: Doing insert",
|
729 |
|
|
testEmlInlineBlock1, null, null, null, getAccessBlock(anotheruser,
|
730 |
|
|
true, false, true, false, false), null, null, null, null);
|
731 |
|
|
insertDocid(newdocid + ".1", testdocument, SUCCESS, false);
|
732 |
|
|
m.logout();
|
733 |
2263
|
sgarg
|
|
734 |
4477
|
daigle
|
// login as another user
|
735 |
|
|
m.login(anotheruser, anotherpassword);
|
736 |
2263
|
sgarg
|
|
737 |
4477
|
daigle
|
// try to read the document and the inline data
|
738 |
|
|
readDocid(newdocid + ".1", FAILURE, true);
|
739 |
|
|
readInlineDataWhichEqualsDoc(newdocid + ".1.1", testEmlInlineBlock1, FAILURE,
|
740 |
|
|
true);
|
741 |
2263
|
sgarg
|
|
742 |
4477
|
daigle
|
// try to update the inline data
|
743 |
|
|
testdocument = get201TestEmlDoc("InlineDataAccessTest: Doing update",
|
744 |
|
|
testEmlInlineBlock2, null, null, null, getAccessBlock(anotheruser,
|
745 |
|
|
true, false, true, false, false), null, null, null, null);
|
746 |
|
|
Thread.sleep(2000);
|
747 |
|
|
updateDocid(newdocid + ".2", testdocument, SUCCESS, false);
|
748 |
2263
|
sgarg
|
|
749 |
4477
|
daigle
|
// try to set the permissions for the inline data
|
750 |
|
|
testdocument = get201TestEmlDoc("InlineDataAccessTest: Doing insert",
|
751 |
|
|
testEmlInlineBlock1, null, null, null, getAccessBlock(anotheruser,
|
752 |
|
|
true, false, false, false, true), null, null, null, null);
|
753 |
|
|
Thread.sleep(2000);
|
754 |
|
|
updateDocid(newdocid + ".3", testdocument, FAILURE, true);
|
755 |
2263
|
sgarg
|
|
756 |
4477
|
daigle
|
// try to delete the document
|
757 |
|
|
deleteDocid(newdocid + ".2", FAILURE, true);
|
758 |
|
|
m.logout();
|
759 |
2288
|
sgarg
|
|
760 |
4477
|
daigle
|
// delete the document
|
761 |
|
|
m.login(username, password);
|
762 |
|
|
deleteDocid(newdocid + ".2", SUCCESS, false);
|
763 |
|
|
m.logout();
|
764 |
2263
|
sgarg
|
|
765 |
4477
|
daigle
|
// ///////Case 3./////////////////////
|
766 |
|
|
// insert an inline document - change permission only
|
767 |
|
|
m.login(username, password);
|
768 |
|
|
newdocid = generateDocid();
|
769 |
2263
|
sgarg
|
|
770 |
4477
|
daigle
|
// insert a document which gives read access to the inline document
|
771 |
|
|
testdocument = get201TestEmlDoc("InlineDataAccessTest: Doing insert",
|
772 |
|
|
testEmlInlineBlock1, null, null, null, getAccessBlock(anotheruser,
|
773 |
|
|
true, false, false, true, false), null, null, null, null);
|
774 |
|
|
insertDocid(newdocid + ".1", testdocument, SUCCESS, false);
|
775 |
|
|
m.logout();
|
776 |
2263
|
sgarg
|
|
777 |
4477
|
daigle
|
// login as another user
|
778 |
|
|
m.login(anotheruser, anotherpassword);
|
779 |
2263
|
sgarg
|
|
780 |
4477
|
daigle
|
// try to read the document and the inline data
|
781 |
|
|
readDocid(newdocid + ".1", FAILURE, true);
|
782 |
|
|
readInlineDataWhichEqualsDoc(newdocid + ".1.1", testEmlInlineBlock1, FAILURE,
|
783 |
|
|
true);
|
784 |
2263
|
sgarg
|
|
785 |
4477
|
daigle
|
// try to update the inline data
|
786 |
|
|
testdocument = get201TestEmlDoc("InlineDataAccessTest: Doing update",
|
787 |
|
|
testEmlInlineBlock2, null, null, null, getAccessBlock(anotheruser,
|
788 |
|
|
true, false, false, true, false), null, null, null, null);
|
789 |
|
|
Thread.sleep(2000);
|
790 |
|
|
updateDocid(newdocid + ".2", testdocument, FAILURE, true);
|
791 |
2263
|
sgarg
|
|
792 |
4477
|
daigle
|
// try to set the permissions for the inline data
|
793 |
|
|
testdocument = get201TestEmlDoc("InlineDataAccessTest: Doing insert",
|
794 |
|
|
testEmlInlineBlock1, null, null, null, getAccessBlock(anotheruser,
|
795 |
|
|
true, false, false, false, true), null, null, null, null);
|
796 |
|
|
// ERRRRRRRRRRRR
|
797 |
|
|
// updateDocid(newdocid + ".2", testdocument, SUCCESS, false);
|
798 |
2263
|
sgarg
|
|
799 |
4477
|
daigle
|
// try to delete the document
|
800 |
|
|
deleteDocid(newdocid + ".1", FAILURE, true);
|
801 |
|
|
m.logout();
|
802 |
2263
|
sgarg
|
|
803 |
4477
|
daigle
|
// delete the document
|
804 |
|
|
m.login(username, password);
|
805 |
|
|
deleteDocid(newdocid + ".1", SUCCESS, false);
|
806 |
|
|
m.logout();
|
807 |
2263
|
sgarg
|
|
808 |
4477
|
daigle
|
// ///////Case 4./////////////////////
|
809 |
|
|
// insert an inline document - change permission only
|
810 |
|
|
m.login(username, password);
|
811 |
|
|
newdocid = generateDocid();
|
812 |
2263
|
sgarg
|
|
813 |
4477
|
daigle
|
// insert a document which gives read access to the inline document
|
814 |
|
|
testdocument = get201TestEmlDoc("InlineDataAccessTest: Doing insert",
|
815 |
|
|
testEmlInlineBlock1, null, null, null, getAccessBlock(anotheruser,
|
816 |
|
|
true, false, false, false, true), null, null, null, null);
|
817 |
|
|
insertDocid(newdocid + ".1", testdocument, SUCCESS, false);
|
818 |
|
|
m.logout();
|
819 |
2263
|
sgarg
|
|
820 |
4477
|
daigle
|
// login as another user
|
821 |
|
|
m.login(anotheruser, anotherpassword);
|
822 |
2263
|
sgarg
|
|
823 |
4477
|
daigle
|
// try to read the document and the inline data
|
824 |
|
|
readDocid(newdocid + ".1", SUCCESS, false);
|
825 |
|
|
readInlineDataWhichEqualsDoc(newdocid + ".1.1", testEmlInlineBlock1, SUCCESS,
|
826 |
|
|
false);
|
827 |
2263
|
sgarg
|
|
828 |
4477
|
daigle
|
// try to update the inline data
|
829 |
|
|
testdocument = get201TestEmlDoc("InlineDataAccessTest: Doing update",
|
830 |
|
|
testEmlInlineBlock2, null, null, null, getAccessBlock(anotheruser,
|
831 |
|
|
true, false, false, false, true), null, null, null, null);
|
832 |
|
|
Thread.sleep(2000);
|
833 |
|
|
updateDocid(newdocid + ".2", testdocument, SUCCESS, false);
|
834 |
2263
|
sgarg
|
|
835 |
4477
|
daigle
|
// try to set the permissions for the inline data
|
836 |
|
|
testdocument = get201TestEmlDoc("InlineDataAccessTest: Doing insert",
|
837 |
|
|
testEmlInlineBlock1, null, null, null, getAccessBlock(anotheruser,
|
838 |
|
|
true, true, true, true, false), null, null, null, null);
|
839 |
|
|
Thread.sleep(2000);
|
840 |
|
|
updateDocid(newdocid + ".3", testdocument, SUCCESS, false);
|
841 |
2263
|
sgarg
|
|
842 |
4477
|
daigle
|
// try to delete the document
|
843 |
|
|
// sleep needed only in case of inline data - jing said that
|
844 |
|
|
// somehow the thread writing data to xml_index takes too much time
|
845 |
|
|
// when used with inline data. hence if delete is requested too soon
|
846 |
|
|
// database gives an error of xml_index records left with FK to
|
847 |
|
|
// xml_document record which is going to be deleted.
|
848 |
|
|
Thread.sleep(10000);
|
849 |
2263
|
sgarg
|
|
850 |
4477
|
daigle
|
deleteDocid(newdocid + ".3", SUCCESS, false);
|
851 |
|
|
m.logout();
|
852 |
2263
|
sgarg
|
|
853 |
4477
|
daigle
|
} catch (MetacatAuthException mae) {
|
854 |
|
|
fail("Authorization failed:\n" + mae.getMessage());
|
855 |
|
|
} catch (MetacatInaccessibleException mie) {
|
856 |
|
|
fail("Metacat Inaccessible:\n" + mie.getMessage());
|
857 |
|
|
} catch (Exception e) {
|
858 |
|
|
fail("General exception:\n" + e.getMessage());
|
859 |
|
|
}
|
860 |
|
|
}
|
861 |
|
|
|
862 |
|
|
/***************************************************************************
|
863 |
|
|
* For EML 2.1.0, checking the following cases:
|
864 |
|
|
* when only inline data is uploaded by a user with the following different
|
865 |
|
|
* access controls in another document 1.read 2.write 3.change permission
|
866 |
|
|
* 4.all And another user tries to do the following: -> tries to read it ->
|
867 |
|
|
* tries to update it -> tries to set permissions on it -> tries to delete it
|
868 |
|
|
*/
|
869 |
|
|
public void inlineData210CasesTest_3() {
|
870 |
|
|
debug("\nRunning: inlineData210CasesTest_3()");
|
871 |
|
|
try {
|
872 |
2263
|
sgarg
|
|
873 |
4477
|
daigle
|
// ///////Case 1./////////////////////
|
874 |
|
|
// insert an inline document - read only
|
875 |
|
|
m.login(username, password);
|
876 |
|
|
newdocid = generateDocid();
|
877 |
2263
|
sgarg
|
|
878 |
4477
|
daigle
|
// insert a document which gives read access to the inline document
|
879 |
|
|
testdocument = get210TestEmlDoc("InlineDataAccessTest: Doing insert",
|
880 |
|
|
testEmlInlineBlock1, null, null, null, getAccessBlock(anotheruser,
|
881 |
|
|
true, true, false, false, false), null, null, null, null);
|
882 |
|
|
insertDocid(newdocid + ".1", testdocument, SUCCESS, false);
|
883 |
|
|
m.logout();
|
884 |
2263
|
sgarg
|
|
885 |
4477
|
daigle
|
// login as another user
|
886 |
|
|
m.login(anotheruser, anotherpassword);
|
887 |
2263
|
sgarg
|
|
888 |
4477
|
daigle
|
// try to read the document and the inline data
|
889 |
|
|
readDocid(newdocid + ".1", SUCCESS, false);
|
890 |
|
|
readInlineDataWhichEqualsDoc(newdocid + ".1.1", testEmlInlineBlock1, SUCCESS,
|
891 |
|
|
false);
|
892 |
2263
|
sgarg
|
|
893 |
4477
|
daigle
|
// try to update the inline data
|
894 |
|
|
testdocument = get210TestEmlDoc("InlineDataAccessTest: Doing update",
|
895 |
|
|
testEmlInlineBlock2, null, null, null, getAccessBlock(anotheruser,
|
896 |
|
|
true, true, false, false, false), null, null, null, null);
|
897 |
|
|
Thread.sleep(2000);
|
898 |
|
|
updateDocid(newdocid + ".2", testdocument, FAILURE, true);
|
899 |
2263
|
sgarg
|
|
900 |
4477
|
daigle
|
// try to set the permissions for the inline data
|
901 |
|
|
testdocument = get210TestEmlDoc("InlineDataAccessTest: Doing insert",
|
902 |
|
|
testEmlInlineBlock1, null, null, null, getAccessBlock(anotheruser,
|
903 |
|
|
true, false, false, false, true), null, null, null, null);
|
904 |
|
|
Thread.sleep(2000);
|
905 |
|
|
updateDocid(newdocid + ".2", testdocument, FAILURE, true);
|
906 |
2263
|
sgarg
|
|
907 |
4477
|
daigle
|
// try to delete the document
|
908 |
|
|
deleteDocid(newdocid + ".1", FAILURE, true);
|
909 |
|
|
m.logout();
|
910 |
2263
|
sgarg
|
|
911 |
4477
|
daigle
|
// delete the document
|
912 |
|
|
m.login(username, password);
|
913 |
|
|
deleteDocid(newdocid + ".1", SUCCESS, false);
|
914 |
|
|
m.logout();
|
915 |
2263
|
sgarg
|
|
916 |
4477
|
daigle
|
// ///////Case 2./////////////////////
|
917 |
|
|
// insert an inline document - write only
|
918 |
|
|
m.login(username, password);
|
919 |
|
|
newdocid = generateDocid();
|
920 |
2263
|
sgarg
|
|
921 |
4477
|
daigle
|
// insert a document which gives read access to the inline document
|
922 |
|
|
testdocument = get210TestEmlDoc("InlineDataAccessTest: Doing insert",
|
923 |
|
|
testEmlInlineBlock1, null, null, null, getAccessBlock(anotheruser,
|
924 |
|
|
true, false, true, false, false), null, null, null, null);
|
925 |
|
|
insertDocid(newdocid + ".1", testdocument, SUCCESS, false);
|
926 |
|
|
m.logout();
|
927 |
2263
|
sgarg
|
|
928 |
4477
|
daigle
|
// login as another user
|
929 |
|
|
m.login(anotheruser, anotherpassword);
|
930 |
2263
|
sgarg
|
|
931 |
4477
|
daigle
|
// try to read the document and the inline data
|
932 |
|
|
readDocid(newdocid + ".1", FAILURE, true);
|
933 |
|
|
readInlineDataWhichEqualsDoc(newdocid + ".1.1", testEmlInlineBlock1, FAILURE,
|
934 |
|
|
true);
|
935 |
2263
|
sgarg
|
|
936 |
4477
|
daigle
|
// try to update the inline data
|
937 |
|
|
testdocument = get210TestEmlDoc("InlineDataAccessTest: Doing update",
|
938 |
|
|
testEmlInlineBlock2, null, null, null, getAccessBlock(anotheruser,
|
939 |
|
|
true, false, true, false, false), null, null, null, null);
|
940 |
|
|
Thread.sleep(2000);
|
941 |
|
|
updateDocid(newdocid + ".2", testdocument, SUCCESS, false);
|
942 |
2263
|
sgarg
|
|
943 |
4477
|
daigle
|
// try to set the permissions for the inline data
|
944 |
|
|
testdocument = get210TestEmlDoc("InlineDataAccessTest: Doing insert",
|
945 |
|
|
testEmlInlineBlock1, null, null, null, getAccessBlock(anotheruser,
|
946 |
|
|
true, false, false, false, true), null, null, null, null);
|
947 |
|
|
Thread.sleep(2000);
|
948 |
|
|
updateDocid(newdocid + ".3", testdocument, FAILURE, true);
|
949 |
2263
|
sgarg
|
|
950 |
4477
|
daigle
|
// try to delete the document
|
951 |
|
|
deleteDocid(newdocid + ".2", FAILURE, true);
|
952 |
|
|
m.logout();
|
953 |
2263
|
sgarg
|
|
954 |
4477
|
daigle
|
// delete the document
|
955 |
|
|
m.login(username, password);
|
956 |
|
|
deleteDocid(newdocid + ".2", SUCCESS, false);
|
957 |
|
|
m.logout();
|
958 |
2263
|
sgarg
|
|
959 |
4477
|
daigle
|
// // ///////Case 3./////////////////////
|
960 |
|
|
// // insert an inline document - change permission only
|
961 |
|
|
// m.login(username, password);
|
962 |
|
|
// newdocid = generateDocid();
|
963 |
|
|
//
|
964 |
|
|
// // insert a document which gives read access to the inline document
|
965 |
|
|
// testdocument = get210TestEmlDoc("InlineDataAccessTest: Doing insert",
|
966 |
|
|
// testEmlInlineBlock1, null, null, null, getAccessBlock(anotheruser,
|
967 |
|
|
// true, false, false, true, false), null, null, null, null);
|
968 |
|
|
// insertDocid(newdocid + ".1", testdocument, SUCCESS, false);
|
969 |
|
|
// m.logout();
|
970 |
|
|
//
|
971 |
|
|
// // login as another user
|
972 |
|
|
// m.login(anotheruser, anotherpassword);
|
973 |
|
|
//
|
974 |
|
|
// // try to read the document and the inline data
|
975 |
|
|
// readDocid(newdocid + ".1", FAILURE, true);
|
976 |
|
|
// readInlineDataWhichEqualsDoc(newdocid + ".1.1", testEmlInlineBlock1, FAILURE,
|
977 |
|
|
// true);
|
978 |
|
|
//
|
979 |
|
|
// // try to update the inline data
|
980 |
|
|
// testdocument = get210TestEmlDoc("InlineDataAccessTest: Doing update",
|
981 |
|
|
// testEmlInlineBlock2, null, null, null, getAccessBlock(anotheruser,
|
982 |
|
|
// true, false, false, true, false), null, null, null, null);
|
983 |
|
|
// Thread.sleep(2000);
|
984 |
|
|
// updateDocid(newdocid + ".2", testdocument, FAILURE, true);
|
985 |
|
|
//
|
986 |
|
|
// // try to set the permissions for the inline data
|
987 |
|
|
// testdocument = get210TestEmlDoc("InlineDataAccessTest: Doing insert",
|
988 |
|
|
// testEmlInlineBlock1, null, null, null, getAccessBlock(anotheruser,
|
989 |
|
|
// true, false, false, false, true), null, null, null, null);
|
990 |
|
|
// // ERRRRRRRRRRRR
|
991 |
|
|
// // updateDocid(newdocid + ".2", testdocument, SUCCESS, false);
|
992 |
|
|
//
|
993 |
|
|
// // try to delete the document
|
994 |
|
|
// deleteDocid(newdocid + ".1", FAILURE, true);
|
995 |
|
|
// m.logout();
|
996 |
|
|
//
|
997 |
|
|
// // delete the document
|
998 |
|
|
// m.login(username, password);
|
999 |
|
|
// deleteDocid(newdocid + ".1", SUCCESS, false);
|
1000 |
|
|
// m.logout();
|
1001 |
|
|
//
|
1002 |
|
|
// // ///////Case 4./////////////////////
|
1003 |
|
|
// // insert an inline document - change permission only
|
1004 |
|
|
// m.login(username, password);
|
1005 |
|
|
// newdocid = generateDocid();
|
1006 |
|
|
//
|
1007 |
|
|
// // insert a document which gives read access to the inline document
|
1008 |
|
|
// testdocument = get210TestEmlDoc("InlineDataAccessTest: Doing insert",
|
1009 |
|
|
// testEmlInlineBlock1, null, null, null, getAccessBlock(anotheruser,
|
1010 |
|
|
// true, false, false, false, true), null, null, null, null);
|
1011 |
|
|
// insertDocid(newdocid + ".1", testdocument, SUCCESS, false);
|
1012 |
|
|
// m.logout();
|
1013 |
|
|
//
|
1014 |
|
|
// // login as another user
|
1015 |
|
|
// m.login(anotheruser, anotherpassword);
|
1016 |
|
|
//
|
1017 |
|
|
// // try to read the document and the inline data
|
1018 |
|
|
// readDocid(newdocid + ".1", SUCCESS, false);
|
1019 |
|
|
// readInlineDataWhichEqualsDoc(newdocid + ".1.1", testEmlInlineBlock1, SUCCESS,
|
1020 |
|
|
// false);
|
1021 |
|
|
//
|
1022 |
|
|
// // try to update the inline data
|
1023 |
|
|
// testdocument = get210TestEmlDoc("InlineDataAccessTest: Doing update",
|
1024 |
|
|
// testEmlInlineBlock2, null, null, null, getAccessBlock(anotheruser,
|
1025 |
|
|
// true, false, false, false, true), null, null, null, null);
|
1026 |
|
|
// Thread.sleep(2000);
|
1027 |
|
|
// updateDocid(newdocid + ".2", testdocument, SUCCESS, false);
|
1028 |
|
|
//
|
1029 |
|
|
// // try to set the permissions for the inline data
|
1030 |
|
|
// testdocument = get210TestEmlDoc("InlineDataAccessTest: Doing insert",
|
1031 |
|
|
// testEmlInlineBlock1, null, null, null, getAccessBlock(anotheruser,
|
1032 |
|
|
// true, true, true, true, false), null, null, null, null);
|
1033 |
|
|
// Thread.sleep(2000);
|
1034 |
|
|
// updateDocid(newdocid + ".3", testdocument, SUCCESS, false);
|
1035 |
|
|
//
|
1036 |
|
|
// // try to delete the document
|
1037 |
|
|
// // sleep needed only in case of inline data - jing said that
|
1038 |
|
|
// // somehow the thread writing data to xml_index takes too much time
|
1039 |
|
|
// // when used with inline data. hence if delete is requested too soon
|
1040 |
|
|
// // database gives an error of xml_index records left with FK to
|
1041 |
|
|
// // xml_document record which is going to be deleted.
|
1042 |
|
|
// Thread.sleep(10000);
|
1043 |
|
|
//
|
1044 |
|
|
// deleteDocid(newdocid + ".3", SUCCESS, false);
|
1045 |
|
|
// m.logout();
|
1046 |
2263
|
sgarg
|
|
1047 |
4477
|
daigle
|
} catch (MetacatAuthException mae) {
|
1048 |
|
|
fail("Authorization failed:\n" + mae.getMessage());
|
1049 |
|
|
} catch (MetacatInaccessibleException mie) {
|
1050 |
|
|
fail("Metacat Inaccessible:\n" + mie.getMessage());
|
1051 |
|
|
} catch (Exception e) {
|
1052 |
|
|
fail("General exception:\n" + e.getMessage());
|
1053 |
|
|
}
|
1054 |
|
|
}
|
1055 |
2263
|
sgarg
|
|
1056 |
4477
|
daigle
|
/***************************************************************************
|
1057 |
|
|
* For EML 2.0.1, checking the following cases: when only Inline data is
|
1058 |
|
|
* uploaded by a user with the following different access controls specified
|
1059 |
|
|
* in addiotnal metadata in another document 1.read 2.write 3.change permission
|
1060 |
|
|
* 4.all And another user tries to do the following: -> tries to read it ->
|
1061 |
|
|
* tries to update it -> tries to set permissions on it -> tries to delete it
|
1062 |
|
|
*/
|
1063 |
|
|
public void inlineData201CasesTest_4() {
|
1064 |
|
|
debug("\nRunning: inlineData201CasesTest_4()");
|
1065 |
|
|
try {
|
1066 |
|
|
// ///////Case 1./////////////////////
|
1067 |
|
|
// insert an inline document - read only
|
1068 |
|
|
m.login(username, password);
|
1069 |
|
|
newdocid = generateDocid();
|
1070 |
|
|
|
1071 |
|
|
// insert a document which gives read access to the inline document
|
1072 |
|
|
testdocument = get201TestEmlDoc("InlineDataAccessTest: Doing insert",
|
1073 |
|
|
testEmlInlineBlock1, null, null, null, null, getAccessBlock(
|
1074 |
|
|
anotheruser, true, true, false, false, false), null, null,
|
1075 |
|
|
null);
|
1076 |
|
|
insertDocid(newdocid + ".1", testdocument, SUCCESS, false);
|
1077 |
|
|
m.logout();
|
1078 |
|
|
|
1079 |
|
|
// login as another user
|
1080 |
|
|
m.login(anotheruser, anotherpassword);
|
1081 |
|
|
|
1082 |
|
|
// try to read the document and the inline data
|
1083 |
|
|
readDocid(newdocid + ".1", FAILURE, true);
|
1084 |
|
|
// ERRRRRRRRRRRRRRR
|
1085 |
|
|
readInlineDataWhichEqualsDoc(newdocid + ".1.1", testEmlInlineBlock1, FAILURE,
|
1086 |
|
|
true);
|
1087 |
|
|
|
1088 |
|
|
// try to update the inline data
|
1089 |
|
|
testdocument = get201TestEmlDoc("InlineDataAccessTest: Doing update",
|
1090 |
|
|
testEmlInlineBlock2, null, null, null, null, getAccessBlock(
|
1091 |
|
|
anotheruser, true, true, false, false, false), null, null,
|
1092 |
|
|
null);
|
1093 |
|
|
updateDocid(newdocid + ".2", testdocument, FAILURE, true);
|
1094 |
|
|
|
1095 |
|
|
// try to set the permissions for the inline data
|
1096 |
|
|
testdocument = get201TestEmlDoc("InlineDataAccessTest: Doing insert",
|
1097 |
|
|
testEmlInlineBlock1, null, null, null, null, getAccessBlock(
|
1098 |
|
|
anotheruser, true, false, false, false, true), null, null,
|
1099 |
|
|
null);
|
1100 |
|
|
updateDocid(newdocid + ".2", testdocument, FAILURE, true);
|
1101 |
|
|
|
1102 |
|
|
// try to delete the document
|
1103 |
|
|
deleteDocid(newdocid + ".1", FAILURE, true);
|
1104 |
|
|
m.logout();
|
1105 |
|
|
|
1106 |
|
|
// delete the document
|
1107 |
|
|
m.login(username, password);
|
1108 |
|
|
deleteDocid(newdocid + ".1", SUCCESS, false);
|
1109 |
|
|
m.logout();
|
1110 |
|
|
|
1111 |
|
|
// ///////Case 2./////////////////////
|
1112 |
|
|
// insert an inline document - write only
|
1113 |
|
|
m.login(username, password);
|
1114 |
|
|
newdocid = generateDocid();
|
1115 |
|
|
|
1116 |
|
|
// insert a document which gives read access to the inline document
|
1117 |
|
|
testdocument = get201TestEmlDoc("InlineDataAccessTest: Doing insert",
|
1118 |
|
|
testEmlInlineBlock1, null, null, null, null, getAccessBlock(
|
1119 |
|
|
anotheruser, true, false, true, false, false), null, null,
|
1120 |
|
|
null);
|
1121 |
|
|
insertDocid(newdocid + ".1", testdocument, SUCCESS, false);
|
1122 |
|
|
m.logout();
|
1123 |
|
|
|
1124 |
|
|
// login as another user
|
1125 |
|
|
m.login(anotheruser, anotherpassword);
|
1126 |
|
|
|
1127 |
|
|
// try to read the document and the inline data
|
1128 |
|
|
readDocid(newdocid + ".1", FAILURE, true);
|
1129 |
|
|
readInlineDataWhichEqualsDoc(newdocid + ".1.1", testEmlInlineBlock1, FAILURE,
|
1130 |
|
|
true);
|
1131 |
|
|
|
1132 |
|
|
// try to update the inline data
|
1133 |
|
|
testdocument = get201TestEmlDoc("InlineDataAccessTest: Doing update",
|
1134 |
|
|
testEmlInlineBlock2, null, null, null, null, getAccessBlock(
|
1135 |
|
|
anotheruser, true, false, true, false, false), null, null,
|
1136 |
|
|
null);
|
1137 |
|
|
// ERRRRRRRRRRRRRRRRRRRRRRRR
|
1138 |
|
|
// updateDocid(newdocid + ".2", testdocument, SUCCESS, false);
|
1139 |
|
|
|
1140 |
|
|
// try to set the permissions for the inline data
|
1141 |
|
|
testdocument = get201TestEmlDoc("InlineDataAccessTest: Doing insert",
|
1142 |
|
|
testEmlInlineBlock1, null, null, null, null, getAccessBlock(
|
1143 |
|
|
anotheruser, true, false, false, false, true), null, null,
|
1144 |
|
|
null);
|
1145 |
|
|
updateDocid(newdocid + ".2", testdocument, FAILURE, true);
|
1146 |
|
|
|
1147 |
|
|
// try to delete the document
|
1148 |
|
|
deleteDocid(newdocid + ".1", FAILURE, true);
|
1149 |
|
|
m.logout();
|
1150 |
|
|
|
1151 |
|
|
// delete the document
|
1152 |
|
|
m.login(username, password);
|
1153 |
|
|
deleteDocid(newdocid + ".1", SUCCESS, false);
|
1154 |
|
|
m.logout();
|
1155 |
|
|
|
1156 |
|
|
// ///////Case 3./////////////////////
|
1157 |
|
|
// insert an inline document - change permission only
|
1158 |
|
|
m.login(username, password);
|
1159 |
|
|
newdocid = generateDocid();
|
1160 |
|
|
|
1161 |
|
|
// insert a document which gives read access to the inline document
|
1162 |
|
|
testdocument = get201TestEmlDoc("InlineDataAccessTest: Doing insert",
|
1163 |
|
|
testEmlInlineBlock1, null, null, null, null, getAccessBlock(
|
1164 |
|
|
anotheruser, true, false, false, true, false), null, null,
|
1165 |
|
|
null);
|
1166 |
|
|
insertDocid(newdocid + ".1", testdocument, SUCCESS, false);
|
1167 |
|
|
m.logout();
|
1168 |
|
|
|
1169 |
|
|
// login as another user
|
1170 |
|
|
m.login(anotheruser, anotherpassword);
|
1171 |
|
|
|
1172 |
|
|
// try to read the document and the inline data
|
1173 |
|
|
readDocid(newdocid + ".1", FAILURE, true);
|
1174 |
|
|
readInlineDataWhichEqualsDoc(newdocid + ".1.1", testEmlInlineBlock1, FAILURE,
|
1175 |
|
|
true);
|
1176 |
|
|
|
1177 |
|
|
// try to update the inline data
|
1178 |
|
|
testdocument = get201TestEmlDoc("InlineDataAccessTest: Doing update",
|
1179 |
|
|
testEmlInlineBlock2, null, null, null, null, getAccessBlock(
|
1180 |
|
|
anotheruser, true, false, false, true, false), null, null,
|
1181 |
|
|
null);
|
1182 |
|
|
updateDocid(newdocid + ".2", testdocument, FAILURE, true);
|
1183 |
|
|
|
1184 |
|
|
// try to set the permissions for the inline data
|
1185 |
|
|
testdocument = get201TestEmlDoc("InlineDataAccessTest: Doing insert",
|
1186 |
|
|
testEmlInlineBlock1, null, null, null, null, getAccessBlock(
|
1187 |
|
|
anotheruser, true, false, false, false, true), null, null,
|
1188 |
|
|
null);
|
1189 |
|
|
// ERRRRRRRRRRRR
|
1190 |
|
|
// updateDocid(newdocid + ".2", testdocument, SUCCESS, false);
|
1191 |
|
|
|
1192 |
|
|
// try to delete the document
|
1193 |
|
|
deleteDocid(newdocid + ".1", FAILURE, true);
|
1194 |
|
|
m.logout();
|
1195 |
|
|
|
1196 |
|
|
// delete the document
|
1197 |
|
|
m.login(username, password);
|
1198 |
|
|
deleteDocid(newdocid + ".1", SUCCESS, false);
|
1199 |
|
|
m.logout();
|
1200 |
|
|
|
1201 |
|
|
// ///////Case 4./////////////////////
|
1202 |
|
|
// insert an inline document - change permission only
|
1203 |
|
|
m.login(username, password);
|
1204 |
|
|
newdocid = generateDocid();
|
1205 |
|
|
|
1206 |
|
|
// insert a document which gives read access to the inline document
|
1207 |
|
|
testdocument = get201TestEmlDoc("InlineDataAccessTest: Doing insert",
|
1208 |
|
|
testEmlInlineBlock1, null, null, null, null, getAccessBlock(
|
1209 |
|
|
anotheruser, true, false, false, false, true), null, null,
|
1210 |
|
|
null);
|
1211 |
|
|
insertDocid(newdocid + ".1", testdocument, SUCCESS, false);
|
1212 |
|
|
m.logout();
|
1213 |
|
|
|
1214 |
|
|
// login as another user
|
1215 |
|
|
m.login(anotheruser, anotherpassword);
|
1216 |
|
|
|
1217 |
|
|
// try to read the document and the inline data
|
1218 |
|
|
readDocid(newdocid + ".1", FAILURE, true);
|
1219 |
|
|
// ERRRRRRRRRRRRRRR
|
1220 |
|
|
// readInlineDataWhichEqualsDoc(newdocid + ".1.1",
|
1221 |
|
|
// testEmlInlineBlock1, SUCCESS, false);
|
1222 |
|
|
|
1223 |
|
|
// try to update the inline data
|
1224 |
|
|
testdocument = get201TestEmlDoc("InlineDataAccessTest: Doing update",
|
1225 |
|
|
testEmlInlineBlock2, null, null, null, null, getAccessBlock(
|
1226 |
|
|
anotheruser, true, false, false, false, true), null, null,
|
1227 |
|
|
null);
|
1228 |
|
|
// ERRRRRR
|
1229 |
|
|
// updateDocid(newdocid + ".2", testdocument, SUCCESS, false);
|
1230 |
|
|
|
1231 |
|
|
// try to set the permissions for the inline data
|
1232 |
|
|
testdocument = get201TestEmlDoc("InlineDataAccessTest: Doing insert",
|
1233 |
|
|
testEmlInlineBlock1, null, null, null, null, getAccessBlock(
|
1234 |
|
|
anotheruser, true, true, true, true, false), null, null, null);
|
1235 |
|
|
// ERRRRRRRRRR
|
1236 |
|
|
// updateDocid(newdocid + ".3", testdocument, SUCCESS, false);
|
1237 |
|
|
|
1238 |
|
|
// try to delete the document
|
1239 |
|
|
deleteDocid(newdocid + ".3", FAILURE, true);
|
1240 |
|
|
m.logout();
|
1241 |
|
|
|
1242 |
|
|
// delete the document
|
1243 |
|
|
m.login(username, password);
|
1244 |
|
|
deleteDocid(newdocid + ".1", SUCCESS, false);
|
1245 |
|
|
m.logout();
|
1246 |
|
|
|
1247 |
|
|
} catch (MetacatAuthException mae) {
|
1248 |
|
|
fail("Authorization failed:\n" + mae.getMessage());
|
1249 |
|
|
} catch (MetacatInaccessibleException mie) {
|
1250 |
|
|
fail("Metacat Inaccessible:\n" + mie.getMessage());
|
1251 |
|
|
} catch (Exception e) {
|
1252 |
|
|
fail("General exception:\n" + e.getMessage());
|
1253 |
|
|
}
|
1254 |
|
|
}
|
1255 |
|
|
|
1256 |
|
|
/***************************************************************************
|
1257 |
|
|
* For EML 2.1.0, checking the following cases: when only Inline data is
|
1258 |
|
|
* uploaded by a user with the following different access controls specified
|
1259 |
|
|
* in addiotnal metadata in another document 1.read 2.write 3.change permission
|
1260 |
|
|
* 4.all And another user tries to do the following: -> tries to read it ->
|
1261 |
|
|
* tries to update it -> tries to set permissions on it -> tries to delete it
|
1262 |
|
|
*/
|
1263 |
|
|
public void inlineData210CasesTest_4() {
|
1264 |
|
|
debug("\nRunning: inlineData210CasesTest_4()");
|
1265 |
|
|
try {
|
1266 |
|
|
// ///////Case 1./////////////////////
|
1267 |
|
|
// insert an inline document - read only
|
1268 |
|
|
m.login(username, password);
|
1269 |
|
|
newdocid = generateDocid();
|
1270 |
|
|
|
1271 |
|
|
// insert a document which gives read access to the inline document
|
1272 |
|
|
testdocument = get210TestEmlDoc("InlineDataAccessTest: Doing insert",
|
1273 |
|
|
testEmlInlineBlock1, null, null, null, null, getAccessBlock(
|
1274 |
|
|
anotheruser, true, true, false, false, false), null, null,
|
1275 |
|
|
null);
|
1276 |
|
|
debug("testdocument: " + testdocument);
|
1277 |
|
|
insertDocid(newdocid + ".1", testdocument, SUCCESS, false);
|
1278 |
|
|
m.logout();
|
1279 |
|
|
|
1280 |
|
|
// login as another user
|
1281 |
|
|
m.login(anotheruser, anotherpassword);
|
1282 |
|
|
|
1283 |
|
|
// try to read the document and the inline data
|
1284 |
|
|
readDocid(newdocid + ".1", FAILURE, true);
|
1285 |
|
|
// ERRRRRRRRRRRRRRR
|
1286 |
|
|
readInlineDataWhichEqualsDoc(newdocid + ".1.1", testEmlInlineBlock1, FAILURE,
|
1287 |
|
|
true);
|
1288 |
|
|
|
1289 |
|
|
// try to update the inline data
|
1290 |
|
|
testdocument = get210TestEmlDoc("InlineDataAccessTest: Doing update",
|
1291 |
|
|
testEmlInlineBlock2, null, null, null, null, getAccessBlock(
|
1292 |
|
|
anotheruser, true, true, false, false, false), null, null,
|
1293 |
|
|
null);
|
1294 |
|
|
Thread.sleep(2000);
|
1295 |
|
|
updateDocid(newdocid + ".2", testdocument, FAILURE, true);
|
1296 |
|
|
|
1297 |
|
|
// try to set the permissions for the inline data
|
1298 |
|
|
testdocument = get210TestEmlDoc("InlineDataAccessTest: Doing insert",
|
1299 |
|
|
testEmlInlineBlock1, null, null, null, null, getAccessBlock(
|
1300 |
|
|
anotheruser, true, false, false, false, true), null, null,
|
1301 |
|
|
null);
|
1302 |
|
|
Thread.sleep(2000);
|
1303 |
|
|
updateDocid(newdocid + ".2", testdocument, FAILURE, true);
|
1304 |
|
|
|
1305 |
|
|
// try to delete the document
|
1306 |
|
|
deleteDocid(newdocid + ".1", FAILURE, true);
|
1307 |
|
|
m.logout();
|
1308 |
|
|
|
1309 |
|
|
// delete the document
|
1310 |
|
|
m.login(username, password);
|
1311 |
|
|
deleteDocid(newdocid + ".1", SUCCESS, false);
|
1312 |
|
|
m.logout();
|
1313 |
|
|
|
1314 |
|
|
// ///////Case 2./////////////////////
|
1315 |
|
|
// insert an inline document - write only
|
1316 |
|
|
m.login(username, password);
|
1317 |
|
|
newdocid = generateDocid();
|
1318 |
|
|
|
1319 |
|
|
// insert a document which gives read access to the inline document
|
1320 |
|
|
testdocument = get210TestEmlDoc("InlineDataAccessTest: Doing insert",
|
1321 |
|
|
testEmlInlineBlock1, null, null, null, null, getAccessBlock(
|
1322 |
|
|
anotheruser, true, false, true, false, false), null, null,
|
1323 |
|
|
null);
|
1324 |
|
|
insertDocid(newdocid + ".1", testdocument, SUCCESS, false);
|
1325 |
|
|
m.logout();
|
1326 |
|
|
|
1327 |
|
|
// login as another user
|
1328 |
|
|
m.login(anotheruser, anotherpassword);
|
1329 |
|
|
|
1330 |
|
|
// try to read the document and the inline data
|
1331 |
|
|
readDocid(newdocid + ".1", FAILURE, true);
|
1332 |
|
|
readInlineDataWhichEqualsDoc(newdocid + ".1.1", testEmlInlineBlock1, FAILURE,
|
1333 |
|
|
true);
|
1334 |
|
|
|
1335 |
|
|
// try to update the inline data
|
1336 |
|
|
testdocument = get210TestEmlDoc("InlineDataAccessTest: Doing update",
|
1337 |
|
|
testEmlInlineBlock2, null, null, null, null, getAccessBlock(
|
1338 |
|
|
anotheruser, true, false, true, false, false), null, null,
|
1339 |
|
|
null);
|
1340 |
|
|
// ERRRRRRRRRRRRRRRRRRRRRRRR
|
1341 |
|
|
// updateDocid(newdocid + ".2", testdocument, SUCCESS, false);
|
1342 |
|
|
|
1343 |
|
|
// try to set the permissions for the inline data
|
1344 |
|
|
testdocument = get210TestEmlDoc("InlineDataAccessTest: Doing insert",
|
1345 |
|
|
testEmlInlineBlock1, null, null, null, null, getAccessBlock(
|
1346 |
|
|
anotheruser, true, false, false, false, true), null, null,
|
1347 |
|
|
null);
|
1348 |
|
|
Thread.sleep(2000);
|
1349 |
|
|
updateDocid(newdocid + ".2", testdocument, FAILURE, true);
|
1350 |
|
|
|
1351 |
|
|
// try to delete the document
|
1352 |
|
|
deleteDocid(newdocid + ".1", FAILURE, true);
|
1353 |
|
|
m.logout();
|
1354 |
|
|
|
1355 |
|
|
// delete the document
|
1356 |
|
|
m.login(username, password);
|
1357 |
|
|
deleteDocid(newdocid + ".1", SUCCESS, false);
|
1358 |
|
|
m.logout();
|
1359 |
|
|
|
1360 |
|
|
// ///////Case 3./////////////////////
|
1361 |
|
|
// insert an inline document - change permission only
|
1362 |
|
|
m.login(username, password);
|
1363 |
|
|
newdocid = generateDocid();
|
1364 |
|
|
|
1365 |
|
|
// insert a document which gives read access to the inline document
|
1366 |
|
|
testdocument = get210TestEmlDoc("InlineDataAccessTest: Doing insert",
|
1367 |
|
|
testEmlInlineBlock1, null, null, null, null, getAccessBlock(
|
1368 |
|
|
anotheruser, true, false, false, true, false), null, null,
|
1369 |
|
|
null);
|
1370 |
|
|
insertDocid(newdocid + ".1", testdocument, SUCCESS, false);
|
1371 |
|
|
m.logout();
|
1372 |
|
|
|
1373 |
|
|
// login as another user
|
1374 |
|
|
m.login(anotheruser, anotherpassword);
|
1375 |
|
|
|
1376 |
|
|
// try to read the document and the inline data
|
1377 |
|
|
readDocid(newdocid + ".1", FAILURE, true);
|
1378 |
|
|
readInlineDataWhichEqualsDoc(newdocid + ".1.1", testEmlInlineBlock1, FAILURE,
|
1379 |
|
|
true);
|
1380 |
|
|
|
1381 |
|
|
// try to update the inline data
|
1382 |
|
|
testdocument = get210TestEmlDoc("InlineDataAccessTest: Doing update",
|
1383 |
|
|
testEmlInlineBlock2, null, null, null, null, getAccessBlock(
|
1384 |
|
|
anotheruser, true, false, false, true, false), null, null,
|
1385 |
|
|
null);
|
1386 |
|
|
Thread.sleep(2000);
|
1387 |
|
|
updateDocid(newdocid + ".2", testdocument, FAILURE, true);
|
1388 |
|
|
|
1389 |
|
|
// try to set the permissions for the inline data
|
1390 |
|
|
testdocument = get210TestEmlDoc("InlineDataAccessTest: Doing insert",
|
1391 |
|
|
testEmlInlineBlock1, null, null, null, null, getAccessBlock(
|
1392 |
|
|
anotheruser, true, false, false, false, true), null, null,
|
1393 |
|
|
null);
|
1394 |
|
|
// ERRRRRRRRRRRR
|
1395 |
|
|
// updateDocid(newdocid + ".2", testdocument, SUCCESS, false);
|
1396 |
|
|
|
1397 |
|
|
// try to delete the document
|
1398 |
|
|
deleteDocid(newdocid + ".1", FAILURE, true);
|
1399 |
|
|
m.logout();
|
1400 |
|
|
|
1401 |
|
|
// delete the document
|
1402 |
|
|
m.login(username, password);
|
1403 |
|
|
deleteDocid(newdocid + ".1", SUCCESS, false);
|
1404 |
|
|
m.logout();
|
1405 |
|
|
|
1406 |
|
|
// ///////Case 4./////////////////////
|
1407 |
|
|
// insert an inline document - change permission only
|
1408 |
|
|
m.login(username, password);
|
1409 |
|
|
newdocid = generateDocid();
|
1410 |
|
|
|
1411 |
|
|
// insert a document which gives read access to the inline document
|
1412 |
|
|
testdocument = get210TestEmlDoc("InlineDataAccessTest: Doing insert",
|
1413 |
|
|
testEmlInlineBlock1, null, null, null, null, getAccessBlock(
|
1414 |
|
|
anotheruser, true, false, false, false, true), null, null,
|
1415 |
|
|
null);
|
1416 |
|
|
insertDocid(newdocid + ".1", testdocument, SUCCESS, false);
|
1417 |
|
|
m.logout();
|
1418 |
|
|
|
1419 |
|
|
// login as another user
|
1420 |
|
|
m.login(anotheruser, anotherpassword);
|
1421 |
|
|
|
1422 |
|
|
// try to read the document and the inline data
|
1423 |
|
|
readDocid(newdocid + ".1", FAILURE, true);
|
1424 |
|
|
// ERRRRRRRRRRRRRRR
|
1425 |
|
|
// readInlineDataWhichEqualsDoc(newdocid + ".1.1",
|
1426 |
|
|
// testEmlInlineBlock1, SUCCESS, false);
|
1427 |
|
|
|
1428 |
|
|
// try to update the inline data
|
1429 |
|
|
testdocument = get210TestEmlDoc("InlineDataAccessTest: Doing update",
|
1430 |
|
|
testEmlInlineBlock2, null, null, null, null, getAccessBlock(
|
1431 |
|
|
anotheruser, true, false, false, false, true), null, null,
|
1432 |
|
|
null);
|
1433 |
|
|
// ERRRRRR
|
1434 |
|
|
// updateDocid(newdocid + ".2", testdocument, SUCCESS, false);
|
1435 |
|
|
|
1436 |
|
|
// try to set the permissions for the inline data
|
1437 |
|
|
testdocument = get210TestEmlDoc("InlineDataAccessTest: Doing insert",
|
1438 |
|
|
testEmlInlineBlock1, null, null, null, null, getAccessBlock(
|
1439 |
|
|
anotheruser, true, true, true, true, false), null, null, null);
|
1440 |
|
|
// ERRRRRRRRRR
|
1441 |
|
|
// updateDocid(newdocid + ".3", testdocument, SUCCESS, false);
|
1442 |
|
|
|
1443 |
|
|
// try to delete the document
|
1444 |
|
|
deleteDocid(newdocid + ".3", FAILURE, true);
|
1445 |
|
|
m.logout();
|
1446 |
|
|
|
1447 |
|
|
// delete the document
|
1448 |
|
|
m.login(username, password);
|
1449 |
|
|
deleteDocid(newdocid + ".1", SUCCESS, false);
|
1450 |
|
|
m.logout();
|
1451 |
|
|
|
1452 |
|
|
} catch (MetacatAuthException mae) {
|
1453 |
|
|
fail("Authorization failed:\n" + mae.getMessage());
|
1454 |
|
|
} catch (MetacatInaccessibleException mie) {
|
1455 |
|
|
fail("Metacat Inaccessible:\n" + mie.getMessage());
|
1456 |
|
|
} catch (Exception e) {
|
1457 |
|
|
fail("General exception:\n" + e.getMessage());
|
1458 |
|
|
}
|
1459 |
|
|
}
|
1460 |
|
|
|
1461 |
|
|
/***************************************************************************
|
1462 |
|
|
* For EML 2.0.1, checking the following cases: -> when no inline data is
|
1463 |
|
|
* specified in the document but rules are specified in additional metadata ->
|
1464 |
|
|
* when a user has RW permission for inline data, can he delete it -> when
|
1465 |
|
|
* inline data with document refering to it is uploaded with read access for
|
1466 |
|
|
* metadata and no access for data
|
1467 |
|
|
*/
|
1468 |
|
|
public void inlineData201CasesTest_5() {
|
1469 |
4339
|
daigle
|
debug("\nRunning: inlineDataCasesTest_5()");
|
1470 |
4477
|
daigle
|
try {
|
1471 |
2263
|
sgarg
|
|
1472 |
4477
|
daigle
|
// m.login(username, password);
|
1473 |
|
|
//
|
1474 |
|
|
// /////////Case 1
|
1475 |
|
|
// debug("Case 1:");
|
1476 |
|
|
// testdocument = get201TestEmlDoc("InlineDataAccessTest: Doing insert",
|
1477 |
|
|
// null, null, null, null, null, getAccessBlock(anotheruser, true, true,
|
1478 |
|
|
// false, false, false), null, null, null);
|
1479 |
|
|
// newdocid = generateDocid();
|
1480 |
|
|
//
|
1481 |
|
|
// // try to insert the wrong document. This document is wrong because
|
1482 |
|
|
// // it has an access block but no distribution.
|
1483 |
|
|
// insertDocid(newdocid + ".1", testdocument, FAILURE, false);
|
1484 |
|
|
// m.logout();
|
1485 |
|
|
//
|
1486 |
|
|
// /////////Case 2
|
1487 |
|
|
// debug("Case 2:");
|
1488 |
|
|
// m.login(username, password);
|
1489 |
|
|
// testdocument = get201TestEmlDoc("InlineDataAccessTest: Doing insert",
|
1490 |
|
|
// testEmlInlineBlock1, null, null, null, getAccessBlock(anotheruser,
|
1491 |
|
|
// true, true, true, false, false), null, null, null, null);
|
1492 |
|
|
// newdocid = generateDocid();
|
1493 |
|
|
// insertDocid(newdocid + ".1", testdocument, SUCCESS, false);
|
1494 |
|
|
// m.logout();
|
1495 |
|
|
//
|
1496 |
|
|
// m.login(anotheruser, anotherpassword);
|
1497 |
|
|
// testdocument = get201TestEmlDoc("InlineDataAccessTest: Doing insert",
|
1498 |
|
|
// null, null, null, null, getAccessBlock(anotheruser, true, true, true,
|
1499 |
|
|
// false, false), null, null, null, null);
|
1500 |
|
|
// /// ERRRRRRRRRRRR
|
1501 |
|
|
// Thread.sleep(2000);
|
1502 |
|
|
// updateDocid(newdocid + ".2", testdocument, SUCCESS, false);
|
1503 |
2263
|
sgarg
|
|
1504 |
4477
|
daigle
|
/////////Case 3
|
1505 |
|
|
debug("Case 3:");
|
1506 |
|
|
// insert a document
|
1507 |
|
|
m.login(username, password);
|
1508 |
|
|
testdocument = get201TestEmlDoc("InlineDataAccessTest: Doing insert",
|
1509 |
|
|
testEmlInlineBlock1, null, null, null, getAccessBlock(anotheruser,
|
1510 |
|
|
true, false, false, false, true), getAccessBlock(anotheruser,
|
1511 |
|
|
false, false, false, false, true), null, null, null);
|
1512 |
|
|
newdocid = generateDocid();
|
1513 |
|
|
insertDocid(newdocid + ".1", testdocument, SUCCESS, false);
|
1514 |
|
|
m.logout();
|
1515 |
2263
|
sgarg
|
|
1516 |
4477
|
daigle
|
// try to read the Inline data
|
1517 |
|
|
m.login(anotheruser, anotherpassword);
|
1518 |
|
|
testdocument = get201TestEmlDoc("InlineDataAccessTest: Doing insert",
|
1519 |
|
|
"", null, null, null, getAccessBlock(anotheruser, true, false, false,
|
1520 |
|
|
false, true), getAccessBlock(anotheruser, false, false,
|
1521 |
|
|
false, false, true), null, null, null);
|
1522 |
|
|
readDocidWhichEqualsDoc(newdocid + ".1", testdocument, SUCCESS, false);
|
1523 |
2263
|
sgarg
|
|
1524 |
4477
|
daigle
|
// try to update the rules for inline data
|
1525 |
|
|
// / ERRRRRRRRRRRR it lets you do that
|
1526 |
|
|
testdocument = get201TestEmlDoc("InlineDataAccessTest: Doing insert",
|
1527 |
|
|
testEmlInlineBlock1, null, null, null, getAccessBlock(anotheruser,
|
1528 |
|
|
true, false, false, false, true), getAccessBlock(anotheruser,
|
1529 |
|
|
true, false, false, false, true), null, null, null);
|
1530 |
|
|
Thread.sleep(2000);
|
1531 |
|
|
updateDocid(newdocid + ".2", testdocument, SUCCESS, false);
|
1532 |
|
|
readDocidWhichEqualsDoc(newdocid + ".2", testdocument, SUCCESS, false);
|
1533 |
2263
|
sgarg
|
|
1534 |
4477
|
daigle
|
m.logout();
|
1535 |
|
|
} catch (MetacatAuthException mae) {
|
1536 |
|
|
fail("Authorization failed:\n" + mae.getMessage());
|
1537 |
|
|
} catch (MetacatInaccessibleException mie) {
|
1538 |
|
|
fail("Metacat Inaccessible:\n" + mie.getMessage());
|
1539 |
|
|
} catch (Exception e) {
|
1540 |
|
|
fail("General exception:\n" + e.getMessage());
|
1541 |
|
|
}
|
1542 |
|
|
}
|
1543 |
|
|
|
1544 |
|
|
/***************************************************************************
|
1545 |
|
|
* For EML 2.1.0, checking the following cases: -> when no inline data is
|
1546 |
|
|
* specified in the document but rules are specified in additional metadata ->
|
1547 |
|
|
* when a user has RW permission for inline data, can he delete it -> when
|
1548 |
|
|
* inline data with document refering to it is uploaded with read access for
|
1549 |
|
|
* metadata and no access for data
|
1550 |
|
|
*/
|
1551 |
|
|
public void inlineData210CasesTest_5() {
|
1552 |
|
|
debug("\nRunning: inlineDataCasesTest_5()");
|
1553 |
|
|
try {
|
1554 |
2263
|
sgarg
|
|
1555 |
4477
|
daigle
|
// Removed test case 1 since there is no way to create a document in
|
1556 |
|
|
// 2.1.0 that has a distribution access element without the distritribution
|
1557 |
|
|
// section.
|
1558 |
|
|
// m.login(username, password);
|
1559 |
|
|
//
|
1560 |
|
|
// /////////Case 1
|
1561 |
|
|
// debug("Case 1:");
|
1562 |
|
|
// testdocument = get210TestEmlDoc("InlineDataAccessTest: Doing insert",
|
1563 |
|
|
// null, null, null, null, null, getAccessBlock(anotheruser, true, true,
|
1564 |
|
|
// false, false, false), null, null, null);
|
1565 |
|
|
// newdocid = generateDocid();
|
1566 |
|
|
//
|
1567 |
|
|
// // try to insert the wrong document
|
1568 |
|
|
// insertDocid(newdocid + ".1", testdocument, FAILURE, false);
|
1569 |
|
|
// m.logout();
|
1570 |
2263
|
sgarg
|
|
1571 |
4477
|
daigle
|
/////////Case 2
|
1572 |
|
|
debug("Case 2:");
|
1573 |
|
|
m.login(username, password);
|
1574 |
|
|
testdocument = get210TestEmlDoc("InlineDataAccessTest: Doing insert",
|
1575 |
|
|
testEmlInlineBlock1, null, null, null, getAccessBlock(anotheruser,
|
1576 |
|
|
true, true, true, false, false), null, null, null, null);
|
1577 |
|
|
newdocid = generateDocid();
|
1578 |
|
|
insertDocid(newdocid + ".1", testdocument, SUCCESS, false);
|
1579 |
|
|
m.logout();
|
1580 |
2263
|
sgarg
|
|
1581 |
4477
|
daigle
|
m.login(anotheruser, anotherpassword);
|
1582 |
|
|
testdocument = get210TestEmlDoc("InlineDataAccessTest: Doing insert",
|
1583 |
|
|
null, null, null, null, getAccessBlock(anotheruser, true, true, true,
|
1584 |
|
|
false, false), null, null, null, null);
|
1585 |
|
|
/// ERRRRRRRRRRRR
|
1586 |
|
|
Thread.sleep(2000);
|
1587 |
|
|
updateDocid(newdocid + ".2", testdocument, SUCCESS, false);
|
1588 |
2263
|
sgarg
|
|
1589 |
4477
|
daigle
|
/////////Case 3
|
1590 |
|
|
debug("Case 3:");
|
1591 |
|
|
// insert a document
|
1592 |
|
|
m.login(username, password);
|
1593 |
|
|
testdocument = get210TestEmlDoc("InlineDataAccessTest: Doing insert",
|
1594 |
|
|
testEmlInlineBlock1, null, null, null, getAccessBlock(anotheruser,
|
1595 |
|
|
true, false, false, false, true), getAccessBlock(anotheruser,
|
1596 |
|
|
false, false, false, false, true), null, null, null);
|
1597 |
|
|
newdocid = generateDocid();
|
1598 |
|
|
insertDocid(newdocid + ".1", testdocument, SUCCESS, false);
|
1599 |
|
|
m.logout();
|
1600 |
2263
|
sgarg
|
|
1601 |
4477
|
daigle
|
// try to read the Inline data
|
1602 |
|
|
m.login(anotheruser, anotherpassword);
|
1603 |
|
|
testdocument = get210TestEmlDoc("InlineDataAccessTest: Doing insert",
|
1604 |
|
|
"", null, null, null, getAccessBlock(anotheruser, true, false, false,
|
1605 |
|
|
false, true), getAccessBlock(anotheruser, false, false,
|
1606 |
|
|
false, false, true), null, null, null);
|
1607 |
|
|
readDocidWhichEqualsDoc(newdocid + ".1", testdocument, SUCCESS, false);
|
1608 |
2263
|
sgarg
|
|
1609 |
4477
|
daigle
|
// try to update the rules for inline data
|
1610 |
|
|
// / ERRRRRRRRRRRR it lets you do that
|
1611 |
|
|
testdocument = get210TestEmlDoc("InlineDataAccessTest: Doing insert",
|
1612 |
|
|
testEmlInlineBlock1, null, null, null, getAccessBlock(anotheruser,
|
1613 |
|
|
true, false, false, false, true), getAccessBlock(anotheruser,
|
1614 |
|
|
true, false, false, false, true), null, null, null);
|
1615 |
|
|
debug("inserting this: " + testdocument);
|
1616 |
|
|
Thread.sleep(2000);
|
1617 |
|
|
updateDocid(newdocid + ".2", testdocument, SUCCESS, false);
|
1618 |
|
|
readDocidWhichEqualsDoc(newdocid + ".2", testdocument, SUCCESS, false);
|
1619 |
2263
|
sgarg
|
|
1620 |
4477
|
daigle
|
m.logout();
|
1621 |
|
|
} catch (MetacatAuthException mae) {
|
1622 |
|
|
fail("Authorization failed:\n" + mae.getMessage());
|
1623 |
|
|
} catch (MetacatInaccessibleException mie) {
|
1624 |
|
|
fail("Metacat Inaccessible:\n" + mie.getMessage());
|
1625 |
|
|
} catch (Exception e) {
|
1626 |
|
|
fail("General exception:\n" + e.getMessage());
|
1627 |
|
|
}
|
1628 |
|
|
}
|
1629 |
2288
|
sgarg
|
|
1630 |
4477
|
daigle
|
/***************************************************************************
|
1631 |
|
|
* for EML 2.0.1, checking the following cases: -> when inline data is
|
1632 |
|
|
* inserted and updated, do access rules apply to the old document
|
1633 |
|
|
*/
|
1634 |
|
|
public void inlineData201CasesTest_6() {
|
1635 |
|
|
debug("\nRunning: inlineDataCasesTest_6()");
|
1636 |
|
|
try {
|
1637 |
2288
|
sgarg
|
|
1638 |
4477
|
daigle
|
// insert the document
|
1639 |
|
|
m.login(username, password);
|
1640 |
|
|
testdocument = get201TestEmlDoc("InlineDataAccessTest: Doing insert",
|
1641 |
|
|
testEmlInlineBlock1, testEmlInlineBlock2, null, null, getAccessBlock(
|
1642 |
|
|
anotheruser, true, true, true, false, false), getAccessBlock(
|
1643 |
|
|
anotheruser, false, false, false, false, true),
|
1644 |
|
|
getAccessBlock(anotheruser, false, false, false, false, true), null,
|
1645 |
|
|
null);
|
1646 |
|
|
newdocid = generateDocid();
|
1647 |
|
|
insertDocid(newdocid + ".1", testdocument, SUCCESS, false);
|
1648 |
2288
|
sgarg
|
|
1649 |
4477
|
daigle
|
m.logout();
|
1650 |
2288
|
sgarg
|
|
1651 |
4477
|
daigle
|
// update the document
|
1652 |
|
|
m.login(anotheruser, anotherpassword);
|
1653 |
|
|
testdocument = get201TestEmlDoc("InlineDataAccessTest: Doing update",
|
1654 |
|
|
testEmlInlineBlock2, testEmlInlineBlock1, null, null, getAccessBlock(
|
1655 |
|
|
anotheruser, true, true, true, false, false), getAccessBlock(
|
1656 |
|
|
anotheruser, false, false, false, false, true),
|
1657 |
|
|
getAccessBlock(anotheruser, false, false, false, false, true), null,
|
1658 |
|
|
null);
|
1659 |
|
|
Thread.sleep(2000);
|
1660 |
|
|
updateDocid(newdocid + ".2", testdocument, SUCCESS, false);
|
1661 |
2288
|
sgarg
|
|
1662 |
4477
|
daigle
|
// try reading the inline document
|
1663 |
|
|
readInlineDataWhichEqualsDoc(newdocid + ".2.1", testEmlInlineBlock1, FAILURE,
|
1664 |
|
|
true);
|
1665 |
2288
|
sgarg
|
|
1666 |
4477
|
daigle
|
System.out.print("Trying to read " + newdocid + ".1.1");
|
1667 |
|
|
readInlineDataWhichEqualsDoc(newdocid + ".1.1", testEmlInlineBlock1, FAILURE,
|
1668 |
|
|
true);
|
1669 |
2288
|
sgarg
|
|
1670 |
4477
|
daigle
|
m.logout();
|
1671 |
|
|
} catch (MetacatAuthException mae) {
|
1672 |
|
|
fail("Authorization failed:\n" + mae.getMessage());
|
1673 |
|
|
} catch (MetacatInaccessibleException mie) {
|
1674 |
|
|
fail("Metacat Inaccessible:\n" + mie.getMessage());
|
1675 |
|
|
} catch (Exception e) {
|
1676 |
|
|
fail("General exception:\n" + e.getMessage());
|
1677 |
|
|
}
|
1678 |
|
|
}
|
1679 |
|
|
|
1680 |
|
|
/***************************************************************************
|
1681 |
|
|
* for EML 2.1.0, checking the following cases: -> when inline data is
|
1682 |
|
|
* inserted and updated, do access rules apply to the old document
|
1683 |
|
|
*/
|
1684 |
|
|
public void inlineData210CasesTest_6() {
|
1685 |
|
|
debug("\nRunning: inlineDataCasesTest_6()");
|
1686 |
|
|
try {
|
1687 |
2288
|
sgarg
|
|
1688 |
4477
|
daigle
|
// insert the document
|
1689 |
|
|
m.login(username, password);
|
1690 |
|
|
testdocument = get210TestEmlDoc("InlineDataAccessTest: Doing insert",
|
1691 |
|
|
testEmlInlineBlock1, testEmlInlineBlock2, null, null, getAccessBlock(
|
1692 |
|
|
anotheruser, true, true, true, false, false), getAccessBlock(
|
1693 |
|
|
anotheruser, false, false, false, false, true),
|
1694 |
|
|
getAccessBlock(anotheruser, false, false, false, false, true), null,
|
1695 |
|
|
null);
|
1696 |
|
|
newdocid = generateDocid();
|
1697 |
|
|
insertDocid(newdocid + ".1", testdocument, SUCCESS, false);
|
1698 |
2288
|
sgarg
|
|
1699 |
4477
|
daigle
|
m.logout();
|
1700 |
2288
|
sgarg
|
|
1701 |
4477
|
daigle
|
// update the document
|
1702 |
|
|
m.login(anotheruser, anotherpassword);
|
1703 |
|
|
testdocument = get210TestEmlDoc("InlineDataAccessTest: Doing update",
|
1704 |
|
|
testEmlInlineBlock2, testEmlInlineBlock1, null, null, getAccessBlock(
|
1705 |
|
|
anotheruser, true, true, true, false, false), getAccessBlock(
|
1706 |
|
|
anotheruser, false, false, false, false, true),
|
1707 |
|
|
getAccessBlock(anotheruser, false, false, false, false, true), null,
|
1708 |
|
|
null);
|
1709 |
|
|
Thread.sleep(2000);
|
1710 |
|
|
updateDocid(newdocid + ".2", testdocument, SUCCESS, false);
|
1711 |
2288
|
sgarg
|
|
1712 |
4477
|
daigle
|
// try reading the inline document
|
1713 |
|
|
readInlineDataWhichEqualsDoc(newdocid + ".2.1", testEmlInlineBlock1, FAILURE,
|
1714 |
|
|
true);
|
1715 |
|
|
|
1716 |
|
|
System.out.print("Trying to read " + newdocid + ".1.1");
|
1717 |
|
|
readInlineDataWhichEqualsDoc(newdocid + ".1.1", testEmlInlineBlock1, FAILURE,
|
1718 |
|
|
true);
|
1719 |
|
|
|
1720 |
|
|
m.logout();
|
1721 |
|
|
} catch (MetacatAuthException mae) {
|
1722 |
|
|
fail("Authorization failed:\n" + mae.getMessage());
|
1723 |
|
|
} catch (MetacatInaccessibleException mie) {
|
1724 |
|
|
fail("Metacat Inaccessible:\n" + mie.getMessage());
|
1725 |
|
|
} catch (Exception e) {
|
1726 |
|
|
fail("General exception:\n" + e.getMessage());
|
1727 |
|
|
}
|
1728 |
|
|
}
|
1729 |
|
|
|
1730 |
|
|
|
1731 |
2263
|
sgarg
|
/**
|
1732 |
4477
|
daigle
|
* Insert a document into metacat. The expected result is passed as result
|
1733 |
|
|
*/
|
1734 |
2263
|
sgarg
|
|
1735 |
|
|
private String insertDocid(String docid, String docText, boolean result,
|
1736 |
|
|
boolean expectKarmaException) {
|
1737 |
|
|
String response = null;
|
1738 |
|
|
try {
|
1739 |
|
|
response = m.insert(docid,
|
1740 |
|
|
new StringReader(testdocument), null);
|
1741 |
|
|
if (result) {
|
1742 |
|
|
assertTrue( (response.indexOf("<success>") != -1));
|
1743 |
|
|
assertTrue(response.indexOf(docid) != -1);
|
1744 |
|
|
}
|
1745 |
|
|
else {
|
1746 |
|
|
assertTrue( (response.indexOf("<success>") == -1));
|
1747 |
|
|
}
|
1748 |
|
|
System.err.println(response);
|
1749 |
|
|
}
|
1750 |
|
|
catch (MetacatInaccessibleException mie) {
|
1751 |
|
|
fail("Metacat Inaccessible:\n" + mie.getMessage());
|
1752 |
|
|
}
|
1753 |
|
|
catch (InsufficientKarmaException ike) {
|
1754 |
|
|
if (!expectKarmaException) {
|
1755 |
|
|
fail("Insufficient karma:\n" + ike.getMessage());
|
1756 |
|
|
}
|
1757 |
|
|
}
|
1758 |
|
|
catch (MetacatException me) {
|
1759 |
|
|
if (result) {
|
1760 |
|
|
fail("Metacat Error:\n" + me.getMessage());
|
1761 |
|
|
}
|
1762 |
|
|
else {
|
1763 |
|
|
System.err.println("Metacat Error: " + me.getMessage());
|
1764 |
|
|
}
|
1765 |
|
|
}
|
1766 |
|
|
catch (Exception e) {
|
1767 |
|
|
fail("General exception:\n" + e.getMessage());
|
1768 |
|
|
}
|
1769 |
|
|
return response;
|
1770 |
|
|
}
|
1771 |
|
|
|
1772 |
|
|
/**
|
1773 |
|
|
* Insert a document into metacat. The expected result is passed as result
|
1774 |
|
|
*/
|
1775 |
|
|
|
1776 |
4477
|
daigle
|
// private String uploadDocid(String docid, String filePath, boolean result,
|
1777 |
|
|
// boolean expectedKarmaException) {
|
1778 |
|
|
// String response = null;
|
1779 |
|
|
// try {
|
1780 |
|
|
// response = m.upload(docid, new File(filePath));
|
1781 |
|
|
// if (result) {
|
1782 |
|
|
// assertTrue( (response.indexOf("<success>") != -1));
|
1783 |
|
|
// assertTrue(response.indexOf(docid) != -1);
|
1784 |
|
|
// }
|
1785 |
|
|
// else {
|
1786 |
|
|
// assertTrue( (response.indexOf("<success>") == -1));
|
1787 |
|
|
// }
|
1788 |
|
|
// System.err.println("respose from metacat: " + response);
|
1789 |
|
|
// }
|
1790 |
|
|
// catch (MetacatInaccessibleException mie) {
|
1791 |
|
|
// fail("Metacat Inaccessible:\n" + mie.getMessage());
|
1792 |
|
|
// }
|
1793 |
|
|
// catch (InsufficientKarmaException ike) {
|
1794 |
|
|
// if (!expectedKarmaException) {
|
1795 |
|
|
// fail("Insufficient karma:\n" + ike.getMessage());
|
1796 |
|
|
// }
|
1797 |
|
|
// }
|
1798 |
|
|
// catch (MetacatException me) {
|
1799 |
|
|
// if (result) {
|
1800 |
|
|
// fail("Metacat Error:\n" + me.getMessage());
|
1801 |
|
|
// }
|
1802 |
|
|
// else {
|
1803 |
|
|
// System.err.println("Metacat Error: " + me.getMessage());
|
1804 |
|
|
// }
|
1805 |
|
|
// }
|
1806 |
|
|
// catch (Exception e) {
|
1807 |
|
|
// fail("General exception:\n" + e.getMessage());
|
1808 |
|
|
// }
|
1809 |
|
|
// return response;
|
1810 |
|
|
// }
|
1811 |
2263
|
sgarg
|
|
1812 |
|
|
/**
|
1813 |
|
|
* Update a document in metacat. The expected result is passed as result
|
1814 |
|
|
*/
|
1815 |
|
|
private String updateDocid(String docid, String docText, boolean result,
|
1816 |
|
|
boolean expectedKarmaFailure) {
|
1817 |
|
|
String response = null;
|
1818 |
|
|
try {
|
1819 |
|
|
response = m.update(docid,
|
1820 |
|
|
new StringReader(testdocument), null);
|
1821 |
|
|
|
1822 |
|
|
if (result) {
|
1823 |
|
|
assertTrue( (response.indexOf("<success>") != -1));
|
1824 |
|
|
assertTrue(response.indexOf(docid) != -1);
|
1825 |
|
|
}
|
1826 |
|
|
else {
|
1827 |
|
|
assertTrue( (response.indexOf("<success>") == -1));
|
1828 |
|
|
}
|
1829 |
|
|
System.err.println(response);
|
1830 |
|
|
}
|
1831 |
|
|
catch (MetacatInaccessibleException mie) {
|
1832 |
|
|
fail("Metacat Inaccessible:\n" + mie.getMessage());
|
1833 |
|
|
}
|
1834 |
|
|
catch (InsufficientKarmaException ike) {
|
1835 |
|
|
if (!expectedKarmaFailure) {
|
1836 |
|
|
fail("Insufficient karma:\n" + ike.getMessage());
|
1837 |
|
|
}
|
1838 |
|
|
}
|
1839 |
|
|
catch (MetacatException me) {
|
1840 |
|
|
if (! (expectedKarmaFailure &&
|
1841 |
|
|
(me.getMessage().indexOf(
|
1842 |
4477
|
daigle
|
"User tried to update an access module when they don't have \"ALL\" permission") !=
|
1843 |
2263
|
sgarg
|
-1))) {
|
1844 |
|
|
fail("Metacat Error:\n" + me.getMessage());
|
1845 |
|
|
}
|
1846 |
|
|
}
|
1847 |
|
|
catch (Exception e) {
|
1848 |
|
|
fail("General exception:\n" + e.getMessage());
|
1849 |
|
|
}
|
1850 |
|
|
|
1851 |
|
|
return response;
|
1852 |
|
|
}
|
1853 |
|
|
|
1854 |
|
|
/**
|
1855 |
|
|
* Delete a document into metacat. The expected result is passed as result
|
1856 |
|
|
*/
|
1857 |
|
|
private void deleteDocid(String docid, boolean result,
|
1858 |
|
|
boolean expectedKarmaFailure) {
|
1859 |
|
|
try {
|
1860 |
|
|
String response = m.delete(docid);
|
1861 |
|
|
if (result) {
|
1862 |
|
|
assertTrue(response.indexOf("<success>") != -1);
|
1863 |
|
|
}
|
1864 |
|
|
else {
|
1865 |
|
|
assertTrue(response.indexOf("<success>") == -1);
|
1866 |
|
|
}
|
1867 |
|
|
System.err.println(response);
|
1868 |
|
|
}
|
1869 |
|
|
catch (MetacatInaccessibleException mie) {
|
1870 |
|
|
fail("Metacat Inaccessible:\n" + mie.getMessage());
|
1871 |
|
|
}
|
1872 |
|
|
catch (InsufficientKarmaException ike) {
|
1873 |
|
|
if (!expectedKarmaFailure) {
|
1874 |
|
|
fail("Insufficient karma:\n" + ike.getMessage());
|
1875 |
|
|
}
|
1876 |
|
|
|
1877 |
|
|
}
|
1878 |
|
|
catch (MetacatException me) {
|
1879 |
|
|
if (result) {
|
1880 |
|
|
fail("Metacat Error:\n" + me.getMessage());
|
1881 |
|
|
}
|
1882 |
|
|
else {
|
1883 |
|
|
System.err.println("Metacat Error:\n" + me.getMessage());
|
1884 |
|
|
}
|
1885 |
|
|
}
|
1886 |
|
|
catch (Exception e) {
|
1887 |
|
|
fail("General exception:\n" + e.getMessage());
|
1888 |
|
|
}
|
1889 |
|
|
}
|
1890 |
|
|
|
1891 |
|
|
/**
|
1892 |
|
|
* Read inline data from metacat. The expected result is passed as result
|
1893 |
|
|
*/
|
1894 |
|
|
private void readInlineDataWhichEqualsDoc(String docid, String testDoc,
|
1895 |
|
|
boolean result,
|
1896 |
|
|
boolean expextedKarmaFailure) {
|
1897 |
|
|
try {
|
1898 |
4477
|
daigle
|
debug("before read, docid: " + docid);
|
1899 |
2263
|
sgarg
|
Reader r = m.readInlineData(docid);
|
1900 |
4477
|
daigle
|
debug("after read, docid: " + docid);
|
1901 |
2263
|
sgarg
|
String doc = IOUtil.getAsString(r, true);
|
1902 |
4477
|
daigle
|
debug("after get as string, doc: " + doc);
|
1903 |
2263
|
sgarg
|
|
1904 |
|
|
if (result) {
|
1905 |
|
|
if (!testDoc.equals(doc)) {
|
1906 |
|
|
System.out.println("doc :" + doc);
|
1907 |
|
|
System.out.println("testDoc:" + testDoc);
|
1908 |
|
|
}
|
1909 |
|
|
|
1910 |
|
|
assertTrue(testDoc.equals(doc));
|
1911 |
|
|
}
|
1912 |
|
|
else {
|
1913 |
2288
|
sgarg
|
System.out.println("doc :" + doc);
|
1914 |
|
|
System.out.println("testDoc:" + testDoc);
|
1915 |
2263
|
sgarg
|
assertTrue(doc.indexOf("<error>") != -1);
|
1916 |
|
|
}
|
1917 |
|
|
}
|
1918 |
|
|
catch (MetacatInaccessibleException mie) {
|
1919 |
|
|
fail("Metacat Inaccessible:\n" + mie.getMessage());
|
1920 |
|
|
}
|
1921 |
|
|
catch (InsufficientKarmaException ike) {
|
1922 |
|
|
if (!expextedKarmaFailure) {
|
1923 |
|
|
fail("Insufficient karma:\n" + ike.getMessage());
|
1924 |
|
|
}
|
1925 |
|
|
}
|
1926 |
|
|
catch (MetacatException me) {
|
1927 |
|
|
if (result) {
|
1928 |
|
|
fail("Metacat Error:\n" + me.getMessage());
|
1929 |
|
|
}
|
1930 |
|
|
else {
|
1931 |
|
|
System.err.println("Metacat Error:\n" + me.getMessage());
|
1932 |
|
|
}
|
1933 |
|
|
}
|
1934 |
|
|
catch (Exception e) {
|
1935 |
|
|
fail("General exception:\n" + e.getMessage());
|
1936 |
|
|
}
|
1937 |
|
|
}
|
1938 |
|
|
|
1939 |
|
|
/**
|
1940 |
|
|
* Read a document from metacat. The expected result is passed as result
|
1941 |
|
|
*/
|
1942 |
|
|
private void readDocid(String docid, boolean result,
|
1943 |
|
|
boolean expextedKarmaFailure) {
|
1944 |
|
|
try {
|
1945 |
|
|
Reader r = m.read(docid);
|
1946 |
|
|
String response = IOUtil.getAsString(r, true);
|
1947 |
|
|
|
1948 |
|
|
if (!result) {
|
1949 |
|
|
assertTrue(response.indexOf("<success>") == -1);
|
1950 |
|
|
}
|
1951 |
|
|
System.err.println(response);
|
1952 |
|
|
}
|
1953 |
|
|
catch (MetacatInaccessibleException mie) {
|
1954 |
|
|
fail("Metacat Inaccessible:\n" + mie.getMessage());
|
1955 |
|
|
}
|
1956 |
|
|
catch (InsufficientKarmaException ike) {
|
1957 |
|
|
if (!expextedKarmaFailure) {
|
1958 |
|
|
fail("Insufficient karma:\n" + ike.getMessage());
|
1959 |
|
|
}
|
1960 |
|
|
}
|
1961 |
|
|
catch (MetacatException me) {
|
1962 |
|
|
if (result) {
|
1963 |
|
|
fail("Metacat Error:\n" + me.getMessage());
|
1964 |
|
|
}
|
1965 |
|
|
else {
|
1966 |
|
|
System.err.println("Metacat Error:\n" + me.getMessage());
|
1967 |
|
|
}
|
1968 |
|
|
}
|
1969 |
|
|
catch (Exception e) {
|
1970 |
|
|
fail("General exception:\n" + e.getMessage());
|
1971 |
|
|
}
|
1972 |
|
|
}
|
1973 |
|
|
|
1974 |
|
|
/**
|
1975 |
|
|
* Read a document from metacat and check if it is equal to a given string.
|
1976 |
|
|
* The expected result is passed as result
|
1977 |
|
|
*/
|
1978 |
|
|
|
1979 |
|
|
private void readDocidWhichEqualsDoc(String docid, String testDoc,
|
1980 |
|
|
boolean result,
|
1981 |
|
|
boolean expextedKarmaFailure) {
|
1982 |
|
|
try {
|
1983 |
|
|
Reader r = m.read(docid);
|
1984 |
|
|
String doc = IOUtil.getAsString(r, true);
|
1985 |
|
|
if (result) {
|
1986 |
|
|
|
1987 |
|
|
if (!testDoc.equals(doc)) {
|
1988 |
4339
|
daigle
|
System.out.println("doc ***********************");
|
1989 |
|
|
System.out.println(doc);
|
1990 |
|
|
System.out.println("end doc ***********************");
|
1991 |
|
|
System.out.println("testDoc ***********************");
|
1992 |
|
|
System.out.println(testDoc);
|
1993 |
|
|
System.out.println("end testDoc ***********************");
|
1994 |
2263
|
sgarg
|
}
|
1995 |
|
|
|
1996 |
|
|
assertTrue(testDoc.equals(doc));
|
1997 |
|
|
}
|
1998 |
|
|
else {
|
1999 |
|
|
assertTrue(doc.indexOf("<error>") != -1);
|
2000 |
|
|
}
|
2001 |
|
|
}
|
2002 |
|
|
catch (MetacatInaccessibleException mie) {
|
2003 |
|
|
fail("Metacat Inaccessible:\n" + mie.getMessage());
|
2004 |
|
|
}
|
2005 |
|
|
catch (InsufficientKarmaException ike) {
|
2006 |
3567
|
tao
|
if (result) {
|
2007 |
|
|
fail("Metacat Error:\n" + ike.getMessage());
|
2008 |
2263
|
sgarg
|
}
|
2009 |
3567
|
tao
|
else {
|
2010 |
|
|
System.out.println("Metacat Error:\n" + ike.getMessage());
|
2011 |
|
|
}
|
2012 |
2263
|
sgarg
|
}
|
2013 |
|
|
catch (MetacatException me) {
|
2014 |
|
|
if (result) {
|
2015 |
|
|
fail("Metacat Error:\n" + me.getMessage());
|
2016 |
|
|
}
|
2017 |
|
|
else {
|
2018 |
|
|
System.out.println("Metacat Error:\n" + me.getMessage());
|
2019 |
|
|
}
|
2020 |
|
|
}
|
2021 |
|
|
catch (Exception e) {
|
2022 |
|
|
fail("General exception:\n" + e.getMessage());
|
2023 |
|
|
}
|
2024 |
|
|
|
2025 |
|
|
}
|
2026 |
|
|
|
2027 |
|
|
/**
|
2028 |
|
|
* Create a hopefully unique docid for testing insert and update. Does
|
2029 |
|
|
* not include the 'revision' part of the id.
|
2030 |
|
|
*
|
2031 |
|
|
* @return a String docid based on the current date and time
|
2032 |
|
|
*/
|
2033 |
|
|
private String generateDocid() {
|
2034 |
|
|
StringBuffer docid = new StringBuffer(prefix);
|
2035 |
|
|
docid.append(".");
|
2036 |
|
|
|
2037 |
4477
|
daigle
|
try {
|
2038 |
|
|
Thread.sleep(1100);
|
2039 |
|
|
} catch (InterruptedException ie) {
|
2040 |
|
|
System.out.println("Warning: generateDocid() could not sleep 1100 ms");
|
2041 |
|
|
}
|
2042 |
2263
|
sgarg
|
// Create a calendar to get the date formatted properly
|
2043 |
|
|
String[] ids = TimeZone.getAvailableIDs( -8 * 60 * 60 * 1000);
|
2044 |
|
|
SimpleTimeZone pdt = new SimpleTimeZone( -8 * 60 * 60 * 1000, ids[0]);
|
2045 |
|
|
pdt.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
|
2046 |
|
|
pdt.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY,
|
2047 |
|
|
2 * 60 * 60 * 1000);
|
2048 |
|
|
Calendar calendar = new GregorianCalendar(pdt);
|
2049 |
|
|
Date trialTime = new Date();
|
2050 |
|
|
calendar.setTime(trialTime);
|
2051 |
|
|
docid.append(calendar.get(Calendar.YEAR));
|
2052 |
|
|
docid.append(calendar.get(Calendar.DAY_OF_YEAR));
|
2053 |
|
|
docid.append(calendar.get(Calendar.HOUR_OF_DAY));
|
2054 |
|
|
docid.append(calendar.get(Calendar.MINUTE));
|
2055 |
|
|
docid.append(calendar.get(Calendar.SECOND));
|
2056 |
|
|
|
2057 |
|
|
return docid.toString();
|
2058 |
|
|
}
|
2059 |
|
|
}
|