/** * 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 * @throws Exception */ static protected void assertSameGraph(final Graph expected, final IPreparedGraphQuery actual) throws Exception { assertSameGraph(expected, asGraph(actual)); }
/** * Test helps PUTs some data, verifies that it is visible, DELETEs the data, * and then verifies that it is gone. * * @param format * The interchange format. */ protected void doDeleteWithPostTest(final RDFFormat format) throws Exception { doInsertWithBodyTest("POST", 23, /*requestPath,*/ format); assertEquals(23, countAll()); doDeleteWithBody(/*requestPath,*/ 23, format); // No solutions (assuming a told triple kb or quads kb w/o axioms). assertEquals(0, countAll()); }
/** * Test of POST w/ BODY having data to be loaded. */ protected void doInsertWithBodyTest(final String method, final int ntriples, /*final String servlet,*/ final RDFFormat format) throws Exception { final byte[] data = genNTRIPLES(ntriples, format); // final File file = File.createTempFile("bigdata-testnssclient", ".data"); /* * Only for testing. Clients should use AddOp(File, RDFFormat). */ final AddOp add = new AddOp(data, format); assertEquals(ntriples, m_repo.add(add)); // Verify the expected #of statements in the store. { final String queryStr = "select * where {?s ?p ?o}"; final IPreparedTupleQuery query = m_repo.prepareTupleQuery(queryStr); assertEquals(ntriples, countResults(query.evaluate())); } }
protected void doDeleteWithBody( /* final String servlet, */final int ntriples, final RDFFormat format) throws Exception { final byte[] data = genNTRIPLES(ntriples, format); final RemoveOp remove = new RemoveOp(data, format); assertEquals(ntriples, m_repo.remove(remove)); }
log.trace("Setting up test:" + getName()); namespace = getName() + UUID.randomUUID(); m_fixture = newFixture(namespace); fail("Could not identify network address for this host."); log.info("Setup done: \nname=" + getName() + "\nnamespace=" + namespace + "\nrootURL=" + m_rootURL + "\nserviceURL=" + m_serviceURL); getIndexManager().getExecutorService());
log.trace("tearing down test: " + getName()); final IIndexManager m_indexManager = getIndexManager(); dropTripleStore(m_indexManager, namespace);
protected Server newFixture(final String lnamespace) throws Exception { final IIndexManager indexManager = getIndexManager(); final Properties properties = getProperties(); createTripleStore(indexManager, lnamespace, properties);
/** * 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()); }
/** * 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(); }
protected void doConstructTest(final String method, final RDFFormat format) throws Exception { setupDataOnServer(); final URI mike = new URIImpl(BD.NAMESPACE + "Mike"); final URI bryan = new URIImpl(BD.NAMESPACE + "Bryan"); assertSameGraph(expected, query);
@Override public Void call() throws Exception { try { final Graph actual = asGraph(m_repo .prepareGraphQuery(queryStr)); assertTrue(!actual.isEmpty()); return null; } catch (Exception e) { log.warn("Call failure", e); errorCount.incrementAndGet(); throw e; } }
/** * Return the exact number of statements in the repository. * * @see #countAll() */ @Deprecated protected long getExactSize() { try { return countAll(); } catch (Exception e) { throw new RuntimeException(e); } // return getSail().getDatabase().getStatementCount(true/* true */); }
/** * 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(); }
"}"; assertSameGraph(expected, m_repo.prepareGraphQuery(queryStr));
log.trace("Setting up test:" + getName()); namespace = getName() + UUID.randomUUID(); m_fixture = newFixture(namespace); fail("Could not identify network address for this host."); log.info("Setup done: \nname=" + getName() + "\nnamespace=" + namespace + "\nrootURL=" + m_rootURL + "\nserviceURL=" + m_serviceURL); getIndexManager().getExecutorService());
log.trace("tearing down test: " + getName()); final IIndexManager m_indexManager = getIndexManager(); dropTripleStore(m_indexManager, namespace);
protected Server newFixture(final String lnamespace) throws Exception { final IIndexManager indexManager = getIndexManager(); final Properties properties = getProperties(); createTripleStore(indexManager, lnamespace, properties);
protected void doDeleteWithBody( /* final String servlet, */final int ntriples, final RDFFormat format) throws Exception { final byte[] data = genNTRIPLES(ntriples, format); final RemoveOp remove = new RemoveOp(data, format); assertEquals(ntriples, m_repo.remove(remove)); }
/** * 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()); }
/** * 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(); }