Project

General

Profile

Revision 4679

Added by daigle about 12 years ago

Change Inline to be inline in the test eml. Added debug statements.

View differences:

test/edu/ucsb/nceas/metacattest/InlineDataAccessTest.java
203 203
		if (onlineUrl1 != null) {
204 204
			testDocument = testDocument
205 205
					+ "<distribution scope=\"document\" id=\"InlineEntity1\">"
206
					+ "<Inline><url function=\"download\">" + onlineUrl1
207
					+ "</url></Inline></distribution>";
206
					+ "<inline><url function=\"download\">" + onlineUrl1
207
					+ "</url></inline></distribution>";
208 208
		}
209 209
		if (onlineUrl2 != null) {
210 210
			testDocument = testDocument
211 211
					+ "<distribution scope=\"document\" id=\"InlineEntity2\">"
212
					+ "<Inline><url function=\"download\">" + onlineUrl2
213
					+ "</url></Inline></distribution>";
212
					+ "<inline><url function=\"download\">" + onlineUrl2
213
					+ "</url></inline></distribution>";
214 214
		}
215 215
		testDocument += testEmlContactBlock;
216 216
		
......
253 253

  
254 254
		testDocument += "</eml:eml>";
255 255

  
256
		debug("Returning following document" + testDocument);
256
		debug("get201TestEmlDoc returning following document: " + testDocument);
257 257
		return testDocument;
258 258
	}
259 259
    
......
289 289
				+ "        <numHeaderLines>1</numHeaderLines>"
290 290
				+ "        <attributeOrientation>column</attributeOrientation>"
291 291
				+ "        <simpleDelimited>"
292
				+ "          <fieldDelimiter>\t</fieldDelimiter>"
292
				+ "          <fieldDelimiter>,</fieldDelimiter>"
293 293
				+ "        </simpleDelimited>"
294 294
				+ "      </textFormat>"
295 295
				+ "    </dataFormat>";
......
312 312
		}
313 313
		if (onlineUrl1 != null) {
314 314
			testDocument = testDocument
315
					+ "<distribution><Inline><url function=\"download\">" + onlineUrl1
316
					+ "</url></Inline>";
315
					+ "<distribution><inline><url function=\"download\">" + onlineUrl1
316
					+ "</url></inline>";
317 317
			if (onlineAccessBlock1 != null) {
318 318
				testDocument += onlineAccessBlock1;
319 319
			}
......
321 321
		}
322 322
		if (onlineUrl2 != null) {
323 323
			testDocument = testDocument
324
					+ "<distribution><Inline><url function=\"download\">" + onlineUrl2
325
					+ "</url></Inline>";
324
					+ "<distribution><inline><url function=\"download\">" + onlineUrl2
325
					+ "</url></inline>";
326 326
			if (onlineAccessBlock2 != null) {
327 327
				testDocument += onlineAccessBlock2;
328 328
			}
......
354 354
			+ "  </attributeList>"
355 355
			+ "</dataTable></dataset></eml:eml>";
356 356

  
357
		debug("Returning following document" + testDocument);
357
		debug("get210TestEmlDoc returning following document: " + testDocument);
358 358
		return testDocument;
359 359
	}
360 360

  
......
509 509
			testdocument = get210TestEmlDoc("Testing insert", testEmlInlineBlock1,
510 510
					null, null, null, null, null, null, null, null);
511 511

  
512
			debug("testdocument: " + testdocument);
513
			
512 514
			insertDocid(newdocid + ".1", testdocument, SUCCESS, false);
513 515
			readDocidWhichEqualsDoc(newdocid, testdocument, SUCCESS, true);
514 516

  
......
872 874

  
873 875
			// ///////Case 1./////////////////////
874 876
			// insert an inline document - read only
877
			debug("Case 1:");
875 878
			m.login(username, password);
876 879
			newdocid = generateDocid();
877 880

  
......
915 918

  
916 919
			// ///////Case 2./////////////////////
917 920
			// insert an inline document - write only
921
			debug("Case 2:");
918 922
			m.login(username, password);
919 923
			newdocid = generateDocid();
920 924

  
921 925
			// insert a document which gives read access to the inline document
926
			debug("Inserting doc: " + newdocid + ".1, which allows document level" 
927
					+ " write access for " + anotheruser + " and expect SUCCESS");
922 928
			testdocument = get210TestEmlDoc("InlineDataAccessTest: Doing insert",
923 929
					testEmlInlineBlock1, null, null, null, getAccessBlock(anotheruser,
924 930
							true, false, true, false, false), null, null, null, null);
......
929 935
			m.login(anotheruser, anotherpassword);
930 936

  
931 937
			// try to read the document and the inline data
938
			debug("Try to read:" + newdocid + ".1 as user: " + anotheruser 
939
					+ " and expect FAILURE since write access does not imply read access");
932 940
			readDocid(newdocid + ".1", FAILURE, true);
933 941
			readInlineDataWhichEqualsDoc(newdocid + ".1.1", testEmlInlineBlock1, FAILURE,
934 942
					true);
935 943

  
936 944
			// try to update the inline data
945
			debug("Updating doc: " + newdocid + ".2, with new inline data." 
946
					+ " as: " + anotheruser + " and expect SUCCESS");
937 947
			testdocument = get210TestEmlDoc("InlineDataAccessTest: Doing update",
938 948
					testEmlInlineBlock2, null, null, null, getAccessBlock(anotheruser,
939 949
							true, false, true, false, false), null, null, null, null);
......
956 966
			deleteDocid(newdocid + ".2", SUCCESS, false);
957 967
			m.logout();
958 968

  
959
//			// ///////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();
969
			// ///////Case 3./////////////////////
970
			// insert an inline document - change permission only
971
			debug("Case 3:");
972
			m.login(username, password);
973
			newdocid = generateDocid();
1046 974

  
975
			// insert a document which gives read access to the inline document
976
			testdocument = get210TestEmlDoc("InlineDataAccessTest: Doing insert",
977
					testEmlInlineBlock1, null, null, null, getAccessBlock(anotheruser,
978
							true, false, false, true, false), null, null, null, null);
979
			insertDocid(newdocid + ".1", testdocument, SUCCESS, false);
980
			m.logout();
981

  
982
			// login as another user
983
			m.login(anotheruser, anotherpassword);
984

  
985
			// try to read the document and the inline data
986
			readDocid(newdocid + ".1", FAILURE, true);
987
			readInlineDataWhichEqualsDoc(newdocid + ".1.1", testEmlInlineBlock1, FAILURE,
988
					true);
989

  
990
			// try to update the inline data
991
			testdocument = get210TestEmlDoc("InlineDataAccessTest: Doing update",
992
					testEmlInlineBlock2, null, null, null, getAccessBlock(anotheruser,
993
							true, false, false, true, false), null, null, null, null);
994
			Thread.sleep(2000);
995
			updateDocid(newdocid + ".2", testdocument, FAILURE, true);
996

  
997
			// try to set the permissions for the inline data
998
			testdocument = get210TestEmlDoc("InlineDataAccessTest: Doing insert",
999
					testEmlInlineBlock1, null, null, null, getAccessBlock(anotheruser,
1000
							true, false, false, false, true), null, null, null, null);
1001
			// ERRRRRRRRRRRR
1002
			// updateDocid(newdocid + ".2", testdocument, SUCCESS, false);
1003

  
1004
			// try to delete the document
1005
			deleteDocid(newdocid + ".1", FAILURE, true);
1006
			m.logout();
1007

  
1008
			// delete the document
1009
			m.login(username, password);
1010
			deleteDocid(newdocid + ".1", SUCCESS, false);
1011
			m.logout();
1012

  
1013
			// ///////Case 4./////////////////////
1014
			// insert an inline document - change permission only
1015
			debug("Case 4:");
1016
			m.login(username, password);
1017
			newdocid = generateDocid();
1018

  
1019
			// insert a document which gives read access to the inline document
1020
			testdocument = get210TestEmlDoc("InlineDataAccessTest: Doing insert",
1021
					testEmlInlineBlock1, null, null, null, getAccessBlock(anotheruser,
1022
							true, false, false, false, true), null, null, null, null);
1023
			insertDocid(newdocid + ".1", testdocument, SUCCESS, false);
1024
			m.logout();
1025

  
1026
			// login as another user
1027
			m.login(anotheruser, anotherpassword);
1028

  
1029
			// try to read the document and the inline data
1030
			readDocid(newdocid + ".1", SUCCESS, false);
1031
			readInlineDataWhichEqualsDoc(newdocid + ".1.1", testEmlInlineBlock1, SUCCESS,
1032
					false);
1033

  
1034
			// try to update the inline data
1035
			testdocument = get210TestEmlDoc("InlineDataAccessTest: Doing update",
1036
					testEmlInlineBlock2, null, null, null, getAccessBlock(anotheruser,
1037
							true, false, false, false, true), null, null, null, null);
1038
			Thread.sleep(2000);
1039
			updateDocid(newdocid + ".2", testdocument, SUCCESS, false);
1040

  
1041
			// try to set the permissions for the inline data
1042
			testdocument = get210TestEmlDoc("InlineDataAccessTest: Doing insert",
1043
					testEmlInlineBlock1, null, null, null, getAccessBlock(anotheruser,
1044
							true, true, true, true, false), null, null, null, null);
1045
			Thread.sleep(2000);
1046
			updateDocid(newdocid + ".3", testdocument, SUCCESS, false);
1047

  
1048
			// try to delete the document
1049
			// sleep needed only in case of inline data - jing said that
1050
			// somehow the thread writing data to xml_index takes too much time
1051
			// when used with inline data. hence if delete is requested too soon
1052
			// database gives an error of xml_index records left with FK to
1053
			// xml_document record which is going to be deleted.
1054
			Thread.sleep(10000);
1055

  
1056
			deleteDocid(newdocid + ".3", SUCCESS, false);
1057
			m.logout();
1058

  
1047 1059
		} catch (MetacatAuthException mae) {
1048 1060
			fail("Authorization failed:\n" + mae.getMessage());
1049 1061
		} catch (MetacatInaccessibleException mie) {
......
1466 1478
	 * metadata and no access for data
1467 1479
	 */
1468 1480
    public void inlineData201CasesTest_5() {
1469
		debug("\nRunning: inlineDataCasesTest_5()");
1481
		debug("\nRunning: inlineData201CasesTest_5()");
1470 1482
		try {
1471 1483

  
1472
//			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);
1484
			m.login(username, password);
1503 1485

  
1486
			/////////Case 1
1487
			debug("Case 1:");
1488
			testdocument = get201TestEmlDoc("InlineDataAccessTest: Doing insert",
1489
					null, null, null, null, null, getAccessBlock(anotheruser, true, true,
1490
							false, false, false), null, null, null);
1491
			newdocid = generateDocid();
1492

  
1493
			// try to insert the wrong document.  This document is wrong because
1494
			// it has an access block but no distribution.
1495
			insertDocid(newdocid + ".1", testdocument, FAILURE, false);
1496
			m.logout();
1497

  
1498
			/////////Case 2
1499
			debug("Case 2:");
1500
			m.login(username, password);
1501
			testdocument = get201TestEmlDoc("InlineDataAccessTest: Doing insert",
1502
					testEmlInlineBlock1, null, null, null, getAccessBlock(anotheruser,
1503
							true, true, true, false, false), null, null, null, null);
1504
			newdocid = generateDocid();
1505
			insertDocid(newdocid + ".1", testdocument, SUCCESS, false);
1506
			m.logout();
1507

  
1508
			m.login(anotheruser, anotherpassword);
1509
			testdocument = get201TestEmlDoc("InlineDataAccessTest: Doing insert",
1510
					null, null, null, null, getAccessBlock(anotheruser, true, true, true,
1511
							false, false), null, null, null, null);
1512
			/// ERRRRRRRRRRRR
1513
			Thread.sleep(2000);
1514
			updateDocid(newdocid + ".2", testdocument, SUCCESS, false);
1515

  
1504 1516
			/////////Case 3
1505 1517
			debug("Case 3:");
1506 1518
			// insert a document
......
1549 1561
	 * metadata and no access for data
1550 1562
	 */
1551 1563
    public void inlineData210CasesTest_5() {
1552
		debug("\nRunning: inlineDataCasesTest_5()");
1564
		debug("\nRunning: inlineData210CasesTest_5()");
1553 1565
		try {
1554 1566

  
1555
			// 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

  
1571 1567
			/////////Case 2
1572 1568
			debug("Case 2:");
1573 1569
			m.login(username, password);
......
1607 1603
			readDocidWhichEqualsDoc(newdocid + ".1", testdocument, SUCCESS, false);
1608 1604

  
1609 1605
			// try to update the rules for inline data
1610
			// / ERRRRRRRRRRRR it lets you do that
1606
			// shouldn't succeed
1611 1607
			testdocument = get210TestEmlDoc("InlineDataAccessTest: Doing insert",
1612 1608
					testEmlInlineBlock1, null, null, null, getAccessBlock(anotheruser,
1613 1609
							true, false, false, false, true), getAccessBlock(anotheruser,
......
1632 1628
	 * inserted and updated, do access rules apply to the old document
1633 1629
	 */
1634 1630
      public void inlineData201CasesTest_6() {
1635
		debug("\nRunning: inlineDataCasesTest_6()");
1631
		debug("\nRunning: inlineData201CasesTest_6()");
1636 1632
		try {
1637 1633

  
1638 1634
			// insert the document
......
1682 1678
	 * inserted and updated, do access rules apply to the old document
1683 1679
	 */
1684 1680
	public void inlineData210CasesTest_6() {
1685
		debug("\nRunning: inlineDataCasesTest_6()");
1681
		debug("\nRunning: inlineData210CasesTest_6()");
1686 1682
		try {
1687 1683

  
1688 1684
			// insert the document

Also available in: Unified diff