@@ -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, &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}
0 commit comments