|
19 | 19 | import static org.junit.Assert.assertTrue; |
20 | 20 |
|
21 | 21 | import java.io.IOException; |
| 22 | +import java.io.InputStream; |
| 23 | +import java.io.File; |
22 | 24 | import java.util.ArrayList; |
23 | 25 |
|
24 | 26 | import javax.xml.parsers.DocumentBuilderFactory; |
|
34 | 36 | import org.w3c.dom.NodeList; |
35 | 37 | import org.xml.sax.SAXException; |
36 | 38 |
|
| 39 | +import com.marklogic.client.Transaction; |
37 | 40 | import com.marklogic.client.document.DocumentManager.Metadata; |
38 | 41 | import com.marklogic.client.document.XMLDocumentManager; |
39 | 42 | import com.marklogic.client.io.DocumentMetadataHandle; |
40 | 43 | import com.marklogic.client.io.DocumentMetadataHandle.Capability; |
41 | 44 | import com.marklogic.client.io.DocumentMetadataHandle.DocumentCollections; |
42 | 45 | import com.marklogic.client.io.DocumentMetadataHandle.DocumentPermissions; |
43 | 46 | import com.marklogic.client.io.DocumentMetadataHandle.DocumentProperties; |
| 47 | +import com.marklogic.client.io.FileHandle; |
| 48 | +import com.marklogic.client.io.InputStreamHandle; |
44 | 49 | import com.marklogic.client.io.StringHandle; |
45 | 50 |
|
46 | 51 | public class DocumentMetadataHandleTest { |
@@ -165,4 +170,26 @@ public void testReadWriteMetadata() throws SAXException, IOException, XpathExcep |
165 | 170 | assertEquals("Wrong quality", 3, metaReadHandle.getQuality()); |
166 | 171 | } |
167 | 172 | } |
| 173 | + |
| 174 | + // testing https://github.com/marklogic/java-client-api/issues/783 |
| 175 | + @Test |
| 176 | + public void testStack20170725() throws IOException { |
| 177 | + XMLDocumentManager documentManager = Common.client.newXMLDocumentManager(); |
| 178 | + Transaction transaction = Common.client.openTransaction(); |
| 179 | + DocumentMetadataHandle metadataHandle = new DocumentMetadataHandle(); |
| 180 | + documentManager.writeAs("all_well.xml", new FileHandle( |
| 181 | + new File("test-complete/src/test/java/com/marklogic/client/functionaltest/data/all_well.xml"))); |
| 182 | + InputStreamHandle handle = documentManager.read("all_well.xml", metadataHandle, new InputStreamHandle(), transaction); |
| 183 | + try { |
| 184 | + InputStream stream = handle.get(); |
| 185 | + try { |
| 186 | + while ( stream.read() > -1 ) {} |
| 187 | + } finally { |
| 188 | + stream.close(); |
| 189 | + } |
| 190 | + } finally { |
| 191 | + handle.close(); |
| 192 | + } |
| 193 | + // if we ran without throwing any exceptions, then this test passes |
| 194 | + } |
168 | 195 | } |
0 commit comments