@@ -385,14 +385,29 @@ public void testWriteMultipleBinaryDocWithDefaultMetadata2() throws Exception
385385 docMgr .readMetadata (rec .getUri (), mh );
386386 assertEquals (" quality" ,5 ,mh .getQuality ());
387387
388- assertTrue ("default collections reset" ,mh .getCollections ().isEmpty ());
388+ // Collections - Test corrected for bug fix from 32783
389+ /* Default collections are applied only in the following cases:
390+
391+ * Creating a document with single write without specifying collections
392+ * Creating a document or updating document content with bulk write without specifying collections
393+ * Resetting collections by deleting all or collection metadata
394+ *
395+ */
396+
397+ String expectedCollections = "size:1|http://permission-collections/|" ;
398+ String actualCollections = getDocumentCollectionsString (mh .getCollections ());
399+
400+ assertEquals ("Document collections difference" , expectedCollections , actualCollections );
389401
390402 page = docMgr .read ("/1/mlfavicon.png" );
391403 rec = page .next ();
392404 docMgr .readMetadata (rec .getUri (), mh );
393405 assertEquals ("default quality" ,0 ,mh .getQuality ());
394406 // System.out.println(rec.getUri()+mh.getCollections().isEmpty());
395- assertFalse ("default collections reset" ,mh .getCollections ().isEmpty ());
407+ expectedCollections = "size:1|collection1|" ;
408+ actualCollections = getDocumentCollectionsString (mh .getCollections ());
409+
410+ assertEquals ("Document collections difference" , expectedCollections , actualCollections );
396411
397412 page = docMgr .read ("/2/mlfavicon.png" );
398413 rec = page .next ();
@@ -462,7 +477,10 @@ public void testWriteMultipleJSONDocsWithDefaultMetadata2() throws Exception
462477 jdm .readMetadata (rec .getUri (), mh );
463478 System .out .print (mh .getCollections ().isEmpty ());
464479 assertEquals ("default quality" ,1 ,mh .getQuality ());
465- assertTrue ("default collections reset" ,mh .getCollections ().isEmpty ());
480+ String expectedCollections = "size:1|http://permission-collections/|" ;
481+ String actualCollections = getDocumentCollectionsString (mh .getCollections ());
482+
483+ assertEquals ("Document collections difference" , expectedCollections , actualCollections );
466484
467485 // Doc3 should have the system default document quality (0) because quality
468486 // was not included in the document-specific metadata. It should be in the
@@ -477,18 +495,20 @@ public void testWriteMultipleJSONDocsWithDefaultMetadata2() throws Exception
477495 DocumentMetadataHandle doc3Metadata =
478496 jdm .readMetadata ("doc3.json" , new DocumentMetadataHandle ());
479497 System .out .println ("doc3 quality: Expected=0, Actual=" + doc3Metadata .getPermissions ());
480- System .out .print ("doc3 collections: Expected: myCollection, Actual=" );
481- for (String collection : doc3Metadata .getCollections ()) {
482- System .out .print (collection + " " );
483- }
484- System .out .println ();
498+ expectedCollections = "size:1|mySpecificCollection|" ;
499+ actualCollections = getDocumentCollectionsString (mh .getCollections ());
500+
501+ assertEquals ("Document collections difference" , expectedCollections , actualCollections );
485502
486503 // Doc 4 should also use the 1st batch default metadata, with quality 1
487504 page = jdm .read ("doc4.json" );
488505 rec = page .next ();
489506 jdm .readMetadata (rec .getUri (), mh );
490507 assertEquals ("default quality" ,1 ,mh .getQuality ());
491- assertTrue ("default collections reset" ,mh .getCollections ().isEmpty ());
508+ expectedCollections = "size:1|http://permission-collections/|" ;
509+ actualCollections = getDocumentCollectionsString (mh .getCollections ());
510+
511+ assertEquals ("Document collections difference" , expectedCollections , actualCollections );
492512 // Doc5 should use the 2nd batch default metadata, with quality 2
493513 page = jdm .read ("doc5.json" );
494514 rec = page .next ();
@@ -553,7 +573,11 @@ public void testWriteGenericDocMgrWithDefaultMetadata() throws Exception
553573 DocumentRecord rec = page .next ();
554574 docMgr .readMetadata (rec .getUri (), mh );
555575 assertEquals ("default quality" ,10 ,mh .getQuality ());
556- assertTrue ("default collections missing" ,mh .getCollections ().isEmpty ());
576+
577+ String expectedCollections = "size:1|http://permission-collections/|" ;
578+ String actualCollections = getDocumentCollectionsString (mh .getCollections ());
579+
580+ assertEquals ("Document collections difference" , expectedCollections , actualCollections );
557581
558582 page = docMgr .read ("/generic/foo.xml" );
559583 rec = page .next ();
0 commit comments