@Test public void testXMLFormatOnJSON() throws KeyManagementException, NoSuchAlgorithmException, IOException, ParserConfigurationException, SAXException, XpathException { System.out.println("Running testXMLFormatOnJSON"); String filename = "json-original.json"; String uri = "/xml-format-json-file/"; // connect the client DatabaseClient client = getDatabaseClient("rest-writer", "x", getConnType()); // create doc manager DocumentManager docMgr = client.newDocumentManager(); File file = new File("src/test/java/com/marklogic/client/functionaltest/data/" + filename); // create a handle on the content FileHandle handle = new FileHandle(file); handle.set(file); handle.setFormat(Format.XML); // create docId String docId = uri + filename; docMgr.write(docId, handle); String expectedUri = uri + filename; String docUri = docMgr.exists(expectedUri).getUri(); assertEquals("URI is not found", expectedUri, docUri); // release the client client.release(); }
@Test public void testTextFormatOnText() throws KeyManagementException, NoSuchAlgorithmException, IOException, ParserConfigurationException, SAXException, XpathException { System.out.println("Running testTextFormatOnText"); String filename = "text-original.txt"; String uri = "/txt-format-txt-file/"; // connect the client DatabaseClient client = getDatabaseClient("rest-writer", "x", getConnType()); // create doc manager DocumentManager docMgr = client.newDocumentManager(); File file = new File("src/test/java/com/marklogic/client/functionaltest/data/" + filename); // create a handle on the content FileHandle handle = new FileHandle(file); handle.set(file); handle.setFormat(Format.TEXT); // create docId String docId = uri + filename; docMgr.write(docId, handle); String expectedUri = uri + filename; String docUri = docMgr.exists(expectedUri).getUri(); assertEquals("URI is not found", expectedUri, docUri); // release the client client.release(); }
@Test public void testXMLFormatOnXML() throws KeyManagementException, NoSuchAlgorithmException, IOException, ParserConfigurationException, SAXException, XpathException { System.out.println("Running testXMLFormatOnXML"); String filename = "flipper.xml"; String uri = "/xml-format-xml-file/"; // connect the client DatabaseClient client = getDatabaseClient("rest-writer", "x", getConnType()); // create doc manager DocumentManager<GenericReadHandle, GenericWriteHandle> docMgr = client.newDocumentManager(); File file = new File("src/test/java/com/marklogic/client/functionaltest/data/" + filename); // create a handle on the content FileHandle handle = new FileHandle(file); handle.set(file); handle.setFormat(Format.XML); // create docId String docId = uri + filename; docMgr.write(docId, handle); String expectedUri = uri + filename; String docUri = docMgr.exists(expectedUri).getUri(); assertEquals("URI is not found", expectedUri, docUri); // release the client client.release(); }
@Test public void testBinaryFormatOnXML() throws KeyManagementException, NoSuchAlgorithmException, IOException, ParserConfigurationException, SAXException, XpathException { System.out.println("Running testBinaryFormatOnXML"); String filename = "flipper.xml"; String uri = "/bin-format-xml-file/"; // connect the client DatabaseClient client = getDatabaseClient("rest-writer", "x", getConnType()); // create doc manager DocumentManager docMgr = client.newDocumentManager(); File file = new File("src/test/java/com/marklogic/client/functionaltest/data/" + filename); // create a handle on the content FileHandle handle = new FileHandle(file); handle.set(file); handle.setFormat(Format.BINARY); // create docId String docId = uri + filename; docMgr.write(docId, handle); String expectedUri = uri + filename; String docUri = docMgr.exists(expectedUri).getUri(); assertEquals("URI is not found", expectedUri, docUri); // release the client client.release(); }
@Test public void testJSONFormatOnJSON() throws KeyManagementException, NoSuchAlgorithmException, IOException, ParserConfigurationException, SAXException, XpathException { System.out.println("Running testJSONFormatOnJSON"); String filename = "json-original.json"; String uri = "/json-format-json-file/"; // connect the client DatabaseClient client = getDatabaseClient("rest-writer", "x", getConnType()); // create doc manager DocumentManager docMgr = client.newDocumentManager(); File file = new File("src/test/java/com/marklogic/client/functionaltest/data/" + filename); // create a handle on the content FileHandle handle = new FileHandle(file); handle.set(file); handle.setFormat(Format.JSON); // create docId String docId = uri + filename; docMgr.write(docId, handle); String expectedUri = uri + filename; String docUri = docMgr.exists(expectedUri).getUri(); assertEquals("URI is not found", expectedUri, docUri); // release the client client.release(); }
@Test public void testBinaryFormatOnText() throws KeyManagementException, NoSuchAlgorithmException, IOException, ParserConfigurationException, SAXException, XpathException { System.out.println("Running testBinaryFormatOnText"); String filename = "text-original.txt"; String uri = "/bin-format-txt-file/"; // connect the client DatabaseClient client = getDatabaseClient("rest-writer", "x", getConnType()); // create doc manager DocumentManager docMgr = client.newDocumentManager(); File file = new File("src/test/java/com/marklogic/client/functionaltest/data/" + filename); // create a handle on the content FileHandle handle = new FileHandle(file); handle.set(file); handle.setFormat(Format.BINARY); // create docId String docId = uri + filename; docMgr.write(docId, handle); String expectedUri = uri + filename; String docUri = docMgr.exists(expectedUri).getUri(); assertEquals("URI is not found", expectedUri, docUri); // release the client client.release(); }
@Test public void testTextFormatOnJSON() throws KeyManagementException, NoSuchAlgorithmException, IOException, ParserConfigurationException, SAXException, XpathException { System.out.println("Running testTextFormatOnJSON"); String filename = "json-original.json"; String uri = "/txt-format-json-file/"; // connect the client DatabaseClient client = getDatabaseClient("rest-writer", "x", getConnType()); // create doc manager DocumentManager docMgr = client.newDocumentManager(); File file = new File("src/test/java/com/marklogic/client/functionaltest/data/" + filename); // create a handle on the content FileHandle handle = new FileHandle(file); handle.set(file); handle.setFormat(Format.TEXT); // create docId String docId = uri + filename; docMgr.write(docId, handle); String expectedUri = uri + filename; String docUri = docMgr.exists(expectedUri).getUri(); assertEquals("URI is not found", expectedUri, docUri); // release the client client.release(); }
@Test public void testBinaryFormatOnBinary() throws KeyManagementException, NoSuchAlgorithmException, IOException, ParserConfigurationException, SAXException, XpathException { System.out.println("Running testBinaryFormatOnBinary"); String filename = "Pandakarlino.jpg"; String uri = "/bin-format-bin-file/"; // connect the client DatabaseClient client = getDatabaseClient("rest-writer", "x", getConnType()); // create doc manager DocumentManager docMgr = client.newDocumentManager(); File file = new File("src/test/java/com/marklogic/client/functionaltest/data/" + filename); // create a handle on the content FileHandle handle = new FileHandle(file); handle.set(file); handle.setFormat(Format.BINARY); // create docId String docId = uri + filename; docMgr.write(docId, handle); String expectedUri = uri + filename; String docUri = docMgr.exists(expectedUri).getUri(); assertEquals("URI is not found", expectedUri, docUri); // release the client client.release(); }
@Test public void testTextFormatOnXML() throws KeyManagementException, NoSuchAlgorithmException, IOException, ParserConfigurationException, SAXException, XpathException { System.out.println("Running testTextFormatOnXML"); String filename = "flipper.xml"; String uri = "/txt-format-xml-file/"; // connect the client DatabaseClient client = getDatabaseClient("rest-writer", "x", getConnType()); // create doc manager DocumentManager docMgr = client.newDocumentManager(); File file = new File("src/test/java/com/marklogic/client/functionaltest/data/" + filename); // create a handle on the content FileHandle handle = new FileHandle(file); handle.set(file); handle.setFormat(Format.TEXT); // create docId String docId = uri + filename; docMgr.write(docId, handle); String expectedUri = uri + filename; String docUri = docMgr.exists(expectedUri).getUri(); assertEquals("URI is not found", expectedUri, docUri); // release the client client.release(); }
@Test public void testBinaryFormatOnJSON() throws KeyManagementException, NoSuchAlgorithmException, IOException, ParserConfigurationException, SAXException, XpathException { System.out.println("Running testBinaryFormatOnJSON"); String filename = "json-original.json"; String uri = "/bin-format-json-file/"; // connect the client DatabaseClient client = getDatabaseClient("rest-writer", "x", getConnType()); // create doc manager DocumentManager docMgr = client.newDocumentManager(); File file = new File("src/test/java/com/marklogic/client/functionaltest/data/" + filename); // create a handle on the content FileHandle handle = new FileHandle(file); handle.set(file); handle.setFormat(Format.BINARY); // create docId String docId = uri + filename; docMgr.write(docId, handle); String expectedUri = uri + filename; String docUri = docMgr.exists(expectedUri).getUri(); assertEquals("URI is not found", expectedUri, docUri); // release the client client.release(); }
@Test public void testXMLFormatOnText() throws KeyManagementException, NoSuchAlgorithmException, IOException, ParserConfigurationException, SAXException, XpathException { System.out.println("Running testXMLFormatOnText"); String filename = "text-original.txt"; String uri = "/xml-format-txt-file/"; // connect the client DatabaseClient client = getDatabaseClient("rest-writer", "x", getConnType()); // create doc manager DocumentManager docMgr = client.newDocumentManager(); File file = new File("src/test/java/com/marklogic/client/functionaltest/data/" + filename); // create a handle on the content FileHandle handle = new FileHandle(file); handle.set(file); handle.setFormat(Format.XML); // create docId String docId = uri + filename; docMgr.write(docId, handle); String expectedUri = uri + filename; String docUri = docMgr.exists(expectedUri).getUri(); assertEquals("URI is not found", expectedUri, docUri); // release the client client.release(); }
@Test public void testUnknownMimetypeOnXML() throws KeyManagementException, NoSuchAlgorithmException, IOException, ParserConfigurationException, SAXException, XpathException { System.out.println("Running testUnknownMimetypeOnXML"); String filename = "flipper.xml"; String uri = "/xml-mimetype/"; // connect the client DatabaseClient client = getDatabaseClient("rest-writer", "x", getConnType()); // create doc manager DocumentManager docMgr = client.newDocumentManager(); File file = new File("src/test/java/com/marklogic/client/functionaltest/data/" + filename); // create a handle on the content FileHandle handle = new FileHandle(file); handle.set(file); handle.setMimetype("application/x-excel"); // create docId String docId = uri + filename; docMgr.write(docId, handle); String expectedUri = uri + filename; String docUri = docMgr.exists(expectedUri).getUri(); assertEquals("URI is not found", expectedUri, docUri); // read document mimetype docMgr.read(docId, handle); String format = handle.getFormat().name(); String expectedFormat = "XML"; assertEquals("Format does not match", expectedFormat, format); // release the client client.release(); }
@Test public void testUnsupportedMimetypeOnXML() throws KeyManagementException, NoSuchAlgorithmException, IOException, ParserConfigurationException, SAXException, XpathException { System.out.println("Running testUnsupportedMimetypeOnXML"); String filename = "flipper.xml"; String uri = "/xml-mimetype/"; // connect the client DatabaseClient client = getDatabaseClient("rest-writer", "x", getConnType()); // create doc manager DocumentManager docMgr = client.newDocumentManager(); File file = new File("src/test/java/com/marklogic/client/functionaltest/data/" + filename); // create a handle on the content FileHandle handle = new FileHandle(file); handle.set(file); handle.setMimetype("application/vnd.nokia.configuration-message"); // create docId String docId = uri + filename; docMgr.write(docId, handle); String expectedUri = uri + filename; String docUri = docMgr.exists(expectedUri).getUri(); assertEquals("URI is not found", expectedUri, docUri); // read document mimetype docMgr.read(docId, handle); String format = handle.getFormat().name(); String expectedFormat = "XML"; assertEquals("Format does not match", expectedFormat, format); // release the client client.release(); }
@Test public void testMatchedMimetypeOnJSON() throws KeyManagementException, NoSuchAlgorithmException, IOException, ParserConfigurationException, SAXException, XpathException { System.out.println("Running testMatchedMimetypeOnJSON"); String filename = "json-original.json"; String uri = "/json-mimetype/"; // connect the client DatabaseClient client = getDatabaseClient("rest-writer", "x", getConnType()); // create doc manager DocumentManager docMgr = client.newDocumentManager(); File file = new File("src/test/java/com/marklogic/client/functionaltest/data/" + filename); // create a handle on the content FileHandle handle = new FileHandle(file); handle.set(file); handle.setMimetype("application/json"); // create docId String docId = uri + filename; docMgr.write(docId, handle); String expectedUri = uri + filename; String docUri = docMgr.exists(expectedUri).getUri(); assertEquals("URI is not found", expectedUri, docUri); // read document format docMgr.read(docId, handle); String format = handle.getFormat().name(); String expectedFormat = "JSON"; assertEquals("Format does not match", expectedFormat, format); // release the client client.release(); }
@Test public void testMatchedMimetypeOnBinary() throws KeyManagementException, NoSuchAlgorithmException, IOException, ParserConfigurationException, SAXException, XpathException { System.out.println("Running testMatchedMimetypeOnBinary"); String filename = "Pandakarlino.jpg"; String uri = "/bin-mimetype/"; // connect the client DatabaseClient client = getDatabaseClient("rest-writer", "x", getConnType()); // create doc manager DocumentManager docMgr = client.newDocumentManager(); File file = new File("src/test/java/com/marklogic/client/functionaltest/data/" + filename); // create a handle on the content FileHandle handle = new FileHandle(file); handle.set(file); handle.setMimetype("image/jpeg"); // create docId String docId = uri + filename; docMgr.write(docId, handle); String expectedUri = uri + filename; String docUri = docMgr.exists(expectedUri).getUri(); assertEquals("URI is not found", expectedUri, docUri); // read document format docMgr.read(docId, handle); String format = handle.getFormat().name(); String expectedFormat = "BINARY"; assertEquals("Format does not match", expectedFormat, format); // release the client client.release(); }
@Test public void testUnmatchedMimetypeOnXML() throws KeyManagementException, NoSuchAlgorithmException, IOException, ParserConfigurationException, SAXException, XpathException { System.out.println("Running testUnmatchedMimetypeOnXML"); String filename = "flipper.xml"; String uri = "/xml-mimetype/"; // connect the client DatabaseClient client = getDatabaseClient("rest-writer", "x", getConnType()); // create doc manager DocumentManager docMgr = client.newDocumentManager(); File file = new File("src/test/java/com/marklogic/client/functionaltest/data/" + filename); // create a handle on the content FileHandle handle = new FileHandle(file); handle.set(file); handle.setMimetype("image/svg+xml"); // create docId String docId = uri + filename; docMgr.write(docId, handle); String expectedUri = uri + filename; String docUri = docMgr.exists(expectedUri).getUri(); assertEquals("URI is not found", expectedUri, docUri); // read document mimetype docMgr.read(docId, handle); String format = handle.getFormat().name(); String expectedFormat = "XML"; assertEquals("Format does not match", expectedFormat, format); // release the client client.release(); }
@Test public void testUnknownMimetypeOnText() throws KeyManagementException, NoSuchAlgorithmException, IOException, ParserConfigurationException, SAXException, XpathException { System.out.println("Running testUnknownMimetypeOnText"); String filename = "text-original.txt"; String uri = "/txt-mimetype/"; // connect the client DatabaseClient client = getDatabaseClient("rest-writer", "x", getConnType()); // create doc manager DocumentManager docMgr = client.newDocumentManager(); File file = new File("src/test/java/com/marklogic/client/functionaltest/data/" + filename); // create a handle on the content FileHandle handle = new FileHandle(file); handle.set(file); handle.setMimetype("application/rtf"); // create docId String docId = uri + filename; docMgr.write(docId, handle); String expectedUri = uri + filename; String docUri = docMgr.exists(expectedUri).getUri(); assertEquals("URI is not found", expectedUri, docUri); // read document mimetype docMgr.read(docId, handle); String format = handle.getFormat().name(); String expectedFormat = "TEXT"; assertEquals("Format does not match", expectedFormat, format); // release the client client.release(); }
@Test public void testUnsupportedMimetypeOnText() throws KeyManagementException, NoSuchAlgorithmException, IOException, ParserConfigurationException, SAXException, XpathException { System.out.println("Running testUnsupportedMimetypeOnText"); String filename = "text-original.txt"; String uri = "/txt-mimetype/"; // connect the client DatabaseClient client = getDatabaseClient("rest-writer", "x", getConnType()); // create doc manager DocumentManager docMgr = client.newDocumentManager(); File file = new File("src/test/java/com/marklogic/client/functionaltest/data/" + filename); // create a handle on the content FileHandle handle = new FileHandle(file); handle.set(file); handle.setMimetype("application/vnd.nokia.configuration-message"); // create docId String docId = uri + filename; docMgr.write(docId, handle); String expectedUri = uri + filename; String docUri = docMgr.exists(expectedUri).getUri(); assertEquals("URI is not found", expectedUri, docUri); // read document mimetype docMgr.read(docId, handle); String format = handle.getFormat().name(); String expectedFormat = "TEXT"; assertEquals("Format does not match", expectedFormat, format); // release the client client.release(); }
@Test public void testMatchedMimetypeOnXML() throws KeyManagementException, NoSuchAlgorithmException, IOException, ParserConfigurationException, SAXException, XpathException { System.out.println("Running testMatchedMimetypeOnXML"); String filename = "flipper.xml"; String uri = "/xml-mimetype/"; // connect the client DatabaseClient client = getDatabaseClient("rest-writer", "x", getConnType()); // create doc manager DocumentManager docMgr = client.newDocumentManager(); File file = new File("src/test/java/com/marklogic/client/functionaltest/data/" + filename); // create a handle on the content FileHandle handle = new FileHandle(file); handle.set(file); handle.setMimetype("application/xml"); // create docId String docId = uri + filename; docMgr.write(docId, handle); String expectedUri = uri + filename; String docUri = docMgr.exists(expectedUri).getUri(); assertEquals("URI is not found", expectedUri, docUri); // read document format docMgr.read(docId, handle); String format = handle.getFormat().name(); String expectedFormat = "XML"; assertEquals("Format does not match", expectedFormat, format); // release the client client.release(); }
@Test public void testUnmatchedMimetypeOnBinary() throws KeyManagementException, NoSuchAlgorithmException, IOException, ParserConfigurationException, SAXException, XpathException { System.out.println("Running testUnmatchedMimetypeOnBinary"); String filename = "Pandakarlino.jpg"; String uri = "/bin-mimetype/"; // connect the client DatabaseClient client = getDatabaseClient("rest-writer", "x", getConnType()); // create doc manager DocumentManager docMgr = client.newDocumentManager(); File file = new File("src/test/java/com/marklogic/client/functionaltest/data/" + filename); // create a handle on the content FileHandle handle = new FileHandle(file); handle.set(file); handle.setMimetype("text/rtf"); // create docId String docId = uri + filename; docMgr.write(docId, handle); String expectedUri = uri + filename; String docUri = docMgr.exists(expectedUri).getUri(); assertEquals("URI is not found", expectedUri, docUri); // read document mimetype docMgr.read(docId, handle); String format = handle.getFormat().name(); String expectedFormat = "BINARY"; assertEquals("Format does not match", expectedFormat, format); // release the client client.release(); }