@BeforeClass public static void beforeClass() { Common.connect(); gmgr = Common.client.newGraphManager(); gmgr.mergeGraphs(new StringHandle(TEST_TRIG) .withMimetype("text/trig")); smgr = Common.client.newSPARQLQueryManager(); }
@Test public void testQuads() throws Exception { gmgr.setDefaultMimetype(RDFMimeTypes.NQUADS); String quadGraphUri = "GraphsTest.testQuads"; String quad1 = "<http://example.org/s1> <http://example.org/p1> <http://example.org/o1> <" + quadGraphUri + "> ."; String quad2 = "<http://example.org/s2> <http://example.org/p2> <http://example.org/o2> <" + quadGraphUri + "> ."; String quad3 = "<http://example.org/s3> <http://example.org/p2> <http://example.org/o2> <" + quadGraphUri + "> ."; String quad4 = "<http://example.org/s4> <http://example.org/p2> <http://example.org/o2> <" + quadGraphUri + "> ."; gmgr.replaceGraphs(new StringHandle(quad1)); StringHandle quadsHandle = gmgr.read(quadGraphUri, new StringHandle()); assertEquals(quad1, quadsHandle.get()); gmgr.mergeGraphs(new StringHandle(quad2)); StringHandle quads1and2 = gmgr.read(quadGraphUri, new StringHandle()); assertEquals(quad1 + "\n" + quad2, quads1and2.get()); gmgr.replaceGraphsAs(quad3); quadsHandle = gmgr.read(quadGraphUri, new StringHandle()); assertEquals(quad3, quadsHandle.get()); gmgr.mergeGraphsAs(quad4); String quads3and4 = gmgr.readAs(quadGraphUri, String.class); assertEquals(quad3 + "\n" + quad4, quads3and4); gmgr.delete(quadGraphUri); }
gmgr.mergeGraphs(new StringHandle(quad2), tx); assertEquals(quad1 + "\n" + quad2, gmgr.read(quadGraphUri, new StringHandle(), tx).get());
@Test public void testMergeReplace_quads() throws FileNotFoundException, InterruptedException { String uri = "http://test.sem.quads/json-quads"; String ntriple6 = "<http://example.org/s6> <http://example.com/mergeQuadP> <http://example.org/o2> <http://test.sem.quads/json-quads>."; File file = new File(datasource + "bug25348.json"); FileHandle filehandle = new FileHandle(); filehandle.set(file); gmWriter.write(uri, filehandle.withMimetype(RDFMimeTypes.RDFJSON)); gmWriter.mergeGraphs(new StringHandle(ntriple6).withMimetype(RDFMimeTypes.NQUADS)); FileHandle handle = gmWriter.read(uri, new FileHandle()); File readFile = handle.get(); String expectedContent = convertFileToString(readFile); assertTrue("Did not merge Quad", expectedContent.contains("<http://example.com/mergeQuadP")); file = new File(datasource + "relative2.nq"); gmWriter.replaceGraphs(new FileHandle(file).withMimetype(RDFMimeTypes.NQUADS)); uri = "http://originalGraph"; StringHandle readQuads = gmWriter.read(uri, new StringHandle()); assertTrue("Did not Replace Quads", readQuads.toString().contains("#electricVehicle2")); gmWriter.deleteGraphs(); try { StringHandle readContent = gmWriter.read(uri, new StringHandle()); assertTrue("Unexpected content read, expecting Resource not found exception", readContent.get() == null); } catch (Exception e) { assertTrue("Unexpected Exception Thrown", e.toString().contains("ResourceNotFoundException")); } }
gmWriter.mergeGraphs(new StringHandle(ntriple6).withMimetype(RDFMimeTypes.NQUADS), trxIn); trxIn.commit(); FileHandle handle = gmWriter.read(uri, new FileHandle()); gmWriter.mergeGraphs(new StringHandle(ntriple6).withMimetype(RDFMimeTypes.NQUADS), trxInMergeGraph); trxInMergeGraph.commit(); expectedContent = null; gmWriter.mergeGraphs(new StringHandle(ntriple6).withMimetype(RDFMimeTypes.NQUADS), trxInMergeGraph); trxInMergeGraph.rollback(); handle = gmWriter.read(uri, new FileHandle()); gmWriter.mergeGraphs(new StringHandle(ntriple6).withMimetype(RDFMimeTypes.NQUADS), trxInMergeGraph); expectedContent = null; trxInMergeGraph = writerClient.openTransaction(); gmWriter.mergeGraphs(new StringHandle(ntriple6).withMimetype(RDFMimeTypes.NQUADS), trxInMergeGraph);
gmWriter.mergeGraphs( new StringHandle(ntriple6).withMimetype(RDFMimeTypes.NQUADS), trxIn); trxIn.commit(); gmWriter.mergeGraphs( new StringHandle(ntriple6).withMimetype(RDFMimeTypes.NQUADS), trxInMergeGraph); expectedContent = null; gmWriter.mergeGraphs( new StringHandle(ntriple6).withMimetype(RDFMimeTypes.NQUADS), trxInMergeGraph); gmWriter.mergeGraphs( new StringHandle(ntriple6).withMimetype(RDFMimeTypes.NQUADS), trxInMergeGraph); expectedContent = null; trxInMergeGraph = writerClient.openTransaction(); gmWriter.mergeGraphs( new StringHandle(ntriple6).withMimetype(RDFMimeTypes.NQUADS), trxInMergeGraph);