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

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


    protected final UriRef graphUriRef = generateUri("myGraph");
    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 {
            simpleTcmProvider.createGraph(uriRefA, mGraph);
            assertTrue(false);
        } catch (EntityAlreadyExistsException e) {
            assertTrue(true);
        }
    }
View Full Code Here


        }
    }

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

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

        }
    }

    @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());
        assertFalse(iterator.hasNext());
    }
View Full Code Here

        assertFalse(iterator.hasNext());
    }

    @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

        assertFalse(iterator.hasNext());
    }

    @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);

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

        assertFalse(iterator.hasNext());
    }

    @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 {
            simpleTcmProvider.getGraph(uriRefA);
            assertTrue(false);
        } catch (NoSuchEntityException e) {
            assertTrue(true);
        }

        // Check that graph is still available under uriRefC
        Graph cGraph = simpleTcmProvider.getGraph(uriRefC);
        assertNotNull(cGraph);
    }
View Full Code Here

//    }

    @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);
        //check that there is no such graph, but only the mgraph
        boolean expThrown = false;
        try {
            Graph g = provider.getGraph(graphUriRef);
        } catch(NoSuchEntityException e) {
            expThrown = true;
        }

        assertTrue(expThrown);
View Full Code Here

    }

    @Test
    public void testCreateGraphExtended() throws Exception {

        TcProvider provider = getInstance();
        Graph graph = provider.createGraph(graphUriRef, null);

        assertNotNull(graph);

        //get a new provider and check that graph is there
        provider = getInstance();
        graph = provider.getGraph(graphUriRef);
        assertNotNull(graph);

        //check that there is no such mgraph, but only the graph
        boolean expThrown = false;

        try {
            MGraph g = provider.getMGraph(graphUriRef);
        } catch(NoSuchEntityException e) {
            expThrown = true;
        }

        assertTrue(expThrown);
View Full Code Here

    }

    @Test
    public void testCreateGraphNoDuplicateNames() throws Exception {

        TcProvider provider = getInstance();
        Graph graph = provider.createGraph(graphUriRef, null);
        assertNotNull(graph);
        boolean expThrown = false;
        try {
            Graph other = provider.createGraph(otherGraphUriRef, null);
        } catch(EntityAlreadyExistsException eaee) {
            expThrown = true;
        }
        assertTrue(expThrown);
    }
View Full Code Here

    }

    @Test
    public void testCreateMGraphNoDuplicateNames() throws Exception {

        TcProvider provider = getInstance();
        MGraph graph = provider.createMGraph(graphUriRef);
        assertNotNull(graph);
        boolean expThrown = false;
        try {
            MGraph other = provider.createMGraph(otherGraphUriRef);
        } catch(EntityAlreadyExistsException eaee) {
            expThrown = true;
        }
        assertTrue(expThrown);
    }
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.