|
17 | 17 | package com.marklogic.client.functionaltest;
|
18 | 18 |
|
19 | 19 | import static org.custommonkey.xmlunit.XMLAssert.assertXpathEvaluatesTo;
|
20 |
| -import static org.junit.Assert.assertEquals; |
21 |
| -import static org.junit.Assert.assertTrue; |
| 20 | +import static org.junit.Assert.*; |
22 | 21 |
|
23 | 22 | import java.io.File;
|
24 | 23 | import java.io.IOException;
|
|
38 | 37 | import org.w3c.dom.Document;
|
39 | 38 | import org.xml.sax.SAXException;
|
40 | 39 |
|
| 40 | +import com.fasterxml.jackson.databind.JsonNode; |
41 | 41 | import com.marklogic.client.DatabaseClient;
|
42 | 42 | import com.marklogic.client.DatabaseClientFactory.Authentication;
|
43 | 43 | import com.marklogic.client.admin.ServerConfigurationManager;
|
44 | 44 | import com.marklogic.client.io.DOMHandle;
|
45 | 45 | import com.marklogic.client.io.DocumentMetadataHandle;
|
46 | 46 | import com.marklogic.client.io.FileHandle;
|
47 | 47 | import com.marklogic.client.io.Format;
|
| 48 | +import com.marklogic.client.io.JacksonHandle; |
48 | 49 | import com.marklogic.client.io.StringHandle;
|
49 | 50 | import com.marklogic.client.query.QueryManager;
|
50 | 51 | import com.marklogic.client.query.RawCombinedQueryDefinition;
|
@@ -772,7 +773,73 @@ public void test12RawCombinedQueryFieldJSON() throws KeyManagementException, NoS
|
772 | 773 | // release client
|
773 | 774 | client.release();
|
774 | 775 | }
|
| 776 | + |
| 777 | + /* |
| 778 | + * When searching using a structured query, the <search:metrics/> element in the response used to include |
| 779 | + * an empty <search:extract-resolution-time/> |
| 780 | + * This test makes sure that the response does not have |
| 781 | + * <search:extract-resolution-time> |
| 782 | + * element |
| 783 | + */ |
| 784 | + |
| 785 | + @Test |
| 786 | + public void testBug43940() throws KeyManagementException, NoSuchAlgorithmException, IOException, ParserConfigurationException, SAXException, XpathException, TransformerException |
| 787 | + { |
| 788 | + // Negative test |
| 789 | + System.out.println("Running testBug43940"); |
| 790 | + |
| 791 | + String[] filenames = {"constraint1.xml", "constraint2.xml", "constraint3.xml", "constraint4.xml", "constraint5.xml"}; |
| 792 | + |
| 793 | + DatabaseClient client = getDatabaseClient("rest-admin", "x", Authentication.DIGEST); |
| 794 | + |
| 795 | + // set query option validation to true |
| 796 | + ServerConfigurationManager srvMgr = client.newServerConfigManager(); |
| 797 | + srvMgr.readConfiguration(); |
| 798 | + srvMgr.setQueryOptionValidation(true); |
| 799 | + srvMgr.writeConfiguration(); |
| 800 | + |
| 801 | + // write docs |
| 802 | + for(String filename : filenames) |
| 803 | + { |
| 804 | + writeDocumentUsingInputStreamHandle(client, filename, "/raw-combined-query/", "XML"); |
| 805 | + } |
| 806 | + |
| 807 | + // get the combined query |
| 808 | + File file = new File("src/test/java/com/marklogic/client/functionaltest/combined/combinedQueryMetricsTrue.xml"); |
| 809 | + |
| 810 | + String combinedQuery = convertFileToString(file); |
| 811 | + |
| 812 | + // create a handle for the search criteria |
| 813 | + StringHandle rawHandle = new StringHandle(combinedQuery); |
775 | 814 |
|
| 815 | + QueryManager queryMgr = client.newQueryManager(); |
| 816 | + |
| 817 | + // create a search definition based on the handle |
| 818 | + RawCombinedQueryDefinition querydef = queryMgr.newRawCombinedQueryDefinition(rawHandle); |
| 819 | + queryMgr.newStringDefinition("LinkResultDocumentsOpt.xml"); |
| 820 | + |
| 821 | + // create result handle |
| 822 | + JacksonHandle resultsHandle = new JacksonHandle(); |
| 823 | + queryMgr.search(querydef, resultsHandle); |
| 824 | + |
| 825 | + // get the result |
| 826 | + //Document resultDoc = resultsHandle.get(); |
| 827 | + JsonNode resultNode = resultsHandle.get().get("metrics"); |
| 828 | + System.out.println("Mime Type : "+resultsHandle.getMimetype()); |
| 829 | + System.out.println(resultNode); |
| 830 | + // Make sure response does not have extract-resolution-time property in the metrics |
| 831 | + assertNull(resultNode.get("extract-resolution-time")); |
| 832 | + // End of Negative test |
| 833 | + |
| 834 | + // Start of positive tests |
| 835 | + |
| 836 | + |
| 837 | + //End of positive tests |
| 838 | + |
| 839 | + // release client |
| 840 | + client.release(); |
| 841 | + } |
| 842 | + |
776 | 843 | @AfterClass
|
777 | 844 | public static void tearDown() throws Exception
|
778 | 845 | {
|
|
0 commit comments