Package org.openrdf.repository.sail

Examples of org.openrdf.repository.sail.SailRepository


    TestSuite negativeTests = new TestSuite();
    negativeTests.setName("Negative Syntax Tests");

    // Read manifest and create declared test cases
    Repository manifestRep = new SailRepository(new MemoryStore());
    manifestRep.initialize();
    RepositoryConnection con = manifestRep.getConnection();

    URL manifestURL = SeRQLParserTestCase.class.getResource(MANIFEST_FILE);
    RDFFormat format = RDFFormat.forFileName(MANIFEST_FILE, RDFFormat.TURTLE);
    con.add(manifestURL, base(manifestURL.toExternalForm()), format);

    String query = "SELECT testName, query, result " + "FROM {} mf:name {testName}; "
        + "        mf:action {query}; " + "        mf:result {result} " + "USING NAMESPACE "
        + "  mf = <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#>, "
        + "  mfx = <http://www.openrdf.org/test-manifest-extensions#>, "
        + "  qt = <http://www.w3.org/2001/sw/DataAccess/tests/test-query#>";

    TupleResult tests = con.prepareTupleQuery(QueryLanguage.SERQL, query).evaluate();
    while (tests.hasNext()) {
      BindingSet testBindings = tests.next();
      String testName = testBindings.getValue("testName").toString();
      String queryFile = testBindings.getValue("query").toString();
      Value result = testBindings.getValue("result");
      if (MFX_CORRECT.equals(result)) {
        positiveTests.addTest(factory.createTest(testName, queryFile, result));
      }
      else if (MFX_PARSE_ERROR.equals(result)) {
        negativeTests.addTest(factory.createTest(testName, queryFile, result));
      }
      else {
        logger.warn("Unexpected result value for test \"" + testName + "\": " + result);
      }
    }

    tests.close();
    con.close();
    manifestRep.shutDown();

    suite.addTest(positiveTests);
    suite.addTest(negativeTests);
    return suite;
  }
View Full Code Here


  }

  protected Repository createRepository(File dataDir, String entailment)
    throws Exception
  {
    Repository dataRep = new SailRepository(createSail(entailment));
    dataRep.setDataDir(dataDir);
    dataRep.initialize();

    RepositoryConnection con = dataRep.getConnection();
    try {
      con.clear();
      con.clearNamespaces();
    }
    finally {
View Full Code Here

  }

  protected Repository createRepository(File dataDir)
    throws Exception
  {
    Repository repository = new SailRepository(newSail());
    repository.setDataDir(dataDir);
    repository.initialize();
    return repository;
  }
View Full Code Here

    throws Exception
  {
    TestSuite suite = new TestSuite(factory.getClass().getName());

    // Read manifest and create declared test cases
    Repository manifestRep = new SailRepository(new MemoryStore());
    manifestRep.initialize();

    RepositoryConnection con = manifestRep.getConnection();

    URL manifestURL = SeRQLQueryTestCase.class.getResource(MANIFEST_FILE);
    RDFFormat format = RDFFormat.forFileName(MANIFEST_FILE, RDFFormat.TURTLE);
    con.add(manifestURL, base(manifestURL.toExternalForm()), format);

    String query = "SELECT testName, entailment, input, query, result " + "FROM {} mf:name {testName};"
        + "        mf:result {result}; " + "        tck:entailment {entailment}; "
        + "        mf:action {} qt:query {query}; " + "                     qt:data {input} "
        + "USING NAMESPACE " + "  mf = <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#>, "
        + "  qt = <http://www.w3.org/2001/sw/DataAccess/tests/test-query#>, "
        + "  tck = <urn:openrdf.org:sesame:tests#> ";

    TupleResult tests = con.prepareTupleQuery(QueryLanguage.SERQL, query).evaluate();
    while (tests.hasNext()) {
      BindingSet testBindings = tests.next();
      String testName = ((Literal)testBindings.getValue("testName")).getLabel();
      String inputFile = testBindings.getValue("input").toString();
      String queryFile = testBindings.getValue("query").toString();
      String resultFile = testBindings.getValue("result").toString();
      String entailment = ((Literal)testBindings.getValue("entailment")).getLabel();

      query = "SELECT graph " + "FROM {} mf:name {testName}; "
          + "        mf:action {} qt:graphData {graph} " + "WHERE testName = \""
          + SeRQLUtil.encodeString(testName) + "\" " + "USING NAMESPACE"
          + "  mf = <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#>,"
          + "  qt = <http://www.w3.org/2001/sw/DataAccess/tests/test-query#>";

      List<String> graphNames = new ArrayList<String>();

      TupleResult graphs = con.prepareTupleQuery(QueryLanguage.SERQL, query).evaluate();
      while (graphs.hasNext()) {
        BindingSet graphBindings = graphs.next();
        graphNames.add(graphBindings.getValue("graph").toString());
      }
      graphs.close();

      if (testName.startsWith("test-029:")) {
        logger.error("test-029 SKIPPED in {}", SeRQLQueryTestCase.class.getName());
        continue;
      }
      suite.addTest(factory.createTest(testName, inputFile, graphNames, queryFile, resultFile, entailment));
    }

    tests.close();
    con.close();
    manifestRep.shutDown();

    return suite;
  }
View Full Code Here

    assertTrue("Repository should contain newly added statement", testCon.hasStatement(statement, false));
    assertTrue("Repository should contain newly added statement", testCon.hasMatch(alice, name, nameAlice,
        false));

    Repository tempRep = new SailRepository(new MemoryStore());
    tempRep.initialize();
    RepositoryConnection con = tempRep.getConnection();

    con.add(testCon.match(null, null, null, false));

    assertTrue("Temp Repository should contain newly added statement", con.hasMatch(bob, name, nameBob,
        false));
    con.close();
    tempRep.shutDown();
  }
View Full Code Here

    throws Exception
  {
    Collection<? extends Statement> entailedStatements = null;
    Collection<? extends Statement> expectedStatements = null;

    Repository repository = new SailRepository(sailStack);
    repository.initialize();

    RepositoryConnection con = repository.getConnection();

    // clear the input store
    con.clear();

    // Upload input data
    InputStream stream = getClass().getResourceAsStream(inputData);
    try {
      con.add(stream, inputData, RDFFormat.NTRIPLES);
      entailedStatements = con.match(null, null, null, true).asSet();
    }
    finally {
      stream.close();
      con.close();
    }

    // Upload output data
    Repository outputRepository = new SailRepository(new MemoryStore());
    outputRepository.initialize();
    con = outputRepository.getConnection();

    stream = getClass().getResourceAsStream(outputData);
    try {
      con.add(stream, outputData, RDFFormat.NTRIPLES);
      expectedStatements = con.match(null, null, null, false).asSet();
    }
    finally {
      stream.close();
      con.close();
      outputRepository.shutDown();
      repository.shutDown();
    }

    // Check whether all expected statements are present in the entailment
    // closure set.
View Full Code Here

  private RDFWriterFactory rdfWriterFactory = new RDFaWriterFactory();

  public void test()
    throws Exception
  {
    Repository rep1 = new SailRepository(new MemoryStore());
    rep1.initialize();

    RepositoryConnection con1 = rep1.getConnection();

    URL rdf = this.getClass().getResource("/testcases/rdfa-test.rdf");

    con1.add(rdf, rdf.toExternalForm(), RDFFormat.forFileName(rdf.toExternalForm()));

    StringWriter writer = new StringWriter();
    RDFWriter rdfWriter = rdfWriterFactory.getWriter(writer);
    rdfWriter.setBaseURI(rdf.toExternalForm());
    con1.export(rdfWriter);

    long before = con1.size();
    con1.close();

    Repository rep2 = new SailRepository(new MemoryStore());
    rep2.initialize();

    RepositoryConnection con2 = rep2.getConnection();

    con2.add(new StringReader(writer.toString()), rdf.toExternalForm(), rdfWriterFactory.getRDFFormat());
    long after = con2.size();
    con2.close();
View Full Code Here

      "}";

    public DataStoreModel()
  {
 
    _repository = new SailRepository(new ForwardChainingRDFSInferencer(new MemoryStore()));
   
        try {
            _repository.initialize();
            con = _repository.getConnection();
        } catch (RepositoryException e) {
View Full Code Here

    @Before
    public void setUp() throws Exception {
        super.setUp();
        Sail store = new MemoryStore();
        store.initialize();
        conn = new SailRepository(store).getConnection();
    }
View Full Code Here

        RepositoryWriter repositoryWriter;
       
        any23 = new Any23();
        Sail store = new MemoryStore();
        store.initialize();
        conn = new SailRepository(store).getConnection();
        repositoryWriter = new RepositoryWriter(conn);
        Assert.assertTrue( any23.extract(fileDocumentSource, repositoryWriter, encoding).hasMatchingExtractors() );

        RepositoryResult<Statement> statements = conn.getStatements(null, vDCTERMS.title, null, false);
        try {
View Full Code Here

TOP

Related Classes of org.openrdf.repository.sail.SailRepository

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.