private void loadStatements(final String namespace, final int nstatements) throws Exception { final Collection<Statement> stmts = new ArrayList<>(nstatements); for (int i = 0; i < nstatements; i++) { stmts.add(generateTriple()); } log.warn(String.format("Loading package into %s namespace...", namespace)); m_mgr.getRepositoryForNamespace(namespace).add(new RemoteRepository.AddOp(stmts)); log.warn(String.format("Loading package into %s namespace done", namespace)); }
public static void loadDataFromResource(final RemoteRepositoryManager repo, final String namespace, final String resource) throws Exception { final InputStream is = SampleBlazegraphCustomFunctionRemote.class .getResourceAsStream(resource); if (is == null) { throw new IOException("Could not locate resource: " + resource); } try { repo.getRepositoryForNamespace(namespace).add( new RemoteRepository.AddOp(is, RDFFormat.N3)); } finally { is.close(); } }
private static void loadDataFromResource(final RemoteRepositoryManager repo, final String namespace, final String resource) throws Exception { final InputStream is = SampleBlazegraphSesameRemote.class .getResourceAsStream(resource); if (is == null) { throw new IOException("Could not locate resource: " + resource); } try { repo.getRepositoryForNamespace(namespace).add( new RemoteRepository.AddOp(is, RDFFormat.N3)); } finally { is.close(); } }
private void simpleQuery(final String namespace) throws QueryEvaluationException, Exception { log.warn(String.format("Execute SPARQL on %s namespace...", namespace)); m_mgr.getRepositoryForNamespace(namespace).prepareTupleQuery("SELECT * {?s ?p ?o} LIMIT 100").evaluate() .close(); log.warn(String.format("Execute SPARQL on %s namespace done", namespace)); }
public static void loadDataFromResource(final RemoteRepositoryManager repo, final String namespace, final String resource) throws Exception { final InputStream is = SampleBlazegraphCustomFunctionRemote.class .getResourceAsStream(resource); if (is == null) { throw new IOException("Could not locate resource: " + resource); } try { repo.getRepositoryForNamespace(namespace).add( new RemoteRepository.AddOp(is, RDFFormat.N3)); } finally { is.close(); } }
private void dropGraph(final String namespace) throws Exception { final RemoteRepository rr = m_mgr.getRepositoryForNamespace(namespace); // force an abort by preparing an invalid update rr.prepareUpdate("DROP GRAPH <" + namespace + ">").evaluate(); }
private void forceAbort(final String namespace) throws Exception { final RemoteRepository rr = m_mgr.getRepositoryForNamespace(namespace); // force an abort by preparing an invalid update rr.prepareUpdate("FORCE ABORT").evaluate(); }
@Override public void run() { String namespace = null; try { latch.await(); // Wait at least 2 created namespaces namespace = "n" + ThreadLocalRandom.current().nextInt( namespaceCount.get() - 1); final Collection<Statement> stmts = new ArrayList<>(100000); for (int i = 0; i < 100000; i++) { stmts.add(generateTriple()); } log.warn(String.format( "Loading package into %s namespace...", namespace)); m_mgr.getRepositoryForNamespace(namespace).add( new RemoteRepository.AddOp(stmts)); log.warn(String.format( "Loading package into %s namespace done", namespace)); } catch (final Exception e) { log.error( String.format( "Failed to load package into namespace %s:", namespace), e); testSucceeding.set(false); } if (testSucceeding.get()) executor.schedule(this, 5, TimeUnit.SECONDS); } });
@Override public void run() { String namespace = null; try { latch.await(); // Wait at least 2 created namespaces namespace = "n" + ThreadLocalRandom.current().nextInt( namespaceCount.get() - 1); log.warn(String.format("Execute SPARQL on %s namespace...", namespace)); m_mgr.getRepositoryForNamespace(namespace) .prepareTupleQuery("SELECT * {?s ?p ?o} LIMIT 100") .evaluate().close(); log.warn(String.format("Execute SPARQL on %s namespace done", namespace)); } catch (final Exception e) { log.error( String.format( "Failed to execute SPARQL on %s namespace:", namespace), e); testSucceeding.set(false); } if (testSucceeding.get()) executor.schedule(this, 1, TimeUnit.SECONDS); } });
.getRepositoryForNamespace(namespace);
private void loadStatements(final String namespace, final int nstatements) throws Exception { final Collection<Statement> stmts = new ArrayList<>(nstatements); for (int i = 0; i < nstatements; i++) { stmts.add(generateTriple()); } log.warn(String.format("Loading package into %s namespace...", namespace)); m_mgr.getRepositoryForNamespace(namespace).add(new RemoteRepository.AddOp(stmts)); log.warn(String.format("Loading package into %s namespace done", namespace)); }
public void testServiceWhiteList() throws Exception { TupleQueryResult res = m_repo.getRepositoryForNamespace(namespace). // prepareTupleQuery("SELECT ?b { ?b <http://purl.org/dc/elements/1.1/title> ?title . " + "SERVICE <" + SOME_SERVICE_ENDPOINT + "> { } }").evaluate(); int resCount = 0;; while(res.hasNext()){ res.next(); resCount++; } assertEquals(0, resCount); boolean exceptionThrown = false; try { res = m_repo.getRepositoryForNamespace(namespace). // prepareTupleQuery("SELECT ?b { ?b <http://purl.org/dc/elements/1.1/title> ?title . " + "SERVICE <" + SOME_SERVICE_ENDPOINT + "1> { } }").evaluate(); } catch(Exception e) { exceptionThrown = e.toString().contains("Service URI http://someService.com/test1 is not allowed"); } assertTrue(exceptionThrown); }
private void simpleQuery(final String namespace) throws QueryEvaluationException, Exception { log.warn(String.format("Execute SPARQL on %s namespace...", namespace)); m_mgr.getRepositoryForNamespace(namespace).prepareTupleQuery("SELECT * {?s ?p ?o} LIMIT 100").evaluate() .close(); log.warn(String.format("Execute SPARQL on %s namespace done", namespace)); }
@Override public void run() { String namespace = null; try { latch.await(); // Wait at least 2 created namespaces namespace = "n" + ThreadLocalRandom.current().nextInt( namespaceCount.get() - 1); final Collection<Statement> stmts = new ArrayList<>(100000); for (int i = 0; i < 100000; i++) { stmts.add(generateTriple()); } log.warn(String.format( "Loading package into %s namespace...", namespace)); m_mgr.getRepositoryForNamespace(namespace).add( new RemoteRepository.AddOp(stmts)); log.warn(String.format( "Loading package into %s namespace done", namespace)); } catch (final Exception e) { log.error( String.format( "Failed to load package into namespace %s:", namespace), e); testSucceeding.set(false); } if (testSucceeding.get()) executor.schedule(this, 5, TimeUnit.SECONDS); } });
private void forceAbort(final String namespace) throws Exception { final RemoteRepository rr = m_mgr.getRepositoryForNamespace(namespace); // force an abort by preparing an invalid update rr.prepareUpdate("FORCE ABORT").evaluate(); }
private void dropGraph(final String namespace) throws Exception { final RemoteRepository rr = m_mgr.getRepositoryForNamespace(namespace); // force an abort by preparing an invalid update rr.prepareUpdate("DROP GRAPH <" + namespace + ">").evaluate(); }
@Override public void run() { String namespace = null; try { latch.await(); // Wait at least 2 created namespaces namespace = "n" + ThreadLocalRandom.current().nextInt( namespaceCount.get() - 1); log.warn(String.format("Execute SPARQL on %s namespace...", namespace)); m_mgr.getRepositoryForNamespace(namespace) .prepareTupleQuery("SELECT * {?s ?p ?o} LIMIT 100") .evaluate().close(); log.warn(String.format("Execute SPARQL on %s namespace done", namespace)); } catch (final Exception e) { log.error( String.format( "Failed to execute SPARQL on %s namespace:", namespace), e); testSucceeding.set(false); } if (testSucceeding.get()) executor.schedule(this, 1, TimeUnit.SECONDS); } });
final TupleQueryResult result = repo.getRepositoryForNamespace(namespace) .prepareTupleQuery(QUERY) .evaluate();
public void testServiceWhiteList() throws Exception { TupleQueryResult res = m_repo.getRepositoryForNamespace(namespace). // prepareTupleQuery("SELECT ?b { ?b <http://purl.org/dc/elements/1.1/title> ?title . " + "SERVICE <" + SOME_SERVICE_ENDPOINT + "> { } }").evaluate(); int resCount = 0;; while(res.hasNext()){ res.next(); resCount++; } assertEquals(0, resCount); boolean exceptionThrown = false; try { res = m_repo.getRepositoryForNamespace(namespace). // prepareTupleQuery("SELECT ?b { ?b <http://purl.org/dc/elements/1.1/title> ?title . " + "SERVICE <" + SOME_SERVICE_ENDPOINT + "1> { } }").evaluate(); } catch(Exception e) { exceptionThrown = e.toString().contains("Service URI http://someService.com/test1 is not allowed"); } assertTrue(exceptionThrown); }
return m_mgr.getRepositoryForNamespace(ns);