|
17 | 17 |
|
18 | 18 | import static org.custommonkey.xmlunit.XMLAssert.assertXpathEvaluatesTo; |
19 | 19 | import static org.junit.Assert.assertEquals; |
| 20 | +import static org.junit.Assert.assertNotNull; |
20 | 21 | import static org.junit.Assert.assertTrue; |
21 | 22 |
|
| 23 | +import java.io.File; |
22 | 24 | import java.io.IOException; |
| 25 | +import java.util.Random; |
23 | 26 |
|
24 | 27 | import javax.xml.bind.DatatypeConverter; |
25 | 28 |
|
|
30 | 33 | import org.w3c.dom.Document; |
31 | 34 |
|
32 | 35 | import com.marklogic.client.document.DocumentDescriptor; |
| 36 | +import com.marklogic.client.document.DocumentPage; |
| 37 | +import com.marklogic.client.document.DocumentRecord; |
| 38 | +import com.marklogic.client.document.DocumentWriteSet; |
33 | 39 | import com.marklogic.client.document.DocumentManager.Metadata; |
34 | 40 | import com.marklogic.client.document.BinaryDocumentManager; |
35 | 41 | import com.marklogic.client.document.BinaryDocumentManager.MetadataExtraction; |
36 | 42 | import com.marklogic.client.io.BytesHandle; |
37 | 43 | import com.marklogic.client.io.DOMHandle; |
| 44 | +import com.marklogic.client.io.FileHandle; |
| 45 | +import com.marklogic.client.io.Format; |
38 | 46 | import com.marklogic.client.io.InputStreamHandle; |
39 | 47 |
|
40 | 48 | public class BinaryDocumentTest { |
@@ -84,4 +92,19 @@ public void testReadWrite() throws IOException, XpathException { |
84 | 92 | assertXpathEvaluatesTo("text HD-HTML","string(/*[local-name()='metadata']/*[local-name()='properties']/*[local-name()='filter-capabilities'])", metadataDocument); |
85 | 93 | assertXpathEvaluatesTo("815","string(/*[local-name()='metadata']/*[local-name()='properties']/*[local-name()='size'])", metadataDocument); |
86 | 94 | } |
| 95 | + |
| 96 | + @Test |
| 97 | + public void test_issue_758() throws Exception { |
| 98 | + BinaryDocumentManager docMgr = Common.client.newBinaryDocumentManager(); |
| 99 | + DocumentWriteSet writeset =docMgr.newWriteSet(); |
| 100 | + FileHandle h1 = new FileHandle(new File( |
| 101 | + "test-complete/src/test/java/com/marklogic/client/functionaltest/data/Sega-4MB.jpg")); |
| 102 | + String uri = "BinaryDocumentTest_" + new Random().nextInt(10000) + "/" + "Sega-4MB.jpg"; |
| 103 | + writeset.add(uri, h1); |
| 104 | + docMgr.write(writeset); |
| 105 | + DocumentPage page = docMgr.read(uri); |
| 106 | + DocumentRecord rec = page.next(); |
| 107 | + assertNotNull("DocumentRecord should never be null", rec); |
| 108 | + assertEquals(rec.getFormat(),Format.BINARY); |
| 109 | + } |
87 | 110 | } |
0 commit comments