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

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


    @Test
    public void testCreateGraphWithInitialCollection() throws Exception {

        Triple t1 = createTestTriple();

        TcProvider provider = getInstance();

        Graph graph = provider.createGraph(graphUriRef, createTestTripleCollection(t1));

        assertEquals(1, graph.size());
        assertTrue(graph.contains(t1));
    }
View Full Code Here


        Triple t1 = createTestTriple();
        Set<Triple> t = new HashSet<Triple>();
        t.add(t1);

        TcProvider provider = getInstance();

        Graph graph = provider.createGraph(graphUriRef, createTestTripleCollection(t1));

        boolean expThrown = false;

        try {
            graph.add(t1);
View Full Code Here

    @Test
    public void testGraphDeletion() throws Exception {

        TripleCollection triples = createTestTripleCollection(createTestTriple());

        TcProvider provider = getInstance();
        UriRef name1 = new UriRef("http://myGraph1");
        Graph graph = provider.createGraph(name1, triples);

        UriRef name2 = new UriRef("http://myGraph2");
        Graph secondGraph = provider.createGraph(name2, triples);

        //if we delete graph with name1, the second graph should still be there
        provider.deleteTripleCollection(name1);

        provider = getInstance();
        Graph firstGraph = provider.getGraph(name2);
        assertNotNull(firstGraph);

        //check second name is not there
        boolean expThrown = false;

        try {
            Graph g = provider.getGraph(name1);
        } catch(NoSuchEntityException nses) {
            expThrown = true;
        }

        assertTrue(expThrown);
View Full Code Here

    }


    @Test
    public void testGetTriplesGraph() throws Exception {
        TcProvider provider = getInstance();
        Graph graph = provider.createGraph(graphUriRef,
                createTestTripleCollection(createTestTriple()));
        TripleCollection tc = provider.getTriples(graphUriRef);
        assertNotNull(tc);
    }
View Full Code Here

        assertNotNull(tc);
    }

    @Test
    public void testGetTriplesMGraph() throws Exception {
        TcProvider provider = getInstance();

        MGraph graph = provider.createMGraph(graphUriRef);

        TripleCollection tc = provider.getTriples(graphUriRef);
        assertNotNull(tc);
    }
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

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.