Skip to content

Commit 6a66084

Browse files
committed
UPdate Bi-temporal tests to have temporal-admin role, Fix temporal
protectwipe test cases.
1 parent f87569a commit 6a66084

File tree

2 files changed

+26
-17
lines changed

2 files changed

+26
-17
lines changed

test-complete/src/test/java/com/marklogic/client/functionaltest/TestBiTempMetaValues.java

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public static void tearDownAfterClass() throws Exception {
139139
public void setUp() throws Exception {
140140
createUserRolesWithPrevilages("test-eval","xdbc:eval", "xdbc:eval-in","xdmp:eval-in","any-uri","xdbc:invoke","temporal:statement-set-system-time", "temporal-document-protect", "temporal-document-wipe");
141141

142-
createRESTUser("eval-user", "x", "test-eval","rest-admin","rest-writer","rest-reader");
142+
createRESTUser("eval-user", "x", "test-eval","rest-admin","rest-writer","rest-reader","temporal-admin");
143143
int restPort = getRestServerPort();
144144
writerClient = getDatabaseClientOnDatabase("localhost", restPort, dbName, "eval-user", "x", Authentication.DIGEST);
145145
}
@@ -718,8 +718,9 @@ public void testProtectDelete() throws Exception {
718718

719719
JSONDocumentManager docMgr = writerClient.newJSONDocumentManager();
720720
JSONDocumentManager docMgrProtect = adminClient.newJSONDocumentManager();
721-
docMgr.write(docId, null, handle, null, null, temporalLsqtCollectionName, insertTime);
722-
721+
docMgr.write(docId, null, handle, null, null, temporalLsqtCollectionName, insertTime);
722+
723+
//TODO: UPdate this test to include temporalDoucmentURi and delete one version of it and search and assert for that deleted version
723724
//Protect document for 30 sec from delete and update. Use Duration.
724725
docMgr.protect(docId, temporalLsqtCollectionName, ProtectionLevel.NODELETE, DatatypeFactory.newInstance().newDuration("PT30S"));
725726

@@ -735,13 +736,13 @@ public void testProtectDelete() throws Exception {
735736

736737
// Sleep for 40 secs and try to delete the same docId.
737738
Thread.sleep(40000);
738-
/*docMgr.delete(docId, null, temporalLsqtCollectionName, deleteTime);
739+
docMgr.delete(docId, null, temporalLsqtCollectionName, deleteTime);
739740
Thread.sleep(5000);
740741

741742
JSONDocumentManager jsonDocMgr = writerClient.newJSONDocumentManager();
742743
DocumentPage readResults = jsonDocMgr.read(docId);
743744
System.out.println("Number of results = " + readResults.size());
744-
assertEquals("Wrong number of results", 0, readResults.size()); */
745+
// assertEquals("Wrong number of results", 0, readResults.size());
745746
}
746747

747748
@Test
@@ -1054,7 +1055,7 @@ public void testProtectWipeWithoutPermission() throws Exception {
10541055
str.append(ex.getMessage());
10551056
System.out.println("Exception not thrown when user does not have permissions" + str.toString());
10561057
}
1057-
assertTrue("Exception not thrown when user does not have permissions", str.toString().contains("User is not allowed to protect resource at documents/protection"));
1058+
assertTrue("Exception not thrown when user does not have permissions", str.toString().contains("Local message: User is not allowed to protect resource at documents/protection"));
10581059
}
10591060

10601061
@Test
@@ -1084,29 +1085,37 @@ public void testProtectWipe() throws Exception {
10841085
docMgr.write(docId, null, handle, null, null, temporalLsqtCollectionName, insertTime);
10851086
Thread.sleep(5000);
10861087

1087-
//Protect document for 30 sec. Use Duration.
1088-
docMgr.protect(docId, temporalLsqtCollectionName, ProtectionLevel.NOWIPE, DatatypeFactory.newInstance().newDuration("PT30S"));
1088+
//Protect document for 60 sec. Use Duration.
1089+
docMgr.protect(docId, temporalLsqtCollectionName, ProtectionLevel.NOWIPE, DatatypeFactory.newInstance().newDuration("PT60S"));
10891090
JacksonDatabindHandle<ObjectNode> handleUpd = getJSONDocumentHandle(
1090-
"2003-01-01T00:00:00", "2008-12-31T23:59:59",
1091+
"2003-01-01T00:00:00", "2012-12-31T23:59:59",
10911092
"1999 Skyway Park - Updated - JSON", docId);
1093+
docMgr.write(docId, null, handleUpd, null, null, temporalLsqtCollectionName, updateTime);
10921094
StringBuilder str = new StringBuilder();
10931095
try {
1094-
docMgr.delete(docId, null, temporalLsqtCollectionName, updateTime);
1096+
docMgr.wipe(docId, temporalLsqtCollectionName);
10951097
}
10961098
catch(Exception ex) {
10971099
str.append(ex.getMessage());
1098-
System.out.println("Exception when delete within 30 sec is " + str.toString());
1100+
System.out.println("Exception when delete within 60 sec is " + str.toString());
10991101
}
1102+
1103+
assertTrue("Did not receive Expected Exception, Expecting TEMPORAL-PROTECTED, received "+str.toString(),str.toString().contains("TEMPORAL-PROTECTED"));
1104+
JSONDocumentManager jsonDocMgr = writerClient.newJSONDocumentManager();
1105+
DocumentPage readResults = jsonDocMgr.read(docId);
1106+
String content = jsonDocMgr.read(docId, new StringHandle()).get();
1107+
assertTrue("Wrong number of results", content.contains("1999 Skyway Park - Updated - JSON"));
11001108

11011109
// Sleep for 40 secs and try to delete the same docId.
1102-
Thread.sleep(40000);
1110+
Thread.sleep(60000);
11031111
Transaction t1 = writerClient.openTransaction();
1104-
// TODO Not sure why this doc is not getting deleted.
1105-
docMgr.delete(docId, t1, temporalLsqtCollectionName, updateTime);
1112+
//TODO replace get with search and verify the system end time for the document \
1113+
//temporal document will not be deleted from DB and using get will only return the latest docuemnt.
1114+
docMgr.wipe(docId, t1, temporalLsqtCollectionName);
11061115
Thread.sleep(5000);
11071116
t1.commit();
1108-
JSONDocumentManager jsonDocMgr = writerClient.newJSONDocumentManager();
1109-
DocumentPage readResults = jsonDocMgr.read(docId);
1117+
// DocumentPage readResults = jsonDocMgr.read(docId);
1118+
readResults = jsonDocMgr.read(docId);
11101119
System.out.println("Number of results = " + readResults.size());
11111120
assertEquals("Wrong number of results", 0, readResults.size());
11121121
}

test-complete/src/test/java/com/marklogic/client/functionaltest/TestBiTemporal.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2991,7 +2991,7 @@ public void testInsertJSONDocumentUsingXMLExtension() throws Exception {
29912991
System.out.println(message);
29922992
System.out.println(statusCode);
29932993

2994-
assertTrue("Error Message", message.equals("XDMP-NOMATCH"));
2994+
assertTrue("Error Message", message.equals("XDMP-DOCROOTTEXT"));
29952995
assertTrue("Status code", (statusCode == 400));
29962996
}
29972997

0 commit comments

Comments
 (0)