Skip to content

Commit 4a7d372

Browse files
committed
added graphManager tests for #358
1 parent 047a288 commit 4a7d372

File tree

1 file changed

+29
-5
lines changed

1 file changed

+29
-5
lines changed

test-complete/src/test/java/com/marklogic/client/functionaltest/TestSemanticsGraphManager.java

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@
2525
import com.marklogic.client.io.BytesHandle;
2626
import com.marklogic.client.io.FileHandle;
2727
import com.marklogic.client.io.InputStreamHandle;
28+
import com.marklogic.client.io.JacksonHandle;
2829
import com.marklogic.client.io.ReaderHandle;
2930
import com.marklogic.client.io.StringHandle;
31+
import com.marklogic.client.io.marker.TriplesReadHandle;
3032
import com.marklogic.client.semantics.Capability;
3133
import com.marklogic.client.semantics.GraphManager;
3234
import com.marklogic.client.semantics.GraphPermissions;
@@ -697,7 +699,7 @@ public void testWriteRead_defaultGraph() throws FileNotFoundException {
697699
* DeleteGraphs and validate ResourceNotFound Exception
698700
*/
699701
@Test
700-
public void test001MergeReplace_quads() throws FileNotFoundException, InterruptedException {
702+
public void testMergeReplace_quads() throws FileNotFoundException, InterruptedException {
701703
String uri = "http://test.sem.quads/json-quads";
702704
String ntriple6 = "<http://example.org/s6> <http://example.com/mergeQuadP> <http://example.org/o2> <http://test.sem.quads/json-quads>.";
703705
File file = new File(datasource + "bug25348.json");
@@ -733,7 +735,7 @@ public void test001MergeReplace_quads() throws FileNotFoundException, Interrupte
733735
*/
734736

735737
@Test
736-
public void test002MergeReplaceAs_Quads() throws Exception {
738+
public void testMergeReplaceAs_Quads() throws Exception {
737739
gmWriter.setDefaultMimetype(RDFMimeTypes.NQUADS);
738740
File file = new File(datasource + "semantics.nq");
739741
gmWriter.replaceGraphsAs(file);
@@ -777,12 +779,34 @@ public void testThings_file() throws Exception {
777779
String tripleGraphUri = "http://test.things.com/file";
778780
File file = new File(datasource + "relative5.xml");
779781
gmWriter.write(tripleGraphUri, new FileHandle(file));
780-
StringHandle things = gmWriter.things(new StringHandle(), "about");
782+
TriplesReadHandle things = gmWriter.things(new StringHandle(), "about");
781783
assertTrue("Things did not return expected Uri's",
782-
things.get().equals("<about> <http://purl.org/dc/elements/1.1/title> \"Anna's Homepage\" ."));
784+
things.toString().contains("<about> <http://purl.org/dc/elements/1.1/title> \"Anna's Homepage\" ."));
783785
gmWriter.delete(tripleGraphUri);
784786
}
785787

788+
@Test
789+
public void testWrite_rdfjson_JacksonHandle() throws Exception {
790+
File file = new File(datasource + "relative6.json");
791+
FileHandle filehandle = new FileHandle();
792+
filehandle.set(file);
793+
gmWriter.write("htp://test.sem.graph/rdfjson", filehandle.withMimetype("application/rdf+json"));
794+
JacksonHandle handle1 = gmWriter.read("htp://test.sem.graph/rdfjson", new JacksonHandle());
795+
JsonNode readFile = handle1.get();
796+
assertTrue("Did not insert document or inserted empty doc", readFile.toString().contains("http://purl.org/dc/elements/1.1/title"));
797+
}
798+
799+
800+
@Test
801+
public void testWrite_rdfjson_TripleReadHandle() throws Exception {
802+
File file = new File(datasource + "relative6.json");
803+
FileHandle filehandle = new FileHandle();
804+
filehandle.set(file);
805+
gmWriter.write("htp://test.sem.graph/rdfjson", filehandle.withMimetype("application/rdf+json"));
806+
TriplesReadHandle handle1 = gmWriter.read("htp://test.sem.graph/rdfjson", new JacksonHandle());
807+
assertTrue("Did not insert document or inserted empty doc", handle1.toString().contains("http://purl.org/dc/elements/1.1/title"));
808+
}
809+
786810
@Test
787811
public void testThings_fileNomatch() throws Exception {
788812
gmWriter.setDefaultMimetype(RDFMimeTypes.TRIPLEXML);
@@ -791,7 +815,7 @@ public void testThings_fileNomatch() throws Exception {
791815
gmWriter.write(tripleGraphUri, new FileHandle(file));
792816
Exception exp = null;
793817
try {
794-
StringHandle things = gmWriter.things(new StringHandle(), "noMatch");
818+
TriplesReadHandle things = gmWriter.things(new StringHandle(), "noMatch");
795819
assertTrue("Things did not return expected Uri's", things == null);
796820
} catch (Exception e) {
797821
exp = e;

0 commit comments

Comments
 (0)