Skip to content

Commit b8f7b12

Browse files
committed
Merge remote-tracking branch 'origin/newRegressionTests' into dev
2 parents 92a919b + a83b067 commit b8f7b12

File tree

8 files changed

+160
-150
lines changed

8 files changed

+160
-150
lines changed

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -868,13 +868,7 @@ public static void tearDownJavaRESTServer(String dbName, String [] fNames, Strin
868868
deleteDB(dbName);
869869
logTestMessages("DELETE-DB",before);
870870

871-
872-
cal = Calendar.getInstance();
873-
long after =cal.getTimeInMillis();
874-
long diff = after - beforeTeardown;
875-
876-
String msg = "### Ending TestCase TEARDOWN ### "+diff/1000+" seconds";
877-
logger.info(msg);
871+
logTestMessages(" Ending TESTCASE TEARDOWN ",beforeTeardown);
878872

879873
}
880874

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ public void validateMetadata(DocumentMetadataHandle mh) {
160160
assertTrue("Document property reviewed not found or not correct", actualProperties.contains("reviewed:true"));
161161
assertTrue("Document property myInteger not found or not correct", actualProperties.contains("myInteger:10"));
162162
assertTrue("Document property myDecimal not found or not correct", actualProperties.contains("myDecimal:34.56678"));
163-
assertTrue("Document property myCalendar not found or not correct", actualProperties.contains("myCalendar:2014"));
163+
assertTrue("Document property myCalendar not found or not correct", actualProperties.contains("myCalendar:2015"));
164164
assertTrue("Document property myString not found or not correct", actualProperties.contains("myString:foo"));
165165

166166
// Permissions
@@ -196,7 +196,7 @@ public void validateUpdatedMetadataProperties(DocumentMetadataHandle mh) {
196196
assertTrue("Document property reviewed not found or not correct", actualProperties.contains("reviewed:true"));
197197
assertTrue("Document property myInteger not found or not correct", actualProperties.contains("myInteger:10"));
198198
assertTrue("Document property myDecimal not found or not correct", actualProperties.contains("myDecimal:34.56678"));
199-
assertTrue("Document property myCalendar not found or not correct", actualProperties.contains("myCalendar:2014"));
199+
assertTrue("Document property myCalendar not found or not correct", actualProperties.contains("myCalendar:2015"));
200200
assertTrue("Document property myString not found or not correct", actualProperties.contains("myString:foo"));
201201

202202
// Permissions
@@ -232,7 +232,7 @@ public void validateUpdatedMetadataCollections(DocumentMetadataHandle mh) {
232232
assertTrue("Document property reviewed not found or not correct", actualProperties.contains("reviewed:true"));
233233
assertTrue("Document property myInteger not found or not correct", actualProperties.contains("myInteger:10"));
234234
assertTrue("Document property myDecimal not found or not correct", actualProperties.contains("myDecimal:34.56678"));
235-
assertTrue("Document property myCalendar not found or not correct", actualProperties.contains("myCalendar:2014"));
235+
assertTrue("Document property myCalendar not found or not correct", actualProperties.contains("myCalendar:2015"));
236236
assertTrue("Document property myString not found or not correct", actualProperties.contains("myString:foo"));
237237

238238
// Permissions

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

Lines changed: 2 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -397,124 +397,10 @@ public void testBulkSearchSQDwithTransactionsandDOMHandle() throws Exception{
397397
DocumentPage page= docMgr.search(qd, 1,results);
398398
System.out.println(this.convertXMLDocumentToString(results.get()));
399399

400-
assertNull("Total search results after rollback are ",results.get().getElementsByTagNameNS("*", "response").item(0).getAttributes().getNamedItem("total"));
400+
assertEquals("Total search results after rollback are ",results.get().getElementsByTagNameNS("*", "response").item(0).getAttributes().getNamedItem("total").getNodeValue(),"0");
401401

402402
}
403403

404404

405-
/* Searching for boolean and string in XML element using value query.
406-
* Purpose: To validate QueryBuilder's new value methods (in 8.0) in XML document using an element.
407-
*
408-
* Load a file that has a boolean value in a XML attribute and use query def to search on that boolean value
409-
*
410-
* Methods used : value(StructuredQueryBuilder.TextIndex index, boolean)
411-
* value(StructuredQueryBuilder.TextIndex index, String)
412-
*/
413-
@Test
414-
public void testQueryBuilderValueWithBooleanAndString() throws XpathException, SAXException, IOException {
415-
416-
String docId[] = {"play-persons.xml"};
417-
418-
TextDocumentManager docMgr = client.newTextDocumentManager();
419-
QueryManager queryMgr = client.newQueryManager();
420-
DocumentWriteSet writeset = docMgr.newWriteSet();
421-
422-
// Put meta-data
423-
424-
DocumentMetadataHandle metadataHandle = new DocumentMetadataHandle();
425-
metadataHandle.getCollections().addAll("my-collection1","my-collection2");
426-
metadataHandle.getPermissions().add("app-user", Capability.UPDATE, Capability.READ);
427-
metadataHandle.getProperties().put("reviewed", true);
428-
metadataHandle.getProperties().put("myString", "foo");
429-
metadataHandle.getProperties().put("myInteger", 10);
430-
metadataHandle.getProperties().put("myDecimal", 34.56678);
431-
metadataHandle.getProperties().put("myCalendar", Calendar.getInstance().get(Calendar.YEAR));
432-
metadataHandle.setQuality(23);
433-
434-
writeset.addDefault(metadataHandle);
435-
436-
// Create a new document using StringHandle
437-
StringBuffer strBuf = new StringBuffer();
438-
439-
strBuf.append("<PLAY>");
440-
strBuf.append("<TITLE>All's Well That Ends Well</TITLE>");
441-
strBuf.append("<PERSONAE>");
442-
strBuf.append("<TITLE>Dramatis Personae</TITLE>");
443-
444-
strBuf.append("<PGROUP>");
445-
strBuf.append("<subgroup>true</subgroup>");
446-
447-
strBuf.append("<PERSONA>KING OF FRANCE</PERSONA>");
448-
strBuf.append("<PERSONA>DUKE OF FLORENCE</PERSONA>");
449-
strBuf.append("<PERSONA>BERTRAM, Count of Rousillon.</PERSONA>");
450-
strBuf.append("<PERSONA>LAFEU, an old lord.</PERSONA>");
451-
strBuf.append("</PGROUP>");
452-
453-
strBuf.append("<PGROUP>");
454-
strBuf.append("<subgroup>false</subgroup>");
455-
456-
strBuf.append("<PERSONA>PAROLLES, a follower of Bertram.</PERSONA>");
457-
strBuf.append("<PERSONA>A Page. </PERSONA>");
458-
strBuf.append("</PGROUP>");
459-
460-
strBuf.append("<PGROUP>");
461-
strBuf.append("<subgroup>false</subgroup>");
462-
strBuf.append("<PERSONA>COUNTESS OF ROUSILLON, mother to Bertram. </PERSONA>");
463-
strBuf.append("<PERSONA>HELENA, a gentlewoman protected by the Countess.</PERSONA>");
464-
strBuf.append("<PERSONA>An old Widow of Florence. </PERSONA>");
465-
strBuf.append("<PERSONA>DIANA, daughter to the Widow.</PERSONA>");
466-
strBuf.append("</PGROUP>");
467-
468-
strBuf.append("<PGROUP>");
469-
strBuf.append("<subgroup>false</subgroup>");
470-
strBuf.append("<PERSONA>VIOLENTA</PERSONA>");
471-
strBuf.append("<PERSONA>MARIANA</PERSONA>");
472-
strBuf.append("<GRPDESCR>neighbours and friends to the Widow.</GRPDESCR>");
473-
strBuf.append("</PGROUP>");
474-
475-
strBuf.append("<PERSONA>Lords, Officers, Soldiers, &amp;c., French and Florentine.</PERSONA>");
476-
strBuf.append("</PERSONAE>");
477-
strBuf.append("</PLAY>");
478-
479-
writeset.add("/1/"+docId[0], new StringHandle().with(strBuf.toString()));
480-
docMgr.write(writeset);
481-
482-
docMgr.write(writeset);
483-
484-
// Search for the range with attribute value true in rangeRelativeBucketConstraintOpt.xml document.
485-
StructuredQueryBuilder qb = new StructuredQueryBuilder();
486-
487-
// Build an object that represents StructuredQueryBuilder.ElementAttribute for use in values method
488-
// that is of type StructuredQueryBuilder.TextIndex
489-
490-
QueryDefinition qd = qb.value(qb.element("subgroup"), false);
491-
492-
// Create handle for the result
493-
StringHandle resultsHandle = new StringHandle().withFormat(Format.XML);
494-
queryMgr.search(qd, resultsHandle);
495-
496-
// Get the result
497-
String resultDoc = resultsHandle.get();
498-
499-
System.out.println(resultDoc);
500-
//Verify that search response has found 1 element attribute
501-
assertXpathEvaluatesTo("fn:doc(\"/1/play-persons.xml\")", "string(//*[local-name()='response']//*[local-name()='result']//@*[local-name()='path'])", resultDoc);
502-
assertXpathEvaluatesTo("3", "count(//*[local-name()='response']//*[local-name()='match'])", resultDoc);
503-
504-
// Search for the following royal (XML ELEMENT) in all-well.xml document.
505-
StructuredQueryBuilder qbStr = new StructuredQueryBuilder();
506-
QueryDefinition qdStr = qbStr.value(qbStr.element("PERSONA"), "KING OF FRANCE","DUKE OF FLORENCE", "BERTRAM, Count of Rousillon.","LAFEU, an old lord.");
507-
508-
// Create handle for the result
509-
StringHandle resultsHandleStr = new StringHandle().withFormat(Format.XML);
510-
queryMgr.search(qdStr, resultsHandleStr);
511-
512-
// Get the result
513-
String resultDocStr = resultsHandleStr.get();
514-
515-
System.out.println(resultDocStr);
516-
//Verify that search response has found 4 PERSONA elements under /PLAY/PERSONAE
517-
assertXpathEvaluatesTo("fn:doc(\"/1/play-persons.xml\")", "string(//*[local-name()='response']//*[local-name()='result']//@*[local-name()='path'])", resultDocStr);
518-
assertXpathEvaluatesTo("4", "count(//*[local-name()='response']//*[local-name()='match'])", resultDocStr);
519-
}
405+
520406
}

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

Lines changed: 121 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,17 @@
1616

1717
package com.marklogic.client.functionaltest;
1818

19+
import static org.custommonkey.xmlunit.XMLAssert.assertXpathEvaluatesTo;
1920
import static org.junit.Assert.*;
2021

2122
import java.io.IOException;
23+
import java.util.Calendar;
2224
import java.util.HashMap;
2325

2426
import javax.xml.parsers.ParserConfigurationException;
2527
import javax.xml.transform.TransformerException;
2628

29+
import org.custommonkey.xmlunit.exceptions.XpathException;
2730
import org.junit.After;
2831
import org.junit.AfterClass;
2932
import org.junit.Before;
@@ -55,6 +58,7 @@
5558
import com.marklogic.client.io.StringHandle;
5659
import com.marklogic.client.io.DocumentMetadataHandle.Capability;
5760
import com.marklogic.client.query.MatchDocumentSummary;
61+
import com.marklogic.client.query.QueryDefinition;
5862
import com.marklogic.client.query.QueryManager;
5963
import com.marklogic.client.query.RawStructuredQueryDefinition;
6064
import com.marklogic.client.query.QueryManager.QueryView;
@@ -334,7 +338,8 @@ public void testBulkSearchSQDwithTransactionsandDOMHandle() throws Exception{
334338
finally{t.rollback();}
335339

336340
docMgr.search(qd, 1,results);
337-
assertNull("Total search results after rollback are ",results.get().getElementsByTagNameNS("*", "response").item(0).getAttributes().getNamedItem("total"));
341+
System.out.println(convertXMLDocumentToString(results.get()));
342+
assertEquals("Total search results after rollback are ",results.get().getElementsByTagNameNS("*", "response").item(0).getAttributes().getNamedItem("total").getNodeValue(),"0");
338343

339344
}
340345
//This test is to verify RAW XML structured Query
@@ -454,4 +459,119 @@ public void testBulkSearchRawJSONStrucQD() throws Exception{
454459
System.out.println(results.get().toString());
455460
assertEquals("Total search results before transaction rollback are ","204",results.get().get("total").asText());
456461
}
462+
/* Searching for boolean and string in XML element using value query.
463+
* Purpose: To validate QueryBuilder's new value methods (in 8.0) in XML document using an element.
464+
*
465+
* Load a file that has a boolean value in a XML attribute and use query def to search on that boolean value
466+
*
467+
* Methods used : value(StructuredQueryBuilder.TextIndex index, boolean)
468+
* value(StructuredQueryBuilder.TextIndex index, String)
469+
*/
470+
@Test
471+
public void testQueryBuilderValueWithBooleanAndString() throws XpathException, SAXException, IOException {
472+
473+
String docId[] = {"play-persons.xml"};
474+
475+
TextDocumentManager docMgr = client.newTextDocumentManager();
476+
QueryManager queryMgr = client.newQueryManager();
477+
DocumentWriteSet writeset = docMgr.newWriteSet();
478+
479+
// Put meta-data
480+
481+
DocumentMetadataHandle metadataHandle = new DocumentMetadataHandle();
482+
metadataHandle.getCollections().addAll("my-collection1","my-collection2");
483+
metadataHandle.getPermissions().add("app-user", Capability.UPDATE, Capability.READ);
484+
metadataHandle.getProperties().put("reviewed", true);
485+
metadataHandle.getProperties().put("myString", "foo");
486+
metadataHandle.getProperties().put("myInteger", 10);
487+
metadataHandle.getProperties().put("myDecimal", 34.56678);
488+
metadataHandle.getProperties().put("myCalendar", Calendar.getInstance().get(Calendar.YEAR));
489+
metadataHandle.setQuality(23);
490+
491+
writeset.addDefault(metadataHandle);
492+
493+
// Create a new document using StringHandle
494+
StringBuffer strBuf = new StringBuffer();
495+
496+
strBuf.append("<PLAY>");
497+
strBuf.append("<TITLE>All's Well That Ends Well</TITLE>");
498+
strBuf.append("<PERSONAE>");
499+
strBuf.append("<TITLE>Dramatis Personae</TITLE>");
500+
501+
strBuf.append("<PGROUP>");
502+
strBuf.append("<subgroup>true</subgroup>");
503+
504+
strBuf.append("<PERSONA>KING OF FRANCE</PERSONA>");
505+
strBuf.append("<PERSONA>DUKE OF FLORENCE</PERSONA>");
506+
strBuf.append("<PERSONA>BERTRAM, Count of Rousillon.</PERSONA>");
507+
strBuf.append("<PERSONA>LAFEU, an old lord.</PERSONA>");
508+
strBuf.append("</PGROUP>");
509+
510+
strBuf.append("<PGROUP>");
511+
strBuf.append("<subgroup>false</subgroup>");
512+
513+
strBuf.append("<PERSONA>PAROLLES, a follower of Bertram.</PERSONA>");
514+
strBuf.append("<PERSONA>A Page. </PERSONA>");
515+
strBuf.append("</PGROUP>");
516+
517+
strBuf.append("<PGROUP>");
518+
strBuf.append("<subgroup>false</subgroup>");
519+
strBuf.append("<PERSONA>COUNTESS OF ROUSILLON, mother to Bertram. </PERSONA>");
520+
strBuf.append("<PERSONA>HELENA, a gentlewoman protected by the Countess.</PERSONA>");
521+
strBuf.append("<PERSONA>An old Widow of Florence. </PERSONA>");
522+
strBuf.append("<PERSONA>DIANA, daughter to the Widow.</PERSONA>");
523+
strBuf.append("</PGROUP>");
524+
525+
strBuf.append("<PGROUP>");
526+
strBuf.append("<subgroup>false</subgroup>");
527+
strBuf.append("<PERSONA>VIOLENTA</PERSONA>");
528+
strBuf.append("<PERSONA>MARIANA</PERSONA>");
529+
strBuf.append("<GRPDESCR>neighbours and friends to the Widow.</GRPDESCR>");
530+
strBuf.append("</PGROUP>");
531+
532+
strBuf.append("<PERSONA>Lords, Officers, Soldiers, &amp;c., French and Florentine.</PERSONA>");
533+
strBuf.append("</PERSONAE>");
534+
strBuf.append("</PLAY>");
535+
536+
writeset.add("/1/"+docId[0], new StringHandle().with(strBuf.toString()));
537+
docMgr.write(writeset);
538+
539+
docMgr.write(writeset);
540+
541+
// Search for the range with attribute value true in rangeRelativeBucketConstraintOpt.xml document.
542+
StructuredQueryBuilder qb = new StructuredQueryBuilder();
543+
544+
// Build an object that represents StructuredQueryBuilder.ElementAttribute for use in values method
545+
// that is of type StructuredQueryBuilder.TextIndex
546+
547+
QueryDefinition qd = qb.value(qb.element("subgroup"), false);
548+
549+
// Create handle for the result
550+
StringHandle resultsHandle = new StringHandle().withFormat(Format.XML);
551+
queryMgr.search(qd, resultsHandle);
552+
553+
// Get the result
554+
String resultDoc = resultsHandle.get();
555+
556+
System.out.println(resultDoc);
557+
//Verify that search response has found 1 element attribute
558+
assertXpathEvaluatesTo("fn:doc(\"/1/play-persons.xml\")", "string(//*[local-name()='response']//*[local-name()='result']//@*[local-name()='path'])", resultDoc);
559+
assertXpathEvaluatesTo("3", "count(//*[local-name()='response']//*[local-name()='match'])", resultDoc);
560+
561+
// Search for the following royal (XML ELEMENT) in all-well.xml document.
562+
StructuredQueryBuilder qbStr = new StructuredQueryBuilder();
563+
QueryDefinition qdStr = qbStr.value(qbStr.element("PERSONA"), "KING OF FRANCE","DUKE OF FLORENCE", "BERTRAM, Count of Rousillon.","LAFEU, an old lord.");
564+
565+
// Create handle for the result
566+
StringHandle resultsHandleStr = new StringHandle().withFormat(Format.XML);
567+
queryMgr.search(qdStr, resultsHandleStr);
568+
569+
// Get the result
570+
String resultDocStr = resultsHandleStr.get();
571+
572+
System.out.println(resultDocStr);
573+
//Verify that search response has found 4 PERSONA elements under /PLAY/PERSONAE
574+
assertXpathEvaluatesTo("fn:doc(\"/1/play-persons.xml\")", "string(//*[local-name()='response']//*[local-name()='result']//@*[local-name()='path'])", resultDocStr);
575+
assertXpathEvaluatesTo("4", "count(//*[local-name()='response']//*[local-name()='match'])", resultDocStr);
576+
}
457577
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public void validateMetadata(DocumentMetadataHandle mh){
149149
assertTrue("Document property reviewed not found or not correct", actualProperties.contains("reviewed:true"));
150150
assertTrue("Document property myInteger not found or not correct", actualProperties.contains("myInteger:10"));
151151
assertTrue("Document property myDecimal not found or not correct", actualProperties.contains("myDecimal:34.56678"));
152-
assertTrue("Document property myCalendar not found or not correct", actualProperties.contains("myCalendar:2014"));
152+
assertTrue("Document property myCalendar not found or not correct", actualProperties.contains("myCalendar:2015"));
153153
assertTrue("Document property myString not found or not correct", actualProperties.contains("myString:foo"));
154154

155155
// Permissions

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
package com.marklogic.client.functionaltest;
1818

1919
import static org.junit.Assert.assertEquals;
20+
import static org.junit.Assert.assertFalse;
2021
import static org.junit.Assert.assertNotNull;
22+
import static org.junit.Assert.assertTrue;
2123

2224
import java.util.Calendar;
2325
import java.util.TimeZone;
@@ -34,6 +36,7 @@
3436
import com.marklogic.client.DatabaseClient;
3537
import com.marklogic.client.DatabaseClientFactory;
3638
import com.marklogic.client.DatabaseClientFactory.Authentication;
39+
import com.marklogic.client.ResourceNotFoundException;
3740
import com.marklogic.client.document.DocumentManager.Metadata;
3841
import com.marklogic.client.document.DocumentWriteSet;
3942
import com.marklogic.client.document.JSONDocumentManager;
@@ -360,15 +363,18 @@ public void testPOJORepoDeleteDateTime() {
360363
pojoReposProducts.delete(calTime);
361364
// Introduce a wait for the document to be deleted.
362365
try {
363-
Thread.sleep(5000);
364-
} catch (InterruptedException e) {
366+
artifact = pojoReposProducts.read(calTime);
367+
assertFalse("Test Expecting exception",true);
368+
} catch (ResourceNotFoundException e) {
365369
// TODO Auto-generated catch block
366-
e.printStackTrace();
370+
assertTrue("expected exception",true);
371+
}catch (Exception e){
372+
assertFalse("Test got unexpected",true);
367373
}
368374
// Validate the artifact read back.
369-
long count = pojoReposProducts.count();
370-
371-
assertEquals("Artifact with calendar as Id found - Delete did not work",0, count);
375+
// long count = pojoReposProducts.count();
376+
//
377+
// assertEquals("Artifact with calendar as Id found - Delete did not work",0, count);
372378
}
373379

374380
@Test

0 commit comments

Comments
 (0)