Package org.apache.clerezza.rdf.core

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


    Assert.assertEquals(0, graph.size());
  }

  @Test
  public void testUseTypedLiterals() {
    MGraph graph = getEmptyMGraph();
    Assert.assertEquals(0, graph.size());
    Literal value = new TypedLiteralImpl("<elem>value</elem>",xmlLiteralType);
    final TripleImpl triple1 = new TripleImpl(uriRef1, uriRef2, value);
    graph.add(triple1);
    Iterator<Triple> tripleIter = graph.filter(uriRef1, uriRef2, null);
    Assert.assertTrue(tripleIter.hasNext());
    Resource gotValue = tripleIter.next().getObject();
    Assert.assertEquals(value, gotValue);
  }
View Full Code Here


   * @return  All the ScriptGeneratedResources pointing
   *      to <code>scriptResource</code>.
   */
  private Set<NonLiteral> getScriptGeneratedResources(
      NonLiteral scriptResource) {
    MGraph contentGraph = cgProvider.getContentGraph();

    Iterator<Triple> it = contentGraph.filter(null,
        SCRIPT.scriptSource,
        scriptResource);

    Set<NonLiteral> resources = new HashSet<NonLiteral>();

View Full Code Here

    Assert.assertEquals(value, gotValue);
  }

  @Test
  public void testUseLanguageLiterals() {
    MGraph graph = getEmptyMGraph();
    Assert.assertEquals(0, graph.size());
    Language language = new Language("it");
    Literal value = new PlainLiteralImpl("<elem>value</elem>",language);
    final TripleImpl triple1 = new TripleImpl(uriRef1, uriRef2, value);
    graph.add(triple1);
    Iterator<Triple> tripleIter = graph.filter(uriRef1, uriRef2, null);
    Assert.assertTrue(tripleIter.hasNext());
    Resource gotValue = tripleIter.next().getObject();
    Assert.assertEquals(value, gotValue);
    Assert.assertEquals(language, ((PlainLiteral)gotValue).getLanguage());
  }
View Full Code Here

    Assert.assertEquals(language, ((PlainLiteral)gotValue).getLanguage());
  }

  @Test
  public void testRemoveViaIterator() {
    MGraph graph = getEmptyMGraph();
    Assert.assertEquals(0, graph.size());
    final TripleImpl triple1 = new TripleImpl(uriRef1, uriRef2, uriRef1);
    graph.add(triple1);
    final TripleImpl triple2 = new TripleImpl(uriRef1, uriRef2, uriRef4);
    graph.add(triple2);
    Assert.assertEquals(2, graph.size());
    Iterator<Triple> iterator = graph.iterator();
    while (iterator.hasNext()) {
      iterator.next();
      iterator.remove();
    }
    Assert.assertEquals(0, graph.size());
  }
View Full Code Here

    Assert.assertEquals(0, graph.size());
  }

  @Test
  public void testGetSize() throws Exception {
    MGraph graph = getEmptyMGraph();
    // The test graph must always be empty after test fixture setup
    Assert.assertEquals(0, graph.size());
  }
View Full Code Here

  }


  @Test
  public void testAddSingleTriple() throws Exception {
    MGraph graph = getEmptyMGraph();
    final Triple triple= createTriple(
        "http://example.org/ontology/Person",
        "http://example.org/ontology/hasName",
        "http://example.org/people/alice");
    Assert.assertEquals(0, graph.size());
    Assert.assertTrue(graph.add(triple));
    Assert.assertEquals(1, graph.size());
  }
View Full Code Here

  }


  @Test
  public void testAddSameTripleTwice() throws Exception {
    MGraph graph = getEmptyMGraph();
    final Triple triple= createTriple(
        "http://example.org/ontology/Person",
        "http://example.org/ontology/hasName",
        "http://example.org/people/alice");
    Assert.assertEquals(0, graph.size());
    Assert.assertTrue(graph.add(triple));
    Assert.assertFalse(graph.add(triple)); // Graph does not change
    Assert.assertEquals(1, graph.size());
  }
View Full Code Here

  }


  @Test
  public void testRemoveSingleTriple() throws Exception {
    MGraph graph = getEmptyMGraph();
    final Triple triple= createTriple(
        "http://example.org/ontology/Person",
        "http://example.org/ontology/hasName",
        "http://example.org/people/alice");
    Assert.assertTrue(graph.add(triple));
    Assert.assertTrue(graph.remove(triple));
    Assert.assertEquals(0, graph.size());
  }
View Full Code Here

    Assert.assertEquals(0, graph.size());
  }

  @Test
  public void testRemoveSameTripleTwice() throws Exception {
    MGraph graph = getEmptyMGraph();
    final Triple tripleAlice= createTriple(
        "http://example.org/ontology/Person",
        "http://example.org/ontology/hasName",
        "http://example.org/people/alice");
    final Triple tripleBob= createTriple(
        "http://example.org/ontology/Person",
        "http://example.org/ontology/hasName",
        "http://example.org/people/bob");
    Assert.assertTrue(graph.add(tripleAlice));
    Assert.assertTrue(graph.add(tripleBob));
    Assert.assertTrue(graph.remove(tripleAlice));
    Assert.assertFalse(graph.remove(tripleAlice));
    Assert.assertEquals(1, graph.size());
  }
View Full Code Here

    Assert.assertEquals(1, graph.size());
  }

  @Test
  public void testGetSameBNode() throws Exception {
    MGraph graph = getEmptyMGraph();
    BNode bNode = new BNode();
    final UriRef HAS_NAME = new UriRef("http://example.org/ontology/hasName");
    final PlainLiteralImpl name = new PlainLiteralImpl("http://example.org/people/alice");
    final PlainLiteralImpl name2 = new PlainLiteralImpl("http://example.org/people/bob");
    final Triple tripleAlice = new TripleImpl(bNode, HAS_NAME, name);
    final Triple tripleBob = new TripleImpl(bNode, HAS_NAME, name2);
    Assert.assertTrue(graph.add(tripleAlice));
    Assert.assertTrue(graph.add(tripleBob));
    Iterator<Triple> result = graph.filter(null, HAS_NAME, name);
    Assert.assertEquals(bNode, result.next().getSubject());
  }
View Full Code Here

TOP

Related Classes of org.apache.clerezza.rdf.core.MGraph

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.