/** * Compare two graphs for equality. * <p> * Note: This is not very efficient if the {@link Graph} implementations are * not indexed. * <p> * Note: This does not handle equality testing with blank nodes (it does not * test for isomorphic graphs). * * @param expected * @param actual */ static protected void assertSameGraph(final Graph expected, final Graph actual) { for (Statement s : expected) { if (!actual.contains(s)) fail("Expecting: " + s); } assertEquals("size", expected.size(), actual.size()); }
/** * Write a graph on a buffer suitable for sending as an HTTP request body. * * @param format * The RDF Format to use. * @param g * The graph. * * @return The serialized data. * * @throws RDFHandlerException */ static protected byte[] writeOnBuffer(final RDFFormat format, final Graph g) throws RDFHandlerException { final RDFWriterFactory writerFactory = RDFWriterRegistry.getInstance() .get(format); if (writerFactory == null) fail("RDFWriterFactory not found: format=" + format); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final RDFWriter writer = writerFactory.getWriter(baos); writer.startRDF(); for (Statement stmt : g) { writer.handleStatement(stmt); } writer.endRDF(); return baos.toByteArray(); }
/** * Generates some statements and serializes them using the specified * {@link RDFFormat}. * * @param ntriples * The #of statements to generate. * @param format * The format. * * @return the serialized statements. */ protected byte[] genNTRIPLES(final int ntriples, final RDFFormat format) throws RDFHandlerException { final Graph g = genNTRIPLES2(ntriples); final RDFWriterFactory writerFactory = RDFWriterRegistry.getInstance() .get(format); if (writerFactory == null) fail("RDFWriterFactory not found: format=" + format); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final RDFWriter writer = writerFactory.getWriter(baos); writer.startRDF(); for (Statement stmt : g) { writer.handleStatement(stmt); } writer.endRDF(); return baos.toByteArray(); }
fail("Could not identify network address for this host.");
/** * Compare two graphs for equality. * <p> * Note: This is not very efficient if the {@link Graph} implementations are * not indexed. * <p> * Note: This does not handle equality testing with blank nodes (it does not * test for isomorphic graphs). * * @param expected * @param actual */ static protected void assertSameGraph(final Graph expected, final Graph actual) { for (Statement s : expected) { if (!actual.contains(s)) fail("Expecting: " + s); } assertEquals("size", expected.size(), actual.size()); }
/** * Write a graph on a buffer suitable for sending as an HTTP request body. * * @param format * The RDF Format to use. * @param g * The graph. * * @return The serialized data. * * @throws RDFHandlerException */ static protected byte[] writeOnBuffer(final RDFFormat format, final Graph g) throws RDFHandlerException { final RDFWriterFactory writerFactory = RDFWriterRegistry.getInstance() .get(format); if (writerFactory == null) fail("RDFWriterFactory not found: format=" + format); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final RDFWriter writer = writerFactory.getWriter(baos); writer.startRDF(); for (Statement stmt : g) { writer.handleStatement(stmt); } writer.endRDF(); return baos.toByteArray(); }
/** * Generates some statements and serializes them using the specified * {@link RDFFormat}. * * @param ntriples * The #of statements to generate. * @param format * The format. * * @return the serialized statements. */ protected byte[] genNTRIPLES(final int ntriples, final RDFFormat format) throws RDFHandlerException { final Graph g = genNTRIPLES2(ntriples); final RDFWriterFactory writerFactory = RDFWriterRegistry.getInstance() .get(format); if (writerFactory == null) fail("RDFWriterFactory not found: format=" + format); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final RDFWriter writer = writerFactory.getWriter(baos); writer.startRDF(); for (Statement stmt : g) { writer.handleStatement(stmt); } writer.endRDF(); return baos.toByteArray(); }
fail("Could not identify network address for this host.");