Examples of TcProvider


Examples of org.apache.clerezza.rdf.core.access.TcProvider

 
  @Test
  @Override
  public void testGetTriples() {
    TcProvider fileTcProvider = getInstance();
    // add Graphs
    MGraph mGraph = new SimpleMGraph();
    // add MGraphs
    mGraph = fileTcProvider.createMGraph(uriRefA1);
    mGraph.add(new TripleImpl(uriRefA1, uriRefA1, uriRefA1));
    mGraph = fileTcProvider.createMGraph(uriRefB1);
    mGraph.add(new TripleImpl(uriRefB1, uriRefB1, uriRefB1));

    // get a MGraph
    TripleCollection tripleCollection2 = fileTcProvider.getTriples(uriRefB1);

    Iterator<Triple> iterator = tripleCollection2.iterator();
    assertEquals(new TripleImpl(uriRefB1, uriRefB1, uriRefB1), iterator.next());
    assertFalse(iterator.hasNext());
  }
View Full Code Here

Examples of org.apache.clerezza.rdf.core.access.TcProvider

  }

  @Test
  @Override
  public void testDeleteEntity() {
    TcProvider fileTcProvider = getInstance();
    MGraph mGraph = fileTcProvider.createMGraph(uriRefA);
    mGraph.add(new TripleImpl(uriRefA, uriRefA, uriRefA));
    fileTcProvider.deleteTripleCollection(uriRefA);
    try {
      fileTcProvider.getMGraph(uriRefA);
      assertTrue(false);
    } catch (NoSuchEntityException e) {
      assertTrue(true);
    }
    fileTcProvider = getInstance();
    try {
      fileTcProvider.getMGraph(uriRefA);
      assertTrue(false);
    } catch (NoSuchEntityException e) {
      assertTrue(true);
    }
  }
View Full Code Here

Examples of org.apache.clerezza.rdf.core.access.TcProvider

    super.testGetTriples();
  }

  @Test
  public void testDataFile() {
    TcProvider provider = getInstance();
    provider.createMGraph(uriRefA);
    File dataFile = new File("data");
    assertTrue(dataFile.exists());

    Set<String> expected = new HashSet<String>();
    expected.add(uriRefA.getUnicodeString());
    assertTrue(expected.equals(getLinesFromFile(dataFile)));

    provider.createMGraph(uriRefB);
    expected.add(uriRefB.getUnicodeString());
    assertTrue(expected.equals(getLinesFromFile(dataFile)));
 
    provider.deleteTripleCollection(uriRefA);
    expected.remove(uriRefA.getUnicodeString());
    assertTrue(expected.equals(getLinesFromFile(dataFile)));
   
    provider.deleteTripleCollection(uriRefB);
    expected.remove(uriRefB.getUnicodeString());
    assertTrue(expected.equals(getLinesFromFile(dataFile)));
  }
View Full Code Here

Examples of org.apache.clerezza.rdf.core.access.TcProvider

  }

  @Test
  public void testAutoMGraphCreationFromExistingFile() throws Exception{
    FileMGraphTest.setup();
    TcProvider provider = getInstance();
    MGraph mGraph = provider.getMGraph(new UriRef(
        FileMGraphTest.getTempFileUri(FileMGraphTest.RDF_FILE_NAME)));
    assertEquals(2 ,mGraph.size());
    FileMGraphTest.cleanUp();
  }
View Full Code Here

Examples of org.apache.clerezza.rdf.core.access.TcProvider

  }

  @Test
  public void restoreFromBackup() throws IOException {
    byte[] backupData = backup.createBackup();
    TcProvider tcProvider = EasyMock.createMock(TcProvider.class);
    EasyMock.expect(tcProvider.getMGraph(testMGraphUri0)).andReturn(
        EasyMock.createNiceMock(MGraph.class));
    EasyMock.expect(tcProvider.getMGraph(testMGraphUri1)).andReturn(
        EasyMock.createNiceMock(MGraph.class));
    tcProvider.deleteTripleCollection(testGraphUriA);
    EasyMock.expect(tcProvider.createGraph(EasyMock.eq(testGraphUriA),
        EasyMock.notNull(TripleCollection.class))).andReturn(new SimpleMGraph().getGraph());
    EasyMock.replay(tcProvider);
    Restorer restore = new Restorer();
    restore.parser = Parser.getInstance();
    restore.restore(new ByteArrayInputStream(backupData), tcProvider);
View Full Code Here

Examples of org.apache.clerezza.rdf.core.access.TcProvider

     * name of the generated graph) and increase the triple collection count by 1.
     */
    @Test
    public void fromInputStreamInSimpleTcProvider() throws Exception {
        InputStream in = getClass().getResourceAsStream(dummy_RdfXml);
        TcProvider tcp = new SimpleTcProvider();
        assertSame(0, tcp.listTripleCollections().size());
        int before = tcp.listTripleCollections().size();
        src = new GraphContentInputSource(in, tcp);
        checkOntology(true);
        assertSame(before + 1, tcp.listTripleCollections().size());
    }
View Full Code Here

Examples of org.apache.clerezza.rdf.core.access.TcProvider

    /**
     * The union graph is read only!
     */
    @Test(expected=NoSuchEntityException.class)
    public void testUnionMgraph(){
        TcProvider provider = getInstance();
        provider.getMGraph(UNION_GRAPH_NAME);
    }
View Full Code Here

Examples of org.apache.clerezza.rdf.core.access.TcProvider

    /**
     * Assert union graph on an empty dataset
     */
    @Test
    public void testEmptyUnionGraph(){
        TcProvider provider = getInstance();
        Graph grpah = provider.getGraph(UNION_GRAPH_NAME);
        Assert.assertNotNull(grpah);
    }
View Full Code Here

Examples of org.apache.clerezza.rdf.core.access.TcProvider

        Assert.assertNotNull(grpah);
    }
   
    @Test
    public void testUnionGraph() throws Exception{
        TcProvider provider = getInstance();
        UriRef type = new UriRef("http://www.w3.org/2000/01/rdf-schema#type");
        UriRef name = new UriRef("http://schema.org/name");
        UriRef personType = new UriRef("http://schema.org/Person");
        UriRef companyType = new UriRef("http://schema.org/Company");
        UriRef worksFor = new UriRef("http://schema.org/works-for");

        //create a graph with persons
        MGraph persons = new SimpleMGraph();
        UriRef tim = new UriRef("http://people.org/tim.johnson");
        persons.add(new TripleImpl(tim, type, personType));
        persons.add(new TripleImpl(tim, name, new PlainLiteralImpl("Tim Johnson")));
        UriRef john = new UriRef("http://people.org/john.swenson");
        persons.add(new TripleImpl(john, type, personType));
        persons.add(new TripleImpl(john, name, new PlainLiteralImpl("John Swenson")));
        provider.createGraph(new UriRef("urn:persons"), persons.getGraph());
       
        //create a MGraph with data about persons
        MGraph orgdata = provider.createMGraph(new UriRef("urn:orgdata"));
        UriRef talinor = new UriRef("http://company.org/talinor");
        orgdata.add(new TripleImpl(talinor, type, companyType));
        orgdata.add(new TripleImpl(talinor, name, new PlainLiteralImpl("Talinor Inc.")));
        orgdata.add(new TripleImpl(john, worksFor, talinor));
        UriRef kondalor = new UriRef("http://company.org/kondalor");
        orgdata.add(new TripleImpl(kondalor, type, companyType));
        orgdata.add(new TripleImpl(kondalor, name, new PlainLiteralImpl("Kondalor Ges.m.b.H.")));
        orgdata.add(new TripleImpl(tim, worksFor, kondalor));
       
        //now get the union graph
        Graph data = provider.getGraph(UNION_GRAPH_NAME);
        Assert.assertNotNull(data);
        //CLEREZZA-714: getTriples need to correctly return the UnionGraph
        data = (Graph)provider.getTriples(UNION_GRAPH_NAME);
        Assert.assertNotNull(data);
        //NOTE: Jena TDB does not support getSize for the union graph
//        int expectedTripleCount = persons.size()+orgdata.size();
//        Assert.assertEquals("Uniongraph has "+data.size()
//            +" triples (expected "+expectedTripleCount+")",
View Full Code Here

Examples of org.apache.clerezza.rdf.core.access.TcProvider

       
    }
   
    @Test
    public void testListGraph(){
        TcProvider provider = getInstance();
        //No union graph in listMGraphs
        Set<UriRef> mgl = provider.listMGraphs();
        Assert.assertFalse("Mgraph list don't contain the read-only union-graph", mgl.contains(UNION_GRAPH_NAME));
        //Union graph in listGraphs
        Set<UriRef> gl = provider.listGraphs();
        Assert.assertTrue("Graph list contain the read-only union-graph", gl.contains(UNION_GRAPH_NAME));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.