Examples of MGraph


Examples of org.apache.clerezza.rdf.core.MGraph

        Assert.assertEquals(trpl2, listener.getEvents().get(0).getTriple());
    }

    @Test
    public void graphEventTestIteratorRemove() {
        MGraph mGraph = getEmptyMGraph();
        TestGraphListener listener = new TestGraphListener();
        mGraph.addGraphListener(listener, new FilterTriple(uriRef1, uriRef2, null));
        mGraph.addGraphListener(listener, new FilterTriple(bnode2, null, literal2));
        mGraph.addGraphListener(listener, new FilterTriple(null, uriRef4, literal2));
        mGraph.add(trpl1);
        mGraph.add(trpl2);
        mGraph.add(trpl3);
        mGraph.add(trpl4);
        listener.resetCumulatedEvents();
        Iterator<Triple> result = mGraph.iterator();
        while (result.hasNext()) {
            result.next();
            result.remove();
        }
        List<GraphEvent> cumulatedEvents = listener.getCumulatedEvents();
View Full Code Here

Examples of org.apache.clerezza.rdf.core.MGraph

        Assert.assertTrue(cumulatedTriples.contains(trpl4));
    }

    @Test
    public void graphEventTestClear() {
        MGraph mGraph = getEmptyMGraph();
        TestGraphListener listener = new TestGraphListener();
        mGraph.addGraphListener(listener, new FilterTriple(uriRef1, uriRef2, null));
        mGraph.addGraphListener(listener, new FilterTriple(bnode2, null, literal2));
        mGraph.addGraphListener(listener, new FilterTriple(null, uriRef4, literal2));
        mGraph.add(trpl1);
        mGraph.add(trpl2);
        mGraph.add(trpl3);
        mGraph.add(trpl4);
        listener.resetCumulatedEvents();
        mGraph.clear();
        List<GraphEvent> cumulatedEvents = listener.getCumulatedEvents();
        Set<Triple> cumulatedTriples = getCumulatedTriples(cumulatedEvents);
        Assert.assertEquals(3, cumulatedEvents.size());
        Assert.assertTrue(cumulatedEvents.get(0) instanceof RemoveEvent);
        Assert.assertTrue(cumulatedTriples.contains(trpl2));
View Full Code Here

Examples of org.apache.clerezza.rdf.core.MGraph

        return triples;
    }

    @Test
    public void graphEventTestWithDelay() throws Exception{
        MGraph mGraph = getEmptyMGraph();
        TestGraphListener listener = new TestGraphListener();
        mGraph.addGraphListener(listener, new FilterTriple(uriRef1, uriRef2, null),
                1000);

        Triple triple0 = new TripleImpl(uriRef2, uriRef2, literal1);
        Triple triple1 = new TripleImpl(uriRef1, uriRef2, uriRef1);
        Triple triple2 = new TripleImpl(uriRef1, uriRef2, literal1);
        Triple triple3 = new TripleImpl(uriRef1, uriRef2, bnode1);
        mGraph.add(triple0);
        mGraph.add(triple1);
        mGraph.add(triple2);
        mGraph.add(triple3);
        Thread.sleep(1500);
        Assert.assertEquals(3, listener.getEvents().size());
        Assert.assertEquals(triple1, listener.getEvents().get(0).getTriple());
        Assert.assertTrue(listener.getEvents().get(0) instanceof AddEvent);
        Assert.assertEquals(triple2, listener.getEvents().get(1).getTriple());
View Full Code Here

Examples of org.apache.clerezza.rdf.core.MGraph

    protected final UriRef otherGraphUriRef = new UriRef(graphUriRef.getUnicodeString());

    @Test
    public void testCreateGraph() {
        TcProvider simpleTcmProvider = getInstance();
        MGraph mGraph = new SimpleMGraph();
        mGraph.add(new TripleImpl(uriRefA, uriRefA, uriRefA));

        Graph createdGraph = simpleTcmProvider.createGraph(uriRefA, mGraph);

        Iterator<Triple> iteratorInput = mGraph.iterator();
        Iterator<Triple> iteratorCreated = createdGraph.iterator();
        assertEquals(iteratorInput.next(), iteratorCreated.next());
        assertFalse(iteratorCreated.hasNext());

        try {
View Full Code Here

Examples of org.apache.clerezza.rdf.core.MGraph

    }

    @Test
    public void testCreateMGraph() {
        TcProvider simpleTcmProvider = getInstance();
        MGraph mGraph = simpleTcmProvider.createMGraph(uriRefA);
        assertTrue(mGraph.isEmpty());

        try {
            simpleTcmProvider.createMGraph(uriRefA);
            assertTrue(false);
        } catch (EntityAlreadyExistsException e) {
View Full Code Here

Examples of org.apache.clerezza.rdf.core.MGraph

    @Test
    public void testGetGraph() {
        TcProvider simpleTcmProvider = getInstance();
        // add Graphs
        MGraph mGraph = new SimpleMGraph();
        mGraph.add(new TripleImpl(uriRefA, uriRefA, uriRefA));
        simpleTcmProvider.createGraph(uriRefA, mGraph);
        mGraph = new SimpleMGraph();
        mGraph.add(new TripleImpl(uriRefA1, uriRefA1, uriRefA1));
        simpleTcmProvider.createGraph(uriRefA1, mGraph);
        mGraph = new SimpleMGraph();
        mGraph.add(new TripleImpl(uriRefB, uriRefB, uriRefB));
        simpleTcmProvider.createGraph(uriRefB, mGraph);
        mGraph = new SimpleMGraph();
        mGraph.add(new TripleImpl(uriRefB1, uriRefB1, uriRefB1));
        simpleTcmProvider.createGraph(uriRefB1, mGraph);

        Graph bGraph = simpleTcmProvider.getGraph(uriRefB);
        Iterator<Triple> iterator = bGraph.iterator();
        assertEquals(new TripleImpl(uriRefB, uriRefB, uriRefB), iterator.next());
View Full Code Here

Examples of org.apache.clerezza.rdf.core.MGraph

    @Test
    public void testGetMGraph() {
        TcProvider simpleTcmProvider = getInstance();
        // add MGraphs
        MGraph mGraph = simpleTcmProvider.createMGraph(uriRefA);
        mGraph.add(new TripleImpl(uriRefA, uriRefA, uriRefA));
        mGraph = simpleTcmProvider.createMGraph(uriRefA1);
        mGraph.add(new TripleImpl(uriRefA1, uriRefA1, uriRefA1));
        mGraph = simpleTcmProvider.createMGraph(uriRefB);
        mGraph.add(new TripleImpl(uriRefB, uriRefB, uriRefA));
        mGraph.add(new TripleImpl(uriRefB, uriRefB, uriRefB));
        mGraph.remove(new TripleImpl(uriRefB, uriRefB, uriRefA));
        assertEquals(1, mGraph.size());
        mGraph = simpleTcmProvider.createMGraph(uriRefB1);
        mGraph.add(new TripleImpl(uriRefB1, uriRefB1, uriRefB1));

        MGraph bGraph = simpleTcmProvider.getMGraph(uriRefB);
        Iterator<Triple> iterator = bGraph.iterator();
        assertEquals(new TripleImpl(uriRefB, uriRefB, uriRefB), iterator.next());
        assertFalse(iterator.hasNext());
    }
View Full Code Here

Examples of org.apache.clerezza.rdf.core.MGraph

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

        // get a Graph
        TripleCollection tripleCollection = simpleTcmProvider.getTriples(uriRefA);
        // get a MGraph
        TripleCollection tripleCollection2 = simpleTcmProvider.getTriples(uriRefB1);
View Full Code Here

Examples of org.apache.clerezza.rdf.core.MGraph

    }

    @Test
    public void testDeleteEntity() {
        TcProvider simpleTcmProvider = getInstance();
        MGraph mGraph = new SimpleMGraph();
        mGraph.add(new TripleImpl(uriRefA, uriRefA, uriRefA));
        Graph graph = mGraph.getGraph();
        simpleTcmProvider.createGraph(uriRefA, graph);
        simpleTcmProvider.createGraph(uriRefC, graph);

        simpleTcmProvider.deleteTripleCollection(uriRefA);
        try {
View Full Code Here

Examples of org.apache.clerezza.rdf.core.MGraph

    @Test
    public void testCreateMGraphExtended() throws Exception {

        TcProvider provider = getInstance();
        MGraph graph = provider.createMGraph(graphUriRef);
        assertNotNull(graph);
        //get a new provider and check that graph is there
        provider = getInstance();
        graph = provider.getMGraph(graphUriRef);
        assertNotNull(graph);
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.