20
20
import com .marklogic .client .ResourceNotFoundException ;
21
21
import com .marklogic .client .ResourceNotResendableException ;
22
22
import com .marklogic .client .admin .QueryOptionsManager ;
23
+ import com .marklogic .client .document .DocumentManager ;
24
+ import com .marklogic .client .document .DocumentPage ;
25
+ import com .marklogic .client .document .DocumentRecord ;
26
+ import com .marklogic .client .document .XMLDocumentManager ;
23
27
import com .marklogic .client .io .DocumentMetadataHandle ;
24
28
import com .marklogic .client .io .Format ;
25
29
import com .marklogic .client .io .SearchHandle ;
32
36
import org .junit .jupiter .api .Test ;
33
37
import org .slf4j .Logger ;
34
38
import org .slf4j .LoggerFactory ;
35
- import org .xml .sax .SAXException ;
36
39
37
- import javax .xml .parsers .ParserConfigurationException ;
38
40
import java .io .ByteArrayOutputStream ;
39
41
import java .io .IOException ;
40
42
41
43
import static org .junit .jupiter .api .Assertions .*;
42
44
43
45
public class StringSearchTest {
44
46
@ SuppressWarnings ("unused" )
45
- private static final Logger logger = ( Logger ) LoggerFactory .getLogger (StringSearchTest .class );
47
+ private static final Logger logger = LoggerFactory .getLogger (StringSearchTest .class );
46
48
47
49
@ BeforeAll
48
50
public static void beforeClass () {
@@ -54,9 +56,27 @@ public static void beforeClass() {
54
56
public static void afterClass () {
55
57
}
56
58
59
+ @ Test
60
+ void returnDocumentsWithMetadataValues () {
61
+ XMLDocumentManager mgr = Common .client .newXMLDocumentManager ();
62
+ mgr .write ("/metadata/test.xml" ,
63
+ new DocumentMetadataHandle ().withMetadataValue ("hello" , "world" ),
64
+ new StringHandle ("<test>metadataabc</test>" ));
65
+
66
+ mgr .setMetadataCategories (DocumentManager .Metadata .METADATAVALUES );
67
+
68
+ DocumentPage page = mgr .search (Common .client .newQueryManager ().newStructuredQueryBuilder ().term ("metadataabc" ), 1 );
69
+ assertTrue (page .hasNext ());
70
+
71
+ DocumentRecord record = page .next ();
72
+ assertEquals ("/metadata/test.xml" , record .getUri ());
73
+ DocumentMetadataHandle .DocumentMetadataValues values = record .getMetadata (new DocumentMetadataHandle ()).getMetadataValues ();
74
+ assertEquals ("world" , values .get ("hello" ));
75
+ }
76
+
57
77
@ Test
58
78
public void testStringSearch ()
59
- throws IOException , ParserConfigurationException , SAXException , FailedRequestException , ForbiddenUserException ,
79
+ throws FailedRequestException , ForbiddenUserException ,
60
80
ResourceNotFoundException , ResourceNotResendableException
61
81
{
62
82
String optionsName = writeOptions ();
0 commit comments