Package org.apache.clerezza.rdf.core.access

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


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

        Assert.assertNotNull(graph);
    }
   
    @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

        Assert.assertTrue("Missing "+expected, expected.isEmpty());
    }
   
    @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

    }

    @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

TOP

Related Classes of org.apache.clerezza.rdf.core.access.TcProvider

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.